[jbosscache-commits] JBoss Cache SVN: r5881 - in core/trunk/src: main/java/org/jboss/cache/commands/remote and 10 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed May 21 12:12:50 EDT 2008


Author: mircea.markus
Date: 2008-05-21 12:12:49 -0400 (Wed, 21 May 2008)
New Revision: 5881

Added:
   core/trunk/src/test/java/org/jboss/cache/commands/write/RemoveNodeCommandTest.java
Modified:
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
   core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
   core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
   core/trunk/src/test/java/org/jboss/cache/commands/write/PutDataMapCommandTest.java
   core/trunk/src/test/java/org/jboss/cache/commands/write/PutKeyValueCommandTest.java
   core/trunk/src/test/java/org/jboss/cache/commands/write/RemoveKeyCommandTest.java
   core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
   core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java
   core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
   core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
   core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java
Log:
JBCACHE-1338 - added unit tests for write commands and write commands refactorings

Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -63,32 +63,28 @@
    public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
    {
       Fqn transformed = getBackupFqn(command.getFqn());
-      return factory.buildPutDataMapCommand(null, transformed, command.getData(),
-            command.isCreateUndoOps(), command.isEraseContents());
+      return factory.buildPutDataMapCommand(null, transformed, command.getData());
    }
 
    @Override
    public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
    {
       Fqn transformed = getBackupFqn(command.getFqn());
-      return factory.buildPutKeyValueCommand(null, transformed, command.getKey(),
-            command.getValue(), command.isCreateUndoOps());
+      return factory.buildPutKeyValueCommand(null, transformed, command.getKey(), command.getValue());
    }
 
    @Override
    public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
    {
       Fqn transformed = getBackupFqn(command.getFqn());
-      return factory.buildPutForExternalReadCommand(null, transformed, command.getKey(),
-            command.getValue(), command.isCreateUndoOps());
+      return factory.buildPutForExternalReadCommand(null, transformed, command.getKey(), command.getValue());
    }
 
    @Override
    public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
    {
       Fqn transformed = getBackupFqn(command.getFqn());
-      return factory.buildRemoveNodeCommand(command.getGlobalTransaction(), transformed, command.isEviction(),
-            command.isSkipSendingNodeEvents(), command.isCreateUndoOps());
+      return factory.buildRemoveNodeCommand(command.getGlobalTransaction(), transformed);
    }
 
    @Override

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -68,10 +68,6 @@
 
    /**
     * Performs a cleanup on nodes that would have been previously gravitated away from the current cache instance.
-    *
-    * @param ctx invocation context, ignored
-    * @return null
-    * @throws Throwable
     */
    public Object perform(InvocationContext ctx) throws Throwable
    {
@@ -128,7 +124,7 @@
    private boolean executeRemove(GlobalTransaction gtx, Fqn toRemove) throws Throwable
    {
       Object result;
-      RemoveNodeCommand removeBackupCommand = commandsFactory.buildRemoveNodeCommand(gtx, toRemove, true, true, false);
+      RemoveNodeCommand removeBackupCommand = commandsFactory.buildRemoveNodeCommand(gtx, toRemove);
 
       InvocationContext ctx = invoker.getInvocationContext();
       ctx.getOptionOverrides().setCacheModeLocal(true);

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -32,17 +32,13 @@
 
    /* parameters*/
    private Map data;
-   boolean createUndoOps;
-   private boolean eraseContents;
    private Map oldData;
 
-   public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContents)
+   public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data)
    {
       this.globalTransaction = globalTransaction;
       this.fqn = fqn;
       this.data = data;
-      this.createUndoOps = createUndoOps;
-      this.eraseContents = eraseContents;
    }
 
    public PutDataMapCommand()
@@ -50,17 +46,13 @@
    }
 
    /**
-    * Adds the provided data map to the data map in the node referenced by the specified Fqn, optionally erasing the node's
-    * data first (if {@link #isEraseContents()} is <tt>true</tt>).
-    *
-    * @param ctx invocation context
-    * @return null
+    * Adds the provided data map to the data map in the node referenced by the specified Fqn.
     */
    public Object perform(InvocationContext ctx)
    {
       if (trace)
       {
-         log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", " + data + " undo=" + createUndoOps + " erase=" + eraseContents + ")");
+         log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", " + data + ")");
       }
       NodeSPI nodeSPI = dataContainer.peekStrict(globalTransaction, fqn, false);
       Map existingData = nodeSPI.getDataDirect();
@@ -70,8 +62,6 @@
       }
       notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, oldData == null ? Collections.emptyMap() : oldData, ctx);
 
-      if (eraseContents) nodeSPI.clearDataDirect();
-
       nodeSPI.putAllDirect(data);
       notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_MAP, nodeSPI.getDataDirect(), ctx);
       return null;
@@ -98,16 +88,6 @@
       return data;
    }
 
-   public boolean isEraseContents()
-   {
-      return eraseContents;
-   }
-
-   public boolean isCreateUndoOps()
-   {
-      return createUndoOps;
-   }
-
    public void setData(Map data)
    {
       this.data = data;
@@ -117,11 +97,10 @@
    {
       if (isVersioned())
       {
-         return eraseContents ? ERASE_VERSIONED_METHOD_ID : VERSIONED_METHOD_ID;
-      }
-      else
+         return VERSIONED_METHOD_ID;
+      } else
       {
-         return eraseContents ? ERASE_METHOD_ID : METHOD_ID;
+         return METHOD_ID;
       }
    }
 
