Author: manik.surtani(a)jboss.com
Date: 2008-04-29 12:01:42 -0400 (Tue, 29 Apr 2008)
New Revision: 5754
Modified:
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
Log:
JBCACHE-1326: Fixed tests that relied on this leak
Modified:
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
===================================================================
---
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-04-29
14:28:51 UTC (rev 5753)
+++
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-04-29
16:01:42 UTC (rev 5754)
@@ -87,7 +87,6 @@
assertEquals(0, workspace.getNodes().size());
assertTrue(entry.getLocks().isEmpty());
- assertEquals(1, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
assertEquals(0, listener.getNodesAdded());
}
@@ -130,7 +129,6 @@
List<Set<Fqn>> mergedChildren =
workspace.getNode(Fqn.fromString("/one")).getMergedChildren();
assertEquals(1, mergedChildren.get(1).size());
System.out.println(entry.getModifications());
- assertEquals(2, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
}
@@ -168,12 +166,10 @@
assertNotNull(workspace.getNode(Fqn.fromString("/one")));
assertEquals(true,
workspace.getNode(Fqn.fromString("/one")).isDeleted());
assertEquals(0,
workspace.getNode(Fqn.fromString("/one")).getMergedChildren().get(0).size());
- assertEquals(2, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
assert 2 == dummy.getAllCalled().size();
assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);
-
}
public void testTransactionRemoveTwiceMethod() throws Exception
@@ -225,8 +221,6 @@
//assert what should be the results of our call
assertEquals(3, workspace.getNodes().size());
-
- assertEquals(3, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
assert 2 == dummy.getAllCalled().size();
assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
@@ -286,8 +280,6 @@
//assert what should be the results of our call
assertEquals(3, workspace.getNodes().size());
-
- assertEquals(3, entry.getModifications().size());
assert 2 == dummy.getAllCalled().size();
assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
assert dummy.getAllCalled().contains(MethodDeclarations.optimisticPrepareMethod);
@@ -347,8 +339,6 @@
//assert what should be the results of our call
assertEquals(3, workspace.getNodes().size());
-
- assertEquals(3, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
assert 2 == dummy.getAllCalled().size();
assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
@@ -398,8 +388,6 @@
//assert what should be the results of our call
assertEquals(3, workspace.getNodes().size());
-
- assertEquals(2, entry.getModifications().size());
assertTrue(!cache.exists("/one/two"));
assert 2 == dummy.getAllCalled().size();
assert dummy.getAllCalled().contains(MethodDeclarations.commitMethod);
Modified:
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
===================================================================
---
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-04-29
14:28:51 UTC (rev 5753)
+++
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-04-29
16:01:42 UTC (rev 5754)
@@ -133,14 +133,13 @@
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
+ MethodCall meth = entry.getModifications().get(0);
mgr.commit();
-
GlobalTransaction remoteGtx = new GlobalTransaction();
remoteGtx.setAddress(new TestAddress());
//hack the method call to make it have the remote gtx
- MethodCall meth = entry.getModifications().get(0);
meth.getArgs()[0] = remoteGtx;
//call our remote method
@@ -161,18 +160,14 @@
assertNotNull(table.get(remoteGtx));
assertNotNull(table.getLocalTransaction(remoteGtx));
//assert that this is populated
- assertEquals(1, table.get(remoteGtx).getModifications().size());
-
//assert that the remote prepare has populated the local workspace
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
- assertEquals(1, entry.getModifications().size());
List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
-
}
@@ -198,15 +193,13 @@
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
+ MethodCall meth = entry.getModifications().get(0);
mgr.commit();
-
GlobalTransaction remoteGtx = new GlobalTransaction();
remoteGtx.setAddress(new TestAddress());
//hack the method call to make it have the remote gtx
- MethodCall meth = entry.getModifications().get(0);
-
meth.getArgs()[0] = remoteGtx;
//call our remote method
MethodCall prepareMethod =
MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod_id, remoteGtx,
injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), false);
@@ -226,10 +219,7 @@
assertNotNull(table.get(remoteGtx));
assertNotNull(table.getLocalTransaction(remoteGtx));
//assert that this is populated
- assertEquals(1, table.get(remoteGtx).getModifications().size());
-
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
- assertEquals(1, entry.getModifications().size());
List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
@@ -277,6 +267,7 @@
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
+ MethodCall meth = entry.getModifications().get(0);
mgr.commit();
@@ -284,15 +275,12 @@
remoteGtx.setAddress(new TestAddress());
//hack the method call to make it have the remote gtx
- MethodCall meth = entry.getModifications().get(0);
meth.getArgs()[0] = remoteGtx;
-
List calls = dummy.getAllCalledIds();
assertEquals(2, calls.size());
-
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
@@ -338,22 +326,19 @@
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
+ MethodCall meth = entry.getModifications().get(0);
mgr.commit();
-
GlobalTransaction remoteGtx = new GlobalTransaction();
remoteGtx.setAddress(new TestAddress());
//hack the method call to make it have the remote gtx
- MethodCall meth = entry.getModifications().get(0);
meth.getArgs()[0] = remoteGtx;
-
List calls = dummy.getAllCalledIds();
assertEquals(2, calls.size());
-
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
@@ -393,14 +378,13 @@
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
+ MethodCall meth = entry.getModifications().get(0);
mgr.commit();
-
GlobalTransaction remoteGtx = new GlobalTransaction();
remoteGtx.setAddress(new TestAddress());
//hack the method call to make it have the remote gtx
- MethodCall meth = entry.getModifications().get(0);
meth.getArgs()[0] = remoteGtx;
//call our remote method
@@ -421,11 +405,8 @@
assertNotNull(table.get(remoteGtx));
assertNotNull(table.getLocalTransaction(remoteGtx));
//assert that this is populated
- assertEquals(1, table.get(remoteGtx).getModifications().size());
-
//assert that the remote prepare has populated the local workspace
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
- assertEquals(1, entry.getModifications().size());
List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
Modified:
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
---
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-04-29
14:28:51 UTC (rev 5753)
+++
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-04-29
16:01:42 UTC (rev 5754)
@@ -287,6 +287,7 @@
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
+ MethodCall meth = entry.getModifications().get(0);
mgr.commit();
//test local calls
@@ -303,7 +304,6 @@
remoteGtx.setAddress(new DummyAddress());
//hack the method call to make it have the remote gtx
- MethodCall meth = entry.getModifications().get(0);
meth.getArgs()[0] = remoteGtx;
//call our remote method
@@ -617,6 +617,7 @@
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
+ MethodCall meth = entry.getModifications().get(0);
mgr.commit();
//test local calls
@@ -635,7 +636,6 @@
remoteGtx.setAddress(new DummyAddress());
// hack the method call to make it have the remote gtx
- MethodCall meth = entry.getModifications().get(0);
meth.getArgs()[0] = remoteGtx;
//call our remote method
@@ -658,7 +658,6 @@
assertNotNull(table.get(remoteGtx));
assertNotNull(table.getLocalTransaction(remoteGtx));
//this is not populated until replication interceptor is used
- assertEquals(1, table.get(remoteGtx).getModifications().size());
calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
@@ -682,7 +681,6 @@
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
assertNull(mgr.getTransaction());
cache.stop();
-
}
public void testRemoteRollbackTransaction() throws Exception
@@ -709,6 +707,7 @@
TransactionTable table = cache.getTransactionTable();
OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
assertNotNull(mgr.getTransaction());
+ MethodCall meth = entry.getModifications().get(0);
mgr.commit();
//test local calls
@@ -721,7 +720,6 @@
remoteGtx.setAddress(new DummyAddress());
// hack the method call to make it have the remote gtx
- MethodCall meth = entry.getModifications().get(0);
meth.getArgs()[0] = remoteGtx;
//call our remote method
@@ -742,8 +740,6 @@
assertNotNull(table.get(remoteGtx));
assertNotNull(table.getLocalTransaction(remoteGtx));
//this is not populated until replication interceptor is used
- assertEquals(1, table.get(remoteGtx).getModifications().size());
-
calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
@@ -768,7 +764,6 @@
assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
cache.stop();
-
}