Author: manik.surtani(a)jboss.com
Date: 2007-09-14 13:18:10 -0400 (Fri, 14 Sep 2007)
New Revision: 4464
Modified:
core/branches/1.4.X/tests/functional/org/jboss/cache/transaction/AsyncRollbackTxLockTest.java
Log:
Enhanced test for JBCACHE-1183
Modified:
core/branches/1.4.X/tests/functional/org/jboss/cache/transaction/AsyncRollbackTxLockTest.java
===================================================================
---
core/branches/1.4.X/tests/functional/org/jboss/cache/transaction/AsyncRollbackTxLockTest.java 2007-09-14
16:00:29 UTC (rev 4463)
+++
core/branches/1.4.X/tests/functional/org/jboss/cache/transaction/AsyncRollbackTxLockTest.java 2007-09-14
17:18:10 UTC (rev 4464)
@@ -2,6 +2,7 @@
import junit.framework.TestCase;
import org.jboss.cache.TreeCache;
+import org.jboss.cache.lock.LockingException;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
@@ -9,7 +10,18 @@
import javax.transaction.TransactionManager;
/**
- * Test behaviour of async rollback timeouted transaction
+ * Test behaviour of async rollback of a tx that times out and subsequent operations on
that transaction.
+ * <p/>
+ * NOTE: To run this test, add the following lines:
+ * <p/>
+ * <tt>
+ * <p/>
+ * <p/>
+ * if ("Thread-0".equals(Thread.currentThread().getName()))
Thread.sleep(1500);
+ * <p/>
+ * </tt>
+ * <p/>
+ * to the first line of PessimistickLockInterceptor#recordNodeLock()
*
* @author <a href="mailto:jhalat@infovide.pl">Jacek Halat</a>
*/
@@ -78,7 +90,15 @@
});
assertNotNull(tm.getTransaction());
Thread.sleep(500);//transaction should be rolledback in another thread
- cache.put("/a", "k", "v");
+ try
+ {
+ cache.put("/a", "k", "v");
+ }
+ catch (LockingException expected)
+ {
+ // this is normal; the tx would have timed out and obtaining locks for this tx
should fail.
+ }
+
tm.rollback();
assertNull(tm.getTransaction());
assertEquals(0, cache.getNumberOfLocksHeld());