[jbosscache-commits] JBoss Cache SVN: r5894 - in core/trunk/src: test/java/org/jboss/cache/buddyreplication and 9 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed May 28 09:31:13 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-05-28 09:31:13 -0400 (Wed, 28 May 2008)
New Revision: 5894

Modified:
   core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
   core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationRejoinTest.java
   core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java
   core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
   core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java
   core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java
   core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java
   core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
   core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
Log:
Refactored tests so they dont use deprecated code

Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -241,6 +241,15 @@
    boolean isLocked(NodeSPI n);
 
    /**
+    * Returns true if the node is locked (either for reading or writing) by anyone, and false otherwise.
+    *
+    * @param n        node to inspect
+    * @param lockType lockType to test for
+    * @return true of locked; false if not.
+    */
+   boolean isLocked(NodeSPI n, LockType lockType);
+
+   /**
     * Retrieves the write lock owner, if any, for the current Fqn.
     *
     * @param f Fqn to inspect

Modified: core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -262,6 +262,21 @@
       return n.getLock().isLocked();
    }
 
+   public boolean isLocked(NodeSPI n, LockType type)
+   {
+      switch (type)
+      {
+         case READ:
+            return n.getLock().isReadLocked();
+         case WRITE:
+            return n.getLock().isWriteLocked();
+         case NONE:
+         default:
+            return false;
+      }
+   }
+
+
    public Object getWriteOwner(Fqn f)
    {
       return getWriteOwner(dataContainer.peek(f));

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationRejoinTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationRejoinTest.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationRejoinTest.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -54,8 +54,8 @@
       // Cache1 will be used only for recovery.
       // Cache2 will perform some updates on the objects and then fail.
 
-      cache1 = new DefaultCacheFactory().createCache(c, false);
-      cache2 = new DefaultCacheFactory().createCache(c.clone(), false);
+      cache1 = new DefaultCacheFactory<String, Integer>().createCache(c, false);
+      cache2 = new DefaultCacheFactory<String, Integer>().createCache(c.clone(), false);
    }
 
    @AfterTest
@@ -172,7 +172,7 @@
       for (int i = 0; i < OBJECT_COUNT / 2; i++)
       {
          Integer integer = cache.get(Fqn.fromString(String.valueOf(i)), "counter");
-         cache.put(Fqn.fromString(String.valueOf(i)), "counter", integer.intValue() + 1);
+         cache.put(Fqn.fromString(String.valueOf(i)), "counter", integer + 1);
       }
    }
 
@@ -186,7 +186,7 @@
    {
       for (int i = 0; i < OBJECT_COUNT; i++)
       {
-         cache.put(new Fqn<String>(String.valueOf(i)), "counter", new Integer(0));
+         cache.put(Fqn.fromElements(String.valueOf(i)), "counter", 0);
       }
    }
 

Modified: core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -572,7 +572,7 @@
    /**
     * Recursively adds GUI nodes starting from fqn
     */
-   private void addGuiNode(Fqn<String> fqn)
+   private void addGuiNode(Fqn fqn)
    {
       Set<Object> children;
 
@@ -587,7 +587,7 @@
       {
          for (Object child_name : children)
          {
-            addGuiNode(new Fqn<String>(fqn, (String) child_name));
+            addGuiNode(Fqn.fromRelativeElements(fqn, (String) child_name));
          }
       }
    }
@@ -598,7 +598,7 @@
       Fqn<String> fqnToPath;
       if (path.length == 0) fqnToPath = Fqn.ROOT;
       List<String> elements = convertMyNodeArrayToStringArray(path);
-      fqnToPath = new Fqn<String>(elements);
+      fqnToPath = Fqn.fromList(elements);
       if (root.hasChild(fqnToPath))
       {
          return root.getChild(fqnToPath);
@@ -887,7 +887,7 @@
             fqnTextField.setText(Fqn.SEPARATOR);
          }
          Object[] information = {"Enter fully qualified name",
-               fqnTextField};
+                                 fqnTextField};
          final String btnString1 = "OK";
          final String btnString2 = "Cancel";
          Object[] options = {btnString1, btnString2};
