[jbosscache-commits] JBoss Cache SVN: r7889 - core/branches/flat/src/test/java/org/horizon/api.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Mar 9 05:03:54 EDT 2009


Author: manik.surtani at jboss.com
Date: 2009-03-09 05:03:53 -0400 (Mon, 09 Mar 2009)
New Revision: 7889

Modified:
   core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
Log:
Improved test

Modified: core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java	2009-03-09 00:53:29 UTC (rev 7888)
+++ core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java	2009-03-09 09:03:53 UTC (rev 7889)
@@ -4,43 +4,39 @@
 import org.horizon.config.Configuration;
 import org.horizon.config.Configuration.CacheMode;
 import org.horizon.manager.CacheManager;
+import org.horizon.test.MultipleCacheManagersTest;
 import org.horizon.test.TestingUtil;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.util.List;
 
- at Test(groups = "functional", testName = "api.CacheClusterJoinTest")
-public class CacheClusterJoinTest {
+ at Test(groups = "functional", testName = "api.CacheClusterJoinTest", enabled = false)
+public class CacheClusterJoinTest extends MultipleCacheManagersTest {
    Cache cache1, cache2;
    CacheManager cm1, cm2;
    Configuration cfg;
 
-   @BeforeMethod(alwaysRun = true)
-   public void setUp() throws Exception {
-      cm1 = TestingUtil.createClusteredCacheManager();
+   public CacheClusterJoinTest() {
+      cleanup = CleanupPhase.AFTER_METHOD;
+   }
+
+   protected void createCacheManagers() throws Throwable {
+      cm1 = addClusterEnabledCacheManager();
       cfg = new Configuration();
       cfg.setCacheMode(CacheMode.REPL_SYNC);
       cfg.setFetchInMemoryState(false);
       cm1.defineCache("cache", cfg);
    }
 
-   @AfterMethod
-   public void tearDown()
-   {
-      TestingUtil.killCacheManagers(cm1, cm2);
-   }
-
    public void testGetMembers() throws Exception {
       cm1.getCache("cache"); // this will make sure any lazy components are started.
       List memb1 = cm1.getMembers();
-      assert 1 == memb1.size();
+      assert 1 == memb1.size() : "Expected 1 member; was " + memb1;
 
       Object coord = memb1.get(0);
 
-      cm2 = TestingUtil.createClusteredCacheManager();
-      cm2.defineCache("cache", cfg);
+      cm2 = addClusterEnabledCacheManager();
+      cm2.defineCache("cache", cfg.clone());
       cm2.getCache("cache"); // this will make sure any lazy components are started.
       TestingUtil.blockUntilViewsReceived(50000, true, cm1, cm2);
       memb1 = cm1.getMembers();
@@ -57,10 +53,10 @@
 
    public void testIsCoordinator() throws Exception {
       cm1.getCache("cache"); // this will make sure any lazy components are started.
-      assert cm1.isCoordinator();
+      assert cm1.isCoordinator() : "Should be coordinator!";
 
-      cm2 = TestingUtil.createClusteredCacheManager();
-      cm2.defineCache("cache", cfg);
+      cm2 = addClusterEnabledCacheManager();
+      cm2.defineCache("cache", cfg.clone());
       cm2.getCache("cache"); // this will make sure any lazy components are started.
       assert cm1.isCoordinator();
       assert !cm2.isCoordinator();
@@ -69,4 +65,4 @@
       TestingUtil.blockUntilViewsReceived(50000, false, cm2);
       assert cm2.isCoordinator();
    }
-}
\ No newline at end of file
+}




More information about the jbosscache-commits mailing list