[jbosscache-commits] JBoss Cache SVN: r4634 - core/trunk/src/test/java/org/jboss/cache/invalidation.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Oct 17 12:00:26 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-10-17 12:00:26 -0400 (Wed, 17 Oct 2007)
New Revision: 4634
Modified:
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
Log:
Add test that recreating removed node works properly
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2007-10-17 15:56:21 UTC (rev 4633)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2007-10-17 16:00:26 UTC (rev 4634)
@@ -468,6 +468,78 @@
checkRemoteNodeIsRemoved(child);
}
}
+
+ public void testPessimisticNodeResurrection() throws Exception {
+ nodeResurrectionTest(false);
+ }
+
+ public void testOptimisticNodeResurrection() throws Exception {
+ nodeResurrectionTest(true);
+ }
+
+ private void nodeResurrectionTest(boolean optimistic) throws Exception
+ {
+ CacheImpl<Object, Object> cache1 = null;
+ CacheImpl<Object, Object> cache2 = null;
+ try
+ {
+ cache1 = createCache(optimistic);
+ cache2 = createCache(optimistic);
+
+ // this fqn is relative, but since it is from the root it may as well be absolute
+ Fqn<String> fqn = Fqn.fromString("/test/fqn1");
+ cache1.put(fqn, "key", "value");
+ assertEquals("value", cache1.get(fqn, "key"));
+ assertEquals(null, cache2.get(fqn, "key"));
+ // Change the value in order to increment the version if Optimistic is used
+ cache1.put(fqn, "key", "newValue");
+ assertEquals("newValue", cache1.get(fqn, "key"));
+ assertEquals(null, cache2.get(fqn, "key"));
+
+ assertEquals(true, cache1.removeNode(fqn));
+ assertEquals(null, cache1.get(fqn, "key"));
+ assertEquals(null, cache2.get(fqn, "key"));
+
+ // Restore locally
+ cache1.put(fqn, "key", "value");
+ assertEquals("value", cache1.get(fqn, "key"));
+ assertEquals(null, cache2.get(fqn, "key"));
+
+ // Repeat, but now restore the node on the remote cache
+ fqn = Fqn.fromString("/test/fqn2");
+ cache1.put(fqn, "key", "value");
+ assertEquals("value", cache1.get(fqn, "key"));
+ assertEquals(null, cache2.get(fqn, "key"));
+ // Change the value in order to increment the version if Optimistic is used
+ cache1.put(fqn, "key", "newValue");
+ assertEquals("newValue", cache1.get(fqn, "key"));
+ assertEquals(null, cache2.get(fqn, "key"));
+
+ assertEquals(true, cache1.removeNode(fqn));
+ assertEquals(null, cache1.get(fqn, "key"));
+ assertEquals(null, cache2.get(fqn, "key"));
+
+ // Restore on remote cache
+ cache2.put(fqn, "key", "value");
+ assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals(null, cache1.get(fqn, "key"));
+ }
+ finally
+ {
+ if (cache1 != null)
+ {
+ cache1.stop();
+ cache1.destroy();
+ }
+ if (cache2 != null)
+ {
+ cache2.stop();
+ cache2.destroy();
+ }
+
+ }
+
+ }
private void dumpVersionInfo(CacheSPI c1, CacheSPI c2, Fqn fqn)
{
More information about the jbosscache-commits
mailing list