1 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 19 public class ValidationFailureTest extends AbstractOptimisticTestCase 20 { 21 public ValidationFailureTest(String name) 22 { 23 super(name); 24 } 25 26 public void testValidationFailureLockRelease() throws Exception 27 { 28 CacheImpl cache = createCache(); 29 30 TransactionManager mgr = cache.getTransactionManager(); 31 32 mgr.begin(); 33 cache.put("/a", "key", "value"); 34 mgr.commit(); 35 36 assertEquals("value", cache.get("/a", "key")); 38 assertEquals(0, cache.getNumberOfLocksHeld()); 39 40 mgr.begin(); 41 cache.put("/b", "key", "value"); 42 Transaction tx1 = mgr.suspend(); 43 44 mgr.begin(); 45 cache.put("/b", "key", "value2"); 46 mgr.commit(); 47 48 mgr.resume(tx1); 49 try 50 { 51 mgr.commit(); 52 assertTrue("Should have failed", false); 53 } 54 catch (Exception e) 55 { 56 assertTrue("Expecting this to fail", true); 57 } 58 59 assertEquals(0, cache.getNumberOfLocksHeld()); 61 62 destroyCache(cache); 63 } 64 } 65 | Popular Tags |