@@ -129,9 +108,9 @@
    public Object[] getParameters()
    {
       if (isVersioned())
-         return new Object[]{globalTransaction, fqn, data, createUndoOps, dataVersion};
+         return new Object[]{globalTransaction, fqn, data, false, dataVersion};
       else
-         return new Object[]{globalTransaction, fqn, data, createUndoOps};
+         return new Object[]{globalTransaction, fqn, data, false};
    }
 
    @Override
@@ -140,8 +119,6 @@
       globalTransaction = (GlobalTransaction) args[0];
       fqn = (Fqn) args[1];
       data = (Map) args[2];
-      createUndoOps = (Boolean) args[3];
-      eraseContents = commandId == ERASE_METHOD_ID;
       if (isVersionedId(commandId)) dataVersion = (DataVersion) args[4];
    }
 
@@ -157,11 +134,7 @@
       if (this == o) return true;
       if (o == null || getClass() != o.getClass()) return false;
       if (!super.equals(o)) return false;
-
       PutDataMapCommand that = (PutDataMapCommand) o;
-
-      if (createUndoOps != that.createUndoOps) return false;
-      if (eraseContents != that.eraseContents) return false;
       if (data != null ? !data.equals(that.data) : that.data != null) return false;
       if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
          return false;
@@ -175,8 +148,6 @@
       int result = super.hashCode();
       result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
       result = 31 * result + (data != null ? data.hashCode() : 0);
-      result = 31 * result + (createUndoOps ? 1 : 0);
-      result = 31 * result + (eraseContents ? 1 : 0);
       return result;
    }
 
@@ -185,8 +156,6 @@
    {
       return "PutDataMapCommand{" +
             "fqn=" + fqn +
-            ", eraseContents=" + eraseContents +
-            ", createUndoOps=" + createUndoOps +
             ", dataVersion=" + dataVersion +
             ", data=" + data +
             ", globalTransaction=" + globalTransaction +
@@ -197,9 +166,4 @@
    {
       return oldData;
    }
-
-   void setEraseContents(boolean eraseContents)
-   {
-      this.eraseContents = eraseContents;
-   }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -16,9 +16,9 @@
    public static final int METHOD_ID = 45;
    public static final int VERSIONED_METHOD_ID = 46;
 
-   public PutForExternalReadCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
+   public PutForExternalReadCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value)
    {
-      super(gtx, fqn, key, value, createUndoOps);
+      super(gtx, fqn, key, value);
    }
 
    public PutForExternalReadCommand()

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -31,16 +31,14 @@
    /* parametres */
    protected Object key;
    protected Object value;
-   protected boolean createUndoOps;
    protected Object oldValue;
 
-   public PutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
+   public PutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value)
    {
       this.globalTransaction = gtx;
       this.fqn = fqn;
       this.key = key;
       this.value = value;
-      this.createUndoOps = createUndoOps;
    }
 
    public PutKeyValueCommand()
@@ -98,11 +96,6 @@
       return value;
    }
 
-   public boolean isCreateUndoOps()
-   {
-      return createUndoOps;
-   }
-
    public void setKey(Object key)
    {
       this.key = key;
@@ -129,9 +122,9 @@
    public Object[] getParameters()
    {
       if (isVersioned())
-         return new Object[]{globalTransaction, fqn, key, value, createUndoOps, dataVersion};
+         return new Object[]{globalTransaction, fqn, key, value, false, dataVersion};
       else
-         return new Object[]{globalTransaction, fqn, key, value, createUndoOps};
+         return new Object[]{globalTransaction, fqn, key, value, false};
    }
 
    @Override
@@ -141,7 +134,6 @@
       fqn = (Fqn) args[1];
       key = args[2];
       value = args[3];
-      createUndoOps = (Boolean) args[4];
       if (isVersionedId(commandId)) dataVersion = (DataVersion) args[5];
    }
 
@@ -154,7 +146,6 @@
 
       PutKeyValueCommand that = (PutKeyValueCommand) o;
 
-      if (createUndoOps != that.createUndoOps) return false;
       if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
          return false;
       if (key != null ? !key.equals(that.key) : that.key != null) return false;
@@ -170,7 +161,6 @@
       result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
       result = 31 * result + (key != null ? key.hashCode() : 0);
       result = 31 * result + (value != null ? value.hashCode() : 0);
-      result = 31 * result + (createUndoOps ? 1 : 0);
       return result;
    }
 
@@ -189,7 +179,6 @@
             ", globalTransaction=" + globalTransaction +
             ", key=" + key +
             ", value=" + value +
-            ", createUndoOps=" + createUndoOps +
             ", oldValue=" + oldValue +
             '}';
    }

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -5,6 +5,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
+import org.jboss.cache.NodeNotExistsException;
 import org.jboss.cache.commands.Visitor;
 import org.jboss.cache.notifications.event.NodeModifiedEvent;
 import org.jboss.cache.optimistic.DataVersion;
@@ -71,8 +72,12 @@
 
    public void rollback()
    {
-      NodeSPI targetNode = dataContainer.peekStrict(globalTransaction, fqn, true);
-      targetNode.putDirect(key, oldValue);
+      NodeSPI targetNode = dataContainer.peek(fqn, false, true);
+      if (targetNode == null) throw new NodeNotExistsException("No such node: " + fqn);
+      if (oldValue != null)
+      {
+         targetNode.putDirect(key, oldValue);
+      }
    }
 
    public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -26,20 +26,15 @@
    private static boolean trace = log.isTraceEnabled();
 
    /*parameters*/
