[jbosscache-commits] JBoss Cache SVN: r8588 - in core/support-branches/3.2.11.GA_JBCACHE-1635/src: test/java/org/jboss/cache/eviction and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Mon Mar 31 01:44:59 EDT 2014
Author: dereed
Date: 2014-03-31 01:44:59 -0400 (Mon, 31 Mar 2014)
New Revision: 8588
Added:
core/support-branches/3.2.11.GA_JBCACHE-1635/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java
Modified:
core/support-branches/3.2.11.GA_JBCACHE-1635/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java
Log:
[JBPAPP-11069] Backport JBCACHE-1635
Modified: core/support-branches/3.2.11.GA_JBCACHE-1635/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java
===================================================================
--- core/support-branches/3.2.11.GA_JBCACHE-1635/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java 2014-03-31 05:41:07 UTC (rev 8587)
+++ core/support-branches/3.2.11.GA_JBCACHE-1635/src/main/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicy.java 2014-03-31 05:44:59 UTC (rev 8588)
@@ -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/support-branches/3.2.11.GA_JBCACHE-1635/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java
===================================================================
--- core/support-branches/3.2.11.GA_JBCACHE-1635/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java (rev 0)
+++ core/support-branches/3.2.11.GA_JBCACHE-1635/src/test/java/org/jboss/cache/eviction/RemoveOnEvictActionPolicyTest.java 2014-03-31 05:44:59 UTC (rev 8588)
@@ -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
+ */
+ at 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));
+ }
+}
More information about the jbosscache-commits
mailing list