[jbosscache-commits] JBoss Cache SVN: r7283 - in core/trunk/src: test/java/org/jboss/cache/buddyreplication and 6 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Dec 11 15:26:09 EST 2008


Author: mircea.markus
Date: 2008-12-11 15:26:09 -0500 (Thu, 11 Dec 2008)
New Revision: 7283

Added:
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/AbstractNodeBasedBuddyTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesBackupActivationInactivationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesNoBuddyPoolTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolNoDataGravitationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolWithDataGravitationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoStateTransfer.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithPoolNoDataGravitationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy4Nodes2BackupsTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesBackupActivationInactivationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesNoBuddyPoolTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoPoolNoDataGravitationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoPoolWithDataGravitationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoStateTransfer.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesWithPoolNoDataGravitationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy4Nodes2BackupsTest.java
   core/trunk/src/test/java/org/jboss/cache/factories/UnitTestXmlConfigurationParser.java
   core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java
   core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy2NodesBackupActivationInactivationTest.java
   core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java
Removed:
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithOptimisticLockingTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyBackupActivationInactivationTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyGroupAssignmentTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationContentTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationWithTransactionsTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java
   core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java
   core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyGroupAssignmentTest.java
Modified:
   core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationFailoverTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/GravitationCleanupTest.java
   core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyReplicationFailoverTest.java
   core/trunk/src/test/java/org/jboss/cache/testng/Base.java
   core/trunk/src/test/java/org/jboss/cache/testng/Derived.java
   core/trunk/src/test/java/org/jboss/cache/testng/Other.java
   core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java
Log:
performance improvements to buddy repl tests

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -485,7 +485,7 @@
 
       public boolean needMoreResponses()
       {
-         return numValidResponses < 1 && pendingResponders.size() > 0;
+         return numValidResponses < 1 && pendingResponders.size() == 0;
       }
    }
 }

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/AbstractNodeBasedBuddyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/AbstractNodeBasedBuddyTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/AbstractNodeBasedBuddyTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,35 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.AfterMethod;
+
+import java.util.List;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public abstract class AbstractNodeBasedBuddyTest extends BuddyReplicationTestsBase
+{
+   protected List<CacheSPI<Object, Object>> caches;
+                        
+   protected final String key = "key";
+   protected  final String value = "value";
+
+   @BeforeClass
+   public abstract void createCaches() throws Exception;
+
+   @AfterClass
+   public void killCaches() throws Exception
+   {
+      super.cleanupCaches(caches, true);
+   }
+
+   @AfterMethod 
+   public void tearDown() throws Exception
+   {
+      super.cleanupCaches(caches, false);
+   }
+}