-   private boolean createUndoOps;
-   private boolean skipSendingNodeEvents;
-   private boolean eviction;
-   private Fqn parentFqn;
-   private NodeSPI targetNode;
-   private Map originalData;
+   private boolean skipSendingNodeEvents = false;
+   protected Fqn parentFqn;
+   protected NodeSPI targetNode;
+   protected Map originalData;
 
-   public RemoveNodeCommand(GlobalTransaction globalTransaction, Fqn fqn, boolean createUndoOps, boolean skipSendingNodeEvents, boolean eviction)
+   public RemoveNodeCommand(GlobalTransaction globalTransaction, Fqn fqn)
    {
       this.globalTransaction = globalTransaction;
       this.fqn = fqn;
-      this.createUndoOps = createUndoOps;
-      this.skipSendingNodeEvents = skipSendingNodeEvents;
-      this.eviction = eviction;
    }
 
    public RemoveNodeCommand()
@@ -48,16 +43,10 @@
 
    /**
     * Removes the node referenced by the specified Fqn.
-    *
-    * @param ctx invocation context
-    * @return true if the node was found and removed, false otherwise.
     */
    public Object perform(InvocationContext ctx)
    {
-      NodeSPI parentNode;
-      if (trace)
-         log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", undo=" + createUndoOps + ")");
-
+      if (trace) log.trace("perform(" + globalTransaction + ", \"" + fqn + ")");
       // Find the node. This will add the temporarily created parent nodes to the TX's node list if globalTransaction != null)
       targetNode = dataContainer.peekVersioned(fqn, dataVersion, true);
       if (targetNode == null)
@@ -65,72 +54,43 @@
          if (trace) log.trace("node " + fqn + " not found");
          return false;
       }
+      notifyBeforeRemove(targetNode, ctx);
 
-      notifyBeforeEviction(targetNode, ctx);
+      NodeSPI parentNode = targetNode.getParent();
+      boolean found = targetNode.isValid() && !targetNode.isDeleted();
+      targetNode.markAsDeleted(true, true);
 
-      parentNode = targetNode.getParent();
-      boolean found;
-
-      // remove subtree from parent
-      if (eviction)
+      if (globalTransaction != null && found)
       {
-         // if there is no parent node and the fqn is root, found == true otherwise found == false.
-         found = targetNode.isValid() && parentNode == null ? fqn.isRoot() : parentNode.removeChildDirect(targetNode.getFqn().getLastElement());
+         prepareForRollback(parentNode);
       }
-      else
-      {
-         found = targetNode.isValid() && !targetNode.isDeleted();
-         targetNode.markAsDeleted(true, true);
-      }
+      notifyAfterRemove(ctx);
+      return found;
+   }
 
-      if (eviction && parentNode != null)
+   private void prepareForRollback(NodeSPI parentNode)
+   {
+      parentFqn = parentNode.getFqn();
+      Map targetData = targetNode.getDataDirect();
+      if (!targetData.isEmpty())
       {
-         parentNode.setChildrenLoaded(false);
+         originalData = new HashMap(targetNode.getDataDirect());
       }
-
-      // create a compensating method call (reverting the effect of
-      // this modification) and put it into the TX's undo list.
-      if (globalTransaction != null && createUndoOps && !eviction && found)
-      {
-         parentFqn = parentNode.getFqn();
-         Map targetData = targetNode.getDataDirect();
-         if (!targetData.isEmpty())
-         {
-            originalData = new HashMap(targetNode.getDataDirect());
-         }
-      }
-
-      notifyAfterEviction(ctx);
-      return found;
    }
 
-   private void notifyAfterEviction(InvocationContext ctx)
+   private void notifyBeforeRemove(NodeSPI n, InvocationContext ctx)
    {
       if (!skipSendingNodeEvents)
       {
-         if (eviction)
-         {
-            notifier.notifyNodeEvicted(fqn, false, ctx);
-         }
-         else
-         {
-            notifier.notifyNodeRemoved(fqn, false, null, ctx);
-         }
+         notifier.notifyNodeRemoved(fqn, true, n.getDataDirect(), ctx);
       }
    }
 
-   private void notifyBeforeEviction(NodeSPI n, InvocationContext ctx)
+   private void notifyAfterRemove(InvocationContext ctx)
    {
       if (!skipSendingNodeEvents)
       {
-         if (eviction)
-         {
-            notifier.notifyNodeEvicted(fqn, true, ctx);
-         }
-         else
-         {
-            notifier.notifyNodeRemoved(fqn, true, n.getDataDirect(), ctx);
-         }
+         notifier.notifyNodeRemoved(fqn, false, null, ctx);
       }
    }
 
@@ -173,16 +133,6 @@
       return skipSendingNodeEvents;
    }
 
