[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/optimistic ...

Manik Surtani msurtani at jboss.com
Tue Jan 9 11:21:53 EST 2007


  User: msurtani
  Date: 07/01/09 11:21:53

  Modified:    tests/functional/org/jboss/cache/optimistic   
                        TxInterceptorTest.java
                        AbstractOptimisticTestCase.java CacheTest.java
  Log:
  Added tests and fix for JBCACHE-927
  
  Revision  Changes    Path
  1.19      +16 -231   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.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- TxInterceptorTest.java	30 Dec 2006 17:49:52 -0000	1.18
  +++ TxInterceptorTest.java	9 Jan 2007 16:21:52 -0000	1.19
  @@ -15,13 +15,8 @@
   import org.jboss.cache.marshall.MethodCallFactory;
   import org.jboss.cache.marshall.MethodDeclarations;
   import org.jboss.cache.transaction.DummyTransactionManager;
  -import org.jgroups.Address;
   
   import javax.transaction.Transaction;
  -import java.io.DataInputStream;
  -import java.io.DataOutputStream;
  -import java.io.ObjectInput;
  -import java.io.ObjectOutput;
   import java.util.List;
   
   public class TxInterceptorTest extends AbstractOptimisticTestCase
  @@ -310,48 +305,13 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0)
  -         {
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0)
  -         {
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0)
  -         {
  -         }
  -
  -         public void readFrom(DataInputStream arg0)
  -         {
  -         }
  -      });
  +      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
  -      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
  +      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
         try
         {
            cache._replicate(prepareMethod);
  @@ -406,48 +366,13 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0)
  -         {
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0)
  -         {
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0)
  -         {
  -         }
  -
  -         public void readFrom(DataInputStream arg0)
  -         {
  -         }
  -      });
  +      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
  -      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
  +      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
         try
         {
            cache._replicate(prepareMethod);
  @@ -527,48 +452,13 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0)
  -         {
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0)
  -         {
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0)
  -         {
  -         }
  -
  -         public void readFrom(DataInputStream arg0)
  -         {
  -         }
  -      });
  +      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
  -      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
  +      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
         try
         {
            cache._replicate(prepareMethod);
  @@ -582,7 +472,7 @@
         assertEquals(2, cache.getTransactionTable().getNumLocalTransactions());
   
   //		    call our remote method
  -      MethodCall commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{remoteGtx});
  +      MethodCall commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, remoteGtx);
         try
         {
            cache._replicate(commitMethod);
  @@ -652,48 +542,13 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0)
  -         {
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0)
  -         {
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0)
  -         {
  -         }
  -
  -         public void readFrom(DataInputStream arg0)
  -         {
  -         }
  -      });
  +      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
  -      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
  +      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
         try
         {
            cache._replicate(prepareMethod);
  @@ -707,7 +562,7 @@
         assertEquals(2, cache.getTransactionTable().getNumLocalTransactions());
   
   //		    call our remote method
  -      MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, new Object[]{remoteGtx});
  +      MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, remoteGtx);
         try
         {
            cache._replicate(rollbackMethod);
  @@ -786,49 +641,14 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0)
  -         {
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0)
  -         {
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0)
  -         {
  -         }
  -
  -         public void readFrom(DataInputStream arg0)
  -         {
  -         }
  -      });
  +      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
  -      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
  +      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
         try
         {
            cache._replicate(prepareMethod);
  @@ -854,7 +674,7 @@
   
         assertNull(mgr.getTransaction());
   //	    call our remote method
  -      MethodCall commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{remoteGtx, Boolean.TRUE});
  +      MethodCall commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, remoteGtx, Boolean.TRUE);
         try
         {
            cache._replicate(commitMethod);
  @@ -908,49 +728,14 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0)
  -         {
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0)
  -         {
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0)
  -         {
  -         }
  -
  -         public void readFrom(DataInputStream arg0)
  -         {
  -         }
  -      });
  +      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
  -      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
  +      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
         try
         {
            cache._replicate(prepareMethod);
  @@ -973,7 +758,7 @@
         assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(2));
   
   //	    call our remote method
  -      MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, new Object[]{remoteGtx});
  +      MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, remoteGtx);
         try
         {
            cache._replicate(rollbackMethod);
  
  
  
  1.44      +45 -0     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.43
  retrieving revision 1.44
  diff -u -b -r1.43 -r1.44
  --- AbstractOptimisticTestCase.java	30 Dec 2006 17:49:52 -0000	1.43
  +++ AbstractOptimisticTestCase.java	9 Jan 2007 16:21:53 -0000	1.44
  @@ -24,11 +24,16 @@
   import org.jboss.cache.misc.TestingUtil;
   import org.jboss.cache.transaction.DummyTransactionManager;
   import org.jboss.cache.xml.XmlHelper;
  +import org.jgroups.Address;
   import org.w3c.dom.Element;
   
   import javax.transaction.SystemException;
   import javax.transaction.TransactionManager;
  +import java.io.DataInputStream;
  +import java.io.DataOutputStream;
   import java.io.File;
  +import java.io.ObjectInput;
  +import java.io.ObjectOutput;
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  @@ -368,4 +373,44 @@
         return newList;
      }
   
  +   protected class DummyAddress implements Address
  +   {
  +
  +      public int compareTo(Object arg0)
  +      {
  +         return 0;
  +      }
  +
  +      public void readFrom(DataInputStream
  +              arg0)
  +      {
  +      }
  +
  +      public void writeTo(DataOutputStream
  +              arg0)
  +      {
  +      }
  +
  +      public void readExternal(ObjectInput
  +              arg0)
  +      {
  +      }
  +
  +      public void writeExternal(ObjectOutput
  +              arg0)
  +      {
  +      }
  +
  +      public int size()
  +      {
  +         return 0;
  +      }
  +
  +      public boolean isMulticastAddress()
  +      {
  +         return false;
  +      }
  +
  +   }
  +
   }
  
  
  
  1.27      +72 -106   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.26
  retrieving revision 1.27
  diff -u -b -r1.26 -r1.27
  --- CacheTest.java	30 Dec 2006 17:49:52 -0000	1.26
  +++ CacheTest.java	9 Jan 2007 16:21:53 -0000	1.27
  @@ -18,15 +18,10 @@
   import org.jboss.cache.marshall.MethodCallFactory;
   import org.jboss.cache.marshall.MethodDeclarations;
   import org.jboss.cache.transaction.DummyTransactionManager;
  -import org.jgroups.Address;
   
   import javax.transaction.RollbackException;
   import javax.transaction.Transaction;
   import javax.transaction.TransactionManager;
  -import java.io.DataInputStream;
  -import java.io.DataOutputStream;
  -import java.io.ObjectInput;
  -import java.io.ObjectOutput;
   import java.util.List;
   
   public class CacheTest extends AbstractOptimisticTestCase
  @@ -38,11 +33,23 @@
         super(s);
      }
   
  +   private CacheImpl c;
   
  -   public void testExplicitTxFailure() throws Exception
  +   protected void setUp() throws Exception
      {
  -      final CacheImpl c = createCache();
  +      c = createCache();
  +   }
  +
  +   protected void tearDown()
  +   {
  +      super.tearDown();
  +      if (c != null)
  +         destroyCache(c);
  +      c = null;
  +   }
   
  +   public void testExplicitTxFailure() throws Exception
  +   {
         // explicit.
         TransactionManager mgr = c.getTransactionManager();
         try
  @@ -59,13 +66,10 @@
         {
            Assert.assertTrue("Expecting a rollback exception!", true);
         }
  -      c.stop();
      }
   
      public void testImplicitTxFailure() throws Exception
      {
  -      final CacheImpl c = createCache();
  -
         // implicit (much harder to orchestrate...
         int numThreads = 50;
         ExceptionThread thread[] = new ExceptionThread[numThreads];
  @@ -96,35 +100,32 @@
         {
            Assert.assertNull("Thread " + thread[i].getName() + " threw exception!", thread[i].getException());
         }
  -      c.stop();
      }
   
      public void testLocalTransaction() throws Exception
      {
  -      CacheImpl cache = createCacheWithListener();
  -
         MockInterceptor dummy = new MockInterceptor();
  -      dummy.setCache(cache);
  +      dummy.setCache(c);
   
  -      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache, true));
  +      c.setInterceptorChain(getAlteredInterceptorChain(dummy, c, true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         assertNull(mgr.getTransaction());
   
         mgr.begin();
   
  -      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
  -      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
  +      assertEquals(0, c.getTransactionTable().getNumGlobalTransactions());
  +      assertEquals(0, c.getTransactionTable().getNumLocalTransactions());
   
         SamplePojo pojo = new SamplePojo(21, "test");
   
  -      cache.put("/one/two", "key1", pojo);
  +      c.put("/one/two", "key1", pojo);
   
         mgr.commit();
   
         assertNull(mgr.getTransaction());
  -      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
  -      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
  +      assertEquals(0, c.getTransactionTable().getNumGlobalTransactions());
  +      assertEquals(0, c.getTransactionTable().getNumLocalTransactions());
   
         //make sure all calls were done in right order
   
  @@ -132,33 +133,31 @@
   
         assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(0));
         assertEquals(MethodDeclarations.commitMethod, calls.get(1));
  -      //flesh this out a bit more
  -
  -      destroyCache(cache);
      }
   
      public void testRollbackTransaction() throws Exception
      {
   
  -      CacheImpl cache = createCacheWithListener();
  +      destroyCache(c);
  +      c = createCacheWithListener();
   
         MockInterceptor dummy = new MockInterceptor();
  -      dummy.setCache(cache);
  +      dummy.setCache(c);
   
  -      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache, true));
  +      c.setInterceptorChain(getAlteredInterceptorChain(dummy, c, true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         assertNull(mgr.getTransaction());
  -      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
  -      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
  +      assertEquals(0, c.getTransactionTable().getNumGlobalTransactions());
  +      assertEquals(0, c.getTransactionTable().getNumLocalTransactions());
   
         SamplePojo pojo = new SamplePojo(21, "test");
         mgr.begin();
  -      cache.put("/one/two", "key1", pojo);
  +      c.put("/one/two", "key1", pojo);
         mgr.rollback();
         assertNull(mgr.getTransaction());
  -      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
  -      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
  +      assertEquals(0, c.getTransactionTable().getNumGlobalTransactions());
  +      assertEquals(0, c.getTransactionTable().getNumLocalTransactions());
   
         //make sure all calls were done in right order
   
  @@ -166,19 +165,17 @@
   
         assertEquals(1, calls.size());
         assertEquals(MethodDeclarations.rollbackMethod, calls.get(0));
  -      destroyCache(cache);
  -
      }
   
  -   public void testRemotePrepareTransaction() throws Exception
  +   public void testRemotePrepareTransaction() throws Throwable
      {
  -
  -      CacheImpl cache = createCacheWithListener();
  +      destroyCache(c);
  +      c = createCacheWithListener();
   
         MockInterceptor dummy = new MockInterceptor();
  -      dummy.setCache(cache);
  +      dummy.setCache(c);
   
  -      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache, true));
  +      c.setInterceptorChain(getAlteredInterceptorChain(dummy, c, true));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -186,14 +183,14 @@
         Transaction tx = mgr.getTransaction();
   
         //this sets
  -      cache.getCurrentTransaction(tx);
  +      c.getCurrentTransaction(tx);
   
         SamplePojo pojo = new SamplePojo(21, "test");
   
  -      cache.put("/one/two", "key1", pojo);
  +      c.put("/one/two", "key1", pojo);
   
  -      GlobalTransaction gtx = cache.getCurrentTransaction(tx);
  -      TransactionTable table = cache.getTransactionTable();
  +      GlobalTransaction gtx = c.getCurrentTransaction(tx);
  +      TransactionTable table = c.getTransactionTable();
         OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
         assertNotNull(mgr.getTransaction());
         mgr.commit();
  @@ -201,55 +198,14 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -
  -         public int compareTo(Object arg0)
  -         {
  -            return 0;
  -         }
  -
  -         public void readFrom(DataInputStream arg0)
  -         {
  -         }
  -
  -         public void writeTo(DataOutputStream arg0)
  -         {
  -         }
  -
  -         public void readExternal(ObjectInput arg0)
  -         {
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0)
  -         {
  -         }
  -
  -         public int size()
  -         {
  -            return 0;
  -         }
  -
  -         public boolean isMulticastAddress()
  -         {
  -            return false;
  -         }
  -
  -      });
  +      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
  -      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
  -      try
  -      {
  -         cache._replicate(prepareMethod);
  -      }
  -      catch (Throwable t)
  -      {
  -         fail();
  -      }
  +      MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
  +      c._replicate(prepareMethod);
   
         //our thread should be null
         assertNull(mgr.getTransaction());
  @@ -268,15 +224,13 @@
         List calls = dummy.getAllCalled();
         assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(2));
   
  -      assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
  -      assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
  -      destroyCache(cache);
  -
  +      assertEquals(1, c.getTransactionTable().getNumGlobalTransactions());
  +      assertEquals(1, c.getTransactionTable().getNumLocalTransactions());
      }
   
      public void testRemoteCacheBroadcast() throws Exception
      {
  -
  +      destroyCache(c);
   
         CacheImpl cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
         CacheImpl cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  @@ -329,7 +283,7 @@
      public void testTwoWayRemoteCacheBroadcast() throws Exception
      {
   
  -
  +      destroyCache(c);
         CacheImpl cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
         CacheImpl cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
         assertEquals(2, cache.getMembers().size());
  @@ -384,7 +338,7 @@
   
      public void testRemotePessCacheBroadcast() throws Exception
      {
  -
  +      destroyCache(c);
   
         CacheImpl cache = createPessimisticCache();
         CacheImpl cache2 = createPessimisticCache();
  @@ -412,20 +366,18 @@
   
      public void testConcurrentNodeRemoval() throws Exception
      {
  -      CacheImpl cache = createCache();
  -
  -      cache.put(fqn, "key", "value");
  +      c.put(fqn, "key", "value");
   
         // now start a tx to change the value in fqn
  -      TransactionManager mgr = cache.getTransactionManager();
  +      TransactionManager mgr = c.getTransactionManager();
         mgr.begin();
   
  -      cache.put(fqn, "key2", "value2");
  +      c.put(fqn, "key2", "value2");
   
         Transaction tx = mgr.suspend();
   
         // now remove the original node...
  -      cache.remove(fqn);
  +      c.remove(fqn);
   
         mgr.resume(tx);
         // now try and commit this - this should fail.
  @@ -441,26 +393,24 @@
   
         Assert.assertTrue("Concurrent mod should result in a rollback", ok);
         // now assert that the node has in fact been removed.
  -      Assert.assertTrue("The node should have been removed!", !cache.exists(fqn));
  +      Assert.assertTrue("The node should have been removed!", !c.exists(fqn));
   
      }
   
      public void testConcurrentNodeModification() throws Exception
      {
  -      CacheImpl cache = createCache();
  -
  -      cache.put(fqn, "key", "value");
  +      c.put(fqn, "key", "value");
   
         // now start a tx to change the value in fqn
  -      TransactionManager mgr = cache.getTransactionManager();
  +      TransactionManager mgr = c.getTransactionManager();
         mgr.begin();
   
  -      cache.put(fqn, "key2", "value2");
  +      c.put(fqn, "key2", "value2");
   
         Transaction tx = mgr.suspend();
   
         // now change the original node...
  -      cache.put(fqn, "key3", "value3");
  +      c.put(fqn, "key3", "value3");
   
         mgr.resume(tx);
         // now try and commit this - this should fail.
  @@ -476,4 +426,20 @@
   
         Assert.assertTrue("Concurrent mod should result in a rollback", ok);
      }
  +
  +   public void testRemoveAndCreate() throws Exception
  +   {
  +      c = createCache();
  +      c.put(fqn, "key", "value");
  +      TransactionManager tm = c.getTransactionManager();
  +      Fqn f = Fqn.fromString("/person/test2");
  +      tm.begin();
  +      c.put(f, "test", "test");
  +      tm.commit();
  +
  +      tm.begin();
  +      c.removeNode(f);
  +      c.put(f, "test", "test");
  +      tm.commit();
  +   }
   }
  
  
  



More information about the jboss-cvs-commits mailing list