Copied: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesBackupActivationInactivationTest.java (from rev 7262, core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesBackupActivationInactivationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesBackupActivationInactivationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Region;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.util.CachePrinter;
+import org.jboss.cache.util.TestingUtil;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+
+/**
+ * Tests handling of the buddy backup region during region
+ * activation and inactivation
+ *
+ * @author Brian Stansberry
+ */
+ at Test(groups = "functional", testName = "buddyreplication.Buddy2NodesBackupActivationInactivationTest")
+public class Buddy2NodesBackupActivationInactivationTest extends AbstractNodeBasedBuddyTest
+{
+   public static final Fqn A = Fqn.fromString("/a");
+   public static final Fqn A_B = Fqn.fromString("/a/b");
+   public static final String JOE = "JOE";
+   
+
+   @BeforeClass
+   public void createCaches() throws Exception
+   {
+      super.caches = new ArrayList<CacheSPI<Object, Object>>(2);
+      caches.add(createCache());
+      caches.add(createCache());
+   }
+
+   public void testBuddyBackupActivation() throws Exception
+   {
+      CacheSPI cache1 = caches.get(0);
+      CacheSPI cache2 = caches.get(1);
+      Fqn A = Fqn.fromString("/a");
+      TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);
+
+      // create the regions on the two cachePool first
+      Region c1 = cache1.getRegionManager().getRegion(A, Region.Type.MARSHALLING, true);
+      Region c2 = cache2.getRegionManager().getRegion(A, Region.Type.MARSHALLING, true);
+
+      assertFalse(c1.isActive());
+      assertFalse(c2.isActive());
+
+      c1.activate();
+      cache1.put(A_B, "name", JOE);
+
+      waitForBuddy(cache2, cache1, true);
+      waitForBuddy(cache1, cache2, true);
+
+//      TestingUtil.sleepThread(getSleepTimeout());
+
+      System.out.println("Cache dump BEFORE activation");
+      System.out.println("cache1 " + CachePrinter.printCacheDetails(cache1));
+      System.out.println("cache2 " + CachePrinter.printCacheDetails(cache2));
+
+      c2.activate();
+
+      System.out.println("Cache dump AFTER activation");
+      System.out.println("cache1 " + CachePrinter.printCacheDetails(cache1));
+      System.out.println("cache2 " + CachePrinter.printCacheDetails(cache2));
+
+      Fqn fqn = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
+
+      assertEquals("State transferred with activation", JOE, cache2.get(fqn, "name"));
+   }
+
+   public void testReplToInactiveRegion() throws Exception
+   {
+      CacheSPI cache1 = caches.get(0);
+      CacheSPI cache2 = caches.get(1);
+
+      TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);
+      Fqn backupFqn = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
+      Fqn A = Fqn.fromString("/a");
+
+      Region regionA = cache1.getRegion(A, true);
+      regionA.registerContextClassLoader(getClass().getClassLoader());
+      regionA.activate();
+
+      // Activate the buddy backup subtree in the recipient so any
+      // repl message doesn't get rejected due to that tree being inactive
+      cache2.getRegionManager().activate(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
+      cache2.getRegionManager().deactivate(A);
+
+      cache1.put(A_B, "name", JOE);
+
+      assertNull("Should be no replication to inactive region", cache2.get(A_B, "name"));
+
+      assertNull("Should be no replication to inactive backup region", cache2.get(backupFqn, "name"));
+   }
+
+   public void testBuddyBackupInactivation() throws Exception
+   {
+      CacheSPI cache1 = caches.get(0);
+      Fqn A = Fqn.fromString("/a");
+      Region regionA = cache1.getRegion(A, true);
+      regionA.registerContextClassLoader(getClass().getClassLoader());
+      regionA.activate();
+
+      Fqn fqn = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
+      fqn = Fqn.fromRelativeFqn(fqn, A_B);
+      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+      cache1.put(fqn, "name", JOE);
+
+      assertEquals("Put should have been OK", JOE, cache1.get(fqn, "name"));
+
+      regionA.deactivate();
+
+      assertNull("Inactivation should have cleared region", cache1.get(fqn, "name"));
+   }
+
+   protected CacheSPI<Object, Object> createCache() throws Exception
+   {
+      CacheMode mode = CacheMode.REPL_SYNC;
+      Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(mode);
+      CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
+      cache.getConfiguration().setUseRegionBasedMarshalling(true);
+      cache.getConfiguration().setInactiveOnStartup(true);
+      cache.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
+      cache.create();
+      cache.start();
+      return cache;
+   }
+
+   private BuddyReplicationConfig getBuddyConfig() throws Exception
+   {
+      BuddyReplicationConfig brc = new BuddyReplicationConfig();
+      brc.setEnabled(true);
+      brc.setAutoDataGravitation(false);
+      return brc;
+   }
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesBackupActivationInactivationTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesNoBuddyPoolTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesNoBuddyPoolTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesNoBuddyPoolTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,144 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.CachePrinter;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import org.testng.annotations.*;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", sequential = true, testName = "buddyreplication.Buddy2NodesNoBuddyPoolTest")
+public class Buddy2NodesNoBuddyPoolTest extends AbstractNodeBasedBuddyTest
+{
+   @BeforeClass
+   public void createCaches() throws Exception
+   {
+      caches = createCaches(2, false);
+   }
+
+   public void testAddingNewCaches() throws Exception
+   {
+      // get some data in there.
+
+      caches.get(0).put("/cache0", "k", "v");
+      caches.get(1).put("/cache1", "k", "v");
+
+      waitForBuddy(caches.get(0), caches.get(1), true);
+      System.out.println("*** Testing cache 1:");
+      waitForBuddy(caches.get(1), caches.get(0), true);
+
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
+
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
+
+      caches.add(createCache(1, null));
+
+      TestingUtil.blockUntilViewsReceived(60000, caches);
+
+      waitForBuddy(caches.get(0), caches.get(1), true);
+      waitForBuddy(caches.get(1), caches.get(2), true);
+      waitForBuddy(caches.get(2), caches.get(0), true);
+
+
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should have backup region for non-buddy";
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have backup region for buddy";
+
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
+
+      assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
+      assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
+      assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for self";
+
+      // ensure no state transfer has happened!!
+      assert caches.get(2).peek(Fqn.fromString("/cache0"), false) == null : "Unnecessary state should not have been transferred!";
+      assert caches.get(2).peek(Fqn.fromString("/cache1"), false) == null : "Unnecessary state should not have been transferred!";
+
+      // ensure backup state has been transferred.
+      assert caches.get(2).peek(fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), Fqn.fromString("/cache1")), false) != null : "Backup state should have transferred!";
+   }
+
+
+   public void testBuddyJoin() throws Exception
+   {
+      CacheSPI<Object, Object> cache2 = null;
+      String key = "key";
+      String value = "value";
+
+      try
+      {
+         Fqn fqn = Fqn.fromString("/test");
+         Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
+
+         assertNoStaleLocks(caches);
+
+         // put something in cache 1
+         caches.get(1).put(fqn, key, value);
+
+         assertNoStaleLocks(caches);
+
+         // this should be in neither of the other cachePool' "main" trees
+         assertEquals(value, caches.get(1).get(fqn, key));
+         assertFalse("Should be false", caches.get(0).exists(fqn));
+
+         // check the backup trees
+         assertEquals("Buddy should have data in backup tree", value, caches.get(0).get(backupFqn, key));
+
+         assertNoStaleLocks(caches);
+
+         // now add a new cache to the cluster
+         cache2 = createCache(1, null);
+
+         // allow this cache a few msecs to join
+         TestingUtil.blockUntilViewsReceived(3000, caches.get(0), caches.get(1), cache2);
+
+         TestingUtil.sleepThread(2000); // allow buddy group reorg
+
+         List<CacheSPI<Object, Object>> dump = new ArrayList<CacheSPI<Object, Object>>(caches);
+         dump.add(cache2);
+
+         // now cachePool.get(1)'s buddy should be cache2, not cache[0]
+         assertIsBuddy(caches.get(1), cache2, true);
+         // this should still be the same
+         assertIsBuddy(caches.get(0), caches.get(1), true);
+         // and cache2's buddy should be cache[0]
+         assertIsBuddy(cache2, caches.get(0), true);
+
+         // so now the backup data we saw on cache[0] should have been removed.
+         assertFalse("This backup data should have been removed", caches.get(0).exists(backupFqn));
+
+         // while cache2 should now posess this backup (due to a state transfer)
+         assertEquals("Backup state should have been transferred to this new cache instance", value, cache2.get(backupFqn, key));
+
+         caches.get(1).removeNode(fqn);
+         assertNoStaleLocks(caches);
+
+
+         assertFalse("Should be null", caches.get(0).exists(fqn));
+         assertFalse("Should be null", caches.get(1).exists(fqn));
+         assertFalse("Should be null", cache2.exists(fqn));
+
+         // check the backup trees
+         assertFalse("Should be null", caches.get(0).exists(backupFqn));
+         assertFalse("Should be null", caches.get(1).exists(backupFqn));
+         assertFalse("Should be null", cache2.exists(backupFqn));
+         assertNoStaleLocks(caches);
+      }
+      finally
+      {
+         if (cache2 != null) cache2.stop();
+      }
+   }
+}

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolNoDataGravitationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolNoDataGravitationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolNoDataGravitationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,178 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.util.CachePrinter;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.replicationlisteners.ReplicationListener;
+import org.testng.annotations.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
+import java.util.List;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "buddyreplication.Buddy3NodesNoPoolNoDataGravitationTest")
+public class Buddy3NodesNoPoolNoDataGravitationTest extends AbstractNodeBasedBuddyTest
+{
+   @BeforeClass
+   public void createCaches() throws Exception
+   {
+      caches = createCaches(3, false, false);
+   }
+
+   public void testSingleBuddy() throws Exception
+   {
+      System.out.println("*** Testing cache 0:");
+      waitForBuddy(caches.get(0), caches.get(1), true);
+      System.out.println("*** Testing cache 1:");
+      waitForBuddy(caches.get(1), caches.get(2), true);
+      System.out.println("*** Testing cache 2:");
+      waitForBuddy(caches.get(2), caches.get(0), true);
+
+      System.out.println("Cache 0 = " + CachePrinter.printCacheLockingInfo(caches.get(0)));
+      System.out.println("Cache 1 = " + CachePrinter.printCacheLockingInfo(caches.get(1)));
+      System.out.println("Cache 2 = " + CachePrinter.printCacheLockingInfo(caches.get(2)));
+   }
+
+   public void testRemovalFromClusterSingleBuddy() throws Exception
+   {
+      try
+      {
+         System.out.println("*** Testing cache 0");
+         waitForBuddy(caches.get(0), caches.get(1), true);
+         System.out.println("*** Testing cache 1");
+         waitForBuddy(caches.get(1), caches.get(2), true);
+         System.out.println("*** Testing cache 2");
+         waitForBuddy(caches.get(2), caches.get(0), true);
+
+         // now remove a cache from the cluster
+         caches.get(2).stop();
+
+         TestingUtil.sleepThread(getSleepTimeout());
+
+         // now test new buddy groups
+         waitForBuddy(caches.get(0), caches.get(1), true);
+         waitForBuddy(caches.get(1), caches.get(0), true);
+         assertNoLocks(caches);
+      }
+      finally
+      {
+         caches.get(2).start();
+      }
+   }
+
+   public void testSimplePut() throws Exception
+   {
+      String fqn = "/test";
+      String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
+
+      assertNoStaleLocks(caches);
+
+      // put something in cache 1
+      caches.get(0).put(fqn, key, value);
+
+      assertNoStaleLocks(caches);
+
+      // this should be in neither of the other cachePool' "main" trees
+      assertEquals(value, caches.get(0).get(fqn, key));
+      assertNull("Should be null", caches.get(1).get(fqn, key));
+      assertNull("Should be null", caches.get(2).get(fqn, key));
+
+      // check the backup trees
+
+      assertEquals("Buddy should have data in backup tree", value, caches.get(1).get(backupFqn, key));
+      assertNull("Should be null", caches.get(2).get(backupFqn, key));
+
+      assertNoStaleLocks(caches);
+
+      System.out.println("Cache 0 = " + CachePrinter.printCacheLockingInfo(caches.get(0)));
+      System.out.println("Cache 1 = " + CachePrinter.printCacheLockingInfo(caches.get(1)));
+      System.out.println("Cache 2 = " + CachePrinter.printCacheLockingInfo(caches.get(2)));
+   }
+
+
+   public void testPutAndRemove() throws Exception
+   {
+      String fqn = "/test";
+      String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
+
+      assertNoStaleLocks(caches);
+
+      // put something in cache 1
+      caches.get(0).put(fqn, key, value);
+
+      assertNoStaleLocks(caches);
+
+      // this should be in neither of the other cachePool' "main" trees
+      assertEquals(value, caches.get(0).get(fqn, key));
+      assertNull("Should be null", caches.get(1).get(fqn, key));
+      assertNull("Should be null", caches.get(2).get(fqn, key));
+
+      // check the backup trees
+
+      assertEquals("Buddy should have data in backup tree", value, caches.get(1).get(backupFqn, key));
+      assertNull("Should be null", caches.get(2).get(backupFqn, key));
+
+      assertNoStaleLocks(caches);
+
+      // now remove
+      caches.get(0).removeNode(fqn);
+      assertNoStaleLocks(caches);
+
+
+      assertNull("Should be null", caches.get(0).get(fqn, key));
+      assertNull("Should be null", caches.get(1).get(fqn, key));
+      assertNull("Should be null", caches.get(2).get(fqn, key));
+
+      // check the backup trees
+      assertNull("Should be null", caches.get(0).get(backupFqn, key));
+      assertNull("Should be null", caches.get(1).get(backupFqn, key));
+      assertNull("Should be null", caches.get(2).get(backupFqn, key));
+
+      assertNoStaleLocks(caches);
+   }
+
+   public void testDataReplicationSuppression() throws Exception
+   {
+      Fqn fqn = Fqn.fromString("/test");
+      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+      caches.get(0).put(fqn, key, value);
+
+      TestingUtil.dumpCacheContents(caches);
+
+      assertEquals("value", caches.get(0).get(fqn, key));
+      assertFalse(caches.get(0).exists(backupFqn));
+      assertEquals("value", caches.get(1).get(backupFqn, key));
+      assertFalse(caches.get(1).exists(fqn));
+      assertFalse(caches.get(2).exists(fqn));
+      assertFalse(caches.get(2).exists(backupFqn));
+
+      assertNoLocks(caches);
+
+      backupFqn = fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
+
+      System.out.println("*** Calling get() on cache[1] with force option");
+
+      ReplicationListener replicationListener0 = ReplicationListener.getReplicationListener(caches.get(0));
+      replicationListener0.expect(DataGravitationCleanupCommand.class);
+
+      caches.get(1).getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
+      assertEquals("value", caches.get(1).get(fqn, key));
+      replicationListener0.waitForReplicationToOccur(); // cleanup commands are async
+
+      TestingUtil.dumpCacheContents(caches);
+
+      assertFalse(caches.get(1).exists(backupFqn));
+      assertEquals("value", caches.get(2).get(backupFqn, key));
+      assertFalse(caches.get(2).exists(fqn));
+      assertFalse(caches.get(0).exists(fqn));
+      assertFalse(caches.get(0).exists(backupFqn));
+   }
+
+}

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolWithDataGravitationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolWithDataGravitationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoPoolWithDataGravitationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,520 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.CacheBlocked;
+import org.jboss.cache.notifications.annotation.CacheUnblocked;
+import org.jboss.cache.notifications.event.Event;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.util.CachePrinter;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.replicationlisteners.ReplicationListener;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
+
+import javax.transaction.TransactionManager;
+import java.util.List;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "buddyreplication.Buddy3NodesNoPoolWithDataGravitationTest")
+public class Buddy3NodesNoPoolWithDataGravitationTest extends AbstractNodeBasedBuddyTest
+{
+   private Fqn fqn = Fqn.fromString("test");
+
+   private String key = "key";
+   private String value = "value";
+
+
+   @BeforeClass
+   public void createCaches() throws Exception
+   {
+      caches = createCaches(3, false, true);
+   }
+
+   public void testDataGravitationDontKillOwner() throws Exception
+   {
+      Fqn fqn = Fqn.fromString("/test");
+      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+
+      TestingUtil.dumpCacheContents(caches);
+
+      caches.get(0).put(fqn, key, value);
+
+      TestingUtil.dumpCacheContents(caches);
+
+      assertEquals("Value should exist", value, caches.get(0).get(fqn, key));
+
+      TestingUtil.dumpCacheContents(caches);
+
+      // use exists instead of get() to prevent going up the interceptor stack
+      assertTrue("Should be false", !caches.get(1).exists(fqn));
+      assertTrue("Should be false", !caches.get(2).exists(fqn));
+
+      assertFalse("Should be false", caches.get(0).exists(backupFqn));
+      assertTrue("Value be true", caches.get(1).exists(backupFqn));
+      assertFalse("Should be false", caches.get(2).exists(backupFqn));
+
+      System.out.println("***** Killed original data owner, about to call a get on a different cache instance.  *****");
+
+      ReplicationListener replListener = ReplicationListener.getReplicationListener(caches.get(1));
+      replListener.expect(DataGravitationCleanupCommand.class);
+
+      // according to data gravitation, a call to *any* cache should retrieve the data, and move the data to the new cache.
+      assertEquals("Value should have gravitated", value, caches.get(2).get(fqn, key));
+      replListener.waitForReplicationToOccur();
+
+      TestingUtil.dumpCacheContents(caches);
+
+      // now lets test the eviction part of gravitation
+      Fqn newBackupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
+
+      // use exists instead of get() to prevent going up the interceptor stack
+      assertTrue("Should be false", !caches.get(0).exists(fqn));
+      assertTrue("Should be false", !caches.get(1).exists(fqn));
+
+      // the old backup should no longer exist
+      assertFalse("Should be null", caches.get(0).exists(backupFqn));
+      assertFalse("Should be null", caches.get(1).exists(backupFqn));
+      assertFalse("Should be null", caches.get(2).exists(backupFqn));
+
+      // and the backup should now exist in caches.get(2)'s buddy which is caches.get(0)
+      assertEquals("Value should exist", value, caches.get(0).get(newBackupFqn, key));
+      assertFalse("Should be null", caches.get(1).exists(newBackupFqn));
+      assertFalse("Should be null", caches.get(2).exists(newBackupFqn));
+   }
+
+
+   public void testCompleteStateSurvival() throws Exception
+   {
+      CacheBlockListener blockListener = new CacheBlockListener();
+
+      caches.get(0).addCacheListener(blockListener);
+      caches.get(1).addCacheListener(blockListener);
+      caches.get(2).addCacheListener(blockListener);
+
+      caches.get(0).put("/0", "key", "value");
+      caches.get(1).put("/1", "key", "value");
+      caches.get(2).put("/2", "key", "value");
+
+//      TestingUtil.sleepThread(getSleepTimeout());
+      //TestingUtil.sleepThread(caches.get(0).getConfiguration().getStateRetrievalTimeout() * 3);
+      blockListener.blockUntilAllCachesAreUnblocked(caches.get(0).getConfiguration().getStateRetrievalTimeout() * 3);
+
+      caches.get(2).stop();
+
+      blockListener.blockUntilAllCachesAreUnblocked(caches.get(0).getConfiguration().getStateRetrievalTimeout() * 5);
+
+      assertEquals("value", caches.get(0).get("/2", "key"));
+
+      blockListener.blockUntilAllCachesAreUnblocked(caches.get(0).getConfiguration().getStateRetrievalTimeout() * 5);
+
+      caches.get(1).stop();
+
+      // cache[0] is all thats left!!
+
+      assertEquals("value", caches.get(0).get("/0", "key"));
+
+      try
+      {
+         assertEquals("value", caches.get(0).get("/1", "key"));
+      }
+      catch (RuntimeException e)
+      {
+         // may barf the first time around since we are unable to contact our buddy and store this data.
+         assertEquals(IllegalArgumentException.class, e.getCause().getClass());
+      }
+
+      // now try the assertion again since the local gravitation would have worked.
+
+      System.out.println("Cache contents " + CachePrinter.printCacheDetails(caches.get(0)));
+
+      assertEquals("value", caches.get(0).get("/1", "key"));
+      assertEquals("value", caches.get(0).get("/2", "key"));
+      caches.get(1).start();
+      caches.get(2).start();
+      caches.get(0).removeCacheListener(blockListener);
+      caches.get(1).removeCacheListener(blockListener);
+      caches.get(2).removeCacheListener(blockListener);
+
+      waitForSingleBuddy(caches);
+   }
+
+   public void testTransactionsCommit() throws Exception
+   {
+
+
+      caches.get(0).put(fqn, key, value);
+      Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
+      Fqn newBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(2).getLocalAddress()) + "/test");
+
+//      dumpCacheContents(caches);
+
+      TransactionManager txman = caches.get(2).getTransactionManager();
+
+
+      assertTrue(caches.get(0).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(!caches.get(2).exists(fqn));
+      assertTrue(!caches.get(0).exists(oldBackupFqn));
+      assertTrue(caches.get(1).exists(oldBackupFqn));
+      assertTrue(!caches.get(2).exists(oldBackupFqn));
+      assertTrue(!caches.get(0).exists(newBackupFqn));
+      assertTrue(!caches.get(1).exists(newBackupFqn));
+      assertTrue(!caches.get(2).exists(newBackupFqn));
+
+
+      txman.begin();
+
+//      dumpCacheContents(caches);
+      // will cause gravitation
+      caches.get(2).get(fqn, key);
+//      dumpCacheContents(caches);
+
+      assertTrue(caches.get(0).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(caches.get(2).exists(fqn));
+      assertTrue(!caches.get(0).exists(oldBackupFqn));
+      assertTrue(caches.get(1).exists(oldBackupFqn));
+      assertTrue(!caches.get(2).exists(oldBackupFqn));
+      assertTrue(!caches.get(0).exists(newBackupFqn));
+      assertTrue(!caches.get(1).exists(newBackupFqn));
+      assertTrue(!caches.get(2).exists(newBackupFqn));
+
+      txman.commit();
+      cleanupDelay(); // cleanup commands are async
+
+//      dumpCacheContents(caches);
+
+      assertTrue(!caches.get(0).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(caches.get(2).exists(fqn));
+      assertTrue(!caches.get(0).exists(oldBackupFqn));
+      assertTrue(!caches.get(1).exists(oldBackupFqn));
+      assertTrue(!caches.get(2).exists(oldBackupFqn));
+      assertTrue(caches.get(0).exists(newBackupFqn));
+      assertTrue(!caches.get(1).exists(newBackupFqn));
+      assertTrue(!caches.get(2).exists(newBackupFqn));
+
+//      dumpCacheContents(caches);
+
+      assertNoLocks(caches);
+   }
+
+   private void cleanupDelay()
+   {
+      TestingUtil.sleepThread(250);
+   }
+
+   public void testTransactionsRollback() throws Exception
+   {
+      System.out.println("Buddy3NodesNoPoolWithDataGravitationTest.testTransactionsRollback****************************");
+      TestingUtil.dumpCacheContents(caches.get(0));
+      TestingUtil.dumpCacheContents(caches.get(1));
+      TestingUtil.dumpCacheContents(caches.get(2));
+      System.out.println("Buddy3NodesNoPoolWithDataGravitationTest.testTransactionsRollback****************************");
+
+      caches.get(0).put(fqn, key, value);
+      Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
+      Fqn newBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(2).getLocalAddress()) + "/test");
+
+//      dumpCacheContents(caches);
+
+      TransactionManager txman = caches.get(2).getTransactionManager();
+
+
+      assertTrue(caches.get(0).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(!caches.get(2).exists(fqn));
+      assertTrue(!caches.get(0).exists(oldBackupFqn));
+      assertTrue(caches.get(1).exists(oldBackupFqn));
+      assertTrue(!caches.get(2).exists(oldBackupFqn));
+      assertTrue(!caches.get(0).exists(newBackupFqn));
+      assertTrue(!caches.get(1).exists(newBackupFqn));
+      assertTrue(!caches.get(2).exists(newBackupFqn));
+
+
+      txman.begin();
+
+//      dumpCacheContents(caches);
+      caches.get(2).get(fqn, key);
+//      dumpCacheContents(caches);
+
+      assertTrue(caches.get(0).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(caches.get(2).exists(fqn));
+      assertTrue(!caches.get(0).exists(oldBackupFqn));
+      assertTrue(caches.get(1).exists(oldBackupFqn));
+      assertTrue(!caches.get(2).exists(oldBackupFqn));
+      assertTrue(!caches.get(0).exists(newBackupFqn));
+      assertTrue(!caches.get(1).exists(newBackupFqn));
+      assertTrue(!caches.get(2).exists(newBackupFqn));
+
+      txman.rollback();
+
+//      dumpCacheContents(caches);
+
+      assertTrue(caches.get(0).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(!caches.get(2).exists(fqn));
+      assertTrue(!caches.get(0).exists(oldBackupFqn));
+      assertTrue(caches.get(1).exists(oldBackupFqn));
+      assertTrue(!caches.get(2).exists(oldBackupFqn));
+      assertTrue(!caches.get(0).exists(newBackupFqn));
+      assertTrue(!caches.get(1).exists(newBackupFqn));
+      assertTrue(!caches.get(2).exists(newBackupFqn));
+
+      assertNoLocks(caches);
+   }
+
+   public void testSubtreeRetrieval() throws Exception
+   {
+      Fqn fqn = Fqn.fromString("/test");
+      Fqn fqn2 = Fqn.fromString("/test/subtree");
+
+      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+      Fqn backupFqn2 = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn2);
+
+      caches.get(0).put(fqn, key, value);
+      caches.get(0).put(fqn2, key, value);
+
+      // test backup replication to buddy
+      assertEquals(value, caches.get(0).get(fqn, key));
+      assertEquals(value, caches.get(0).get(fqn2, key));
+      assertEquals(value, caches.get(1).get(backupFqn, key));
+      assertEquals(value, caches.get(1).get(backupFqn2, key));
+
+      assertTrue(!caches.get(0).exists(backupFqn));
+      assertTrue(!caches.get(0).exists(backupFqn2));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn2));
+      assertTrue(!caches.get(2).exists(fqn));
+      assertTrue(!caches.get(2).exists(fqn2));
+      assertTrue(!caches.get(2).exists(backupFqn));
+      assertTrue(!caches.get(2).exists(backupFqn2));
+
+      assertNoLocks(caches);
+
+      // gravitate to 2:
+      ReplicationListener replListener1 = ReplicationListener.getReplicationListener(caches.get(0));
+      replListener1.expect(DataGravitationCleanupCommand.class);
+      caches.get(2).getNode(fqn);  // expectWithTx entire subtree to gravitate.
+      replListener1.waitForReplicationToOccur(); // cleanup commands are async
+
+      Fqn newBackupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
+      Fqn newBackupFqn2 = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn2);
+
+      assertEquals(value, caches.get(2).get(fqn, key));
+      assertTrue(caches.get(2).exists(fqn2));
+      assertEquals(value, caches.get(0).get(newBackupFqn, key));
+      assertTrue(caches.get(0).exists(newBackupFqn2));
+
+      assertTrue(!caches.get(2).exists(newBackupFqn));
+      assertTrue(!caches.get(2).exists(newBackupFqn2));
+      assertTrue(!caches.get(0).exists(fqn));
+      assertTrue(!caches.get(0).exists(fqn2));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn2));
+      assertTrue(!caches.get(1).exists(newBackupFqn));
+      assertTrue(!caches.get(1).exists(newBackupFqn2));
+
+      TestingUtil.dumpCacheContents(caches);
+
+      for (CacheSPI<Object, Object> cache : caches)
+      {
+         assertTrue(!cache.exists(backupFqn));
+         assertTrue(!cache.exists(backupFqn2));
+      }
+
+      assertNoLocks(caches);
+   }
+
+   private void testDataOwner(boolean optimistic) throws Exception
+   {
+      List<CacheSPI<Object, Object>> caches = createCaches(1, 2, false, true, optimistic);
+      cachesTL.set(caches);
+
+      // add some stuff on the primary
+      CacheSPI dataOwner = caches.get(0);
+      CacheSPI buddy = caches.get(1);
+
+      dataOwner.put(fqn, key, value);
+
+      System.out.println("dataOwner: " + CachePrinter.printCacheDetails(dataOwner));
+      System.out.println("buddy: " + CachePrinter.printCacheDetails(buddy));
+
+      assert dataOwner.peek(fqn, false) != null : "Should have data";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+
+      assert buddy.peek(fqn, false) == null : "Should not have data";
+      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
+      assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";
+
+      // now do a gravitate call.
+      assert buddy.get(fqn, key).equals(value) : "Data should have gravitated!";
+      // gravitation cleanup calls are async.
+      cleanupDelay();
+
+      System.out.println("dataOwner: " + CachePrinter.printCacheDetails(dataOwner));
+      System.out.println("buddy: " + CachePrinter.printCacheDetails(buddy));
+
+      assert buddy.peek(fqn, false) != null : "Should have data";
+      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
+      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+
+      assert dataOwner.peek(fqn, false) == null : "Should not have data";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
+      assert dataOwner.peek(fqnTransformer.getBackupFqn(buddy.getLocalAddress(), fqn), false) != null : "Should have backup data";
+   }
+
+   public void testStaleRegionOnDataOwner() throws Exception
+   {
+      // add some stuff on the primary
+      CacheSPI first = caches.get(0);
+      CacheSPI second = caches.get(1);
+      CacheSPI third = caches.get(2);
+
+      first.put(fqn, key, value);
+
+      System.out.println("first: " + CachePrinter.printCacheDetails(first));
+      System.out.println("second: " + CachePrinter.printCacheDetails(second));
+
+      assert first.peek(fqn, false) != null : "Should have data";
+      assert first.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(third.getLocalAddress())), false) != null : "Should have backup node for second";
+      assert first.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(first.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+
+      assert second.peek(fqn, false) == null : "Should not have data";
+      assert second.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(second.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+      assert second.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(first.getLocalAddress())), false) != null : "Should have backup node for second";
+      assert second.peek(fqnTransformer.getBackupFqn(first.getLocalAddress(), fqn), false) != null : "Should have backup data";
+
+      // now do a gravitate call.
+      assert second.get(fqn, key).equals(value) : "Data should have gravitated!";
+      // gravitation cleanup calls are async.
+      cleanupDelay();
+
+      System.out.println("first: " + CachePrinter.printCacheDetails(first));
+      System.out.println("second: " + CachePrinter.printCacheDetails(second));
+
+      assert second.peek(fqn, false) != null : "Should have data";
+      assert second.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(first.getLocalAddress())), false) != null : "Should have backup node for second";
+      assert second.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(second.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+
+      assert third.peek(fqn, false) == null : "Should not have data";
+      assert third.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(third.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+      assert third.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(second.getLocalAddress())), false) != null : "Should have backup node for second";
+      assert third.peek(fqnTransformer.getBackupFqn(second.getLocalAddress(), fqn), false) != null : "Should have backup data";
+   }
+
+   public void testStaleRegionOnBuddy() throws Exception
+   {
+      Fqn fqn = Fqn.fromString("/a/b/c");
+      Object key = "key", value = "value";
+
+      // add some stuff on the primary
+      CacheSPI dataOwner = caches.get(0);
+      CacheSPI buddy = caches.get(1);
+      CacheSPI thirdInstance = caches.get(2);
+
+      assertIsBuddy(dataOwner, buddy, true);
+      assertIsBuddy(buddy, thirdInstance, true);
+      assertIsBuddy(thirdInstance, dataOwner, true);
+
+      dataOwner.put(fqn, key, value);
+
+      System.out.println("dataOwner: " + CachePrinter.printCacheLockingInfo(dataOwner));
+      System.out.println("buddy: " + CachePrinter.printCacheLockingInfo(buddy));
+      System.out.println("thirdInstance: " + CachePrinter.printCacheLockingInfo(thirdInstance));
+
+      assert dataOwner.peek(fqn, false) != null : "Should have data";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for 2nd instance!";
+
+      assert buddy.peek(fqn, false) == null : "Should not have data";
+      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
+      assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";
+
+      // now do a gravitate call.
+      assert thirdInstance.get(fqn, key).equals(value) : "Data should have gravitated!";
+
+      // gravitation cleanup calls are async.
+      TestingUtil.sleepThread(250);
+
+      System.out.println("dataOwner: " + CachePrinter.printCacheLockingInfo(dataOwner));
+      System.out.println("buddy: " + CachePrinter.printCacheLockingInfo(buddy));
+      System.out.println("thirdInstance: " + CachePrinter.printCacheLockingInfo(thirdInstance));
+
+      assert thirdInstance.peek(fqn, false) != null : "Should have data";
+      assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
+      assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+
+      assert dataOwner.peek(fqn, false) == null : "Should not have data";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
+      assert dataOwner.peek(fqnTransformer.getBackupFqn(thirdInstance.getLocalAddress(), fqn), false) != null : "Should have backup data";
+      assert buddy.peek(fqn, false) == null : "Should not have data";
+      assert buddy.peek(fqn.getParent(), false) == null : "Should not have any part of the data";
+      assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) == null : "Should NOT have backup data";
+   }
+
+   @CacheListener
+   public static class CacheBlockListener
+   {
+      private int blocks = 0;
+
+      @CacheBlocked
+      public void processBlock(Event e)
+      {
+         if (e.isPre())
+         {
+            System.out.println(">>>>>>>> Got BLOCK on cache " + e.getCache().getLocalAddress());
+            synchronized (this)
+            {
+               blocks++;
+               notifyAll();
+            }
+         }
+      }
+
+      @CacheUnblocked
+      public void processUnblock(Event e)
+      {
+         if (e.isPre())
+         {
+            System.out.println(">>>>>>>> Got UNBLOCK on cache " + e.getCache().getLocalAddress());
+            synchronized (this)
+            {
+               blocks--;
+               notifyAll();
+            }
+         }
+      }
+
+      public void blockUntilAllCachesAreUnblocked(long maxWait) throws InterruptedException
+      {
+         synchronized (this)
+         {
+            if (blocks > 1)
+            {
+               wait(maxWait);
+            }
+            // try returning anyway?
+            blocks = 0;
+            /*
+            if (blocks > 1)
+               throw new RuntimeException("Timed out waiting for unblocks.  Number of blocks = " + blocks);
+            if (blocks == 1) blocks = 0;
+            */
+         }
+      }
+   }
+}