-   public boolean isCreateUndoOps()
-   {
-      return createUndoOps;
-   }
-
-   public boolean isEviction()
-   {
-      return eviction;
-   }
-
    public int getCommandId()
    {
       return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
@@ -192,9 +142,9 @@
    public Object[] getParameters()
    {
       if (isVersioned())
-         return new Object[]{globalTransaction, fqn, createUndoOps, skipSendingNodeEvents, dataVersion};
+         return new Object[]{globalTransaction, fqn, true, skipSendingNodeEvents, dataVersion};
       else
-         return new Object[]{globalTransaction, fqn, createUndoOps, skipSendingNodeEvents};
+         return new Object[]{globalTransaction, fqn, true, skipSendingNodeEvents};
    }
 
    @Override
@@ -202,7 +152,6 @@
    {
       globalTransaction = (GlobalTransaction) args[0];
       fqn = (Fqn) args[1];
-      createUndoOps = (Boolean) args[2];
       skipSendingNodeEvents = (Boolean) args[3];
       if (isVersionedId(commandId)) dataVersion = (DataVersion) args[4];
    }
@@ -216,8 +165,6 @@
 
       RemoveNodeCommand that = (RemoveNodeCommand) o;
 
-      if (createUndoOps != that.createUndoOps) return false;
-      if (eviction != that.eviction) return false;
       if (skipSendingNodeEvents != that.skipSendingNodeEvents) return false;
       if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
          return false;
@@ -230,9 +177,7 @@
    {
       int result = super.hashCode();
       result = 31 * result + (globalTransaction != null ? globalTransaction.hashCode() : 0);
-      result = 31 * result + (createUndoOps ? 1 : 0);
       result = 31 * result + (skipSendingNodeEvents ? 1 : 0);
-      result = 31 * result + (eviction ? 1 : 0);
       return result;
    }
 
@@ -254,9 +199,7 @@
             "fqn=" + fqn +
             ", dataVersion=" + dataVersion +
             ", globalTransaction=" + globalTransaction +
-            ", createUndoOps=" + createUndoOps +
             ", skipSendingNodeEvents=" + skipSendingNodeEvents +
-            ", eviction=" + eviction +
             ", parentFqn=" + parentFqn +
             ", targetNode=" + targetNode +
             '}';

Modified: core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -17,12 +17,7 @@
 import org.jboss.cache.commands.read.GetKeysCommand;
 import org.jboss.cache.commands.read.GetNodeCommand;
 import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
+import org.jboss.cache.commands.remote.*;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
@@ -87,23 +82,23 @@
       this.txManager = txManager;
    }
 
-   public PutDataMapCommand buildPutDataMapCommand(GlobalTransaction gtx, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContents)
+   public PutDataMapCommand buildPutDataMapCommand(GlobalTransaction gtx, Fqn fqn, Map data)
    {
-      PutDataMapCommand cmd = new PutDataMapCommand(gtx, fqn, data, createUndoOps, eraseContents);
+      PutDataMapCommand cmd = new PutDataMapCommand(gtx, fqn, data);
       cmd.initialize(notifier, dataContainer);
       return cmd;
    }
 
-   public PutKeyValueCommand buildPutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
+   public PutKeyValueCommand buildPutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value)
    {
-      PutKeyValueCommand command = new PutKeyValueCommand(gtx, fqn, key, value, createUndoOps);
+      PutKeyValueCommand command = new PutKeyValueCommand(gtx, fqn, key, value);
       command.initialize(notifier, dataContainer);
       return command;
    }
 
-   public PutForExternalReadCommand buildPutForExternalReadCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
+   public PutForExternalReadCommand buildPutForExternalReadCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value)
    {
-      PutForExternalReadCommand command = new PutForExternalReadCommand(gtx, fqn, key, value, createUndoOps);
+      PutForExternalReadCommand command = new PutForExternalReadCommand(gtx, fqn, key, value);
       command.initialize(notifier, dataContainer);
       return command;
    }
@@ -151,9 +146,9 @@
       return command;
    }
 
-   public RemoveNodeCommand buildRemoveNodeCommand(GlobalTransaction gtx, Fqn fqn, boolean eviction, boolean skipSendingNodeEvents, boolean createUndoOps)
+   public RemoveNodeCommand buildRemoveNodeCommand(GlobalTransaction gtx, Fqn fqn)
    {
-      RemoveNodeCommand command = new RemoveNodeCommand(gtx, fqn, createUndoOps, skipSendingNodeEvents, eviction);
+      RemoveNodeCommand command = new RemoveNodeCommand(gtx, fqn);
       command.initialize(notifier, dataContainer);
       return command;
    }
@@ -180,8 +175,7 @@
          command.initialize(txManager);
          command.initialize(cacheSpi, dataContainer, notifier);
          return command;
-      }
-      else
+      } else
       {
          InvalidateCommand command = new InvalidateCommand(fqn);
          command.initialize(cacheSpi, dataContainer, notifier);
@@ -460,8 +454,7 @@
                returnValue.initialize(txManager);
                returnValue.initialize(cacheSpi, dataContainer, notifier);
                command = returnValue;
-            }
-            else
+            } else
             {
                InvalidateCommand returnValue = new InvalidateCommand();
                returnValue.initialize(cacheSpi, dataContainer, notifier);

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -246,21 +246,11 @@
       {
          return returnValue;
       }
-      if (command.isEraseContents())
-      {
-         loader.removeData(command.getFqn());
-         // if we are erasing all the data then consider this node loaded
-         NodeSPI n = dataContainer.peek(command.getFqn(), false, false);
-         n.setDataLoaded(true);
-         return returnValue;
-      }
-      else
-      {
-         loader.put(command.getFqn(), command.getData());
-         if (getStatisticsEnabled()) cacheStores++;
 
-         return returnValue;
-      }
+      loader.put(command.getFqn(), command.getData());
+      if (getStatisticsEnabled()) cacheStores++;
+
+      return returnValue;
    }
 
    @Override
