[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/statetransfer ...

Manik Surtani manik at jboss.org
Mon Apr 23 10:52:29 EDT 2007


  User: msurtani
  Date: 07/04/23 10:52:29

  Modified:    tests/functional/org/jboss/cache/statetransfer  
                        StateTransferTestBase.java
                        StateTransfer200Test.java
  Log:
  Removed obsolete method (StateTransferManager.loadState()) and rewrote tests that depended on it.  Also javadoc'd BuddyManager static util methods.
  
  Revision  Changes    Path
  1.38      +12 -16    JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransferTestBase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: StateTransferTestBase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransferTestBase.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -b -r1.37 -r1.38
  --- StateTransferTestBase.java	16 Apr 2007 17:37:10 -0000	1.37
  +++ StateTransferTestBase.java	23 Apr 2007 14:52:29 -0000	1.38
  @@ -38,7 +38,6 @@
   import java.util.HashMap;
   import java.util.Map;
   import java.util.Properties;
  -import java.util.Set;
   import java.util.concurrent.Semaphore;
   import java.util.concurrent.TimeUnit;
   
  @@ -59,7 +58,7 @@
      public static final Integer TWENTY = 20;
      public static final Integer FORTY = 40;
   
  -   protected Map caches;
  +   protected Map<String, Cache> caches;
      private ClassLoader orig_TCL;
   
   
  @@ -277,13 +276,13 @@
   
         char[] chars = path.toCharArray();
         StringBuffer sb = new StringBuffer();
  -      for (int i = 0; i < chars.length; i++)
  +      for (char aChar : chars)
         {
  -         if (chars[i] == '\\')
  +         if (aChar == '\\')
            {
               sb.append('\\');
            }
  -         sb.append(chars[i]);
  +         sb.append(aChar);
         }
         return sb.toString();
      }
  @@ -292,7 +291,7 @@
      {
         super.setUp();
   
  -      caches = new HashMap();
  +      caches = new HashMap<String, Cache>();
   
         // Save the TCL in case a test changes it
         orig_TCL = Thread.currentThread().getContextClassLoader();
  @@ -308,14 +307,11 @@
         // Restore the TCL in case a test changed it
         Thread.currentThread().setContextClassLoader(orig_TCL);
   
  -      Set keys = caches.keySet();
  -      String[] cacheIDs = new String[keys.size()];
  -      cacheIDs = (String[]) keys.toArray(cacheIDs);
  -      for (int i = 0; i < cacheIDs.length; i++)
  +      for (String cacheID : caches.keySet())
         {
  -         stopCache((Cache) caches.get(cacheIDs[i]));
  +         stopCache(caches.get(cacheID));
            TestingUtil.sleepThread(1500);
  -         File file = new File(getTempLocation(cacheIDs[i]));
  +         File file = new File(getTempLocation(cacheID));
            cleanFile(file);
         }
      }
  @@ -342,9 +338,9 @@
         File[] children = file.listFiles();
         if (children != null)
         {
  -         for (int i = 0; i < children.length; i++)
  +         for (File child : children)
            {
  -            cleanFile(children[i]);
  +            cleanFile(child);
            }
         }
   
  
  
  
  1.19      +20 -29    JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransfer200Test.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: StateTransfer200Test.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/statetransfer/StateTransfer200Test.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- StateTransfer200Test.java	27 Mar 2007 10:05:31 -0000	1.18
  +++ StateTransfer200Test.java	23 Apr 2007 14:52:29 -0000	1.19
  @@ -7,9 +7,9 @@
   
   package org.jboss.cache.statetransfer;
   
  +import org.jboss.cache.CacheImpl;
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.Node;
   import org.jboss.cache.buddyreplication.BuddyManager;
   import org.jboss.cache.config.BuddyReplicationConfig;
   import org.jboss.cache.factories.XmlConfigurationParser;
  @@ -24,7 +24,7 @@
    * Tests that state transfer works properly if the version is 2.0.0.GA.
    *
    * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
  - * @version $Revision: 1.18 $
  + * @version $Revision: 1.19 $
    */
   public class StateTransfer200Test extends VersionedTestBase
   {
  @@ -70,41 +70,32 @@
      public void testBuddyIntegration() throws Exception
      {
         CacheSPI cache1 = createCache("cache1", false, false, false, false, false);
  -
         cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
  -
         cache1.start();
   
  -      CacheSPI cache2 = createCache("cache2", false, false, false);
  -
  -      // Pause to give caches time to see each other
  -      TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
  +      // cache 1 won't have a buddy at this stage.
   
  -      Fqn backup = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE);
  -      backup = new Fqn(backup, "a");
  -      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
  -      cache1.put(backup, null);
  -
  -      Node target = cache1.peek(backup, true);
  +      // put some state in cache 1
  +      cache1.put(A_B, "name", JOE);
  +      cache1.put(A_C, "name", JANE);
   
  -      assertNotNull("Data Node should not be null", target);
  +      // now start up cache 2
  +      CacheSPI cache2 = createCache("cache2", false, false, false, false, false);
  +      cache2.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
  +      cache2.start();
   
  -      Fqn abc = Fqn.fromString("/a/b/c");
  -      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
  -      cache2.put(abc, "name", JOE);
  -      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
  -      cache2.put(A_D, "name", JANE);
  +      // Pause to give caches time to see each other
  +      TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
   
  -      Object[] sources = cache1.getMembers().toArray();
  -      ClassLoader cl = Thread.currentThread().getContextClassLoader();
  -      Fqn a = Fqn.fromString("/a");
  -      cache1.getStateTransferManager().loadState(a, target, sources, cl);
  +      System.out.println("C1: " + ((CacheImpl) cache1).printLockInfo());
  +      System.out.println("C2: " + ((CacheImpl) cache2).printLockInfo());
   
  -      Fqn test = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, abc);
  -      assertEquals("/a/b/c state integrated in backup region", JOE, cache1.get(test, "name"));
  +      // now peek into cache 2 to check that this state has been transferred into the backup subtree
  +      Fqn test = BuddyManager.getBackupFqn(cache1.getLocalAddress(), A_B);
  +      assertEquals("/a/b state should have integrated in backup region " + test, JOE, cache2.get(test, "name"));
   
  -      test = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, A_D);
  -      assertEquals("/a/d state integrated in backup region", JANE, cache1.get(test, "name"));
  +      test = BuddyManager.getBackupFqn(cache1.getLocalAddress(), A_C);
  +      assertEquals("/a/c state should have integrated in backup region " + test, JANE, cache2.get(test, "name"));
      }
   
      public void testCacheLoaderFailure() throws Exception
  
  
  



More information about the jboss-cvs-commits mailing list