Copied: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoStateTransfer.java (from rev 7262, core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoStateTransfer.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoStateTransfer.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,72 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.util.CachePrinter;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+/**
+ * This is to test JBCACHE-1229
+ *
+ * @author Manik Surtani (<a href="mailto:manik AT jboss DOT org">manik AT jboss DOT org</a>)
+ * @since 2.1.0
+ */
+ at Test(groups = "functional", testName = "buddyreplication.Buddy3NodesNoStateTransfer")
+public class Buddy3NodesNoStateTransfer extends BuddyReplicationTestsBase
+{
+   public void testCachesWithoutStateTransfer() throws Exception
+   {
+      List<CacheSPI<Object, Object>> caches = createCaches(1, 3, false, false, false, false);
+      cachesTL.set(caches);
+
+      int cacheNumber = 0;
+      for (CacheSPI c : caches)
+      {
+         c.getConfiguration().setFetchInMemoryState(false);
+         c.start();
+         c.put("/" + cacheNumber++, "k", "v");
+      }
+
+      waitForBuddy(caches.get(0), caches.get(1), true);
+      waitForBuddy(caches.get(1), caches.get(2), true);
+      waitForBuddy(caches.get(2), caches.get(0), true);
+      Thread.sleep(2000);//wait for state transfer
+
+      for (CacheSPI c : caches)
+         System.out.println("Cache (local address " + c.getLocalAddress() + ") contents: " + CachePrinter.printCacheLockingInfo(c));
+
+      for (int i = 0; i < 3; i++)
+      {
+         int backupIndex = i == 2 ? 0 : i + 1;
+
+         assert caches.get(i).exists("/" + i) : "Data should exist on owner (cache #" + i + ")";
+         Fqn backup = fqnTransformer.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i));
+
+         assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
+         boolean backupStatePropagated = caches.get(backupIndex).exists(backup);
+         boolean backupOlderThanOwner = backupIndex < i;
+         assert (!backupStatePropagated && !backupOlderThanOwner) || (backupStatePropagated && backupOlderThanOwner) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
+      }
+
+      // now NEW state should transfer just fine.
+
+      cacheNumber = 0;
+      for (CacheSPI c : caches)
+      {
+         c.put("/" + (cacheNumber++) + "_NEW", "k", "v");
+      }
+
+      for (int i = 0; i < 3; i++)
+      {
+         int backupIndex = i == 2 ? 0 : i + 1;
+
+         assert caches.get(i).exists("/" + i + "_NEW") : "Data should exist on owner (cache #" + i + ")";
+         Fqn backup = fqnTransformer.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i + "_NEW"));
+
+         assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
+         assert caches.get(backupIndex).exists(backup) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
+      }
+   }
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesNoStateTransfer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java (from rev 7262, core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.replicationlisteners.ReplicationListener;
+import org.jgroups.JChannel;
+import org.jgroups.protocols.DISCARD;
+import static org.testng.AssertJUnit.*;
+import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+/**
+ * Tests behaviour when data owners fail - essentially this tests data gravitation
+ *
+ * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
+ */
+ at Test(groups = "functional", testName = "buddyreplication.Buddy3NodesWithFailoverTest")
+public class Buddy3NodesWithFailoverTest extends BuddyReplicationTestsBase
+{
+   protected boolean optimisticLocks = false;
+   protected String key = "key";
+   protected String value = "value";
+   BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
+
+   public void testSubtreeRetrieval() throws Exception
+   {
+      List<CacheSPI<Object, Object>> caches = createCaches(3, false, true, optimisticLocks);
+      cachesTL.set(caches);
+
+      Fqn fqn = Fqn.fromString("/test");
+      Fqn fqn2 = Fqn.fromString("/test/subtree");
+
+      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+      Fqn backupFqn2 = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn2);
+
+      caches.get(0).put(fqn, key, value);
+      caches.get(0).put(fqn2, key, value);
+
+      // test backup replication to buddy
+      assertEquals(value, caches.get(0).get(fqn, key));
+      assertEquals(value, caches.get(0).get(fqn2, key));
+      assertEquals(value, caches.get(1).get(backupFqn, key));
+      assertEquals(value, caches.get(1).get(backupFqn2, key));
+
+      assertTrue(!caches.get(0).exists(backupFqn));
+      assertTrue(!caches.get(0).exists(backupFqn2));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn2));
+      assertTrue(!caches.get(2).exists(fqn));
+      assertTrue(!caches.get(2).exists(fqn2));
+      assertTrue(!caches.get(2).exists(backupFqn));
+      assertTrue(!caches.get(2).exists(backupFqn2));
+
+      assertNoLocks(caches);
+
+      // gravitate to 2:
+      ReplicationListener replListener1 = ReplicationListener.getReplicationListener(caches.get(0));
+      replListener1.expect(DataGravitationCleanupCommand.class);
+      caches.get(2).getNode(fqn);  // expectWithTx entire subtree to gravitate.
+      replListener1.waitForReplicationToOccur(); // cleanup commands are async
+
+      Fqn newBackupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
+      Fqn newBackupFqn2 = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn2);
+
+      assertEquals(value, caches.get(2).get(fqn, key));
+      assertTrue(caches.get(2).exists(fqn2));
+      assertEquals(value, caches.get(0).get(newBackupFqn, key));
+      assertTrue(caches.get(0).exists(newBackupFqn2));
+
+      assertTrue(!caches.get(2).exists(newBackupFqn));
+      assertTrue(!caches.get(2).exists(newBackupFqn2));
+      assertTrue(!caches.get(0).exists(fqn));
+      assertTrue(!caches.get(0).exists(fqn2));
+      assertTrue(!caches.get(1).exists(fqn));
+      assertTrue(!caches.get(1).exists(fqn2));
+      assertTrue(!caches.get(1).exists(newBackupFqn));
+      assertTrue(!caches.get(1).exists(newBackupFqn2));
+
+      TestingUtil.dumpCacheContents(caches);
+
+      for (CacheSPI<Object, Object> cache : caches)
+      {
+         assertTrue(!cache.exists(backupFqn));
+         assertTrue(!cache.exists(backupFqn2));
+      }
+
+      assertNoLocks(caches);
+   }
+
+   @Test
+   public void testDataGravitationKillOwner() throws Exception
+   {
+      List<CacheSPI<Object, Object>> cachePool = createCaches(3, false, true);
+      Fqn fqn = Fqn.fromString("/test");
+      Fqn backupFqn = fqnTransformer.getBackupFqn(cachePool.get(0).getLocalAddress(), fqn);
+
+      TestingUtil.dumpCacheContents(cachePool);
+
+      cachePool.get(0).put(fqn, key, value);
+
+      TestingUtil.dumpCacheContents(cachePool);
+
+      assertEquals("Value should exist", value, cachePool.get(0).get(fqn, key));
+
+      TestingUtil.dumpCacheContents(cachePool);
+
+      // use exists instead of get() to prevent going up the interceptor stack
+      assertTrue("Should be false", !cachePool.get(1).exists(fqn));
+      assertTrue("Should be false", !cachePool.get(2).exists(fqn));
+
+      assertFalse("Should be false", cachePool.get(0).exists(backupFqn));
+      assertTrue("Value be true", cachePool.get(1).exists(backupFqn));
+      assertFalse("Should be false", cachePool.get(2).exists(backupFqn));
+
+      System.out.println("***** About to kill original data owner (" + cachePool.get(0).getLocalAddress() + ").  *****");
+      // forcefully kill data owner.
+      amendDiscard(cachePool.get(0), cachePool.get(1), 2, true);
+      waitForSingleBuddy(cachePool.get(1), cachePool.get(2));
+
+      System.out.println("Killed.  Testing backup roots.");
+      TestingUtil.dumpCacheContents(cachePool);
+      // assert that the remaining cachePool have picked new buddies.  Cache 1 should have cache 2's backup data.
+      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
+      assert cachePool.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()), 1), false) != null : "Should have dead node as a defunct backup root.";
+
+      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
+      assert cachePool.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
+
+      System.out.println("***** Killed original data owner, about to call a get on a different cache instance.  *****");
+
+      ReplicationListener replListener = ReplicationListener.getReplicationListener(cachePool.get(1));
+      replListener.expect(DataGravitationCleanupCommand.class);
+
+      // according to data gravitation, a call to *any* cache should retrieve the data, and move the data to the new cache.
+      assertEquals("Value should have gravitated", value, cachePool.get(2).get(fqn, key));
+      replListener.waitForReplicationToOccur();
+
+      TestingUtil.dumpCacheContents(cachePool);
+
+      // now lets test the eviction part of gravitation
+      Fqn newBackupFqn = fqnTransformer.getBackupFqn(cachePool.get(2).getLocalAddress(), fqn);
+
+      // use exists instead of get() to prevent going up the interceptor stack
+      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
+      assert cachePool.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
+      assert cachePool.get(1).peek(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()), false) == null : "Should not have dead node as a defunct backup root.";
+
+      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
+      assert cachePool.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
+      assertTrue("Should be false", !cachePool.get(1).exists(fqn));
+
+      // the old backup should no longer exist
+      assertFalse("Should be null", cachePool.get(1).exists(backupFqn));
+      assertFalse("Should be null", cachePool.get(2).exists(backupFqn));
+   }
+
+   private void amendDiscard(CacheSPI cacheToKill, CacheSPI anotherCache, int finalExpectedClusterSize, boolean enable)
+   {
+      JChannel channel = (JChannel) cacheToKill.getRPCManager().getChannel();
+      DISCARD discard = (DISCARD) channel.getProtocolStack().findProtocol(DISCARD.class);
+      if (discard != null)
+      {
+         discard.setDiscardAll(enable);
+         TestingUtil.blockUntilViewReceived(anotherCache, finalExpectedClusterSize, 10000, false);
+         // an extra second, for some reason we need this.
+         TestingUtil.sleepThread(1000);
+      }
+   }
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithPoolNoDataGravitationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithPoolNoDataGravitationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithPoolNoDataGravitationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,91 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "buddyreplication.Buddy3NodesWithPoolNoDataGravitationTest")
+public class Buddy3NodesWithPoolNoDataGravitationTest extends AbstractNodeBasedBuddyTest
+{
+
+   @BeforeClass
+   public void createCaches() throws Exception
+   {
+      caches = createCaches(3, true, false);
+   }
+   
+   public void testChangingBuddyPoolMembership() throws Exception
+   {
+      Map map = caches.get(0).getBuddyManager().buddyPool;
+
+      // first test the values
+      assertEquals("Failed on cache 1", "A", map.get(caches.get(0).getLocalAddress()));
+      assertEquals("Failed on cache 1", "B", map.get(caches.get(1).getLocalAddress()));
+      assertEquals("Failed on cache 1", "C", map.get(caches.get(2).getLocalAddress()));
+
+      // now test against each other
+      checkConsistentPoolState(caches);
+
+      caches.get(2).stop();
+      CacheSPI<Object, Object> newlyCreated = createCache(1, "Z");
+
+      waitForSingleBuddy(caches.get(0), caches.get(1), newlyCreated);
+//      TestingUtil.blockUntilViewsReceived(cachePool.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
+//      TestingUtil.sleepThread(getSleepTimeout());
+
+      // first test the values
+      assertEquals("Failed on cache 1", "A", map.get(caches.get(0).getLocalAddress()));
+      assertEquals("Failed on cache 1", "B", map.get(caches.get(1).getLocalAddress()));
+      assertEquals("Failed on cache 1", "Z", map.get(newlyCreated.getLocalAddress()));
+
+      // now test against each other
+      checkConsistentPoolState(caches);
+
+      newlyCreated.stop();
+      newlyCreated.destroy();
+
+      waitForSingleBuddy(caches.get(0), caches.get(1));
+      
+      caches.get(2).start();
+
+      waitForSingleBuddy(caches.get(0), caches.get(1), caches.get(2));
+   }
+
+
+
+   public void test3CachesWithPoolNames() throws Exception
+   {
+      long st = System.currentTimeMillis();
+      System.out.println("Setup: " + (System.currentTimeMillis() - st));
+      st = System.currentTimeMillis();
+
+      BuddyManager m = caches.get(0).getBuddyManager();
+      Map groupMap = m.buddyPool;
+
+      assertEquals("A", groupMap.get(caches.get(0).getLocalAddress()));
+      assertEquals("B", groupMap.get(caches.get(1).getLocalAddress()));
+      assertEquals("C", groupMap.get(caches.get(2).getLocalAddress()));
+      System.out.println("Test: " + (System.currentTimeMillis() - st));
+   }
+
+   public void testBuddyPoolSync() throws Exception
+   {
+      Map map = caches.get(0).getBuddyManager().buddyPool;
+
+      // first test the values
+      assertEquals("Failed on cache 1", "A", map.get(caches.get(0).getLocalAddress()));
+      assertEquals("Failed on cache 1", "B", map.get(caches.get(1).getLocalAddress()));
+      assertEquals("Failed on cache 1", "C", map.get(caches.get(2).getLocalAddress()));
+
+      // now test against each other
+      checkConsistentPoolState(caches);
+   }
+
+
+}