@@ -388,14 +378,7 @@
       public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
       {
          if (generateStatistics) putCount++;
-         if (command.isEraseContents())
-         {
-            modifications.add(new Modification(Modification.ModificationType.PUT_DATA_ERASE, command.getFqn(), command.getData()));
-         }
-         else
-         {
-            modifications.add(new Modification(Modification.ModificationType.PUT_DATA, command.getFqn(), command.getData()));
-         }
+         modifications.add(new Modification(Modification.ModificationType.PUT_DATA, command.getFqn(), command.getData()));
          affectedFqns.add(command.getFqn());
          return null;
       }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -116,7 +116,7 @@
                size = command.getData().size();
             }
             EvictedEventNode event = new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT, size);
-            event.setResetElementCount(command.isEraseContents());
+            event.setResetElementCount(false);
             registerEvictionEventToRegionManager(event, r);
          }
       }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -280,7 +280,7 @@
       @Override
       public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
       {
-         VersionedDataCommand clone = commandsFactory.buildPutDataMapCommand(null, command.getFqn(), command.getData(), command.isCreateUndoOps(), command.isEraseContents());
+         VersionedDataCommand clone = commandsFactory.buildPutDataMapCommand(null, command.getFqn(), command.getData());
          setDataVersion(clone, command.getFqn());
          return null;
       }
@@ -288,7 +288,7 @@
       @Override
       public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
       {
-         VersionedDataCommand clone = commandsFactory.buildPutKeyValueCommand(null, command.getFqn(), command.getKey(), command.getValue(), command.isCreateUndoOps());
+         VersionedDataCommand clone = commandsFactory.buildPutKeyValueCommand(null, command.getFqn(), command.getKey(), command.getValue());
          setDataVersion(clone, command.getFqn());
          return null;
       }
@@ -296,7 +296,7 @@
       @Override
       public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
       {
-         VersionedDataCommand clone = commandsFactory.buildPutForExternalReadCommand(null, command.getFqn(), command.getKey(), command.getValue(), command.isCreateUndoOps());
+         VersionedDataCommand clone = commandsFactory.buildPutForExternalReadCommand(null, command.getFqn(), command.getKey(), command.getValue());
          setDataVersion(clone, command.getFqn());
          return null;
       }
@@ -304,8 +304,7 @@
       @Override
       public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
       {
-         VersionedDataCommand clone = commandsFactory.buildRemoveNodeCommand(command.getGlobalTransaction(), command.getFqn(), command.isEviction(),
-               command.isSkipSendingNodeEvents(), command.isCreateUndoOps());
+         VersionedDataCommand clone = commandsFactory.buildRemoveNodeCommand(command.getGlobalTransaction(), command.getFqn());
          setDataVersion(clone, command.getFqn());
          return null;
       }

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -390,7 +390,7 @@
          InvocationContext ctx = invocationContextContainer.get();
          cacheStatusCheck(ctx);
          GlobalTransaction tx = transactionTable.getCurrentTransaction();
-         RemoveNodeCommand command = commandsFactory.buildRemoveNodeCommand(tx, fqn, false, false, true);
+         RemoveNodeCommand command = commandsFactory.buildRemoveNodeCommand(tx, fqn);
          Object retval = invoker.invoke(ctx, command);
          return retval != null && (Boolean) retval;
       }
@@ -432,7 +432,7 @@
    {
       InvocationContext ctx = invocationContextContainer.get();
       cacheStatusCheck(ctx);
-      PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(null, fqn, data, true, false);
+      PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(null, fqn, data);
       invoker.invoke(ctx, command);
    }
 
@@ -450,7 +450,7 @@
       {
          getInvocationContext().getOptionOverrides().setFailSilently(true);
          getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
-         PutForExternalReadCommand command = commandsFactory.buildPutForExternalReadCommand(null, fqn, key, value, false);
+         PutForExternalReadCommand command = commandsFactory.buildPutForExternalReadCommand(null, fqn, key, value);
          invoker.invoke(ctx, command);
       }
       else
@@ -465,7 +465,7 @@
       InvocationContext ctx = invocationContextContainer.get();
       cacheStatusCheck(ctx);
       GlobalTransaction tx = transactionTable.getCurrentTransaction();
-      PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value, false);
+      PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value);
       return (V) invoker.invoke(ctx, command);
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -266,7 +266,7 @@
          childNode.markAsDeleted(false);
          //if we'll rollback the tx data should be added to the node again
          Map oldData = new HashMap(childNode.getDataDirect());
-         PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(ctx.getGlobalTransaction(), fqn, oldData, false, false);
+         PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(ctx.getGlobalTransaction(), fqn, oldData);
          // txTable.get(gtx).addUndoOperation(command); --- now need to make sure this is added to the normal mods list instead
          entry.addModification(command);
          //we're prepared for rollback, now reset the node

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -139,7 +139,7 @@
    {
       Fqn fqn1 = Fqn.fromString("/hello/world");
 
-      PutKeyValueCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false);
+      PutKeyValueCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value");
       ReplicateCommand call2 = new ReplicateCommand(call1);
 
       BuddyManager bm = createBasicBuddyManager();
@@ -157,7 +157,7 @@
    {
       Fqn fqn1 = Fqn.ROOT;
 
-      ReplicableCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false);
+      ReplicableCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value");
       ReplicateCommand call2 = new ReplicateCommand(call1);
 
       BuddyManager bm = createBasicBuddyManager();
