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

Manik Surtani msurtani at jboss.com
Thu Jan 11 08:49:05 EST 2007


  User: msurtani
  Date: 07/01/11 08:49:05

  Modified:    tests/functional/org/jboss/cache/eviction             
                        MRUPolicyTest.java LFUAlgorithmTest.java
                        FIFOPolicyTest.java OptimisticEvictionTest.java
                        RegionManagerTest.java LFUPolicyTest.java
                        ExpirationPolicyTest.java
                        ProgrammaticLRUPolicyTest.java
                        ReplicatedLRUPolicyTest.java
                        EvictionConfigurationTest.java LRUPolicyTest.java
                        ConcurrentEvictionTest.java
                        ElementSizePolicyTest.java
  Log:
  Changed CacheImpl ctor to be protected, and changed cache factories accordingly
  
  Revision  Changes    Path
  1.13      +8 -6      JBossCache/tests/functional/org/jboss/cache/eviction/MRUPolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MRUPolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/MRUPolicyTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- MRUPolicyTest.java	30 Dec 2006 19:48:45 -0000	1.12
  +++ MRUPolicyTest.java	11 Jan 2007 13:49:05 -0000	1.13
  @@ -8,7 +8,7 @@
   
   import junit.framework.TestCase;
   import org.jboss.cache.CacheImpl;
  -import org.jboss.cache.factories.XmlConfigurationParser;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.misc.TestingUtil;
   
  @@ -16,7 +16,7 @@
    * Unit tests for MRUPolicy.
    *
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
    */
   public class MRUPolicyTest extends TestCase
   {
  @@ -35,7 +35,9 @@
         wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
         log("wakeupInterval is " + wakeupIntervalMillis);
         if (wakeupIntervalMillis < 0)
  +      {
            fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
  +      }
   
         t1_ex = t2_ex = null;
         isTrue = true;
  @@ -49,9 +51,7 @@
   
      private void initCaches() throws Exception
      {
  -      cache = new CacheImpl();
  -      XmlConfigurationParser parser = new XmlConfigurationParser();
  -      cache.setConfiguration(parser.parseFile("META-INF/local-mru-eviction-service.xml")); // read in generic local xml
  +      cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-mru-eviction-service.xml", false);// read in generic local xml
         cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
         cache.start();
  @@ -130,11 +130,13 @@
               {
                  e.printStackTrace();
                  if (t1_ex == null)
  +               {
                     t1_ex = e;
               }
            }
         }
      }
  +   }
   
   
      public void testConcurrentPutAndEvict() throws Exception
  @@ -161,7 +163,7 @@
            log("nodes/locks: " + cache.getNumberOfNodes() + "/" + cache.getNumberOfLocksHeld());
            TestingUtil.sleepThread(1000);
            if (counter > 10)
  -         { // run for 10 seconds
  +         {// run for 10 seconds
               isTrue = false;
               break;
            }
  
  
  
  1.8       +28 -27    JBossCache/tests/functional/org/jboss/cache/eviction/LFUAlgorithmTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LFUAlgorithmTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/LFUAlgorithmTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- LFUAlgorithmTest.java	30 Dec 2006 17:49:58 -0000	1.7
  +++ LFUAlgorithmTest.java	11 Jan 2007 13:49:05 -0000	1.8
  @@ -10,6 +10,7 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Region;
   import org.jboss.cache.RegionManager;
  @@ -20,7 +21,7 @@
    * Unit test for LFUAlgorithm.
    *
    * @author Daniel Huang - dhuang at jboss.org - 10/2005
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public class LFUAlgorithmTest extends TestCase
   {
  @@ -39,7 +40,7 @@
   
         algo = new LFUAlgorithm();
         LFUConfiguration config = new LFUConfiguration();
  -      regionManager = new RegionManager(new CacheImpl());
  +      regionManager = new RegionManager((CacheImpl) DefaultCacheFactory.getInstance().createCache(false));
         config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
         regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
         // doesn't this need a cache?!?? :-/
  @@ -118,31 +119,31 @@
      // What's this doing here?  This should be a stress test, not a functional test.  There are no assertions, for
      // example.  :S - Manik, Nov 06
   
  -//   public void testMaxNode3() throws Exception
  -//   {
  -//      Region region = regionManager.getRegion("/a/b", true);
  -//      LFUConfiguration config = new LFUConfiguration();
  -//
  -//      config.setMaxNodes(15000);
  -//      config.setMinNodes(15000);
  -//
  -//      region.setEvictionPolicy(config);
  -//      for (int i = 0; i < 20000; i++)
  -//      {
  -//         Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
  -//         region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
  -//
  -//         if ((i % 2) == 0)
  -//         {
  -//            region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT));
  -//         }
  -//      }
  -//
  -//      algo.process(region);
  -////      LFUQueue queue = (LFUQueue) algo.evictionQueue;
  -////      Iterator it = queue.iterate();
  -//
  -//   }
  +   //   public void testMaxNode3() throws Exception
  +   //   {
  +   //      Region region = regionManager.getRegion("/a/b", true);
  +   //      LFUConfiguration config = new LFUConfiguration();
  +   //
  +   //      config.setMaxNodes(15000);
  +   //      config.setMinNodes(15000);
  +   //
  +   //      region.setEvictionPolicy(config);
  +   //      for (int i = 0; i < 20000; i++)
  +   //      {
  +   //         Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
  +   //         region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
  +   //
  +   //         if ((i % 2) == 0)
  +   //         {
  +   //            region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.VISIT_NODE_EVENT));
  +   //         }
  +   //      }
  +   //
  +   //      algo.process(region);
  +   ////      LFUQueue queue = (LFUQueue) algo.evictionQueue;
  +   ////      Iterator it = queue.iterate();
  +   //
  +   //   }
   
      public void testMinNode1() throws Exception
      {
  
  
  
  1.13      +10 -7     JBossCache/tests/functional/org/jboss/cache/eviction/FIFOPolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FIFOPolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/FIFOPolicyTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- FIFOPolicyTest.java	30 Dec 2006 19:48:45 -0000	1.12
  +++ FIFOPolicyTest.java	11 Jan 2007 13:49:05 -0000	1.13
  @@ -8,8 +8,8 @@
   
   import junit.framework.TestCase;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.misc.TestingUtil;
   
  @@ -17,7 +17,7 @@
    * Unit tests for FIFOPolicy.
    *
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
    */
   public class FIFOPolicyTest extends TestCase
   {
  @@ -40,7 +40,9 @@
         wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
         log("wakeupInterval is " + wakeupIntervalMillis);
         if (wakeupIntervalMillis < 0)
  +      {
            fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
  +      }
   
         t1_ex = t2_ex = null;
         isTrue = true;
  @@ -48,8 +50,7 @@
   
      void initCaches() throws Exception
      {
  -      cache = new CacheImpl();
  -      cache.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-fifo-eviction-service.xml")); // read in generic local xml
  +      cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-fifo-eviction-service.xml", false);// read in generic local xml
         cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
         cache.start();
  @@ -158,7 +159,7 @@
         int period = wakeupIntervalMillis + 500;
   
         log("sleeping for " + period + "ms");
  -      TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
  +      TestingUtil.sleepThread(period);// it really depends the eviction thread time.
         try
         {
            for (int i = 0; i < 5; i++)
  @@ -180,7 +181,7 @@
            {
               String str = rootStr + Integer.toString(i);
               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("-- sleeping for " + period + "ms");
            }
         }
  @@ -279,11 +280,13 @@
               {
                  e.printStackTrace();
                  if (t1_ex == null)
  +               {
                     t1_ex = e;
               }
            }
         }
      }
  +   }
   
   
      public void testConcurrentPutAndEvict() throws Exception
  @@ -310,7 +313,7 @@
            log("nodes/locks: " + cache.getNumberOfNodes() + "/" + cache.getNumberOfLocksHeld());
            TestingUtil.sleepThread(1000);
            if (counter > 10)
  -         { // run for 10 seconds
  +         {// run for 10 seconds
               isTrue = false;
               break;
            }
  
  
  
  1.10      +2 -4      JBossCache/tests/functional/org/jboss/cache/eviction/OptimisticEvictionTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticEvictionTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/OptimisticEvictionTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- OptimisticEvictionTest.java	30 Dec 2006 17:49:58 -0000	1.9
  +++ OptimisticEvictionTest.java	11 Jan 2007 13:49:05 -0000	1.10
  @@ -2,9 +2,9 @@
   
   import junit.framework.TestCase;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.DummyTransactionManagerLookup;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.interceptors.EvictionInterceptor;
   import org.jboss.cache.misc.TestingUtil;
   
  @@ -37,9 +37,7 @@
         super.setUp();
   
         txManager = new DummyTransactionManagerLookup().getTransactionManager();
  -      cache = new CacheImpl();
  -      cache.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/optimistic-eviction.xml"));
  -      cache.start();
  +      cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/optimistic-eviction.xml");
      }
   
      protected void tearDown() throws Exception
  
  
  
  1.19      +3 -2      JBossCache/tests/functional/org/jboss/cache/eviction/RegionManagerTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RegionManagerTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/RegionManagerTest.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- RegionManagerTest.java	30 Dec 2006 17:49:58 -0000	1.18
  +++ RegionManagerTest.java	11 Jan 2007 13:49:05 -0000	1.19
  @@ -2,6 +2,7 @@
   
   import junit.framework.TestCase;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Region;
   import org.jboss.cache.RegionManager;
  @@ -18,7 +19,7 @@
    *
    * @author Ben Wang, Feb 11, 2004
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Revision: 1.18 $
  + * @version $Revision: 1.19 $
    */
   public class RegionManagerTest extends TestCase
   {
  @@ -140,7 +141,7 @@
         assertEquals(10, config.getMinNodes());
         assertEquals(Fqn.fromString("/test/"), region.getFqn());
   
  -      CacheImpl cache = new CacheImpl();
  +      CacheImpl cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
   
         // test the 1.2.x style configuration
         xml = "<region name=\"abc\">" +
  
  
  
  1.11      +11 -11    JBossCache/tests/functional/org/jboss/cache/eviction/LFUPolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LFUPolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/LFUPolicyTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- LFUPolicyTest.java	30 Dec 2006 19:48:45 -0000	1.10
  +++ LFUPolicyTest.java	11 Jan 2007 13:49:05 -0000	1.11
  @@ -8,9 +8,8 @@
   
   import junit.framework.TestCase;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.config.Configuration;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.misc.TestingUtil;
   
  @@ -18,7 +17,7 @@
    * Unit tests for LFU Policy.
    *
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    */
   public class LFUPolicyTest extends TestCase
   {
  @@ -41,7 +40,9 @@
         wakeupIntervalMillis = cache.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
         log("wakeupInterval is " + wakeupIntervalMillis);
         if (wakeupIntervalMillis < 0)
  +      {
            fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis);
  +      }
   
         t1_ex = t2_ex = null;
         isTrue = true;
  @@ -49,12 +50,9 @@
   
      void initCaches() throws Exception
      {
  -      cache = new CacheImpl();
  -      XmlConfigurationParser parser = new XmlConfigurationParser();
  -      Configuration c = parser.parseFile("META-INF/local-lfu-eviction-service.xml");
  -      cache.setConfiguration(c);
  -      c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      c.setIsolationLevel(IsolationLevel.SERIALIZABLE);
  +      cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-lfu-eviction-service.xml", false);
  +      cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  +      cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
         cache.start();
      }
   
  @@ -129,7 +127,7 @@
         int period = wakeupIntervalMillis + 500;
   
         log("sleeping for " + period + "ms");
  -      TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
  +      TestingUtil.sleepThread(period);// it really depends the eviction thread time.
   
         System.out.println("cache is:\n" + cache.toString(true));
   
  @@ -301,11 +299,13 @@
               {
                  e.printStackTrace();
                  if (t1_ex == null)
  +               {
                     t1_ex = e;
               }
            }
         }
      }
  +   }
   
   
      public void testConcurrentPutAndEvict() throws Exception
  @@ -332,7 +332,7 @@
            log("nodes/locks: " + cache.getNumberOfNodes() + "/" + cache.getNumberOfLocksHeld());
            TestingUtil.sleepThread(1000);
            if (counter > 10)
  -         { // run for 10 seconds
  +         {// run for 10 seconds
               isTrue = false;
               break;
            }
  
  
  
  1.7       +4 -3      JBossCache/tests/functional/org/jboss/cache/eviction/ExpirationPolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ExpirationPolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/ExpirationPolicyTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- ExpirationPolicyTest.java	10 Jan 2007 00:11:31 -0000	1.6
  +++ ExpirationPolicyTest.java	11 Jan 2007 13:49:05 -0000	1.7
  @@ -10,6 +10,7 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.config.Configuration;
   import org.jboss.cache.config.EvictionConfig;
  @@ -19,7 +20,7 @@
    * Unit tests for {@link ExpirationPolicy}.
    *
    * @author Elias Ross
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class ExpirationPolicyTest extends TestCase
   {
  @@ -38,8 +39,8 @@
      public void setUp() throws Exception
      {
         super.setUp();
  -      cache = new CacheImpl();
  -      Configuration conf = new Configuration();
  +      cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
  +      Configuration conf = cache.getConfiguration();
         EvictionConfig econf = new EvictionConfig(ExpirationPolicy.class.getName());
         econf.setWakeupIntervalSeconds(1);
         conf.setEvictionConfig(econf);
  
  
  
  1.10      +5 -3      JBossCache/tests/functional/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ProgrammaticLRUPolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- ProgrammaticLRUPolicyTest.java	30 Dec 2006 19:48:45 -0000	1.9
  +++ ProgrammaticLRUPolicyTest.java	11 Jan 2007 13:49:05 -0000	1.10
  @@ -26,6 +26,7 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.RegionManager;
   import org.jboss.cache.config.EvictionConfig;
  @@ -40,7 +41,7 @@
    * Unit tests for programmatic configuration of LRU policy
    *
    * @author Ben Wang, Oct, 2006
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.10 $
    */
   public class ProgrammaticLRUPolicyTest extends TestCase
   {
  @@ -59,14 +60,15 @@
         wakeupIntervalMillis_ = cache_.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
         log("wakeupInterval is " + wakeupIntervalMillis_);
         if (wakeupIntervalMillis_ < 0)
  +      {
            fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
  +      }
   
      }
   
      public void initCaches() throws Exception
      {
  -      cache_ = new CacheImpl();
  -      cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-lru-eviction-service.xml")); // read in generic local xml
  +      cache_ = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-lru-eviction-service.xml", false);// read in generic local xml
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache_.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
   
  
  
  
  1.18      +5 -5      JBossCache/tests/functional/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedLRUPolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/ReplicatedLRUPolicyTest.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- ReplicatedLRUPolicyTest.java	10 Jan 2007 17:06:52 -0000	1.17
  +++ ReplicatedLRUPolicyTest.java	11 Jan 2007 13:49:05 -0000	1.18
  @@ -3,10 +3,10 @@
   import junit.framework.TestCase;
   import org.jboss.cache.AbstractCacheListener;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.config.Configuration.CacheMode;
   import org.jboss.cache.factories.UnitTestCacheFactory;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.misc.TestingUtil;
   
   /**
  @@ -27,15 +27,15 @@
      public void setUp() throws Exception
      {
         super.setUp();
  -      cache_ = new CacheImpl();
  +      cache_ = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
         initCaches(cache_);
         cache_.getConfiguration().setUseRegionBasedMarshalling(true);
         cache_.start();
         cache_.getNotifier().addCacheListener(listener_);
         listener_.resetCounter();
   
  -      cache2_ = new CacheImpl();
  -      cache2_.setConfiguration(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC)); // read in generic local xml
  +      cache2_ = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
  +      cache2_.setConfiguration(UnitTestCacheFactory.createConfiguration(CacheMode.REPL_SYNC));// read in generic local xml
         cache2_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache2_.getConfiguration().setUseRegionBasedMarshalling(true);
         cache2_.start();
  
  
  
  1.13      +5 -9      JBossCache/tests/functional/org/jboss/cache/eviction/EvictionConfigurationTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EvictionConfigurationTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/EvictionConfigurationTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- EvictionConfigurationTest.java	30 Dec 2006 17:49:58 -0000	1.12
  +++ EvictionConfigurationTest.java	11 Jan 2007 13:49:05 -0000	1.13
  @@ -8,18 +8,17 @@
   
   import junit.framework.TestCase;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Region;
   import org.jboss.cache.RegionManager;
  -import org.jboss.cache.config.Configuration;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.lock.IsolationLevel;
   
   /**
    * Unit test to test Eviction configuration types.
    *
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
    */
   public class EvictionConfigurationTest extends TestCase
   {
  @@ -207,12 +206,9 @@
   
      private void setupCache(String configurationName) throws Exception
      {
  -      cache = new CacheImpl();
  -      XmlConfigurationParser parser = new XmlConfigurationParser();
  -      Configuration c = parser.parseFile(configurationName);
  -      c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      c.setIsolationLevel(IsolationLevel.SERIALIZABLE);
  -      cache.setConfiguration(c);
  +      cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache(configurationName, false);
  +      cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  +      cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
         cache.start();
         regionManager = cache.getRegionManager();
      }
  
  
  
  1.22      +23 -20    JBossCache/tests/functional/org/jboss/cache/eviction/LRUPolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LRUPolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/LRUPolicyTest.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- LRUPolicyTest.java	30 Dec 2006 19:48:45 -0000	1.21
  +++ LRUPolicyTest.java	11 Jan 2007 13:49:05 -0000	1.22
  @@ -4,8 +4,8 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.misc.TestingUtil;
   
  @@ -14,7 +14,7 @@
    *
    * @author Ben Wang, Feb 11, 2004
    * @author Daniel Huang - dhuang at jboss.org
  - * @version $Revision: 1.21 $
  + * @version $Revision: 1.22 $
    */
   public class LRUPolicyTest extends TestCase
   {
  @@ -37,7 +37,9 @@
         wakeupIntervalMillis_ = cache_.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
         log("wakeupInterval is " + wakeupIntervalMillis_);
         if (wakeupIntervalMillis_ < 0)
  +      {
            fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
  +      }
   
         t1_ex = t2_ex = null;
         isTrue = true;
  @@ -45,8 +47,7 @@
   
      public void initCaches() throws Exception
      {
  -      cache_ = new CacheImpl();
  -      cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-lru-eviction-service.xml")); // read in generic local xml
  +      cache_ = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-lru-eviction-service.xml", false);// read in generic local xml
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache_.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
         cache_.start();
  @@ -62,8 +63,8 @@
      {
         String rootStr = "/org/jboss/test/data/inuse/";
         Fqn fqn;
  -//      cache_.put("/", "a", "b");
  -//      TestingUtil.sleepThread(wakeupIntervalMillis_ + 500);
  +      //      cache_.put("/", "a", "b");
  +      //      TestingUtil.sleepThread(wakeupIntervalMillis_ + 500);
   
         for (int i = 0; i < 10; i++)
         {
  @@ -158,17 +159,17 @@
   
         int period = (wakeupIntervalMillis_ / 2 + 500);
         log("sleeping for " + period + "ms");
  -      TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
  +      TestingUtil.sleepThread(period);// it really depends the eviction thread time.
         String str = rootStr + "7";
         Fqn fqn = Fqn.fromString(str);
         try
         {
  -         cache_.get(fqn, str);   // just to keep it fresh
  +         cache_.get(fqn, str);// just to keep it fresh
            System.out.println("-- sleeping for " + period + "ms");
  -         TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
  -         cache_.get(fqn, str);   // just to keep it fresh
  +         TestingUtil.sleepThread(period);// it really depends the eviction thread time.
  +         cache_.get(fqn, str);// just to keep it fresh
            System.out.println("-- sleeping for " + period + "ms");
  -         TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
  +         TestingUtil.sleepThread(period);// it really depends the eviction thread time.
            String val = (String) cache_.get(rootStr + "3", rootStr + "3");
            System.out.println("-- val=" + val);
            assertNull("DataNode should be empty ", val);
  @@ -208,19 +209,19 @@
   
         int period = (wakeupIntervalMillis_ / 2 + 500);
         log("period is " + period);
  -//      TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
  +      //      TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
         String str1 = rootStr + "7";
         Fqn fqn1 = Fqn.fromString(str1);
         String str2 = rootStr + "7/7";
         Fqn fqn2 = Fqn.fromString(str2);
         try
         {
  -         cache_.get(fqn1, str1);   // just to keep it fresh
  -         cache_.get(fqn2, str2);   // just to keep it fresh
  -         TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
  -         cache_.get(fqn1, str1);   // just to keep it fresh
  -         cache_.get(fqn2, str2);   // just to keep it fresh
  -         TestingUtil.sleepThread(period);  // it really depends the eviction thread time.
  +         cache_.get(fqn1, str1);// just to keep it fresh
  +         cache_.get(fqn2, str2);// just to keep it fresh
  +         TestingUtil.sleepThread(period);// it really depends the eviction thread time.
  +         cache_.get(fqn1, str1);// just to keep it fresh
  +         cache_.get(fqn2, str2);// just to keep it fresh
  +         TestingUtil.sleepThread(period);// it really depends the eviction thread time.
            String val = (String) cache_.get(rootStr + "7/7", rootStr + "7/7");
            assertNotNull("DataNode should not be empty ", val);
            cache_.remove(fqn1);
  @@ -259,11 +260,13 @@
               {
                  e.printStackTrace();
                  if (t1_ex == null)
  +               {
                     t1_ex = e;
               }
            }
         }
      }
  +   }
   
   
      public void testConcurrentPutAndEvict() throws Exception
  @@ -291,7 +294,7 @@
            log("nodes/locks: " + cache_.getNumberOfNodes() + "/" + cache_.getNumberOfLocksHeld());
            TestingUtil.sleepThread(1000);
            if (counter > 10)
  -         { // run for 10 seconds
  +         {// run for 10 seconds
               isTrue = false;
               break;
            }
  @@ -302,7 +305,7 @@
      {
         try
         {
  -//       String rootStr = "org/jboss/test/data/";
  +         //       String rootStr = "org/jboss/test/data/";
            String rootStr = "/test/testdata";
   
            for (int i = 0; i < 10; i++)
  
  
  
  1.8       +5 -4      JBossCache/tests/functional/org/jboss/cache/eviction/ConcurrentEvictionTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConcurrentEvictionTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/ConcurrentEvictionTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- ConcurrentEvictionTest.java	30 Dec 2006 19:48:45 -0000	1.7
  +++ ConcurrentEvictionTest.java	11 Jan 2007 13:49:05 -0000	1.8
  @@ -11,15 +11,15 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.misc.TestingUtil;
   
   /**
    * Tests cache behavior in the presence of concurrent passivation.
    *
    * @author Brian Stansberry
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public class ConcurrentEvictionTest extends TestCase
   {
  @@ -37,15 +37,16 @@
         initCaches();
         wakeupIntervalMillis_ = cache_.getConfiguration().getEvictionConfig().getWakeupIntervalSeconds() * 1000;
         if (wakeupIntervalMillis_ < 0)
  +      {
            fail("testEviction(): eviction thread wake up interval is illegal " + wakeupIntervalMillis_);
  +      }
   
      }
   
      void initCaches() throws Exception
      {
         TestingUtil.recursiveFileRemove("/tmp/JBossCacheFileCacheLoader");
  -      cache_ = new CacheImpl();
  -      cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-eviction-cacheloader-service.xml")); // read in generic local xml
  +      cache_ = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-eviction-cacheloader-service.xml", false);// read in generic local xml
         cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache_.start();
      }
  
  
  
  1.13      +2 -3      JBossCache/tests/functional/org/jboss/cache/eviction/ElementSizePolicyTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ElementSizePolicyTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/eviction/ElementSizePolicyTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- ElementSizePolicyTest.java	4 Jan 2007 05:35:41 -0000	1.12
  +++ ElementSizePolicyTest.java	11 Jan 2007 13:49:05 -0000	1.13
  @@ -8,10 +8,10 @@
   
   import junit.framework.TestCase;
   import org.jboss.cache.CacheImpl;
  +import org.jboss.cache.DefaultCacheFactory;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Node;
   import org.jboss.cache.NodeSPI;
  -import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.lock.IsolationLevel;
   
   /**
  @@ -49,8 +49,7 @@
   
      void initCaches() throws Exception
      {
  -      cache = new CacheImpl();
  -      cache.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-elementsize-eviction-service.xml"));// read in generic local xml
  +      cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-elementsize-eviction-service.xml", false);// read in generic local xml
         cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
         cache.start();
  
  
  



More information about the jboss-cvs-commits mailing list