[jboss-cvs] JBossCache/tests/functional/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Tue Jul 18 14:28:39 EDT 2006
User: msurtani
Date: 06/07/18 14:28:39
Added: tests/functional/org/jboss/cache CacheFactoryTest.java
Log:
Cache construction tests
Revision Changes Path
1.1 date: 2006/07/18 18:28:39; author: msurtani; state: Exp;JBossCache/tests/functional/org/jboss/cache/CacheFactoryTest.java
Index: CacheFactoryTest.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache;
import junit.framework.TestCase;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationImpl;
import org.jboss.cache.factories.CacheFactory;
import org.jboss.cache.factories.DefaultCacheFactory;
/**
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
public class CacheFactoryTest extends TestCase
{
CacheFactory factory;
Configuration expected;
String configFile = "META-INF/replSync-service.xml";
private TreeCacheProxyImpl cache;
protected void setUp()
{
factory = new DefaultCacheFactory();
expected = new ConfigurationImpl();
((ConfigurationImpl) expected).readConfiguration(Thread.currentThread().getContextClassLoader().getResourceAsStream(configFile));
}
protected void tearDown()
{
if (cache != null && cache.treeCache != null && cache.treeCache.started)
{
cache.stop();
}
}
public void testFromConfigFileStarted()
{
cache = (TreeCacheProxyImpl) factory.createCache(configFile);
assertEquals(expected, cache.getConfiguration());
// get a hold of the underlying TreeCache
TreeCache tc = cache.treeCache;
assertTrue("Should have started", tc.started);
doSimpleConfTests(tc);
}
public void testFromConfigFileUnstarted()
{
cache = (TreeCacheProxyImpl) factory.createCache(configFile, false);
assertEquals(expected, cache.getConfiguration());
// get a hold of the underlying TreeCache
TreeCache tc = cache.treeCache;
assertFalse("Should not have started", tc.started);
doSimpleConfTests(tc);
}
public void testFromConfigObjStarted()
{
cache = (TreeCacheProxyImpl) factory.createCache(expected);
// get a hold of the underlying TreeCache
TreeCache tc = cache.treeCache;
assertTrue("Should have started", tc.started);
doSimpleConfTests(tc);
}
public void testFromConfigObjUnstarted()
{
cache = (TreeCacheProxyImpl) factory.createCache(expected, false);
// get a hold of the underlying TreeCache
TreeCache tc = cache.treeCache;
assertFalse("Should not have started", tc.started);
doSimpleConfTests(tc);
}
private void doSimpleConfTests(TreeCache tc)
{
assertEquals("REPL_SYNC", tc.getCacheMode());
assertEquals(10000, tc.getLockAcquisitionTimeout());
assertEquals("REPEATABLE_READ", tc.getIsolationLevel());
assertEquals(true, tc.getUseRegionBasedMarshalling());
}
public void testLifecycle() throws Exception
{
cache = (TreeCacheProxyImpl) factory.createCache(expected, false);
assertFalse(cache.treeCache.started);
cache.start();
assertTrue(cache.treeCache.started);
cache.stop();
assertFalse(cache.treeCache.started);
}
}
More information about the jboss-cvs-commits
mailing list