Author: bstansberry(a)jboss.com
Date: 2008-04-08 18:38:03 -0400 (Tue, 08 Apr 2008)
New Revision: 5517
Modified:
core/branches/2.1.X/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
Log:
[JBCACHE-1326] TxInterceptor leaks MethodCall to thread
Modified:
core/branches/2.1.X/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
===================================================================
---
core/branches/2.1.X/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-04-08
22:35:36 UTC (rev 5516)
+++
core/branches/2.1.X/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-04-08
22:38:03 UTC (rev 5517)
@@ -3,6 +3,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration.CacheMode;
+
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -85,13 +87,30 @@
doScrubbingTest(true);
}
+ public void testScrubbingAfterOnePhaseCommit() throws Exception
+ {
+ setUpOnePhaseCache();
+
+ doScrubbingTest(true);
+ }
+
public void testScrubbingAfterRollback() throws Exception
{
doScrubbingTest(false);
}
+ public void testScrubbingAfterOnePhaseRollback() throws Exception
+ {
+ setUpOnePhaseCache();
+
+ doScrubbingTest(true);
+ }
+
private void doScrubbingTest(boolean commit) throws Exception
{
+ // Start clean
+ cache.getInvocationContext().reset();
+
tm.begin();
cache.getRoot().put("key", "value");
assertNotNull("Tx should have been set up by now",
cache.getInvocationContext().getTransaction());
@@ -109,5 +128,20 @@
assertNull("Tx should have been scrubbed",
cache.getInvocationContext().getTransaction());
assertNull("Gtx should have been scrubbed",
cache.getInvocationContext().getGlobalTransaction());
+ assertEquals("MethodCall should have been scrubbed", null,
cache.getInvocationContext().getMethodCall());
}
+
+ private void setUpOnePhaseCache()
+ {
+ if (cache != null)
+ {
+ cache.stop();
+ cache = null;
+ }
+
+ cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache("META-INF/conf-test/replSync-service.xml",
false);
+ cache.getConfiguration().setCacheMode(CacheMode.REPL_ASYNC);
+ cache.start();
+ tm = cache.getTransactionManager();
+ }
}
Show replies by date