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