[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/eviction ...
Brian Stansberry
brian.stansberry at jboss.com
Thu Dec 21 16:19:42 EST 2006
User: bstansberry
Date: 06/12/21 16:19:42
Modified: tests/functional/org/jboss/cache/eviction Tag:
Branch_JBossCache_1_4_0
StateTransferIntegrationTest.java
Log:
[JBCACHE-913] Add a test that eviction actually occurs.
Revision Changes Path
No revision
No revision
1.1.2.2 +36 -2 JBossCache/tests/functional/org/jboss/cache/eviction/StateTransferIntegrationTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StateTransferIntegrationTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/StateTransferIntegrationTest.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- StateTransferIntegrationTest.java 21 Dec 2006 04:40:07 -0000 1.1.2.1
+++ StateTransferIntegrationTest.java 21 Dec 2006 21:19:42 -0000 1.1.2.2
@@ -22,9 +22,12 @@
package org.jboss.cache.eviction;
+import java.util.Set;
+
import org.jboss.cache.Fqn;
import org.jboss.cache.PropertyConfigurator;
import org.jboss.cache.TreeCache;
+import org.jboss.cache.misc.TestingUtil;
import junit.framework.TestCase;
@@ -56,7 +59,38 @@
RegionManager erm = cache2.getEvictionRegionManager();
Region region = erm.getRegion(Fqn.ROOT);
- // We expect events for ROOT , /a, /a/b and /a/b/c
- assertEquals("Saw the expected number of node events", 4, region.nodeEventQueueSize());
+ // 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());
}
}
More information about the jboss-cvs-commits
mailing list