@@ -924,7 +924,7 @@
          }
 
          Object[] information = {"Enter fully qualified name",
-               fqnTextField};
+                                 fqnTextField};
          final String btnString1 = "OK";
          final String btnString2 = "Cancel";
          Object[] options = {btnString1, btnString2};
@@ -960,7 +960,7 @@
             fqnTextField.setText(Fqn.SEPARATOR);
          }
          Object[] information = {"Enter fully qualified name",
-               fqnTextField};
+                                 fqnTextField};
          final String btnString1 = "OK";
          final String btnString2 = "Cancel";
          Object[] options = {btnString1, btnString2};

Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -1962,7 +1962,7 @@
     */
    public void testRemoveAndGetInTransaction() throws Exception
    {
-      Fqn fqn = new Fqn<String>("/a/b");
+      Fqn fqn = Fqn.fromString("/a/b");
       String key = "key";
       String value = "value";
 

Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -5,6 +5,9 @@
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.NodeSPI;
+import static org.jboss.cache.lock.LockType.READ;
+import static org.jboss.cache.lock.LockType.WRITE;
+import org.jboss.cache.misc.TestingUtil;
 import org.jboss.cache.transaction.DummyTransactionManagerLookup;
 import static org.testng.AssertJUnit.assertFalse;
 import static org.testng.AssertJUnit.assertTrue;
@@ -26,14 +29,16 @@
    private Cache<Object, Object> cache;
    private TransactionManager tm;
    private Fqn<String> fqn = Fqn.fromString("/a/b/c");
+   private LockManager lockManager;
 
    @BeforeMethod(alwaysRun = true)
    public void setUp()
    {
-      cache = new DefaultCacheFactory().createCache(false);
+      cache = new DefaultCacheFactory<Object, Object>().createCache(false);
       cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       cache.start();
       tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+      lockManager = TestingUtil.extractLockManager(cache);
    }
 
    @AfterMethod(alwaysRun = true)
@@ -58,12 +63,12 @@
       cache.put(fqn, "k2", "v2");
       NodeSPI<Object, Object> n = (NodeSPI<Object, Object>) cache.getRoot().getChild(fqn);
 
-      assertFalse(n.getLock().isReadLocked());
-      assertTrue(n.getLock().isWriteLocked());
-      assertTrue(n.getParent().getLock().isReadLocked());
-      assertFalse(n.getParent().getLock().isWriteLocked());
-      assertTrue(n.getParent().getParent().getLock().isReadLocked());
-      assertFalse(n.getParent().getParent().getLock().isWriteLocked());
+      assertFalse(lockManager.isLocked(n, READ));
+      assertTrue(lockManager.isLocked(n, WRITE));
+      assertTrue(lockManager.isLocked(n.getParent(), READ));
+      assertFalse(lockManager.isLocked(n.getParent(), WRITE));
+      assertTrue(lockManager.isLocked(n.getParent().getParent(), READ));
+      assertFalse(lockManager.isLocked(n.getParent().getParent(), WRITE));
 
       tm.commit();
 
@@ -80,12 +85,12 @@
       cache.get(fqn, "k2");
       NodeSPI<Object, Object> n = (NodeSPI<Object, Object>) cache.getRoot().getChild(fqn);
 
-      assertTrue(n.getLock().isReadLocked());
-      assertFalse(n.getLock().isWriteLocked());
-      assertTrue(n.getParent().getLock().isReadLocked());
-      assertFalse(n.getParent().getLock().isWriteLocked());
-      assertTrue(n.getParent().getParent().getLock().isReadLocked());
-      assertFalse(n.getParent().getParent().getLock().isWriteLocked());
+      assertTrue(lockManager.isLocked(n, READ));
+      assertFalse(lockManager.isLocked(n, WRITE));
+      assertTrue(lockManager.isLocked(n.getParent(), READ));
+      assertFalse(lockManager.isLocked(n.getParent(), WRITE));
+      assertTrue(lockManager.isLocked(n.getParent().getParent(), READ));
+      assertFalse(lockManager.isLocked(n.getParent().getParent(), WRITE));
 
       tm.commit();
 
@@ -102,12 +107,12 @@
       cache.remove(fqn, "k2");
       NodeSPI<Object, Object> n = (NodeSPI<Object, Object>) cache.getRoot().getChild(fqn);
 
-      assertFalse(n.getLock().isReadLocked());
-      assertTrue(n.getLock().isWriteLocked());
-      assertTrue(n.getParent().getLock().isReadLocked());
-      assertFalse(n.getParent().getLock().isWriteLocked());
-      assertTrue(n.getParent().getParent().getLock().isReadLocked());
-      assertFalse(n.getParent().getParent().getLock().isWriteLocked());
+      assertFalse(lockManager.isLocked(n, READ));
+      assertTrue(lockManager.isLocked(n, WRITE));
+      assertTrue(lockManager.isLocked(n.getParent(), READ));
+      assertFalse(lockManager.isLocked(n.getParent(), WRITE));
+      assertTrue(lockManager.isLocked(n.getParent().getParent(), READ));
+      assertFalse(lockManager.isLocked(n.getParent().getParent(), WRITE));
 
       tm.commit();
 

Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -19,6 +19,7 @@
 import org.jboss.cache.invocation.CacheInvocationDelegate;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.CacheLoaderManager;
+import org.jboss.cache.lock.LockManager;
 import org.jboss.cache.util.CachePrinter;
 import org.jgroups.JChannel;
 
@@ -58,7 +59,8 @@
          field = baseType.getDeclaredField(fieldName);
          field.setAccessible(true);
          field.set(owner, newValue);
-      } catch (Exception e)
+      }
+      catch (Exception e)
       {
          throw new RuntimeException(e);//just to simplify exception handeling
       }
