[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/invalidation ...
Manik Surtani
msurtani at jboss.com
Wed Nov 29 11:04:40 EST 2006
User: msurtani
Date: 06/11/29 11:04:40
Modified: tests/functional/org/jboss/cache/invalidation Tag:
Branch_JBossCache_1_3_0
InvalidationInterceptorTest.java
Log:
updated to deal with invalidations in a tx
Revision Changes Path
No revision
No revision
1.13.2.1 +33 -0 JBossCache/tests/functional/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InvalidationInterceptorTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/invalidation/InvalidationInterceptorTest.java,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -u -b -r1.13 -r1.13.2.1
--- InvalidationInterceptorTest.java 31 Mar 2006 14:34:18 -0000 1.13
+++ InvalidationInterceptorTest.java 29 Nov 2006 16:04:40 -0000 1.13.2.1
@@ -13,6 +13,7 @@
import junit.textui.TestRunner;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.DataNode;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
import org.jboss.cache.xml.XmlHelper;
@@ -22,6 +23,8 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.io.File;
+import java.util.Map;
+import java.util.Iterator;
/**
* Tests the async interceptor
@@ -152,8 +155,16 @@
TreeCache cache2 = createCache(false);
Fqn fqn = Fqn.fromString("/a/b");
+
+ assertNoNodesMarkedForRemoval(cache1.getRoot());
+ assertNoNodesMarkedForRemoval(cache2.getRoot());
+
cache1.put(fqn, "key", "value");
+ assertNoNodesMarkedForRemoval(cache1.getRoot());
+ assertNoNodesMarkedForRemoval(cache2.getRoot());
+
+
// test that this has NOT replicated, but rather has been invalidated:
Assert.assertEquals("value", cache1.get(fqn, "key"));
Assert.assertNull("Should NOT have replicated!", cache2.get(fqn));
@@ -170,6 +181,10 @@
Assert.assertEquals("value", cache2.get(fqn, "key"));
txm.commit();
+ assertNoNodesMarkedForRemoval(cache1.getRoot());
+ assertNoNodesMarkedForRemoval(cache2.getRoot());
+
+
Assert.assertNull("Should be null", cache1.get(fqn));
Assert.assertEquals("value", cache2.get(fqn, "key"));
@@ -182,6 +197,10 @@
Assert.assertEquals("value2", cache1.get(fqn, "key2"));
txm.commit();
+ assertNoNodesMarkedForRemoval(cache1.getRoot());
+ assertNoNodesMarkedForRemoval(cache2.getRoot());
+
+
Assert.assertEquals("value2", cache1.get(fqn, "key2"));
Assert.assertNull("Should have been invalidated!", cache2.get(fqn));
@@ -194,6 +213,9 @@
Assert.assertEquals("value", cache2.get(fqn, "key"));
txm.rollback();
+ assertNoNodesMarkedForRemoval(cache1.getRoot());
+ assertNoNodesMarkedForRemoval(cache2.getRoot());
+
Assert.assertEquals("value2", cache1.get(fqn, "key2"));
Assert.assertNull("Should not have committed", cache2.get(fqn));
@@ -205,6 +227,17 @@
}
+ private void assertNoNodesMarkedForRemoval(DataNode n)
+ {
+ assertFalse("Node " + n.getFqn() + " contains removal marker!", n.containsKey("__JBOSS_MARKED_FOR_REMOVAL"));
+ Map ch = n.getChildren();
+ if (ch != null && !ch.isEmpty())
+ {
+ Iterator i = ch.values().iterator();
+ while (i.hasNext()) assertNoNodesMarkedForRemoval((DataNode) i.next());
+ }
+ }
+
public void testOptSyncUnableToEvict() throws Exception
{
More information about the jboss-cvs-commits
mailing list