[jbosscache-commits] JBoss Cache SVN: r5613 - in core/trunk/src: test/java/org/jboss/cache/misc and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Apr 21 20:37:00 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-04-21 20:37:00 -0400 (Mon, 21 Apr 2008)
New Revision: 5613

Modified:
   core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
Log:
Fixed various issues

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java	2008-04-21 23:39:34 UTC (rev 5612)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java	2008-04-22 00:37:00 UTC (rev 5613)
@@ -114,7 +114,7 @@
          Transaction tx = getTransaction();
          GlobalTransaction realGtx = getGlobalTransaction(tx, gtx);
          if (tx == null && realGtx != null && realGtx.isRemote()) tx = txTable.getLocalTransaction(gtx);
-         setTransactionalContext(tx, gtx, ctx);
+         setTransactionalContext(tx, realGtx, ctx);
 
          if (optionOverride != null)
          {

Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java	2008-04-21 23:39:34 UTC (rev 5612)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java	2008-04-22 00:37:00 UTC (rev 5613)
@@ -14,11 +14,10 @@
 import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
 import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.interceptors.Interceptor;
 import org.jboss.cache.interceptors.base.ChainedInterceptor;
 import org.jboss.cache.invocation.CacheInvocationDelegate;
+import org.jboss.cache.invocation.CacheLifecycleManager;
 import org.jboss.cache.invocation.InterceptorChain;
-import org.jboss.cache.invocation.CacheLifecycleManager;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.CacheLoaderManager;
 
@@ -211,7 +210,7 @@
       throw new RuntimeException("timed out before caches had complete views");
    }
 
