Author: manik.surtani(a)jboss.com
Date: 2009-02-09 13:29:38 -0500 (Mon, 09 Feb 2009)
New Revision: 7667
Added:
core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java
Log:
Added new expiry test
Added: core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java
(rev 0)
+++
core/branches/flat/src/test/java/org/horizon/expiry/ReplicatedExpiryTest.java 2009-02-09
18:29:38 UTC (rev 7667)
@@ -0,0 +1,42 @@
+package org.horizon.expiry;
+
+import org.horizon.BaseClusteredTest;
+import org.horizon.Cache;
+import org.horizon.config.Configuration;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+@Test(groups = "functional", sequential = true)
+public class ReplicatedExpiryTest extends BaseClusteredTest {
+
+ Cache c1, c2;
+
+ @BeforeMethod
+ public void setUp() {
+ Configuration cfg = new Configuration();
+ cfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ List<Cache> caches = createClusteredCaches(2, "cache", cfg);
+ c1 = caches.get(0);
+ c2 = caches.get(1);
+ }
+
+ public void testExpiryReplicates() throws InterruptedException {
+ long start = System.currentTimeMillis();
+ long lifespan = 10000;
+ c1.put("k", "v", lifespan, TimeUnit.MILLISECONDS);
+
+ while (System.currentTimeMillis() < start + lifespan + 1000) {
+ if (System.currentTimeMillis() < start + lifespan) {
+ assert c1.get("k").equals("v");
+ assert c2.get("k").equals("v");
+ } else {
+ assert c1.get("k") == null;
+ assert c2.get("k") == null;
+ }
+ Thread.sleep(250);
+ }
+ }
+}
Show replies by date