[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/statetransfer ...
Brian Stansberry
brian.stansberry at jboss.com
Thu Dec 21 18:11:57 EST 2006
User: bstansberry
Date: 06/12/21 18:11:57
Modified: tests/functional/org/jboss/cache/statetransfer Tag:
Branch_JBossCache_1_4_0 VersionedTestBase.java
Log:
Move the JBCACHE-913 tests to the versioned state transfer tests
Revision Changes Path
No revision
No revision
1.6.2.3 +61 -0 JBossCache/tests/functional/org/jboss/cache/statetransfer/VersionedTestBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: VersionedTestBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/VersionedTestBase.java,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -u -b -r1.6.2.2 -r1.6.2.3
--- VersionedTestBase.java 4 Nov 2006 06:16:47 -0000 1.6.2.2
+++ VersionedTestBase.java 21 Dec 2006 23:11:57 -0000 1.6.2.3
@@ -10,9 +10,15 @@
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Random;
+import java.util.Set;
import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.PropertyConfigurator;
+import org.jboss.cache.TreeCache;
import org.jboss.cache.TreeCacheMBean;
+import org.jboss.cache.eviction.Region;
+import org.jboss.cache.eviction.RegionManager;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.misc.TestingUtil;
@@ -611,6 +617,61 @@
}
+ /**
+ * Test for JBCACHE-913
+ *
+ * @throws Exception
+ */
+ public void testEvictionSeesStateTransfer() throws Exception
+ {
+ TreeCache cache1 = new TreeCache();
+ PropertyConfigurator config = new PropertyConfigurator();
+ config.configure(cache1, "META-INF/replSync-eviction-service.xml");
+ cache1.startService();
+
+ cache1.put("/a/b/c", "key", "value");
+
+ TreeCache cache2 = new TreeCache();
+ config.configure(cache2, "META-INF/replSync-eviction-service.xml");
+ cache2.startService();
+
+ RegionManager erm = cache2.getEvictionRegionManager();
+ Region region = erm.getRegion(Fqn.ROOT);
+ // We expect events for /a, /a/b and /a/b/c
+ assertEquals("Saw the expected number of node events", 3, region.nodeEventQueueSize());
+ }
+
+ /**
+ * Further test for JBCACHE-913
+ *
+ * @throws Exception
+ */
+ public void testEvictionAfterStateTransfer() throws Exception
+ {
+ TreeCache cache1 = new TreeCache();
+ PropertyConfigurator config = new PropertyConfigurator();
+ config.configure(cache1, "META-INF/replSync-eviction-service.xml");
+ cache1.startService();
+
+ for (int i = 0; i < 4; i++)
+ cache1.put("/org/jboss/test/data/" + i, "key", "value");
+
+ TreeCache cache2 = new TreeCache();
+ config.configure(cache2, "META-INF/replSync-eviction-service.xml");
+ cache2.startService();
+
+ Set children = cache2.getChildrenNames("/org/jboss/test/data");
+ assertEquals("All children transferred", 4, children.size());
+
+ // Sleep 10.1 secs to let the eviction thread run at least twice,
+ // which will evict all 4 nodes due to their ttl of 4 secs
+ TestingUtil.sleepThread(10500);
+
+ children = cache2.getChildrenNames("/org/jboss/test/data");
+ if (children != null)
+ assertEquals("All children evicted", 0, children.size());
+ }
+
private Object createBen(ClassLoader loader) throws Exception
{
Class addrClazz = loader.loadClass("org.jboss.cache.marshall.Address");
More information about the jboss-cvs-commits
mailing list