[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/config ...
Brian Stansberry
brian.stansberry at jboss.com
Wed May 9 14:32:08 EDT 2007
User: bstansberry
Date: 07/05/09 14:32:08
Added: tests/functional/org/jboss/cache/config
ChannelInjectionTest.java
Log:
[JBCACHE--1023] Inject preconfigured Channel
Revision Changes Path
1.1 date: 2007/05/09 18:32:08; author: bstansberry; state: Exp;JBossCache/tests/functional/org/jboss/cache/config/ChannelInjectionTest.java
Index: ChannelInjectionTest.java
===================================================================
package org.jboss.cache.config;
import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.misc.TestingUtil;
import org.jgroups.JChannel;
/**
* Tests that JBC prefers an injected Channel to creating one via
* a configured JChannelFactory and stack name.
*
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
* @version $Revision: 1.1 $
*/
public class ChannelInjectionTest extends TestCase
{
private Set<Cache> caches = new HashSet();
public void tearDown() throws Exception
{
super.tearDown();
for (Cache cache : caches)
{
try
{
cache.stop();
}
catch (Exception e)
{
e.printStackTrace(System.out);
}
}
}
public void testChannelInjectionPreference() throws Exception
{
Cache cache1 = createCache();
Cache cache2 = createCache();
JChannel ch1 = new JChannel(JChannel.DEFAULT_PROTOCOL_STACK);
cache1.getConfiguration().getRuntimeConfig().setChannel(ch1);
JChannel ch2 = new JChannel(JChannel.DEFAULT_PROTOCOL_STACK);
cache2.getConfiguration().getRuntimeConfig().setChannel(ch2);
cache1.start();
cache2.start();
TestingUtil.blockUntilViewsReceived(new Cache[] { cache1, cache2 }, 10000);
Fqn fqn = Fqn.fromString("/a");
cache1.put(fqn, "key", "value");
assertEquals("Value replicated", "value", cache2.get(fqn, "key"));
}
private Cache createCache() throws Exception
{
Configuration config = new Configuration();
config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
Cache cache = DefaultCacheFactory.getInstance().createCache(config, false);
caches.add(cache);
return cache;
}
}
More information about the jboss-cvs-commits
mailing list