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

Manik Surtani msurtani at jboss.com
Thu Jul 20 04:05:18 EDT 2006


  User: msurtani
  Date: 06/07/20 04:05:18

  Modified:    tests/functional/org/jboss/cache/optimistic     
                        AbstractOptimisticTestCase.java AsyncCacheTest.java
                        CacheTest.java NodeInterceptorGetKeyValTest.java
                        NodeInterceptorRemoveKeyValTest.java
  Log:
  Fixed some broken UTs to use the new xml parsers, cache factories, etc.
  
  Revision  Changes    Path
  1.33      +58 -32    JBossCache/tests/functional/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbstractOptimisticTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -b -r1.32 -r1.33
  --- AbstractOptimisticTestCase.java	18 Jul 2006 10:50:47 -0000	1.32
  +++ AbstractOptimisticTestCase.java	20 Jul 2006 08:05:18 -0000	1.33
  @@ -7,6 +7,7 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.CacheListener;
  +import org.jboss.cache.config.Configuration;
   import org.jboss.cache.misc.TestingUtil;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.xml.XmlHelper;
  @@ -58,10 +59,12 @@
       protected TreeCache createCacheUnstarted(boolean optimistic) throws Exception
       {
           TreeCache cache = new TreeCache();
  -        if (optimistic) cache.setNodeLockingScheme("OPTIMISTIC");
  +        Configuration c = new Configuration();
  +        cache.setConfiguration(c);
  +        if (optimistic) c.setNodeLockingScheme("OPTIMISTIC");
   
  -        cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -        cache.setCacheMode("LOCAL");
  +        c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  +        c.setCacheMode("LOCAL");
           return cache;
       }
   
  @@ -111,7 +114,9 @@
       protected TreeCache createCacheWithLoader(boolean passivationEnabled) throws Exception
       {
           TreeCache cache = createCacheUnstarted();
  -        cache.setCacheLoaderConfiguration(getCacheLoaderConfig(true, getTempDir(), passivationEnabled));
  +        Configuration c = cache.getConfiguration();
  +        cache.setConfiguration(c);
  +        c.setCacheLoaderConfiguration(getCacheLoaderConfig(true, getTempDir(), passivationEnabled));
           cache.createService();
           cache.startService();
           return cache;
  @@ -135,11 +140,16 @@
   
       protected TreeCache createPessimisticCache() throws Exception
       {
  -        TreeCache cache = new TreeCache("name", getDefaultProperties(), 5000L);
  +        TreeCache cache = new TreeCache();
  +        Configuration c = new Configuration();
  +        cache.setConfiguration(c);
   
  -        cache.setCacheMode(TreeCache.REPL_SYNC);
  -        cache.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
  -        cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  +        c.setClusterName("name");
  +        c.setInitialStateRetrievalTimeout(5000);
  +        c.setClusterConfig(getDefaultProperties());
  +        c.setCacheModeInt(Configuration.CacheMode.REPL_SYNC);
  +        c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
  +        c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
           cache.createService();
           cache.startService();
   
  @@ -149,11 +159,17 @@
   
       protected TreeCache createPessimisticCacheLocal() throws Exception
       {
  -        TreeCache cache = new TreeCache("name", getDefaultProperties(), 5000L);
  +        TreeCache cache = new TreeCache();
  +        Configuration c = new Configuration();
  +        cache.setConfiguration(c);
   
  -        cache.setCacheMode(TreeCache.LOCAL);
  -        cache.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
  -        cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  +        c.setClusterName("name");
  +        c.setInitialStateRetrievalTimeout(5000);
  +        c.setClusterConfig(getDefaultProperties());
  +
  +        c.setCacheModeInt(Configuration.CacheMode.LOCAL);
  +        c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
  +        c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
           cache.createService();
           cache.startService();
   
  @@ -178,54 +194,64 @@
                   "pbcast.STATE_TRANSFER";
       }
   
  -    protected TreeCache createReplicatedCache(int mode) throws Exception
  +    protected TreeCache createReplicatedCache(Configuration.CacheMode mode) throws Exception
       {
           return createReplicatedCache("test", mode);
       }
   
  -    protected TreeCache createReplicatedCache(String name, int mode) throws Exception
  +    protected TreeCache createReplicatedCache(String name, Configuration.CacheMode mode) throws Exception
       {
  -        TreeCache cache = new TreeCache(name, getDefaultProperties(), 5000L);
  +        TreeCache cache = new TreeCache();
  +        Configuration c = new Configuration();
  +        cache.setConfiguration(c);
   
  -        cache.setCacheMode(mode);
  -        if (mode == TreeCache.REPL_SYNC)
  +        c.setClusterName( name );
  +        c.setInitialStateRetrievalTimeout(5000);
  +        c.setClusterConfig(getDefaultProperties());
  +        c.setCacheModeInt(mode);
  +        if (mode == Configuration.CacheMode.REPL_SYNC)
           {
               // make sure commits and rollbacks are sync as well
  -            cache.setSyncCommitPhase(true);
  -            cache.setSyncRollbackPhase(true);
  +            c.setSyncCommitPhase(true);
  +            c.setSyncRollbackPhase(true);
           }
  -        cache.setNodeLockingScheme("OPTIMISTIC");
  -        cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  +        c.setNodeLockingScheme("OPTIMISTIC");
  +        c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
           cache.createService();
           cache.startService();
   
           return cache;
       }
   
  -    protected TreeCache createReplicatedCacheWithLoader(boolean shared, int cacheMode) throws Exception
  +    protected TreeCache createReplicatedCacheWithLoader(boolean shared, Configuration.CacheMode cacheMode) throws Exception
       {
           return createReplicatedCacheWithLoader("temp-loader", shared, cacheMode);
       }
   
       protected TreeCache createReplicatedCacheWithLoader(boolean shared) throws Exception
       {
  -        return createReplicatedCacheWithLoader("temp-loader", shared, TreeCache.REPL_SYNC);
  +        return createReplicatedCacheWithLoader("temp-loader", shared, Configuration.CacheMode.REPL_SYNC);
       }
   
       protected TreeCache createReplicatedCacheWithLoader(String name, boolean shared) throws Exception
       {
  -        return createReplicatedCacheWithLoader(name, shared, TreeCache.REPL_SYNC);
  +        return createReplicatedCacheWithLoader(name, shared, Configuration.CacheMode.REPL_SYNC);
       }
   
  -    protected TreeCache createReplicatedCacheWithLoader(String name, boolean shared, int cacheMode) throws Exception
  +    protected TreeCache createReplicatedCacheWithLoader(String name, boolean shared, Configuration.CacheMode cacheMode) throws Exception
       {
  -        TreeCache cache = new TreeCache(name, getDefaultProperties(), 5000L);
  -        cache.setCacheMode(cacheMode);
  -        cache.setSyncCommitPhase(true);
  -        cache.setSyncRollbackPhase(true);
  -        cache.setNodeLockingScheme("OPTIMISTIC");
  -        cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -        cache.setCacheLoaderConfiguration(getCacheLoaderConfig(shared, shared ? getTempDir(name + "-shared") : getTempDir(name + instanceNumber++), false));
  +        TreeCache cache = new TreeCache();
  +        Configuration c = new Configuration();
  +        cache.setConfiguration(c);
  +        c.setClusterName(name);
  +        c.setInitialStateRetrievalTimeout(5000);
  +        c.setClusterConfig(getDefaultProperties());
  +        c.setCacheModeInt(cacheMode);
  +        c.setSyncCommitPhase(true);
  +        c.setSyncRollbackPhase(true);
  +        c.setNodeLockingScheme("OPTIMISTIC");
  +        c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  +        c.setCacheLoaderConfiguration(getCacheLoaderConfig(shared, shared ? getTempDir(name + "-shared") : getTempDir(name + instanceNumber++), false));
   
           cache.createService();
           cache.startService();
  
  
  
  1.5       +5 -4      JBossCache/tests/functional/org/jboss/cache/optimistic/AsyncCacheTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AsyncCacheTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/AsyncCacheTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- AsyncCacheTest.java	5 May 2006 12:06:58 -0000	1.4
  +++ AsyncCacheTest.java	20 Jul 2006 08:05:18 -0000	1.5
  @@ -8,6 +8,7 @@
   import org.jboss.cache.GlobalTransaction;
   import org.jboss.cache.TransactionTable;
   import org.jboss.cache.TreeCache;
  +import org.jboss.cache.config.Configuration;
   import org.jboss.cache.misc.TestingUtil;
   import org.jboss.cache.loader.SamplePojo;
   import org.jboss.cache.transaction.DummyTransactionManager;
  @@ -29,8 +30,8 @@
       {
   
   
  -        TreeCache cache = createReplicatedCache(TreeCache.REPL_ASYNC);
  -        TreeCache cache2 = createReplicatedCache(TreeCache.REPL_ASYNC);
  +        TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
  +        TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
   
           DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -81,8 +82,8 @@
       {
   
   
  -        TreeCache cache = createReplicatedCache(TreeCache.REPL_ASYNC);
  -        TreeCache cache2 = createReplicatedCache(TreeCache.REPL_ASYNC);
  +        TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
  +        TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
   
           DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  
  
  
  1.18      +4 -4      JBossCache/tests/functional/org/jboss/cache/optimistic/CacheTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/CacheTest.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- CacheTest.java	16 May 2006 22:42:26 -0000	1.17
  +++ CacheTest.java	20 Jul 2006 08:05:18 -0000	1.18
  @@ -98,13 +98,13 @@
           TreeCache cache = createCacheWithListener();
   
           Interceptor txInterceptor = new TxInterceptor();
  -        txInterceptor.setCache(cache);
  +        txInterceptor.setCache(cache.getSPI());
           Interceptor replicationInterceptor = new OptimisticReplicationInterceptor();
  -        replicationInterceptor.setCache(cache);
  +        replicationInterceptor.setCache(cache.getSPI());
           Interceptor createInterceptor = new OptimisticCreateIfNotExistsInterceptor();
  -        createInterceptor.setCache(cache);
  +        createInterceptor.setCache(cache.getSPI());
           Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -        nodeInterceptor.setCache(cache);
  +        nodeInterceptor.setCache(cache.getSPI());
           MockInterceptor dummy = new MockInterceptor();
           dummy.setCache(cache);
   
  
  
  
  1.7       +20 -20    JBossCache/tests/functional/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeInterceptorGetKeyValTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- NodeInterceptorGetKeyValTest.java	26 Jan 2006 20:36:29 -0000	1.6
  +++ NodeInterceptorGetKeyValTest.java	20 Jul 2006 08:05:18 -0000	1.7
  @@ -31,9 +31,9 @@
           final TreeCache cache = createCacheWithListener(listener);
   
           Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
  -        interceptor.setCache(cache);
  +        interceptor.setCache(cache.getSPI());
           Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -        nodeInterceptor.setCache(cache);
  +        nodeInterceptor.setCache(cache.getSPI());
           MockInterceptor dummy = new MockInterceptor();
           dummy.setCache(cache);
   
  @@ -48,8 +48,8 @@
           Transaction tx = mgr.getTransaction();
   
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
  +        InvocationContext.getCurrent().setTransaction(tx);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx));
   
           SamplePojo pojo = new SamplePojo(21, "test");
   
  @@ -84,8 +84,8 @@
           Transaction tx2 = mgr.getTransaction();
   
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx2);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2));
  +        InvocationContext.getCurrent().setTransaction(tx2);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx2));
   
           assertNull(cache.get("/one/two", "key1"));
           mgr.commit();
  @@ -99,9 +99,9 @@
           final TreeCache cache = createCacheWithListener(listener);
   
           Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
  -        interceptor.setCache(cache);
  +        interceptor.setCache(cache.getSPI());
           Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -        nodeInterceptor.setCache(cache);
  +        nodeInterceptor.setCache(cache.getSPI());
           MockInterceptor dummy = new MockInterceptor();
           dummy.setCache(cache);
   
  @@ -116,8 +116,8 @@
           Transaction tx = mgr.getTransaction();
   
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
  +        InvocationContext.getCurrent().setTransaction(tx);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx));
   
           SamplePojo pojo = new SamplePojo(21, "test");
   
  @@ -158,9 +158,9 @@
           final TreeCache cache = createCacheWithListener(listener);
   
           Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
  -        interceptor.setCache(cache);
  +        interceptor.setCache(cache.getSPI());
           Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -        nodeInterceptor.setCache(cache);
  +        nodeInterceptor.setCache(cache.getSPI());
           MockInterceptor dummy = new MockInterceptor();
           dummy.setCache(cache);
   
  @@ -175,8 +175,8 @@
           Transaction tx = mgr.getTransaction();
   
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
  +        InvocationContext.getCurrent().setTransaction(tx);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx));
   
           SamplePojo pojo = new SamplePojo(21, "test");
   
  @@ -216,9 +216,9 @@
           final TreeCache cache = createCacheWithListener(listener);
   
           Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
  -        interceptor.setCache(cache);
  +        interceptor.setCache(cache.getSPI());
           Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -        nodeInterceptor.setCache(cache);
  +        nodeInterceptor.setCache(cache.getSPI());
           MockInterceptor dummy = new MockInterceptor();
           dummy.setCache(cache);
   
  @@ -233,8 +233,8 @@
           Transaction tx = mgr.getTransaction();
   
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
  +        InvocationContext.getCurrent().setTransaction(tx);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx));
   
           SamplePojo pojo = new SamplePojo(21, "test");
   
  @@ -248,8 +248,8 @@
           mgr.begin();
           Transaction tx2 = mgr.getTransaction();
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx2);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2));
  +        InvocationContext.getCurrent().setTransaction(tx2);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx2));
   
           SamplePojo pojo2 = new SamplePojo(22, "test2");
   
  
  
  
  1.7       +12 -12    JBossCache/tests/functional/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeInterceptorRemoveKeyValTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- NodeInterceptorRemoveKeyValTest.java	26 Jan 2006 20:36:29 -0000	1.6
  +++ NodeInterceptorRemoveKeyValTest.java	20 Jul 2006 08:05:18 -0000	1.7
  @@ -40,9 +40,9 @@
           final TreeCache cache = createCacheWithListener(listener);
   
           Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
  -        interceptor.setCache(cache);
  +        interceptor.setCache(cache.getSPI());
           Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -        nodeInterceptor.setCache(cache);
  +        nodeInterceptor.setCache(cache.getSPI());
           MockInterceptor dummy = new MockInterceptor();
           dummy.setCache(cache);
   
  @@ -57,8 +57,8 @@
           Transaction tx = mgr.getTransaction();
   
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
  +        InvocationContext.getCurrent().setTransaction(tx);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx));
   
           cache.remove("/one/two", "keyOne");
   
  @@ -91,9 +91,9 @@
           final TreeCache cache = createCacheWithListener(listener);
   
           Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
  -        interceptor.setCache(cache);
  +        interceptor.setCache(cache.getSPI());
           Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -        nodeInterceptor.setCache(cache);
  +        nodeInterceptor.setCache(cache.getSPI());
           MockInterceptor dummy = new MockInterceptor();
           dummy.setCache(cache);
   
  @@ -108,8 +108,8 @@
           Transaction tx = mgr.getTransaction();
   
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
  +        InvocationContext.getCurrent().setTransaction(tx);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx));
   
           SamplePojo pojo = new SamplePojo(21, "test");
           Map temp = new HashMap();
  @@ -149,9 +149,9 @@
           final TreeCache cache = createCacheWithListener(listener);
   
           Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
  -        interceptor.setCache(cache);
  +        interceptor.setCache(cache.getSPI());
           Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
  -        nodeInterceptor.setCache(cache);
  +        nodeInterceptor.setCache(cache.getSPI());
           MockInterceptor dummy = new MockInterceptor();
           dummy.setCache(cache);
   
  @@ -166,8 +166,8 @@
           Transaction tx = mgr.getTransaction();
   
           // inject InvocationContext
  -        cache.getInvocationContext().setTransaction(tx);
  -        cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
  +        InvocationContext.getCurrent().setTransaction(tx);
  +        InvocationContext.getCurrent().setGlobalTransaction(cache.getCurrentTransaction(tx));
   
           SamplePojo pojo = new SamplePojo(21, "test");
           Map temp = new HashMap();
  
  
  



More information about the jboss-cvs-commits mailing list