Author: manik.surtani(a)jboss.com
Date: 2008-01-04 14:23:10 -0500 (Fri, 04 Jan 2008)
New Revision: 4995
Added:
core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveNodeOptimisticTest.java
core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveNodeTest.java
Log:
Added tests for JBCACHE-1256
Added: core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveNodeOptimisticTest.java
===================================================================
--- core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveNodeOptimisticTest.java
(rev 0)
+++
core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveNodeOptimisticTest.java 2008-01-04
19:23:10 UTC (rev 4995)
@@ -0,0 +1,9 @@
+package org.jboss.cache;
+
+public class RemoveNodeOptimisticTest extends RemoveNodeTest
+{
+ public RemoveNodeOptimisticTest()
+ {
+ optimistic = true;
+ }
+}
Added: core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveNodeTest.java
===================================================================
--- core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveNodeTest.java
(rev 0)
+++ core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveNodeTest.java 2008-01-04
19:23:10 UTC (rev 4995)
@@ -0,0 +1,54 @@
+package org.jboss.cache;
+
+import junit.framework.TestCase;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * Tests removing deep, nonexistent nodes
+ *
+ * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
+ */
+public class RemoveNodeTest extends TestCase
+{
+ protected boolean optimistic = false;
+ protected TreeCache cache;
+
+ protected void setUp() throws Exception
+ {
+ cache = new TreeCache();
+ if (optimistic) cache.setNodeLockingScheme("OPTIMISTIC");
+
cache.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache.start();
+ }
+
+ protected void tearDown()
+ {
+ cache.stop();
+ }
+
+ public void testPhantomStructuralNodesOnRemove() throws Exception
+ {
+ assert cache.peek(Fqn.fromString("/a/b/c")) == null;
+ cache.remove("/a/b/c");
+ assert cache.peek(Fqn.fromString("/a/b/c")) == null;
+ assert cache.peek(Fqn.fromString("/a/b")) == null;
+ assert cache.peek(Fqn.fromString("/a")) == null;
+
+ System.out.println("Cache: " + cache.printDetails());
+ }
+
+ public void testPhantomStructuralNodesOnRemoveTransactional() throws Exception
+ {
+ TransactionManager tm = cache.getTransactionManager();
+ assert cache.peek(Fqn.fromString("/a/b/c")) == null;
+ tm.begin();
+ cache.remove("/a/b/c");
+ tm.commit();
+ assert cache.peek(Fqn.fromString("/a/b/c")) == null;
+ assert cache.peek(Fqn.fromString("/a/b")) == null;
+ assert cache.peek(Fqn.fromString("/a")) == null;
+
+ System.out.println("Cache: " + cache.printDetails());
+ }
+}
Show replies by date