Copied: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy4Nodes2BackupsTest.java (from rev 7262, core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy4Nodes2BackupsTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy4Nodes2BackupsTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.buddyreplication;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.util.TestingUtil;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.BeforeClass;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+
+/**
+ * Tests how groups are formed and disbanded
+ *
+ * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
+ */
+ at Test(groups = {"functional", "jgroups"}, testName = "buddyreplication.Buddy4Nodes2BackupsTest")
+public class Buddy4Nodes2BackupsTest extends AbstractNodeBasedBuddyTest
+{
+   @BeforeClass
+   public void createCaches() throws Exception
+   {
+      caches = createCaches(2, 4, false);
+   }
+
+   private Log log = LogFactory.getLog(Buddy4Nodes2BackupsTest.class);
+   BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
+
+   public void test2Buddies() throws Exception
+   {
+      TestingUtil.blockUntilViewsReceived(5000, caches.toArray(new Cache[0]));
+
+      waitForBuddy(caches.get(0), caches.get(1), false);
+      waitForBuddy(caches.get(0), caches.get(2), false);
+
+      waitForBuddy(caches.get(1), caches.get(2), false);
+      waitForBuddy(caches.get(1), caches.get(3), false);
+
+      waitForBuddy(caches.get(2), caches.get(3), false);
+      waitForBuddy(caches.get(2), caches.get(0), false);
+
+      waitForBuddy(caches.get(3), caches.get(0), false);
+      waitForBuddy(caches.get(3), caches.get(1), false);
+   }
+
+
+   public void testPutAndRemove2() throws Exception
+   {
+      String fqn = "/test";
+      String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
+
+      // put something in cache 1
+      assertNoStaleLocks(caches);
+
+      caches.get(0).put(fqn, key, value);
+
+      assertNoStaleLocks(caches);
+
+      // this should be in neither of the other cachePool' "main" trees
+      assertEquals(value, caches.get(0).get(fqn, key));
+      assertNull("Should be null", caches.get(1).get(fqn, key));
+      assertNull("Should be null", caches.get(2).get(fqn, key));
+      assertNull("Should be null", caches.get(3).get(fqn, key));
+
+      // check the backup trees
+      assertEquals("Buddy should have data in backup tree", value, caches.get(1).get(backupFqn, key));
+      assertEquals("Buddy should have data in backup tree", value, caches.get(2).get(backupFqn, key));
+      assertNull("Should be null", caches.get(3).get(backupFqn, key));
+
+      assertNoStaleLocks(caches);
+
+      // now remove
+      caches.get(0).removeNode(fqn);
+      assertNoStaleLocks(caches);
+
+      assertNull("Should be null", caches.get(0).get(fqn, key));
+      assertNull("Should be null", caches.get(1).get(fqn, key));
+      assertNull("Should be null", caches.get(2).get(fqn, key));
+      assertNull("Should be null", caches.get(3).get(fqn, key));
+
+      // check the backup trees
+      assertNull("Should be null", caches.get(0).get(backupFqn, key));
+      assertNull("Should be null", caches.get(1).get(backupFqn, key));
+      assertNull("Should be null", caches.get(2).get(backupFqn, key));
+      assertNull("Should be null", caches.get(3).get(backupFqn, key));
+
+      assertNoStaleLocks(caches);
+   }
+   
+
+   @Test (dependsOnMethods = {"test2Buddies", "testPutAndRemove2"} )
+   public void testRemovalFromCluster2Buddies() throws Throwable
+{
+      assertNoLocks(caches);
+
+      TestingUtil.sleepThread(getSleepTimeout());
+
+      waitForBuddy(caches.get(0), caches.get(1), false);
+      waitForBuddy(caches.get(0), caches.get(2), false);
+
+      waitForBuddy(caches.get(1), caches.get(2), false);
+      waitForBuddy(caches.get(1), caches.get(3), false);
+
+      waitForBuddy(caches.get(2), caches.get(3), false);
+      waitForBuddy(caches.get(2), caches.get(0), false);
+
+      waitForBuddy(caches.get(3), caches.get(0), false);
+      waitForBuddy(caches.get(3), caches.get(1), false);
+
+      // now remove a cache from the cluster
+      caches.get(1).stop();
+      caches.set(1, null);
+
+      TestingUtil.sleepThread(getSleepTimeout());
+
+      // now test new buddy groups
+      waitForBuddy(caches.get(0), caches.get(2), false);
+      waitForBuddy(caches.get(0), caches.get(3), false);
+
+      waitForBuddy(caches.get(2), caches.get(3), false);
+      waitForBuddy(caches.get(2), caches.get(0), false);
+
+      waitForBuddy(caches.get(3), caches.get(0), false);
+      waitForBuddy(caches.get(3), caches.get(2), false);
+      assertNoLocks(caches);
+   }
+
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy4Nodes2BackupsTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,216 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.buddyreplication;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Region;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.util.CachePrinter;
-import org.jboss.cache.util.TestingUtil;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.jboss.cache.UnitTestCacheFactory;
-
-/**
- * Tests handling of the buddy backup region during region
- * activation and inactivation
- *
- * @author Brian Stansberry
- */
- at Test(groups = "functional", testName = "buddyreplication.BuddyBackupActivationInactivationTest")
-public class BuddyBackupActivationInactivationTest extends BuddyReplicationTestsBase
-{
-   public static final Fqn A = Fqn.fromString("/a");
-   public static final Fqn A_B = Fqn.fromString("/a/b");
-   public static final String JOE = "JOE";
-
-   protected ThreadLocal<Map<String, Cache>> cachesTL = new ThreadLocal<Map<String, Cache>>();
-   private ThreadLocal<ClassLoader> orig_TCL_TL = new ThreadLocal<ClassLoader>();
-
-   public void testBuddyBackupActivation() throws Exception
-   {
-      CacheSPI cache1 = createCache("cache1", true, true, true);
-      CacheSPI cache2 = createCache("cache2", true, true, true);
-      Fqn A = Fqn.fromString("/a");
-      TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);
-
-      // create the regions on the two caches first
-      Region c1 = cache1.getRegionManager().getRegion(A, Region.Type.MARSHALLING, true);
-      Region c2 = cache2.getRegionManager().getRegion(A, Region.Type.MARSHALLING, true);
-
-      assertFalse(c1.isActive());
-      assertFalse(c2.isActive());
-
-      c1.activate();
-      cache1.put(A_B, "name", JOE);
-
-      waitForBuddy(cache2, cache1, true);
-      waitForBuddy(cache1, cache2, true);
-
-//      TestingUtil.sleepThread(getSleepTimeout());
-
-      System.out.println("Cache dump BEFORE activation");
-      System.out.println("cache1 " + CachePrinter.printCacheDetails(cache1));
-      System.out.println("cache2 " + CachePrinter.printCacheDetails(cache2));
-
-      c2.activate();
-
-      System.out.println("Cache dump AFTER activation");
-      System.out.println("cache1 " + CachePrinter.printCacheDetails(cache1));
-      System.out.println("cache2 " + CachePrinter.printCacheDetails(cache2));
-
-      Fqn fqn = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
-
-      assertEquals("State transferred with activation", JOE, cache2.get(fqn, "name"));
-   }
-
-   public void testReplToInactiveRegion() throws Exception
-   {
-      CacheSPI cache1 = createCache("cache1", true, true, true);
-      CacheSPI cache2 = createCache("cache2", true, true, true);
-
-      TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);
-      Fqn backupFqn = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
-      Fqn A = Fqn.fromString("/a");
-
-      Region regionA = cache1.getRegion(A, true);
-      regionA.registerContextClassLoader(getClass().getClassLoader());
-      regionA.activate();
-
-      // Activate the buddy backup subtree in the recipient so any
-      // repl message doesn't get rejected due to that tree being inactive
-      cache2.getRegionManager().activate(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
-      cache2.getRegionManager().deactivate(A);
-
-      cache1.put(A_B, "name", JOE);
-
-//      TestingUtil.sleepThread(getSleepTimeout());
-      assertNull("Should be no replication to inactive region", cache2.get(A_B, "name"));
-
-      assertNull("Should be no replication to inactive backup region", cache2.get(backupFqn, "name"));
-   }
-
-   public void testBuddyBackupInactivation() throws Exception
-   {
-      CacheSPI cache1 = createCache("cache1", true, true, true);
-      Fqn A = Fqn.fromString("/a");
-      Region regionA = cache1.getRegion(A, true);
-      regionA.registerContextClassLoader(getClass().getClassLoader());
-      regionA.activate();
-
-      Fqn fqn = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
-      fqn = Fqn.fromRelativeFqn(fqn, A_B);
-      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
-      cache1.put(fqn, "name", JOE);
-
-      assertEquals("Put should have been OK", JOE, cache1.get(fqn, "name"));
-
-      regionA.deactivate();
-
-      assertNull("Inactivation should have cleared region", cache1.get(fqn, "name"));
-   }
-
-   protected CacheSPI<?, ?> createCache(String cacheID,
-                                        boolean sync,
-                                        boolean useMarshalling,
-                                        boolean startCache)
-         throws Exception
-   {
-      
-      Map<String, Cache> caches = cachesTL.get();
-      
-      if (caches.get(cacheID) != null)
-      {
-         throw new IllegalStateException(cacheID + " already created");
-      }
-
-      CacheMode mode = sync ? CacheMode.REPL_SYNC : CacheMode.REPL_ASYNC;
-      Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(mode);
-
-      CacheSPI<?, ?> cache = (CacheSPI<?, ?>) new UnitTestCacheFactory<Object, Object>().createCache(c, false);
-
-      //cache.getConfiguration().setClusterName("TestCluster");
-      if (useMarshalling)
-      {
-         cache.getConfiguration().setUseRegionBasedMarshalling(true);
-         cache.getConfiguration().setInactiveOnStartup(true);
-      }
-      cache.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
-      // Put the cache in the map before starting, so if it fails in
-      // start it can still be destroyed later
-      caches.put(cacheID, cache);
-
-      if (startCache)
-      {
-         cache.create();
-         cache.start();
-      }
-
-      return cache;
-   }
-
-   @BeforeMethod(alwaysRun = true)
-   protected void setUp() throws Exception
-   {
-      Map<String, Cache> caches = new HashMap<String, Cache>();
-      cachesTL.set(caches);
-
-      // Save the TCL in case a test changes it
-      orig_TCL_TL.set(Thread.currentThread().getContextClassLoader());
-   }
-
-   @AfterMethod(alwaysRun = true)
-   public void tearDown() throws Exception
-   {
-      super.tearDown();
-
-      // Restore the TCL in case a test changed it
-      Thread.currentThread().setContextClassLoader(orig_TCL_TL.get());
-      Map<String, Cache> caches = new HashMap<String, Cache>();
-
-      for (String cacheID : caches.keySet())
-      {
-         stopCache(caches.get(cacheID));
-      }
-      cachesTL.set(null);
-   }
-
-   protected void stopCache(Cache cache)
-   {
-      if (cache != null)
-      {
-         try
-         {
-            cache.stop();
-            cache.destroy();
-         }
-         catch (Exception e)
-         {
-            System.out.println("Exception stopping cache " + e.getMessage());
-            e.printStackTrace(System.out);
-         }
-      }
-   }
-
-   private BuddyReplicationConfig getBuddyConfig() throws Exception
-   {
-      BuddyReplicationConfig brc = new BuddyReplicationConfig();
-      brc.setEnabled(true);
-      brc.setAutoDataGravitation(false);
-      return brc;
-   }
-}

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,195 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.buddyreplication;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.util.CachePrinter;
-import org.jboss.cache.util.TestingUtil;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
-/**
- * Tests how groups are formed and disbanded
- *
- * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
- */
- at Test(groups = {"functional", "jgroups"}, testName = "buddyreplication.BuddyGroupAssignmentTest")
-public class BuddyGroupAssignmentTest extends BuddyReplicationTestsBase
-{
-   private Log log = LogFactory.getLog(BuddyGroupAssignmentTest.class);
-   BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
-
-   public void testSingleBuddy() throws Exception
-   {
-      log.debug("Running testSingleBuddy");
-      List<CacheSPI<Object, Object>> caches = createCaches(3, false);
-      cachesTL.set(caches);
-
-      System.out.println("*** Testing cache 0:");
-      waitForBuddy(caches.get(0), caches.get(1), true);
-      System.out.println("*** Testing cache 1:");
-      waitForBuddy(caches.get(1), caches.get(2), true);
-      System.out.println("*** Testing cache 2:");
-      waitForBuddy(caches.get(2), caches.get(0), true);
-
-      System.out.println("Cache 0 = " + CachePrinter.printCacheLockingInfo(caches.get(0)));
-      System.out.println("Cache 1 = " + CachePrinter.printCacheLockingInfo(caches.get(1)));
-      System.out.println("Cache 2 = " + CachePrinter.printCacheLockingInfo(caches.get(2)));
-   }
-
-   public void test2Buddies() throws Exception
-   {
-      log.debug("Running test2Buddies");
-      List<CacheSPI<Object, Object>> caches = createCaches(2, 3, false);
-      cachesTL.set(caches);
-
-      TestingUtil.blockUntilViewsReceived(5000, caches.toArray(new Cache[0]));
-//      TestingUtil.sleepThread(2000);
-
-      System.out.println("*** Testing cache 0");
-      waitForBuddy(caches.get(0), caches.get(1), false);
-      waitForBuddy(caches.get(0), caches.get(2), false);
-      System.out.println("*** Testing cache 1");
-      waitForBuddy(caches.get(1), caches.get(2), false);
-      waitForBuddy(caches.get(1), caches.get(0), false);
-      System.out.println("*** Testing cache 2");
-      waitForBuddy(caches.get(2), caches.get(1), false);
-      waitForBuddy(caches.get(2), caches.get(0), false);
-   }
-
-   public void testRemovalFromClusterSingleBuddy() throws Exception
-   {
-      log.debug("Running testRemovalFromClusterSingleBuddy");
-      List<CacheSPI<Object, Object>> caches = createCaches(3, false);
-      cachesTL.set(caches);
-
-      System.out.println("*** Testing cache 0");
-      waitForBuddy(caches.get(0), caches.get(1), true);
-      System.out.println("*** Testing cache 1");
-      waitForBuddy(caches.get(1), caches.get(2), true);
-      System.out.println("*** Testing cache 2");
-      waitForBuddy(caches.get(2), caches.get(0), true);
-
-      // now remove a cache from the cluster
-      caches.get(1).stop();
-      caches.set(1, null);
-
-      TestingUtil.sleepThread(getSleepTimeout());
-
-      // now test new buddy groups
-      System.out.println("*** Testing cache 0");
-      waitForBuddy(caches.get(0), caches.get(2), true);
-      System.out.println("*** Testing cache 2");
-      waitForBuddy(caches.get(2), caches.get(0), true);
-      System.out.println("*** Completed successfully ***");
-      assertNoLocks(caches);
-   }
-
-   public void testRemovalFromCluster2Buddies() throws Throwable
-{
-      log.debug("Running testRemovalFromCluster2Buddies");
-      List<CacheSPI<Object, Object>> caches = createCaches(2, 4, false);
-      cachesTL.set(caches);
-      assertNoLocks(caches);
-
-      TestingUtil.sleepThread(getSleepTimeout());
-
-      System.out.println("*** Testing cache 0");
-      waitForBuddy(caches.get(0), caches.get(1), false);
-      waitForBuddy(caches.get(0), caches.get(2), false);
-      System.out.println("*** Testing cache 1");
-      waitForBuddy(caches.get(1), caches.get(2), false);
-      waitForBuddy(caches.get(1), caches.get(3), false);
-      System.out.println("*** Testing cache 2");
-      waitForBuddy(caches.get(2), caches.get(3), false);
-      waitForBuddy(caches.get(2), caches.get(0), false);
-      System.out.println("*** Testing cache 3");
-      waitForBuddy(caches.get(3), caches.get(0), false);
-      waitForBuddy(caches.get(3), caches.get(1), false);
-
-      // now remove a cache from the cluster
-      caches.get(1).stop();
-      caches.set(1, null);
-
-      TestingUtil.sleepThread(getSleepTimeout());
-
-      // now test new buddy groups
-      System.out.println("*** Testing cache 0");
-      waitForBuddy(caches.get(0), caches.get(2), false);
-      waitForBuddy(caches.get(0), caches.get(3), false);
-      System.out.println("*** Testing cache 2");
-      waitForBuddy(caches.get(2), caches.get(3), false);
-      waitForBuddy(caches.get(2), caches.get(0), false);
-      System.out.println("*** Testing cache 3");
-      waitForBuddy(caches.get(3), caches.get(0), false);
-      waitForBuddy(caches.get(3), caches.get(2), false);
-      assertNoLocks(caches);
-   }
-
-   public void testAddingNewCaches() throws Exception
-   {
-      log.debug("Running testAddingNewCaches");
-      List<CacheSPI<Object, Object>> caches = createCaches(2, false);
-      cachesTL.set(caches);
-
-      // get some data in there.
-
-      caches.get(0).put("/cache0", "k", "v");
-      caches.get(1).put("/cache1", "k", "v");
-
-      System.out.println("*** Testing cache 0:");
-      waitForBuddy(caches.get(0), caches.get(1), true);
-      System.out.println("*** Testing cache 1:");
-      waitForBuddy(caches.get(1), caches.get(0), true);
-
-      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
-      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
-
-      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
-      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
-
-      caches.add(createCache(1, null));
-
-      TestingUtil.blockUntilViewsReceived(60000, caches);
-
-      System.out.println("*** Testing cache 0:");
-      waitForBuddy(caches.get(0), caches.get(1), true);
-      System.out.println("*** Testing cache 1:");
-      waitForBuddy(caches.get(1), caches.get(2), true);
-      System.out.println("*** Testing cache 2:");
-      waitForBuddy(caches.get(2), caches.get(0), true);
-
-
-      System.out.println("0 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(0)));
-      System.out.println("1 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(1)));
-      System.out.println("2 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(2)));
-
-      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
-      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should have backup region for non-buddy";
-      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have backup region for buddy";
-
-      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
-      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
-      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
-
-      assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
-      assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
-      assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for self";
-
-      // ensure no state transfer has happened!!
-      assert caches.get(2).peek(Fqn.fromString("/cache0"), false) == null : "Unnecessary state should not have been transferred!";
-      assert caches.get(2).peek(Fqn.fromString("/cache1"), false) == null : "Unnecessary state should not have been transferred!";
-
-      // ensure backup state has been transferred.
-      assert caches.get(2).peek(fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), Fqn.fromString("/cache1")), false) != null : "Backup state should have transferred!";
-   }
-}

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -29,24 +29,6 @@
 {
    private Log log = LogFactory.getLog(BuddyPoolBroadcastTest.class);
 
-   private void checkConsistentPoolState(List<CacheSPI<Object, Object>> caches)
-   {
-      for (int i = 0; i < caches.size(); i++)
-      {
-         Map groupMap = caches.get(i).getBuddyManager().buddyPool;
-         for (int j = 0; j < caches.size(); j++)
-         {
-            if (i != j)
-            {
-               Map groupMap2 = caches.get(j).getBuddyManager().buddyPool;
-               for (CacheSPI cache : caches)
-               {
-                  assertEquals("Comparing contents of cache " + (i + 1) + " pool map with cache " + (j + 1), groupMap.get(cache), groupMap2.get(cache));
-               }
-            }
-         }
-      }
-   }
 
    @AfterMethod(alwaysRun = true)
    public void tearDown() throws Exception
@@ -61,7 +43,6 @@
       log.error("Running test2CachesWithPoolNames");
       List<CacheSPI<Object, Object>> caches = createCaches(2, true);
       cachesTL.set(caches);
-      log.error("Created 2 caches");
 
       BuddyManager m = caches.get(0).getBuddyManager();
       Map groupMap = m.buddyPool;
@@ -70,72 +51,6 @@
       assertEquals("B", groupMap.get(caches.get(1).getLocalAddress()));
    }
 
-   public void test3CachesWithPoolNames() throws Exception
-   {
-      log.debug("Running test3CachesWithPoolNames");
-      long st = System.currentTimeMillis();
-      List<CacheSPI<Object, Object>> caches = createCaches(3, true);
-      cachesTL.set(caches);
-      System.out.println("Setup: " + (System.currentTimeMillis() - st));
-      st = System.currentTimeMillis();
-
-      BuddyManager m = caches.get(0).getBuddyManager();
-      Map groupMap = m.buddyPool;
-
-      assertEquals("A", groupMap.get(caches.get(0).getLocalAddress()));
-      assertEquals("B", groupMap.get(caches.get(1).getLocalAddress()));
-      assertEquals("C", groupMap.get(caches.get(2).getLocalAddress()));
-      System.out.println("Test: " + (System.currentTimeMillis() - st));
-   }
-
-   public void testBuddyPoolSync() throws Exception
-   {
-      log.debug("Running testBuddyPoolSync");
-      List<CacheSPI<Object, Object>> caches = createCaches(3, true);
-      cachesTL.set(caches);
-
-      Map map = caches.get(0).getBuddyManager().buddyPool;
-
-      // first test the values
-      assertEquals("Failed on cache 1", "A", map.get(caches.get(0).getLocalAddress()));
-      assertEquals("Failed on cache 1", "B", map.get(caches.get(1).getLocalAddress()));
-      assertEquals("Failed on cache 1", "C", map.get(caches.get(2).getLocalAddress()));
-
-      // now test against each other
-      checkConsistentPoolState(caches);
-   }
-
-   public void testChangingBuddyPoolMembership() throws Exception
-   {
-      log.debug("Running testChangingBuddyPoolMembership");
-      List<CacheSPI<Object, Object>> caches = createCaches(3, true);
-      cachesTL.set(caches);
-
-      Map map = caches.get(0).getBuddyManager().buddyPool;
-
-      // first test the values
-      assertEquals("Failed on cache 1", "A", map.get(caches.get(0).getLocalAddress()));
-      assertEquals("Failed on cache 1", "B", map.get(caches.get(1).getLocalAddress()));
-      assertEquals("Failed on cache 1", "C", map.get(caches.get(2).getLocalAddress()));
-
-      // now test against each other
-      checkConsistentPoolState(caches);
-
-      caches.get(1).stop();
-      caches.set(1, createCache(1, "Z"));
-
-      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
-      TestingUtil.sleepThread(getSleepTimeout());
-
-      // first test the values
-      assertEquals("Failed on cache 1", "A", map.get(caches.get(0).getLocalAddress()));
-      assertEquals("Failed on cache 1", "Z", map.get(caches.get(1).getLocalAddress()));
-      assertEquals("Failed on cache 1", "C", map.get(caches.get(2).getLocalAddress()));
-
-      // now test against each other
-      checkConsistentPoolState(caches);
-   }
-
    public void testConcurrency() throws Exception
    {
          int numCaches = 4;

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,351 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.buddyreplication;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.notifications.annotation.CacheBlocked;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.CacheUnblocked;
-import org.jboss.cache.notifications.event.Event;
-import org.jboss.cache.util.CachePrinter;
-import org.jboss.cache.util.TestingUtil;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Teststhe transfer of content under *normal* operation
- *
- * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
- */
- at Test(groups = {"functional"}, testName = "buddyreplication.BuddyReplicationTestsBase")
-public class BuddyReplicationContentTest extends BuddyReplicationTestsBase
-{
-   private final String key = "key";
-   private final String value = "value";
-   private Log log = LogFactory.getLog(BuddyGroupAssignmentTest.class);
-
-   private void assertNoStaleLocks(List<CacheSPI<Object, Object>> caches)
-   {
-      for (CacheSPI<Object, Object> cache : caches) assertNoStaleLocks(cache);
-   }
-
-   private void assertNoStaleLocks(CacheSPI<Object, Object> cache)
-   {
-      assertEquals("Number of locks in cache instance " + cache + " should be 0", 0, cache.getNumberOfLocksHeld());
-   }
-
-   public void testSimplePut() throws Exception
-   {
-      log.debug("Running testSimplePut");
-      List<CacheSPI<Object, Object>> caches = createCaches(3, false);
-      cachesTL.set(caches);
-
-      String fqn = "/test";
-      String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
-
-      assertNoStaleLocks(caches);
-
-      // put something in cache 1
-      caches.get(0).put(fqn, key, value);
-
-      assertNoStaleLocks(caches);
-
-      // this should be in neither of the other caches' "main" trees
-      assertEquals(value, caches.get(0).get(fqn, key));
-      assertNull("Should be null", caches.get(1).get(fqn, key));
-      assertNull("Should be null", caches.get(2).get(fqn, key));
-
-      // check the backup trees
-
-      assertEquals("Buddy should have data in backup tree", value, caches.get(1).get(backupFqn, key));
-      assertNull("Should be null", caches.get(2).get(backupFqn, key));
-
-      assertNoStaleLocks(caches);
-
-      System.out.println("Cache 0 = " + CachePrinter.printCacheLockingInfo(caches.get(0)));
-      System.out.println("Cache 1 = " + CachePrinter.printCacheLockingInfo(caches.get(1)));
-      System.out.println("Cache 2 = " + CachePrinter.printCacheLockingInfo(caches.get(2)));
-   }
-
-   public void testPutAndRemove() throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = createCaches(3, false);
-      cachesTL.set(caches);
-      log.debug("Running testPutAndRemove");
-
-      String fqn = "/test";
-      String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
-
-      assertNoStaleLocks(caches);
-
-      // put something in cache 1
-      caches.get(0).put(fqn, key, value);
-
-      assertNoStaleLocks(caches);
-
-      // this should be in neither of the other caches' "main" trees
-      assertEquals(value, caches.get(0).get(fqn, key));
-      assertNull("Should be null", caches.get(1).get(fqn, key));
-      assertNull("Should be null", caches.get(2).get(fqn, key));
-
-      // check the backup trees
-
-      assertEquals("Buddy should have data in backup tree", value, caches.get(1).get(backupFqn, key));
-      assertNull("Should be null", caches.get(2).get(backupFqn, key));
-
-      assertNoStaleLocks(caches);
-
-      // now remove
-      caches.get(0).removeNode(fqn);
-      assertNoStaleLocks(caches);
-
-
-      assertNull("Should be null", caches.get(0).get(fqn, key));
-      assertNull("Should be null", caches.get(1).get(fqn, key));
-      assertNull("Should be null", caches.get(2).get(fqn, key));
-
-      // check the backup trees
-      assertNull("Should be null", caches.get(0).get(backupFqn, key));
-      assertNull("Should be null", caches.get(1).get(backupFqn, key));
-      assertNull("Should be null", caches.get(2).get(backupFqn, key));
-
-      assertNoStaleLocks(caches);
-   }
-
-   public void testPutAndRemove2() throws Exception
-   {
-      log.debug("Running testPutAndRemove2");
-      List<CacheSPI<Object, Object>> caches = createCaches(2, 4, false);
-      cachesTL.set(caches);
-
-      String fqn = "/test";
-      String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
-
-      // put something in cache 1
-      assertNoStaleLocks(caches);
-
-      caches.get(0).put(fqn, key, value);
-
-      assertNoStaleLocks(caches);
-
-      // this should be in neither of the other caches' "main" trees
-      assertEquals(value, caches.get(0).get(fqn, key));
-      assertNull("Should be null", caches.get(1).get(fqn, key));
-      assertNull("Should be null", caches.get(2).get(fqn, key));
-      assertNull("Should be null", caches.get(3).get(fqn, key));
-
-      // check the backup trees
-      assertEquals("Buddy should have data in backup tree", value, caches.get(1).get(backupFqn, key));
-      assertEquals("Buddy should have data in backup tree", value, caches.get(2).get(backupFqn, key));
-      assertNull("Should be null", caches.get(3).get(backupFqn, key));
-
-      assertNoStaleLocks(caches);
-
-      // now remove
-      caches.get(0).removeNode(fqn);
-      assertNoStaleLocks(caches);
-
-      assertNull("Should be null", caches.get(0).get(fqn, key));
-      assertNull("Should be null", caches.get(1).get(fqn, key));
-      assertNull("Should be null", caches.get(2).get(fqn, key));
-      assertNull("Should be null", caches.get(3).get(fqn, key));
-
-      // check the backup trees
-      assertNull("Should be null", caches.get(0).get(backupFqn, key));
-      assertNull("Should be null", caches.get(1).get(backupFqn, key));
-      assertNull("Should be null", caches.get(2).get(backupFqn, key));
-      assertNull("Should be null", caches.get(3).get(backupFqn, key));
-
-      assertNoStaleLocks(caches);
-   }
-
-   public void testBuddyJoin() throws Exception
-   {
-      log.debug("Running testBuddyJoin");
-      List<CacheSPI<Object, Object>> caches = createCaches(2, false);
-      cachesTL.set(caches);
-      CacheSPI<Object, Object> cache2 = null;
-
-      try
-      {
-         Fqn fqn = Fqn.fromString("/test");
-         Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
-
-         assertNoStaleLocks(caches);
-
-         // put something in cache 1
-         caches.get(1).put(fqn, key, value);
-
-         assertNoStaleLocks(caches);
-
-         // this should be in neither of the other caches' "main" trees
-         assertEquals(value, caches.get(1).get(fqn, key));
-         assertFalse("Should be false", caches.get(0).exists(fqn));
-
-         // check the backup trees
-         assertEquals("Buddy should have data in backup tree", value, caches.get(0).get(backupFqn, key));
-
-         assertNoStaleLocks(caches);
-
-         // now add a new cache to the cluster
-         cache2 = createCache(1, null);
-
-         // allow this cache a few msecs to join
-         TestingUtil.blockUntilViewsReceived(3000, caches.get(0), caches.get(1), cache2);
-
-         TestingUtil.sleepThread(2000); // allow buddy group reorg
-
-         List<CacheSPI<Object, Object>> dump = new ArrayList<CacheSPI<Object, Object>>(caches);
-         dump.add(cache2);
-         TestingUtil.dumpCacheContents(dump);
-
-         // now caches.get(1)'s buddy should be cache2, not cache[0]
-         assertIsBuddy(caches.get(1), cache2, true);
-         // this should still be the same
-         assertIsBuddy(caches.get(0), caches.get(1), true);
-         // and cache2's buddy should be cache[0]
-         assertIsBuddy(cache2, caches.get(0), true);
-
-         // so now the backup data we saw on cache[0] should have been removed.
-         assertFalse("This backup data should have been removed", caches.get(0).exists(backupFqn));
-
-         // while cache2 should now posess this backup (due to a state transfer)
-         assertEquals("Backup state should have been transferred to this new cache instance", value, cache2.get(backupFqn, key));
-
-         caches.get(1).removeNode(fqn);
-         assertNoStaleLocks(caches);
-
-
-         assertFalse("Should be null", caches.get(0).exists(fqn));
-         assertFalse("Should be null", caches.get(1).exists(fqn));
-         assertFalse("Should be null", cache2.exists(fqn));
-
-         // check the backup trees
-         assertFalse("Should be null", caches.get(0).exists(backupFqn));
-         assertFalse("Should be null", caches.get(1).exists(backupFqn));
-         assertFalse("Should be null", cache2.exists(backupFqn));
-
-         assertNoStaleLocks(caches);
-
-      }
-      finally
-      {
-         if (cache2 != null) cache2.stop();
-      }
-   }
-
-   //@Test (invocationCount = 25)
-   public void testCompleteStateSurvival() throws Exception
-   {
-      log.debug("Running testCompleteStateSurvival");
-      List<CacheSPI<Object, Object>> caches = createCaches(3, false, true);
-      cachesTL.set(caches);
-      CacheBlockListener blockListener = new CacheBlockListener();
-
-      caches.get(0).addCacheListener(blockListener);
-      caches.get(1).addCacheListener(blockListener);
-      caches.get(2).addCacheListener(blockListener);
-
-      caches.get(0).put("/0", "key", "value");
-      caches.get(1).put("/1", "key", "value");
-      caches.get(2).put("/2", "key", "value");
-
-//      TestingUtil.sleepThread(getSleepTimeout());
-      //TestingUtil.sleepThread(caches.get(0).getConfiguration().getStateRetrievalTimeout() * 3);
-      blockListener.blockUntilAllCachesAreUnblocked(caches.get(0).getConfiguration().getStateRetrievalTimeout() * 3);
-
-      log.info("stopping 2");
-      caches.get(2).stop();
-
-      blockListener.blockUntilAllCachesAreUnblocked(caches.get(0).getConfiguration().getStateRetrievalTimeout() * 5);
-
-      assertEquals("value", caches.get(0).get("/2", "key"));
-
-      blockListener.blockUntilAllCachesAreUnblocked(caches.get(0).getConfiguration().getStateRetrievalTimeout() * 5);
-
-      caches.get(1).stop();
-
-      // cache[0] is all thats left!!
-
-      assertEquals("value", caches.get(0).get("/0", "key"));
-
-      try
-      {
-         assertEquals("value", caches.get(0).get("/1", "key"));
-      }
-      catch (RuntimeException e)
-      {
-         // may barf the first time around since we are unable to contact our buddy and store this data.
-         assertEquals(IllegalArgumentException.class, e.getCause().getClass());
-      }
-
-      // now try the assertion again since the local gravitation would have worked.
-
-      System.out.println("Cache contents " + CachePrinter.printCacheDetails(caches.get(0)));
-
-      assertEquals("value", caches.get(0).get("/1", "key"));
-      assertEquals("value", caches.get(0).get("/2", "key"));
-   }
-
-   @CacheListener
-   public static class CacheBlockListener
-   {
-      private int blocks = 0;
-
-      @CacheBlocked
-      public void processBlock(Event e)
-      {
-         if (e.isPre())
-         {
-            System.out.println(">>>>>>>> Got BLOCK on cache " + e.getCache().getLocalAddress());
-            synchronized (this)
-            {
-               blocks++;
-               notifyAll();
-            }
-         }
-      }
-
-      @CacheUnblocked
-      public void processUnblock(Event e)
-      {
-         if (e.isPre())
-         {
-            System.out.println(">>>>>>>> Got UNBLOCK on cache " + e.getCache().getLocalAddress());
-            synchronized (this)
-            {
-               blocks--;
-               notifyAll();
-            }
-         }
-      }
-
-      public void blockUntilAllCachesAreUnblocked(long maxWait) throws InterruptedException
-      {
-         synchronized (this)
-         {
-            if (blocks > 1)
-            {
-               wait(maxWait);
-            }
-            // try returning anyway?
-            blocks = 0;
-            /*
-            if (blocks > 1)
-               throw new RuntimeException("Timed out waiting for unblocks.  Number of blocks = " + blocks);
-            if (blocks == 1) blocks = 0;
-            */
-         }
-      }
-   }
-}

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,260 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.buddyreplication;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.internals.replicationlisteners.ReplicationListener;
-import org.jgroups.JChannel;
-import org.jgroups.protocols.DISCARD;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
-/**
- * Tests behaviour when data owners fail - essentially this tests data gravitation
- *
- * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
- */
- at Test(groups = "functional", testName = "buddyreplication.BuddyReplicationFailoverTest")
-public class BuddyReplicationFailoverTest extends BuddyReplicationTestsBase
-{
-   protected boolean optimisticLocks = false;
-   private String key = "key";
-   private String value = "value";
-   BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
-
-   public void testDataGravitationKillOwner() throws Exception
-   {
-      testDataGravitation(true);
-   }
-
-   public void testDataGravitationDontKillOwner() throws Exception
-   {
-      testDataGravitation(false);
-   }
-
-   private void testDataGravitation(boolean killOwner) throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = createCaches(3, false, true, optimisticLocks);
-      cachesTL.set(caches);
-
-      Fqn fqn = Fqn.fromString("/test");
-      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
-
-      TestingUtil.dumpCacheContents(caches);
-
-      caches.get(0).put(fqn, key, value);
-
-      TestingUtil.dumpCacheContents(caches);
-
-      assertEquals("Value should exist", value, caches.get(0).get(fqn, key));
-
-      TestingUtil.dumpCacheContents(caches);
-
-      // use exists instead of get() to prevent going up the interceptor stack
-      assertTrue("Should be false", !caches.get(1).exists(fqn));
-      assertTrue("Should be false", !caches.get(2).exists(fqn));
-
-      assertFalse("Should be false", caches.get(0).exists(backupFqn));
-      assertTrue("Value be true", caches.get(1).exists(backupFqn));
-      assertFalse("Should be false", caches.get(2).exists(backupFqn));
-
-      if (killOwner)
-      {
-         System.out.println("***** About to kill original data owner (" + caches.get(0).getLocalAddress() + ").  *****");
-         // forcefully kill data owner.
-         killChannel(caches.get(0), caches.get(1), 2);
-         waitForSingleBuddy(caches.get(1), caches.get(2));
-
-         System.out.println("Killed.  Testing backup roots.");
-         TestingUtil.dumpCacheContents(caches);
-         // assert that the remaining caches have picked new buddies.  Cache 1 should have cache 2's backup data.
-         assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
-         assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
-         assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
-         assert caches.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) != null : "Should have dead node as a defunct backup root.";
-
-         assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
-         assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
-         assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
-         assert caches.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
-      }
-
-      System.out.println("***** Killed original data owner, about to call a get on a different cache instance.  *****");
-
-      ReplicationListener replListener = ReplicationListener.getReplicationListener(caches.get(1));
-      replListener.expect(DataGravitationCleanupCommand.class);
-
-      // according to data gravitation, a call to *any* cache should retrieve the data, and move the data to the new cache.
-      assertEquals("Value should have gravitated", value, caches.get(2).get(fqn, key));
-      replListener.waitForReplicationToOccur();
-
-      TestingUtil.dumpCacheContents(caches);
-
-      // now lets test the eviction part of gravitation
-      Fqn newBackupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
-
-      // use exists instead of get() to prevent going up the interceptor stack
-      if (!killOwner)
-      {
-         assertTrue("Should be false", !caches.get(0).exists(fqn));
-      }
-      else
-      {
-         assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
-         assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
-         assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
-         assert caches.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
-         assert caches.get(1).peek(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a defunct backup root.";
-
-         assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
-         assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
-         assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
-         assert caches.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
-      }
-      assertTrue("Should be false", !caches.get(1).exists(fqn));
-
-      // the old backup should no longer exist
-      if (!killOwner) assertFalse("Should be null", caches.get(0).exists(backupFqn));
-      assertFalse("Should be null", caches.get(1).exists(backupFqn));
-      assertFalse("Should be null", caches.get(2).exists(backupFqn));
-
-      // and the backup should now exist in caches.get(2)'s buddy which is caches.get(0)
-      if (killOwner)
-      {
-         assertEquals("Value should exist", value, caches.get(1).get(newBackupFqn, key));
-      }
-      else
-      {
-         assertEquals("Value should exist", value, caches.get(0).get(newBackupFqn, key));
-         assertFalse("Should be null", caches.get(1).exists(newBackupFqn));
-      }
-      assertFalse("Should be null", caches.get(2).exists(newBackupFqn));
-   }
-
-   private void killChannel(CacheSPI cacheToKill, CacheSPI anotherCache, int finalExpectedClusterSize)
-   {
-      JChannel channel = (JChannel) cacheToKill.getRPCManager().getChannel();
-      DISCARD discard = (DISCARD) channel.getProtocolStack().findProtocol(DISCARD.class);
-      if (discard != null)
-      {
-         discard.setDiscardAll(true);
-         TestingUtil.blockUntilViewReceived(anotherCache, finalExpectedClusterSize, 10000, false);
-         // an extra second, for some reason we need this.
-         TestingUtil.sleepThread(1000);
-      }
-   }
-
-   public void testDataReplicationSuppression() throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = createCaches(3, false, false, optimisticLocks);
-      cachesTL.set(caches);
-
-      Fqn fqn = Fqn.fromString("/test");
-      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
-      caches.get(0).put(fqn, key, value);
-
-      TestingUtil.dumpCacheContents(caches);
-
-      assertEquals("value", caches.get(0).get(fqn, key));
-      assertFalse(caches.get(0).exists(backupFqn));
-      assertEquals("value", caches.get(1).get(backupFqn, key));
-      assertFalse(caches.get(1).exists(fqn));
-      assertFalse(caches.get(2).exists(fqn));
-      assertFalse(caches.get(2).exists(backupFqn));
-
-      assertNoLocks(caches);
-
-      backupFqn = fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
-
-      System.out.println("*** Calling get() on cache[1] with force option");
-
-      ReplicationListener replicationListener0 = ReplicationListener.getReplicationListener(caches.get(0));
-      replicationListener0.expect(DataGravitationCleanupCommand.class);
-
-      caches.get(1).getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
-      assertEquals("value", caches.get(1).get(fqn, key));
-      replicationListener0.waitForReplicationToOccur(); // cleanup commands are async
-
-      TestingUtil.dumpCacheContents(caches);
-
-      assertFalse(caches.get(1).exists(backupFqn));
-      assertEquals("value", caches.get(2).get(backupFqn, key));
-      assertFalse(caches.get(2).exists(fqn));
-      assertFalse(caches.get(0).exists(fqn));
-      assertFalse(caches.get(0).exists(backupFqn));
-   }
-
-   public void testSubtreeRetrieval() throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = createCaches(3, false, true, optimisticLocks);
-      cachesTL.set(caches);
-
-      Fqn fqn = Fqn.fromString("/test");
-      Fqn fqn2 = Fqn.fromString("/test/subtree");
-
-      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
-      Fqn backupFqn2 = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn2);
-
-      caches.get(0).put(fqn, key, value);
-      caches.get(0).put(fqn2, key, value);
-
-      // test backup replication to buddy
-      assertEquals(value, caches.get(0).get(fqn, key));
-      assertEquals(value, caches.get(0).get(fqn2, key));
-      assertEquals(value, caches.get(1).get(backupFqn, key));
-      assertEquals(value, caches.get(1).get(backupFqn2, key));
-
-      assertTrue(!caches.get(0).exists(backupFqn));
-      assertTrue(!caches.get(0).exists(backupFqn2));
-      assertTrue(!caches.get(1).exists(fqn));
-      assertTrue(!caches.get(1).exists(fqn2));
-      assertTrue(!caches.get(2).exists(fqn));
-      assertTrue(!caches.get(2).exists(fqn2));
-      assertTrue(!caches.get(2).exists(backupFqn));
-      assertTrue(!caches.get(2).exists(backupFqn2));
-
-      assertNoLocks(caches);
-
-      // gravitate to 2:
-      ReplicationListener replListener1 = ReplicationListener.getReplicationListener(caches.get(0));
-      replListener1.expect(DataGravitationCleanupCommand.class);
-      caches.get(2).getNode(fqn);  // expectWithTx entire subtree to gravitate.
-      replListener1.waitForReplicationToOccur(); // cleanup commands are async
-
-      Fqn newBackupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
-      Fqn newBackupFqn2 = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn2);
-
-      assertEquals(value, caches.get(2).get(fqn, key));
-      assertTrue(caches.get(2).exists(fqn2));
-      assertEquals(value, caches.get(0).get(newBackupFqn, key));
-      assertTrue(caches.get(0).exists(newBackupFqn2));
-
-      assertTrue(!caches.get(2).exists(newBackupFqn));
-      assertTrue(!caches.get(2).exists(newBackupFqn2));
-      assertTrue(!caches.get(0).exists(fqn));
-      assertTrue(!caches.get(0).exists(fqn2));
-      assertTrue(!caches.get(1).exists(fqn));
-      assertTrue(!caches.get(1).exists(fqn2));
-      assertTrue(!caches.get(1).exists(newBackupFqn));
-      assertTrue(!caches.get(1).exists(newBackupFqn2));
-
-      TestingUtil.dumpCacheContents(caches);
-
-      for (CacheSPI<Object, Object> cache : caches)
-      {
-         assertTrue(!cache.exists(backupFqn));
-         assertTrue(!cache.exists(backupFqn2));
-      }
-
-      assertNoLocks(caches);
-   }
-}

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -6,10 +6,7 @@
  */
 package org.jboss.cache.buddyreplication;
 
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.*;
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
@@ -23,12 +20,13 @@
 import org.jboss.cache.util.TestingUtil;
 import org.jgroups.Address;
 import static org.testng.AssertJUnit.*;
