Clover coverage report -
Coverage timestamp: Wed Jan 31 2007 15:38:53 EST
file stats: LOC: 64   Methods: 2
NCLOC: 39   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ValidationFailureTest.java - 95.2% 100% 95.7%
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   
 11    import javax.transaction.Transaction;
 12    import javax.transaction.TransactionManager;
 13   
 14    /**
 15    * Tests a failure in validating a concurrently updated node
 16    *
 17    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 18    */
 19    public class ValidationFailureTest extends AbstractOptimisticTestCase
 20    {
 21  1 public ValidationFailureTest(String name)
 22    {
 23  1 super(name);
 24    }
 25   
 26  1 public void testValidationFailureLockRelease() throws Exception
 27    {
 28  1 CacheImpl cache = createCache();
 29   
 30  1 TransactionManager mgr = cache.getTransactionManager();
 31   
 32  1 mgr.begin();
 33  1 cache.put("/a", "key", "value");
 34  1 mgr.commit();
 35   
 36    // should succeed, 0 locks left over
 37  1 assertEquals("value", cache.get("/a", "key"));
 38  1 assertEquals(0, cache.getNumberOfLocksHeld());
 39   
 40  1 mgr.begin();
 41  1 cache.put("/b", "key", "value");
 42  1 Transaction tx1 = mgr.suspend();
 43   
 44  1 mgr.begin();
 45  1 cache.put("/b", "key", "value2");
 46  1 mgr.commit();
 47   
 48  1 mgr.resume(tx1);
 49  1 try
 50    {
 51  1 mgr.commit();
 52  0 assertTrue("Should have failed", false);
 53    }
 54    catch (Exception e)
 55    {
 56  1 assertTrue("Expecting this to fail", true);
 57    }
 58   
 59    // nothing should have been locked.
 60  1 assertEquals(0, cache.getNumberOfLocksHeld());
 61   
 62  1 destroyCache(cache);
 63    }
 64    }