Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Chu Yeow http://blog.codefront.net/

« Newer Snippets
Older Snippets »
Showing 11-12 of 12 total

Running a single test method with ZenTest

// HOWTO run a single test method.
// You need ZenTest installed (gem install ZenTest).

# Run ruby_fork in the background.
ruby_fork -rubygems -e 'require_gem "rails"' &

# Run a single test method.
ruby_fork_client -r test/functional/account_controller_test.rb -- -n test_unactivated_user_should_activate

JBossCache - unmarshalling cached objects across JVMs

JBossCache doesn't natively allow you to put and get objects across classloaders, so we need to marshal and unmarshal the objects with org.jboss.invocation.MarshalledValue.

private TreeCacheMBean cache;


void put(String path, Object key, Object value) throws Exception {
  cache.put(path, key, getMarshalledValue(value));

Object get(String path, Object key) throws Exception {
  return getUnMarshalledValue(cache.get(path, key));
}

private Object getUnMarshalledValue(Object value) throws IOException, ClassNotFoundException {
  return ((MarshalledValue) value).get();
}
    
private Object getMarshalledValue(Object value) throws IOException {
  return new MarshalledValue(value);
}
« Newer Snippets
Older Snippets »
Showing 11-12 of 12 total