@@ -177,10 +177,10 @@
       Fqn fqn3 = Fqn.fromString("/hello/again");
       Fqn fqn4 = Fqn.fromString("/buddy/replication");
 
-      PutKeyValueCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false);
-      PutKeyValueCommand call2 = new PutKeyValueCommand(null, fqn2, "key", "value", false);
-      PutKeyValueCommand call3 = new PutKeyValueCommand(null, fqn3, "key", "value", false);
-      PutKeyValueCommand call4 = new PutKeyValueCommand(null, fqn4, "key", "value", false);
+      PutKeyValueCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value");
+      PutKeyValueCommand call2 = new PutKeyValueCommand(null, fqn2, "key", "value");
+      PutKeyValueCommand call3 = new PutKeyValueCommand(null, fqn3, "key", "value");
+      PutKeyValueCommand call4 = new PutKeyValueCommand(null, fqn4, "key", "value");
       List<ReplicableCommand> list = new ArrayList<ReplicableCommand>();
       list.add(call1);
       list.add(call2);

Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/PutDataMapCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/PutDataMapCommandTest.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/PutDataMapCommandTest.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -2,20 +2,17 @@
 
 import static org.easymock.EasyMock.*;
 import org.easymock.IMocksControl;
-import org.jboss.cache.commands.read.AbstractDataCommandTest;
 import org.jboss.cache.transaction.GlobalTransaction;
 import org.jboss.cache.notifications.Notifier;
 import org.jboss.cache.notifications.event.NodeModifiedEvent;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.DataContainer;
-import org.jboss.cache.NodeSPI;
 import org.jboss.cache.mock.NodeSpiMock;
 import org.testng.annotations.Test;
 import org.testng.annotations.BeforeMethod;
 
 import java.util.Map;
 import java.util.HashMap;
