[jbosscache-commits] JBoss Cache SVN: r5689 - in core/trunk/src: test/java/org/jboss/cache/buddyreplication and 2 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Apr 25 08:22:41 EDT 2008


Author: mircea.markus
Date: 2008-04-25 08:22:40 -0400 (Fri, 25 Apr 2008)
New Revision: 5689

Modified:
   core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
   core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
   core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
Log:
JBCACHE-1222 - fixed FIFO eviction test

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java	2008-04-25 12:11:55 UTC (rev 5688)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java	2008-04-25 12:22:40 UTC (rev 5689)
@@ -335,6 +335,7 @@
       InvocationContext ctx = invocationContextContainer.get();
       cacheStatusCheck(ctx);
       List<Fqn> nodesToEvict = cacheData.getNodesForEviction(fqn, recursive);
+      //todo optimize this so that it performs only one call disregarding 
       for (Fqn aFqn : nodesToEvict)
       {
          invoker.invoke(ctx, commandsFactory.buildEvictFqnCommand(aFqn));

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java	2008-04-25 12:11:55 UTC (rev 5688)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java	2008-04-25 12:22:40 UTC (rev 5689)
@@ -204,7 +204,7 @@
 
          List<CacheSPI<Object, Object>> dump = new ArrayList<CacheSPI<Object, Object>>(caches);
          dump.add(cache2);
-         dumpCacheContents(dump);
+         TestingUtil.dumpCacheContents(dump);
 
          // now caches.get(1)'s buddy should be cache2, not cache[0]
          assertIsBuddy(caches.get(1), cache2, true);

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java	2008-04-25 12:11:55 UTC (rev 5688)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java	2008-04-25 12:22:40 UTC (rev 5689)
@@ -43,15 +43,15 @@
       Fqn fqn = Fqn.fromString("/test");
       Fqn backupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
 
-      dumpCacheContents(caches);
+      TestingUtil.dumpCacheContents(caches);
 
       caches.get(0).put(fqn, key, value);
 
-      dumpCacheContents(caches);
+      TestingUtil.dumpCacheContents(caches);
 
       assertEquals("Value should exist", value, caches.get(0).get(fqn, key));
 
-      dumpCacheContents(caches);
+      TestingUtil.dumpCacheContents(caches);
 
       // use exists instead of get() to prevent going up the interceptor stack
       assertTrue("Should be false", !caches.get(1).exists(fqn));
@@ -68,7 +68,7 @@
          killChannel(caches.get(0), caches.get(1), 2);
 
          System.out.println("Killed.  Testing backup roots.");
-         dumpCacheContents(caches);
+         TestingUtil.dumpCacheContents(caches);
          // assert that the remaining caches have picked new buddies.  Cache 1 should have cache 2's backup data.
          assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
          assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
@@ -88,7 +88,7 @@
 
       delay(); // cleanup commands are async
 
-      dumpCacheContents(caches);
+      TestingUtil.dumpCacheContents(caches);
 
       // now lets test the eviction part of gravitation
       Fqn newBackupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
@@ -152,7 +152,7 @@
       Fqn backupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
       caches.get(0).put(fqn, key, value);
 
-      dumpCacheContents(caches);
+      TestingUtil.dumpCacheContents(caches);
 
       assertEquals("value", caches.get(0).get(fqn, key));
       assertFalse(caches.get(0).exists(backupFqn));
@@ -171,7 +171,7 @@
       assertEquals("value", caches.get(1).get(fqn, key));
       delay(); // cleanup commands are async
 
-      dumpCacheContents(caches);
+      TestingUtil.dumpCacheContents(caches);
 
       assertFalse(caches.get(1).exists(backupFqn));
       assertEquals("value", caches.get(2).get(backupFqn, key));
@@ -231,7 +231,7 @@
       assertTrue(!caches.get(1).exists(newBackupFqn));
       assertTrue(!caches.get(1).exists(newBackupFqn2));
 
-      dumpCacheContents(caches);
+      TestingUtil.dumpCacheContents(caches);
 
       for (CacheSPI<Object, Object> cache : caches)
       {

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java	2008-04-25 12:11:55 UTC (rev 5688)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java	2008-04-25 12:22:40 UTC (rev 5689)
@@ -320,24 +320,6 @@
       assertTrue(buddyLocalAddress + " should be a buddy to " + group.getGroupName(), group.getBuddies().contains(buddyLocalAddress));
    }
 
-   protected void dumpCacheContents(List<CacheSPI<Object, Object>> caches)
-   {
-      System.out.println("**** START: Cache Contents ****");
-      for (int i = 0; i < caches.size(); i++)
-      {
-         if (caches.get(i) == null)
-         {
-            System.out.println("  ** Cache " + i + " is null!");
-         }
-         else
-         {
-            System.out.println("  ** Cache " + i + " is " + caches.get(i).getLocalAddress());
-            System.out.println("    " + CachePrinter.printCacheLockingInfo(caches.get(i)));
-         }
-      }
-      System.out.println("**** END: Cache Contents ****");
-   }
-
    protected void assertNoLocks(List<CacheSPI<Object, Object>> caches)
    {
       for (Cache cache : caches)

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java	2008-04-25 12:11:55 UTC (rev 5688)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOPolicyTest.java	2008-04-25 12:22:40 UTC (rev 5689)
@@ -19,6 +19,8 @@
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.util.List;
 import java.util.ArrayList;
@@ -136,7 +138,7 @@
          cache.put(fqn, str, str);
       }
 
-      TestingUtil.sleepThread(wakeupIntervalMillis + 500);
+      TestingUtil.sleepThread(wakeupIntervalMillis + 10000);
       assertEquals("Number of nodes", maxNodes + 2, cache.getNumberOfNodes());
       for (int i = 0; i < maxNodes; i++)
       {

Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java	2008-04-25 12:11:55 UTC (rev 5688)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java	2008-04-25 12:22:40 UTC (rev 5689)
@@ -11,6 +11,7 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.CacheStatus;
 import org.jboss.cache.Fqn;
+import org.jboss.cache.util.CachePrinter;
 import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
 import org.jboss.cache.factories.ComponentRegistry;
@@ -26,6 +27,7 @@
 import java.lang.reflect.Field;
 import java.util.List;
 import java.util.Random;
+import java.util.ArrayList;
 
 /**
  * Utilities for unit testing JBossCache.
@@ -586,4 +588,31 @@
       }
       return null;
    }
+
+   public static void dumpCacheContents(List<CacheSPI> caches)
+   {
+      System.out.println("**** START: Cache Contents ****");
+      for (int i = 0; i < caches.size(); i++)
+      {
+         if (caches.get(i) == null)
+         {
+            System.out.println("  ** Cache " + i + " is null!");
+         }
+         else
+         {
+            System.out.println("  ** Cache " + i + " is " + caches.get(i).getLocalAddress());
+            System.out.println("    " + CachePrinter.printCacheLockingInfo(caches.get(i)));
+         }
+      }
+      System.out.println("**** END: Cache Contents ****");
+   }
+   public static void dumpCacheContents(Object... caches)
+   {
+      List<CacheSPI> result = new ArrayList<CacheSPI>();
+      for (Object cache: caches)
+      {
+         result.add((CacheSPI<Object, Object>) cache);
+      }
+      dumpCacheContents(result);
+   }
 }




More information about the jbosscache-commits mailing list