Author: dereed
Date: 2014-03-31 01:20:14 -0400 (Mon, 31 Mar 2014)
New Revision: 8585
Added:
core/trunk/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java
Log:
[JBCACHE-1635] RemoveOnEvictActionPolicy should return true if node doesn't exist
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java 2014-02-28
02:47:41 UTC (rev 8584)
+++
core/trunk/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java 2014-03-31
05:20:14 UTC (rev 8585)
@@ -52,7 +52,8 @@
try
{
- return cache.removeNode(fqn);
+ cache.removeNode(fqn);
+ return true;
}
catch (Exception e)
{
@@ -60,4 +61,4 @@
return false;
}
}
-}
\ No newline at end of file
+}
Added:
core/trunk/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java 2014-03-31
05:20:14 UTC (rev 8585)
@@ -0,0 +1,62 @@
+package org.jboss.cache.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.testng.annotations.AfterMethod;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests for RemoveOnEvictActionPolicy
+ *
+ * @author Dennis Reed
+ */
+@Test(groups = "functional", testName =
"eviction.RemoveOnEvictActionPolicyTest")
+public class RemoveOnEvictActionPolicyTest
+{
+ RemoveOnEvictActionPolicy action;
+ Cache cache;
+ Log log = LogFactory.getLog(RemoveOnEvictActionPolicyTest.class);
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ cache = new DefaultCacheFactory().createCache();
+ action = new RemoveOnEvictActionPolicy();
+ action.setCache(cache);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ cache.stop();
+ cache.destroy();
+ cache = null;
+ action = null;
+ }
+
+ /**
+ * Test basic operation
+ */
+ public void testEvict() throws EvictionException
+ {
+ Fqn fqn = Fqn.fromString("/a/b/c");
+
+ cache.put(fqn, "key", "dummy" );
+ assertTrue("Evict should succeed", action.evict(fqn));
+ }
+
+ /**
+ * Test evict where node has already been removed. JBCACHE-1635
+ */
+ public void testEvictWithNoNode() throws EvictionException
+ {
+ Fqn fqn = Fqn.fromString("/a/b/c");
+
+ assertTrue("Evict should succeed", action.evict(fqn));
+ }
+}
Property changes on:
core/trunk/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java
___________________________________________________________________
Added: svn:executable
+ *
Show replies by date