[jbosscache-commits] JBoss Cache SVN: r7630 - in core/trunk/src/test/java/org/jboss/cache/api: mvcc/read_committed and 2 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Feb 3 08:44:20 EST 2009


Author: mircea.markus
Date: 2009-02-03 08:44:19 -0500 (Tue, 03 Feb 2009)
New Revision: 7630

Added:
   core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPIWithCLTest.java
   core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeMoveWithCLMvccTest.java
   core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveWithCLMvccTest.java
   core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeMoveAPIWithCLOptimisticTest.java
Modified:
   core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
Log:
CL tests interfered causing intermitent failures, fixed that by sepparating tests

Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java	2009-02-03 09:56:12 UTC (rev 7629)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java	2009-02-03 13:44:19 UTC (rev 7630)
@@ -3,19 +3,13 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.*;
-import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.element.LoadersElementParser;
-import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
 import org.jboss.cache.util.TestingUtil;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.Test;
-import org.w3c.dom.Element;
 
 import javax.transaction.TransactionManager;
-import java.util.Map;
 import java.util.Random;
 import java.util.concurrent.CountDownLatch;
 
@@ -258,105 +252,6 @@
       assertEquals(nodeB, nodeA.getChildren().iterator().next());
    }
 
-   public void testWithCacheloaders() throws Exception
-   {
-      doCacheLoaderTest(false, false);
-   }
-
-   public void testWithPassivation() throws Exception
-   {
-      doCacheLoaderTest(true, false);
-   }
-
-   public void testWithCacheloadersTx() throws Exception
-   {
-      doCacheLoaderTest(false, true);
-   }
-
-   public void testWithPassivationTx() throws Exception
-   {
-      doCacheLoaderTest(true, true);
-   }
-
-   protected void doCacheLoaderTest(boolean pasv, boolean useTx) throws Exception
-   {
-      Node<Object, Object> rootNode = cache.getRoot();
-
-      cache.destroy();
-      cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig(pasv, "/", DummyInMemoryCacheLoader.class.getName(), "debug=true", false, false, false, false));
-      cache.start();
-
-      DummyInMemoryCacheLoader loader = (DummyInMemoryCacheLoader) cache.getCacheLoaderManager().getCacheLoader();
-
-      rootNode.put("key", "value");
-
-      if (!pasv)
-      {
-         Map m = loader.get(Fqn.ROOT);
-         assertNotNull("Should not be null", m);
-         assertEquals("value", m.get("key"));
-      }
-
-      Node<Object, Object> nodeA = rootNode.addChild(A);
-      nodeA.put(k, vA);
-      Node<Object, Object> nodeB = rootNode.addChild(B);
-      nodeB.put(k, vB);
-      Node<Object, Object> nodeC = nodeA.addChild(C);
-      nodeC.put(k, vC);
-      Node<Object, Object> nodeD = nodeC.addChild(D);
-      nodeD.put(k, vD);
-      Node<Object, Object> nodeE = nodeD.addChild(E);
-      nodeE.put(k, vE);
-      cache.evict(Fqn.ROOT, true);
-
-      // move
-      if (useTx) tm.begin();
-      cache.move(nodeC.getFqn(), nodeB.getFqn());
-      if (useTx) tm.commit();
-
-      // after eviction, the node objects we hold are probably stale.
-      nodeA = rootNode.getChild(A);
-      nodeB = rootNode.getChild(B);
-      nodeC = nodeB.getChild(C);
-      log.info("nodeC get child B ");
-      nodeD = nodeC.getChild(D);
-      log.info("nodeD get child E ");
-      nodeE = nodeD.getChild(E);
-
-      Fqn old_C = C;
-      Fqn old_D = Fqn.fromRelativeFqn(old_C, D);
-      Fqn old_E = Fqn.fromRelativeFqn(old_D, E);
-
-      // test data
-      assertEquals(vA, nodeA.get(k));
-      assertEquals(vB, nodeB.get(k));
-      assertEquals(vC, nodeC.get(k));
-      assertEquals(vD, nodeD.get(k));
-      assertEquals(vE, nodeE.get(k));
-
-      // parentage
-      assertEquals(rootNode, nodeA.getParent());
-      assertEquals(rootNode, nodeB.getParent());
-      assertEquals(nodeB, nodeC.getParent());
-      assertEquals(nodeC, nodeD.getParent());
-      assertEquals(nodeD, nodeE.getParent());
-
-
-      if (pasv) cache.evict(Fqn.ROOT, true);
-
-      //now inspect the loader.
-      assertEquals(vA, loader.get(nodeA.getFqn()).get(k));
-      assertEquals(vB, loader.get(nodeB.getFqn()).get(k));
-      assertEquals(vC, loader.get(nodeC.getFqn()).get(k));
-      assertEquals(vD, loader.get(nodeD.getFqn()).get(k));
-      assertEquals(vE, loader.get(nodeE.getFqn()).get(k));
-
-      assertNull(loader.get(old_C));
-      assertNull(loader.get(old_D));
-      assertNull(loader.get(old_E));
-
-   }
-
    public void testLocksDeepMove() throws Exception
    {
       Node<Object, Object> rootNode = cache.getRoot();
@@ -446,7 +341,7 @@
 
       for (int i = 0; i < N; i++)
       {
-         movers[i] = new Thread("Mover-" + i)
+         movers[i] = new Thread(Thread.currentThread().getName() + " -Mover-" + i)
          {
             public void run()
             {
@@ -541,25 +436,6 @@
       assert 0 == cache.getNumberOfLocksHeld();
    }
 
-   protected CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation, String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
-   {
-      String xml =
-            "      <loaders passivation=\"" + passivation + "\" shared=\"" + shared + "\">\n" +
-                  "         <preload>\n" +
-                  "            <node fqn=\"" + preload + "\"/>\n" +
-                  "         </preload>\n" +
-                  "         <loader class=\"" + cacheloaderClass + "\" async=\"" + async + "\" fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
-                  "                     purgeOnStartup=\"" + purgeOnStartup + "\">\n" +
-                  "            <properties>\n" +
-                  properties +
-                  "            </properties>\n" +
-                  "         </loader>\n" +
-                  "      </loaders>";
-      Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
-      LoadersElementParser elementParser = new LoadersElementParser();
-      return elementParser.parseLoadersElement(element);
-   }
-
    protected boolean isOptimistic()
    {
       return false;

Added: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPIWithCLTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPIWithCLTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPIWithCLTest.java	2009-02-03 13:44:19 UTC (rev 7630)
@@ -0,0 +1,172 @@
+package org.jboss.cache.api;
+
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+import org.jboss.cache.*;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import javax.transaction.TransactionManager;
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = {"functional", "pessimistic"}, testName = "api.NodeMoveAPIWithCLTest")
+public class NodeMoveAPIWithCLTest extends AbstractSingleCacheTest
+{
+
+   protected final Log log = LogFactory.getLog(getClass());
+
+   protected static final Fqn A = Fqn.fromString("/a"), B = Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn.fromString("/d"), E = Fqn.fromString("/e");
+   protected static final Object k = "key", vA = "valueA", vB = "valueB", vC = "valueC", vD = "valueD", vE = "valueE";
+
+   protected Configuration.NodeLockingScheme nodeLockingScheme = Configuration.NodeLockingScheme.PESSIMISTIC;
+
+   private TransactionManager tm;
+
+   protected CacheSPI createCache()
+   {
+      // start a single cache instance
+      CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache("configs/local-tx.xml", false, getClass());
+      cache.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+      cache.getConfiguration().setFetchInMemoryState(false);
+      cache.getConfiguration().setEvictionConfig(null);
+      configure(cache.getConfiguration());
+      cache.start();
+      tm = cache.getTransactionManager();
+      return cache;
+   }
+
+   protected void configure(Configuration c)
+   {
+      // to be overridden
+   }
+
+
+   public void testWithCacheloaders() throws Exception
+   {
+      doCacheLoaderTest(false, false);
+   }
+
+   public void testWithPassivation() throws Exception
+   {
+      doCacheLoaderTest(true, false);
+   }
+
+   public void testWithCacheloadersTx() throws Exception
+   {
+      doCacheLoaderTest(false, true);
+   }
+
+   public void testWithPassivationTx() throws Exception
+   {
+      doCacheLoaderTest(true, true);
+   }
+
+   protected void doCacheLoaderTest(boolean pasv, boolean useTx) throws Exception
+   {
+      Node<Object, Object> rootNode = cache.getRoot();
+
+      cache.destroy();
+      cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig(pasv, "/", DummyInMemoryCacheLoader.class.getName(), "debug=true", false, false, false, false));
+      cache.start();
+
+      DummyInMemoryCacheLoader loader = (DummyInMemoryCacheLoader) cache.getCacheLoaderManager().getCacheLoader();
+
+      rootNode.put("key", "value");
+
+      if (!pasv)
+      {
+         Map m = loader.get(Fqn.ROOT);
+         assertNotNull("Should not be null", m);
+         assertEquals("value", m.get("key"));
+      }
+
+      Node<Object, Object> nodeA = rootNode.addChild(A);
+      nodeA.put(k, vA);
+      Node<Object, Object> nodeB = rootNode.addChild(B);
+      nodeB.put(k, vB);
+      Node<Object, Object> nodeC = nodeA.addChild(C);
+      nodeC.put(k, vC);
+      Node<Object, Object> nodeD = nodeC.addChild(D);
+      nodeD.put(k, vD);
+      Node<Object, Object> nodeE = nodeD.addChild(E);
+      nodeE.put(k, vE);
+      cache.evict(Fqn.ROOT, true);
+
+      // move
+      if (useTx) tm.begin();
+      cache.move(nodeC.getFqn(), nodeB.getFqn());
+      if (useTx) tm.commit();
+
+      // after eviction, the node objects we hold are probably stale.
+      nodeA = rootNode.getChild(A);
+      nodeB = rootNode.getChild(B);
+      nodeC = nodeB.getChild(C);
+      log.info("nodeC get child B ");
+      nodeD = nodeC.getChild(D);
+      log.info("nodeD get child E ");
+      nodeE = nodeD.getChild(E);
+
+      Fqn old_C = C;
+      Fqn old_D = Fqn.fromRelativeFqn(old_C, D);
+      Fqn old_E = Fqn.fromRelativeFqn(old_D, E);
+
+      // test data
+      assertEquals(vA, nodeA.get(k));
+      assertEquals(vB, nodeB.get(k));
+      assertEquals(vC, nodeC.get(k));
+      assertEquals(vD, nodeD.get(k));
+      assertEquals(vE, nodeE.get(k));
+
+      // parentage
+      assertEquals(rootNode, nodeA.getParent());
+      assertEquals(rootNode, nodeB.getParent());
+      assertEquals(nodeB, nodeC.getParent());
+      assertEquals(nodeC, nodeD.getParent());
+      assertEquals(nodeD, nodeE.getParent());
+
+
+      if (pasv) cache.evict(Fqn.ROOT, true);
+
+      //now inspect the loader.
+      assertEquals(vA, loader.get(nodeA.getFqn()).get(k));
+      assertEquals(vB, loader.get(nodeB.getFqn()).get(k));
+      assertEquals(vC, loader.get(nodeC.getFqn()).get(k));
+      assertEquals(vD, loader.get(nodeD.getFqn()).get(k));
+      assertEquals(vE, loader.get(nodeE.getFqn()).get(k));
+
+      assertNull(loader.get(old_C));
+      assertNull(loader.get(old_D));
+      assertNull(loader.get(old_E));
+
+   }
+
+   protected CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation, String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
+   {
+      String xml =
+            "      <loaders passivation=\"" + passivation + "\" shared=\"" + shared + "\">\n" +
+                  "         <preload>\n" +
+                  "            <node fqn=\"" + preload + "\"/>\n" +
+                  "         </preload>\n" +
+                  "         <loader class=\"" + cacheloaderClass + "\" async=\"" + async + "\" fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
+                  "                     purgeOnStartup=\"" + purgeOnStartup + "\">\n" +
+                  "            <properties>\n" +
+                  properties +
+                  "            </properties>\n" +
+                  "         </loader>\n" +
+                  "      </loaders>";
+      Element element = XmlConfigHelper.stringToElementInCoreNS(xml);
+      LoadersElementParser elementParser = new LoadersElementParser();
+      return elementParser.parseLoadersElement(element);
+   }
+}

Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeMoveWithCLMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeMoveWithCLMvccTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeMoveWithCLMvccTest.java	2009-02-03 13:44:19 UTC (rev 7630)
@@ -0,0 +1,20 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.api.NodeMoveAPIWithCLTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = {"functional", "mvcc"}, testName = "api.mvcc.read_committed.NodeMoveWithCLMvccTest")
+public class NodeMoveWithCLMvccTest extends NodeMoveAPIWithCLTest
+{
+   @Override
+   protected void configure(Configuration c)
+   {
+      c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+   }
+
+}

Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveWithCLMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveWithCLMvccTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveWithCLMvccTest.java	2009-02-03 13:44:19 UTC (rev 7630)
@@ -0,0 +1,20 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.api.NodeMoveAPIWithCLTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = {"functional", "mvcc"}, testName = "api.mvcc.repeatable_read.NodeMoveWithCLMvccTest")
+public class NodeMoveWithCLMvccTest extends NodeMoveAPIWithCLTest
+{
+   @Override
+   protected void configure(Configuration c)
+   {
+      c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+   }
+
+}
\ No newline at end of file

Added: core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeMoveAPIWithCLOptimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeMoveAPIWithCLOptimisticTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeMoveAPIWithCLOptimisticTest.java	2009-02-03 13:44:19 UTC (rev 7630)
@@ -0,0 +1,18 @@
+package org.jboss.cache.api.optimistic;
+
+import org.testng.annotations.Test;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.api.NodeMoveAPIWithCLTest;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = {"functional", "optimistic"}, testName = "api.optimistic.NodeMoveAPIWithCLOptimisticTest")
+public class NodeMoveAPIWithCLOptimisticTest extends NodeMoveAPIWithCLTest
+{
+   protected Configuration.NodeLockingScheme getNodeLockingScheme()
+   {
+      return Configuration.NodeLockingScheme.OPTIMISTIC;
+   }
+
+}




More information about the jbosscache-commits mailing list