+import static org.testng.AssertJUnit.assertEquals;
 import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
 
 import javax.transaction.TransactionManager;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Base class for BR tests
@@ -54,50 +52,57 @@
          {
             if (c != null && c.getBuddyManager() != null) c.getBuddyManager().stop();
          }
+         cleanupCaches(caches, true);
+      }
+      cachesTL.set(null);
+      System.gc();
+      new UnitTestCacheFactory().cleanUp();
+   }
 
-         for (CacheSPI c : caches)
+   protected void cleanupCaches(List<CacheSPI<Object, Object>> caches, boolean stop)
+   {
+      for (CacheSPI c : caches)
+      {
+         if (c != null)
          {
-            if (c != null)
+            TransactionManager tm = c.getTransactionManager();
+            if (tm != null)
             {
-               TransactionManager tm = c.getTransactionManager();
-               if (tm != null)
+               try
                {
-                  try
-                  {
-                     if (tm.getTransaction() != null) tm.rollback();
-                  }
-                  catch (Exception e)
-                  {
-                     // error rolling back gtx2EntryMap
-                     e.printStackTrace();
-                  }
+                  if (tm.getTransaction() != null) tm.rollback();
                }
+               catch (Exception e)
+               {
+                  // error rolling back gtx2EntryMap
+                  e.printStackTrace();
+               }
+            }
 
-               CacheLoaderManager clm = c.getCacheLoaderManager();
-               if (clm != null)
+            CacheLoaderManager clm = c.getCacheLoaderManager();
+            if (clm != null)
+            {
+               CacheLoader cl = c.getCacheLoaderManager().getCacheLoader();
+               try
                {
-                  CacheLoader cl = c.getCacheLoaderManager().getCacheLoader();
-                  try
-                  {
-                     if (cl != null) cl.remove(Fqn.ROOT);
-                  }
-                  catch (Exception e)
-                  {
-                     // unable to clean cache loader
-                     e.printStackTrace();
-                  }
+                  if (cl != null) cl.remove(Fqn.ROOT);
                }
-
+               catch (Exception e)
+               {
+                  // unable to clean cache loader
+                  e.printStackTrace();
+               }
+            }
+            if (stop)
+            {
                c.stop();
-               c = null;
             }
+            else
+            {
+               c.removeNode(Fqn.ROOT);
+            }
          }
       }
-      cachesTL.set(null);
-      System.gc();
-
-      new UnitTestCacheFactory().cleanUp();
-
    }
 
    protected final static int VIEW_BLOCK_TIMEOUT = 5000;
