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

Manik Surtani msurtani at jboss.com
Wed Sep 6 11:30:58 EDT 2006


  User: msurtani
  Date: 06/09/06 11:30:58

  Modified:    tests/functional/org/jboss/cache/lock    
                        AcquireAllTest.java BreakDeadMemberLocksTest.java
                        LockReleaseTest.java UpgradeLockTest.java
  Log:
  Removed TreeCache dependency on ServiceMBeanSupport
  
  Revision  Changes    Path
  1.6       +47 -40    JBossCache/tests/functional/org/jboss/cache/lock/AcquireAllTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AcquireAllTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/lock/AcquireAllTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- AcquireAllTest.java	14 Aug 2006 17:52:35 -0000	1.5
  +++ AcquireAllTest.java	6 Sep 2006 15:30:58 -0000	1.6
  @@ -13,46 +13,49 @@
   
   /**
    * @author Bela Ban
  - * @version $Id: AcquireAllTest.java,v 1.5 2006/08/14 17:52:35 msurtani Exp $
  + * @version $Id: AcquireAllTest.java,v 1.6 2006/09/06 15:30:58 msurtani Exp $
    */
  -public class AcquireAllTest extends TestCase {
  -   TreeCache cache=null, cache2;
  -   Transaction tx=null;
  -   final Fqn FQN=Fqn.fromString("/myNode");
  -   final String KEY="key";
  -   final String VALUE="value";
  +public class AcquireAllTest extends TestCase
  +{
  +   TreeCache cache = null, cache2;
  +   Transaction tx = null;
  +   final Fqn FQN = Fqn.fromString("/myNode");
  +   final String KEY = "key";
  +   final String VALUE = "value";
   
   
  -
  -
  -
  -   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;
         }
  -      if(tx != null) {
  +      if (tx != null)
  +      {
            tx.commit();
  -         tx=null;
  +         tx = null;
         }
      }
   
   
  -   public void testAcquireAll() throws Exception {
  +   public void testAcquireAll() throws Exception
  +   {
         DataNode root;
  -      Object owner=Thread.currentThread();
  +      Object owner = Thread.currentThread();
   
  -      cache=createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
  +      cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
         cache.put("/a/b/c", null);
         cache.put("/1/2/3", null);
   
  -      root=cache.getRoot();
  +      root = cache.getRoot();
   
   
         root.acquireAll(owner, 2000, DataNode.LockType.READ);
  @@ -67,16 +70,17 @@
      }
   
   
  -   public void testAcquireAllReplicated() throws Exception {
  +   public void testAcquireAllReplicated() throws Exception
  +   {
         DataNode root;
  -      Object owner=Thread.currentThread();
  +      Object owner = Thread.currentThread();
   
  -      cache2=createCache(Configuration.CacheMode.REPL_ASYNC, IsolationLevel.SERIALIZABLE);
  +      cache2 = createCache(Configuration.CacheMode.REPL_ASYNC, IsolationLevel.SERIALIZABLE);
         cache2.put("/a/b/c", null);
         cache2.put("/1/2/3", null);
   
  -      cache=createCache(Configuration.CacheMode.REPL_ASYNC, IsolationLevel.SERIALIZABLE);
  -      root=cache.getRoot();
  +      cache = createCache(Configuration.CacheMode.REPL_ASYNC, IsolationLevel.SERIALIZABLE);
  +      root = cache.getRoot();
   
         root.acquireAll(owner, 2000, DataNode.LockType.READ);
         root.releaseAll(owner);
  @@ -90,36 +94,39 @@
      }
   
   
  -
  -   TreeCache createCache(Configuration.CacheMode mode, IsolationLevel level) throws Exception {
  -      TreeCache c=new TreeCache();
  +   TreeCache createCache(Configuration.CacheMode mode, IsolationLevel level) throws Exception
  +   {
  +      TreeCache c = new TreeCache();
         c.getConfiguration().setCacheMode(mode);
         c.getConfiguration().setIsolationLevel(level);
         c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
  -      c.createService();
  -      c.startService();
  +      c.create();
  +      c.start();
         return c;
      }
   
  -   Transaction startTransaction() {
  -      DummyTransactionManager mgr=DummyTransactionManager.getInstance();
  -      try {
  +   Transaction startTransaction()
  +   {
  +      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
  +      try
  +      {
            mgr.begin();
            return mgr.getTransaction();
         }
  -      catch(Throwable t) {
  +      catch (Throwable t)
  +      {
            return null;
         }
      }
   
   
  -
  -
  -   public static Test suite() {
  +   public static Test suite()
  +   {
         return new TestSuite(AcquireAllTest.class);
      }
   
  -   public static void main(String[] args) {
  +   public static void main(String[] args)
  +   {
         junit.textui.TestRunner.run(suite());
      }
   
  
  
  
  1.3       +58 -52    JBossCache/tests/functional/org/jboss/cache/lock/BreakDeadMemberLocksTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BreakDeadMemberLocksTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/lock/BreakDeadMemberLocksTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- BreakDeadMemberLocksTest.java	20 Jul 2006 09:03:53 -0000	1.2
  +++ BreakDeadMemberLocksTest.java	6 Sep 2006 15:30:58 -0000	1.3
  @@ -66,7 +66,7 @@
         TreeCache cacheB = createCache("B");
         
         // Pause to give caches time to see each other
  -      TestingUtil.blockUntilViewsReceived(new TreeCache[] { cacheA, cacheB }, 60000);
  +      TestingUtil.blockUntilViewsReceived(new TreeCache[]{cacheA, cacheB}, 60000);
         
         final TransactionManager tm = cacheB.getTransactionManager();
         tm.begin();
  @@ -84,8 +84,10 @@
         HangSync sync = new HangSync(monitor);
         tx.registerSynchronization(sync);
         
  -      Thread t = new Thread() {
  -        public void run() {
  +      Thread t = new Thread()
  +      {
  +         public void run()
  +         {
              try
              {
                 tm.resume(tx);
  @@ -108,8 +110,8 @@
         // Confirm that B's tx replicated
         assertTrue(cacheA.exists("/EXISTS"));
         
  -      cacheB.stopService();
  -      cacheB.destroyService();
  +      cacheB.stop();
  +      cacheB.destroy();
         
         while (cacheA.getMembers().size() > 1)
         {
  @@ -138,11 +140,11 @@
         if (caches.get(cacheID) != null)
         throw new IllegalStateException(cacheID + " already created");
         
  -      TreeCache tree=new TreeCache();
  +      TreeCache tree = new TreeCache();
         tree.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replSync-service.xml"));
         
  -      tree.createService();
  -      tree.startService();
  +      tree.create();
  +      tree.start();
         
         caches.put(cacheID, tree);
         
  @@ -167,12 +169,14 @@
         TreeCache cache = (TreeCache) caches.get(id);
         if (cache != null)
         {
  -         try {
  -            cache.stopService();
  -            cache.destroyService();
  +         try
  +         {
  +            cache.stop();
  +            cache.destroy();
               caches.remove(id);
            }
  -         catch (Exception e) {
  +         catch (Exception e)
  +         {
               System.out.println("Exception stopping cache " + e.getMessage());
               e.printStackTrace(System.out);
            }
  @@ -189,7 +193,9 @@
            this.monitor = monitor;
         }
   
  -      public void afterCompletion(int arg0) {}
  +      public void afterCompletion(int arg0)
  +      {
  +      }
   
         public void beforeCompletion()
         {
  @@ -202,7 +208,7 @@
            {
               Thread.sleep(30000);
            }
  -         catch(InterruptedException e) {}
  +         catch (InterruptedException e) {}
         }
         
         
  
  
  
  1.3       +85 -60    JBossCache/tests/functional/org/jboss/cache/lock/LockReleaseTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LockReleaseTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/lock/LockReleaseTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- LockReleaseTest.java	20 Jul 2006 10:31:35 -0000	1.2
  +++ LockReleaseTest.java	6 Sep 2006 15:30:58 -0000	1.3
  @@ -26,154 +26,174 @@
    * Verifies that there are no read locks held when a transaction ends.
    *
    * @author Bela Ban
  - * @version $Id: LockReleaseTest.java,v 1.2 2006/07/20 10:31:35 msurtani Exp $
  + * @version $Id: LockReleaseTest.java,v 1.3 2006/09/06 15:30:58 msurtani Exp $
    */
  -public class LockReleaseTest extends TestCase {
  -   TreeCache cache=null;
  -   UserTransaction tx=null;
  +public class LockReleaseTest extends TestCase
  +{
  +   TreeCache cache = null;
  +   UserTransaction tx = null;
      Log log;
  -   Properties p=null;
  -   String old_factory=null;
  -   final String FACTORY="org.jboss.cache.transaction.DummyContextFactory";
  -   final Fqn    NODE1=Fqn.fromString("/test");
  -   final Fqn    NODE2=Fqn.fromString("/my/test");
  -   final String KEY="key";
  -   final String VAL1="val1";
  -   final String VAL2="val2";
  +   Properties p = null;
  +   String old_factory = null;
  +   final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
  +   final Fqn NODE1 = Fqn.fromString("/test");
  +   final Fqn NODE2 = Fqn.fromString("/my/test");
  +   final String KEY = "key";
  +   final String VAL1 = "val1";
  +   final String VAL2 = "val2";
   
   
  -   public LockReleaseTest(String name) {
  +   public LockReleaseTest(String name)
  +   {
         super(name);
      }
   
  -   public void setUp() throws Exception {
  +   public void setUp() throws Exception
  +   {
         super.setUp();
  -      old_factory=System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
  +      old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
         DummyTransactionManager.getInstance();
  -      if(p == null) {
  -         p=new Properties();
  +      if (p == null)
  +      {
  +         p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
         }
  -      tx=(UserTransaction)new InitialContext(p).lookup("UserTransaction");
  +      tx = (UserTransaction) new InitialContext(p).lookup("UserTransaction");
      }
   
  -   public void tearDown() throws Exception {
  +   public void tearDown() throws Exception
  +   {
         super.tearDown();
  -      if(cache != null)
  -         cache.stopService();
  +      if (cache != null)
  +         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;
  +         old_factory = null;
         }
   
  -      if(tx != null) {
  -         try {
  +      if (tx != null)
  +      {
  +         try
  +         {
               tx.rollback();
            }
  -         catch(Throwable t) {
  +         catch (Throwable t)
  +         {
            }
  -         tx=null;
  +         tx = null;
         }
      }
   
  -   TreeCache createCache(IsolationLevel level) throws Exception {
  -      TreeCache c=new TreeCache();
  +   TreeCache createCache(IsolationLevel level) throws Exception
  +   {
  +      TreeCache c = new TreeCache();
         c.getConfiguration().setClusterName("test");
         c.getConfiguration().setInitialStateRetrievalTimeout(10000);
         c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
         c.getConfiguration().setLockAcquisitionTimeout(500);
         c.getConfiguration().setIsolationLevel(level);
  -      c.createService();
  -      c.startService();
  +      c.create();
  +      c.start();
         return c;
      }
   
   
  -
  -   public void testReadWithReadUncommitted() throws Exception {
  +   public void testReadWithReadUncommitted() throws Exception
  +   {
         testReadLockRelease(IsolationLevel.READ_UNCOMMITTED);
      }
   
  -   public void testWriteWithReadUncommitted() throws Exception {
  +   public void testWriteWithReadUncommitted() throws Exception
  +   {
         testWriteLockRelease(IsolationLevel.READ_UNCOMMITTED);
      }
   
   
  -   public void testReadWithReadCommitted() throws Exception {
  +   public void testReadWithReadCommitted() throws Exception
  +   {
         testReadLockRelease(IsolationLevel.READ_COMMITTED);
      }
   
  -   public void testWriteWithReadCommitted() throws Exception {
  +   public void testWriteWithReadCommitted() throws Exception
  +   {
         testWriteLockRelease(IsolationLevel.READ_COMMITTED);
      }
   
   
  -   public void testReadWithRepeatableRead() throws Exception {
  +   public void testReadWithRepeatableRead() throws Exception
  +   {
         testReadLockRelease(IsolationLevel.REPEATABLE_READ);
      }
   
  -   public void testWriteWithRepeatableRead() throws Exception {
  +   public void testWriteWithRepeatableRead() throws Exception
  +   {
         testWriteLockRelease(IsolationLevel.REPEATABLE_READ);
      }
   
   
  -   public void testReadWithSerialzable() throws Exception {
  +   public void testReadWithSerialzable() throws Exception
  +   {
         testReadLockRelease(IsolationLevel.SERIALIZABLE);
      }
   
  -   public void testWriteWithSerializable() throws Exception {
  +   public void testWriteWithSerializable() throws Exception
  +   {
         testWriteLockRelease(IsolationLevel.SERIALIZABLE);
      }
   
   
  -   public void testGetKeys() throws Exception {
  -      cache=createCache(IsolationLevel.REPEATABLE_READ);
  +   public void testGetKeys() throws Exception
  +   {
  +      cache = createCache(IsolationLevel.REPEATABLE_READ);
         // add initial values outside of TX
         cache.put(NODE1, KEY, VAL1);
         cache.put(NODE2, KEY, VAL1);
         assertEquals("we ran outside of a TX, locks should have been released: ", 0, cache.getNumberOfLocksHeld());
   
  -      Set keys=cache.getKeys(NODE1);
  +      Set keys = cache.getKeys(NODE1);
         System.out.println("keys of " + NODE1 + " are " + keys);
         assertEquals("getKeys() called outside the TX should have released all locks", 0, cache.getNumberOfLocksHeld());
   
         tx.begin();
  -      keys=cache.getKeys(NODE1);
  +      keys = cache.getKeys(NODE1);
         assertEquals("we should hold 1 read locks now: ", 1, cache.getNumberOfLocksHeld());
  -      keys=cache.getKeys(NODE2);
  +      keys = cache.getKeys(NODE2);
         assertEquals("we should hold 3 read locks now: ", 3, cache.getNumberOfLocksHeld());
         tx.commit();
         assertEquals("we should have released all 3 read locks: ", 0, cache.getNumberOfLocksHeld());
      }
   
   
  -   public void testGetChildrenNames() throws Exception {
  -      cache=createCache(IsolationLevel.REPEATABLE_READ);
  +   public void testGetChildrenNames() throws Exception
  +   {
  +      cache = createCache(IsolationLevel.REPEATABLE_READ);
         // add initial values outside of TX
         cache.put(NODE1, KEY, VAL1);
         cache.put(NODE2, KEY, VAL1);
         assertEquals("we ran outside of a TX, locks should have been released: ", 0, cache.getNumberOfLocksHeld());
   
  -      Set keys=cache.getChildrenNames(NODE2);
  +      Set keys = cache.getChildrenNames(NODE2);
         System.out.println("keys of " + NODE2 + " are " + keys);
         assertEquals("getChildrenNames() called outside the TX should have released all locks", 0,
                      cache.getNumberOfLocksHeld());
   
         tx.begin();
  -      keys=cache.getChildrenNames(NODE1);
  +      keys = cache.getChildrenNames(NODE1);
         assertEquals("we should hold 1 read locks now: ", 1, cache.getNumberOfLocksHeld());
  -      keys=cache.getChildrenNames(NODE2);
  +      keys = cache.getChildrenNames(NODE2);
         assertEquals("we should hold 3 read locks now: ", 3, cache.getNumberOfLocksHeld());
         tx.commit();
         assertEquals("we should have released all 3 read locks: ", 0, cache.getNumberOfLocksHeld());
      }
   
  -   public void testPrint() throws Exception {
  -      cache=createCache(IsolationLevel.REPEATABLE_READ);
  +   public void testPrint() throws Exception
  +   {
  +      cache = createCache(IsolationLevel.REPEATABLE_READ);
         // add initial values outside of TX
         cache.put(NODE1, KEY, VAL1);
         cache.put(NODE2, KEY, VAL1);
  @@ -192,8 +212,9 @@
      }
   
   
  -   void testReadLockRelease(IsolationLevel level) throws Exception {
  -      cache=createCache(level);
  +   void testReadLockRelease(IsolationLevel level) throws Exception
  +   {
  +      cache = createCache(level);
         // add initial values outside of TX
         cache.put(NODE1, KEY, VAL1);
         cache.put(NODE2, KEY, VAL1);
  @@ -208,8 +229,9 @@
         assertEquals("we should have released all 3 read locks: ", 0, cache.getNumberOfLocksHeld());
      }
   
  -   void testWriteLockRelease(IsolationLevel level) throws Exception {
  -      cache=createCache(level);
  +   void testWriteLockRelease(IsolationLevel level) throws Exception
  +   {
  +      cache = createCache(level);
         // add initial values outside of TX
         cache.put(NODE1, KEY, VAL1);
         cache.put(NODE2, KEY, VAL1);
  @@ -224,16 +246,19 @@
         assertEquals("we should have released all 3 write locks: ", 0, cache.getNumberOfLocksHeld());
      }
   
  -   void log(String msg) {
  +   void log(String msg)
  +   {
         log.info("-- [" + Thread.currentThread() + "]: " + msg);
      }
   
   
  -   public static Test suite() throws Exception {
  +   public static Test suite() throws Exception
  +   {
         return new TestSuite(LockReleaseTest.class);
      }
   
  -   public static void main(String[] args) throws Exception {
  +   public static void main(String[] args) throws Exception
  +   {
         junit.textui.TestRunner.run(suite());
      }
   
  
  
  
  1.4       +73 -50    JBossCache/tests/functional/org/jboss/cache/lock/UpgradeLockTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UpgradeLockTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/lock/UpgradeLockTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- UpgradeLockTest.java	20 Jul 2006 10:31:35 -0000	1.3
  +++ UpgradeLockTest.java	6 Sep 2006 15:30:58 -0000	1.4
  @@ -24,108 +24,126 @@
    * Tests upgrade locks from read -> write
    *
    * @author Bela Ban
  - * @version $Id: UpgradeLockTest.java,v 1.3 2006/07/20 10:31:35 msurtani Exp $
  + * @version $Id: UpgradeLockTest.java,v 1.4 2006/09/06 15:30:58 msurtani Exp $
    */
  -public class UpgradeLockTest extends TestCase {
  -   TreeCache cache=null;
  -   UserTransaction tx=null;
  +public class UpgradeLockTest extends TestCase
  +{
  +   TreeCache cache = null;
  +   UserTransaction tx = null;
      Log log;
  -   Properties p=null;
  -   String old_factory=null;
  -   final String FACTORY="org.jboss.cache.transaction.DummyContextFactory";
  -   final String NODE1="/test";
  -   final String NODE2="/my/test";
  -   final String KEY="key";
  -   final String VAL1="val1";
  -   final String VAL2="val2";
  +   Properties p = null;
  +   String old_factory = null;
  +   final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
  +   final String NODE1 = "/test";
  +   final String NODE2 = "/my/test";
  +   final String KEY = "key";
  +   final String VAL1 = "val1";
  +   final String VAL2 = "val2";
   
   
  -   public UpgradeLockTest(String name) {
  +   public UpgradeLockTest(String name)
  +   {
         super(name);
      }
   
  -   public void setUp() throws Exception {
  +   public void setUp() throws Exception
  +   {
         super.setUp();
  -      old_factory=System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
  +      old_factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
         DummyTransactionManager.getInstance();
  -      if(p == null) {
  -         p=new Properties();
  +      if (p == null)
  +      {
  +         p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
         }
  -      tx=(UserTransaction)new InitialContext(p).lookup("UserTransaction");
  +      tx = (UserTransaction) new InitialContext(p).lookup("UserTransaction");
      }
   
  -   public void tearDown() throws Exception {
  +   public void tearDown() throws Exception
  +   {
         super.tearDown();
  -      if(cache != null)
  -         cache.stopService();
  +      if (cache != null)
  +         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;
  +         old_factory = null;
         }
   
  -      if(tx != null) {
  -         try {
  +      if (tx != null)
  +      {
  +         try
  +         {
               tx.rollback();
            }
  -         catch(Throwable t) {
  +         catch (Throwable t)
  +         {
            }
  -         tx=null;
  +         tx = null;
         }
      }
   
  -   TreeCache createCache(IsolationLevel level) throws Exception {
  -      TreeCache c=new TreeCache();
  +   TreeCache createCache(IsolationLevel level) throws Exception
  +   {
  +      TreeCache c = new TreeCache();
         c.getConfiguration().setClusterName("test");
         c.getConfiguration().setInitialStateRetrievalTimeout(10000);
         c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
         c.getConfiguration().setLockAcquisitionTimeout(500);
         c.getConfiguration().setIsolationLevel(level);
  -      c.createService();
  -      c.startService();
  +      c.create();
  +      c.start();
         return c;
      }
   
   
  -   public void testUpgradeWithNone() throws Exception {
  +   public void testUpgradeWithNone() throws Exception
  +   {
         runTestWithIsolationLevel(IsolationLevel.NONE);
      }
   
   
  -   public void testUpgradeWithReadUncommitted() throws Exception {
  +   public void testUpgradeWithReadUncommitted() throws Exception
  +   {
         runTestWithIsolationLevel(IsolationLevel.READ_UNCOMMITTED);
      }
   
  -   public void testUpgradeWithReadCommitted() throws Exception {
  +   public void testUpgradeWithReadCommitted() throws Exception
  +   {
         runTestWithIsolationLevel(IsolationLevel.READ_COMMITTED);
      }
   
  -   public void testUpgradeWithRepeatableRead() throws Exception {
  +   public void testUpgradeWithRepeatableRead() throws Exception
  +   {
         runTestWithIsolationLevel(IsolationLevel.REPEATABLE_READ);
      }
   
  -   public void testUpgradeWithSerializable() throws Exception {
  +   public void testUpgradeWithSerializable() throws Exception
  +   {
         runTestWithIsolationLevel(IsolationLevel.SERIALIZABLE);
      }
   
  -   public void testIsolationLevelSerializable() throws Exception {
  +   public void testIsolationLevelSerializable() throws Exception
  +   {
         _testIsolationLevel(IsolationLevel.SERIALIZABLE);
      }
   
  -   public void testIsolationLevelNone() throws Exception {
  +   public void testIsolationLevelNone() throws Exception
  +   {
         _testIsolationLevel(IsolationLevel.NONE);
      }
   
   
  -   void _testIsolationLevel(IsolationLevel l) throws Exception {
  -      cache=createCache(l);
  +   void _testIsolationLevel(IsolationLevel l) throws Exception
  +   {
  +      cache = createCache(l);
         tx.begin();
   
  -      int expected_num_locks=l == IsolationLevel.NONE? 0 : 1;
  +      int expected_num_locks = l == IsolationLevel.NONE ? 0 : 1;
   
         cache.put(NODE1, null);
         assertEquals(expected_num_locks, cache.getNumberOfLocksHeld());
  @@ -138,15 +156,16 @@
      }
   
   
  -
  -   void runTestWithIsolationLevel(IsolationLevel level) throws Exception {
  -      cache=createCache(level);
  +   void runTestWithIsolationLevel(IsolationLevel level) throws Exception
  +   {
  +      cache = createCache(level);
         // add initial values outside of TX
         cache.put(NODE1, KEY, VAL1);
         cache.put(NODE2, KEY, VAL1);
   
         tx.begin();
  -      try {
  +      try
  +      {
            assertEquals(VAL1, cache.get(NODE1, KEY));
            assertEquals(VAL1, cache.get(NODE2, KEY));
   
  @@ -156,8 +175,9 @@
            assertEquals(VAL2, cache.get(NODE2, KEY));
            tx.commit();
         }
  -      catch(Throwable t) {
  -         if(tx != null)
  +      catch (Throwable t)
  +      {
  +         if (tx != null)
               tx.rollback();
         }
         assertEquals(VAL2, cache.get(NODE1, KEY));
  @@ -165,17 +185,20 @@
      }
   
   
  -   void log(String msg) {
  +   void log(String msg)
  +   {
         log.info("-- [" + Thread.currentThread() + "]: " + msg);
      }
   
   
  -   public static Test suite() throws Exception {
  +   public static Test suite() throws Exception
  +   {
         // return getDeploySetup(TxUnitTestCase.class, "cachetest.jar");
         return new TestSuite(UpgradeLockTest.class);
      }
   
  -   public static void main(String[] args) throws Exception {
  +   public static void main(String[] args) throws Exception
  +   {
         junit.textui.TestRunner.run(suite());
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list