[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/transaction ...
Manik Surtani
msurtani at jboss.com
Wed Oct 11 09:30:40 EDT 2006
User: msurtani
Date: 06/10/11 09:30:40
Added: tests/functional/org/jboss/cache/transaction Tag:
Branch_JBossCache_1_4_0 SuspendTxTest.java
Log:
Revision Changes Path
No revision
No revision
1.1.2.1 +63 -0 JBossCache/tests/functional/org/jboss/cache/transaction/Attic/SuspendTxTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SuspendTxTest.java
===================================================================
RCS file: SuspendTxTest.java
diff -N SuspendTxTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SuspendTxTest.java 11 Oct 2006 13:30:40 -0000 1.1.2.1
@@ -0,0 +1,63 @@
+package org.jboss.cache.transaction;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.transaction.DummyTransactionManager;
+
+import javax.transaction.Transaction;
+
+public class SuspendTxTest extends TestCase {
+ TreeCache cache;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ cache=new TreeCache();
+ cache.setCacheMode("local");
+ cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
+ cache.createService();
+ cache.startService();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ cache.stopService();
+ cache.destroyService();
+ }
+
+ /**
+ * Tests that locks created when a transaction is suspended are independent
+ * from the transaction.
+ */
+ public void testSuspendedLocks() throws Exception {
+ DummyTransactionManager mgr=DummyTransactionManager.getInstance();
+ mgr.begin();
+
+ cache.put("/one/two", "key1", "val1");
+ int numLocksBefore = cache.getNumberOfLocksHeld();
+
+ Transaction tx = mgr.suspend();
+
+ // The currently is that the transaction is cached in the
+ // thread-local invocation context, if you uncomment the
+ // next two lines, the test will succeed.
+ // cache.getInvocationContext().setTransaction(null);
+ // cache.getInvocationContext().setGlobalTransaction(null);
+
+ cache.put("/a/b", "key1", "val1");
+ mgr.resume(tx);
+
+ assertEquals(numLocksBefore, cache.getNumberOfLocksHeld());
+ }
+
+
+ public static Test suite() {
+ return new TestSuite(SuspendTxTest.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+}
More information about the jboss-cvs-commits
mailing list