[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/optimistic ...
Manik Surtani
msurtani at jboss.com
Sat Nov 11 12:50:03 EST 2006
User: msurtani
Date: 06/11/11 12:50:03
Modified: tests/functional/org/jboss/cache/optimistic Tag:
Branch_JBossCache_1_4_0
OptimisticVersioningTest.java
TxInterceptorTest.java
AsyncFullStackInterceptorTest.java
OptimisticReplicationInterceptorTest.java
CacheTest.java AbstractOptimisticTestCase.java
Log:
JBCACHE-843
Revision Changes Path
No revision
No revision
1.3.4.1 +15 -11 JBossCache/tests/functional/org/jboss/cache/optimistic/OptimisticVersioningTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticVersioningTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/OptimisticVersioningTest.java,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -u -b -r1.3 -r1.3.4.1
--- OptimisticVersioningTest.java 14 Dec 2005 15:40:24 -0000 1.3
+++ OptimisticVersioningTest.java 11 Nov 2006 17:50:02 -0000 1.3.4.1
@@ -22,6 +22,21 @@
*/
public class OptimisticVersioningTest extends AbstractOptimisticTestCase
{
+ TreeCache cache1, cache2;
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ cache1 = createReplicatedCache(TreeCache.REPL_SYNC);
+ cache2 = createReplicatedCache(TreeCache.REPL_SYNC);
+ }
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ cache1.remove(Fqn.ROOT);
+ cache1.stopService();
+ cache2.remove(Fqn.ROOT);
+ cache2.stopService();
+ }
public OptimisticVersioningTest(String name)
{
super(name);
@@ -29,9 +44,6 @@
public void testVersionPropagation() throws Exception
{
- TreeCache cache1 = createReplicatedCache(TreeCache.REPL_SYNC);
- TreeCache cache2 = createReplicatedCache(TreeCache.REPL_SYNC);
-
Fqn fqn = Fqn.fromString("/a/b");
String key = "key";
@@ -53,15 +65,10 @@
Assert.assertEquals("value2", cache1.get(fqn, key));
Assert.assertEquals("value2", cache2.get(fqn, key));
Assert.assertEquals("Version info should have propagated", v1, v2);
-
- cache1.stop();
- cache2.stop();
}
public void testTwoCachesUpdatingSimultaneously() throws Exception
{
- TreeCache cache1 = createReplicatedCache(TreeCache.REPL_SYNC);
- TreeCache cache2 = createReplicatedCache(TreeCache.REPL_SYNC);
TransactionManager mgr1 = cache1.getTransactionManager();
TransactionManager mgr2 = cache2.getTransactionManager();
Transaction tx1, tx2;
@@ -109,8 +116,5 @@
v2 = ((OptimisticTreeNode) cache2.get(fqn)).getVersion();
Assert.assertEquals("Version info should have propagated", v1, v2);
-
- cache1.stop();
- cache2.stop();
}
}
1.11.2.1 +11 -7 JBossCache/tests/functional/org/jboss/cache/optimistic/TxInterceptorTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TxInterceptorTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/TxInterceptorTest.java,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -b -r1.11 -r1.11.2.1
--- TxInterceptorTest.java 16 May 2006 22:42:26 -0000 1.11
+++ TxInterceptorTest.java 11 Nov 2006 17:50:03 -0000 1.11.2.1
@@ -10,7 +10,11 @@
import org.jboss.cache.OptimisticTransactionEntry;
import org.jboss.cache.TransactionTable;
import org.jboss.cache.TreeCache;
-import org.jboss.cache.interceptors.*;
+import org.jboss.cache.interceptors.Interceptor;
+import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
+import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
+import org.jboss.cache.interceptors.OptimisticReplicationInterceptor;
+import org.jboss.cache.interceptors.TxInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -446,7 +450,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
@@ -553,7 +557,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
@@ -687,7 +691,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
@@ -826,7 +830,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
@@ -975,7 +979,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
@@ -1111,7 +1115,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
1.4.2.1 +79 -80 JBossCache/tests/functional/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AsyncFullStackInterceptorTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -b -r1.4 -r1.4.2.1
--- AsyncFullStackInterceptorTest.java 5 May 2006 12:06:58 -0000 1.4
+++ AsyncFullStackInterceptorTest.java 11 Nov 2006 17:50:03 -0000 1.4.2.1
@@ -2,9 +2,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
-import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCache;
import org.jboss.cache.loader.SamplePojo;
+import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.transaction.DummyTransactionManager;
import javax.transaction.Transaction;
@@ -313,84 +314,82 @@
destroyCache(cache2);
}
- public void testValidationFailCommit2Instances() throws Exception
- {
- groupIncreaser++;
- TreeCache cache = createAsyncReplicatedCache();
- TreeCache cache2 = createAsyncReplicatedCache();
-
- DummyTransactionManager mgr = DummyTransactionManager.getInstance();
- assertNull(mgr.getTransaction());
-
- mgr.begin();
- Transaction tx = mgr.getTransaction();
- assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
- assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
-
- SamplePojo pojo = new SamplePojo(21, "test");
-
- cache.put("/one/two", "key1", pojo);
-
- mgr.suspend();
-
- assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
- assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
-
- GlobalTransaction gtx = cache.getCurrentTransaction(tx);
- TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table
- .get(gtx);
-
-
- assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
- assertNull(mgr.getTransaction());
-
- mgr.begin();
-
- SamplePojo pojo2 = new SamplePojo(22, "test2");
-
- cache2.put("/one/two", "key1", pojo2);
-
- mgr.commit();
-
- // let async calls propagate
- TestingUtil.sleepThread((long)1000);
-
- assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
- assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
-
- mgr.resume(tx);
-
- boolean fail = false;
- try
- {
- mgr.commit();
- }
- catch (Exception e)
- {
- fail = true;
-
- }
-
- assertEquals(true, fail);
- assertNull(mgr.getTransaction());
- assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
- assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
-
- assertEquals(0, entry.getTransactionWorkSpace().getNodes().size());
-
- assertTrue(cache.exists(Fqn.fromString("/one/two")));
- assertNotNull(cache.get(Fqn.fromString("/")).getChild("one"));
- assertEquals(false, cache.get(Fqn.fromString("/")).getLock().isLocked());
- assertEquals(false, cache.get(Fqn.fromString("/one")).getLock().isLocked());
- assertEquals(false, cache.get(Fqn.fromString("/one/two")).getLock().isLocked());
- assertNotNull(cache.get(Fqn.fromString("/one")).getChild("two"));
- assertEquals(pojo2, cache.get(Fqn.fromString("/one/two"), "key1"));
-
- destroyCache(cache);
- destroyCache(cache2);
-
- }
+// public void testValidationFailCommit2Instances() throws Exception
+// {
+// groupIncreaser++;
+// TreeCache cache = createAsyncReplicatedCache();
+// TreeCache cache2 = createAsyncReplicatedCache();
+//
+// DummyTransactionManager mgr = DummyTransactionManager.getInstance();
+// assertNull(mgr.getTransaction());
+//
+// mgr.begin();
+// Transaction tx = mgr.getTransaction();
+// assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
+// assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
+//
+// SamplePojo pojo = new SamplePojo(21, "test");
+//
+// cache.put("/one/two", "key1", pojo);
+//
+// mgr.suspend();
+//
+// assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
+// assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
+//
+// GlobalTransaction gtx = cache.getCurrentTransaction(tx);
+// TransactionTable table = cache.getTransactionTable();
+// OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table
+// .get(gtx);
+//
+//
+// assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
+// assertNull(mgr.getTransaction());
+//
+// mgr.begin();
+//
+// SamplePojo pojo2 = new SamplePojo(22, "test2");
+//
+// cache2.put("/one/two", "key1", pojo2);
+//
+// mgr.commit();
+//
+// // let async calls propagate
+// TestingUtil.sleepThread((long)1000);
+//
+// assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
+// assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
+//
+// mgr.resume(tx);
+//
+// try
+// {
+// mgr.commit();
+// fail("Expecting to fail");
+// }
+// catch (Exception e)
+// {
+// // this is normal
+// }
+//
+// assertNull(mgr.getTransaction());
+// assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
+// assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
+//
+// assertEquals(0, entry.getTransactionWorkSpace().getNodes().size());
+//
+// assertTrue(cache.exists(Fqn.fromString("/one/two")));
+// assertNotNull(cache.get(Fqn.fromString("/")).getChild("one"));
+// assertEquals(false, cache.get(Fqn.fromString("/")).getLock().isLocked());
+// assertEquals(false, cache.get(Fqn.fromString("/one")).getLock().isLocked());
+// assertEquals(false, cache.get(Fqn.fromString("/one/two")).getLock().isLocked());
+// assertNotNull(cache.get(Fqn.fromString("/one")).getChild("two"));
+// assertEquals(pojo2, cache.get(Fqn.fromString("/one/two"), "key1"));
+//
+// destroyCache(cache);
+// destroyCache(cache2);
+//
+// }
protected TreeCache createAsyncReplicatedCache() throws Exception
{
1.12.2.1 +13 -5 JBossCache/tests/functional/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticReplicationInterceptorTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -b -r1.12 -r1.12.2.1
--- OptimisticReplicationInterceptorTest.java 16 May 2006 22:42:26 -0000 1.12
+++ OptimisticReplicationInterceptorTest.java 11 Nov 2006 17:50:03 -0000 1.12.2.1
@@ -10,7 +10,11 @@
import org.jboss.cache.OptimisticTransactionEntry;
import org.jboss.cache.TransactionTable;
import org.jboss.cache.TreeCache;
-import org.jboss.cache.interceptors.*;
+import org.jboss.cache.interceptors.Interceptor;
+import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
+import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
+import org.jboss.cache.interceptors.OptimisticReplicationInterceptor;
+import org.jboss.cache.interceptors.TxInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -20,7 +24,11 @@
import javax.transaction.RollbackException;
import javax.transaction.Transaction;
-import java.io.*;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;
@@ -235,7 +243,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
@@ -367,7 +375,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
@@ -763,7 +771,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
1.17.2.1 +17 -6 JBossCache/tests/functional/org/jboss/cache/optimistic/CacheTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/CacheTest.java,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -u -b -r1.17 -r1.17.2.1
--- CacheTest.java 16 May 2006 22:42:26 -0000 1.17
+++ CacheTest.java 11 Nov 2006 17:50:03 -0000 1.17.2.1
@@ -7,8 +7,16 @@
import junit.framework.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
-import org.jboss.cache.interceptors.*;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.GlobalTransaction;
+import org.jboss.cache.OptimisticTransactionEntry;
+import org.jboss.cache.TransactionTable;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.interceptors.Interceptor;
+import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
+import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
+import org.jboss.cache.interceptors.OptimisticReplicationInterceptor;
+import org.jboss.cache.interceptors.TxInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -19,7 +27,11 @@
import javax.transaction.RollbackException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
-import java.io.*;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.List;
public class CacheTest extends AbstractOptimisticTestCase
@@ -280,7 +292,7 @@
meth.getArgs()[0] = remoteGtx;
//call our remote method
- MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), Boolean.FALSE});
+ MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
try
{
cache._replicate(prepareMethod);
@@ -312,7 +324,6 @@
destroyCache(cache);
}
-
public void testRemoteCacheBroadcast() throws Exception
{
1.31.2.1 +24 -2 JBossCache/tests/functional/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractOptimisticTestCase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -u -b -r1.31 -r1.31.2.1
--- AbstractOptimisticTestCase.java 5 May 2006 12:06:58 -0000 1.31
+++ AbstractOptimisticTestCase.java 11 Nov 2006 17:50:03 -0000 1.31.2.1
@@ -7,12 +7,18 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
import org.jboss.cache.TreeCacheListener;
-import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.marshall.JBCMethodCall;
+import org.jboss.cache.marshall.MethodCallFactory;
+import org.jboss.cache.marshall.MethodDeclarations;
+import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.xml.XmlHelper;
import org.w3c.dom.Element;
import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.Random;
/**
@@ -257,5 +263,21 @@
}
}
-
+ protected List injectDataVersion(List modifications)
+ {
+ List newList = new ArrayList();
+ Iterator mi = modifications.iterator();
+ while (mi.hasNext())
+ {
+ JBCMethodCall c = (JBCMethodCall) mi.next();
+ Object[] oa = c.getArgs();
+ Object[] na = new Object[oa.length + 1];
+ System.out.println("*** " + oa.length);
+ for (int i=0; i<oa.length; i++) na[i] = oa[i];
+ na[oa.length] = new DefaultDataVersion();
+ newList.add(MethodCallFactory.create(MethodDeclarations.getVersionedMethod(c.getMethodId()), na));
+ }
+ return newList;
+ }
}
+
More information about the jboss-cvs-commits
mailing list