Author: manik.surtani(a)jboss.com
Date: 2008-01-02 19:31:30 -0500 (Wed, 02 Jan 2008)
New Revision: 4950
Added:
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
Modified:
core/branches/1.4.X/src/org/jboss/cache/TreeCache.java
Log:
Added test and fix for JBCACHE-1241 - do not remove internal fqns when removing root.
Modified: core/branches/1.4.X/src/org/jboss/cache/TreeCache.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/TreeCache.java 2008-01-03 00:17:12 UTC (rev
4949)
+++ core/branches/1.4.X/src/org/jboss/cache/TreeCache.java 2008-01-03 00:31:30 UTC (rev
4950)
@@ -3886,7 +3886,8 @@
{
for (Iterator i = children.iterator(); i.hasNext();)
{
- remove(new Fqn(fqn, i.next()), o);
+ Fqn childFqn = new Fqn(fqn, i.next());
+ if (!internalFqns.contains(childFqn)) remove(childFqn, o);
}
}
}
@@ -3917,7 +3918,8 @@
{
for (Iterator i = children.iterator(); i.hasNext();)
{
- evict(new Fqn(fqn, i.next()));
+ Fqn childFqn = new Fqn(fqn, i.next());
+ if (!internalFqns.contains(childFqn)) evict(childFqn);
}
}
}
Added:
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
===================================================================
---
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
(rev 0)
+++
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java 2008-01-03
00:31:30 UTC (rev 4950)
@@ -0,0 +1,44 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.TreeCache;
+import org.jboss.cache.misc.TestingUtil;
+
+import java.util.ArrayList;
+
+/**
+ * Test added to replicate a found issue - JBCACHE-1241
+ *
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class RemoveRootBuddyTest extends BuddyReplicationTestsBase
+{
+ TreeCache cache1, cache2;
+
+ protected void setUp() throws Exception
+ {
+ cache1 = createCache(false, 1, "myBuddyPoolReplicationGroup", false,
true, true);
+ cache2 = createCache(false, 1, "myBuddyPoolReplicationGroup", false,
true, true);
+
+ TestingUtil.blockUntilViewsReceived(new TreeCache[]{cache1, cache2}, 60000);
+ }
+
+ protected void tearDown()
+ {
+ cache1.stop();
+ cache2.stop();
+ }
+
+ public void testRemoveRootNode() throws Exception
+ {
+ int opCount = 10;
+ for (int i = 0; i < opCount; i++)
+ {
+ String key = String.valueOf(opCount);
+ String value = String.valueOf(opCount);
+ Fqn f = Fqn.fromString("/test" + key);
+ cache1.put(f, key, value);
+ }
+ cache1.remove(Fqn.ROOT);
+ }
+}