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

Manik Surtani msurtani at belmont.prod.atl2.jboss.com
Wed Aug 30 17:05:16 EDT 2006


  User: msurtani
  Date: 06/08/30 17:05:16

  Modified:    tests/functional/org/jboss/cache/optimistic      
                        AbstractOptimisticTestCase.java AsyncCacheTest.java
                        CacheTest.java ConcurrentTransactionTest.java
                        OptimisticVersioningTest.java
                        ThreadedCacheAccessTest.java
  Log:
  fixed up some unit tests
  
  Revision  Changes    Path
  1.38      +0 -0      JBossCache/tests/functional/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  
  
  
  1.6       +81 -80    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.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- AsyncCacheTest.java	20 Jul 2006 08:05:18 -0000	1.5
  +++ AsyncCacheTest.java	30 Aug 2006 21:05:16 -0000	1.6
  @@ -9,18 +9,32 @@
   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.misc.TestingUtil;
   import org.jboss.cache.transaction.DummyTransactionManager;
   
   import javax.transaction.Transaction;
   
  -/**
  - * @author xenephon
  - */
   public class AsyncCacheTest extends AbstractOptimisticTestCase
   {
   
  +   TreeCache cache, cache2;
  +
  +   protected void setUp() throws Exception
  +   {
  +      cache = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
  +      cache2 = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
  +   }
  +
  +   protected void tearDown()
  +   {
  +      super.tearDown();
  +      destroyCache(cache);
  +      destroyCache(cache2);
  +      cache = null;
  +      cache2 = null;
  +   }
  +
       public AsyncCacheTest(String s)
       {
           super(s);
  @@ -29,9 +43,8 @@
       public void testRemoteCacheBroadcast() throws Exception
       {
   
  -
  -        TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
  -        TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
  +      assertEquals(2, cache.getMembers().size());
  +      assertEquals(2, cache2.getMembers().size());
   
           DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -63,7 +76,7 @@
           assertEquals(pojo, cache.get(Fqn.fromString("/one/two"), "key1"));
   
           // allow changes to replicate since this is async
  -        TestingUtil.sleepThread((long)1000);
  +      TestingUtil.sleepThread((long) 1000);
   
           assertEquals(0, cache2.getTransactionTable().getNumGlobalTransactions());
           assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
  @@ -71,19 +84,13 @@
           assertTrue(cache2.exists(Fqn.fromString("/one/two")));
           assertTrue(cache2.exists(Fqn.fromString("/one")));
           assertEquals(pojo, cache2.get(Fqn.fromString("/one/two"), "key1"));
  -
  -
  -        destroyCache(cache);
  -        destroyCache(cache2);
       }
   
   
       public void testTwoWayRemoteCacheBroadcast() throws Exception
       {
  -
  -
  -        TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
  -        TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
  +      assertEquals(2, cache.getMembers().size());
  +      assertEquals(2, cache2.getMembers().size());
   
           DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -115,7 +122,7 @@
           assertEquals(pojo, cache.get(Fqn.fromString("/one/two"), "key1"));
   
           // let the async calls complete
  -        TestingUtil.sleepThread((long)1000);
  +      TestingUtil.sleepThread((long) 1000);
   
           assertEquals(0, cache2.getTransactionTable().getNumGlobalTransactions());
           assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
  @@ -124,11 +131,5 @@
           assertTrue(cache2.exists(Fqn.fromString("/one")));
   
           assertEquals(pojo, cache2.get(Fqn.fromString("/one/two"), "key1"));
  -
  -
  -        destroyCache(cache);
  -        destroyCache(cache2);
  -
  -
       }
   }
  
  
  
  1.22      +359 -336  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.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- CacheTest.java	25 Aug 2006 14:10:10 -0000	1.21
  +++ CacheTest.java	30 Aug 2006 21:05:16 -0000	1.22
  @@ -19,11 +19,11 @@
   import org.jboss.cache.interceptors.OptimisticReplicationInterceptor;
   import org.jboss.cache.interceptors.TxInterceptor;
   import org.jboss.cache.loader.SamplePojo;
  +import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodCallFactory;
   import org.jboss.cache.marshall.MethodDeclarations;
   import org.jboss.cache.transaction.DummyTransactionManager;
   import org.jgroups.Address;
  -import org.jboss.cache.marshall.MethodCall;
   
   import javax.transaction.RollbackException;
   import javax.transaction.Transaction;
  @@ -249,19 +249,36 @@
           remoteGtx.setAddress(new Address()
           {
   
  -            public int compareTo(Object arg0){return 0;}
  +         public int compareTo(Object arg0)
  +         {
  +            return 0;
  +         }
   
  -            public void readFrom(DataInputStream arg0){}
  +         public void readFrom(DataInputStream arg0)
  +         {
  +         }
   
  -            public void writeTo(DataOutputStream arg0){}
  +         public void writeTo(DataOutputStream arg0)
  +         {
  +         }
   
  -            public void readExternal(ObjectInput arg0){}
  +         public void readExternal(ObjectInput arg0)
  +         {
  +         }
   
  -            public void writeExternal(ObjectOutput arg0){}
  +         public void writeExternal(ObjectOutput arg0)
  +         {
  +         }
   
  -            public int size(){return 0;}
  +         public int size()
  +         {
  +            return 0;
  +         }
   
  -            public boolean isMulticastAddress(){return false;}
  +         public boolean isMulticastAddress()
  +         {
  +            return false;
  +         }
   
           });
           //hack the method call to make it have the remote gtx
  @@ -308,6 +325,9 @@
   
           TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
           TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  +      assertEquals(2, cache.getMembers().size());
  +      assertEquals(2, cache2.getMembers().size());
  +
   
           DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  @@ -357,6 +377,9 @@
   
           TreeCache cache = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
           TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  +      assertEquals(2, cache.getMembers().size());
  +      assertEquals(2, cache2.getMembers().size());
  +
   
           DummyTransactionManager mgr = DummyTransactionManager.getInstance();
   
  
  
  
  1.3       +2 -2      JBossCache/tests/functional/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConcurrentTransactionTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/ConcurrentTransactionTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- ConcurrentTransactionTest.java	30 Aug 2006 19:09:57 -0000	1.2
  +++ ConcurrentTransactionTest.java	30 Aug 2006 21:05:16 -0000	1.3
  @@ -25,7 +25,7 @@
         super(name);
      }
   
  -   public void setUp()
  +   protected void setUp()
      {
         try
         {
  @@ -37,7 +37,7 @@
         }
      }
   
  -   public void tearDown()
  +   protected void tearDown()
      {
         if (cache != null)
         {
  
  
  
  1.5       +97 -91    JBossCache/tests/functional/org/jboss/cache/optimistic/OptimisticVersioningTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: OptimisticVersioningTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/OptimisticVersioningTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- OptimisticVersioningTest.java	20 Jul 2006 09:03:54 -0000	1.4
  +++ OptimisticVersioningTest.java	30 Aug 2006 21:05:16 -0000	1.5
  @@ -23,16 +23,30 @@
    */
   public class OptimisticVersioningTest extends AbstractOptimisticTestCase
   {
  +   TreeCache cache1, cache2;
  +
       public OptimisticVersioningTest(String name)
       {
           super(name);
       }
   
  -    public void testVersionPropagation() throws Exception
  +   protected void setUp() throws Exception
  +   {
  +      cache1 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  +      cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  +   }
  +
  +   protected void tearDown()
       {
  -        TreeCache cache1 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  -        TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  +      super.tearDown();
  +      destroyCache(cache1);
  +      destroyCache(cache2);
  +      cache1 = null;
  +      cache2 = null;
  +   }
   
  +   public void testVersionPropagation() throws Exception
  +   {
           Fqn fqn = Fqn.fromString("/a/b");
           String key = "key";
   
  @@ -54,15 +68,10 @@
           Assert.assertEquals("value2", cache1.get(fqn, key));
           Assert.assertEquals("value2", cache2.get(fqn, key));
           Assert.assertEquals("Version info should have propagated", v1, v2);
  -
  -        cache1.stop();
  -        cache2.stop();
       }
   
       public void testTwoCachesUpdatingSimultaneously() throws Exception
       {
  -        TreeCache cache1 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
  -        TreeCache cache2 = createReplicatedCache(Configuration.CacheMode.REPL_SYNC);
           TransactionManager mgr1 = cache1.getTransactionManager();
           TransactionManager mgr2 = cache2.getTransactionManager();
           Transaction tx1, tx2;
  @@ -110,8 +119,5 @@
           v2 = ((OptimisticTreeNode) cache2.get(fqn)).getVersion();
   
           Assert.assertEquals("Version info should have propagated", v1, v2);
  -
  -        cache1.stop();
  -        cache2.stop();
       }
   }
  
  
  
  1.4       +92 -85    JBossCache/tests/functional/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ThreadedCacheAccessTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- ThreadedCacheAccessTest.java	25 Apr 2006 15:18:29 -0000	1.3
  +++ ThreadedCacheAccessTest.java	30 Aug 2006 21:05:16 -0000	1.4
  @@ -35,12 +35,19 @@
       private final String key = "key", value = "value";
   
       private TreeCache cache;
  +   private WorkerThread[] threads;
   
       public ThreadedCacheAccessTest(String name)
       {
           super(name);
       }
   
  +   protected void tearDown()
  +   {
  +      super.tearDown();
  +      destroyCache(cache);
  +   }
  +
       public void testThreadedMostlyReads() throws Exception
       {
           cache = createCache();
  @@ -48,7 +55,7 @@
   
           cache.put(fqn, key, value);
   
  -        WorkerThread[] threads = new WorkerThread[ numThreads ];
  +      threads = new WorkerThread[ numThreads ];
   
           for (int i = 0; i < numThreads; i++)
           {
  
  
  



More information about the jboss-cvs-commits mailing list