@@ -80,7 +82,8 @@
          {
             e.printStackTrace();
             return null;
-         } else
+         }
+         else
          {
             // try with superclass!!
             return extractField(type.getSuperclass(), target, fieldName);
@@ -286,7 +289,8 @@
       if (members == null || memberCount > members.size())
       {
          return false;
-      } else if (memberCount < members.size())
+      }
+      else if (memberCount < members.size())
       {
          // This is an exceptional condition
          StringBuffer sb = new StringBuffer("Cache at address ");
@@ -328,7 +332,8 @@
       if (members == null || memberCount > members.size())
       {
          return false;
-      } else if (memberCount < members.size())
+      }
+      else if (memberCount < members.size())
       {
          if (barfIfTooManyMembers)
          {
@@ -351,7 +356,8 @@
             sb.append(')');
 
             throw new IllegalStateException(sb.toString());
-         } else return false;
+         }
+         else return false;
       }
 
       return true;
@@ -487,6 +493,11 @@
       return (ComponentRegistry) extractField(cache, "componentRegistry");
    }
 
+   public static LockManager extractLockManager(Cache cache)
+   {
+      return extractComponentRegistry(cache).getComponent(LockManager.class);
+   }
+
    /**
     * For testing only - introspects a cache and extracts the ComponentRegistry
     *
@@ -607,7 +618,8 @@
          if (c == null)
          {
             System.out.println("  ** Cache " + count + " is null!");
-         } else
+         }
+         else
          {
             System.out.println("  ** Cache " + count + " is " + c.getLocalAddress());
             System.out.println("    " + CachePrinter.printCacheLockingInfo(c));

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -2,9 +2,9 @@
 
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.loader.SamplePojo;
+import org.jboss.cache.lock.LockManager;
 import org.jboss.cache.misc.TestingUtil;
 import org.jboss.cache.transaction.GlobalTransaction;
 import org.jboss.cache.transaction.OptimisticTransactionEntry;
@@ -22,8 +22,6 @@
 @Test(groups = {"functional", "transaction"})
 public class AsyncFullStackInterceptorTest extends AbstractOptimisticTestCase
 {
-
-
    /**
     * @param name
     */
@@ -56,7 +54,6 @@
       assertNull(cache.getNode("/one"));
 
       destroyCache(cache);
-
    }
 
    public void testSingleInstanceDuplicateCommit() throws Exception
@@ -65,6 +62,7 @@
       CacheSPI<Object, Object> cache = createAsyncReplicatedCache();
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
       assertNull(mgr.getTransaction());
 
       mgr.begin();
