[jbosscache-commits] JBoss Cache SVN: r6645 - in core/trunk/src/test/java/org/jboss/cache: util/internals and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Aug 29 11:26:10 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-08-29 11:26:10 -0400 (Fri, 29 Aug 2008)
New Revision: 6645

Modified:
   core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java
   core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
   core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
Log:
Fixed eviction tests

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java	2008-08-29 14:21:27 UTC (rev 6644)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java	2008-08-29 15:26:10 UTC (rev 6645)
@@ -55,4 +55,4 @@
       signaller.waitForEvictionThreadCompletion(timeToWait, unit);
       return evicted;
    }
-}
+}
\ No newline at end of file

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java	2008-08-29 14:21:27 UTC (rev 6644)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java	2008-08-29 15:26:10 UTC (rev 6645)
@@ -10,6 +10,7 @@
 import org.jboss.cache.config.EvictionRegionConfig;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.util.CachePrinter;
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.util.internals.EvictionController;
 import org.jboss.cache.util.internals.EvictionWatcher;
@@ -150,22 +151,50 @@
 
       System.out.println("REGIONS: " + cache.getRegionManager().dumpRegions());
 
+      final Fqn fqn7 = Fqn.fromString(rootStr + "7");
+
       for (int i = 0; i < 10; i++)
       {
          String str = rootStr + i;
          Fqn fqn = Fqn.fromString(str);
          cache.put(fqn, str, str);
+
+         // playing favourites here:
+         cache.getNode(fqn7);// just to keep it fresh
       }
 
-      String str = rootStr + "7";
-      Fqn fqn = Fqn.fromString(str);
-      cache.get(fqn, str);// just to keep it fresh
-      cache.get(fqn, str);// just to keep it fresh
+      System.out.println("Cache: " + CachePrinter.printCacheDetails(cache));
+
+      Thread retrieverThread = new Thread()
+      {
+         @Override
+         public void run()
+         {
+            try
+            {
+               while (true)
+               {
+                  cache.getNode(fqn7);// just to keep it fresh
+                  sleep(50);
+               }
+            }
+            catch (Exception ie)
+            {
+            }
+         }
+      };
+
+      retrieverThread.setDaemon(true);
+      retrieverThread.start();
       assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(rootStr + 3));
       String val = (String) cache.get(rootStr + "3", rootStr + "3");
       assertNull("Node should be empty ", val);
-      val = (String) cache.get(rootStr + "7", rootStr + "7");
+      Node n = cache.getNode(fqn7);
+      assert n != null;
+      val = (String) n.get(rootStr + "7");
       assertNotNull("Node should not be empty ", val);
+      retrieverThread.interrupt();
+      retrieverThread.join();
       new EvictionController(cache).startEviction(true);
       assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(rootStr + 7));
       val = (String) cache.get(rootStr + "7", rootStr + "7");

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java	2008-08-29 14:21:27 UTC (rev 6644)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java	2008-08-29 15:26:10 UTC (rev 6645)
@@ -63,6 +63,12 @@
       LRUAlgorithmConfig cfg = (LRUAlgorithmConfig) cache1.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
       cfg.setMaxAge(0);
       cfg.setTimeToLive(0);
+
+      cfg = (LRUAlgorithmConfig) cache3.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
+      cfg.setMaxAge(-1, TimeUnit.SECONDS);
+      cfg.setTimeToLive(-1, TimeUnit.SECONDS);
+      cfg.setMaxNodes(200);
+
       String str = rootStr + "0";
       Fqn fqn = Fqn.fromString(str);
       cache1.put(str, str, str);

Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java	2008-08-29 14:21:27 UTC (rev 6644)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java	2008-08-29 15:26:10 UTC (rev 6645)
@@ -45,7 +45,7 @@
       {
          throw new IllegalStateException("No timer task!!!");
       }
-      timerTask.stop();
+      stopEvictionThread();
       originalWakeupInterval = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
    }
 
@@ -154,6 +154,11 @@
       return s;
    }
 
+   public void stopEvictionThread()
+   {
+      timerTask.stop();
+   }
+
    public static class Signaller
    {
       Semaphore s = new Semaphore(1);




More information about the jbosscache-commits mailing list