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

Manik Surtani msurtani at jboss.com
Wed Sep 6 11:31:01 EDT 2006


  User: msurtani
  Date: 06/09/06 11:31:01

  Modified:    tests/functional/org/jboss/cache/transaction           
                        AbortionTest.java ConcurrentBankTest.java
                        ConcurrentTransactionalTest.java DeadlockTest.java
                        InvocationContextCleanupTest.java
                        IsolationLevelNoneTest.java
                        IsolationLevelReadCommittedNodeCreationRollbackTest.java
                        IsolationLevelReadCommittedTest.java
                        PrepareTxTest.java
                        ReplicatedTransactionDeadlockTest.java
                        TransactionTest.java
  Log:
  Removed TreeCache dependency on ServiceMBeanSupport
  
  Revision  Changes    Path
  1.4       +187 -187  JBossCache/tests/functional/org/jboss/cache/transaction/AbortionTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AbortionTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/AbortionTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- AbortionTest.java	20 Jul 2006 10:32:09 -0000	1.3
  +++ AbortionTest.java	6 Sep 2006 15:31:00 -0000	1.4
  @@ -55,7 +55,7 @@
       {
           MyTC c = new MyTC();
           c.getConfiguration().setCacheMode("REPL_SYNC");
  -        c.getConfiguration().setClusterConfig( getJGroupsStack() );
  +      c.getConfiguration().setClusterConfig(getJGroupsStack());
           c.getConfiguration().setFetchInMemoryState(false);
           if (!notifying)
           {
  @@ -65,7 +65,7 @@
           {
               c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.NotifyingTransactionManager");
           }
  -        c.startService();
  +      c.start();
           return c;
       }
   
  @@ -88,8 +88,8 @@
       {
           if (c != null)
           {
  -            c.stopService();
  -            c.destroyService();
  +         c.stop();
  +         c.destroy();
           }
       }
   
  @@ -216,9 +216,9 @@
               super();
           }
   
  -        public void startService() throws Exception
  +      public void start() throws Exception
           {
  -            super.startService();
  +         super.start();
               myChannel = channel;
               myDispatcher = disp;
           }
  
  
  
  1.6       +82 -53    JBossCache/tests/functional/org/jboss/cache/transaction/ConcurrentBankTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConcurrentBankTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/ConcurrentBankTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- ConcurrentBankTest.java	20 Jul 2006 11:14:18 -0000	1.5
  +++ ConcurrentBankTest.java	6 Sep 2006 15:31:00 -0000	1.6
  @@ -21,25 +21,24 @@
   import java.util.Set;
   
   /**
  - *
    * Unit test for local TreeCache with concurrent transactions.
    * Uses locking and multiple threads to test concurrent r/w access to the tree.
    *
    * @author <a href="mailto:spohl at users.sourceforge.net">Stefan Pohl</a>
    * @author Ben Wang
  - * @version $Revision: 1.5 $
  - *
  + * @version $Revision: 1.6 $
    */
  -public class ConcurrentBankTest extends TestCase {
  +public class ConcurrentBankTest extends TestCase
  +{
      TreeCache cache;
  -   private static Log logger_=LogFactory.getLog(ConcurrentBankTest.class);
  +   private static Log logger_ = LogFactory.getLog(ConcurrentBankTest.class);
      static Properties p = null;
      String old_factory = null;
      final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
      final String NODE = "/cachetest";
      final int ROLLBACK_CHANCE = 100;
   
  -   static String customer[] = { "cu1", "cu2", "cu3" };
  +   static String customer[] = {"cu1", "cu2", "cu3"};
      static final int BOOKINGS = 1000;
      static boolean _testFailedinThread = false;
   
  @@ -48,8 +47,9 @@
         super(name);
      }
   
  -   public void failMain() {
  -      _testFailedinThread=true;
  +   public void failMain()
  +   {
  +      _testFailedinThread = true;
      }
   
      public void setUp() throws Exception
  @@ -58,7 +58,8 @@
         old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
         DummyTransactionManager.getInstance();
  -      if (p == null) {
  +      if (p == null)
  +      {
            p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
         }
  @@ -70,17 +71,18 @@
         // XML file above only sets REPEATABLE-READ
         cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
   
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
      }
   
      public void tearDown() throws Exception
      {
         super.tearDown();
  -      cache.stopService();
  +      cache.stop();
         // BW. kind of a hack to destroy jndi binding and thread local tx before next run.
         DummyTransactionManager.destroy();
  -      if (old_factory != null) {
  +      if (old_factory != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
            old_factory = null;
         }
  @@ -89,8 +91,10 @@
      public void testConcurrentBooking()
      {
         Teller one, two;
  -      try {
  -         if(cache.get(NODE)==null) {
  +      try
  +      {
  +         if (cache.get(NODE) == null)
  +         {
               cache.put(NODE, "cu1", new Integer(1000));
               cache.put(NODE, "cu2", new Integer(1000));
               cache.put(NODE, "cu3", new Integer(1000));
  @@ -100,17 +104,21 @@
            two = new Teller("two", cache);
   
            one.start();
  -          TestingUtil.sleepThread((long)100);
  +         TestingUtil.sleepThread((long) 100);
             two.start();
            one.join();
            two.join();
   
  -         log("lock info:\n" + cache.printLockInfo()+_testFailedinThread);
  -         if(_testFailedinThread) fail();
  -      } catch (Exception e) {
  +         log("lock info:\n" + cache.printLockInfo() + _testFailedinThread);
  +         if (_testFailedinThread) fail();
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
            fail(e.toString());
  -      } finally {
  +      }
  +      finally
  +      {
            /*
            try {
               cache.remove(NODE);
  @@ -152,20 +160,23 @@
         {
            int count = customer.length;
            UserTransaction tx = null;
  -         try {
  +         try
  +         {
               tx = (UserTransaction) new InitialContext(p).lookup("UserTransaction");
   
               boolean again = false;
               int src = 0;
               int dst = 0;
               int amo = 0;
  -            int anz =0;
  -            while(anz<BOOKINGS) {
  -               if(!again) {
  -                  src = (int) (Math.random()*count);
  -                  dst = (int) (Math.random()*(count-1));
  -                  amo =1+ (int) (Math.random()*20);
  -                  if(dst>=src) dst++;
  +            int anz = 0;
  +            while (anz < BOOKINGS)
  +            {
  +               if (!again)
  +               {
  +                  src = (int) (Math.random() * count);
  +                  dst = (int) (Math.random() * (count - 1));
  +                  amo = 1 + (int) (Math.random() * 20);
  +                  if (dst >= src) dst++;
                  }
   
                  tx.begin();
  @@ -173,26 +184,30 @@
                  tx.commit();  // releases read lock
   
                  int sum = sumAccounts(accounts);
  -               log(anz+": "+accounts+" Summe: "+sum);
  +               log(anz + ": " + accounts + " Summe: " + sum);
                  // the sum of all accounts always has to be 3000
  -               if(sum!=3000) {
  +               if (sum != 3000)
  +               {
                     failMain();
                     return; // terminate thread
                  }
                  assertEquals("the sum of all accounts always has to be 3000", 3000, sum);
   
  -               try {
  +               try
  +               {
                     tx.begin();
                     deposit(customer[src], customer[dst], amo, tx);  // gets write lock
                     tx.commit(); // releases write lock
                     again = false;
                  }
  -               catch(TimeoutException timeout_ex) {
  +               catch (TimeoutException timeout_ex)
  +               {
                     System.out.println("transaction is rolled back, will try again (ex=" + timeout_ex.getClass() + ")");
                     tx.rollback();
                     again = true;
                  }
  -               catch(Throwable e) {
  +               catch (Throwable e)
  +               {
                     System.out.println("transaction is rolled back, will try again (ex=" + e.getMessage() + ")");
                     tx.rollback();
                     again = true;
  @@ -200,57 +215,71 @@
                  anz++;
                  yield();
               }
  -         } catch (Throwable t) {
  +         }
  +         catch (Throwable t)
  +         {
               t.printStackTrace();
               fail(t.toString());
            }
         }
  +
         /**
          * Posting
          */
  -      public void deposit(String from, String to, int amount, UserTransaction tx) throws Exception {
  -         log("deposit("+from+", "+to+", "+amount+") called.");
  +      public void deposit(String from, String to, int amount, UserTransaction tx) throws Exception
  +      {
  +         log("deposit(" + from + ", " + to + ", " + amount + ") called.");
            int act;
            // debit
            act = ((Integer) cache.get(NODE, from)).intValue();
  -         cache.put(NODE, from, new Integer(act-amount));
  -         log("deposit("+from+", "+to+", "+amount+") debited.");
  +         cache.put(NODE, from, new Integer(act - amount));
  +         log("deposit(" + from + ", " + to + ", " + amount + ") debited.");
   
            // eventually rollback the transaction
  -         if((int) (Math.random()*ROLLBACK_CHANCE) == 0) {
  -            log("!!!manually set rollback ("+from+", "+to+", "+amount+").");
  +         if ((int) (Math.random() * ROLLBACK_CHANCE) == 0)
  +         {
  +            log("!!!manually set rollback (" + from + ", " + to + ", " + amount + ").");
               tx.setRollbackOnly();
               throw new Exception("Manually set rollback!");
            }
   
            // credit
            act = ((Integer) cache.get(NODE, to)).intValue();
  -         cache.put(NODE, to, new Integer(act+amount));
  +         cache.put(NODE, to, new Integer(act + amount));
   
  -         log("deposit("+from+", "+to+", "+amount+") finished.");
  +         log("deposit(" + from + ", " + to + ", " + amount + ") finished.");
         }
  +
         /**
          * retrieving amounts of accounts
          */
  -      public HashMap getAccounts() throws CacheException {
  +      public HashMap getAccounts() throws CacheException
  +      {
            log("getAccounts() called.");
            HashMap result = new HashMap();
  -         try {
  +         try
  +         {
               Set set = cache.getKeys(NODE);  // gets read lock
               Iterator iter = set.iterator();
  -            while(iter.hasNext()) {
  +            while (iter.hasNext())
  +            {
                  String name = (String) iter.next();
                  result.put(name, cache.get(NODE, name));
               }
               return result;
  -         } catch(CacheException ce) {
  +         }
  +         catch (CacheException ce)
  +         {
               throw ce;
            }
         }
  -      protected int sumAccounts(HashMap map) {
  +
  +      protected int sumAccounts(HashMap map)
  +      {
            Iterator iter = map.values().iterator();
            int result = 0;
  -         while(iter.hasNext()) {
  +         while (iter.hasNext())
  +         {
               result += ((Integer) iter.next()).intValue();
            }
            return result;
  
  
  
  1.5       +65 -41    JBossCache/tests/functional/org/jboss/cache/transaction/ConcurrentTransactionalTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConcurrentTransactionalTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/ConcurrentTransactionalTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- ConcurrentTransactionalTest.java	20 Jul 2006 11:48:26 -0000	1.4
  +++ ConcurrentTransactionalTest.java	6 Sep 2006 15:31:00 -0000	1.5
  @@ -32,14 +32,14 @@
    * Unit test for local TreeCache. Use locking and multiple threads to test
    * concurrent access to the tree.
    *
  - * @version $Id: ConcurrentTransactionalTest.java,v 1.4 2006/07/20 11:48:26 msurtani Exp $
  + * @version $Id: ConcurrentTransactionalTest.java,v 1.5 2006/09/06 15:31:00 msurtani Exp $
    */
   public class ConcurrentTransactionalTest extends TestCase
   {
      TreeCache cache;
  -   private Log logger_=LogFactory.getLog(ConcurrentTransactionalTest.class);
  -   static Throwable thread_ex=null;
  -   final int NUM=10000;
  +   private Log logger_ = LogFactory.getLog(ConcurrentTransactionalTest.class);
  +   static Throwable thread_ex = null;
  +   final int NUM = 10000;
      static Properties p = null;
      String old_factory = null;
      final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
  @@ -55,7 +55,8 @@
         old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
         DummyTransactionManager.getInstance();
  -      if (p == null) {
  +      if (p == null)
  +      {
            p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
         }
  @@ -72,15 +73,19 @@
         cache.put("/a/b/c", null);
      }
   
  -   private UserTransaction getTransaction() {
  +   private UserTransaction getTransaction()
  +   {
         UserTransaction tx = null;
  -      try {
  +      try
  +      {
            tx = (UserTransaction) new InitialContext(p).lookup("UserTransaction");
  -      } catch (NamingException e) {
  +      }
  +      catch (NamingException e)
  +      {
            e.printStackTrace();
         }
   
  -      if(tx == null)
  +      if (tx == null)
            throw new RuntimeException("Tx is null");
   
         return tx;
  @@ -89,10 +94,11 @@
      public void tearDown() throws Exception
      {
         super.tearDown();
  -      cache.stopService();
  -      thread_ex=null;
  +      cache.stop();
  +      thread_ex = null;
         DummyTransactionManager.destroy();
  -      if (old_factory != null) {
  +      if (old_factory != null)
  +      {
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old_factory);
            old_factory = null;
         }
  @@ -110,9 +116,11 @@
         work_();
      }
   
  -   private void work_() throws Throwable {
  +   private void work_() throws Throwable
  +   {
         Updater one, two;
  -      try {
  +      try
  +      {
            one = new Updater("Thread one");
            two = new Updater("Thread two");
            long current = System.currentTimeMillis();
  @@ -120,40 +128,46 @@
            two.start();
            one.join();
            two.join();
  -         if(thread_ex != null)
  +         if (thread_ex != null)
               throw thread_ex;
   
            long now = System.currentTimeMillis();
  -         log("*** Time elapsed: " + (now-current));
  +         log("*** Time elapsed: " + (now - current));
   
            System.out.println("cache content: " + cache.toString());
            Set keys = cache.getKeys("/a/b/c");
            System.out.println("number of keys=" + keys.size());
   
  -         if(keys.size() != NUM) {
  +         if (keys.size() != NUM)
  +         {
               scanForNullValues(keys);
   
  -            try {
  +            try
  +            {
                  System.out.println("size=" + keys.size());
  -               List l=new LinkedList(keys);
  +               List l = new LinkedList(keys);
                  Collections.sort(l);
                  System.out.println("keys: " + l);
  -               for(int i=0; i < NUM; i++) {
  -                  if(!l.contains(new Integer(i)))
  +               for (int i = 0; i < NUM; i++)
  +               {
  +                  if (!l.contains(new Integer(i)))
                        System.out.println("missing: " + i);
                  }
   
  -               LinkedList duplicates=new LinkedList();
  -               for(Iterator it=l.iterator(); it.hasNext();) {
  -                  Integer integer=(Integer)it.next();
  -                  if(duplicates.contains(integer)) {
  +               LinkedList duplicates = new LinkedList();
  +               for (Iterator it = l.iterator(); it.hasNext();)
  +               {
  +                  Integer integer = (Integer) it.next();
  +                  if (duplicates.contains(integer))
  +                  {
                        System.out.println(integer + " is a duplicate");
                     }
                     else
                        duplicates.add(integer);
                  }
               }
  -            catch(Exception e1) {
  +            catch (Exception e1)
  +            {
                  e1.printStackTrace();
               }
            }
  @@ -161,16 +175,20 @@
            assertEquals(NUM, keys.size());
            log("lock info:\n" + cache.printLockInfo());
   
  -      } catch (Exception e) {
  +      }
  +      catch (Exception e)
  +      {
            e.printStackTrace();
            fail(e.toString());
         }
      }
   
  -   private void scanForNullValues(Set keys) {
  -      for(Iterator it=keys.iterator(); it.hasNext();) {
  -         Object o=it.next();
  -         if(o == null)
  +   private void scanForNullValues(Set keys)
  +   {
  +      for (Iterator it = keys.iterator(); it.hasNext();)
  +      {
  +         Object o = it.next();
  +         if (o == null)
               System.err.println("found a null value in keys");
         }
      }
  @@ -181,19 +199,24 @@
      }
   
   
  -   class Updater extends Thread {
  -      String val=null;
  +   class Updater extends Thread
  +   {
  +      String val = null;
         UserTransaction tx;
   
  -      Updater(String name) {
  -         this.val=name;
  +      Updater(String name)
  +      {
  +         this.val = name;
         }
   
  -      public void run() {
  -         try {
  +      public void run()
  +      {
  +         try
  +         {
               log("adding data");
  -            tx=getTransaction();
  -            for(int i=0; i < NUM; i++) {
  +            tx = getTransaction();
  +            for (int i = 0; i < NUM; i++)
  +            {
                  log("adding data i=" + i);
                  tx.begin();
                  cache.put("/a/b/c", new Integer(i), val);
  @@ -201,9 +224,10 @@
                  yield();
               }
            }
  -         catch(Throwable t) {
  +         catch (Throwable t)
  +         {
               t.printStackTrace();
  -            thread_ex=t;
  +            thread_ex = t;
            }
         }
      }
  
  
  
  1.6       +250 -182  JBossCache/tests/functional/org/jboss/cache/transaction/DeadlockTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DeadlockTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/DeadlockTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- DeadlockTest.java	20 Jul 2006 10:32:09 -0000	1.5
  +++ DeadlockTest.java	6 Sep 2006 15:31:00 -0000	1.6
  @@ -17,10 +17,10 @@
   import org.jboss.cache.Fqn;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.config.Configuration;
  -import org.jboss.cache.misc.TestingUtil;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.lock.TimeoutException;
   import org.jboss.cache.lock.UpgradeException;
  +import org.jboss.cache.misc.TestingUtil;
   
   import javax.transaction.NotSupportedException;
   import javax.transaction.SystemException;
  @@ -30,66 +30,73 @@
    * Tests transactional access to a local TreeCache, with concurrent (deadlock-prone) access.
    * Note: we use DummpyTranasctionManager to replace jta
    *
  - * @version $Id: DeadlockTest.java,v 1.5 2006/07/20 10:32:09 msurtani Exp $
  + * @version $Id: DeadlockTest.java,v 1.6 2006/09/06 15:31:00 msurtani Exp $
    */
  -public class DeadlockTest extends TestCase {
  -   TreeCache   cache=null;
  +public class DeadlockTest extends TestCase
  +{
  +   TreeCache cache = null;
      Exception   thread_ex;
   
  -   final Fqn NODE=Fqn.fromString("/a/b/c");
  -   final Fqn PARENT_NODE=Fqn.fromString("/a/b");
  -   final Fqn FQN1=NODE;
  -   final Fqn FQN2=Fqn.fromString("/1/2/3");
  -   final Log log=LogFactory.getLog(DeadlockTest.class);
  +   final Fqn NODE = Fqn.fromString("/a/b/c");
  +   final Fqn PARENT_NODE = Fqn.fromString("/a/b");
  +   final Fqn FQN1 = NODE;
  +   final Fqn FQN2 = Fqn.fromString("/1/2/3");
  +   final Log log = LogFactory.getLog(DeadlockTest.class);
   
   
  -   public DeadlockTest(String name) {
  +   public DeadlockTest(String name)
  +   {
         super(name);
      }
   
  -   public void setUp() throws Exception {
  +   public void setUp() throws Exception
  +   {
         super.setUp();
         DummyTransactionManager.getInstance();
  -      cache=new TreeCache();
  +      cache = new TreeCache();
         cache.getConfiguration().setInitialStateRetrievalTimeout(10000);
         cache.getConfiguration().setClusterName("test");
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
         cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
         cache.getConfiguration().setLockAcquisitionTimeout(3000);
  -      cache.createService();
  -      cache.startService();
  -      thread_ex=null;
  +      cache.create();
  +      cache.start();
  +      thread_ex = null;
      }
   
   
  -   public void tearDown() throws Exception {
  +   public void tearDown() throws Exception
  +   {
         super.tearDown();
  -      if(cache != null)
  -         cache.stopService();
  -      if(thread_ex != null)
  +      if (cache != null)
  +         cache.stop();
  +      if (thread_ex != null)
            throw thread_ex;
      }
   
   
  -   public void testConcurrentUpgrade() throws CacheException, InterruptedException {
  -      MyThread t1=new MyThreadTimeout("MyThread#1", NODE);
  -      MyThread t2=new MyThread("MyThread#2", NODE);
  +   public void testConcurrentUpgrade() throws CacheException, InterruptedException
  +   {
  +      MyThread t1 = new MyThreadTimeout("MyThread#1", NODE);
  +      MyThread t2 = new MyThread("MyThread#2", NODE);
   
         cache.put(NODE, null);
   
         t1.start();
         t2.start();
   
  -       TestingUtil.sleepThread((long)5000);
  +      TestingUtil.sleepThread((long) 5000);
   
  -       synchronized(t1) {
  +      synchronized (t1)
  +      {
             t1.notify(); // t1 will now try to upgrade RL to WL, but fails b/c t2 still has a RL
          }
   
  -       TestingUtil.sleepThread((long)5000);
  +      TestingUtil.sleepThread((long) 5000);
   
  -       synchronized(t2) {
  +      synchronized (t2)
  +      {
             t2.notify(); // t1 should now be able to upgrade because t1 was rolled back (RL was removed)
          }
   
  @@ -102,9 +109,10 @@
       * Typical deadlock: t1 acquires WL on /a/b/c, t2 WL on /1/2/3, then t1 attempts to get WL on /1/2/3 (locked by t2),
       * and t2 tries to acquire WL on /a/b/c. One (or both) of the 2 transactions is going to timeout and roll back.
       */
  -   public void testPutDeadlock() throws CacheException, InterruptedException {
  -      MyPutter t1=new MyPutterTimeout("MyPutter#1", FQN1, FQN2);
  -      MyPutter t2=new MyPutter("MyPutter#2", FQN2, FQN1);
  +   public void testPutDeadlock() throws CacheException, InterruptedException
  +   {
  +      MyPutter t1 = new MyPutterTimeout("MyPutter#1", FQN1, FQN2);
  +      MyPutter t2 = new MyPutter("MyPutter#2", FQN2, FQN1);
   
         cache.put(FQN1, null);
         cache.put(FQN2, null);
  @@ -112,15 +120,17 @@
         t1.start();
         t2.start();
   
  -       TestingUtil.sleepThread((long)1000);
  +      TestingUtil.sleepThread((long) 1000);
   
  -       synchronized(t1) {
  +      synchronized (t1)
  +      {
             t1.notify(); // t1 will now try to acquire WL on /1/2/3 (held by t2) - this will time out
          }
   
  -       TestingUtil.sleepThread((long)1000);
  +      TestingUtil.sleepThread((long) 1000);
   
  -       synchronized(t2) {
  +      synchronized (t2)
  +      {
             t2.notify(); // t2 tries to acquire WL on /a/b/c (held by t1)
          }
   
  @@ -129,21 +139,25 @@
      }
   
   
  -   public void testCreateIfNotExistsLogic() throws CacheException, InterruptedException {
  +   public void testCreateIfNotExistsLogic() throws CacheException, InterruptedException
  +   {
         cache.put(NODE, null);
   
  -      class T0 extends GenericThread {
  -         public T0(String name) {
  +      class T0 extends GenericThread
  +      {
  +         public T0(String name)
  +         {
               super(name);
            }
   
  -         protected void _run() throws Exception {
  -            Transaction myTx=startTransaction();
  +         protected void _run() throws Exception
  +         {
  +            Transaction myTx = startTransaction();
               log("put(" + NODE + ")");
               cache.put(NODE, null);
               log("put(" + NODE + "): OK");
   
  -            synchronized(this) {wait();}
  +            synchronized (this) {wait();}
   
               log("remove(" + NODE + ")");
               cache.remove(NODE);
  @@ -154,13 +168,16 @@
            }
         }
   
  -      class T1 extends GenericThread {
  -         public T1(String name) {
  +      class T1 extends GenericThread
  +      {
  +         public T1(String name)
  +         {
               super(name);
            }
   
  -         protected void _run() throws Exception {
  -            Transaction myTx=startTransaction();
  +         protected void _run() throws Exception
  +         {
  +            Transaction myTx = startTransaction();
               log("put(" + NODE + ")");
               cache.put(NODE, null);
               log("put(" + NODE + "): OK");
  @@ -171,13 +188,14 @@
   
         }
   
  -      T0 t0=new T0("T0");
  +      T0 t0 = new T0("T0");
         t0.start();
  -       TestingUtil.sleepThread((long)500);
  -       T1 t1=new T1("T1");
  +      TestingUtil.sleepThread((long) 500);
  +      T1 t1 = new T1("T1");
         t1.start();
  -       TestingUtil.sleepThread((long)500);
  -       synchronized(t0) {
  +      TestingUtil.sleepThread((long) 500);
  +      synchronized (t0)
  +      {
             t0.notify();
          }
         t0.join();
  @@ -185,136 +203,158 @@
      }
   
   
  -   public void testMoreThanOneUpgrader() throws Exception {
  -      final int NUM=2;
  -      final Object lock=new Object();
  +   public void testMoreThanOneUpgrader() throws Exception
  +   {
  +      final int NUM = 2;
  +      final Object lock = new Object();
   
         cache.put(NODE, "bla", "blo");
   
  -      MyUpgrader[] upgraders=new MyUpgrader[NUM];
  -      for(int i=0; i < upgraders.length; i++) {
  -         upgraders[i]=new MyUpgrader("Upgrader#" + i, NODE, lock);
  +      MyUpgrader[] upgraders = new MyUpgrader[NUM];
  +      for (int i = 0; i < upgraders.length; i++)
  +      {
  +         upgraders[i] = new MyUpgrader("Upgrader#" + i, NODE, lock);
            upgraders[i].start();
         }
   
  -       TestingUtil.sleepThread((long)1000);
  +      TestingUtil.sleepThread((long) 1000);
          log("locks: " + cache.printLockInfo());
   
  -      synchronized(lock) {
  +      synchronized (lock)
  +      {
            lock.notifyAll();
         }
   
         // all threads now try to upgrade the RL to a WL
  -      for(int i=0; i < upgraders.length; i++) {
  -         MyThread upgrader=upgraders[i];
  +      for (int i = 0; i < upgraders.length; i++)
  +      {
  +         MyThread upgrader = upgraders[i];
            upgrader.join();
         }
      }
   
   
  -   public void testPutsAndRemovesOnParentAndChildNodes() throws InterruptedException {
  -      ContinuousPutter putter=new ContinuousPutter("Putter", NODE);
  -      ContinuousRemover remover=new ContinuousRemover("Remover", PARENT_NODE);
  +   public void testPutsAndRemovesOnParentAndChildNodes() throws InterruptedException
  +   {
  +      ContinuousPutter putter = new ContinuousPutter("Putter", NODE);
  +      ContinuousRemover remover = new ContinuousRemover("Remover", PARENT_NODE);
         putter.start();
         remover.start();
  -       TestingUtil.sleepThread((long)5000);
  +      TestingUtil.sleepThread((long) 5000);
          log("stopping Putter");
  -      putter.looping=false;
  +      putter.looping = false;
         log("stopping Remover");
  -      remover.looping=false;
  +      remover.looping = false;
         putter.join();
         remover.join();
      }
   
  -   public void testPutsAndRemovesOnParentAndChildNodesReversed() throws InterruptedException {
  -      ContinuousPutter putter=new ContinuousPutter("Putter", PARENT_NODE);
  -      ContinuousRemover remover=new ContinuousRemover("Remover", NODE);
  +   public void testPutsAndRemovesOnParentAndChildNodesReversed() throws InterruptedException
  +   {
  +      ContinuousPutter putter = new ContinuousPutter("Putter", PARENT_NODE);
  +      ContinuousRemover remover = new ContinuousRemover("Remover", NODE);
         putter.start();
         remover.start();
  -       TestingUtil.sleepThread((long)5000);
  +      TestingUtil.sleepThread((long) 5000);
          log("stopping Putter");
  -      putter.looping=false;
  +      putter.looping = false;
         log("stopping Remover");
  -      remover.looping=false;
  +      remover.looping = false;
         putter.join();
         remover.join();
      }
   
  -   public void testPutsAndRemovesOnSameNode() throws InterruptedException {
  -      ContinuousPutter putter=new ContinuousPutter("Putter", NODE);
  -      ContinuousRemover remover=new ContinuousRemover("Remover", NODE);
  +   public void testPutsAndRemovesOnSameNode() throws InterruptedException
  +   {
  +      ContinuousPutter putter = new ContinuousPutter("Putter", NODE);
  +      ContinuousRemover remover = new ContinuousRemover("Remover", NODE);
         putter.start();
         remover.start();
  -       TestingUtil.sleepThread((long)5000);
  +      TestingUtil.sleepThread((long) 5000);
          log("stopping Putter");
  -      putter.looping=false;
  +      putter.looping = false;
         log("stopping Remover");
  -      remover.looping=false;
  +      remover.looping = false;
         putter.join();
         remover.join();
      }
   
   
  -   class GenericThread extends Thread {
  +   class GenericThread extends Thread
  +   {
         protected Transaction tx;
  -      protected boolean looping=true;
  +      protected boolean looping = true;
   
  -      public GenericThread() {
  +      public GenericThread()
  +      {
   
         }
   
  -      public GenericThread(String name) {
  +      public GenericThread(String name)
  +      {
            super(name);
         }
   
  -      public void setLooping(boolean looping) {
  -         this.looping=looping;
  +      public void setLooping(boolean looping)
  +      {
  +         this.looping = looping;
         }
   
  -      public void run() {
  -         try {
  +      public void run()
  +      {
  +         try
  +         {
               _run();
            }
  -         catch(Exception t) {
  +         catch (Exception t)
  +         {
               System.out.println(getName() + ": " + t);
  -            if(thread_ex == null)
  -               thread_ex=t;
  +            if (thread_ex == null)
  +               thread_ex = t;
            }
  -         if(log.isTraceEnabled())
  +         if (log.isTraceEnabled())
               log.trace("Thread " + getName() + " terminated");
         }
   
  -      protected void _run() throws Exception {
  +      protected void _run() throws Exception
  +      {
            throw  new UnsupportedOperationException();
         }
      }
   
   
  -   class ContinuousRemover extends GenericThread {
  +   class ContinuousRemover extends GenericThread
  +   {
         Fqn fqn;
   
  -      public ContinuousRemover(String name, Fqn fqn) {
  +      public ContinuousRemover(String name, Fqn fqn)
  +      {
            super(name);
  -         this.fqn=fqn;
  +         this.fqn = fqn;
         }
   
   
  -      protected void _run() throws Exception {
  -         while(thread_ex == null && looping) {
  -            try {
  -               if(interrupted())
  +      protected void _run() throws Exception
  +      {
  +         while (thread_ex == null && looping)
  +         {
  +            try
  +            {
  +               if (interrupted())
                     break;
  -               tx=startTransaction();
  +               tx = startTransaction();
                  log("remove(" + fqn + ")");
                  cache.remove(fqn);
                  sleep(random(20));
                  tx.commit();
               }
  -            catch(InterruptedException interrupted) {
  +            catch (InterruptedException interrupted)
  +            {
                  tx.rollback();
                  break;
               }
  -            catch(Exception ex) {
  +            catch (Exception ex)
  +            {
                  tx.rollback();
                  throw ex;
               }
  @@ -322,31 +362,38 @@
         }
      }
   
  -   class ContinuousPutter extends GenericThread {
  +   class ContinuousPutter extends GenericThread
  +   {
         Fqn fqn;
   
  -      public ContinuousPutter(String name, Fqn fqn) {
  +      public ContinuousPutter(String name, Fqn fqn)
  +      {
            super(name);
  -         this.fqn=fqn;
  +         this.fqn = fqn;
         }
   
   
  -      protected void _run() throws Exception {
  -         while(thread_ex == null && looping) {
  -            try {
  -               if(interrupted())
  +      protected void _run() throws Exception
  +      {
  +         while (thread_ex == null && looping)
  +         {
  +            try
  +            {
  +               if (interrupted())
                     break;
  -               tx=startTransaction();
  +               tx = startTransaction();
                  log("put(" + fqn + ")");
                  cache.put(fqn, "foo", "bar");
                  sleep(random(20));
                  tx.commit();
               }
  -            catch(InterruptedException interrupted) {
  +            catch (InterruptedException interrupted)
  +            {
                  tx.rollback();
                  break;
               }
  -            catch(Exception ex) {
  +            catch (Exception ex)
  +            {
                  tx.rollback();
                  throw ex;
               }
  @@ -354,28 +401,31 @@
         }
      }
   
  -   public static long random(long range) {
  -      return (long)((Math.random() * 100000) % range) + 1;
  +   public static long random(long range)
  +   {
  +      return (long) ((Math.random() * 100000) % range) + 1;
      }
   
   
  -
  -   class MyThread extends GenericThread {
  +   class MyThread extends GenericThread
  +   {
         Fqn fqn;
   
   
  -      public MyThread(String name, Fqn fqn) {
  +      public MyThread(String name, Fqn fqn)
  +      {
            super(name);
  -         this.fqn=fqn;
  +         this.fqn = fqn;
         }
   
  -      protected void _run() throws Exception {
  -         tx=startTransaction();
  +      protected void _run() throws Exception
  +      {
  +         tx = startTransaction();
            log("get(" + fqn + ")");
            cache.get(fqn, "bla"); // acquires RL
            log("done, locks: " + cache.printLockInfo());
   
  -         synchronized(this) {wait();}
  +         synchronized (this) {wait();}
   
            log("put(" + fqn + ")");
            cache.put(fqn, "key", "val"); // need to upgrade RL to WL
  @@ -386,27 +436,31 @@
      }
   
   
  -   class MyUpgrader extends MyThread {
  +   class MyUpgrader extends MyThread
  +   {
         Object lock;
   
  -      public MyUpgrader(String name, Fqn fqn) {
  +      public MyUpgrader(String name, Fqn fqn)
  +      {
            super(name, fqn);
         }
   
  -      public MyUpgrader(String name, Fqn fqn, Object lock) {
  +      public MyUpgrader(String name, Fqn fqn, Object lock)
  +      {
            super(name, fqn);
  -         this.lock=lock;
  +         this.lock = lock;
         }
   
  -      protected void _run() throws Exception {
  -         tx=startTransaction();
  +      protected void _run() throws Exception
  +      {
  +         tx = startTransaction();
            try
            {
                log("get(" + fqn + ")");
   
                cache.get(fqn, "bla"); // acquires RL
   
  -             synchronized(lock) {lock.wait();}
  +            synchronized (lock) {lock.wait();}
   
                 log("put(" + fqn + ")");
                cache.put(fqn, "key", "val"); // need to upgrade RL to WL
  @@ -422,22 +476,28 @@
         }
      }
   
  -   class MyThreadTimeout extends MyThread {
  +   class MyThreadTimeout extends MyThread
  +   {
   
  -      public MyThreadTimeout(String name, Fqn fqn) {
  +      public MyThreadTimeout(String name, Fqn fqn)
  +      {
            super(name, fqn);
         }
   
  -      protected void _run() throws Exception {
  -         try {
  +      protected void _run() throws Exception
  +      {
  +         try
  +         {
               super._run();
            }
  -         catch(UpgradeException upgradeEx) {
  +         catch (UpgradeException upgradeEx)
  +         {
               log("received UpgradeException as expected");
               tx.rollback();
               log("rolled back TX, locks: " + cache.printLockInfo());
            }
  -         catch(TimeoutException timeoutEx) {
  +         catch (TimeoutException timeoutEx)
  +         {
               log("received TimeoutException as expected");
               tx.rollback();
               log("rolled back TX, locks: " + cache.printLockInfo());
  @@ -446,22 +506,24 @@
      }
   
   
  -
  -   class MyPutter extends GenericThread {
  +   class MyPutter extends GenericThread
  +   {
         Fqn fqn1, fqn2;
   
  -      public MyPutter(String name, Fqn fqn1, Fqn fqn2) {
  +      public MyPutter(String name, Fqn fqn1, Fqn fqn2)
  +      {
            super(name);
  -         this.fqn1=fqn1;
  -         this.fqn2=fqn2;
  +         this.fqn1 = fqn1;
  +         this.fqn2 = fqn2;
         }
   
  -      protected void _run() throws Exception {
  -         tx=startTransaction();
  +      protected void _run() throws Exception
  +      {
  +         tx = startTransaction();
            log("put(" + fqn1 + ")");
            cache.put(fqn1, "key", "val"); // need to upgrade RL to WL
            log("done, locks: " + cache.printLockInfo());
  -         synchronized(this) {wait();}
  +         synchronized (this) {wait();}
            log("put(" + fqn2 + ")");
            cache.put(fqn2, "key", "val"); // need to upgrade RL to WL
            log("done, locks: " + cache.printLockInfo());
  @@ -470,17 +532,22 @@
         }
      }
   
  -   class MyPutterTimeout extends MyPutter {
  +   class MyPutterTimeout extends MyPutter
  +   {
   
  -      public MyPutterTimeout(String name, Fqn fqn1, Fqn fqn2) {
  +      public MyPutterTimeout(String name, Fqn fqn1, Fqn fqn2)
  +      {
            super(name, fqn1, fqn2);
         }
   
  -      protected void _run() throws Exception {
  -         try {
  +      protected void _run() throws Exception
  +      {
  +         try
  +         {
               super._run();
            }
  -         catch(TimeoutException timeoutEx) {
  +         catch (TimeoutException timeoutEx)
  +         {
               log("received TimeoutException as expected");
               tx.rollback();
               log("rolled back TX, locks: " + cache.printLockInfo());
  @@ -489,27 +556,28 @@
      }
   
   
  -
  -   private static void log(String msg) {
  +   private static void log(String msg)
  +   {
         System.out.println(Thread.currentThread().getName() + ": " + msg);
      }
   
   
  -
  -    Transaction startTransaction() throws SystemException, NotSupportedException {
  -       DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +   Transaction startTransaction() throws SystemException, NotSupportedException
  +   {
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
          mgr.begin();
  -       Transaction tx=mgr.getTransaction();
  +      Transaction tx = mgr.getTransaction();
          return tx;
       }
   
   
  -
  -   public static Test suite() throws Exception {
  +   public static Test suite() throws Exception
  +   {
         return new TestSuite(DeadlockTest.class);
      }
   
  -   public static void main(String[] args) throws Exception {
  +   public static void main(String[] args) throws Exception
  +   {
         junit.textui.TestRunner.run(suite());
      }
   
  
  
  
  1.4       +108 -108  JBossCache/tests/functional/org/jboss/cache/transaction/InvocationContextCleanupTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: InvocationContextCleanupTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/InvocationContextCleanupTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- InvocationContextCleanupTest.java	20 Jul 2006 09:03:55 -0000	1.3
  +++ InvocationContextCleanupTest.java	6 Sep 2006 15:31:00 -0000	1.4
  @@ -34,7 +34,7 @@
           cache.getConfiguration().setClusterName("InvocationContextCleanupTest");
           cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
           cache.getConfiguration().setLockAcquisitionTimeout(2000);
  -        cache.startService();
  +      cache.start();
           return cache;
       }
   
  @@ -42,11 +42,11 @@
       {
           if (caches != null)
           {
  -            for (int i=0; i<caches.length; i++)
  +         for (int i = 0; i < caches.length; i++)
               {
                   if (caches[i] != null)
                   {
  -                    caches[i].stopService();
  +               caches[i].stop();
                       caches[i] = null;
                   }
               }
  @@ -110,7 +110,7 @@
               }
               catch (SystemException e)
               {
  -                throw new RuntimeException("Unable to sustend transaction! " + e.getMessage() );
  +            throw new RuntimeException("Unable to sustend transaction! " + e.getMessage());
               }
   
               try
  
  
  
  1.4       +36 -29    JBossCache/tests/functional/org/jboss/cache/transaction/IsolationLevelNoneTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IsolationLevelNoneTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/IsolationLevelNoneTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- IsolationLevelNoneTest.java	20 Jul 2006 10:32:09 -0000	1.3
  +++ IsolationLevelNoneTest.java	6 Sep 2006 15:31:00 -0000	1.4
  @@ -15,38 +15,42 @@
   
   /**
    * Tests whether modifications within callbacks (TreeCacheListener) are handled correctly
  + *
    * @author Bela Ban
  - * @version $Id: IsolationLevelNoneTest.java,v 1.3 2006/07/20 10:32:09 msurtani Exp $
  + * @version $Id: IsolationLevelNoneTest.java,v 1.4 2006/09/06 15:31:00 msurtani Exp $
    */
  -public class IsolationLevelNoneTest extends TestCase {
  -   TreeCache cache=null;
  -   final Fqn FQN=Fqn.fromString("/a/b/c");
  -   final String KEY="key";
  -   final String VALUE="value";
  +public class IsolationLevelNoneTest extends TestCase
  +{
  +   TreeCache cache = null;
  +   final Fqn FQN = Fqn.fromString("/a/b/c");
  +   final String KEY = "key";
  +   final String VALUE = "value";
      Transaction tx;
   
   
  -
  -   protected void setUp() throws Exception {
  +   protected void setUp() throws Exception
  +   {
         super.setUp();
      }
   
  -   protected void tearDown() throws Exception {
  +   protected void tearDown() throws Exception
  +   {
         super.tearDown();
  -      if(cache != null) {
  -         cache.stopService();
  -         cache.destroyService();
  -         cache=null;
  +      if (cache != null)
  +      {
  +         cache.stop();
  +         cache.destroy();
  +         cache = null;
         }
      }
   
   
  -
  -   public void testWithoutTransactions() throws Exception {
  -      cache=new TreeCache();
  +   public void testWithoutTransactions() throws Exception
  +   {
  +      cache = new TreeCache();
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
         cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE);
  -      cache.startService();
  +      cache.start();
         cache.put(FQN, KEY, VALUE);
         cache.put(FQN + "/d", KEY, VALUE);
         assertTrue(cache.exists(FQN, KEY));
  @@ -55,13 +59,14 @@
         assertEquals(0, cache.getNumberOfLocksHeld());
      }
   
  -   public void testWithTransactions() throws Exception {
  -      cache=new TreeCache();
  +   public void testWithTransactions() throws Exception
  +   {
  +      cache = new TreeCache();
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
         cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE);
         cache.setTransactionManagerLookup(new DummyTransactionManagerLookup());
  -      cache.startService();
  -      tx=startTransaction();
  +      cache.start();
  +      tx = startTransaction();
         cache.put(FQN, KEY, VALUE);
         cache.put(FQN + "/d", KEY, VALUE);
         assertTrue(cache.exists(FQN, KEY));
  @@ -72,13 +77,14 @@
      }
   
   
  -   public void testWithTransactionsRepeatableRead() throws Exception {
  -      cache=new TreeCache();
  +   public void testWithTransactionsRepeatableRead() throws Exception
  +   {
  +      cache = new TreeCache();
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
         cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
         cache.setTransactionManagerLookup(new DummyTransactionManagerLookup());
  -      cache.startService();
  -      tx=startTransaction();
  +      cache.start();
  +      tx = startTransaction();
         cache.put(FQN, KEY, VALUE);
         cache.put(FQN + "/d", KEY, VALUE);
         assertTrue(cache.exists(FQN, KEY));
  @@ -88,16 +94,17 @@
         tx.commit();
      }
   
  -   private Transaction startTransaction() throws SystemException, NotSupportedException {
  -      DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +   private Transaction startTransaction() throws SystemException, NotSupportedException
  +   {
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         mgr.begin();
         return mgr.getTransaction();
      }
   
  -   public static Test suite() {
  +   public static Test suite()
  +   {
         return new TestSuite(IsolationLevelNoneTest.class);
      }
   
   
  -
   }
  
  
  
  1.3       +18 -24    JBossCache/tests/functional/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IsolationLevelReadCommittedNodeCreationRollbackTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- IsolationLevelReadCommittedNodeCreationRollbackTest.java	20 Jul 2006 10:32:09 -0000	1.2
  +++ IsolationLevelReadCommittedNodeCreationRollbackTest.java	6 Sep 2006 15:31:00 -0000	1.3
  @@ -6,28 +6,27 @@
    */
   package org.jboss.cache.transaction;
   
  -import junit.framework.TestCase;
  +import EDU.oswego.cs.dl.util.concurrent.Latch;
   import junit.framework.AssertionFailedError;
   import junit.framework.Test;
  +import junit.framework.TestCase;
   import junit.framework.TestSuite;
  -import org.jboss.cache.TreeCache;
  -import org.jboss.cache.Fqn;
   import org.jboss.cache.DummyTransactionManagerLookup;
  +import org.jboss.cache.Fqn;
  +import org.jboss.cache.TreeCache;
   import org.jboss.cache.config.Configuration;
   import org.jboss.cache.lock.IsolationLevel;
   import org.jboss.cache.lock.TimeoutException;
  -import EDU.oswego.cs.dl.util.concurrent.Latch;
   
  -import javax.transaction.Transaction;
  -import javax.transaction.SystemException;
   import javax.transaction.NotSupportedException;
  +import javax.transaction.SystemException;
  +import javax.transaction.Transaction;
   
   /**
    * Tests READ_COMMITED isolation level.
    *
    * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
  - *
  - * @version $Id: IsolationLevelReadCommittedNodeCreationRollbackTest.java,v 1.2 2006/07/20 10:32:09 msurtani Exp $
  + * @version $Id: IsolationLevelReadCommittedNodeCreationRollbackTest.java,v 1.3 2006/09/06 15:31:00 msurtani Exp $
    */
   
   public class IsolationLevelReadCommittedNodeCreationRollbackTest extends TestCase
  @@ -57,7 +56,7 @@
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
         cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
         cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
  -      cache.startService();
  +      cache.start();
      }
   
   
  @@ -65,9 +64,9 @@
      {
         super.tearDown();
   
  -      cache.stopService();
  -      cache.destroyService();
  -      cache=null;
  +      cache.stop();
  +      cache.destroy();
  +      cache = null;
      }
   
   
  @@ -116,7 +115,7 @@
               {
                  writerError = e;
               }
  -            catch(Throwable t)
  +            catch (Throwable t)
               {
                  t.printStackTrace();
                  writerFailed = true;
  @@ -173,7 +172,7 @@
               {
                  readerError = e;
               }
  -            catch(Throwable t)
  +            catch (Throwable t)
               {
                  t.printStackTrace();
                  readerFailed = true;
  @@ -217,23 +216,18 @@
   
      private Transaction startTransaction() throws SystemException, NotSupportedException
      {
  -      DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         mgr.begin();
         return mgr.getTransaction();
      }
   
   
  -
  -   public static Test suite() {
  +   public static Test suite()
  +   {
   
         return new TestSuite(IsolationLevelReadCommittedNodeCreationRollbackTest.class);
   
      }
   
   
  -
  -
  -
  -
  -
   }
  
  
  
  1.7       +20 -24    JBossCache/tests/functional/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IsolationLevelReadCommittedTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- IsolationLevelReadCommittedTest.java	20 Jul 2006 08:05:18 -0000	1.6
  +++ IsolationLevelReadCommittedTest.java	6 Sep 2006 15:31:00 -0000	1.7
  @@ -1,7 +1,6 @@
   package org.jboss.cache.transaction;
   
   
  -
   import EDU.oswego.cs.dl.util.concurrent.Latch;
   import junit.framework.AssertionFailedError;
   import junit.framework.Test;
  @@ -17,13 +16,11 @@
   import javax.transaction.Transaction;
   
   
  -
   /**
    * Tests READ_COMMITED isolation level.
    *
    * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
  - *
  - * @version $Id: IsolationLevelReadCommittedTest.java,v 1.6 2006/07/20 08:05:18 msurtani Exp $
  + * @version $Id: IsolationLevelReadCommittedTest.java,v 1.7 2006/09/06 15:31:00 msurtani Exp $
    */
   
   public class IsolationLevelReadCommittedTest extends TestCase
  @@ -53,7 +50,7 @@
         cache.getConfiguration().setCacheMode("LOCAL");
         cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
         cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
  -      cache.startService();
  +      cache.start();
      }
   
   
  @@ -61,9 +58,9 @@
      {
         super.tearDown();
   
  -      cache.stopService();
  -      cache.destroyService();
  -      cache=null;
  +      cache.stop();
  +      cache.destroy();
  +      cache = null;
      }
   
   
  @@ -120,7 +117,7 @@
               {
                  readerError = e;
               }
  -            catch(Throwable t)
  +            catch (Throwable t)
               {
                  t.printStackTrace();
                  readerFailed = true;
  @@ -138,7 +135,6 @@
         }, "READER");
         readerThread.start();
   
  -
         // start a writer thread and a transaction
   
         Thread writerThread = new Thread(new Runnable()
  @@ -169,7 +165,7 @@
               {
                  writerError = e;
               }
  -            catch(Throwable t)
  +            catch (Throwable t)
               {
                  t.printStackTrace();
                  writerFailed = true;
  @@ -212,14 +208,14 @@
   
      private Transaction startTransaction() throws SystemException, NotSupportedException
      {
  -      DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         mgr.begin();
         return mgr.getTransaction();
      }
   
   
  -
  -   public static Test suite() {
  +   public static Test suite()
  +   {
   
         return new TestSuite(IsolationLevelReadCommittedTest.class);
   
  
  
  
  1.3       +94 -77    JBossCache/tests/functional/org/jboss/cache/transaction/PrepareTxTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PrepareTxTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/PrepareTxTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- PrepareTxTest.java	20 Jul 2006 09:03:55 -0000	1.2
  +++ PrepareTxTest.java	6 Sep 2006 15:31:00 -0000	1.3
  @@ -17,70 +17,79 @@
    * Date: Jun 9, 2004
    * Time: 9:05:19 AM
    */
  -public class PrepareTxTest extends TestCase {
  +public class PrepareTxTest extends TestCase
  +{
      TreeCache cache;
   
  -   protected void setUp() throws Exception {
  +   protected void setUp() throws Exception
  +   {
         super.setUp();
  -      cache=new TreeCache();
  +      cache = new TreeCache();
         cache.getConfiguration().setCacheMode("local");
         cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
      }
   
  -   protected void tearDown() throws Exception {
  +   protected void tearDown() throws Exception
  +   {
         super.tearDown();
  -      cache.stopService();
  -      cache.destroyService();
  +      cache.stop();
  +      cache.destroy();
      }
   
   
  -
  -
  -   /** Tests cache modification <em>inside</em> the afterCompletion() callback. Reproduces a bug fixed in
  +   /**
  +    * Tests cache modification <em>inside</em> the afterCompletion() callback. Reproduces a bug fixed in
       * connection with JBossCache being used as Hibernate's second level cache 
  +    *
       * @throws Exception
       * @throws NotSupportedException
       */
  -   public void testCacheModificationInBeforeCompletionPhase() throws Exception, NotSupportedException {
  -      int numLocks=0;
  -      DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +   public void testCacheModificationInBeforeCompletionPhase() throws Exception, NotSupportedException
  +   {
  +      int numLocks = 0;
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
         mgr.begin();
  -      Transaction tx=mgr.getTransaction();
  +      Transaction tx = mgr.getTransaction();
   
         // this will cause the cache to register with TransactionManager for TX completion callbacks
         cache.put("/one/two/three", "key1", "val1");
         System.out.println("before commit:\n" + cache.printLockInfo());
  -      numLocks=cache.getNumberOfLocksHeld();
  +      numLocks = cache.getNumberOfLocksHeld();
         assertEquals(3, numLocks);
   
         // we register *second*
  -      tx.registerSynchronization(new Synchronization() {
  +      tx.registerSynchronization(new Synchronization()
  +      {
   
  -         public void beforeCompletion() {
  -            try {
  +         public void beforeCompletion()
  +         {
  +            try
  +            {
                  cache.put("/a/b/c", null);
                  System.out.println("before commit:\n" + cache.printLockInfo());
               }
  -            catch(CacheException e) {
  +            catch (CacheException e)
  +            {
                  e.printStackTrace();
               }
            }
   
  -         public void afterCompletion(int status) {
  +         public void afterCompletion(int status)
  +         {
            }
         });
   
         tx.commit();
         System.out.println("after commit:\n" + cache.printLockInfo());
  -      numLocks=cache.getNumberOfLocksHeld();
  +      numLocks = cache.getNumberOfLocksHeld();
         assertEquals(0, numLocks);
   
         int num_local_txs, num_global_txs;
  -      TransactionTable tx_table=cache.getTransactionTable();
  -      num_local_txs=tx_table.getNumLocalTransactions();
  -      num_global_txs=tx_table.getNumGlobalTransactions();
  +      TransactionTable tx_table = cache.getTransactionTable();
  +      num_local_txs = tx_table.getNumLocalTransactions();
  +      num_global_txs = tx_table.getNumGlobalTransactions();
         System.out.println("Number of Transactions: " + num_local_txs + "\nNumber of GlobalTransactions: " +
                            num_global_txs + "\nTransactionTable:\n " + tx_table.toString(true));
         assertEquals(num_local_txs, num_global_txs);
  @@ -88,36 +97,43 @@
      }
   
   
  -
  -   /** Tests cache modification <em>inside</em> the afterCompletion() callback. Reproduces a bug fixed in
  +   /**
  +    * Tests cache modification <em>inside</em> the afterCompletion() callback. Reproduces a bug fixed in
        * connection with JBossCache being used as Hibernate's second level cache
  +    *
        * @throws Exception
        * @throws NotSupportedException
        */
  -    public void testCacheModificationInAfterCompletionPhase() throws Exception, NotSupportedException {
  -       int numLocks=0;
  -       DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  +   public void testCacheModificationInAfterCompletionPhase() throws Exception, NotSupportedException
  +   {
  +      int numLocks = 0;
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
          mgr.begin();
  -       Transaction tx=mgr.getTransaction();
  +      Transaction tx = mgr.getTransaction();
   
          // this will cause the cache to register with TransactionManager for TX completion callbacks
          cache.put("/one/two/three", "key1", "val1");
          System.out.println("before commit:\n" + cache.printLockInfo());
  -       numLocks=cache.getNumberOfLocksHeld();
  +      numLocks = cache.getNumberOfLocksHeld();
          assertEquals(3, numLocks);
   
          // we register *second*
  -       tx.registerSynchronization(new Synchronization() {
  +      tx.registerSynchronization(new Synchronization()
  +      {
   
  -          public void beforeCompletion() {
  +         public void beforeCompletion()
  +         {
             }
   
  -          public void afterCompletion(int status) {
  -             try {
  +         public void afterCompletion(int status)
  +         {
  +            try
  +            {
                   cache.put("/a/b/c", null);
                   System.out.println("before commit:\n" + cache.printLockInfo());
                }
  -             catch(CacheException e) {
  +            catch (CacheException e)
  +            {
                   e.printStackTrace();
                }
             }
  @@ -125,13 +141,13 @@
   
          tx.commit();
          System.out.println("after commit:\n" + cache.printLockInfo());
  -       numLocks=cache.getNumberOfLocksHeld();
  +      numLocks = cache.getNumberOfLocksHeld();
          assertEquals(0, numLocks);
   
          int num_local_txs, num_global_txs;
  -       TransactionTable tx_table=cache.getTransactionTable();
  -       num_local_txs=tx_table.getNumLocalTransactions();
  -       num_global_txs=tx_table.getNumGlobalTransactions();
  +      TransactionTable tx_table = cache.getTransactionTable();
  +      num_local_txs = tx_table.getNumLocalTransactions();
  +      num_global_txs = tx_table.getNumGlobalTransactions();
          System.out.println("Number of Transactions: " + num_local_txs + "\nNumber of GlobalTransactions: " +
                             num_global_txs + "\nTransactionTable:\n " + tx_table.toString(true));
          assertEquals(num_local_txs, num_global_txs);
  @@ -139,12 +155,13 @@
       }
   
   
  -
  -   public static Test suite() {
  +   public static Test suite()
  +   {
         return new TestSuite(PrepareTxTest.class);
      }
   
  -   public static void main(String[] args) {
  +   public static void main(String[] args)
  +   {
         junit.textui.TestRunner.run(suite());
      }
   
  
  
  
  1.4       +223 -190  JBossCache/tests/functional/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReplicatedTransactionDeadlockTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- ReplicatedTransactionDeadlockTest.java	20 Jul 2006 11:48:26 -0000	1.3
  +++ ReplicatedTransactionDeadlockTest.java	6 Sep 2006 15:31:00 -0000	1.4
  @@ -55,33 +55,49 @@
    *
    * @author Marian Nikolov
    * @author $Author: msurtani $
  - * @version $RCSfile: ReplicatedTransactionDeadlockTest.java,v $
  - * @version $Revision: 1.3 $
  - * @version $Date: 2006/07/20 11:48:26 $
  + * @version $Date: 2006/09/06 15:31:00 $
  + */
  +public class ReplicatedTransactionDeadlockTest extends TestCase
  +{
  +   /**
  +    * The number of worker threads to start concurrently.
    */
  -public class ReplicatedTransactionDeadlockTest extends TestCase {
  -    /** The number of worker threads to start concurrently. */
       private static final int NUM_WORKERS = 2;
  -    /** The number of test runs to perform. */
  +   /**
  +    * The number of test runs to perform.
  +    */
       private static final int NUM_RUNS = 100;
   
  -    /** The initial context factory properties. */
  +   /**
  +    * The initial context factory properties.
  +    */
       private static final Properties PROPERTIES;
  -    /** The context factory to be used for the test. */
  +   /**
  +    * The context factory to be used for the test.
  +    */
       private static final String CONTEXT_FACTORY =
           "org.jboss.cache.transaction.DummyContextFactory";
  -    /** The original context factory to be restored after the test. */
  +   /**
  +    * The original context factory to be restored after the test.
  +    */
       private String m_contextFactory = null;
   
  -    /** Exception recorded if any of the worker threads fails. */
  +   /**
  +    * Exception recorded if any of the worker threads fails.
  +    */
       private static volatile Exception mcl_exception = null;
   
  -    /** The source cache where we put modifications. */
  +   /**
  +    * The source cache where we put modifications.
  +    */
       private TreeCache m_srcCache = null;
  -    /** The target cache where we replicate modifications. */
  +   /**
  +    * The target cache where we replicate modifications.
  +    */
       private TreeCache m_dstCache = null;
   
  -    static {
  +   static
  +   {
           PROPERTIES = new Properties();
           PROPERTIES.put(Context.INITIAL_CONTEXT_FACTORY,
                   "org.jboss.cache.transaction.DummyContextFactory");
  @@ -92,14 +108,16 @@
        *
        * @param name The test name.
        */
  -    public ReplicatedTransactionDeadlockTest(String name) {
  +   public ReplicatedTransactionDeadlockTest(String name)
  +   {
           super(name);
       }
   
       /**
        * {@inheritDoc}
        */
  -    protected void setUp() throws Exception {
  +   protected void setUp() throws Exception
  +   {
           super.setUp();
           mcl_exception = null;
           m_contextFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
  @@ -113,8 +131,8 @@
           m_srcCache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
   
           m_srcCache.getConfiguration().setSyncCommitPhase(true);
  -        m_srcCache.createService();
  -        m_srcCache.startService();
  +      m_srcCache.create();
  +      m_srcCache.start();
           // setup and start the destination cache
           m_dstCache = new TreeCache();
           m_dstCache.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replSync-service.xml"));
  @@ -123,21 +141,23 @@
           m_dstCache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
   
           m_dstCache.getConfiguration().setSyncCommitPhase(true);
  -        m_dstCache.createService();
  -        m_dstCache.startService();
  +      m_dstCache.create();
  +      m_dstCache.start();
       }
   
       /**
        * {@inheritDoc}
        */
  -    protected void tearDown() throws Exception {
  +   protected void tearDown() throws Exception
  +   {
           super.tearDown();
           DummyTransactionManager.destroy();
  -        m_srcCache.stopService();
  +      m_srcCache.stop();
           m_srcCache = null;
  -        m_dstCache.stopService();
  +      m_dstCache.stop();
           m_dstCache = null;
  -        if (m_contextFactory != null) {
  +      if (m_contextFactory != null)
  +      {
               System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                       m_contextFactory);
               m_contextFactory = null;
  @@ -151,7 +171,8 @@
        *
        * @throws Exception Any exception if thrown by the cache.
        */
  -    public void testConcurrentReplicatedTransaction() throws Exception {
  +   public void testConcurrentReplicatedTransaction() throws Exception
  +   {
           performTest();
       }
   
  @@ -160,21 +181,26 @@
        *
        * @throws Exception Any exception if thrown by the cache.
        */
  -    private void performTest() throws Exception {
  +   private void performTest() throws Exception
  +   {
           // repeat the test several times since it's not always reproducible
  -        for (int i = 0; i < NUM_RUNS; i++) {
  -            if (mcl_exception != null) {
  +      for (int i = 0; i < NUM_RUNS; i++)
  +      {
  +         if (mcl_exception != null)
  +         {
                   // terminate the test on the first failed worker
                   fail("Due to an exception: " + mcl_exception);
               }
               // start several worker threads to work with the same FQN
               Worker[] t = new Worker[NUM_WORKERS];
  -            for (int j = 0; j < t.length; j++) {
  -                t[j] = new Worker("worker " + i + ":" +j);
  +         for (int j = 0; j < t.length; j++)
  +         {
  +            t[j] = new Worker("worker " + i + ":" + j);
                   t[j].start();
               }
               // wait for all workers to complete before repeating the test
  -            for (int j = 0; j < t.length; j++) {
  +         for (int j = 0; j < t.length; j++)
  +         {
                   t[j].join();
               }
           }
  @@ -186,7 +212,8 @@
        * @return A user transaction.
        * @throws Exception Any exception thrown by the context lookup.
        */
  -    private UserTransaction getTransaction() throws Exception {
  +   private UserTransaction getTransaction() throws Exception
  +   {
           return (UserTransaction) new InitialContext(PROPERTIES)
                   .lookup("UserTransaction");
       }
  @@ -194,10 +221,10 @@
       /**
        * Log a message.
        *
  -
        * @param msg The meessage to be logged.
        */
  -    private void log(String msg) {
  +   private void log(String msg)
  +   {
           System.out.println(System.currentTimeMillis() + " "
                   + Thread.currentThread() + " " + msg);
       }
  @@ -207,23 +234,25 @@
        *
        * @author Marian Nikolov
        * @author $Author: msurtani $
  -     * @version $RCSfile: ReplicatedTransactionDeadlockTest.java,v $
  -     * @version $Revision: 1.3 $
  -     * @version $Date: 2006/07/20 11:48:26 $
  +    * @version $Date: 2006/09/06 15:31:00 $
        */
  -    private class Worker extends Thread {
  +   private class Worker extends Thread
  +   {
           /**
            * Constructor.
            */
  -        public Worker(String name) {
  +      public Worker(String name)
  +      {
               super(name);
           }
   
           /**
            * {@inheritDoc}
            */
  -        public void run() {
  -            try {
  +      public void run()
  +      {
  +         try
  +         {
                   UserTransaction tx = getTransaction();
                   log("begin");
                   tx.begin();
  @@ -232,18 +261,22 @@
                   log("commit");
                   tx.commit();
                   log("leave");
  -            } catch (Exception e) {
  +         }
  +         catch (Exception e)
  +         {
                   log("caught exception " + e);
                   mcl_exception = e;
               }
           }
       }
   
  -    public static Test suite() {
  +   public static Test suite()
  +   {
           return new TestSuite(ReplicatedTransactionDeadlockTest.class);
       }
   
  -    public static void main(String[] args) throws Exception {
  +   public static void main(String[] args) throws Exception
  +   {
           junit.textui.TestRunner.run(suite());
       }
   }
  
  
  
  1.13      +4 -4      JBossCache/tests/functional/org/jboss/cache/transaction/TransactionTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TransactionTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/TransactionTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- TransactionTest.java	30 Aug 2006 17:08:20 -0000	1.12
  +++ TransactionTest.java	6 Sep 2006 15:31:00 -0000	1.13
  @@ -37,7 +37,7 @@
    * Tests transactional access to a local TreeCache.
    * Note: we use DummpyTranasctionManager to replace jta
    *
  - * @version $Id: TransactionTest.java,v 1.12 2006/08/30 17:08:20 msurtani Exp $
  + * @version $Id: TransactionTest.java,v 1.13 2006/09/06 15:31:00 msurtani Exp $
    */
   public class TransactionTest extends TestCase
   {
  @@ -72,8 +72,8 @@
         cache.getConfiguration().setInitialStateRetrievalTimeout(10000);
         cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
         thread_ex = null;
      }
   
  @@ -82,7 +82,7 @@
         super.tearDown();
         if (cache != null)
         {
  -         cache.stopService();
  +         cache.stop();
            cache = null;
         }
   
  
  
  



More information about the jboss-cvs-commits mailing list