[jbosscache-commits] JBoss Cache SVN: r7495 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Sun Jan 18 10:31:28 EST 2009
Author: mircea.markus
Date: 2009-01-18 10:31:27 -0500 (Sun, 18 Jan 2009)
New Revision: 7495
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
Log:
removed test as it was doing wrong assumptions
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java 2009-01-16 17:23:19 UTC (rev 7494)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java 2009-01-18 15:31:27 UTC (rev 7495)
@@ -9,7 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -18,6 +17,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
/**
* Tests basic group membership semantics
@@ -38,7 +38,6 @@
public void test2CachesWithPoolNames() throws Exception
{
- log.error("Running test2CachesWithPoolNames");
List<CacheSPI<Object, Object>> caches = createCaches(2, true);
cachesTL.set(caches);
@@ -48,87 +47,4 @@
assertEquals("A", groupMap.get(caches.get(0).getLocalAddress()));
assertEquals("B", groupMap.get(caches.get(1).getLocalAddress()));
}
-
- public void testConcurrency() throws Exception
- {
- int numCaches = 4;
- List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(4);
- cachesTL.set(caches);
- CountDownLatch latch = new CountDownLatch(1);
- CacheStarter[] starters = new CacheStarter[numCaches];
-
- for (int i = 0; i < numCaches; i++)
- {
- caches.add(createCache(1, new String(new char[]{(char) ('A' + i)}), false, false));
- starters[i] = new CacheStarter("CacheStarter-" + i, latch, caches.get(i));
- starters[i].start();
- }
-
- // now have the lot start simultaneously
- latch.countDown();
-
- // allow a generous sleep time
- TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 60000);
-
-
- long timeout = System.currentTimeMillis() + 5000 * numCaches;
- while (System.currentTimeMillis() < timeout)
- {
- boolean allPoolNameBroadcasted = true;
- for (int i = 0; i < numCaches; i++)
- {
- boolean receivedFromAll = caches.get(i).getBuddyManager().buddyPool.size() == numCaches;
- allPoolNameBroadcasted &= receivedFromAll;
- }
- if (allPoolNameBroadcasted)
- {
- break;
- }
- if (System.currentTimeMillis() >= timeout)
- {
- log.error("********* pool membership was not brodcasted in " + (timeout - System.currentTimeMillis()) + " millis!");
-
- assert false : "pool membership was not brodcasted in " + timeout + " millis!";
- }
- Thread.sleep(50);
- }
-
- //and now look at the state of things.
- Map map = caches.get(0).getBuddyManager().buddyPool;
- for (int i = 0; i < numCaches; i++)
- {
- if (caches.get(i) != null)
- assertEquals("Failed on cache " + i + "(" + caches.get(i).getLocalAddress() + ")", new String(new char[]{(char) ('A' + i)}), map.get(caches.get(i).getLocalAddress()));
- }
-
- checkConsistentPoolState(caches);
- }
-
- public class CacheStarter extends Thread
- {
- private CountDownLatch latch;
- private CacheSPI cache;
-
- public CacheStarter(String name, CountDownLatch latch, CacheSPI cache)
- {
- super(name);
- this.latch = latch;
- this.cache = cache;
- }
-
- public void run()
- {
- try
- {
- latch.await();
- cache.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- log.error(e);
- }
- }
- }
-
}
More information about the jbosscache-commits
mailing list