[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/invocationcontext ...
Manik Surtani
msurtani at jboss.com
Wed Sep 6 07:40:29 EDT 2006
User: msurtani
Date: 06/09/06 07:40:29
Modified: tests/functional/org/jboss/cache/invocationcontext
TransactionTest.java
Log:
Added check to ensure tx and gtx are scrubbed after commit
Revision Changes Path
1.3 +27 -15 JBossCache/tests/functional/org/jboss/cache/invocationcontext/TransactionTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransactionTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/invocationcontext/TransactionTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- TransactionTest.java 6 Sep 2006 11:36:22 -0000 1.2
+++ TransactionTest.java 6 Sep 2006 11:40:29 -0000 1.3
@@ -5,11 +5,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.factories.DefaultCacheFactory;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import java.util.Map;
@@ -21,10 +16,12 @@
public class TransactionTest extends TestCase
{
private CacheSPI cache;
+ private TransactionManager tm;
protected void setUp()
{
cache = (CacheSPI) new DefaultCacheFactory().createCache("META-INF/local-tx-service.xml");
+ tm = cache.getTransactionManager();
}
protected void tearDown()
@@ -36,10 +33,8 @@
}
}
- public void testTxExistenceAfterWrite() throws SystemException, NotSupportedException, HeuristicMixedException, HeuristicRollbackException, RollbackException
+ public void testTxExistenceAfterWrite() throws Exception
{
- TransactionManager tm = cache.getTransactionManager();
-
// make sure we have a running transaction.
tm.begin();
@@ -47,7 +42,7 @@
assertNull("Gtx should not have been set up yet", cache.getInvocationContext().getGlobalTransaction());
// now make a WRITE call into the cache (should start a tx)
- cache.put(Fqn.ROOT, "k", "v");
+ cache.put("k", "v");
Map data = cache.getData();
assertEquals("Data map should not empty", 1, data.size());
@@ -57,15 +52,10 @@
assertNotNull("Gtx should have been set up by now", cache.getInvocationContext().getGlobalTransaction());
tm.commit();
-
- assertNull("Tx should have been scrubbed", cache.getInvocationContext().getTransaction());
- assertNull("Gtx should have been scrubbed", cache.getInvocationContext().getGlobalTransaction());
}
- public void testTxExistenceAfterRead() throws SystemException, NotSupportedException, HeuristicMixedException, HeuristicRollbackException, RollbackException
+ public void testTxExistenceAfterRead() throws Exception
{
- TransactionManager tm = cache.getTransactionManager();
-
// make sure we have a running transaction.
tm.begin();
@@ -82,6 +72,28 @@
assertNotNull("Gtx should have been set up by now", cache.getInvocationContext().getGlobalTransaction());
tm.commit();
+ }
+
+ public void testScrubbingAfterCommit() throws Exception
+ {
+ doScrubbingTest(true);
+ }
+
+ public void testScrubbingAfterRollback() throws Exception
+ {
+ doScrubbingTest(false);
+ }
+
+ private void doScrubbingTest(boolean commit) throws Exception
+ {
+ tm.begin();
+ cache.put("key", "value");
+ assertNotNull("Tx should have been set up by now", cache.getInvocationContext().getTransaction());
+ assertEquals("The same current transaction should be associated with this invocation ctx.", tm.getTransaction(), cache.getInvocationContext().getTransaction());
+ assertNotNull("Gtx should have been set up by now", cache.getInvocationContext().getGlobalTransaction());
+
+ if (commit) tm.commit();
+ else tm.rollback();
assertNull("Tx should have been scrubbed", cache.getInvocationContext().getTransaction());
assertNull("Gtx should have been scrubbed", cache.getInvocationContext().getGlobalTransaction());
More information about the jboss-cvs-commits
mailing list