[jbosscache-commits] JBoss Cache SVN: r4827 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Dec 11 12:00:59 EST 2007


Author: manik.surtani at jboss.com
Date: 2007-12-11 12:00:59 -0500 (Tue, 11 Dec 2007)
New Revision: 4827

Modified:
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
Log:
Should use CacheSPI where possible in tests

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java	2007-12-11 16:41:18 UTC (rev 4826)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java	2007-12-11 17:00:59 UTC (rev 4827)
@@ -6,19 +6,14 @@
  */
 package org.jboss.cache.buddyreplication;
 
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.util.ArrayList;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.misc.TestingUtil;
+import static org.testng.AssertJUnit.*;
 import org.testng.annotations.Test;
 
+import java.util.ArrayList;
+
 /**
  * Tests how groups are formed and disbanded
  *
@@ -37,7 +32,7 @@
 
    public void testNonRegionBasedStateTransfer() throws Exception
    {
-      caches = new ArrayList<CacheImpl<Object, Object>>();
+      caches = new ArrayList<CacheSPI<Object, Object>>();
       caches.add(createCache(1, "TEST", false, true));
 
       Fqn<String> main = Fqn.fromString("/a/b/c");
@@ -45,18 +40,18 @@
 
       caches.add(createCache(1, "TEST", false, true));
 
-      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheImpl[0]), VIEW_BLOCK_TIMEOUT);
+      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
       TestingUtil.sleepThread(getSleepTimeout());
 
       Fqn<String> test = new Fqn<String>(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
-              BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress()));
+            BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress()));
       test = new Fqn<String>(test, main);
 
       assertEquals("State transferred", "Joe", caches.get(1).get(test, "name"));
 
       caches.add(createCache(1, "TEST", false, true));
 
-      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheImpl[0]), VIEW_BLOCK_TIMEOUT);
+      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
       TestingUtil.sleepThread(getSleepTimeout());
 
       assertNull("State not transferred", caches.get(2).get(test, "name"));
@@ -69,11 +64,11 @@
 
       assertEquals("State transferred", "Joe", caches.get(2).get(test, "name"));
    }
-   
+
    public void testRegionBasedStateTransfer() throws Exception
    {
-      caches = new ArrayList<CacheImpl<Object, Object>>();
-      
+      caches = new ArrayList<CacheSPI<Object, Object>>();
+
       caches.add(createCache(1, "TEST", false, false));
       caches.add(createCache(1, "TEST", false, false));
       caches.add(createCache(1, "TEST", false, false));
@@ -93,14 +88,14 @@
       caches.get(1).start();
       caches.get(2).start();
       caches.get(3).start();
-      
-      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheImpl[0]), VIEW_BLOCK_TIMEOUT);
+
+      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
       TestingUtil.sleepThread(getSleepTimeout());
-      
+
       Fqn fqnA = Fqn.fromString("/a");
       Fqn fqnD = Fqn.fromString("/d");
-      
-      // FIXME We have to use a hack to get JBC to recognize that our 
+
+      // FIXME We have to use a hack to get JBC to recognize that our
       // regions are for marshalling
       ClassLoader cl = Fqn.class.getClassLoader();
       caches.get(0).getRegion(fqnA, true).registerContextClassLoader(cl);
@@ -111,36 +106,36 @@
       caches.get(1).getRegion(fqnD, true).registerContextClassLoader(cl);
       caches.get(2).getRegion(fqnD, true).registerContextClassLoader(cl);
       caches.get(3).getRegion(fqnD, true).registerContextClassLoader(cl);
-      
+
       caches.get(0).getRegion(fqnA, true).activate();
       caches.get(1).getRegion(fqnA, true).activate();
       caches.get(2).getRegion(fqnA, true).activate();
       caches.get(3).getRegion(fqnA, true).activate();
-      
+
       caches.get(0).getRegion(fqnD, true).activate();
       caches.get(1).getRegion(fqnD, true).activate();
-      
+
       Fqn mainA = Fqn.fromString("/a/b/c");
       caches.get(0).put(mainA, "name", "Joe");
-      
+
       Fqn mainD = Fqn.fromString("/d/e/f");
       caches.get(0).put(mainD, "name", "Joe");
-      
-      Fqn group = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, 
-                          BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress()));
+
+      Fqn group = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
+            BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress()));
       Fqn testA = new Fqn(group, mainA);
       assertEquals("/a replicated", "Joe", caches.get(1).get(testA, "name"));
       assertNull("No backup of /a", caches.get(2).get(testA, "name"));
-      
+
       Fqn testD = new Fqn(group, mainD);
       assertEquals("/d replicated", "Joe", caches.get(1).get(testD, "name"));
       assertNull("No backup of /d", caches.get(2).get(testD, "name"));
-      
+
       // Make 2 the buddy of 0 -- this should cause a push from 0 to 2
       caches.get(1).stop();
 
-      TestingUtil.sleepThread(getSleepTimeout());          
-      
+      TestingUtil.sleepThread(getSleepTimeout());
+
       assertEquals("/a state transferred", "Joe", caches.get(2).get(testA, "name"));
       assertNull("/d state not transferred", caches.get(2).get(testD, "name"));
 
@@ -154,7 +149,7 @@
 
    public void testPersistentStateTransfer() throws Exception
    {
-      caches = new ArrayList<CacheImpl<Object, Object>>();
+      caches = new ArrayList<CacheSPI<Object, Object>>();
 
       caches.add(createCacheWithCacheLoader(false, false, false, true, false));
       caches.get(0).getConfiguration().setFetchInMemoryState(false);
@@ -169,13 +164,13 @@
 
       caches.get(1).start();
 
-      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheImpl[0]), VIEW_BLOCK_TIMEOUT);
+      TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), VIEW_BLOCK_TIMEOUT);
       TestingUtil.sleepThread(getSleepTimeout());
 
       Fqn test = BuddyManager.getBackupFqn(caches.get(0).getLocalAddress(), main);
 
       assertFalse("/a/b/c shld not be bin memory", caches.get(1).exists(test));
-      assertNotNull("/a/b/c shld be in CL", caches.get(1).getCacheLoader().get(test));
+      assertNotNull("/a/b/c shld be in CL", caches.get(1).getCacheLoaderManager().getCacheLoader().get(test));
       assertEquals("/a/b/c shld in cache loader", "Joe", caches.get(1).get(test, "name"));
    }
 }
\ No newline at end of file




More information about the jbosscache-commits mailing list