[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/buddyreplication ...
Manik Surtani
msurtani at jboss.com
Fri Mar 2 07:07:44 EST 2007
User: msurtani
Date: 07/03/02 07:07:44
Modified: tests/functional/org/jboss/cache/buddyreplication
BuddyReplicationContentTest.java
BuddyReplicationWithTransactionsTest.java
BuddyReplicationFailoverTest.java
BuddyPoolBroadcastTest.java
BuddyReplicationTestsBase.java
BuddyGroupAssignmentTest.java
BuddyReplicationWithCacheLoaderTest.java
BuddyAssignmentStateTransferTest.java
Log:
Refactored test cleanup methods
Revision Changes Path
1.16 +0 -9 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.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- BuddyReplicationContentTest.java 7 Feb 2007 22:06:53 -0000 1.15
+++ BuddyReplicationContentTest.java 2 Mar 2007 12:07:44 -0000 1.16
@@ -20,7 +20,6 @@
{
private String key = "key";
private String value = "value";
- private CacheImpl[] caches;
private Log log = LogFactory.getLog(BuddyGroupAssignmentTest.class);
@@ -41,14 +40,6 @@
log.debug("Finishing setUp()");
}
- protected void tearDown() throws Exception
- {
- super.tearDown();
- log.debug("Starting tearDown()");
- cleanup(caches);
- log.debug("Finishing tearDown()");
- }
-
public void testSimplePut() throws Exception
{
log.debug("Running testSimplePut");
1.6 +0 -10 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationWithTransactionsTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- BuddyReplicationWithTransactionsTest.java 30 Dec 2006 17:50:00 -0000 1.5
+++ BuddyReplicationWithTransactionsTest.java 2 Mar 2007 12:07:44 -0000 1.6
@@ -20,16 +20,6 @@
private Fqn fqn = Fqn.fromString("test");
private String key = "key";
private String value = "value";
- private CacheImpl[] caches;
-
- protected void tearDown() throws Exception
- {
- if (caches != null)
- {
- cleanup(caches);
- caches = null;
- }
- }
public void testTransactionsCommit() throws Exception
{
1.20 +0 -11 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.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- BuddyReplicationFailoverTest.java 30 Dec 2006 17:50:00 -0000 1.19
+++ BuddyReplicationFailoverTest.java 2 Mar 2007 12:07:44 -0000 1.20
@@ -20,17 +20,6 @@
protected boolean optimisticLocks = false;
private String key = "key";
private String value = "value";
- private CacheImpl[] caches;
-
- protected void tearDown() throws Exception
- {
- if (caches != null)
- {
- cleanup(caches);
- caches = null;
- }
- }
-
public void testDataGravitationKillOwner() throws Exception
{
1.20 +0 -10 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyPoolBroadcastTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyPoolBroadcastTest.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- BuddyPoolBroadcastTest.java 26 Feb 2007 14:15:08 -0000 1.19
+++ BuddyPoolBroadcastTest.java 2 Mar 2007 12:07:44 -0000 1.20
@@ -22,7 +22,6 @@
public class BuddyPoolBroadcastTest extends BuddyReplicationTestsBase
{
- private CacheImpl[] caches;
private Log log = LogFactory.getLog(BuddyPoolBroadcastTest.class);
private void checkConsistentPoolState(CacheImpl[] caches)
@@ -52,15 +51,6 @@
log.debug("Finishing setUp()");
}
- protected void tearDown() throws Exception
- {
- log.debug("Starting tearDown()");
- super.tearDown();
- cleanup(caches);
- log.debug("Finishing tearDown()");
- }
-
-
public void test2CachesWithPoolNames() throws Exception
{
log.debug("Running test2CachesWithPoolNames");
1.42 +46 -40 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.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- BuddyReplicationTestsBase.java 7 Feb 2007 22:06:52 -0000 1.41
+++ BuddyReplicationTestsBase.java 2 Mar 2007 12:07:44 -0000 1.42
@@ -34,6 +34,52 @@
*/
public abstract class BuddyReplicationTestsBase extends TestCase
{
+ protected CacheImpl[] caches;
+
+ protected void tearDown() throws Exception
+ {
+ if (caches != null)
+ {
+ for (CacheImpl c : caches)
+ {
+ if (c != null)
+ {
+ TransactionManager tm = c.getTransactionManager();
+ if (tm != null)
+ {
+ try
+ {
+ if (tm.getTransaction() != null) tm.rollback();
+ }
+ catch (Exception e)
+ {
+ // error rolling back txs
+ e.printStackTrace();
+ }
+ }
+ c.stop();
+ c = null;
+ }
+ CacheLoaderManager clm = c.getCacheLoaderManager();
+ if (clm != null)
+ {
+ CacheLoader cl = c.getCacheLoaderManager().getCacheLoader();
+ try
+ {
+ if (cl != null) cl.remove(Fqn.ROOT);
+ }
+ catch (Exception e)
+ {
+ // unable to clean cache loader
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ caches = null;
+ System.gc();
+ }
+
protected static int VIEW_BLOCK_TIMEOUT = 5000;
protected CacheImpl createCache(int numBuddies, String buddyPoolName) throws Exception
@@ -213,46 +259,6 @@
return caches;
}
- protected void cleanup(CacheImpl[] caches) throws Exception
- {
- System.out.println("*** cleaning up");
-
- if (caches != null)
- {
- for (int i = 0; i < caches.length; i++)
- {
- if (caches[i] != null)
- {
- destroyCache(caches[i]);
- TestingUtil.sleepThread(1500);
- caches[i] = null;
- }
- }
- }
- }
-
- private void destroyCache(CacheImpl c) throws Exception
- {
- TransactionManager tm = c.getTransactionManager();
- if (tm != null && tm.getTransaction() != null)
- {
- try
- {
- tm.rollback();
- }
- catch (Exception e)
- {
- }
- }
- CacheLoaderManager clm = c.getCacheLoaderManager();
- if (clm != null)
- {
- CacheLoader cl = c.getCacheLoaderManager().getCacheLoader();
- if (cl != null) cl.remove(Fqn.ROOT);
- }
- c.stop();
- }
-
protected void printBuddyGroup(CacheImpl cache)
{
BuddyGroup bg = cache.getBuddyManager().buddyGroup;
1.15 +0 -10 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyGroupAssignmentTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- BuddyGroupAssignmentTest.java 30 Dec 2006 17:50:00 -0000 1.14
+++ BuddyGroupAssignmentTest.java 2 Mar 2007 12:07:44 -0000 1.15
@@ -18,7 +18,6 @@
*/
public class BuddyGroupAssignmentTest extends BuddyReplicationTestsBase
{
- private CacheImpl[] caches;
private Log log = LogFactory.getLog(BuddyGroupAssignmentTest.class);
protected void setUp() throws Exception
@@ -28,15 +27,6 @@
log.debug("Finishing setUp()");
}
- protected void tearDown() throws Exception
- {
- super.tearDown();
- log.debug("Starting tearDown()");
- cleanup(caches);
- log.debug("Finishing tearDown()");
- }
-
-
public void testSingleBuddy() throws Exception
{
log.debug("Running testSingleBuddy");
1.8 +1 -19 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationWithCacheLoaderTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- BuddyReplicationWithCacheLoaderTest.java 2 Jan 2007 17:15:30 -0000 1.7
+++ BuddyReplicationWithCacheLoaderTest.java 2 Mar 2007 12:07:44 -0000 1.8
@@ -24,6 +24,7 @@
protected String value = "value";
protected boolean passivation = false;
+
private CacheLoader[] getLoaders(CacheImpl[] caches)
{
CacheLoader[] retVal = new CacheLoader[caches.length];
@@ -39,9 +40,6 @@
public void testWithDataGravitationDefault() throws Exception
{
- CacheImpl[] caches = null;
- try
- {
// create 3 caches
caches = createCachesWithCacheLoader(3, true, true, passivation);
@@ -115,21 +113,10 @@
// test that bkup does not exist in loader2
assertTrue("should not exist in loaders2", !loaders[2].exists(b1));
assertTrue("should not exist in loaders2", !loaders[2].exists(b2));
-
-
- }
- finally
- {
- cleanup(caches);
- }
-
}
public void testWithDataGravitationEviction() throws Exception
{
- CacheImpl[] caches = null;
- try
- {
// create 3 caches
caches = createCachesWithCacheLoader(3, true, false, passivation);
CacheLoader[] loaders = getLoaders(caches);
@@ -185,10 +172,5 @@
assertTrue("should not exist in loaders2", !loaders[2].exists(b1));
assertTrue("should not exist in loaders2", !loaders[2].exists(b2));
}
- finally
- {
- cleanup(caches);
- }
- }
}
1.12 +48 -129 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.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- BuddyAssignmentStateTransferTest.java 30 Jan 2007 01:22:57 -0000 1.11
+++ BuddyAssignmentStateTransferTest.java 2 Mar 2007 12:07:44 -0000 1.12
@@ -29,9 +29,7 @@
public void testNonRegionBasedStateTransfer() throws Exception
{
- CacheImpl[] caches = new CacheImpl[2];
- try
- {
+ caches = new CacheImpl[2];
caches[0] = createCache(1, "TEST", false, true);
Fqn main = Fqn.fromString("/a/b/c");
@@ -66,79 +64,6 @@
assertEquals("State transferred", "Joe", caches[2].get(test, "name"));
}
- finally
- {
- cleanup(caches);
- }
- }
-
- public void testRegionBasedStateTransfer() throws Exception
- {
-
- // TODO: Reinstate once we have proper FLUSH working.
- // This test relies on calls to inactive regions being queued and re-run
- // when the region is activated. After discussions with Brian, the queueing
- // was removed, presuming FLUSH will fix this. Need to test with FLUSH.
- // - Manik Surtani (16 Oct 2006)
- /*
- CacheImpl[] caches = new CacheImpl[3];
-
- try
- {
- caches[0] = createCache(1, "TEST", false, false);
- caches[1] = createCache(1, "TEST", false, false);
- caches[2] = createCache(1, "TEST", false, false);
- caches[0].getConfiguration().setInactiveOnStartup(true);
- caches[1].getConfiguration().setInactiveOnStartup(true);
- caches[2].getConfiguration().setInactiveOnStartup(true);
- caches[0].getConfiguration().setUseRegionBasedMarshalling(true);
- caches[1].getConfiguration().setUseRegionBasedMarshalling(true);
- caches[2].getConfiguration().setUseRegionBasedMarshalling(true);
- caches[0].start();
- caches[1].start();
- caches[2].start();
-
- TestingUtil.blockUntilViewsReceived(caches, VIEW_BLOCK_TIMEOUT);
- TestingUtil.sleepThread(getSleepTimeout());
-
- caches[0].activateRegion("/a");
- caches[1].activateRegion("/a");
- caches[2].activateRegion("/a");
-
- caches[0].activateRegion("/d");
- caches[1].activateRegion("/d");
-
- Fqn mainA = Fqn.fromString("/a/b/c");
- caches[0].put(mainA, "name", "Joe");
-
- Fqn mainD = Fqn.fromString("/d/e/f");
- caches[0].put(mainD, "name", "Joe");
-
- Fqn group = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
- BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress()));
- Fqn testA = new Fqn(group, mainA);
- assertEquals("/a replicated", "Joe", caches[1].get(testA, "name"));
- assertNull("No backup of /a", caches[2].get(testA, "name"));
-
- Fqn testD = new Fqn(group, mainD);
- assertEquals("/d replicated", "Joe", caches[1].get(testD, "name"));
- assertNull("No backup of /d", caches[2].get(testD, "name"));
-
- // Make 2 the buddy of 0
- caches[1].stop();
- caches[1] = null;
-
- TestingUtil.sleepThread(getSleepTimeout());
-
- assertEquals("/a state transferred", "Joe", caches[2].get(testA, "name"));
- assertNull("/d state not transferred", caches[2].get(testD, "name"));
- }
- finally
- {
- cleanup(caches);
- }
- */
- }
public void testPersistentStateTransfer() throws Exception
{
@@ -146,10 +71,9 @@
tmpLoc += File.separator + "BuddyReplicationTestsBase-";
String tmpLoc0 = tmpLoc + 0;
String tmpLoc1 = tmpLoc + 1;
- CacheImpl[] caches = new CacheImpl[2];
+ caches = new CacheImpl[2];
+
- try
- {
caches[0] = createCacheWithCacheLoader(tmpLoc0, false, false, false, true, false);
caches[0].getConfiguration().setFetchInMemoryState(false);
@@ -174,9 +98,4 @@
assertNotNull("/a/b/c shld be in CL", caches[1].getCacheLoader().get(test));
assertEquals("/a/b/c shld in cache loader", "Joe", caches[1].get(test, "name"));
}
- finally
- {
- cleanup(caches);
- }
- }
}
More information about the jboss-cvs-commits
mailing list