Author: manik.surtani(a)jboss.com
Date: 2008-10-28 15:35:49 -0400 (Tue, 28 Oct 2008)
New Revision: 7022
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
Log:
Added partial state tests
Modified:
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java 2008-10-28
19:22:41 UTC (rev 7021)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java 2008-10-28
19:35:49 UTC (rev 7022)
@@ -22,7 +22,10 @@
package org.jboss.cache.passivation;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.Region;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -49,6 +52,57 @@
doTest(NodeLockingScheme.PESSIMISTIC);
}
+ public void testStateTransferOfPassivatedPartialState() throws Exception
+ {
+ doPartialStateTransferTest(NodeLockingScheme.MVCC);
+ }
+
+ public void testStateTransferOfPassivatedPartialStatePessimistic() throws Exception
+ {
+ doPartialStateTransferTest(NodeLockingScheme.PESSIMISTIC);
+ }
+
+
+ private void doPartialStateTransferTest(NodeLockingScheme nls) throws Exception
+ {
+ CacheSPI cache1=null, cache2=null;
+ String subtree = "/SESSIONS";
+ try
+ {
+ Set<Object> nameSet = new HashSet<Object>();
+ nameSet.add("a");
+ nameSet.add("b");
+ nameSet.add("c");
+
+ cache1 = (CacheSPI) new UnitTestCacheFactory().createCache(buildConf(nls,
"cache1", true));
+ cache2 = (CacheSPI) new UnitTestCacheFactory().createCache(buildConf(nls,
"cache2", true));
+
+ Region r1 = cache1.getRegionManager().getRegion(subtree, true);
+ Region r2 = cache2.getRegionManager().getRegion(subtree, true);
+ r1.registerContextClassLoader(getClass().getClassLoader());
+ r2.registerContextClassLoader(getClass().getClassLoader());
+
+ r1.activate();
+
+ cache1.put(subtree + "/a", "k", "v");
+ cache1.put(subtree + "/b", "k", "v");
+ cache1.put(subtree + "/c", "k", "v");
+
+ Node root1 = cache1.getNode(subtree);
+ assert root1.getChildrenNames().equals(nameSet) : "Expecting " +
nameSet + " but got " + root1.getChildrenNames();
+
+ cache1.evict(Fqn.fromString("/a"));
+
+ r2.activate();
+ Node root2 = cache1.getNode(subtree);
+ assert root2.getChildrenNames().equals(nameSet) : "Expecting " +
nameSet + " but got " + root2.getChildrenNames();
+ }
+ finally
+ {
+ TestingUtil.killCaches(cache1, cache2);
+ }
+ }
+
private void doTest(NodeLockingScheme nls) throws Exception
{
Cache cache1=null, cache2=null;
@@ -59,7 +113,7 @@
nameSet.add("b");
nameSet.add("c");
- cache1 = new UnitTestCacheFactory().createCache(buildConf(nls,
"cache1"));
+ cache1 = new UnitTestCacheFactory().createCache(buildConf(nls,
"cache1", false));
cache1.put("/a", "k", "v");
cache1.put("/b", "k", "v");
@@ -68,7 +122,7 @@
cache1.evict(Fqn.fromString("/a"));
- cache2 = new UnitTestCacheFactory().createCache(buildConf(nls,
"cache2"));
+ cache2 = new UnitTestCacheFactory().createCache(buildConf(nls,
"cache2", false));
assert cache2.getRoot().getChildrenNames().equals(nameSet) : "Expecting
" + nameSet + " but got " + cache2.getRoot().getChildrenNames();
}
finally
@@ -77,9 +131,14 @@
}
}
- private Configuration buildConf(NodeLockingScheme nls, String n) throws Exception
+ private Configuration buildConf(NodeLockingScheme nls, String n, boolean regionbased)
throws Exception
{
Configuration c = new Configuration();
+ if (regionbased)
+ {
+ c.setUseRegionBasedMarshalling(true);
+ c.setInactiveOnStartup(true);
+ }
c.setCacheMode(CacheMode.REPL_SYNC);
c.setNodeLockingScheme(nls);
CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "bin="+n, false, true, false);