Author: manik.surtani(a)jboss.com
Date: 2008-05-12 12:32:31 -0400 (Mon, 12 May 2008)
New Revision: 5829
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
Log:
Fixed broken tests
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -26,6 +26,7 @@
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionSetup;
import org.jboss.cache.xml.XmlHelper;
import org.jgroups.Address;
@@ -34,6 +35,7 @@
import org.w3c.dom.Element;
import javax.transaction.SystemException;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -88,6 +90,14 @@
return createCacheWithLoader(false);
}
+ protected void setupTransactions(CacheSPI cache, Transaction tx)
+ {
+ cache.getInvocationContext().setTransaction(tx);
+ GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
+ cache.getInvocationContext().setGlobalTransaction(gtx);
+
cache.getInvocationContext().setTransactionEntry(cache.getTransactionTable().get(gtx));
+ }
+
protected CacheLoaderConfig getCacheLoaderConfig(boolean shared, boolean passivation)
throws Exception
{
String xml = " <config>\n" +
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -65,11 +65,8 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
-
SamplePojo pojo = new SamplePojo(21, "test");
cache.put("/one/two", "key1", pojo);
@@ -103,9 +100,7 @@
Transaction tx2 = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2,
true));
+ setupTransactions(cache, tx2);
assertEquals(0, cache.getRoot().getChildrenNames().size());
mgr.commit();
@@ -117,11 +112,8 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
-
assertEquals(null, dummy.getCalledCommand());
TransactionTable table = cache.getTransactionTable();
@@ -146,9 +138,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -59,8 +59,7 @@
Transaction tx = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -96,8 +95,7 @@
Transaction tx2 = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2,
true));
+ setupTransactions(cache, tx2);
assertNull(cache.get("/one/two", "key1"));
mgr.commit();
@@ -109,8 +107,7 @@
Transaction tx = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -143,14 +140,14 @@
assertEquals(null, dummy.getCalledCommand());
}
+
public void testTransactionGetKeyValOverwriteNullMethod() throws Exception
{
mgr.begin();
Transaction tx = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -189,8 +186,7 @@
Transaction tx = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -204,8 +200,7 @@
mgr.begin();
Transaction tx2 = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2,
true));
+ setupTransactions(cache, tx2);
SamplePojo pojo2 = new SamplePojo(22, "test2");
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -58,9 +58,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -95,9 +93,7 @@
Transaction tx2 = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2,
true));
+ setupTransactions(cache, tx2);
assertNull(cache.get("/one/two", "key1"));
mgr.commit();
@@ -110,11 +106,8 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
-
assertEquals(null, dummy.getCalledCommand());
TransactionTable table = cache.getTransactionTable();
@@ -138,11 +131,8 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
-
SamplePojo pojo = new SamplePojo(21, "test");
cache.put("/one/two", "key1", pojo);
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -58,9 +58,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -94,9 +92,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -133,9 +129,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -171,9 +165,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -210,9 +202,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -224,8 +214,7 @@
//start a new transaction
mgr.begin();
Transaction tx2 = mgr.getTransaction();
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2,
true));
+ setupTransactions(cache, tx2);
SamplePojo pojo2 = new SamplePojo(21, "test");
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -61,9 +61,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -96,9 +94,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -134,9 +130,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -61,9 +61,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -98,9 +96,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -140,9 +136,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -61,9 +61,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
assert null == cache.getNode("/one/two");
@@ -93,9 +91,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
Map temp = new HashMap();
@@ -131,9 +127,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -172,9 +166,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -67,9 +67,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
cache.remove("/one/two", "keyOne");
@@ -98,9 +96,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -136,9 +132,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx,
true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java 2008-05-12
16:18:11 UTC (rev 5828)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java 2008-05-12
16:32:31 UTC (rev 5829)
@@ -53,9 +53,7 @@
entry = (OptimisticTransactionEntry) table.get(gtx);
workspace = entry.getTransactionWorkSpace();
- // set invocation context elements
- cache.getInvocationContext().setGlobalTransaction(gtx);
- cache.getInvocationContext().setTransaction(tx);
+ setupTransactions(cache, tx);
}
public void testNodeCreation() throws Exception
@@ -119,6 +117,7 @@
// we should now remove stuff from the InvocationCtx
cache.getInvocationContext().setGlobalTransaction(null);
cache.getInvocationContext().setTransaction(null);
+ cache.getInvocationContext().setTransactionEntry(null);
try
{