@@ -137,7 +142,6 @@
       BuddyReplicationConfig brc = new BuddyReplicationConfig();
       if (buddyPoolName != null) brc.setBuddyPoolName(buddyPoolName);
       brc.setEnabled(true);
-//      brc.setBuddyCommunicationTimeout(500000);
       brc.setDataGravitationRemoveOnFind(removeOnFind);
       brc.setDataGravitationSearchBackupTrees(true);
       brc.setAutoDataGravitation(useDataGravitation);
@@ -220,7 +224,7 @@
          caches.add(createCacheWithCacheLoader(useDataGravitation, removeOnFind, passivation, fetchPersistent, true));
       }
 
-      // allow some time for the caches to start up and discover each other
+      // allow some time for the cachePool to start up and discover each other
       TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), VIEW_BLOCK_TIMEOUT);
       TestingUtil.sleepThread(getSleepTimeout());
       return caches;
@@ -269,7 +273,7 @@
 
       if (start)
       {
-         // allow some time for the caches to start up and discover each other
+         // allow some time for the cachePool to start up and discover each other
          TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), VIEW_BLOCK_TIMEOUT);
          TestingUtil.sleepThread(getSleepTimeout());
       }
@@ -279,10 +283,10 @@
 
    protected void printBuddyGroup(Cache cache)
    {
-      BuddyManager bm = ((CacheSPI) cache).getBuddyManager();
-      BuddyGroup bg = bm.buddyGroup;
-      System.out.println("*** " + bg);
-      System.out.println("    Groups I participate in: " + bm.buddyGroupsIParticipateIn.keySet());
+//      BuddyManager bm = ((CacheSPI) cache).getBuddyManager();
+//      BuddyGroup bg = bm.buddyGroup;
+//      System.out.println("*** " + bg);
+//      System.out.println("    Groups I participate in: " + bm.buddyGroupsIParticipateIn.keySet());
    }
 
    /**
@@ -298,7 +302,6 @@
       Address dataOwnerLocalAddress = dataOwner.getLocalAddress();
       Address buddyLocalAddress = buddy.getLocalAddress();
 
-      System.out.println("*** assert with groups.  Testing that " + buddyLocalAddress + " is a buddy for owner " + dataOwnerLocalAddress + " only buddy? " + onlyBuddy);
       printBuddyGroup(dataOwner);
 
       BuddyManager dataOwnerBuddyManager = ((CacheSPI) dataOwner).getBuddyManager();
@@ -311,8 +314,6 @@
 
       // and now on the buddy end
       BuddyGroup group = buddyBuddyManager.buddyGroupsIParticipateIn.get(dataOwnerLocalAddress);
-      System.out.println("*** Groups I participate in: " + buddyBuddyManager.buddyGroupsIParticipateIn);
-      System.out.println("*** Buddy's version of dataOwner's group " + group);
 
       assertTrue("buddy's list of groups it participates in should contain data owner's group name", buddyBuddyManager.buddyGroupsIParticipateIn.containsKey(dataOwnerLocalAddress));
       if (onlyBuddy) assertEquals(1, group.getBuddies().size());
@@ -324,6 +325,14 @@
       waitForBuddy(dataOwner, buddy, onlyBuddy, 60000);
    }
 
+
+
+   public void waitForSingleBuddy(List caches) throws Exception
+   {
+      Cache[] array = (Cache[]) caches.toArray(new Cache[0]);
+      waitForSingleBuddy(array);
+   }
+
    /**
     * Will wait for 60 secs + 10sec * caches.length for the given caches to become buddys.
     * The caches should be ordered as per underlying view.
@@ -379,4 +388,32 @@
       }
    }
 
+   public void assertNoStaleLocks(List<CacheSPI<Object, Object>> caches)
+   {
+      for (CacheSPI<Object, Object> cache : caches) assertNoStaleLocks(cache);
+   }
+
+   private void assertNoStaleLocks(CacheSPI<Object, Object> cache)
+   {
+      assertEquals("Number of locks in cache instance " + cache + " should be 0", 0, cache.getNumberOfLocksHeld());
+   }
+
+   protected void checkConsistentPoolState(List<CacheSPI<Object, Object>> caches)
+   {
+      for (int i = 0; i < caches.size(); i++)
+      {
+         Map groupMap = caches.get(i).getBuddyManager().buddyPool;
+         for (int j = 0; j < caches.size(); j++)
+         {
+            if (i != j)
+            {
+               Map groupMap2 = caches.get(j).getBuddyManager().buddyPool;
+               for (CacheSPI cache : caches)
+               {
+                  assertEquals("Comparing contents of cache " + (i + 1) + " pool map with cache " + (j + 1), groupMap.get(cache), groupMap2.get(cache));
+               }
+            }
+         }
+      }
+   }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -66,7 +66,7 @@
    private void dataGravitationDefaultTest(boolean autoGravitate)
          throws Exception
    {
-      // create 3 caches
+      // create 3 cachePool
       List<CacheSPI<Object, Object>> caches = createCachesWithCacheLoader(3, autoGravitate, true, passivation);
       cachesTL.set(caches);
 
@@ -171,7 +171,7 @@
    private void dataGravitationEvictionTest(boolean autoGravitate)
          throws Exception
    {
-      // create 3 caches
+      // create 3 cachePool
       List<CacheSPI<Object, Object>> caches = createCachesWithCacheLoader(3, autoGravitate, false, passivation);
       cachesTL.set(caches);
       CacheLoader[] loaders = getLoaders(caches);

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithOptimisticLockingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithOptimisticLockingTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithOptimisticLockingTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,27 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.buddyreplication;
-
-import org.testng.annotations.Test;
-
-/**
- * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
- */
- at Test(groups = {"functional", "jgroups", "optimistic"}, testName = "buddyreplication.BuddyReplicationFailoverTest")
-public class BuddyReplicationWithOptimisticLockingTest extends BuddyReplicationFailoverTest
-{
-   public BuddyReplicationWithOptimisticLockingTest()
-   {
-      optimisticLocks = true;
-   }
-
-   @Override
-   public void testDataGravitationKillOwner() throws Exception
-   {
-      super.testDataGravitationKillOwner();
-   }
-}

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,156 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.buddyreplication;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
-import static org.jboss.cache.util.TestingUtil.dumpCacheContents;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-
-import javax.transaction.TransactionManager;
-import java.util.List;
-
-/**
- * @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
- */
- at Test(groups = {"functional", "jgroups"}, testName = "buddyreplication.BuddyReplicationWithTransactionsTest")
-public class BuddyReplicationWithTransactionsTest extends BuddyReplicationTestsBase
-{
-   private Fqn fqn = Fqn.fromString("test");
-   private String key = "key";
-   private String value = "value";
-   BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
-
-   public void testTransactionsCommit() throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = caches = createCaches(3, false, true, false);
-      cachesTL.set(caches);
-      
-
-      caches.get(0).put(fqn, key, value);
-      Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
-      Fqn newBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(2).getLocalAddress()) + "/test");
-
-      dumpCacheContents(caches);
-
-      TransactionManager txman = caches.get(2).getTransactionManager();
-
-
-      assertTrue(caches.get(0).exists(fqn));
-      assertTrue(!caches.get(1).exists(fqn));
-      assertTrue(!caches.get(2).exists(fqn));
-      assertTrue(!caches.get(0).exists(oldBackupFqn));
-      assertTrue(caches.get(1).exists(oldBackupFqn));
-      assertTrue(!caches.get(2).exists(oldBackupFqn));
-      assertTrue(!caches.get(0).exists(newBackupFqn));
-      assertTrue(!caches.get(1).exists(newBackupFqn));
-      assertTrue(!caches.get(2).exists(newBackupFqn));
-
-
-      txman.begin();
-
-      dumpCacheContents(caches);
-      // will cause gravitation
-      caches.get(2).get(fqn, key);
-      dumpCacheContents(caches);
-
-      assertTrue(caches.get(0).exists(fqn));
-      assertTrue(!caches.get(1).exists(fqn));
-      assertTrue(caches.get(2).exists(fqn));
-      assertTrue(!caches.get(0).exists(oldBackupFqn));
-      assertTrue(caches.get(1).exists(oldBackupFqn));
-      assertTrue(!caches.get(2).exists(oldBackupFqn));
-      assertTrue(!caches.get(0).exists(newBackupFqn));
-      assertTrue(!caches.get(1).exists(newBackupFqn));
-      assertTrue(!caches.get(2).exists(newBackupFqn));
-
-      txman.commit();
-      cleanupDelay(); // cleanup commands are async
-
-      dumpCacheContents(caches);
-
-      assertTrue(!caches.get(0).exists(fqn));
-      assertTrue(!caches.get(1).exists(fqn));
-      assertTrue(caches.get(2).exists(fqn));
-      assertTrue(!caches.get(0).exists(oldBackupFqn));
-      assertTrue(!caches.get(1).exists(oldBackupFqn));
-      assertTrue(!caches.get(2).exists(oldBackupFqn));
-      assertTrue(caches.get(0).exists(newBackupFqn));
-      assertTrue(!caches.get(1).exists(newBackupFqn));
-      assertTrue(!caches.get(2).exists(newBackupFqn));
-
-      dumpCacheContents(caches);
-
-      assertNoLocks(caches);
-   }
-
-   private void cleanupDelay()
-   {
-      TestingUtil.sleepThread(250);
-   }
-
-   public void testTransactionsRollback() throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = caches = createCaches(3, false, true, false);
-      cachesTL.set(caches);
-
-      caches.get(0).put(fqn, key, value);
-      Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
-      Fqn newBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(2).getLocalAddress()) + "/test");
-
-      dumpCacheContents(caches);
-
-      TransactionManager txman = caches.get(2).getTransactionManager();
-
-
-      assertTrue(caches.get(0).exists(fqn));
-      assertTrue(!caches.get(1).exists(fqn));
-      assertTrue(!caches.get(2).exists(fqn));
-      assertTrue(!caches.get(0).exists(oldBackupFqn));
-      assertTrue(caches.get(1).exists(oldBackupFqn));
-      assertTrue(!caches.get(2).exists(oldBackupFqn));
-      assertTrue(!caches.get(0).exists(newBackupFqn));
-      assertTrue(!caches.get(1).exists(newBackupFqn));
-      assertTrue(!caches.get(2).exists(newBackupFqn));
-
-
-      txman.begin();
-
-      dumpCacheContents(caches);
-      caches.get(2).get(fqn, key);
-      dumpCacheContents(caches);
-
-      assertTrue(caches.get(0).exists(fqn));
-      assertTrue(!caches.get(1).exists(fqn));
-      assertTrue(caches.get(2).exists(fqn));
-      assertTrue(!caches.get(0).exists(oldBackupFqn));
-      assertTrue(caches.get(1).exists(oldBackupFqn));
-      assertTrue(!caches.get(2).exists(oldBackupFqn));
-      assertTrue(!caches.get(0).exists(newBackupFqn));
-      assertTrue(!caches.get(1).exists(newBackupFqn));
-      assertTrue(!caches.get(2).exists(newBackupFqn));
-
-      txman.rollback();
-
-      dumpCacheContents(caches);
-
-      assertTrue(caches.get(0).exists(fqn));
-      assertTrue(!caches.get(1).exists(fqn));
-      assertTrue(!caches.get(2).exists(fqn));
-      assertTrue(!caches.get(0).exists(oldBackupFqn));
-      assertTrue(caches.get(1).exists(oldBackupFqn));
-      assertTrue(!caches.get(2).exists(oldBackupFqn));
-      assertTrue(!caches.get(0).exists(newBackupFqn));
-      assertTrue(!caches.get(1).exists(newBackupFqn));
-      assertTrue(!caches.get(2).exists(newBackupFqn));
-
-      assertNoLocks(caches);
-   }
-
-}

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,73 +0,0 @@
-package org.jboss.cache.buddyreplication;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.util.CachePrinter;
-import org.jboss.cache.util.TestingUtil;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
-/**
- * This is to test JBCACHE-1229
- *
- * @author Manik Surtani (<a href="mailto:manik AT jboss DOT org">manik AT jboss DOT org</a>)
- * @since 2.1.0
- */
- at Test(groups = "functional", testName = "buddyreplication.DisabledStateTransferTest")
-public class DisabledStateTransferTest extends BuddyReplicationTestsBase
-{
-   public void testCachesWithoutStateTransfer() throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = createCaches(1, 3, false, false, false, false);
-      cachesTL.set(caches);
-
-      int cacheNumber = 0;
-      for (CacheSPI c : caches)
-      {
-         c.getConfiguration().setFetchInMemoryState(false);
-         c.start();
-         c.put("/" + cacheNumber++, "k", "v");
-      }
-
-      waitForBuddy(caches.get(0), caches.get(1), true);
-      waitForBuddy(caches.get(1), caches.get(2), true);
-      waitForBuddy(caches.get(2), caches.get(0), true);
-      Thread.sleep(2000);//wait for state transfer
-
-      for (CacheSPI c : caches)
-         System.out.println("Cache (local address " + c.getLocalAddress() + ") contents: " + CachePrinter.printCacheLockingInfo(c));
-
-      for (int i = 0; i < 3; i++)
-      {
-         int backupIndex = i == 2 ? 0 : i + 1;
-
-         assert caches.get(i).exists("/" + i) : "Data should exist on owner (cache #" + i + ")";
-         Fqn backup = fqnTransformer.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i));
-
-         assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
-         boolean backupStatePropagated = caches.get(backupIndex).exists(backup);
-         boolean backupOlderThanOwner = backupIndex < i;
-         assert (!backupStatePropagated && !backupOlderThanOwner) || (backupStatePropagated && backupOlderThanOwner) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
-      }
-
-      // now NEW state should transfer just fine.
-
-      cacheNumber = 0;
-      for (CacheSPI c : caches)
-      {
-         c.put("/" + (cacheNumber++) + "_NEW", "k", "v");
-      }
-
-      for (int i = 0; i < 3; i++)
-      {
-         int backupIndex = i == 2 ? 0 : i + 1;
-
-         assert caches.get(i).exists("/" + i + "_NEW") : "Data should exist on owner (cache #" + i + ")";
-         Fqn backup = fqnTransformer.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i + "_NEW"));
-
-         assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
-         assert caches.get(backupIndex).exists(backup) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
-      }
-   }
-}

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -23,26 +23,6 @@
    Object key = "key", value = "value";
    BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
 