-import java.util.Collections;
 
 /**
  * Tester class for {@link PutDataMapCommand}
@@ -42,7 +39,7 @@
    {
       gtx = new GlobalTransaction();
       dataMap = new HashMap();
-      command = new PutDataMapCommand(gtx, testFqn, dataMap, true, false);
+      command = new PutDataMapCommand(gtx, testFqn, dataMap);
       control = createStrictControl();
       notifier = control.createMock(Notifier.class);
       container = control.createMock(DataContainer.class);
@@ -66,33 +63,8 @@
       assert command.getOldData().get("k").equals("v");
       control.verify();
    }
-   public void testAddDataWithErase()
-   {
-      command.setEraseContents(true);
-      expect(container.peekStrict(gtx, testFqn, false)).andReturn(node);
-      dataMap.put("k2", "v2");
-      Map expected = new HashMap(dataMap);
-      notifier.notifyNodeModified(testFqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, node.getData(), null);
-      notifier.notifyNodeModified(testFqn, false, NodeModifiedEvent.ModificationType.PUT_MAP, expected, null);
+   
 
-      control.replay();
-      assert null == command.perform(null) : "null result is always expected";
-      assert command.getOldData().size() == 1;
-      assert command.getOldData().get("k").equals("v");
-      assert node.getData().size() == 1;
-      assert node.getData().get("k2").equals("v2");
-      control.verify();
-      control.reset();
-      
-      //check rollback now
-      expect(container.peek(testFqn, false, true)).andReturn(node);
-      control.replay();
-      command.rollback();
-      assert node.getData().size() == 1;
-      assert node.getData().containsKey("k");
-      control.verify();
-   }
-
    public void testRollbackNonexistentNode()
    {
       expect(container.peek(testFqn, false, true)).andReturn(null);

Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/PutKeyValueCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/PutKeyValueCommandTest.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/PutKeyValueCommandTest.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -7,7 +7,6 @@
 
 import java.util.Map;
 import java.util.HashMap;
-import java.util.Collections;
 
 /**
  * tester class for {@link PutKeyValueCommand}.
@@ -22,7 +21,7 @@
 
    public AbstractVersionedDataCommand moreSetUp()
    {
-      command = new PutForExternalReadCommand(globalTransaction, fqn, "k", "v", true);
+      command = new PutForExternalReadCommand(globalTransaction, fqn, "k", "v");
       return command;
    }
 
@@ -63,7 +62,6 @@
       assert nodes.adfNode.getData().size() == 1;
       assert "existingValue".equals(nodes.adfNode.getData().get("existingKey"));
       control.verify();
-      
    }
 
    public void testOverWriteData()

Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/RemoveKeyCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/RemoveKeyCommandTest.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/RemoveKeyCommandTest.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -47,7 +47,17 @@
       notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.REMOVE_DATA, expected, ctx);
       control.replay();
       assert null == command.perform(ctx);
+      assert nodes.adfgNode.getData().size() == 1;
+      assert "newValue".equals(nodes.adfgNode.getData().get("newKey"));
       control.verify();
+
+      control.reset();
+      expect(container.peek(fqn, false, true)).andReturn(nodes.adfgNode);
+      control.replay();
+      command.rollback();
+      assert nodes.adfgNode.getData().size() == 1;
+      assert "newValue".equals(nodes.adfgNode.getData().get("newKey"));
+      control.verify();
    }
 
    public void testRemoveExistentPair()
@@ -57,11 +67,18 @@
       nodes.adfgNode.putAll(expected);
       expect(container.peek(fqn, false, false)).andReturn(nodes.adfgNode);
       notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.REMOVE_DATA, expected, ctx);
-      expected = new HashMap();
-      expected.put(key,null);
       notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.REMOVE_DATA, expected, ctx);
       control.replay();
-      assert null == command.perform(ctx);
+      assert "newValue" == command.perform(ctx);
+      assert nodes.adfgNode.getData().get(key) == null;
       control.verify();
+
+      control.reset();
+      expect(container.peek(fqn, false, true)).andReturn(nodes.adfgNode);
+      control.replay();
+      command.rollback();
+      assert nodes.adfgNode.getData().size() == 1;
+      assert "newValue".equals(nodes.adfgNode.getData().get(key));
+      control.verify();
    }
 }

Added: core/trunk/src/test/java/org/jboss/cache/commands/write/RemoveNodeCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/RemoveNodeCommandTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/RemoveNodeCommandTest.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -0,0 +1,82 @@
+package org.jboss.cache.commands.write;
+
+import static org.easymock.EasyMock.*;
+import org.testng.annotations.Test;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+/**
+ * tester for  {@link RemoveNodeCommand}.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ */
+ at Test(groups = "unit")
+public class RemoveNodeCommandTest extends AbstractVersionedDataCommandTest
+{
+   RemoveNodeCommand command;
+
+   public AbstractVersionedDataCommand moreSetUp()
+   {
+      command = new RemoveNodeCommand(globalTransaction, fqn);
+      command.setDataVersion(dataVersion);
+      return command;
+   }
+
+   public void testNonExistentNode()
+   {
+      expect(container.peekVersioned(fqn, dataVersion, true)).andReturn(null);
+      control.replay();
+      assert Boolean.FALSE == command.perform(ctx) : "nonexistent node was not remove; false expected";
+   }
+
+   public void testRemovalNoNotificationsValidNode()
+   {
+      //aditional setup
+      command.setSkipSendingNodeEvents(true); //no notification
+      nodes.adfNode.put("akey","avalue");
+      ctx.setGlobalTransaction(new GlobalTransaction());
+
+      //check perform
+      expect(container.peekVersioned(fqn, dataVersion, true)).andReturn(nodes.adfNode);
+      control.replay();
+      assert Boolean.TRUE == command.perform(ctx);
+      assert nodes.adfgNode.isDeleted();
+      assert nodes.adfhNode.isDeleted();
+      assert command.originalData != null;
+      control.verify();
+
+      //check rollback
+      control.reset();
+      nodes.adNode.removeChild("f");
+      expect(container.peek(nodes.ad)).andReturn(nodes.adNode);
+      control.replay();
+      command.rollback();
+      assert nodes.adNode.hasChild("f");
+   }
+   public void testRemovalNoNotificationsInvalidNode()
+   {
+      command.setSkipSendingNodeEvents(true); //no notification
+      nodes.adfNode.setValid(false, false);   //invalid node
+      
+      expect(container.peekVersioned(fqn, dataVersion, true)).andReturn(nodes.adfNode);
+      control.replay();
+      assert Boolean.FALSE == command.perform(ctx);
+      assert nodes.adfgNode.isDeleted();
+      assert nodes.adfhNode.isDeleted();
+      control.verify();
+   }
+   
+   public void testRemovalWithNotificationsInvalidNode()
+   {
+      nodes.adfNode.setValid(false, false);   //invalid node
+
+      expect(container.peekVersioned(fqn, dataVersion, true)).andReturn(nodes.adfNode);
+      notifier.notifyNodeRemoved(fqn, true, nodes.adfNode.getDataDirect(), ctx);
+      notifier.notifyNodeRemoved(fqn, false, null, ctx);
+      control.replay();
+      assert Boolean.FALSE == command.perform(ctx);
+      assert nodes.adfgNode.isDeleted();
+      assert nodes.adfhNode.isDeleted();
+      control.verify();
+   }
+}

Modified: core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -303,7 +303,7 @@
       // this region is node granularity
       Fqn fqn = Fqn.fromString("/a/b/c");
 
-      PutDataMapCommand putDataMapCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data, false, false);
+      PutDataMapCommand putDataMapCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data);
       invoker.invoke(putDataMapCommand);
 
       Region region = regionManager.getRegion(fqn.toString(), false);
@@ -324,7 +324,7 @@
 
       for (int i = 0; i < 100; i++)
       {
-         PutKeyValueCommand pkvCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, i, "value", false);
+         PutKeyValueCommand pkvCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, i, "value");
          invoker.invoke(pkvCommand);
 
          assertEquals("value", cache.peek(fqn, false, false).getDirect(i));
@@ -341,7 +341,7 @@
       assertNull(region.takeLastEventNode());
 
       fqn = Fqn.fromString("/a/b");
-      PutDataMapCommand putCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data, false, false);
+      PutDataMapCommand putCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data);
       invoker.invoke(putCommand);
       event = regionManager.getRegion(fqn.toString(), false).takeLastEventNode();
       assertFalse(event.isResetElementCount());
@@ -360,7 +360,7 @@
          assertEquals(i, node.getDirect(i));
       }
 
-      PutDataMapCommand putDataMap = commandsFactory.buildPutDataMapCommand(null, fqn, data, false, true);
+      PutDataMapCommand putDataMap = commandsFactory.buildPutDataMapCommand(null, fqn, data);
       invoker.invoke(putDataMap);
       event = regionManager.getRegion(fqn.toString(), false).takeLastEventNode();
       assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
@@ -389,7 +389,7 @@
       Object key = "key";
       Object value = "value";
 
