Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 52   Methods: 3
NCLOC: 33   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
InterceptorCacheReferenceTest.java - 100% 100% 100%
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.interceptors;
 8   
 9    import junit.framework.TestCase;
 10    import org.jboss.cache.Cache;
 11    import org.jboss.cache.CacheSPI;
 12    import org.jboss.cache.DefaultCacheFactory;
 13    import org.jboss.cache.config.Configuration;
 14   
 15    /**
 16    * Tests that all interceptors in a given interceptor chain have the same cache instance.
 17    *
 18    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 19    */
 20    public class InterceptorCacheReferenceTest extends TestCase
 21    {
 22  1 public void testPessLocking() throws Exception
 23    {
 24  1 Configuration c = new Configuration();
 25  1 c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
 26  1 Cache cache = DefaultCacheFactory.getInstance().createCache(c);
 27   
 28  1 assertInterceptorsHaveSameCache((CacheSPI) cache);
 29   
 30  1 cache.stop();
 31    }
 32   
 33  1 public void testOptLocking() throws Exception
 34    {
 35  1 Configuration c = new Configuration();
 36  1 c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
 37  1 Cache cache = DefaultCacheFactory.getInstance().createCache(c);
 38   
 39  1 assertInterceptorsHaveSameCache((CacheSPI) cache);
 40   
 41  1 cache.stop();
 42    }
 43   
 44  2 private void assertInterceptorsHaveSameCache(CacheSPI c) throws Exception
 45    {
 46  2 for (Interceptor i : c.getInterceptorChain())
 47    {
 48  16 System.out.println("Testing " + i);
 49  16 assertSame(c, i.cache);
 50    }
 51    }
 52    }