Author: mircea.markus
Date: 2008-05-29 03:42:12 -0400 (Thu, 29 May 2008)
New Revision: 5908
Modified:
core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java
Log:
JBCACHE-1338 - migrated to the new notification mechanism
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java 2008-05-29
07:32:14 UTC (rev 5907)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/AsyncReplTest.java 2008-05-29
07:42:12 UTC (rev 5908)
@@ -13,6 +13,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.ReplicationListener;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import static org.testng.AssertJUnit.*;
@@ -32,15 +33,18 @@
public class AsyncReplTest
{
private CacheSPI<Object, Object> cache1, cache2;
+ private ReplicationListener replListener1, replListener2;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
log("creating cache1");
cache1 = createCache("CacheGroup");
+ replListener1 = new ReplicationListener(cache1);
log("creating cache2");
cache2 = createCache("CacheGroup");
+ replListener2 = new ReplicationListener(cache2);
}
@@ -96,22 +100,24 @@
Fqn fqn = Fqn.fromString("/a");
String key = "key";
+ replListener2.expectAny();
cache1.put(fqn, key, "value1");
// allow for replication
- TestingUtil.sleepThread((long) 500);
+ replListener2.waitForReplicationToOccur(500);
assertEquals("value1", cache1.get(fqn, key));
assertEquals("value1", cache2.get(fqn, key));
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
+ replListener2.expectAny();
cache1.put(fqn, key, "value2");
assertEquals("value2", cache1.get(fqn, key));
assertEquals("value1", cache2.get(fqn, key));
mgr.commit();
- TestingUtil.sleepThread((long) 500);
+ replListener2.waitForReplicationToOccur(500);
assertEquals("value2", cache1.get(fqn, key));
assertEquals("value2", cache2.get(fqn, key));
@@ -123,8 +129,6 @@
mgr.rollback();
- TestingUtil.sleepThread((long) 500);
-
assertEquals("value2", cache1.get(fqn, key));
assertEquals("value2", cache2.get(fqn, key));
}
@@ -136,10 +140,11 @@
{
cache3 = createCache("DifferentGroup");
cache4 = createCache("DifferentGroup");
+ replListener2.expectAny();
cache1.put("/a/b/c", "age", 38);
// because we use async repl, modfication may not yet have been propagated to
cache2, so
// we have to wait a little
- TestingUtil.sleepThread((long) 1000);
+ replListener2.waitForReplicationToOccur(500);
assertNull("Should not have replicated",
cache3.get("/a/b/c", "age"));
}
catch (Exception e)