Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 96   Methods: 8
NCLOC: 63   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CacheFactoryTest.java 50% 100% 100% 97.2%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache;
 8   
 9    import junit.framework.TestCase;
 10    import org.jboss.cache.config.Configuration;
 11    import org.jboss.cache.factories.XmlConfigurationParser;
 12    import org.jboss.cache.lock.IsolationLevel;
 13   
 14    /**
 15    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 16    */
 17    public class CacheFactoryTest extends TestCase
 18    {
 19    Configuration expected;
 20    String configFile = "META-INF/replSync-service.xml";
 21    private CacheImpl cache;
 22   
 23  5 protected void setUp()
 24    {
 25  5 XmlConfigurationParser parser = new XmlConfigurationParser();
 26  5 expected = parser.parseFile(configFile);
 27    }
 28   
 29  5 protected void tearDown()
 30    {
 31  5 if (cache != null)
 32    {
 33  5 cache.stop();
 34    }
 35    }
 36   
 37  1 public void testFromConfigFileStarted()
 38    {
 39  1 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(configFile);
 40    // can't test for this anymore since the RuntimeConfig is attached to the running cache
 41    //assertEquals(expected, cache.getConfiguration());
 42   
 43  1 assertTrue("Should have started", cache.isStarted());
 44  1 doSimpleConfTests(cache.getConfiguration());
 45    }
 46   
 47  1 public void testFromConfigFileUnstarted()
 48    {
 49  1 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(configFile, false);
 50    // can't test for this anymore since the RuntimeConfig is attached to the running cache
 51    // assertEquals(expected, cache.getConfiguration());
 52   
 53  1 assertFalse("Should not have started", cache.isStarted());
 54   
 55  1 doSimpleConfTests(cache.getConfiguration());
 56    }
 57   
 58  1 public void testFromConfigObjStarted()
 59    {
 60  1 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(expected);
 61   
 62  1 assertTrue("Should have started", cache.isStarted());
 63   
 64  1 doSimpleConfTests(cache.getConfiguration());
 65    }
 66   
 67  1 public void testFromConfigObjUnstarted()
 68    {
 69  1 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(expected, false);
 70   
 71  1 assertFalse("Should not have started", cache.isStarted());
 72   
 73  1 doSimpleConfTests(cache.getConfiguration());
 74    }
 75   
 76  4 private void doSimpleConfTests(Configuration tc)
 77    {
 78  4 assertEquals(Configuration.CacheMode.REPL_SYNC, tc.getCacheMode());
 79  4 assertEquals(10000, tc.getLockAcquisitionTimeout());
 80  4 assertEquals(IsolationLevel.REPEATABLE_READ, tc.getIsolationLevel());
 81  4 assertEquals(true, tc.isUseRegionBasedMarshalling());
 82    // test some of the XML content.
 83    // assertEquals("UDP(ip_mcast=true;ip_ttl=64;loopback=false;mcast_addr=228.1.2.3;mcast_port=48866;mcast_recv_buf_size=80000;mcast_send_buf_size=150000;ucast_recv_buf_size=80000;ucast_send_buf_size=150000):PING(down_thread=false;num_initial_members=3;timeout=2000;up_thread=false):MERGE2(max_interval=20000;min_interval=10000):FD_SOCK:VERIFY_SUSPECT(down_thread=false;timeout=1500;up_thread=false):pbcast.NAKACK(down_thread=false;gc_lag=50;max_xmit_size=8192;retransmit_timeout=600,1200,2400,4800;up_thread=false):UNICAST(down_thread=false;min_threshold=10;timeout=600,1200,2400;window_size=100):pbcast.STABLE(desired_avg_gossip=20000;down_thread=false;up_thread=false):FRAG(down_thread=false;frag_size=8192;up_thread=false):pbcast.GMS(join_retry_timeout=2000;join_timeout=5000;print_local_addr=true;shun=true):pbcast.STATE_TRANSFER(down_thread=true;up_thread=true)", tc.getClusterConfig());
 84    }
 85   
 86  1 public void testLifecycle() throws Exception
 87    {
 88  1 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(expected, false);
 89  1 assertFalse(cache.isStarted());
 90  1 cache.start();
 91  1 assertTrue(cache.isStarted());
 92  1 cache.stop();
 93  1 assertFalse(cache.isStarted());
 94    }
 95   
 96    }