-    /**
+   /**
     * Checks each cache to see if the number of elements in the array
     * returned by {@link CacheSPI#getMembers()} matches the size of
     * the <code>caches</code> parameter.
@@ -536,9 +535,12 @@
       }
       throw new RuntimeException("Timed out waiting for condition");
    }
-   public static void replicateCommand(CacheSPI cache, CacheCommand prepcareCommand)
+
+   public static void replicateCommand(CacheSPI cache, CacheCommand command) throws Throwable
    {
-      //todo implement
+      ComponentRegistry cr = extractComponentRegistry(cache);
+      InterceptorChain ic = cr.getComponent(InterceptorChain.class);
+      ic.invoke(command);
    }
 
    public static void blockUntilViewsReceived(int timeout, List caches)

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java	2008-04-21 23:39:34 UTC (rev 5612)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java	2008-04-22 00:37:00 UTC (rev 5613)
@@ -40,6 +40,7 @@
    {
       cache = createCache();
       lri = new LockReportInterceptor();
+      TestingUtil.extractComponentRegistry(cache).wireDependencies(lri);
 
       TestingUtil.injectInterceptor(cache, lri, OptimisticLockingInterceptor.class);
 

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java	2008-04-21 23:39:34 UTC (rev 5612)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java	2008-04-22 00:37:00 UTC (rev 5613)
@@ -7,7 +7,6 @@
 package org.jboss.cache.optimistic;
 
 import org.jboss.cache.CacheSPI;
-import org.jboss.cache.commands.CommandsFactory;
 import org.jboss.cache.commands.state.GlobalTransactionCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -30,8 +29,6 @@
 @Test(groups = {"functional", "transaction"})
 public class TxInterceptorTest extends AbstractOptimisticTestCase
 {
-   private CommandsFactory commandsFactory;
-
    @Override
    protected CacheSPI<Object, Object> createCacheUnstarted(boolean optimistic) throws Exception
    {
@@ -223,7 +220,6 @@
       }
       catch (Exception e)
       {
-         e.printStackTrace();
          failed = true;
          assertTrue(true);
       }
@@ -309,11 +305,10 @@
 
       remoteGtx.setAddress(new DummyAddress());
       //hack the method call to make it have the remote globalTransaction
-      commandsFactory = new CommandsFactory();
       GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
       try
       {
          TestingUtil.replicateCommand(cache, prepareCommand);
@@ -372,7 +367,7 @@
       GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
       try
       {
          TestingUtil.replicateCommand(cache, prepareCommand);
@@ -455,7 +450,7 @@
       GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
       try
       {
          TestingUtil.replicateCommand(cache, prepareCommand);
@@ -469,7 +464,7 @@
       assertEquals(2, cache.getTransactionTable().getNumLocalTransactions());
 
 //		    call our remote method
-      CommitCommand commitMethod = commandsFactory.buildCommitCommand(remoteGtx);
+      CommitCommand commitMethod = new CommitCommand(remoteGtx);
       try
       {
          TestingUtil.replicateCommand(cache, commitMethod);
@@ -543,7 +538,7 @@
       GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
       try
       {
          TestingUtil.replicateCommand(cache, prepareCommand);
@@ -557,10 +552,10 @@
       assertEquals(2, cache.getTransactionTable().getNumLocalTransactions());
 
 //		    call our remote method
-      RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand(remoteGtx);
+      RollbackCommand rollbackCommand = new RollbackCommand(remoteGtx);
       try
       {
-         TestingUtil.replicateCommand(cache, command);
+         TestingUtil.replicateCommand(cache, rollbackCommand);
       }
       catch (Throwable t)
       {
@@ -641,7 +636,7 @@
       GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
       try
       {
          TestingUtil.replicateCommand(cache, prepareCommand);
@@ -667,7 +662,7 @@
 
       assertNull(mgr.getTransaction());
 //	    call our remote method
-      CommitCommand commitCommand = commandsFactory.buildCommitCommand(remoteGtx);
+      CommitCommand commitCommand = new CommitCommand(remoteGtx);
       try
       {
          TestingUtil.replicateCommand(cache, commitCommand);
@@ -725,10 +720,10 @@
       GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
       command.setGlobalTransaction(remoteGtx);
       //call our remote method
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
       try
       {
-         TestingUtil.replicateCommand(cache, command);
+         TestingUtil.replicateCommand(cache, prepareCommand);
       }
       catch (Throwable t)
       {
@@ -748,7 +743,7 @@
       assertEquals(OptimisticPrepareCommand.METHOD_ID, calls.get(2));
 
 //	    call our remote method
-      RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand(remoteGtx);
+      RollbackCommand rollbackCommand = new RollbackCommand(remoteGtx);
       try
       {
          TestingUtil.replicateCommand(cache, rollbackCommand);

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java	2008-04-21 23:39:34 UTC (rev 5612)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java	2008-04-22 00:37:00 UTC (rev 5613)
@@ -11,7 +11,6 @@
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CommandsFactory;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.RollbackCommand;
@@ -47,7 +46,6 @@
    private CacheSPI<Object, Object> cache;
    private TransactionManager mgr;
    private MockInterceptor dummy;
-   private CommandsFactory commandsFactory;
 
    @BeforeMethod
    public void setUp() throws Exception
@@ -110,8 +108,7 @@
       assertTrue(!cache.exists("/one/two"));
       assertEquals(null, dummy.getCalledCommand());
 
-      commandsFactory = new CommandsFactory();
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
       //now let us do a prepare
       TestingUtil.replicateCommand(cache, prepareCommand);
 
@@ -164,7 +161,7 @@
       //lets change one of the underlying version numbers
       workspace.getNode(Fqn.fromString("/one/two")).getNode().setVersion(new DefaultDataVersion(2));
       //now let us do a prepare
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
       try
       {
          TestingUtil.replicateCommand(cache, prepareCommand);
@@ -211,7 +208,7 @@
 
       //lets change one of the underlying version numbers
       //now let us do a prepare
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
       try
       {
          TestingUtil.replicateCommand(cache, prepareCommand);
@@ -222,7 +219,7 @@
          assertTrue(true);
       }
 
-      CommitCommand commitCommand = commandsFactory.buildCommitCommand(gtx);
+      CommitCommand commitCommand = new CommitCommand(gtx);
       TestingUtil.replicateCommand(cache, commitCommand);
 
 
@@ -288,7 +285,7 @@
 
       //lets change one of the underlying version numbers
       //now let us do a prepare
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
       try
       {
          TestingUtil.replicateCommand(cache, prepareCommand);
@@ -300,7 +297,7 @@
       }
 
 
-      CommitCommand commitCommand = commandsFactory.buildCommitCommand(gtx);
+      CommitCommand commitCommand = new CommitCommand(gtx);
       TestingUtil.replicateCommand(cache, commitCommand);
 
 
@@ -367,7 +364,7 @@
 
       //lets change one of the underlying version numbers
       //now let us do a prepare
-      OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+      OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
 
       try
       {
@@ -379,7 +376,7 @@
          assertTrue(true);
       }
 
-      RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand(null);
+      RollbackCommand rollbackCommand = new RollbackCommand(gtx);
       TestingUtil.replicateCommand(cache, rollbackCommand);
 
 




More information about the jbosscache-commits mailing list