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

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Feb 27 15:23:40 EST 2008


Author: bstansberry at jboss.com
Date: 2008-02-27 15:23:40 -0500 (Wed, 27 Feb 2008)
New Revision: 5377

Modified:
   core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
Log:
[JBCACHE-1298] Test if removal of non-existent node leaves invalid tombstone on remote nodes

Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java	2008-02-27 17:37:38 UTC (rev 5376)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java	2008-02-27 20:23:40 UTC (rev 5377)
@@ -17,8 +17,10 @@
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.optimistic.DefaultDataVersion;
 import org.jboss.cache.xml.XmlHelper;
 import static org.testng.AssertJUnit.*;
+
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
@@ -760,6 +762,11 @@
       deleteNonExistentTest(false);
    }
    
+   /**
+    * Test for JBCACHE-1297
+    * 
+    * @throws Exception
+    */
    public void testDeleteNonExistentOptimistic() throws Exception
    {
       deleteNonExistentTest(true);
@@ -807,7 +814,58 @@
       assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");      
       assertNull("Should be null", cache2.getNode(fqn));      
    }
+   
+   /**
+    * Test for JBCACHE-1298.
+    * 
+    * @throws Exception
+    */
+   public void testAddOfDeletedNonExistent() throws Exception
+   {
+      List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
+      caches.add(createUnstartedCache(true));
+      caches.add(createUnstartedCache(true));
+      cache1 = caches.get(0);
+      cache2 = caches.get(1);
 
+      cache1.start();
+      cache2.start();
+
+      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 5000);
+
+      Fqn fqn = Fqn.fromString("/a/b");
+
+      assertNull("Should be null", cache1.getNode(fqn));
+      assertNull("Should be null", cache2.getNode(fqn));
+      
+      // OK, here's the real test
+      TransactionManager tm = cache2.getTransactionManager();
+      tm.begin();
+      try
+      {
+         // Remove a node that doesn't exist in cache2
+         cache2.removeNode(fqn);
+         tm.commit();
+      }
+      catch (Exception e)
+      {
+         String msg = "Unable to remove non-existent node " + fqn;
+         log.error(msg, e);
+         fail(msg + " -- " + e);
+      }
+      
+      // Actually, it shouldn't have been invalidated, should be null
+      // But, this assertion will pass if it is null, and we want
+      assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");      
+      assertNull("Should be null", cache2.getNode(fqn));  
+
+      cache1.getInvocationContext().getOptionOverrides().setDataVersion(new DefaultDataVersion());
+      cache1.put(fqn, "key", "value");
+      
+      assertEquals("value", cache1.getNode(fqn).get("key"));
+      assertHasBeenInvalidated(cache2.getNode(fqn), "Should have been invalidated");    
+   }
+
    protected CacheSPI<Object, Object> createUnstartedCache(boolean optimistic) throws Exception
    {
       CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(false);




More information about the jbosscache-commits mailing list