[jbosscache-commits] JBoss Cache SVN: r7460 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Jan 14 06:13:22 EST 2009
Author: mircea.markus
Date: 2009-01-14 06:13:22 -0500 (Wed, 14 Jan 2009)
New Revision: 7460
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesNoBuddyPoolTest.java
Log:
don't rely on method execution order
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesNoBuddyPoolTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesNoBuddyPoolTest.java 2009-01-14 00:48:40 UTC (rev 7459)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy2NodesNoBuddyPoolTest.java 2009-01-14 11:13:22 UTC (rev 7460)
@@ -2,6 +2,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.Cache;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.CachePrinter;
@@ -15,7 +16,7 @@
/**
* @author Mircea.Markus at jboss.com
*/
- at Test(groups = "functional", sequential = true, testName = "buddyreplication.Buddy2NodesNoBuddyPoolTest")
+ at Test(groups = "functional", testName = "buddyreplication.Buddy2NodesNoBuddyPoolTest")
public class Buddy2NodesNoBuddyPoolTest extends AbstractNodeBasedBuddyTest
{
@BeforeClass
@@ -24,6 +25,20 @@
caches = createCaches(2, false);
}
+ @AfterMethod
+ @Override
+ public void tearDown() throws Exception
+ {
+ if (caches.get(2) != null)
+ {
+ Cache cache = caches.get(2);
+ caches.remove(2);
+ cache.stop();
+ cache.destroy();
+ }
+ super.tearDown();
+ }
+
public void testAddingNewCaches() throws Exception
{
// get some data in there.
@@ -72,72 +87,64 @@
public void testBuddyJoin() throws Exception
{
- CacheSPI<Object, Object> cache2 = null;
String key = "key";
String value = "value";
- try
- {
- Fqn fqn = Fqn.fromString("/test");
- Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
+ Fqn fqn = Fqn.fromString("/test");
+ Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
- assertNoStaleLocks(caches);
+ assertNoStaleLocks(caches);
- // put something in cache 1
- caches.get(1).put(fqn, key, value);
+ // put something in cache 1
+ caches.get(1).put(fqn, key, value);
- assertNoStaleLocks(caches);
+ assertNoStaleLocks(caches);
- // this should be in neither of the other cachePool' "main" trees
- assertEquals(value, caches.get(1).get(fqn, key));
- assertFalse("Should be false", caches.get(0).exists(fqn));
+ // this should be in neither of the other cachePool' "main" trees
+ assertEquals(value, caches.get(1).get(fqn, key));
+ assertFalse("Should be false", caches.get(0).exists(fqn));
- // check the backup trees
- assertEquals("Buddy should have data in backup tree", value, caches.get(0).get(backupFqn, key));
+ // check the backup trees
+ assertEquals("Buddy should have data in backup tree", value, caches.get(0).get(backupFqn, key));
- assertNoStaleLocks(caches);
+ assertNoStaleLocks(caches);
- // now add a new cache to the cluster
- cache2 = createCache(1, null);
+ // now add a new cache to the cluster
+ caches.add(createCache(1, null));
- // allow this cache a few msecs to join
- TestingUtil.blockUntilViewsReceived(3000, caches.get(0), caches.get(1), cache2);
+ // allow this cache a few msecs to join
+ TestingUtil.blockUntilViewsReceived(3000, caches.get(0), caches.get(1), caches.get(2));
- TestingUtil.sleepThread(2000); // allow buddy group reorg
+ TestingUtil.sleepThread(2000); // allow buddy group reorg
- List<CacheSPI<Object, Object>> dump = new ArrayList<CacheSPI<Object, Object>>(caches);
- dump.add(cache2);
+ List<CacheSPI<Object, Object>> dump = new ArrayList<CacheSPI<Object, Object>>(caches);
+ dump.add(caches.get(2));
- // now cachePool.get(1)'s buddy should be cache2, not cache[0]
- assertIsBuddy(caches.get(1), cache2, true);
- // this should still be the same
- assertIsBuddy(caches.get(0), caches.get(1), true);
- // and cache2's buddy should be cache[0]
- assertIsBuddy(cache2, caches.get(0), true);
+ // now cachePool.get(1)'s buddy should be cache2, not cache[0]
+ assertIsBuddy(caches.get(1), caches.get(2), true);
+ // this should still be the same
+ assertIsBuddy(caches.get(0), caches.get(1), true);
+ // and cache2's buddy should be cache[0]
+ assertIsBuddy(caches.get(2), caches.get(0), true);
- // so now the backup data we saw on cache[0] should have been removed.
- assertFalse("This backup data should have been removed", caches.get(0).exists(backupFqn));
+ // so now the backup data we saw on cache[0] should have been removed.
+ assertFalse("This backup data should have been removed", caches.get(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));
+ // 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, caches.get(2).get(backupFqn, key));
- caches.get(1).removeNode(fqn);
- assertNoStaleLocks(caches);
+ caches.get(1).removeNode(fqn);
+ assertNoStaleLocks(caches);
- assertFalse("Should be null", caches.get(0).exists(fqn));
- assertFalse("Should be null", caches.get(1).exists(fqn));
- assertFalse("Should be null", cache2.exists(fqn));
+ assertFalse("Should be null", caches.get(0).exists(fqn));
+ assertFalse("Should be null", caches.get(1).exists(fqn));
+ assertFalse("Should be null", caches.get(2).exists(fqn));
- // check the backup trees
- assertFalse("Should be null", caches.get(0).exists(backupFqn));
- assertFalse("Should be null", caches.get(1).exists(backupFqn));
- assertFalse("Should be null", cache2.exists(backupFqn));
- assertNoStaleLocks(caches);
- }
- finally
- {
- if (cache2 != null) cache2.stop();
- }
+ // check the backup trees
+ assertFalse("Should be null", caches.get(0).exists(backupFqn));
+ assertFalse("Should be null", caches.get(1).exists(backupFqn));
+ assertFalse("Should be null", caches.get(2).exists(backupFqn));
+ assertNoStaleLocks(caches);
}
}
More information about the jbosscache-commits
mailing list