Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 79   Methods: 3
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CacheModeLocalSimpleTest.java 50% 100% 100% 94.6%
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.options;
 8   
 9    import junit.framework.TestCase;
 10    import org.jboss.cache.CacheImpl;
 11    import org.jboss.cache.DefaultCacheFactory;
 12    import org.jboss.cache.Fqn;
 13    import org.jboss.cache.config.Configuration;
 14    import org.jboss.cache.config.Option;
 15   
 16    import javax.transaction.TransactionManager;
 17   
 18    /**
 19    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 20    */
 21    public class CacheModeLocalSimpleTest extends TestCase
 22    {
 23    private CacheImpl cache1, cache2;
 24    private Option cacheModeLocal;
 25   
 26  1 public void setUp() throws Exception
 27    {
 28  1 cache1 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
 29  1 Configuration c = new Configuration();
 30  1 cache1.setConfiguration(c);
 31  1 c.setCacheMode("REPL_SYNC");
 32  1 c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
 33   
 34  1 cache2 = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
 35  1 c = new Configuration();
 36  1 cache2.setConfiguration(c);
 37  1 c.setCacheMode("REPL_SYNC");
 38  1 c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
 39   
 40  1 cache1.start();
 41  1 cache2.start();
 42   
 43  1 cacheModeLocal = new Option();
 44  1 cacheModeLocal.setCacheModeLocal(true);
 45    }
 46   
 47  1 public void tearDown()
 48    {
 49  1 if (cache1 != null)
 50    {
 51  1 cache1.stop();
 52  1 cache1 = null;
 53    }
 54   
 55  1 if (cache2 != null)
 56    {
 57  1 cache2.stop();
 58  1 cache2 = null;
 59    }
 60    }
 61   
 62  1 public void testCacheModeLocalWithTx() throws Exception
 63    {
 64  1 TransactionManager mgr = cache1.getTransactionManager();
 65  1 mgr.begin();
 66   
 67  1 cache1.put(Fqn.fromString("/replicate"), "k", "v");
 68  1 cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
 69  1 cache1.put(Fqn.fromString("/not-replicate"), "k", "v");
 70   
 71  1 mgr.commit();
 72   
 73  1 assertEquals("v", cache1.get("/replicate", "k"));
 74  1 assertEquals("v", cache1.get("/not-replicate", "k"));
 75   
 76  1 assertEquals("v", cache2.get("/replicate", "k"));
 77  1 assertNull(cache2.get("/not-replicate", "k"));
 78    }
 79    }