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

Manik Surtani msurtani at jboss.com
Thu Sep 7 12:59:05 EDT 2006


  User: msurtani
  Date: 06/09/07 12:59:05

  Modified:    tests/functional/org/jboss/cache/optimistic    
                        AbstractOptimisticTestCase.java CacheTest.java
                        OptimisticReplicationInterceptorTest.java
                        TxInterceptorTest.java
  Log:
  Fixed a bunch of optimistic locking test breakages to do with new ICI
  
  Revision  Changes    Path
  1.40      +54 -1     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.39
  retrieving revision 1.40
  diff -u -b -r1.39 -r1.40
  --- AbstractOptimisticTestCase.java	6 Sep 2006 15:30:58 -0000	1.39
  +++ AbstractOptimisticTestCase.java	7 Sep 2006 16:59:05 -0000	1.40
  @@ -5,15 +5,24 @@
   
   import junit.framework.TestCase;
   import org.jboss.cache.CacheListener;
  +import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.config.Configuration;
  +import org.jboss.cache.interceptors.Interceptor;
  +import org.jboss.cache.interceptors.InvocationContextInterceptor;
  +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.lock.IsolationLevel;
   import org.jboss.cache.misc.TestingUtil;
   import org.jboss.cache.transaction.DummyTransactionManager;
   import org.jboss.cache.xml.XmlHelper;
   import org.w3c.dom.Element;
   
  +import javax.transaction.SystemException;
  +import javax.transaction.TransactionManager;
   import java.io.File;
   import java.util.Random;
   
  @@ -271,7 +280,51 @@
   
      protected void tearDown()
      {
  -      DummyTransactionManager.getInstance().setTransaction(null);
  +      TransactionManager mgr = DummyTransactionManager.getInstance();
  +      try
  +      {
  +         if (mgr.getTransaction() != null)
  +         {
  +            mgr.rollback();
  +         }
  +      }
  +      catch (SystemException e)
  +      {
  +         // do nothing
  +      }
  +   }
  +
  +   protected Interceptor getAlteredInterceptorChain(Interceptor newLast, CacheSPI spi, boolean replicated)
  +   {
  +      Interceptor ici = new InvocationContextInterceptor();
  +      ici.setCache(spi);
  +
  +      Interceptor txInterceptor = new TxInterceptor();
  +      txInterceptor.setCache(spi);
  +
  +      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  +      replicationInterceptor.setCache(spi);
  +
  +      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  +      createInterceptor.setCache(spi);
  +
  +      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  +      nodeInterceptor.setCache(spi);
  +
  +      ici.setNext(txInterceptor);
  +      if (replicated)
  +      {
  +         txInterceptor.setNext(replicationInterceptor);
  +         replicationInterceptor.setNext(createInterceptor);
  +      }
  +      else
  +      {
  +         txInterceptor.setNext(createInterceptor);
  +      }
  +      createInterceptor.setNext(nodeInterceptor);
  +      nodeInterceptor.setNext(newLast);
  +
  +      return ici;
      }
   
      public abstract class ExceptionThread extends Thread
  
  
  
  1.24      +6 -51     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.23
  retrieving revision 1.24
  diff -u -b -r1.23 -r1.24
  --- CacheTest.java	6 Sep 2006 15:30:58 -0000	1.23
  +++ CacheTest.java	7 Sep 2006 16:59:05 -0000	1.24
  @@ -13,11 +13,6 @@
   import org.jboss.cache.TransactionTable;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.config.Configuration;
  -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.MethodCall;
   import org.jboss.cache.marshall.MethodCallFactory;
  @@ -106,26 +101,12 @@
   
      public void testLocalTransaction() throws Exception
      {
  -
         TreeCache cache = createCacheWithListener();
   
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
  -      dummy.setCache(cache);
  -
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  +      dummy.setCache(cache.getCacheSPI());
   
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         assertNull(mgr.getTransaction());
  @@ -153,7 +134,6 @@
         assertEquals(MethodDeclarations.commitMethod, calls.get(1));
         //flesh this out a bit more
   
  -
         destroyCache(cache);
      }
   
  @@ -162,22 +142,10 @@
   
         TreeCache cache = createCacheWithListener();
   
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
  -      dummy.setCache(cache);
  +      dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         assertNull(mgr.getTransaction());
  @@ -207,23 +175,10 @@
   
         TreeCache cache = createCacheWithListener();
   
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
  -      dummy.setCache(cache);
  -
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  +      dummy.setCache(cache.getCacheSPI());
   
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  
  
  
  1.17      +89 -512   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.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- OptimisticReplicationInterceptorTest.java	6 Sep 2006 15:30:58 -0000	1.16
  +++ OptimisticReplicationInterceptorTest.java	7 Sep 2006 16:59:05 -0000	1.17
  @@ -11,11 +11,6 @@
   import org.jboss.cache.TransactionTable;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.config.Configuration;
  -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.MethodCall;
   import org.jboss.cache.marshall.MethodCallFactory;
  @@ -27,7 +22,6 @@
   import javax.transaction.Transaction;
   import java.io.DataInputStream;
   import java.io.DataOutputStream;
  -import java.io.IOException;
   import java.io.ObjectInput;
   import java.io.ObjectOutput;
   import java.util.ArrayList;
  @@ -38,7 +32,7 @@
    */
   public class OptimisticReplicationInterceptorTest extends AbstractOptimisticTestCase
   {
  -
  +   private TreeCache cache;
   
      /**
       * @param name
  @@ -46,31 +40,26 @@
      public OptimisticReplicationInterceptorTest(String name)
      {
         super(name);
  -
      }
   
  -   public void testLocalTransaction() throws Exception
  +   protected void setUp() throws Exception
      {
  +      super.setUp();
  +      cache = createCache();
  +   }
   
  -      final TreeCache cache = createCache();
  +   protected void tearDown()
  +   {
  +      super.tearDown();
  +      destroyCache(cache);
  +   }
   
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
  +   public void testLocalTransaction() throws Exception
  +   {
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         assertNull(mgr.getTransaction());
  @@ -96,33 +85,14 @@
   
         assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(0));
         assertEquals(MethodDeclarations.commitMethod, calls.get(1));
  -
  -      cache.stop();
  -
  -
      }
   
      public void testRollbackTransaction() throws Exception
      {
  -
  -      TreeCache cache = createCache();
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         assertNull(mgr.getTransaction());
  @@ -143,34 +113,14 @@
   
         assertEquals(1, calls.size());
         assertEquals(MethodDeclarations.rollbackMethod, calls.get(0));
  -
  -      cache.stop();
  -
  -
      }
   
      public void testRemotePrepareTransaction() throws Exception
      {
  -
  -      TreeCache cache = createCache();
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -194,57 +144,13 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0) throws IOException,
  -                 ClassNotFoundException
  -         {
  -
  -
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public void readFrom(DataInputStream arg0) throws IOException, IllegalAccessException, InstantiationException
  -         {
  -
  -
  -         }
  -      });
  +      remoteGtx.setAddress(new TestAddress());
         //hack the method call to make it have the remote gtx
  -      MethodCall meth = (MethodCall) entry.getModifications().get(0);
  +      MethodCall meth = entry.getModifications().get(0);
   
         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, remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), false);
         try
         {
            cache._replicate(prepareMethod);
  @@ -275,34 +181,15 @@
         assertEquals(1, cache.getTransactionTable().getNumGlobalTransactions());
         assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
   
  -      cache.stop();
  -
  -
      }
   
   
      public void testRemoteRollbackTransaction() throws Exception
      {
  -
  -      TreeCache cache = createCache();
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -326,57 +213,13 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0) throws IOException,
  -                 ClassNotFoundException
  -         {
  -
  -
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public void readFrom(DataInputStream arg0) throws IOException, IllegalAccessException, InstantiationException
  -         {
  -
  -
  -         }
  -      });
  +      remoteGtx.setAddress(new TestAddress());
         //hack the method call to make it have the remote gtx
  -      MethodCall meth = (MethodCall) entry.getModifications().get(0);
  +      MethodCall meth = entry.getModifications().get(0);
   
         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, remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), false);
         try
         {
            cache._replicate(prepareMethod);
  @@ -408,7 +251,7 @@
         assertEquals(1, 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);
  @@ -422,35 +265,15 @@
         assertEquals(MethodDeclarations.rollbackMethod, calls.get(3));
         assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
         assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
  -
  -      cache.stop();
  -
  -
      }
   
   
      public void testRemoteCommitNoPrepareTransaction() throws Exception
      {
  -
  -      TreeCache cache = createCache();
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -474,53 +297,9 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0) throws IOException,
  -                 ClassNotFoundException
  -         {
  -
  -
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public void readFrom(DataInputStream arg0) throws IOException, IllegalAccessException, InstantiationException
  -         {
  -
  -
  -         }
  -      });
  +      remoteGtx.setAddress(new TestAddress());
         //hack the method call to make it have the remote gtx
  -      MethodCall meth = (MethodCall) entry.getModifications().get(0);
  +      MethodCall meth = entry.getModifications().get(0);
   
         meth.getArgs()[0] = remoteGtx;
   
  @@ -533,7 +312,7 @@
         assertEquals(0, 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);
  @@ -549,35 +328,15 @@
         assertEquals(2, calls.size());
         assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
         assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
  -
  -      cache.stop();
  -
  -
      }
   
   
      public void testRemoteRollbackNoPrepareTransaction() throws Throwable
      {
  -
  -      TreeCache cache = createCache();
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -601,51 +360,7 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0) throws IOException,
  -                 ClassNotFoundException
  -         {
  -
  -
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeTo(DataOutputStream arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public void readFrom(DataInputStream arg0) throws IOException, IllegalAccessException, InstantiationException
  -         {
  -
  -
  -         }
  -      });
  +      remoteGtx.setAddress(new TestAddress());
         //hack the method call to make it have the remote gtx
         MethodCall meth = (MethodCall) entry.getModifications().get(0);
   
  @@ -660,7 +375,7 @@
         assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
   
         //	    call our remote method
  -      MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, new Object[]{remoteGtx});
  +      MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, remoteGtx);
   
         cache._replicate(rollbackMethod);
         assertTrue("Should be handled on the remote end without barfing, in the event of a rollback without a prepare", true);
  @@ -670,35 +385,15 @@
         assertEquals(2, calls.size());
         assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
         assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
  -
  -
  -      cache.stop();
  -
      }
   
   
      public void testRemoteCommitTransaction() throws Exception
      {
  -
  -      TreeCache cache = createCache();
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -722,57 +417,13 @@
   
         GlobalTransaction remoteGtx = new GlobalTransaction();
   
  -      remoteGtx.setAddress(new Address()
  -      {
  -         public boolean isMulticastAddress()
  -         {
  -
  -            return false;
  -         }
  -
  -         public void readExternal(ObjectInput arg0) throws IOException,
  -                 ClassNotFoundException
  -         {
  -
  -
  -         }
  -
  -         public int size()
  -         {
  -
  -            return 0;
  -         }
  -
  -         public void writeExternal(ObjectOutput arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public void writeTo(DataOutputStream arg0) throws IOException
  -         {
  -
  -
  -         }
  -
  -         public void readFrom(DataInputStream arg0) throws IOException, IllegalAccessException, InstantiationException
  -         {
  -
  -
  -         }
  -
  -         public int compareTo(Object arg0)
  -         {
  -
  -            return 0;
  -         }
  -      });
  +      remoteGtx.setAddress(new TestAddress());
         //hack the method call to make it have the remote gtx
  -      MethodCall meth = (MethodCall) entry.getModifications().get(0);
  +      MethodCall meth = entry.getModifications().get(0);
   
         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, remoteGtx, entry.getModifications(), null, remoteGtx.getAddress(), false);
         try
         {
            cache._replicate(prepareMethod);
  @@ -804,7 +455,7 @@
         assertEquals(1, 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);
  @@ -818,60 +469,24 @@
         assertEquals(MethodDeclarations.commitMethod, calls.get(3));
         assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
         assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());
  -
  -
  -      cache.stop();
  -
      }
   
   
      public void testTwoWayRemoteCacheBroadcast() throws Exception
      {
  +      destroyCache(cache);
  +      cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
   
  -
  -      TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  -
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  -
  -
  -      Interceptor txInterceptor2 = new TxInterceptor();
  -      txInterceptor2.setCache(cache2.getCacheSPI());
  -      Interceptor replicationInterceptor2 = new OptimisticReplicationInterceptor();
  -      replicationInterceptor2.setCache(cache2.getCacheSPI());
  -      Interceptor createInterceptor2 = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor2.setCache(cache2.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor2 = new OptimisticNodeInterceptor();
  -      nodeInterceptor2.setCache(cache2.getCacheSPI());
         MockInterceptor dummy2 = new MockInterceptor();
  -      dummy2.setCache(cache2.getCacheSPI());
  -
  -      txInterceptor2.setNext(replicationInterceptor2);
  -      replicationInterceptor2.setNext(createInterceptor2);
  -      createInterceptor2.setNext(nodeInterceptor2);
  -      nodeInterceptor2.setNext(dummy2);
  -
  -      cache2.setInterceptorChain(txInterceptor2);
  +      dummy.setCache(cache2.getCacheSPI());
   
  +      cache2.setInterceptorChain(getAlteredInterceptorChain(dummy2, cache2.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -912,62 +527,28 @@
         assertEquals(MethodDeclarations.optimisticPrepareMethod, calls2.get(0));
         assertEquals(MethodDeclarations.commitMethod, calls2.get(1));
   
  -      cache.stop();
  -      cache2.stop();
  -
  +      destroyCache(cache2);
      }
   
   
      public void testFailurePrepareRemoteCacheBroadcast() throws Exception
      {
  +      destroyCache(cache);
  +      cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
   
  -
  -      TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  -
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  -
  -
  -      Interceptor txInterceptor2 = new TxInterceptor();
  -      txInterceptor2.setCache(cache2.getCacheSPI());
  -      Interceptor replicationInterceptor2 = new OptimisticReplicationInterceptor();
  -      replicationInterceptor2.setCache(cache2.getCacheSPI());
  -      Interceptor createInterceptor2 = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor2.setCache(cache2.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor2 = new OptimisticNodeInterceptor();
  -      nodeInterceptor2.setCache(cache2.getCacheSPI());
         MockFailureInterceptor dummy2 = new MockFailureInterceptor();
         List failures = new ArrayList();
         failures.add(MethodDeclarations.optimisticPrepareMethod);
         dummy2.setFailurelist(failures);
  -      dummy2.setCache(cache2.getCacheSPI());
  -
  -      txInterceptor2.setNext(replicationInterceptor2);
  -      replicationInterceptor2.setNext(createInterceptor2);
  -      createInterceptor2.setNext(nodeInterceptor2);
  -      nodeInterceptor2.setNext(dummy2);
  -
  -      cache2.setInterceptorChain(txInterceptor2);
  +      dummy.setCache(cache2.getCacheSPI());
   
  +      cache2.setInterceptorChain(getAlteredInterceptorChain(dummy2, cache2.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -1015,66 +596,30 @@
         List calls2 = dummy2.getAllCalled();
         assertEquals(MethodDeclarations.rollbackMethod, calls2.get(0));
   
  -
  -      cache.stop();
  -      cache2.stop();
  -
  +      destroyCache(cache2);
      }
   
   
      public void testFailurePrepareLocalCacheBroadcast() throws Exception
      {
   
  -
  -      TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  -
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
  +      destroyCache(cache);
  +      cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
   
         MockFailureInterceptor dummy = new MockFailureInterceptor();
  -      List failures = new ArrayList();
  -      failures.add(MethodDeclarations.optimisticPrepareMethod);
  -      dummy.setFailurelist(failures);
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  -
  -
  -      Interceptor txInterceptor2 = new TxInterceptor();
  -      txInterceptor2.setCache(cache2.getCacheSPI());
  -      Interceptor replicationInterceptor2 = new OptimisticReplicationInterceptor();
  -      replicationInterceptor2.setCache(cache2.getCacheSPI());
  -      Interceptor createInterceptor2 = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor2.setCache(cache2.getCacheSPI());
  -      OptimisticNodeInterceptor nodeInterceptor2 = new OptimisticNodeInterceptor();
  -      nodeInterceptor2.setCache(cache2.getCacheSPI());
  -
         MockInterceptor dummy2 = new MockInterceptor();
  -      dummy2.setCache(cache2.getCacheSPI());
  +      dummy.setCache(cache2.getCacheSPI());
   
  +      cache2.setInterceptorChain(getAlteredInterceptorChain(dummy2, cache2.getCacheSPI(), true));
   
  -      txInterceptor2.setNext(replicationInterceptor2);
  -      replicationInterceptor2.setNext(createInterceptor2);
  -      createInterceptor2.setNext(nodeInterceptor2);
  -      nodeInterceptor2.setNext(dummy2);
  -
  -      cache2.setInterceptorChain(txInterceptor2);
  -
  +      List failures = new ArrayList();
  +      failures.add(MethodDeclarations.optimisticPrepareMethod);
  +      dummy.setFailurelist(failures);
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -1121,9 +666,41 @@
         List calls2 = dummy2.getAllCalled();
         assertEquals(0, calls2.size());
   
  +      destroyCache(cache2);
  +   }
  +
  +   static class TestAddress implements Address
  +   {
  +      public boolean isMulticastAddress()
  +      {
  +         return false;
  +      }
  +
  +      public void readExternal(ObjectInput arg0)
  +      {
  +      }
  +
  +      public int size()
  +      {
  +         return 0;
  +      }
   
  -      cache.stop();
  -      cache2.stop();
  +      public void writeExternal(ObjectOutput arg0)
  +      {
  +      }
   
  +      public void writeTo(DataOutputStream arg0)
  +      {
      }
  +
  +      public void readFrom(DataInputStream arg0)
  +      {
  +      }
  +
  +      public int compareTo(Object arg0)
  +      {
  +         return 0;
  +      }
  +   }
  +
   }
  
  
  
  1.16      +14 -189   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.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- TxInterceptorTest.java	6 Sep 2006 15:30:58 -0000	1.15
  +++ TxInterceptorTest.java	7 Sep 2006 16:59:05 -0000	1.16
  @@ -10,11 +10,6 @@
   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.MethodCall;
   import org.jboss.cache.marshall.MethodCallFactory;
  @@ -29,41 +24,21 @@
   import java.io.ObjectOutput;
   import java.util.List;
   
  -/**
  - * @author xenephon
  - */
   public class TxInterceptorTest extends AbstractOptimisticTestCase
   {
  -
  -
  -   /**
  -    * @param name
  -    */
      public TxInterceptorTest(String name)
      {
         super(name);
  -
      }
   
      public void testNoTransaction() throws Exception
      {
   
         TreeCache cache = createCache();
  -
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         assertNull(mgr.getTransaction());
         assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
  @@ -90,20 +65,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -138,21 +103,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -181,21 +135,10 @@
      public void testEmptyLocalTransaction() throws Exception
      {
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -221,20 +164,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -261,20 +194,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -316,21 +239,10 @@
      public void testgtxTransactionExists() throws Exception
      {
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -365,21 +277,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -481,21 +382,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -610,23 +500,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -749,24 +626,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -887,24 +750,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -1029,24 +878,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -      replicationInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(replicationInterceptor);
  -      replicationInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  -
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), true));
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
         //start local transaction
  @@ -1166,20 +1001,10 @@
      {
   
         TreeCache cache = createCache();
  -      Interceptor txInterceptor = new TxInterceptor();
  -      txInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -      createInterceptor.setCache(cache.getCacheSPI());
  -      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -      nodeInterceptor.setCache(cache.getCacheSPI());
         MockInterceptor dummy = new MockInterceptor();
         dummy.setCache(cache.getCacheSPI());
   
  -      txInterceptor.setNext(createInterceptor);
  -      createInterceptor.setNext(nodeInterceptor);
  -      nodeInterceptor.setNext(dummy);
  -
  -      cache.setInterceptorChain(txInterceptor);
  +      cache.setInterceptorChain(getAlteredInterceptorChain(dummy, cache.getCacheSPI(), false));
   
         DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  
  
  



More information about the jboss-cvs-commits mailing list