[jbosscache-commits] JBoss Cache SVN: r7082 - core/trunk/src/test/java/org/jboss/cache/passivation.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Nov 4 11:12:57 EST 2008


Author: mircea.markus
Date: 2008-11-04 11:12:57 -0500 (Tue, 04 Nov 2008)
New Revision: 7082

Modified:
   core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
Log:
make the test sequential as it shares a static dummy in memory cache loader

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java	2008-11-04 14:57:30 UTC (rev 7081)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java	2008-11-04 16:12:57 UTC (rev 7082)
@@ -27,6 +27,7 @@
 import org.jboss.cache.Node;
 import org.jboss.cache.Region;
 import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.CacheLoaderConfig;
@@ -37,11 +38,13 @@
 import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
 import org.jboss.cache.util.TestingUtil;
 import org.testng.annotations.Test;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.util.HashSet;
 import java.util.Set;
 
- at Test(groups = "functional")
+ at Test(groups = "functional", sequential = true)
 public class ReplAndStateTransferWithPassivationTest extends AbstractCacheLoaderTestBase
 {
    public void testStateTransferOfPassivatedState() throws Exception
@@ -51,7 +54,32 @@
 
    public void testStateTransferOfPassivatedStatePessimistic() throws Exception
    {
-      doTest(NodeLockingScheme.PESSIMISTIC, false);
+//      doTest(NodeLockingScheme.PESSIMISTIC, false);
+      Cache cache1=null, cache2=null;
+      Fqn A = Fqn.fromRelativeElements(Fqn.ROOT, "a"), B = Fqn.fromRelativeElements(Fqn.ROOT, "b"), C = Fqn.fromRelativeElements(Fqn.ROOT, "c");
+      try
+      {
+         Set<Object> nameSet = new HashSet<Object>();
+         nameSet.add(A.getLastElement());
+         nameSet.add(B.getLastElement());
+         nameSet.add(C.getLastElement());
+
+         cache1 = new UnitTestCacheFactory().createCache(buildConf(NodeLockingScheme.PESSIMISTIC, "cache1", false, false, true));
+
+         cache1.put(A, "k", "v");
+         cache1.put(B, "k", "v");
+         cache1.put(C, "k", "v");
+         assert cache1.getNode(Fqn.ROOT).getChildrenNames().equals(nameSet);
+
+         cache1.evict(A);
+
+         cache2 = new UnitTestCacheFactory().createCache(buildConf(NodeLockingScheme.PESSIMISTIC, "cache2", false, false, true));
+         assert cache2.getRoot().getChildrenNames().equals(nameSet) : "Expecting " + nameSet + " but got " + cache2.getRoot().getChildrenNames();
+      }
+      finally
+      {
+         TestingUtil.killCaches(cache1, cache2);
+      }
    }
 
    public void testStateTransferOfPassivatedPartialState() throws Exception
@@ -166,7 +194,7 @@
       }
    }
 
-   private Configuration buildConf(NodeLockingScheme nls, String n, boolean regionbased, boolean useBR, boolean brSearchSubtrees) throws Exception
+   private Configuration buildConf(NodeLockingScheme nls, String name, boolean regionbased, boolean useBR, boolean brSearchSubtrees) throws Exception
    {
       Configuration c = new Configuration();
       if (regionbased)
@@ -176,7 +204,7 @@
       }
       c.setCacheMode(CacheMode.REPL_SYNC);
       c.setNodeLockingScheme(nls);
-      CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "bin="+n, false, true, false);
+      CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "bin="+name, false, true, false);
       clc.setPassivation(true);
       c.setCacheLoaderConfig(clc);
       if (useBR)




More information about the jbosscache-commits mailing list