Author: manik.surtani(a)jboss.com
Date: 2009-02-09 13:29:53 -0500 (Mon, 09 Feb 2009)
New Revision: 7668
Added:
core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
Removed:
core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java
Log:
Renamed test
Copied: core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java (from
rev 7666, core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java)
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
(rev 0)
+++ core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java 2009-02-09
18:29:53 UTC (rev 7668)
@@ -0,0 +1,65 @@
+package org.horizon.api;
+
+import org.horizon.BaseClusteredTest;
+import org.horizon.Cache;
+import org.horizon.config.Configuration;
+import org.horizon.config.Configuration.CacheMode;
+import org.horizon.manager.CacheManager;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+@Test(groups = "functional", sequential = true)
+public class CacheClusterJoinTest extends BaseClusteredTest {
+ Cache cache1, cache2;
+ CacheManager cm1, cm2;
+ Configuration cfg;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception {
+ cm1 = addClusterEnabledCacheManager();
+ cfg = new Configuration();
+ cfg.setCacheMode(CacheMode.REPL_SYNC);
+ cm1.defineCache("cache", cfg);
+ }
+
+ 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();
+
+ Object coord = memb1.get(0);
+
+ cm2 = addClusterEnabledCacheManager();
+ cm2.defineCache("cache", cfg);
+ cm2.getCache("cache"); // this will make sure any lazy components are
started.
+ TestingUtil.blockUntilViewsReceived(50000, true, cm1, cm2);
+ memb1 = cm1.getMembers();
+ List memb2 = cm2.getMembers();
+ assert 2 == memb1.size();
+ assert memb1.equals(memb2);
+
+ cm1.stop();
+ TestingUtil.blockUntilViewsReceived(50000, false, cm2);
+ memb2 = cm2.getMembers();
+ assert 1 == memb2.size();
+ assert !coord.equals(memb2.get(0));
+ }
+
+ public void testIsCoordinator() throws Exception {
+ cm1.getCache("cache"); // this will make sure any lazy components are
started.
+ assert cm1.isCoordinator();
+
+ cm2 = addClusterEnabledCacheManager();
+ cm2.defineCache("cache", cfg);
+ cm2.getCache("cache"); // this will make sure any lazy components are
started.
+ assert cm1.isCoordinator();
+ assert !cm2.isCoordinator();
+ cm1.stop();
+ // wait till cache2 gets the view change notification
+ TestingUtil.blockUntilViewsReceived(50000, false, cm2);
+ assert cm2.isCoordinator();
+ }
+}
\ No newline at end of file
Property changes on:
core/branches/flat/src/test/java/org/horizon/api/CacheClusterJoinTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java 2009-02-09 18:29:38
UTC (rev 7667)
+++ core/branches/flat/src/test/java/org/horizon/api/CacheSPITest.java 2009-02-09 18:29:53
UTC (rev 7668)
@@ -1,80 +0,0 @@
-package org.horizon.api;
-
-import org.horizon.config.Configuration;
-import org.horizon.config.Configuration.CacheMode;
-import org.horizon.config.GlobalConfiguration;
-import org.horizon.manager.CacheManager;
-import org.horizon.manager.DefaultCacheManager;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
-@Test(groups = "functional")
-public class CacheSPITest {
- private ThreadLocal<CacheManager> cacheManager1TL = new
ThreadLocal<CacheManager>();
- private ThreadLocal<CacheManager> cacheManager2TL = new
ThreadLocal<CacheManager>();
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception {
- GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
- Configuration conf = new Configuration();
- conf.setCacheMode(CacheMode.REPL_SYNC);
-
- cacheManager1TL.set(new DefaultCacheManager(gc, conf, false));
- cacheManager2TL.set(new DefaultCacheManager(gc, conf, false));
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception {
- TestingUtil.killCacheManagers(cacheManager1TL.get(), cacheManager2TL.get());
- cacheManager1TL.set(null);
- cacheManager2TL.set(null);
- }
-
- public void testGetMembers() throws Exception {
- CacheManager cm1 = cacheManager1TL.get();
- CacheManager cm2 = cacheManager2TL.get();
-
- cm1.start();
- cm1.getCache(); // this will make sure any lazy components are started.
- List memb1 = cm1.getMembers();
- assert 1 == memb1.size();
-
- Object coord = memb1.get(0);
-
- cm2.start();
- cm2.getCache(); // this will make sure any lazy components are started.
- TestingUtil.blockUntilViewsReceived(50000, true, cm1, cm2);
- memb1 = cm1.getMembers();
- List memb2 = cm2.getMembers();
- assert 2 == memb1.size();
- assert memb1.equals(memb2);
-
- cm1.stop();
- TestingUtil.blockUntilViewsReceived(50000, false, cm2);
- memb2 = cm2.getMembers();
- assert 1 == memb2.size();
- assert !coord.equals(memb2.get(0));
- }
-
- public void testIsCoordinator() throws Exception {
- CacheManager cm1 = cacheManager1TL.get();
- CacheManager cm2 = cacheManager2TL.get();
-
- cm1.start();
- cm1.getCache(); // this will make sure any lazy components are started.
- assert cm1.isCoordinator();
-
- cm2.start();
- cm2.getCache(); // this will make sure any lazy components are started.
- assert cm1.isCoordinator();
- assert !cm2.isCoordinator();
- cm1.stop();
- // wait till cache2 gets the view change notification
- TestingUtil.blockUntilViewsReceived(50000, false, cm2);
- assert cm2.isCoordinator();
- }
-}
\ No newline at end of file