@@ -97,9 +95,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getNode("/one"));
-      assertEquals(false, cache.getRoot().getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode(Fqn.fromString("/one"))).getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode(Fqn.fromString("/one/two"))).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode(Fqn.fromString("/one"))));
+      assertEquals(false, lockManager.isLocked(cache.getNode(Fqn.fromString("/one/two"))));
       assertNotNull(cache.getNode("/one/two"));
       assertNotNull(cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -111,6 +109,7 @@
    {
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createAsyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -161,14 +160,13 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getNode("/one"));
-      assertEquals(false, cache.getRoot().getLock().isLocked());
-      assertEquals(false, cache.getNode("/one").getLock().isLocked());
-      assertEquals(false, cache.getNode("/one/two").getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertEquals(pojo2, cache.get(Fqn.fromString("/one/two"), "key1"));
 
       destroyCache(cache);
-
    }
 
    public void test2InstanceCommit() throws Exception
@@ -176,6 +174,8 @@
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createAsyncReplicatedCache();
       CacheSPI<Object, Object> cache2 = createAsyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
+      LockManager lockManager2 = TestingUtil.extractLockManager(cache2);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -202,9 +202,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getNode("/one"));
-      assertEquals(false, cache.getRoot().getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertNotNull(cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -221,9 +221,9 @@
 
       assertTrue(cache2.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache2.getRoot().getChild("one"));
-      assertEquals(false, cache2.getRoot().getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache2.getNode("/one")).getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache2.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager2.isLocked(cache2.getRoot()));
+      assertEquals(false, lockManager2.isLocked(cache2.getNode("/one")));
+      assertEquals(false, lockManager2.isLocked(cache2.getNode("/one/two")));
       assertNotNull(cache2.getNode("/one").getChild("two"));
       assertNotNull(cache2.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -236,6 +236,8 @@
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createAsyncReplicatedCache();
       CacheSPI<Object, Object> cache2 = createAsyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
+      LockManager lockManager2 = TestingUtil.extractLockManager(cache2);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -262,9 +264,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getNode("/one"));
-      assertEquals(false, cache.getRoot().getLock().isLocked());
-      assertEquals(false, cache.getNode("/one").getLock().isLocked());
-      assertEquals(false, cache.getNode("/one/two").getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertNotNull(cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -281,9 +283,9 @@
 
       assertTrue(cache2.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache2.getRoot().getChild("one"));
-      assertEquals(false, cache2.getRoot().getLock().isLocked());
-      assertEquals(false, cache2.getNode("/one").getLock().isLocked());
-      assertEquals(false, cache2.getNode("/one/two").getLock().isLocked());
+      assertEquals(false, lockManager2.isLocked(cache2.getRoot()));
+      assertEquals(false, lockManager2.isLocked(cache2.getNode("/one")));
+      assertEquals(false, lockManager2.isLocked(cache2.getNode("/one/two")));
       assertNotNull(cache2.getNode("/one").getChild("two"));
       assertNotNull(cache2.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -306,6 +308,7 @@
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createAsyncReplicatedCache();
       CacheSPI<Object, Object> cache2 = createAsyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -365,9 +368,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getNode("/one"));
-      assertEquals(false, cache.getRoot().getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertEquals(pojo2, cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -376,6 +379,7 @@
 
    }
 
+   @SuppressWarnings("unchecked")
    protected CacheSPI<Object, Object> createAsyncReplicatedCache() throws Exception
    {
       return createReplicatedCache("temp" + groupIncreaser, Configuration.CacheMode.REPL_ASYNC);

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -4,9 +4,10 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.loader.SamplePojo;
+import org.jboss.cache.lock.LockManager;
+import org.jboss.cache.misc.TestingUtil;
 import org.jboss.cache.transaction.GlobalTransaction;
 import org.jboss.cache.transaction.OptimisticTransactionEntry;
 import org.jboss.cache.transaction.TransactionTable;
@@ -66,6 +67,7 @@
       TestListener listener = new TestListener();
 
       CacheSPI<Object, Object> cache = createCacheWithListener(listener);
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -83,11 +85,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getRoot().getChild("one"));
-      assertEquals(false, cache.getRoot().getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertNotNull(cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -102,6 +102,7 @@
    {
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createCacheWithListener();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -127,11 +128,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getRoot().getChild("one"));
-      assertEquals(false, cache.getRoot().getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertNotNull(cache.get(Fqn.fromString("/one/two"), "key1"));
       destroyCache(cache);
@@ -172,6 +171,7 @@
    {
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createSyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -206,11 +206,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getRoot().getChild("one"));
-      assertEquals(false, cache.getRoot().getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertNotNull(cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -222,6 +220,7 @@
    {
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createSyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -273,11 +272,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getRoot().getChild("one"));
-      assertEquals(false, cache.getRoot().getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertEquals(pojo2, cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -290,6 +287,8 @@
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createSyncReplicatedCache();
       CacheSPI<Object, Object> cache2 = createSyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
+      LockManager lockManager2 = TestingUtil.extractLockManager(cache2);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -316,11 +315,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getRoot().getChild("one"));
-      assertEquals(false, cache.getRoot().getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertNotNull(cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -334,9 +331,9 @@
 
       assertTrue(cache2.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache2.getRoot().getChild("one"));
-      assertEquals(false, cache2.getRoot().getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache2.getNode("/one")).getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache2.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager2.isLocked(cache2.getRoot()));
+      assertEquals(false, lockManager2.isLocked(cache2.getNode("/one")));
+      assertEquals(false, lockManager2.isLocked(cache2.getNode("/one/two")));
       assertNotNull(cache2.getNode("/one").getChild("two"));
       assertNotNull(cache2.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -349,6 +346,8 @@
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createSyncReplicatedCache();
       CacheSPI<Object, Object> cache2 = createSyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
+      LockManager lockManager2 = TestingUtil.extractLockManager(cache2);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -375,11 +374,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getRoot().getChild("one"));
-      assertEquals(false, cache.getRoot().getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock()
-            .isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertNotNull(cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -393,9 +390,9 @@
 
       assertTrue(cache2.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache2.getRoot().getChild("one"));
-      assertEquals(false, cache2.getRoot().getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache2.getNode("/one")).getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache2.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager2.isLocked(cache2.getRoot()));
+      assertEquals(false, lockManager2.isLocked(cache2.getNode("/one")));
+      assertEquals(false, lockManager2.isLocked(cache2.getNode("/one/two")));
       assertNotNull(cache2.getNode("/one").getChild("two"));
       assertNotNull(cache2.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -415,6 +412,7 @@
       groupIncreaser++;
       CacheSPI<Object, Object> cache = createSyncReplicatedCache();
       CacheSPI<Object, Object> cache2 = createSyncReplicatedCache();
+      LockManager lockManager = TestingUtil.extractLockManager(cache);
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       assertNull(mgr.getTransaction());
@@ -475,9 +473,9 @@
 
       assertTrue(cache.exists(Fqn.fromString("/one/two")));
       assertNotNull(cache.getRoot().getChild("one"));
-      assertEquals(false, cache.getRoot().getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one")).getLock().isLocked());
-      assertEquals(false, ((NodeSPI<Object, Object>) cache.getNode("/one/two")).getLock().isLocked());
+      assertEquals(false, lockManager.isLocked(cache.getRoot()));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one")));
+      assertEquals(false, lockManager.isLocked(cache.getNode("/one/two")));
       assertNotNull(cache.getNode("/one").getChild("two"));
       assertEquals(pojo2, cache.get(Fqn.fromString("/one/two"), "key1"));
 
@@ -642,7 +640,7 @@
       destroyCache(cache);
    }
 
-
+   @SuppressWarnings("unchecked")
    protected CacheSPI<Object, Object> createSyncReplicatedCache() throws Exception
    {
       return createReplicatedCache("temp" + groupIncreaser, Configuration.CacheMode.REPL_SYNC);
@@ -660,7 +658,7 @@
 
    public void testPuts() throws Exception
    {
-      CacheSPI cache = createCache();
+      CacheSPI<Object, Object> cache = createCache();
       Transaction tx;
 
       TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();

Modified: core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -6,8 +6,9 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.lock.NodeLock;
-import static org.testng.AssertJUnit.assertFalse;
+import org.jboss.cache.lock.LockManager;
+import org.jboss.cache.lock.LockType;
+import org.jboss.cache.misc.TestingUtil;
 import static org.testng.AssertJUnit.assertTrue;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -33,7 +34,7 @@
    {
       Configuration c = new Configuration();
       c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
-      CacheFactory<String, String> instance = new DefaultCacheFactory();
+      CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
       cache = (CacheSPI<String, String>) instance.createCache(c);
       tm = cache.getTransactionManager();
    }
@@ -114,27 +115,23 @@
 
    private void assertNotLocked(Fqn fqn)
    {
-      NodeSPI<String, String> n = cache.peek(fqn, true);
-      NodeLock lock = n.getLock();
-      assertFalse("node " + fqn + " is locked!", lock.isLocked());
+      assert !TestingUtil.extractLockManager(cache).isLocked(cache.peek(fqn, true)) : "Node " + fqn + " is locked!!";
    }
 
    private void assertLocked(Object owner, Fqn fqn, boolean write_locked)
    {
+      LockManager lm = TestingUtil.extractLockManager(cache);
       NodeSPI<String, String> n = cache.peek(fqn, true);
-      if (owner == null)
-         owner = Thread.currentThread();
-      NodeLock lock = n.getLock();
-      assertTrue("node " + fqn + " is not locked", lock.isLocked());
+      if (owner == null) owner = Thread.currentThread();
+      assertTrue("node " + fqn + " is not locked", lm.isLocked(n));
       if (write_locked)
       {
-         assertTrue("node " + fqn + " is not write-locked" + (lock.isReadLocked() ? " but is read-locked instead!" : "!"), lock.isWriteLocked());
+         assertTrue("node " + fqn + " is not write-locked by owner " + owner, lm.ownsLock(fqn, LockType.WRITE, owner));
       }
       else
       {
-         assertTrue("node " + fqn + " is not read-locked" + (lock.isWriteLocked() ? " but is write-locked instead!" : "!"), lock.isReadLocked());
+         assertTrue("node " + fqn + " is not read-locked by owner " + owner, lm.ownsLock(fqn, LockType.READ, owner));
       }
-      assertTrue("owner " + owner + "is not owner for lock " + lock, lock.isOwner(owner));
    }
 
 }

Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -85,8 +85,8 @@
 
    private void initCaches(Configuration.CacheMode caching_mode) throws Exception
    {
-      cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(false);
-      cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(false);
+      cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+      cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
       cache1.getConfiguration().setCacheMode(caching_mode);
       cache2.getConfiguration().setCacheMode(caching_mode);
       cache1.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
@@ -113,6 +113,9 @@
     * to integrate the given cache with a multiplexer.
     * <p/>
     * param cache a cache that has been configured but not yet created.
+    *
+    * @param cache cache
+    * @throws Exception exception
     */
    protected void configureMultiplexer(Cache cache) throws Exception
    {
@@ -149,7 +152,7 @@
    {
       initCaches(Configuration.CacheMode.REPL_SYNC);
       cache1.getConfiguration().setSyncCommitPhase(true);
-      cache1.getRoot().getLock().releaseAll();
+      TestingUtil.extractLockManager(cache1).unlockAll(cache1.getRoot());
       TransactionManager tm = beginTransaction();
       cache1.put("/bela/ban", "name", "Bela Ban");
       assertEquals(3, cache1.getNumberOfLocksHeld());
@@ -185,9 +188,6 @@
       assertTrue("\"age\" must be 38", age == 38);
    }
 
-   /**
-    * @throws Exception
-    */
    public void testSimplePut() throws Exception
    {
       initCaches(Configuration.CacheMode.REPL_SYNC);
@@ -466,8 +466,6 @@
    /**
     * Test for JBCACHE-361 -- does marking a tx on the remote side
     * rollback-only cause a rollback on the originating side?
-    *
-    * @throws Exception
     */
    public void testSyncReplWithRemoteRollback() throws Exception
    {
@@ -586,7 +584,7 @@
     * SynchronizationHandlers to register (atHead, atTail), and the OrderedSynchronizationHandler would call the
     * SynchronizationHandler in the order in which they are defined.
     *
-    * @throws Exception
+    * @throws Exception exception
     */
    public void testConcurrentPuts() throws Exception
    {
@@ -686,8 +684,8 @@
    {
       Object myMutex = new Object();
 
-      final CacheSPI c1 = (CacheSPI) new DefaultCacheFactory().createCache(false);
-      final CacheSPI c2 = (CacheSPI) new DefaultCacheFactory().createCache(false);
+      final CacheSPI<Object, Object> c1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+      final CacheSPI<Object, Object> c2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
       c1.getConfiguration().setClusterName("TempCluster");
       c2.getConfiguration().setClusterName("TempCluster");
       c1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
@@ -708,7 +706,7 @@
 
       class MyThread extends Thread
       {
-         Object mutex;
+         final Object mutex;
 
          public MyThread(String name, Object mutex)
          {
@@ -747,6 +745,7 @@
                }
                catch (Exception e)
                {
+                  // do nothing
                }
             }
          }
@@ -984,12 +983,10 @@
     * the cache2.get will get different values.
     * Note that we have used sleep to interpose thread execution sequence.
     * Although it's not fool proof, it is rather simple and intuitive.
-    *
-    * @throws Exception
     */
    public void testPutTx() throws Exception
    {
-      TransactionManager tm = null;
+      TransactionManager tm;
 
       try
       {
@@ -1032,7 +1029,7 @@
       {
          public void run()
          {
-            TransactionManager tm = null;
+            TransactionManager tm;
 
             try
             {
@@ -1073,7 +1070,7 @@
       {
          public void run()
          {
-            TransactionManager tm = null;
+            TransactionManager tm;
 
             try
             {
@@ -1133,7 +1130,7 @@
       {
          public void run()
          {
-            TransactionManager tm = null;
+            TransactionManager tm;
 
             try
             {
@@ -1164,7 +1161,7 @@
       {
          public void run()
          {
-            TransactionManager tm = null;
+            TransactionManager tm;
 
             try
             {
@@ -1243,7 +1240,7 @@
       CacheSPI<Object, Object> callbackCache;
       Object callbackKey;
       Exception ex;
-      Object mutex = new Object();
+      final Object mutex = new Object();
 
       CallbackListener(CacheSPI<Object, Object> cache, Object callbackKey)
       {

Modified: core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -16,7 +16,10 @@
 import org.jboss.cache.Node;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.lock.NodeLock;
+import org.jboss.cache.lock.LockManager;
+import static org.jboss.cache.lock.LockType.READ;
+import static org.jboss.cache.lock.LockType.WRITE;
+import org.jboss.cache.misc.TestingUtil;
 import org.jboss.cache.util.CachePrinter;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
@@ -46,7 +49,8 @@
 {
    CacheSPI<String, Comparable> cache = null;
    UserTransaction tx = null;
-   Exception thread_ex;
+   Exception exception;
+   LockManager lockManager;
 
    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception
@@ -63,7 +67,8 @@
 
       cache.create();
       cache.start();
-      thread_ex = null;
+      exception = null;
+      lockManager = TestingUtil.extractLockManager(cache);
    }
 
    @AfterMethod(alwaysRun = true)
@@ -86,6 +91,7 @@
          }
          catch (Throwable t)
          {
+            // do nothing
          }
          tx = null;
       }
@@ -505,24 +511,18 @@
       cache.put("/a/b/c", null);
       cache.put("/a/b/c", null);
 
-      NodeSPI n = (NodeSPI) cache.getNode("/a");
-      NodeLock lock = n.getLock();
-      int num = lock.getReaderOwners().size();
-      assertEquals(0, num);
+      NodeSPI n = cache.getNode("/a");
+      assert !lockManager.isLocked(n, READ);
       // make sure this is write locked.
       assertLocked(gtx, "/a", true);
 
-      n = (NodeSPI) cache.getNode("/a/b");
-      lock = n.getLock();
-      num = lock.getReaderOwners().size();
-      assertEquals(0, num);
+      n = cache.getNode("/a/b");
+      assert !lockManager.isLocked(n, READ);
       // make sure this is write locked.
       assertLocked(gtx, "/a/b", true);
 
-      n = (NodeSPI) cache.getNode("/a/b/c");
-      lock = n.getLock();
-      num = lock.getReaderOwners().size();
-      assertEquals(0, num);
+      n = cache.getNode("/a/b/c");
+      assert !lockManager.isLocked(n, READ);
       // make sure this is write locked.
       assertLocked(gtx, "/a/b/c", true);
 
@@ -530,24 +530,19 @@
       assertEquals(0, cache.getNumberOfLocksHeld());
    }
 
-   private void assertLocked(Object owner, String fqn, boolean write_locked)
+   private void assertLocked(Object owner, String fqn, boolean writeLocked)
    {
       NodeSPI<String, Comparable> n = cache.peek(Fqn.fromString(fqn), true);
-      NodeLock lock = n.getLock();
-      if (owner == null)
+      if (owner == null) owner = Thread.currentThread();
+      assertTrue("node " + fqn + " is not locked", lockManager.isLocked(n));
+      if (writeLocked)
       {
-         owner = Thread.currentThread();
+         assertTrue("node " + fqn + " is not write-locked by owner " + owner, lockManager.ownsLock(Fqn.fromString(fqn), WRITE, owner));
       }
-      assertTrue("node " + fqn + " is not locked", lock.isLocked());
-      if (write_locked)
-      {
-         assertTrue("node " + fqn + " is not write-locked" + (lock.isReadLocked() ? " but is read-locked instead!" : "!"), lock.isWriteLocked());
-      }
       else
       {
-         assertTrue("node " + fqn + " is not read-locked" + (lock.isWriteLocked() ? " but is write-locked instead!" : "!"), lock.isReadLocked());
+         assertTrue("node " + fqn + " is not read-locked by owner " + owner, lockManager.ownsLock(Fqn.fromString(fqn), READ, owner));
       }
-      assertTrue("owner " + owner + "is not owner", lock.isOwner(owner));
    }
 
    public void testConcurrentNodeAccessOnRemovalWithTx() throws Exception
@@ -558,10 +553,8 @@
       // this node should now be locked.
       TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
       Transaction t = tm.suspend();
-      Transaction t2;
       // start a new tx
       tm.begin();
-      t2 = tm.getTransaction();
       try
       {
          cache.getNode("/a/b/c");// should fail
@@ -879,7 +872,7 @@
             }
             catch (Exception e)
             {
-               thread_ex = e;
+               exception = e;
             }
          }
       }
@@ -908,7 +901,7 @@
             }
             catch (Exception e)
             {
-               thread_ex = e;
+               exception = e;
             }
          }
       }
@@ -919,9 +912,9 @@
       writer.start();
       reader.join();
       writer.join();
-      if (thread_ex != null)
+      if (exception != null)
       {
-         throw thread_ex;
+         throw exception;
       }
    }
 

Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java	2008-05-28 09:14:50 UTC (rev 5893)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java	2008-05-28 13:31:13 UTC (rev 5894)
@@ -1,6 +1,10 @@
 package org.jboss.cache.util.internals;
 
-import org.jboss.cache.*;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Region;
+import org.jboss.cache.RegionManager;
 import org.jboss.cache.config.EvictionConfig;
 import org.jboss.cache.config.EvictionRegionConfig;
 import org.jboss.cache.eviction.EvictionTimerTask;
@@ -8,7 +12,6 @@
 import org.jboss.cache.misc.TestingUtil;
 
 import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
 import java.util.Timer;
 
 /**
@@ -45,10 +48,11 @@
    {
       try
       {
-         Method method = EvictionTimerTask.class.getDeclaredMethod("processRegions", null);
+         Method method = EvictionTimerTask.class.getDeclaredMethod("processRegions", new Class[]{null});
          method.setAccessible(true);
          method.invoke(timerTask);
-      } catch (Exception e)
+      }
+      catch (Exception e)
       {
          e.printStackTrace();
          throw new IllegalStateException(e);
@@ -71,7 +75,8 @@
       {
          LRUConfiguration configuration = (LRUConfiguration) erConfig.getEvictionPolicyConfig();
          ttl = configuration.getTimeToLiveSeconds();
-      } else
+      }
+      else
       {
          throw new IllegalArgumentException("Only LRU being handled for now; please add other implementations here");
       }




More information about the jbosscache-commits mailing list