-      PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false);
+      PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value);
       invoker.invoke(command);
       assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
       EvictedEventNode event = region.takeLastEventNode();
@@ -399,7 +399,7 @@
       assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
       assertNull(region.takeLastEventNode());
 
-      command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false);
+      command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value);
       invoker.invoke(command);
       assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
       event = region.takeLastEventNode();
@@ -427,7 +427,7 @@
       assertEquals(fqn, event.getFqn());
       assertNull(region.takeLastEventNode());
 
-      RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveNodeCommand(null, fqn, false, false, false);
+      RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveNodeCommand(null, fqn);
       invoker.invoke(removeNodeCommand);
 
       assertNull(cache.peek(fqn, false, false));
@@ -482,7 +482,7 @@
       // this region is node granularity
       Fqn fqn = Fqn.fromString("/a/b/c");
 
-      PutDataMapCommand putDataCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data, false, false);
+      PutDataMapCommand putDataCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data);
       invoker.invoke(putDataCommand);
 
       Region region = regionManager.getRegion(fqn.toString(), false);
@@ -500,7 +500,7 @@
       assertEquals(fqn, event.getFqn());
       assertNull(region.takeLastEventNode());
 
-      RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveNodeCommand(null, fqn, false, false, false);
+      RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveNodeCommand(null, fqn);
       invoker.invoke(removeNodeCommand);
       assertNull(cache.getNode(fqn));
       event = region.takeLastEventNode();
@@ -510,7 +510,7 @@
 
       Object key = "key";
       Object value = "value";
-      PutKeyValueCommand putKeyValueCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false);
+      PutKeyValueCommand putKeyValueCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value);
       invoker.invoke(putKeyValueCommand);
       assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
       event = region.takeLastEventNode();

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -152,7 +152,7 @@
 
    public void testObjectFromByteBuffer() throws Exception
    {
-      PutKeyValueCommand put = new PutKeyValueCommand(null, A_B, "name", "Joe", false);
+      PutKeyValueCommand put = new PutKeyValueCommand(null, A_B, "name", "Joe");
       ReplicateCommand replicate = new ReplicateCommand(put);
 
       rman.setDefaultInactive(true);

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -29,7 +29,7 @@
       Map map = createMap(size);
       Fqn fqn = Fqn.fromString("/my/stuff");
       String key = "key";
-      PutKeyValueCommand putCommand = new PutKeyValueCommand(null, fqn, key, map, false);
+      PutKeyValueCommand putCommand = new PutKeyValueCommand(null, fqn, key, map);
       ReplicateCommand replicateCommand = new ReplicateCommand(putCommand);
 
       byte[] buf = marshaller.objectToByteBuffer(replicateCommand);

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -112,7 +112,7 @@
    public void testMethodCall() throws Exception
    {
       Fqn fqn = Fqn.fromElements(3, false);
-      ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false);
+      ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value");
       byte[] asBytes = marshaller.objectToByteBuffer(cmd);
       Object o2 = marshaller.objectFromByteBuffer(asBytes);
 
@@ -125,7 +125,7 @@
    public void testNestedMethodCall() throws Exception
    {
       Fqn fqn = Fqn.fromElements(3, false);
-      ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false);
+      ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value");
       ReplicableCommand replicateCmd = new ReplicateCommand(cmd);
       byte[] asBytes = marshaller.objectToByteBuffer(replicateCmd);
       Object o2 = marshaller.objectFromByteBuffer(asBytes);
@@ -215,12 +215,12 @@
       Fqn f = Fqn.fromElements("BlahBlah", 3, false);
       String k = "key", v = "value";
 
-      ReplicableCommand cmd = new PutKeyValueCommand(null, f, k, v, true);
+      ReplicableCommand cmd = new PutKeyValueCommand(null, f, k, v);
       ReplicableCommand replCmd = new ReplicateCommand(cmd);
 
       calls.add(replCmd);
 
-      cmd = new PutKeyValueCommand(null, f, k, v, true);
+      cmd = new PutKeyValueCommand(null, f, k, v);
       replCmd = new ReplicateCommand(cmd);
 
       calls.add(replCmd);

Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -36,11 +36,11 @@
 
       byteStream = new ByteArrayOutputStream();
       stream = new ObjectOutputStream(byteStream);
-      command1 = new PutDataMapCommand(null, Fqn.ROOT, null, false, true);
+      command1 = new PutDataMapCommand(null, Fqn.ROOT, null);
 
       list.clear();
       list.add(command1);
-      list.add(new PutDataMapCommand(null, Fqn.ROOT, null, false, true));
+      list.add(new PutDataMapCommand(null, Fqn.ROOT, null));
       prepareComand = new PrepareCommand(null, list, null, true);
 
       CacheMarshaller210 cm210 = new CacheMarshaller210();

Modified: core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java	2008-05-21 08:31:52 UTC (rev 5880)
+++ core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java	2008-05-21 16:12:49 UTC (rev 5881)
@@ -100,7 +100,14 @@
 
    public void markAsDeleted(boolean marker, boolean recursive)
    {
-      throw new UnsupportedOperationException();
+      this.isDeleted = marker;
+      if (recursive)
+      {
+         for (NodeSpiMock child : children.values())
+         {
+            child.markAsDeleted(marker, true);
+         }
+      }
    }
 
    public void addChild(Object nodeName, Node nodeToAdd)




More information about the jbosscache-commits mailing list