[jbosscache-commits] JBoss Cache SVN: r5516 - core/trunk/src/test/java/org/jboss/cache/invocationcontext.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Apr 8 18:35:36 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-04-08 18:35:36 -0400 (Tue, 08 Apr 2008)
New Revision: 5516

Modified:
   core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
Log:
[JBCACHE-1326] TxInterceptor leaks MethodCall to thread

Modified: core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java	2008-04-08 09:48:35 UTC (rev 5515)
+++ core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java	2008-04-08 22:35:36 UTC (rev 5516)
@@ -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();
+   }
 }




More information about the jbosscache-commits mailing list