Author: manik.surtani(a)jboss.com
Date: 2008-01-04 09:38:52 -0500 (Fri, 04 Jan 2008)
New Revision: 4982
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java
core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
Log:
Patched some tests that should expect ids instead of methods
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java 2008-01-04
14:24:13 UTC (rev 4981)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java 2008-01-04
14:38:52 UTC (rev 4982)
@@ -20,7 +20,8 @@
public class MockFailureInterceptor extends Interceptor
{
private List<Method> allCalled = new ArrayList<Method>();
- private List failurelist = new ArrayList();
+ private List<Method> failurelist = new ArrayList<Method>();
+ private List<Integer> allCalledIdsList = new ArrayList<Integer>();
@Override
public Object invoke(InvocationContext ctx) throws Throwable
@@ -30,6 +31,7 @@
{
if (failurelist.contains(m.getMethod())) throw new Exception("Failure in
method " + m);
allCalled.add(m.getMethod());
+ allCalledIdsList.add(m.getMethodId());
}
return null;
@@ -38,7 +40,7 @@
/**
* @return Returns the failurelist.
*/
- public List getFailurelist()
+ public List<Method> getFailurelist()
{
return failurelist;
}
@@ -46,7 +48,7 @@
/**
* @param failurelist The failurelist to set.
*/
- public void setFailurelist(List failurelist)
+ public void setFailurelist(List<Method> failurelist)
{
this.failurelist = failurelist;
}
@@ -66,4 +68,9 @@
{
this.allCalled = called;
}
+
+ public List<Integer> getAllCalledIds()
+ {
+ return allCalledIdsList;
+ }
}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java 2008-01-04
14:24:13 UTC (rev 4981)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java 2008-01-04
14:38:52 UTC (rev 4982)
@@ -22,6 +22,7 @@
private Method called = null;
private List<Method> calledlist = new ArrayList<Method>();
+ private List<Integer> calledIdsList = new ArrayList<Integer>();
@Override
public synchronized Object invoke(InvocationContext ctx) throws Throwable
@@ -30,6 +31,7 @@
if (!MethodDeclarations.isBlockUnblockMethod(m.getMethodId()))
{
calledlist.add(m.getMethod());
+ calledIdsList.add(m.getMethodId());
called = m.getMethod();
}
@@ -49,6 +51,11 @@
return calledlist;
}
+ public List<Integer> getAllCalledIds()
+ {
+ return calledIdsList;
+ }
+
/**
* @param called The called to set.
*/
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-01-04
14:24:13 UTC (rev 4981)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-01-04
14:38:52 UTC (rev 4982)
@@ -79,7 +79,7 @@
//make sure all calls were done in right order
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
@@ -105,7 +105,7 @@
//make sure all calls were done in right order
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(1, calls.size());
assertEquals(MethodDeclarations.rollbackMethod_id, calls.get(0));
@@ -166,7 +166,7 @@
//assert that the remote prepare has populated the local workspace
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
assertEquals(1, entry.getModifications().size());
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
@@ -230,7 +230,7 @@
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
assertEquals(1, entry.getModifications().size());
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
@@ -289,7 +289,7 @@
meth.getArgs()[0] = remoteGtx;
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(2, calls.size());
@@ -350,7 +350,7 @@
meth.getArgs()[0] = remoteGtx;
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(2, calls.size());
@@ -426,7 +426,7 @@
//assert that the remote prepare has populated the local workspace
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
assertEquals(1, entry.getModifications().size());
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
@@ -491,12 +491,12 @@
assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
- List calls2 = dummy2.getAllCalled();
+ List calls2 = dummy2.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls2.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls2.get(1));
@@ -554,12 +554,12 @@
assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.rollbackMethod_id, calls.get(1));
//we have no prepare - as it failed - but we have a commit
- List calls2 = dummy2.getAllCalled();
+ List calls2 = dummy2.getAllCalledIds();
assertEquals(MethodDeclarations.rollbackMethod_id, calls2.get(0));
destroyCache(cache2);
@@ -618,11 +618,11 @@
assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
- List calls = dummy.getAllCalled();
+ List calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.rollbackMethod_id, calls.get(0));
//we have no prepare - as it failed - but we have a commit
- List calls2 = dummy2.getAllCalled();
+ List calls2 = dummy2.getAllCalledIds();
assertEquals(0, calls2.size());
destroyCache(cache2);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-01-04
14:24:13 UTC (rev 4981)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-01-04
14:38:52 UTC (rev 4982)
@@ -53,7 +53,7 @@
//make sure all calls were done in right order
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
@@ -88,7 +88,7 @@
assertNull(mgr.getTransaction());
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
@@ -119,7 +119,7 @@
assertNull(mgr.getTransaction());
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(1, calls.size());
assertEquals(MethodDeclarations.rollbackMethod_id, calls.get(0));
@@ -206,7 +206,7 @@
assertNull(mgr.getTransaction());
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
boolean failed = false;
@@ -253,7 +253,7 @@
assertNull(mgr.getTransaction());
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
@@ -290,7 +290,7 @@
mgr.commit();
//test local calls
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
assertNull(mgr.getTransaction());
@@ -325,7 +325,7 @@
assertNotNull(table.getLocalTransaction(remoteGtx));
//assert that the method has been passed up the stack
- calls = dummy.getAllCalled();
+ calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
//assert we have the tx in th table
@@ -386,7 +386,7 @@
assertNotNull(table.getLocalTransaction(remoteGtx));
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
//assert we have two current transactions
@@ -397,7 +397,7 @@
mgr.commit();
//check local calls
- calls = dummy.getAllCalled();
+ calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(1));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(2));
@@ -483,7 +483,7 @@
assertNull(table.get(remoteGtx));
assertNull(table.getLocalTransaction(remoteGtx));
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
@@ -493,7 +493,7 @@
//commit the local tx
mgr.commit();
- calls = dummy.getAllCalled();
+ calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(3));
@@ -571,7 +571,7 @@
assertNull(table.get(remoteGtx));
assertNull(table.getLocalTransaction(remoteGtx));
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.rollbackMethod_id, calls.get(1));
@@ -581,7 +581,7 @@
//commit the local tx
mgr.commit();
- calls = dummy.getAllCalled();
+ calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(3));
@@ -620,7 +620,7 @@
mgr.commit();
//test local calls
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
@@ -660,7 +660,7 @@
//this is not populated until replication interceptor is used
assertEquals(1, table.get(remoteGtx).getModifications().size());
- calls = dummy.getAllCalled();
+ calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
assertNull(mgr.getTransaction());
@@ -712,7 +712,7 @@
mgr.commit();
//test local calls
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));
@@ -744,7 +744,7 @@
//this is not populated until replication interceptor is used
assertEquals(1, table.get(remoteGtx).getModifications().size());
- calls = dummy.getAllCalled();
+ calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
// call our remote method
@@ -758,7 +758,7 @@
fail();
}
- calls = dummy.getAllCalled();
+ calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(2));
assertEquals(MethodDeclarations.rollbackMethod_id, calls.get(3));
@@ -800,7 +800,7 @@
mgr.commit();
- List<?> calls = dummy.getAllCalled();
+ List<?> calls = dummy.getAllCalledIds();
assertEquals(MethodDeclarations.optimisticPrepareMethod_id, calls.get(0));
assertEquals(MethodDeclarations.commitMethod_id, calls.get(1));