-   public void testStaleRegionOnDataOwnerPessimistic() throws Exception
-   {
-      testDataOwner(false);
-   }
-
-   public void testStaleRegionOnDataOwnerOptimistic() throws Exception
-   {
-      testDataOwner(true);
-   }
-
-   public void testStaleRegionOnBuddyPessimistic() throws Exception
-   {
-      testBuddy(false);
-   }
-
-   public void testStaleRegionOnBuddyOptimistic() throws Exception
-   {
-      testBuddy(true);
-   }
-
    /**
     * UT for https://jira.jboss.org/jira/browse/JBCACHE-1445.
     */
@@ -82,100 +62,7 @@
    }
 
 
-   private void testDataOwner(boolean optimistic) throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = createCaches(1, 2, false, true, optimistic);
-      cachesTL.set(caches);
 
-      // add some stuff on the primary
-      CacheSPI dataOwner = caches.get(0);
-      CacheSPI buddy = caches.get(1);
-
-      dataOwner.put(fqn, key, value);
-
-      System.out.println("dataOwner: " + CachePrinter.printCacheDetails(dataOwner));
-      System.out.println("buddy: " + CachePrinter.printCacheDetails(buddy));
-
-      assert dataOwner.peek(fqn, false) != null : "Should have data";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
-
-      assert buddy.peek(fqn, false) == null : "Should not have data";
-      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
-      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
-      assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";
-
-      // now do a gravitate call.
-      assert buddy.get(fqn, key).equals(value) : "Data should have gravitated!";
-      // gravitation cleanup calls are async.
-      cleanupDelay();
-
-      System.out.println("dataOwner: " + CachePrinter.printCacheDetails(dataOwner));
-      System.out.println("buddy: " + CachePrinter.printCacheDetails(buddy));
-
-      assert buddy.peek(fqn, false) != null : "Should have data";
-      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
-      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
-
-      assert dataOwner.peek(fqn, false) == null : "Should not have data";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
-      assert dataOwner.peek(fqnTransformer.getBackupFqn(buddy.getLocalAddress(), fqn), false) != null : "Should have backup data";
-   }
-
-   private void testBuddy(boolean optimistic) throws Exception
-   {
-      List<CacheSPI<Object, Object>> caches = createCaches(1, 3, false, true, optimistic);
-      cachesTL.set(caches);
-
-      // add some stuff on the primary
-      CacheSPI dataOwner = caches.get(0);
-      CacheSPI buddy = caches.get(1);
-      CacheSPI thirdInstance = caches.get(2);
-
-      assertIsBuddy(dataOwner, buddy, true);
-      assertIsBuddy(buddy, thirdInstance, true);
-      assertIsBuddy(thirdInstance, dataOwner, true);
-
-      dataOwner.put(fqn, key, value);
-
-      System.out.println("dataOwner: " + CachePrinter.printCacheLockingInfo(dataOwner));
-      System.out.println("buddy: " + CachePrinter.printCacheLockingInfo(buddy));
-      System.out.println("thirdInstance: " + CachePrinter.printCacheLockingInfo(thirdInstance));
-
-      assert dataOwner.peek(fqn, false) != null : "Should have data";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for 2nd instance!";
-
-      assert buddy.peek(fqn, false) == null : "Should not have data";
-      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
-      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
-      assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";
-
-      // now do a gravitate call.
-      assert thirdInstance.get(fqn, key).equals(value) : "Data should have gravitated!";
-
-      // gravitation cleanup calls are async.
-      cleanupDelay();
-
-      System.out.println("dataOwner: " + CachePrinter.printCacheLockingInfo(dataOwner));
-      System.out.println("buddy: " + CachePrinter.printCacheLockingInfo(buddy));
-      System.out.println("thirdInstance: " + CachePrinter.printCacheLockingInfo(thirdInstance));
-
-      assert thirdInstance.peek(fqn, false) != null : "Should have data";
-      assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
-      assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
-
-      assert dataOwner.peek(fqn, false) == null : "Should not have data";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
-      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
-      assert dataOwner.peek(fqnTransformer.getBackupFqn(thirdInstance.getLocalAddress(), fqn), false) != null : "Should have backup data";
-      assert buddy.peek(fqn, false) == null : "Should not have data";
-      assert buddy.peek(fqn.getParent(), false) == null : "Should not have any part of the data";
-      assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) == null : "Should NOT have backup data";
-   }
-
    private void cleanupDelay()
    {
       TestingUtil.sleepThread(250);

Copied: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesBackupActivationInactivationTest.java (from rev 7262, core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyBackupActivationInactivationTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesBackupActivationInactivationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesBackupActivationInactivationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,14 @@
+package org.jboss.cache.buddyreplication.mvcc;
+
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+ at Test(groups = {"functional", "mvcc"}, testName = "buddyreplication.mvcc.Buddy2NodesBackupActivationInactivationTest")
+public class Buddy2NodesBackupActivationInactivationTest extends org.jboss.cache.buddyreplication.Buddy2NodesBackupActivationInactivationTest
+{
+   @Override
+   protected NodeLockingScheme getNonOptimisticLockingScheme()
+   {
+      return NodeLockingScheme.MVCC;
+   }
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesBackupActivationInactivationTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesNoBuddyPoolTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesNoBuddyPoolTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy2NodesNoBuddyPoolTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,19 @@
+package org.jboss.cache.buddyreplication.mvcc;
+
+import org.jboss.cache.config.Configuration;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test (groups = "functional", testName = "buddyreplication.mvcc.Buddy2NodesNoBuddyPoolTest")
+public class Buddy2NodesNoBuddyPoolTest extends org.jboss.cache.buddyreplication.Buddy2NodesNoBuddyPoolTest
+{
+   @Override
+   protected Configuration.NodeLockingScheme getNonOptimisticLockingScheme()
+   {
+      return Configuration.NodeLockingScheme.MVCC;
+   }
+
+}

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoPoolNoDataGravitationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoPoolNoDataGravitationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoPoolNoDataGravitationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,18 @@
+package org.jboss.cache.buddyreplication.mvcc;
+
+import org.testng.annotations.Test;
+import org.jboss.cache.config.Configuration;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "mvcc.buddyreplication.Buddy3NodesNoPoolNoDataGravitationTest")
+public class Buddy3NodesNoPoolNoDataGravitationTest extends org.jboss.cache.buddyreplication.Buddy3NodesNoPoolNoDataGravitationTest
+{
+   @Override
+   protected Configuration.NodeLockingScheme getNonOptimisticLockingScheme()
+   {
+      return Configuration.NodeLockingScheme.MVCC;
+   }
+   
+}

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoPoolWithDataGravitationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoPoolWithDataGravitationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoPoolWithDataGravitationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,18 @@
+package org.jboss.cache.buddyreplication.mvcc;
+
+import org.testng.annotations.Test;
+import org.jboss.cache.config.Configuration;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "buddyreplication.mvcc.Buddy3NodesNoPoolWithDataGravitationTest")
+public class Buddy3NodesNoPoolWithDataGravitationTest extends org.jboss.cache.buddyreplication.Buddy3NodesNoPoolWithDataGravitationTest 
+{
+   @Override
+   protected Configuration.NodeLockingScheme getNonOptimisticLockingScheme()
+   {
+      return Configuration.NodeLockingScheme.MVCC;
+   }
+
+}

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoStateTransfer.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoStateTransfer.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesNoStateTransfer.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,18 @@
+package org.jboss.cache.buddyreplication.mvcc;
+
+import org.jboss.cache.config.Configuration;
+import org.testng.annotations.Test;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "buddyreplication.mvcc.Buddy3NodesNoStateTransfer")
+public class Buddy3NodesNoStateTransfer extends org.jboss.cache.buddyreplication.Buddy3NodesNoStateTransfer
+{
+   @Override
+   protected Configuration.NodeLockingScheme getNonOptimisticLockingScheme()
+   {
+      return Configuration.NodeLockingScheme.MVCC;
+   }
+
+}

Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesWithPoolNoDataGravitationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesWithPoolNoDataGravitationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesWithPoolNoDataGravitationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,19 @@
+package org.jboss.cache.buddyreplication.mvcc;
+
+import org.testng.annotations.Test;
+import org.jboss.cache.buddyreplication.BuddyReplicationTestsBase;
+import org.jboss.cache.config.Configuration;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "mvcc.buddyreplication.Buddy3NodesWithPoolNoDataGravitationTest")
+public class Buddy3NodesWithPoolNoDataGravitationTest extends org.jboss.cache.buddyreplication.Buddy3NodesWithPoolNoDataGravitationTest
+{
+   @Override
+   protected Configuration.NodeLockingScheme getNonOptimisticLockingScheme()
+   {
+      return Configuration.NodeLockingScheme.MVCC;
+   }
+   
+}

