[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/buddyreplication ...
Manik Surtani
manik at jboss.org
Sun May 27 11:21:54 EDT 2007
User: msurtani
Date: 07/05/27 11:21:54
Modified: tests/functional/org/jboss/cache/buddyreplication
BuddyReplicationFailoverTest.java
BuddyReplicationContentTest.java
BuddyAssignmentStateTransferTest.java
BuddyReplicationTestsBase.java
Log:
Fixed more BR brittleness
Revision Changes Path
1.23 +16 -18 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationFailoverTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- BuddyReplicationFailoverTest.java 25 May 2007 16:34:51 -0000 1.22
+++ BuddyReplicationFailoverTest.java 27 May 2007 15:21:54 -0000 1.23
@@ -79,16 +79,16 @@
dumpCacheContents(caches);
// now lets test the eviction part of gravitation
- String newBackupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyManager.getGroupNameFromAddress(caches[2].getLocalAddress()) + fqn;
+ Fqn newBackupFqn = BuddyManager.getBackupFqn(caches[2].getLocalAddress(), fqn);
// use exists instead of get() to prevent going up the interceptor stack
if (!killOwner) assertTrue("Should be false", !caches[0].exists(fqn));
assertTrue("Should be false", !caches[1].exists(fqn));
// the old backup should no longer exist
- if (!killOwner) assertNull("Should be null", caches[0].get(backupFqn, key));
- assertNull("Should be null", caches[1].get(backupFqn, key));
- assertNull("Should be null", caches[2].get(backupFqn, key));
+ if (!killOwner) assertFalse("Should be null", caches[0].exists(backupFqn));
+ assertFalse("Should be null", caches[1].exists(backupFqn));
+ assertFalse("Should be null", caches[2].exists(backupFqn));
// and the backup should now exist in caches[2]'s buddy which is caches[0]
if (killOwner)
@@ -98,9 +98,9 @@
else
{
assertEquals("Value should exist", value, caches[0].get(newBackupFqn, key));
- assertNull("Should be null", caches[1].get(newBackupFqn, key));
+ assertFalse("Should be null", caches[1].exists(newBackupFqn));
}
- assertNull("Should be null", caches[2].get(newBackupFqn, key));
+ assertFalse("Should be null", caches[2].exists(newBackupFqn));
}
public void testDataReplicationSuppression() throws Exception
@@ -108,23 +108,21 @@
caches = createCaches(3, false, false, optimisticLocks);
Fqn fqn = Fqn.fromString("/test");
- Fqn backupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress())
- + "/test");
+ Fqn backupFqn = BuddyManager.getBackupFqn(caches[0].getLocalAddress(), fqn);
caches[0].put(fqn, key, value);
dumpCacheContents(caches);
assertEquals("value", caches[0].get(fqn, key));
- assertNull(caches[0].get(backupFqn, key));
+ assertFalse(caches[0].exists(backupFqn));
assertEquals("value", caches[1].get(backupFqn, key));
- assertNull(caches[1].get(fqn, key));
- assertNull(caches[2].get(fqn, key));
- assertNull(caches[2].get(backupFqn, key));
+ assertFalse(caches[1].exists(fqn));
+ assertFalse(caches[2].exists(fqn));
+ assertFalse(caches[2].exists(backupFqn));
assertNoLocks(caches);
- backupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyManager.getGroupNameFromAddress(caches[1].getLocalAddress())
- + "/test");
+ backupFqn = BuddyManager.getBackupFqn(caches[1].getLocalAddress(), fqn);
System.out.println("*** Calling get() on cache[1] with force option");
@@ -133,11 +131,11 @@
dumpCacheContents(caches);
- assertNull(caches[1].get(backupFqn, key));
+ assertFalse(caches[1].exists(backupFqn));
assertEquals("value", caches[2].get(backupFqn, key));
- assertNull(caches[2].get(fqn, key));
- assertNull(caches[0].get(fqn, key));
- assertNull(caches[0].get(backupFqn, key));
+ assertFalse(caches[2].exists(fqn));
+ assertFalse(caches[0].exists(fqn));
+ assertFalse(caches[0].exists(backupFqn));
}
public void testSubtreeRetrieval() throws Exception
1.17 +16 -11 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationContentTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- BuddyReplicationContentTest.java 2 Mar 2007 12:07:44 -0000 1.16
+++ BuddyReplicationContentTest.java 27 May 2007 15:21:54 -0000 1.17
@@ -9,6 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheImpl;
+import org.jboss.cache.Fqn;
import org.jboss.cache.misc.TestingUtil;
/**
@@ -166,8 +167,8 @@
try
{
- String fqn = "/test";
- String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyManager.getGroupNameFromAddress(caches[1].getLocalAddress()) + fqn;
+ Fqn fqn = Fqn.fromString("/test");
+ Fqn backupFqn = BuddyManager.getBackupFqn(caches[1].getLocalAddress(), fqn);
assertNoStaleLocks(caches);
@@ -178,7 +179,7 @@
// this should be in neither of the other caches' "main" trees
assertEquals(value, caches[1].get(fqn, key));
- assertNull("Should be null", caches[0].get(fqn, key));
+ assertFalse("Should be false", caches[0].exists(fqn));
// check the backup trees
assertEquals("Buddy should have data in backup tree", value, caches[0].get(backupFqn, key));
@@ -189,7 +190,11 @@
cache2 = createCache(1, null);
// allow this cache a few msecs to join
- TestingUtil.sleepThread(500);
+ TestingUtil.blockUntilViewsReceived(3000, caches[0], caches[1], cache2);
+
+ TestingUtil.sleepThread(2000); // allow buddy group reorg
+
+ dumpCacheContents(caches[0], caches[1], cache2);
// now caches[1]'s buddy should be cache2, not cache[0]
assertIsBuddy(caches[1], cache2, true);
@@ -199,7 +204,7 @@
assertIsBuddy(cache2, caches[0], true);
// so now the backup data we saw on cache[0] should have been removed.
- assertNull("This backup data should have been removed", caches[0].get(backupFqn, key));
+ assertFalse("This backup data should have been removed", caches[0].exists(backupFqn));
// while cache2 should now posess this backup (due to a state transfer)
assertEquals("Backup state should have been transferred to this new cache instance", value, cache2.get(backupFqn, key));
@@ -208,14 +213,14 @@
assertNoStaleLocks(caches);
- assertNull("Should be null", caches[0].get(fqn, key));
- assertNull("Should be null", caches[1].get(fqn, key));
- assertNull("Should be null", cache2.get(fqn, key));
+ assertFalse("Should be null", caches[0].exists(fqn));
+ assertFalse("Should be null", caches[1].exists(fqn));
+ assertFalse("Should be null", cache2.exists(fqn));
// check the backup trees
- assertNull("Should be null", caches[0].get(backupFqn, key));
- assertNull("Should be null", caches[1].get(backupFqn, key));
- assertNull("Should be null", cache2.get(backupFqn, key));
+ assertFalse("Should be null", caches[0].exists(backupFqn));
+ assertFalse("Should be null", caches[1].exists(backupFqn));
+ assertFalse("Should be null", cache2.exists(backupFqn));
assertNoStaleLocks(caches);
1.13 +3 -12 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyAssignmentStateTransferTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- BuddyAssignmentStateTransferTest.java 2 Mar 2007 12:07:44 -0000 1.12
+++ BuddyAssignmentStateTransferTest.java 27 May 2007 15:21:54 -0000 1.13
@@ -10,8 +10,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.misc.TestingUtil;
-import java.io.File;
-
/**
* Tests how groups are formed and disbanded
*
@@ -67,14 +65,9 @@
public void testPersistentStateTransfer() throws Exception
{
- String tmpLoc = System.getProperty("java.io.tmpdir", "/tmp");
- tmpLoc += File.separator + "BuddyReplicationTestsBase-";
- String tmpLoc0 = tmpLoc + 0;
- String tmpLoc1 = tmpLoc + 1;
caches = new CacheImpl[2];
-
- caches[0] = createCacheWithCacheLoader(tmpLoc0, false, false, false, true, false);
+ caches[0] = createCacheWithCacheLoader(false, false, false, true, false);
caches[0].getConfiguration().setFetchInMemoryState(false);
caches[0].start();
@@ -82,7 +75,7 @@
Fqn main = Fqn.fromString("/a/b/c");
caches[0].put(main, "name", "Joe");
- caches[1] = createCacheWithCacheLoader(tmpLoc1, false, false, false, true, false);
+ caches[1] = createCacheWithCacheLoader(false, false, false, true, false);
caches[1].getConfiguration().setFetchInMemoryState(false);
caches[1].start();
@@ -90,9 +83,7 @@
TestingUtil.blockUntilViewsReceived(caches, VIEW_BLOCK_TIMEOUT);
TestingUtil.sleepThread(getSleepTimeout());
- Fqn group = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
- BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress()));
- Fqn test = new Fqn(group, main);
+ Fqn test = BuddyManager.getBackupFqn(caches[0].getLocalAddress(), main);
assertFalse("/a/b/c shld not be bin memory", caches[1].exists(test));
assertNotNull("/a/b/c shld be in CL", caches[1].getCacheLoader().get(test));
1.48 +4 -4 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationTestsBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- BuddyReplicationTestsBase.java 25 May 2007 16:34:51 -0000 1.47
+++ BuddyReplicationTestsBase.java 27 May 2007 15:21:54 -0000 1.48
@@ -200,7 +200,7 @@
CacheImpl[] caches = new CacheImpl[numCaches];
for (int i = 0; i < numCaches; i++)
{
- caches[i] = createCacheWithCacheLoader((tmpLoc + i), useDataGravitation, removeOnFind, passivation, fetchPersistent, true);
+ caches[i] = createCacheWithCacheLoader(useDataGravitation, removeOnFind, passivation, fetchPersistent, true);
}
// allow some time for the caches to start up and discover each other
@@ -209,7 +209,7 @@
return caches;
}
- protected CacheImpl createCacheWithCacheLoader(String location, boolean useDataGravitation, boolean removeOnFind, boolean passivation, boolean fetchPersistent, boolean start) throws Exception
+ protected CacheImpl createCacheWithCacheLoader(boolean useDataGravitation, boolean removeOnFind, boolean passivation, boolean fetchPersistent, boolean start) throws Exception
{
CacheImpl cache = createCache(1, null, useDataGravitation, removeOnFind, false);
@@ -219,7 +219,7 @@
"<cacheloader>\n" +
"<class>org.jboss.cache.loader.DummyInMemoryCacheLoader</class>\n" +
- "<properties>location=" + (location) + "</properties>\n" +
+// "<properties>location=" + (location) + "</properties>\n" +
"<async>false</async>\n" +
"<shared>false</shared>\n" +
"<fetchPersistentState>" + fetchPersistent + "</fetchPersistentState>\n" +
@@ -301,7 +301,7 @@
assertTrue(buddyLocalAddress + " should be a buddy to " + group.getGroupName(), group.getBuddies().contains(buddyLocalAddress));
}
- protected void dumpCacheContents(CacheImpl[] caches)
+ protected void dumpCacheContents(CacheImpl... caches)
{
System.out.println("**** START: Cache Contents ****");
for (int i = 0; i < caches.length; i++)
More information about the jboss-cvs-commits
mailing list