Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 111   Methods: 7
NCLOC: 90   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
IsolationLevelNoneTest.java 50% 100% 100% 98.2%
coverage coverage
 1    package org.jboss.cache.transaction;
 2   
 3    import junit.framework.Test;
 4    import junit.framework.TestCase;
 5    import junit.framework.TestSuite;
 6    import org.jboss.cache.CacheImpl;
 7    import org.jboss.cache.DefaultCacheFactory;
 8    import org.jboss.cache.DummyTransactionManagerLookup;
 9    import org.jboss.cache.Fqn;
 10    import org.jboss.cache.config.Configuration;
 11    import org.jboss.cache.lock.IsolationLevel;
 12   
 13    import javax.transaction.NotSupportedException;
 14    import javax.transaction.SystemException;
 15    import javax.transaction.Transaction;
 16   
 17    /**
 18    * Tests whether modifications within callbacks (TreeCacheListener) are handled correctly
 19    *
 20    * @author Bela Ban
 21    * @version $Id: IsolationLevelNoneTest.java,v 1.7 2007/01/11 13:49:06 msurtani Exp $
 22    */
 23    public class IsolationLevelNoneTest extends TestCase
 24    {
 25    CacheImpl cache = null;
 26    final Fqn FQN = Fqn.fromString("/a/b/c");
 27    final String KEY = "key";
 28    final String VALUE = "value";
 29    Transaction tx;
 30   
 31   
 32  3 protected void setUp() throws Exception
 33    {
 34  3 super.setUp();
 35    }
 36   
 37  3 protected void tearDown() throws Exception
 38    {
 39  3 super.tearDown();
 40  3 if (cache != null)
 41    {
 42  3 cache.stop();
 43  3 cache.destroy();
 44  3 cache = null;
 45    }
 46    }
 47   
 48   
 49  1 public void testWithoutTransactions() throws Exception
 50    {
 51  1 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
 52  1 cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
 53  1 cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE);
 54  1 cache.start();
 55  1 cache.put(FQN, KEY, VALUE);
 56  1 cache.put(FQN + "/d", KEY, VALUE);
 57  1 assertTrue(cache.exists(FQN, KEY));
 58  1 assertEquals(VALUE, cache.get(FQN, KEY));
 59  1 System.out.println("cache: " + cache.toString(true) + ", locks: " + cache.printLockInfo());
 60  1 assertEquals(0, cache.getNumberOfLocksHeld());
 61    }
 62   
 63  1 public void testWithTransactions() throws Exception
 64    {
 65  1 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
 66  1 cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
 67  1 cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE);
 68  1 cache.setTransactionManagerLookup(new DummyTransactionManagerLookup());
 69  1 cache.start();
 70  1 tx = startTransaction();
 71  1 cache.put(FQN, KEY, VALUE);
 72  1 cache.put(FQN + "/d", KEY, VALUE);
 73  1 assertTrue(cache.exists(FQN, KEY));
 74  1 assertEquals(VALUE, cache.get(FQN, KEY));
 75  1 System.out.println("cache: " + cache.toString(true) + ", locks: " + cache.printLockInfo());
 76  1 assertEquals(0, cache.getNumberOfLocksHeld());
 77  1 tx.commit();
 78    }
 79   
 80   
 81  1 public void testWithTransactionsRepeatableRead() throws Exception
 82    {
 83  1 cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
 84  1 cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
 85  1 cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
 86  1 cache.setTransactionManagerLookup(new DummyTransactionManagerLookup());
 87  1 cache.start();
 88  1 tx = startTransaction();
 89  1 cache.put(FQN, KEY, VALUE);
 90  1 cache.put(FQN + "/d", KEY, VALUE);
 91  1 assertTrue(cache.exists(FQN, KEY));
 92  1 assertEquals(VALUE, cache.get(FQN, KEY));
 93  1 System.out.println("cache: " + cache.toString(true) + ", locks: " + cache.printLockInfo());
 94  1 assertEquals(5, cache.getNumberOfLocksHeld());
 95  1 tx.commit();
 96    }
 97   
 98  2 private Transaction startTransaction() throws SystemException, NotSupportedException
 99    {
 100  2 DummyTransactionManager mgr = DummyTransactionManager.getInstance();
 101  2 mgr.begin();
 102  2 return mgr.getTransaction();
 103    }
 104   
 105  1 public static Test suite()
 106    {
 107  1 return new TestSuite(IsolationLevelNoneTest.class);
 108    }
 109   
 110   
 111    }