Copied: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy4Nodes2BackupsTest.java (from rev 7262, core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyGroupAssignmentTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy4Nodes2BackupsTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy4Nodes2BackupsTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,14 @@
+package org.jboss.cache.buddyreplication.mvcc;
+
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+ at Test(groups = {"functional", "mvcc"}, testName = "buddyreplication.mvcc.Buddy4Nodes2BackupsTest")
+public class Buddy4Nodes2BackupsTest extends org.jboss.cache.buddyreplication.Buddy4Nodes2BackupsTest
+{
+   @Override
+   protected NodeLockingScheme getNonOptimisticLockingScheme()
+   {
+      return NodeLockingScheme.MVCC;
+   }
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy4Nodes2BackupsTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyBackupActivationInactivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyBackupActivationInactivationTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyBackupActivationInactivationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,14 +0,0 @@
-package org.jboss.cache.buddyreplication.mvcc;
-
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
- at Test(groups = {"functional", "mvcc"}, testName = "buddyreplication.mvcc.BuddyBackupActivationInactivationTest")
-public class BuddyBackupActivationInactivationTest extends org.jboss.cache.buddyreplication.BuddyBackupActivationInactivationTest
-{
-   @Override
-   protected NodeLockingScheme getNonOptimisticLockingScheme()
-   {
-      return NodeLockingScheme.MVCC;
-   }
-}

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyGroupAssignmentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyGroupAssignmentTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyGroupAssignmentTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,14 +0,0 @@
-package org.jboss.cache.buddyreplication.mvcc;
-
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
- at Test(groups = {"functional", "mvcc"}, testName = "buddyreplication.mvcc.BuddyGroupAssignmentTest")
-public class BuddyGroupAssignmentTest extends org.jboss.cache.buddyreplication.BuddyGroupAssignmentTest
-{
-   @Override
-   protected NodeLockingScheme getNonOptimisticLockingScheme()
-   {
-      return NodeLockingScheme.MVCC;
-   }
-}

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationContentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationContentTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationContentTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,14 +0,0 @@
-package org.jboss.cache.buddyreplication.mvcc;
-
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
- at Test(groups = {"functional", "mvcc"}, testName = "buddyreplication.mvcc.BuddyReplicationContentTest")
-public class BuddyReplicationContentTest extends org.jboss.cache.buddyreplication.BuddyReplicationContentTest
-{
-   @Override
-   protected NodeLockingScheme getNonOptimisticLockingScheme()
-   {
-      return NodeLockingScheme.MVCC;
-   }
-}

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationFailoverTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationFailoverTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,10 +1,11 @@
 package org.jboss.cache.buddyreplication.mvcc;
 
 import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.buddyreplication.Buddy3NodesWithFailoverTest;
 import org.testng.annotations.Test;
 
- at Test(groups = {"functional", "mvcc"}, testName = "buddyreplication.mvcc.BuddyReplicationFailoverTest")
-public class BuddyReplicationFailoverTest extends org.jboss.cache.buddyreplication.BuddyReplicationFailoverTest
+ at Test(groups = {"functional", "mvcc"}, testName = "buddyreplication.mvcc.Buddy3NodesWithFailoverTest")
+public class BuddyReplicationFailoverTest extends Buddy3NodesWithFailoverTest
 {
    @Override
    protected NodeLockingScheme getNonOptimisticLockingScheme()

Deleted: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationWithTransactionsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationWithTransactionsTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/BuddyReplicationWithTransactionsTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,14 +0,0 @@
-package org.jboss.cache.buddyreplication.mvcc;
-
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
- at Test(groups = {"functional", "mvcc"}, testName = "buddyreplication.mvcc.BuddyReplicationWithTransactionsTest")
-public class BuddyReplicationWithTransactionsTest extends org.jboss.cache.buddyreplication.BuddyReplicationWithTransactionsTest
-{
-   @Override
-   protected NodeLockingScheme getNonOptimisticLockingScheme()
-   {
-      return NodeLockingScheme.MVCC;
-   }
-}

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/GravitationCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/GravitationCleanupTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/GravitationCleanupTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -11,16 +11,4 @@
    {
       return NodeLockingScheme.MVCC;
    }
-
-   @Override
-   public void testStaleRegionOnDataOwnerOptimistic()
-   {
-      // noop
-   }
-
-   @Override
-   public void testStaleRegionOnBuddyOptimistic()
-   {
-      // noop
-   }
 }

Added: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestXmlConfigurationParser.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestXmlConfigurationParser.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestXmlConfigurationParser.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,124 @@
+package org.jboss.cache.factories;
+
+import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.util.FileLookup;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.InputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * The purpose of this class is to make sure that the parsing of the test files is only performed once.
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+class UnitTestXmlConfigurationParser
+{
+   private static Log log = LogFactory.getLog(UnitTestCacheConfigurationFactory.class);
+   public static final String DEFAULT_CONFIGURATION_FILE = "unit-test-cache-service.xml";
+   public static final String JGROUPS_CHANNEL;
+   public static final String JGROUPS_STACK_TYPE = "jgroups.stack";
+
+   static
+   {
+      JGROUPS_CHANNEL = System.getProperty(JGROUPS_STACK_TYPE);
+   }
+
+
+   private volatile static UnitTestXmlConfigurationParser instance;
+   private volatile Configuration confCache;
+   private volatile Map<String, Element> elementCache = new HashMap<String, Element>();
+
+
+   public static Configuration getConfiguration(Configuration.CacheMode cacheMode, boolean useTcp)
+   {
+      if (instance == null)
+      {
+         synchronized (UnitTestXmlConfigurationParser.class)
+         {
+            if (instance == null)
+            {
+               instance = new UnitTestXmlConfigurationParser();
+               instance.parseFile();
+            }
+         }
+      }
+      if (instance == null)
+      {
+         log.error("instance is null after creating node!!!");
+         throw new IllegalStateException();
+      }
+      //if there is an enforced jgroups stack, then only consider that one
+      if (JGROUPS_CHANNEL != null)
+      {
+         useTcp = JGROUPS_CHANNEL.trim().equals("tcp");
+      }
+      String resultKey = useTcp ? "tcp-" : "udp-";
+      resultKey += cacheMode.isSynchronous() ? "sync" : "async";
+      Configuration resultConf;
+      try
+      {
+         resultConf = instance.confCache.clone();
+      } catch (CloneNotSupportedException e)
+      {
+         log.error("Could not clone:", e);
+         throw new IllegalStateException(e);
+      }
+      Element stack = instance.elementCache.get(resultKey);
+      if (stack == null)
+      {
+         log.error("stack is null!!!");
+         throw new NullPointerException();
+      }
+      resultConf.setClusterConfig(stack);
+      if (resultConf.getClusterConfig() == null)
+      {
+         log.error("Null cluster config");
+         throw new IllegalStateException();
+      }
+      resultConf.setCacheMode(cacheMode);
+      return resultConf;
+   }
+
+   private void parseFile()
+   {
+      parseStream(new FileLookup().lookupFile(DEFAULT_CONFIGURATION_FILE));
+   }
+
+   private void parseStream(InputStream stream)
+   {
+      try
+      {
+// loop through all elements in XML.
+         if (stream == null) throw new ConfigurationException("Input stream for configuration xml is null!");
+
+         Element root = XmlConfigHelper.getDocumentRoot(stream);
+         XmlConfigurationParser parser = new XmlConfigurationParser();
+         confCache = parser.parseElement(root);
+         if (confCache == null) throw new NullPointerException("Null conf cache!!");
+
+         Element list = (Element) root.getElementsByTagNameNS("*", "protocol_stacks").item(0);
+         NodeList stacks = list.getElementsByTagNameNS("*", "stack");
+
+         for (int i = 0; i < stacks.getLength(); i++)
+         {
+            Element stack = (Element) stacks.item(i);
+            String stackName = stack.getAttribute("name");
+            Element jgroupsStack = (Element) stack.getElementsByTagNameNS("*", "config").item(0);
+            elementCache.put(stackName, jgroupsStack);
+         }
+      }
+      catch (Exception e)
+      {
+         log.error(e);
+         throw new IllegalStateException(e);
+      }
+   }
+}

Deleted: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,155 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.loader;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.transaction.DummyTransactionManager;
-import org.jboss.cache.util.TestDbPropertiesFactory;
-import org.jboss.cache.util.TestingUtil;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-import org.hsqldb.jdbc.jdbcDataSource;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import java.util.Properties;
-
-/**
- * This test runs cache loader tests using Database as the cache loader store.
- * The default test is configured using MySQL.
- * The server and database configuration is read from a properties file located at
- * /etc/cache-jdbc.properties.
- * <p/>
- * The appropriate JDBC driver (i.e mysql-connector-java-3.0.10-stable-bin.jar)
- * must be in the lib directory for this test to run successfuly
- *
- * @author <a href="hmesha at novell.com">Hany Mesha</a>
- * @version <tt>$Revision$</tt>
- */
- at Test(groups = {"functional"}, testName = "loader.JDBCCacheLoaderDerbyDSTest")
-public class JDBCCacheLoaderDerbyDSTest extends CacheLoaderTestsBase
-{
-   //private String old_factory = null;
-   private final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
-   private final String JNDI_NAME = "java:/DerbyDS";
-   private Properties prop;
-   private jdbcDataSource ds;
-
-   protected void configureCache() throws Exception
-   {
-      //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
-      System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
-      DummyTransactionManager.getInstance();
-
-      Context context = new InitialContext();
-      try
-      {
-         Object obj = context.lookup(JNDI_NAME);
-         assertNull(JNDI_NAME + " not bound", obj);
-      }
-      catch (NameNotFoundException n)
-      {
-         // expected
-      }
-
-      prop = TestDbPropertiesFactory.getTestDbProperties();
-
-      ds = new jdbcDataSource();
-      ds.setDatabase(prop.getProperty("cache.jdbc.url"));
-      ds.setUser("sa");
-
-      String props = "cache.jdbc.datasource =" + JNDI_NAME + "\n" +
-            "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
-            "cache.jdbc.sql-concat= 1 || 2" + "\n" +
-            "cache.jdbc.table.name=jbosscache" + "\n" +
-            "cache.jdbc.table.primarykey=jbosscache_pk";
-
-      CacheLoaderConfig config = getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false);
-      cache.getConfiguration().setCacheLoaderConfig(config);
-      cache.create();
-
-
-      context.bind(JNDI_NAME, ds);
-      assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
-   }
-
-   protected void cleanup()
-   {
-//      ds.setShutdownDatabase("shutdown");
-      TestDbPropertiesFactory.shutdownInMemoryDatabase(prop);
-   }
-
-   public void testLargeObject()
-   {
-      try
-      {
-         String key = "LargeObj";
-         // create an object with size bigger than 4k (k=1024 bytes)
-         StringBuilder text = new StringBuilder("LargeObject");
-         while (text.toString().getBytes().length < (1024 * 100))
-         {
-            text.append(text);
-         }
-         String initialValue = text.toString();
-         // insert it into the cache loader
-         loader.remove(Fqn.fromString("/"));
-
-         Object retVal = loader.put(FQN, key, initialValue);
-         assertNull(retVal);
-         addDelay();
-         // load the object from the cache loader and validate it
-         assertEquals(initialValue, (String) loader.get(FQN).get(key));
-         // update the object and validate it
-         String updatedValue = initialValue.concat(("UpdatedValue"));
-         retVal = loader.put(FQN, key, updatedValue);
-         assertEquals(initialValue, (String) retVal);
-         assertEquals(updatedValue, (String) loader.get(FQN).get(key));
-      }
-      catch (Exception e)
-      {
-         fail(e.toString());
-      }
-   }
-
-   public void testTransactionRollback() throws Exception
-   {
-      // no-op
-   }
-
-   public void testIntegratedTransactionRollback() throws Exception
-   {
-      // no-op
-   }
-
-   @AfterMethod(alwaysRun = true)
-   public void tearDown() throws Exception
-   {
-      super.tearDown();
-      Properties icProps = new Properties();
-      icProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
-      Context ctx = new InitialContext(icProps);
-      ctx.unbind(JNDI_NAME);
-      /*
-      if (old_factory != null)
-      {
-         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
-      }
-      else
-      {
-         System.getProperties().remove(Context.INITIAL_CONTEXT_FACTORY);
-      }
-      */ 
-   }
-
-   public void testRemoveData()
-   {
-      super.testRemoveData();
-   }
-}

Copied: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java (from rev 7269, core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderDerbyDSTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.loader;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.util.TestDbPropertiesFactory;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+import org.hsqldb.jdbc.jdbcDataSource;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import java.util.Properties;
+
+/**
+ * This test runs cache loader tests using Database as the cache loader store.
+ * The default test is configured using MySQL.
+ * The server and database configuration is read from a properties file located at
+ * /etc/cache-jdbc.properties.
+ * <p/>
+ * The appropriate JDBC driver (i.e mysql-connector-java-3.0.10-stable-bin.jar)
+ * must be in the lib directory for this test to run successfuly
+ *
+ * @author <a href="hmesha at novell.com">Hany Mesha</a>
+ * @version <tt>$Revision$</tt>
+ */
+ at Test(groups = {"functional"}, testName = "loader.JDBCCacheLoaderHsqldbDSTest")
+public class JDBCCacheLoaderHsqldbDSTest extends CacheLoaderTestsBase
+{
+   //private String old_factory = null;
+   private final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
+   private final String JNDI_NAME = "java:/DerbyDS";
+   private Properties prop;
+   private jdbcDataSource ds;
+
+   protected void configureCache() throws Exception
+   {
+      //old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+      System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
+      DummyTransactionManager.getInstance();
+
+      Context context = new InitialContext();
+      try
+      {
+         Object obj = context.lookup(JNDI_NAME);
+         assertNull(JNDI_NAME + " not bound", obj);
+      }
+      catch (NameNotFoundException n)
+      {
+         // expected
+      }
+
+      prop = TestDbPropertiesFactory.getTestDbProperties();
+
+      ds = new jdbcDataSource();
+      ds.setDatabase(prop.getProperty("cache.jdbc.url"));
+      ds.setUser("sa");
+
+      String props = "cache.jdbc.datasource =" + JNDI_NAME + "\n" +
+            "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
+            "cache.jdbc.sql-concat= 1 || 2" + "\n" +
+            "cache.jdbc.table.name=jbosscache" + "\n" +
+            "cache.jdbc.table.primarykey=jbosscache_pk";
+
+      CacheLoaderConfig config = getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false);
+      cache.getConfiguration().setCacheLoaderConfig(config);
+      cache.create();
+
+
+      context.bind(JNDI_NAME, ds);
+      assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
+   }
+
+   protected void cleanup()
+   {
+//      ds.setShutdownDatabase("shutdown");
+      TestDbPropertiesFactory.shutdownInMemoryDatabase(prop);
+   }
+
+   public void testLargeObject()
+   {
+      try
+      {
+         String key = "LargeObj";
+         // create an object with size bigger than 4k (k=1024 bytes)
+         StringBuilder text = new StringBuilder("LargeObject");
+         while (text.toString().getBytes().length < (1024 * 100))
+         {
+            text.append(text);
+         }
+         String initialValue = text.toString();
+         // insert it into the cache loader
+         loader.remove(Fqn.fromString("/"));
+
+         Object retVal = loader.put(FQN, key, initialValue);
+         assertNull(retVal);
+         addDelay();
+         // load the object from the cache loader and validate it
+         assertEquals(initialValue, (String) loader.get(FQN).get(key));
+         // update the object and validate it
+         String updatedValue = initialValue.concat(("UpdatedValue"));
+         retVal = loader.put(FQN, key, updatedValue);
+         assertEquals(initialValue, (String) retVal);
+         assertEquals(updatedValue, (String) loader.get(FQN).get(key));
+      }
+      catch (Exception e)
+      {
+         fail(e.toString());
+      }
+   }
+
+   public void testTransactionRollback() throws Exception
+   {
+      // no-op
+   }
+
+   public void testIntegratedTransactionRollback() throws Exception
+   {
+      // no-op
+   }
+
+   @AfterMethod(alwaysRun = true)
+   public void tearDown() throws Exception
+   {
+      super.tearDown();
+      Properties icProps = new Properties();
+      icProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
+      Context ctx = new InitialContext(icProps);
+      ctx.unbind(JNDI_NAME);
+      /*
+      if (old_factory != null)
+      {
+         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
+      }
+      else
+      {
+         System.getProperties().remove(Context.INITIAL_CONTEXT_FACTORY);
+      }
+      */ 
+   }
+
+   public void testRemoveData()
+   {
+      super.testRemoveData();
+   }
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy2NodesBackupActivationInactivationTest.java (from rev 7262, core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy2NodesBackupActivationInactivationTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy2NodesBackupActivationInactivationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.multiplexer;
+
+import org.jboss.cache.Cache;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Repeats the superclass tests, but with the multiplexer enabled.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Test(enabled = true, testName = "multiplexer.Buddy2NodesBackupActivationInactivationTest")
+public class Buddy2NodesBackupActivationInactivationTest extends org.jboss.cache.buddyreplication.Buddy2NodesBackupActivationInactivationTest
+{
+   private ThreadLocal<MultiplexerTestHelper> muxHelperTL = new ThreadLocal<MultiplexerTestHelper>();
+
+   @BeforeMethod(alwaysRun = true)
+   protected void setUp() throws Exception
+   {
+      muxHelperTL.set(new MultiplexerTestHelper());
+   }
+
+   @AfterMethod(alwaysRun = true)
+   public void tearDown() throws Exception
+   {
+      try
+      {
+         super.tearDown();
+      }
+      finally
+      {
+         if (muxHelperTL.get() != null)
+            muxHelperTL.get().tearDown();
+         muxHelperTL.set(null);
+      }
+   }
+
+   @Override
+   protected void configureMultiplexer(Cache cache) throws Exception
+   {
+      muxHelperTL.get().configureCacheForMux(cache);
+   }
+
+   @Override
+   protected void validateMultiplexer(Cache cache)
+   {
+      assertTrue("Cache is using multiplexer", cache.getConfiguration().isUsingMultiplexer());
+   }
+
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy2NodesBackupActivationInactivationTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java (from rev 7262, core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyGroupAssignmentTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.multiplexer;
+
+import org.jboss.cache.Cache;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Repeats the superclass tests, but with the multiplexer enabled.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+ at Test(enabled = true, testName = "multiplexer.Buddy4Nodes2BackupsTest")
+public class Buddy4Nodes2BackupsTest extends org.jboss.cache.buddyreplication.Buddy4Nodes2BackupsTest
+{
+   private MultiplexerTestHelper muxHelper;
+
+   @BeforeMethod(alwaysRun = true)
+   public void setUp() throws Exception
+   {
+      muxHelper = new MultiplexerTestHelper();
+   }
+
+   @AfterMethod(alwaysRun = true)
+   public void tearDown() throws Exception
+   {
+      try
+      {
+         super.tearDown();
+      }
+      finally
+      {
+         if (muxHelper != null)
+            muxHelper.tearDown();
+         muxHelper = null;
+      }
+   }
+
+   @Override
+   protected void configureMultiplexer(Cache cache) throws Exception
+   {
+      muxHelper.configureCacheForMux(cache);
+   }
+
+   @Override
+   protected void validateMultiplexer(Cache cache)
+   {
+      assertTrue("Cache is using multiplexer", cache.getConfiguration().isUsingMultiplexer());
+   }
+
+}


Property changes on: core/trunk/src/test/java/org/jboss/cache/multiplexer/Buddy4Nodes2BackupsTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyBackupActivationInactivationTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.multiplexer;
-
-import org.jboss.cache.Cache;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Repeats the superclass tests, but with the multiplexer enabled.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
- at Test(enabled = true, testName = "multiplexer.BuddyBackupActivationInactivationTest")
-public class BuddyBackupActivationInactivationTest
-   extends org.jboss.cache.buddyreplication.BuddyBackupActivationInactivationTest
-{
-   private ThreadLocal<MultiplexerTestHelper> muxHelperTL = new ThreadLocal<MultiplexerTestHelper>();
-
-   @BeforeMethod(alwaysRun = true)
-   protected void setUp() throws Exception
-   {
-      muxHelperTL.set(new MultiplexerTestHelper());
-
-      super.setUp();
-   }
-
-   @AfterMethod(alwaysRun = true)
-   public void tearDown() throws Exception
-   {
-      try
-      {
-         super.tearDown();
-      }
-      finally
-      {
-         if (muxHelperTL.get() != null)
-            muxHelperTL.get().tearDown();
-         muxHelperTL.set(null);
-      }
-   }
-
-   @Override
-   protected void configureMultiplexer(Cache cache) throws Exception
-   {
-      muxHelperTL.get().configureCacheForMux(cache);
-   }
-
-   @Override
-   protected void validateMultiplexer(Cache cache)
-   {
-      assertTrue("Cache is using multiplexer", cache.getConfiguration().isUsingMultiplexer());
-   }
-
-}

Deleted: core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyGroupAssignmentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyGroupAssignmentTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyGroupAssignmentTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.multiplexer;
-
-import org.jboss.cache.Cache;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Repeats the superclass tests, but with the multiplexer enabled.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
- at Test(enabled = true, testName = "multiplexer.BuddyGroupAssignmentTest")
-public class BuddyGroupAssignmentTest extends org.jboss.cache.buddyreplication.BuddyGroupAssignmentTest
-{
-   private MultiplexerTestHelper muxHelper;
-
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() throws Exception
-   {
-      muxHelper = new MultiplexerTestHelper();
-   }
-
-   @AfterMethod(alwaysRun = true)
-   public void tearDown() throws Exception
-   {
-      try
-      {
-         super.tearDown();
-      }
-      finally
-      {
-         if (muxHelper != null)
-            muxHelper.tearDown();
-         muxHelper = null;
-      }
-   }
-
-   @Override
-   protected void configureMultiplexer(Cache cache) throws Exception
-   {
-      muxHelper.configureCacheForMux(cache);
-   }
-
-   @Override
-   protected void validateMultiplexer(Cache cache)
-   {
-      assertTrue("Cache is using multiplexer", cache.getConfiguration().isUsingMultiplexer());
-   }
-
-}

Modified: core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyReplicationFailoverTest.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/BuddyReplicationFailoverTest.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -22,6 +22,7 @@
 package org.jboss.cache.multiplexer;
 
 import org.jboss.cache.Cache;
+import org.jboss.cache.buddyreplication.Buddy3NodesWithFailoverTest;
 import static org.testng.AssertJUnit.assertTrue;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -34,9 +35,8 @@
  * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
  * @version $Revision$
  */
- at Test(groups={"functional", "jgroups"}, enabled = true, testName = "multiplexer.BuddyReplicationFailoverTest")
-public class BuddyReplicationFailoverTest
-   extends org.jboss.cache.buddyreplication.BuddyReplicationFailoverTest
+ at Test(groups={"functional", "jgroups"}, enabled = true, testName = "multiplexer.Buddy3NodesWithFailoverTest")
+public class BuddyReplicationFailoverTest extends Buddy3NodesWithFailoverTest
 {
    private ThreadLocal<MultiplexerTestHelper> muxHelperTL = new ThreadLocal<MultiplexerTestHelper>();
 

Modified: core/trunk/src/test/java/org/jboss/cache/testng/Base.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/testng/Base.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/testng/Base.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -1,21 +1,69 @@
 package org.jboss.cache.testng;
 
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
 
 /**
  * @author Mircea.Markus at jboss.com
  */
- at Test(groups = "functional", testName = "Base")
+ at Test(groups = "functional", testName = "sadsadsa")
 public class Base
 {
+   private int value = -5;
+
+   static int count;
+
+   public Base(int value)
+   {
+      this.value = value;
+   }
+
+   public Base()
+   {
+   }
+
+   @Factory
+   public static Object[] createInstances()
+   {
+      Base base = new Base(1);
+      Base base2 = new Base(2);
+      return new Object[]{base, base2};
+   }
+
+
+   @BeforeClass
+   public void beforeTest()
+   {
+      System.out.println("Base.beforeTest" + value);
+   }
+
+   @AfterClass
+   public void afterTest()
+   {
+      System.out.println("Base.afterTest" + value);
+   }
+
    public void testBaseAaaaaa()
    {
-      System.out.println( getThreadName() + "aaaaaaaaaaaa");
+      System.out.println(getThreadName() + "aaaaaaaaaaaa" + value);
    }
 
+   @BeforeMethod
+   public void beforeMethod()
+   {
+      System.out.println("Base.beforeMethod" + value);
+   }
+
+   @AfterMethod
+   public void afterMethod()
+   {
+      System.out.println("Base.afterMethod" + value);
+   }
+
    public void testBaseBbbbbbb()
    {
-      System.out.println( getThreadName() + "bbbbbbbbbbbbb");
+      count++;
+//      if (count == 2) throw new RuntimeException();
+      System.out.println(getThreadName() + "bbbbbbbbbbbbb" + value);
    }
 
    protected String getThreadName()

Modified: core/trunk/src/test/java/org/jboss/cache/testng/Derived.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/testng/Derived.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/testng/Derived.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -5,21 +5,26 @@
 /**                                
  * @author Mircea.Markus at jboss.com
  */
- at Test(groups = "functional" , testName = "testng.Derived")
+ at Test(groups = "functional" , testName = "Same")
 public class Derived extends Base
 {
-   public void testDerivedCcccc()
+   public Derived(int value)
    {
-      System.out.println(getThreadName() + "ccccccccccccccccc");
+      super(value);
    }
 
-   public void testDerivedDdddd()
-   {
-      System.out.println(getThreadName() + "dddddddddddddddddddd");
-   }
-
-   protected String getThreadName()
-   {
-      return "[" + getClass() + " ************ -> " + Thread.currentThread().getName() + "] ";
-   }
+   //   public void testDerivedCcccc()
+//   {
+//      System.out.println(getThreadName() + "ccccccccccccccccc");
+//   }
+//
+//   public void testDerivedDdddd()
+//   {
+//      System.out.println(getThreadName() + "dddddddddddddddddddd");
+//   }
+//
+//   protected String getThreadName()
+//   {
+//      return "[" + getClass() + " ************ -> " + Thread.currentThread().getName() + "] ";
+//   }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/testng/Other.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/testng/Other.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/testng/Other.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -5,7 +5,7 @@
 /**
  * @author Mircea.Markus at jboss.com
  */
- at Test(groups = "functional", testName = "Other")
+ at Test(groups = "functional", enabled = false, testName = "Same")
 public class Other
 {
    public void eeeeeeeeeeee() {

Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java	2008-12-11 16:33:03 UTC (rev 7282)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java	2008-12-11 20:26:09 UTC (rev 7283)
@@ -75,10 +75,10 @@
       CommandAwareRpcDispatcher realDispatcher = (CommandAwareRpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
       RpcDispatcher.Marshaller2 realMarshaller = (RpcDispatcher.Marshaller2) realDispatcher.getMarshaller();
       RpcDispatcher.Marshaller2 delegate = null;
-      if ((realMarshaller instanceof RegionMarshallerDelegate) || (realMarshaller instanceof MarshallerDelegate))
-      {
-         throw new RuntimeException("Illegal state");
-      }
+//      if ((realMarshaller instanceof RegionMarshallerDelegate) || (realMarshaller instanceof MarshallerDelegate))
+//      {
+//         throw new RuntimeException("Illegal state");
+//      }
       if (realDispatcher instanceof InactiveRegionAwareRpcDispatcher)
          delegate = new RegionMarshallerDelegate((Marshaller) realMarshaller);
       else




More information about the jbosscache-commits mailing list