Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 81   Methods: 4
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ConcurrentTransactionTest.java 50% 96.3% 100% 93.9%
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.optimistic;
 8   
 9    import org.jboss.cache.CacheImpl;
 10    import org.jboss.cache.Fqn;
 11    import org.jboss.cache.NodeSPI;
 12   
 13    import javax.transaction.Transaction;
 14    import javax.transaction.TransactionManager;
 15   
 16    /**
 17    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 18    */
 19    public class ConcurrentTransactionTest extends AbstractOptimisticTestCase
 20    {
 21    private CacheImpl cache;
 22   
 23  1 public ConcurrentTransactionTest(String name)
 24    {
 25  1 super(name);
 26    }
 27   
 28  1 protected void setUp()
 29    {
 30  1 try
 31    {
 32  1 cache = createCache();
 33    }
 34    catch (Exception e)
 35    {
 36  0 e.printStackTrace();
 37    }
 38    }
 39   
 40  1 protected void tearDown()
 41    {
 42  1 if (cache != null)
 43    {
 44  1 cache.stop();
 45  1 cache = null;
 46    }
 47    }
 48   
 49  1 public void testConcurrentTransactions() throws Exception
 50    {
 51  1 TransactionManager tm = cache.getTransactionManager();
 52  1 cache.put("/a/b/c/d", key, value);
 53   
 54  1 assertEquals(value, cache.get("/a/b/c/d", key));
 55   
 56  1 tm.begin();
 57  1 Transaction tx = tm.getTransaction();
 58   
 59  1 cache.put("/a/b/x/y", key, value);
 60  1 tm.suspend();
 61   
 62    // a number of random puts in unrelated sub nodes.
 63  1 cache.put("/a/b/c/d", key, value + value);
 64  1 cache.put("/a/b/c/e", key, value);
 65  1 cache.put("/a/b/c/f", key, value);
 66  1 cache.put("/a/b/c/g", key, value);
 67   
 68  1 assertEquals(value + value, cache.get("/a/b/c/d", key));
 69  1 assertEquals(value, cache.get("/a/b/c/e", key));
 70  1 assertEquals(value, cache.get("/a/b/c/f", key));
 71  1 assertEquals(value, cache.get("/a/b/c/g", key));
 72   
 73  1 tm.resume(tx);
 74  1 tx.commit();
 75   
 76  1 assertEquals(value, cache.get("/a/b/x/y", key));
 77   
 78  1 NodeSPI n = (NodeSPI) cache.get(Fqn.ROOT);
 79  1 System.out.println(n.getVersion());
 80    }
 81    }