[jbosscache-commits] JBoss Cache SVN: r5379 - core/trunk/src/test/java/org/jboss/cache/optimistic.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Feb 29 15:20:17 EST 2008


Author: bstansberry at jboss.com
Date: 2008-02-29 15:20:17 -0500 (Fri, 29 Feb 2008)
New Revision: 5379

Modified:
   core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java
Log:
Add a test of removal with a specified version

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java	2008-02-28 18:06:54 UTC (rev 5378)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java	2008-02-29 20:20:17 UTC (rev 5379)
@@ -6,8 +6,13 @@
  */
 package org.jboss.cache.optimistic;
 
+import junit.framework.Assert;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.config.Configuration;
 import static org.testng.AssertJUnit.assertEquals;
@@ -29,6 +34,8 @@
 @Test(groups = "functional")
 public class OptimisticVersioningTest extends AbstractOptimisticTestCase
 {
+   private static final Log log = LogFactory.getLog(OptimisticVersioningTest.class);
+   
    CacheSPI cache1, cache2;
 
    @BeforeMethod(alwaysRun = true)
@@ -123,4 +130,35 @@
 
       assertEquals("Version info should have propagated", v1, v2);
    }
+   
+   public void testRemovalWithSpecifiedVersion() throws Exception
+   {
+      Fqn fqn = Fqn.fromString("/test/node");
+      
+      Node root = cache1.getRoot();
+      cache1.getInvocationContext().getOptionOverrides().setDataVersion(new NonLockingDataVersion());
+      root.addChild(fqn);
+      cache1.getInvocationContext().getOptionOverrides().setDataVersion(new NonLockingDataVersion());
+      cache1.removeNode(fqn);
+      
+      Assert.assertNull(cache1.getRoot().getChild(fqn));
+   }
+   
+   private static class NonLockingDataVersion implements DataVersion {
+
+      /** The serialVersionUID */
+      private static final long serialVersionUID = 1L;
+
+      public boolean newerThan(DataVersion dataVersion) {
+          
+          if (dataVersion instanceof DefaultDataVersion) {
+              log.info("unexpectedly validating against a DefaultDataVersion", new Exception("Just a stack trace"));
+          }
+          else {
+              log.trace("non locking lock check...");
+          }
+          return false;
+      }
+
+  }
 }




More information about the jbosscache-commits mailing list