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

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Jan 7 04:32:46 EST 2009


Author: mircea.markus
Date: 2009-01-07 04:32:46 -0500 (Wed, 07 Jan 2009)
New Revision: 7384

Modified:
   core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
Log:
more reliable evction checking

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java	2009-01-06 11:18:51 UTC (rev 7383)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java	2009-01-07 09:32:46 UTC (rev 7384)
@@ -23,7 +23,6 @@
 package org.jboss.cache.eviction;
 
 
-import org.jboss.cache.CacheFactory;
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.RegionManager;
@@ -41,6 +40,7 @@
 import java.util.concurrent.TimeUnit;
 import org.jboss.cache.UnitTestCacheFactory;
 import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.EvictionController;
 
 /**
  * Unit tests for programmatic configuration of LRU policy
@@ -52,26 +52,23 @@
 public class ProgrammaticLRUPolicyTest extends EvictionTestsBase
 {
    CacheSPI<Object, Object> cache;
+   EvictionController evController;
    long wakeupIntervalMillis = 0;
 
    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception
    {
-      initCaches();
+      initCache();
       wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupInterval();
-      if (wakeupIntervalMillis < 0)
-      {
-         fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
-      }
-
+      evController = new EvictionController(cache);
    }
 
-   private void initCaches()
+   private void initCache()
    {
       Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
       UnitTestCacheFactory<Object, Object> instance = new UnitTestCacheFactory<Object, Object>();
       cache = (CacheSPI<Object, Object>) instance.createCache(conf, false, getClass());
-      EvictionConfig erc = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), 200);
+      EvictionConfig erc = new EvictionConfig(new EvictionRegionConfig(Fqn.ROOT, new LRUAlgorithmConfig(0, 0, 10)), -1);
       conf.setEvictionConfig(erc);
       cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
@@ -115,7 +112,8 @@
       String val = (String) cache.get(rootStr + "3", rootStr + "3");
       assertNotNull("DataNode should be empty ", val);
 
-      assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(rootStr + 3));
+      evController.startEviction();
+
       val = (String) cache.get(rootStr + "3", rootStr + "3");
       assertNull("DataNode should be empty ", val);
    }
@@ -166,7 +164,7 @@
          fail("Failed to get" + e);
       }
 
-      assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn);
+      evController.startEviction();
 
       try
       {
@@ -184,8 +182,7 @@
    {
       addObjectBasedRegion();
 
-      Integer ii = 1;
-      Fqn rootfqn = Fqn.fromElements(ii);
+      Fqn rootfqn = Fqn.fromElements((Integer) 1);
       for (int i = 0; i < 10; i++)
       {
          Fqn fqn = Fqn.fromRelativeElements(rootfqn, i);
@@ -205,7 +202,7 @@
          Integer in = 3;
          Fqn fqn = Fqn.fromRelativeElements(rootfqn, in);
          Object val = cache.get(fqn, in);
-         assertNotNull("DataNode should be empty ", val);
+         assertNotNull("DataNode should not be empty ", val);
       }
       catch (Exception e)
       {
@@ -215,7 +212,8 @@
 
       Integer in = 3;
       Fqn fqn = Fqn.fromRelativeElements(rootfqn, in);
-      assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn);
+      Thread.sleep(1500);//max age is 1000, so this should expire
+      evController.startEviction();
 
       try
       {




More information about the jbosscache-commits mailing list