Author: bstansberry(a)jboss.com
Date: 2008-02-27 12:37:38 -0500 (Wed, 27 Feb 2008)
New Revision: 5376
Modified:
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
Log:
[JBCACHE-1297] Add test for invalidation of locally non-existent Fqns
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
15:52:37 UTC (rev 5375)
+++
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-02-27
17:37:38 UTC (rev 5376)
@@ -754,7 +754,60 @@
n = caches.get(0).getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
}
+
+ public void testDeleteNonExistentPessimistic() throws Exception
+ {
+ deleteNonExistentTest(false);
+ }
+
+ public void testDeleteNonExistentOptimistic() throws Exception
+ {
+ deleteNonExistentTest(true);
+ }
+
+ private void deleteNonExistentTest(boolean optimistic) throws Exception
+ {
+ List<CacheSPI<Object, Object>> caches = new
ArrayList<CacheSPI<Object, Object>>();
+ caches.add(createUnstartedCache(optimistic));
+ caches.add(createUnstartedCache(optimistic));
+ 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));
+
+ cache1.putForExternalRead(fqn, "key", "value");
+
+ assertEquals("value",cache1.getNode(fqn).get("key"));
+ 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);
+ }
+
+ assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been
invalidated");
+ assertNull("Should be null", cache2.getNode(fqn));
+ }
+
protected CacheSPI<Object, Object> createUnstartedCache(boolean optimistic)
throws Exception
{
CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(false);
Show replies by date