Author: manik.surtani(a)jboss.com
Date: 2008-06-27 12:55:10 -0400 (Fri, 27 Jun 2008)
New Revision: 6102
Added:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheSPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedMvccNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalMvccNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedMvccNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccInvalidationAsyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccInvalidationSyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccReplAsyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccReplSyncTest.java
Removed:
core/trunk/src/test/java/org/jboss/cache/api/CacheAPIOptimisticTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeAPIOptimisticTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveOptimisticTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveOptimisticTest.java
Modified:
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalOptNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalPessNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/NodeValidityTestBase.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedOptNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedPessNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeMoveOptimisticTest.java
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeReplicatedMoveOptimisticTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticInvalidationAsyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticInvalidationSyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticReplAsyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticReplSyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticInvalidationAsyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticInvalidationSyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticReplAsyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticReplSyncTest.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
Log:
Improved tests
Deleted: core/trunk/src/test/java/org/jboss/cache/api/CacheAPIOptimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/CacheAPIOptimisticTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++ core/trunk/src/test/java/org/jboss/cache/api/CacheAPIOptimisticTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,19 +0,0 @@
-package org.jboss.cache.api;
-
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
-
-/**
- * Optimistically locked version of {@link org.jboss.cache.api.CacheAPITest}
- */
-@Test(groups = {"functional", "optimistic"})
-public class CacheAPIOptimisticTest extends CacheAPITest
-{
- @Override
- protected NodeLockingScheme getNodeLockingScheme()
- {
- return NodeLockingScheme.OPTIMISTIC;
- }
-
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/api/NodeAPIOptimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPIOptimisticTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPIOptimisticTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,33 +0,0 @@
-package org.jboss.cache.api;
-
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
-import org.jboss.cache.interceptors.PessimisticLockInterceptor;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.testng.annotations.Test;
-
-/**
- * An optimistic version of {@link org.jboss.cache.api.NodeAPITest}
- */
-@Test(groups = {"functional", "optimistic"})
-public class NodeAPIOptimisticTest extends NodeAPITest
-{
- protected NodeLockingScheme getNodeLockingScheme()
- {
- return NodeLockingScheme.OPTIMISTIC;
- }
-
- protected void assertNodeLockingScheme()
- {
- assert cache.getConfiguration().getNodeLockingScheme() ==
NodeLockingScheme.OPTIMISTIC;
- boolean interceptorChainOK = false;
-
- for (CommandInterceptor i : cache.getInterceptorChain())
- {
- if (i instanceof PessimisticLockInterceptor) assert false : "Not an
optimistic locking chain!!";
- if (i instanceof OptimisticNodeInterceptor) interceptorChainOK = true;
- }
-
- assert interceptorChainOK : "Not an optimistic locking chain!!";
- }
-}
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-06-27 16:01:12
UTC (rev 6101)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-06-27 16:55:10
UTC (rev 6102)
@@ -8,7 +8,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeNotExistsException;
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.DummyInMemoryCacheLoader;
@@ -41,14 +41,14 @@
protected static final Fqn<String> A = Fqn.fromString("/a"), B =
Fqn.fromString("/b"), C = Fqn.fromString("/c"), D =
Fqn.fromString("/d"), E = Fqn.fromString("/e");
protected Object k = "key", vA = "valueA", vB =
"valueB", vC = "valueC", vD = "valueD", vE =
"valueE";
- protected boolean optimistic = false;
+ protected NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
// start a single cache instance
- cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache("META-INF/conf-test/local-tx-service.xml",
false);
- cache.getConfiguration().setNodeLockingScheme(optimistic ?
Configuration.NodeLockingScheme.OPTIMISTIC :
Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache("META-INF/conf-test/local-tx-service.xml", false);
+ cache.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache.start();
rootNode = cache.getRoot();
tm = cache.getTransactionManager();
@@ -239,7 +239,7 @@
cache.move(nodeB.getFqn(), Fqn.ROOT);
// need to think of a way to test the same with optimistically locked nodes
- if (!optimistic)
+ if (!isOptimistic())
{
assertEquals(rootNode, nodeA.getParent());
assertEquals(rootNode, nodeB.getParent());
@@ -405,8 +405,8 @@
@Test(groups = {"functional"})
public void testConcurrency() throws InterruptedException
{
- // FIXME: investigate intermittent failure when in optimistic mode.
- if (optimistic) return;
+ // FIXME: investigate intermittent failure when in isOptimistic() mode.
+ if (isOptimistic()) return;
final int N = 3;// number of threads
final int loops = 1 << 6;// number of loops
@@ -549,4 +549,9 @@
LoadersElementParser elementParser = new LoadersElementParser();
return elementParser.parseLoadersElement(element);
}
+
+ protected boolean isOptimistic()
+ {
+ return nodeLockingScheme == NodeLockingScheme.OPTIMISTIC;
+ }
}
Deleted: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveOptimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveOptimisticTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveOptimisticTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.api;
-
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "optimistic"})
-public class NodeMoveOptimisticTest extends NodeMoveAPITest
-{
- public NodeMoveOptimisticTest()
- {
- optimistic = true;
- }
-
- public void testLocks()
- {
- // no op
- }
-
- public void testLocksDeepMove()
- {
- // no op
- }
-
- @Override
- @Test(groups = {"functional"})
- public void testWithCacheloaders() throws Exception
- {
- super.testWithCacheloaders(); //To change body of overridden methods use File |
Settings | File Templates.
- }
-
- @Override
- @Test(groups = {"functional"})
- public void testWithPassivation() throws Exception
- {
- super.testWithPassivation(); //To change body of overridden methods use File |
Settings | File Templates.
- }
-}
Deleted:
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveOptimisticTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveOptimisticTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveOptimisticTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,18 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.api;
-
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "optimistic"})
-public class NodeReplicatedMoveOptimisticTest extends NodeReplicatedMoveTest
-{
- public NodeReplicatedMoveOptimisticTest()
- {
- optimistic = true;
- }
-}
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -15,6 +15,7 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
@@ -34,7 +35,7 @@
protected static final Fqn<String> A = Fqn.fromString("/a"), B =
Fqn.fromString("/b"), C = Fqn.fromString("/c"), D =
Fqn.fromString("/d"), E = Fqn.fromString("/e");
protected Object k = "key", vA = "valueA", vB =
"valueB", vC = "valueC", vD = "valueD", vE =
"valueE";
- protected boolean optimistic = false;
+ protected NodeLockingScheme nodeLockingScheme;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -43,7 +44,7 @@
cache1 = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC),
false);
cache1.getConfiguration().setSyncCommitPhase(true);
cache1.getConfiguration().setSyncRollbackPhase(true);
- cache1.getConfiguration().setNodeLockingScheme(optimistic ?
Configuration.NodeLockingScheme.OPTIMISTIC :
Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache1.start();
rootNode = cache1.getRoot();
tm = cache1.getTransactionManager();
@@ -52,7 +53,7 @@
cache2 = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC),
false);
cache2.getConfiguration().setSyncCommitPhase(true);
cache2.getConfiguration().setSyncRollbackPhase(true);
- cache2.getConfiguration().setNodeLockingScheme(optimistic ?
Configuration.NodeLockingScheme.OPTIMISTIC :
Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache2.start();
}
@@ -94,7 +95,7 @@
cache2.stop();
cache1.destroy();
cache2.destroy();
- if (optimistic)
+ if (isOptimistic())
{
cache1.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
cache2.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
@@ -113,8 +114,8 @@
assertEquals(vA, cache1.getRoot().getChild(A).get(k));
assertEquals(vB, cache1.getRoot().getChild(A).getChild(B).get(k));
- assertInvalidated(cache2, A, "Should be invalidated", optimistic);
- assertInvalidated(cache2, Fqn.fromRelativeElements(A, B.getLastElement()),
"Should be invalidated", optimistic);
+ assertInvalidated(cache2, A, "Should be invalidated");
+ assertInvalidated(cache2, Fqn.fromRelativeElements(A, B.getLastElement()),
"Should be invalidated");
// now move...
cache1.move(nodeB.getFqn(), Fqn.ROOT);
@@ -122,8 +123,8 @@
assertEquals(vA, cache1.getRoot().getChild(A).get(k));
assertEquals(vB, cache1.getRoot().getChild(B).get(k));
- assertInvalidated(cache2, A, "Should be invalidated", optimistic);
- assertInvalidated(cache2, B, "Should be invalidated", optimistic);
+ assertInvalidated(cache2, A, "Should be invalidated");
+ assertInvalidated(cache2, B, "Should be invalidated");
// now make sure a node exists on cache 2
cache2.getRoot().addChild(A).put("k2", "v2");
@@ -132,20 +133,20 @@
try
{
cache1.move(B, A);// should throw an NPE
- if (!optimistic) assert false : "Should throw an exception!";
+ if (!isOptimistic()) assert false : "Should throw an exception!";
}
catch (NodeNotExistsException expected)
{
- if (optimistic) assert false : "Should not have thrown an
exception!";
+ if (isOptimistic()) assert false : "Should not have thrown an
exception!";
}
}
- private void assertInvalidated(Cache cache, Fqn fqn, String msg, boolean optimistic)
+ private void assertInvalidated(Cache cache, Fqn fqn, String msg)
{
assert cache.getRoot().getChild(fqn) == null : msg;
NodeSPI n = ((CacheSPI) cache).peek(fqn, true, true);
- assert n == null || optimistic : msg;
- assert !optimistic || !n.isValid() : msg;
+ assert n == null || isOptimistic() : msg;
+ assert !isOptimistic() || !n.isValid() : msg;
}
public void testReplTxCommit() throws Exception
@@ -206,4 +207,9 @@
assertEquals(vA, cache2.getRoot().getChild(A).get(k));
assertEquals(vB, cache2.getRoot().getChild(A).getChild(B).get(k));
}
+
+ protected boolean isOptimistic()
+ {
+ return nodeLockingScheme == NodeLockingScheme.OPTIMISTIC;
+ }
}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheSPIMVCCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheSPIMVCCTest.java
(rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheSPIMVCCTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,14 @@
+package org.jboss.cache.api.mvcc;
+
+import org.jboss.cache.api.CacheSPITest;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class CacheSPIMVCCTest extends CacheSPITest
+{
+ public CacheSPIMVCCTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Added:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,14 @@
+package org.jboss.cache.api.mvcc;
+
+import org.jboss.cache.api.DeletedChildResurrectionTest;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class DeletedChildResurrectionMvccTest extends DeletedChildResurrectionTest
+{
+ public DeletedChildResurrectionMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java
(rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.cache.api.mvcc;
+
+import org.jboss.cache.api.NodeMoveAPITest;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class NodeMoveMvccTest extends NodeMoveAPITest
+{
+ public NodeMoveMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at
gnu.org.
+ */
+package org.jboss.cache.api.mvcc;
+
+import org.jboss.cache.api.NodeReplicatedMoveTest;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class NodeReplicatedMoveMvccTest extends NodeReplicatedMoveTest
+{
+ public NodeReplicatedMoveMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java
(rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,14 @@
+package org.jboss.cache.api.mvcc;
+
+import org.jboss.cache.api.SyncReplTest;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "jgroups", "mvcc"})
+public class SyncReplMvccTest extends SyncReplTest
+{
+ public SyncReplMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java
(rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,14 @@
+package org.jboss.cache.api.mvcc;
+
+import org.jboss.cache.api.SyncReplTxTest;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "jgroups", "transaction",
"mvcc"})
+public class SyncReplTxMvccTest extends SyncReplTxTest
+{
+ public SyncReplTxMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Added:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedMvccNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedMvccNodeValidityTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedMvccNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,13 @@
+package org.jboss.cache.api.nodevalidity;
+
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class InvalidatedMvccNodeValidityTest extends InvalidatedOptNodeValidityTest
+{
+ public InvalidatedMvccNodeValidityTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedOptNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -2,6 +2,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.testng.annotations.Test;
@@ -14,7 +15,7 @@
{
public InvalidatedOptNodeValidityTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
}
public void testTombstoneRevival()
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -6,6 +6,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
import org.testng.annotations.AfterMethod;
@@ -23,6 +24,7 @@
public InvalidatedPessNodeValidityTest()
{
invalidation = true;
+ nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
}
protected Cache<String, String> createObserver()
@@ -43,10 +45,10 @@
protected Cache<String, String> newCache()
{
- CacheFactory<String, String> f = new DefaultCacheFactory();
+ CacheFactory<String, String> f = new DefaultCacheFactory<String,
String>();
Cache<String, String> cache = f.createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
- optimisticConfiguration(cache.getConfiguration());
+ nodeLockingSchemeSpecificSetup(cache.getConfiguration());
// need a cache loader as a shared data source between the 2 instances
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new
CacheLoaderConfig.IndividualCacheLoaderConfig();
Added:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalMvccNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalMvccNodeValidityTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalMvccNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,13 @@
+package org.jboss.cache.api.nodevalidity;
+
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class LocalMvccNodeValidityTest extends LocalPessNodeValidityTest
+{
+ public LocalMvccNodeValidityTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalOptNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalOptNodeValidityTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalOptNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,5 +1,6 @@
package org.jboss.cache.api.nodevalidity;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
/**
@@ -11,6 +12,6 @@
{
public LocalOptNodeValidityTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
}
}
\ No newline at end of file
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalPessNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalPessNodeValidityTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalPessNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -3,6 +3,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -19,6 +20,7 @@
public LocalPessNodeValidityTest()
{
clustered = false;
+ nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
}
@AfterMethod
@@ -38,9 +40,9 @@
{
if (cache == null)
{
- CacheFactory<String, String> f = new DefaultCacheFactory();
+ CacheFactory<String, String> f = new DefaultCacheFactory<String,
String>();
cache = f.createCache(false);
- optimisticConfiguration(cache.getConfiguration());
+ nodeLockingSchemeSpecificSetup(cache.getConfiguration());
cache.start();
return cache;
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/NodeValidityTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/NodeValidityTestBase.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/NodeValidityTestBase.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -7,9 +7,10 @@
import org.jboss.cache.NodeNotValidException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -25,7 +26,7 @@
@Test(groups = {"functional"})
public abstract class NodeValidityTestBase
{
- protected boolean optimistic;
+ protected NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
// needed to attach a blockUntilViewsReceived in setup
protected boolean clustered = true;
@@ -43,17 +44,22 @@
protected abstract Cache<String, String> createModifier();
- protected void optimisticConfiguration(Configuration c)
+ protected void nodeLockingSchemeSpecificSetup(Configuration c)
{
- if (optimistic)
+ c.setNodeLockingScheme(nodeLockingScheme);
+ if (isOptimistic())
{
- c.setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
c.setSyncCommitPhase(true);
c.setSyncRollbackPhase(true);
}
}
+ protected boolean isOptimistic()
+ {
+ return nodeLockingScheme == NodeLockingScheme.OPTIMISTIC;
+ }
+
@BeforeMethod
public void setUp()
{
@@ -122,7 +128,7 @@
// the old node is only marked as invalid if we use opt locking
// with pess locking we directly move the node reference so the old ref is still
valid, EVEN if the move happens
// remotely.
- if (optimistic) assert !obsNode.isValid() : "Should no longer be valid";
+ if (isOptimistic()) assert !obsNode.isValid() : "Should no longer be
valid";
assert observer.getRoot().getChild(newParent).isValid() : "Should be
valid";
}
@@ -148,7 +154,7 @@
// the old node is only marked as invalid if we use opt locking
// with pess locking we directly move the node reference so the old ref is still
valid.
- if (optimistic)
+ if (isOptimistic())
{
assert !obsParentNode.isValid() : "Should no longer be valid";
assert !obsChildNode.isValid() : "Should no longer be valid";
@@ -296,7 +302,7 @@
modifier.put(parent, K, V);
modifier.removeNode(parent);
- if (optimistic && invalidation)
+ if (isOptimistic() && invalidation)
{
// if we are using optimistic invalidation then we should see tombstones. NOT
otherwise.
NodeSPI modifierTombstone = modifierImpl.peek(parent, true, true);
@@ -328,7 +334,7 @@
modifier.put(child, K, V);
modifier.removeNode(parent);
- if (optimistic && invalidation)
+ if (isOptimistic() && invalidation)
{
// if we are using optimistic invalidation then we should see tombstones. NOT
otherwise.
NodeSPI modifierParentTombstone = modifierImpl.peek(parent, true, true);
Added:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedMvccNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedMvccNodeValidityTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedMvccNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,13 @@
+package org.jboss.cache.api.nodevalidity;
+
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class ReplicatedMvccNodeValidityTest extends ReplicatedPessNodeValidityTest
+{
+ public ReplicatedMvccNodeValidityTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedOptNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedOptNodeValidityTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedOptNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,5 +1,6 @@
package org.jboss.cache.api.nodevalidity;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
/**
@@ -11,6 +12,6 @@
{
public ReplicatedOptNodeValidityTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
}
}
\ No newline at end of file
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedPessNodeValidityTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedPessNodeValidityTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedPessNodeValidityTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -28,7 +28,7 @@
CacheFactory<String, String> f = new DefaultCacheFactory();
Cache<String, String> cache = f.createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- optimisticConfiguration(cache.getConfiguration());
+ nodeLockingSchemeSpecificSetup(cache.getConfiguration());
cache.start();
return cache;
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeMoveOptimisticTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeMoveOptimisticTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeMoveOptimisticTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -7,6 +7,7 @@
package org.jboss.cache.api.optimistic;
import org.jboss.cache.api.NodeMoveAPITest;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
@Test(groups = {"functional", "optimistic"})
@@ -14,7 +15,7 @@
{
public NodeMoveOptimisticTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
}
public void testLocks()
@@ -26,18 +27,4 @@
{
// no op
}
-
- @Override
- @Test(groups = {"functional"})
- public void testWithCacheloaders() throws Exception
- {
- super.testWithCacheloaders(); //To change body of overridden methods use File |
Settings | File Templates.
- }
-
- @Override
- @Test(groups = {"functional"})
- public void testWithPassivation() throws Exception
- {
- super.testWithPassivation(); //To change body of overridden methods use File |
Settings | File Templates.
- }
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeReplicatedMoveOptimisticTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeReplicatedMoveOptimisticTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeReplicatedMoveOptimisticTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -7,6 +7,7 @@
package org.jboss.cache.api.optimistic;
import org.jboss.cache.api.NodeReplicatedMoveTest;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
@Test(groups = {"functional", "optimistic"})
@@ -14,6 +15,6 @@
{
public NodeReplicatedMoveOptimisticTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
}
}
Added:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccInvalidationAsyncTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccInvalidationAsyncTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccInvalidationAsyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,15 @@
+package org.jboss.cache.api.pfer;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class PFERMvccInvalidationAsyncTest extends PutForExternalReadTestBase
+{
+ public PFERMvccInvalidationAsyncTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ cacheMode = Configuration.CacheMode.INVALIDATION_ASYNC;
+ }
+}
Added:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccInvalidationSyncTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccInvalidationSyncTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccInvalidationSyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,15 @@
+package org.jboss.cache.api.pfer;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class PFERMvccInvalidationSyncTest extends PutForExternalReadTestBase
+{
+ public PFERMvccInvalidationSyncTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ cacheMode = Configuration.CacheMode.INVALIDATION_SYNC;
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccReplAsyncTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccReplAsyncTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccReplAsyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,15 @@
+package org.jboss.cache.api.pfer;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class PFERMvccReplAsyncTest extends PutForExternalReadTestBase
+{
+ public PFERMvccReplAsyncTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ cacheMode = Configuration.CacheMode.REPL_ASYNC;
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccReplSyncTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccReplSyncTest.java
(rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERMvccReplSyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -0,0 +1,15 @@
+package org.jboss.cache.api.pfer;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class PFERMvccReplSyncTest extends PutForExternalReadTestBase
+{
+ public PFERMvccReplSyncTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ cacheMode = Configuration.CacheMode.REPL_SYNC;
+ }
+}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticInvalidationAsyncTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticInvalidationAsyncTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticInvalidationAsyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -7,6 +7,7 @@
package org.jboss.cache.api.pfer;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
/**
@@ -20,7 +21,7 @@
{
public PFEROptimisticInvalidationAsyncTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
cacheMode = Configuration.CacheMode.INVALIDATION_ASYNC;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticInvalidationSyncTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticInvalidationSyncTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticInvalidationSyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -7,6 +7,7 @@
package org.jboss.cache.api.pfer;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
/**
@@ -20,7 +21,7 @@
{
public PFEROptimisticInvalidationSyncTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
cacheMode = Configuration.CacheMode.INVALIDATION_SYNC;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticReplAsyncTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticReplAsyncTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticReplAsyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,6 +1,7 @@
package org.jboss.cache.api.pfer;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
@Test(groups = {"functional", "optimistic"})
@@ -8,7 +9,7 @@
{
public PFEROptimisticReplAsyncTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
cacheMode = Configuration.CacheMode.REPL_ASYNC;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticReplSyncTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticReplSyncTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFEROptimisticReplSyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,6 +1,7 @@
package org.jboss.cache.api.pfer;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
@Test(groups = {"functional", "optimistic"})
@@ -8,7 +9,7 @@
{
public PFEROptimisticReplSyncTest()
{
- optimistic = true;
+ nodeLockingScheme = NodeLockingScheme.OPTIMISTIC;
cacheMode = Configuration.CacheMode.REPL_SYNC;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticInvalidationAsyncTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticInvalidationAsyncTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticInvalidationAsyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -7,6 +7,7 @@
package org.jboss.cache.api.pfer;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
/**
@@ -20,7 +21,7 @@
{
public PFERPessimisticInvalidationAsyncTest()
{
- optimistic = false;
+ nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
cacheMode = Configuration.CacheMode.INVALIDATION_ASYNC;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticInvalidationSyncTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticInvalidationSyncTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticInvalidationSyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -7,6 +7,7 @@
package org.jboss.cache.api.pfer;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
/**
@@ -20,7 +21,7 @@
{
public PFERPessimisticInvalidationSyncTest()
{
- optimistic = false;
+ nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
cacheMode = Configuration.CacheMode.INVALIDATION_SYNC;
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticReplAsyncTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticReplAsyncTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticReplAsyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,6 +1,7 @@
package org.jboss.cache.api.pfer;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
@Test(groups = {"functional", "pessimistic"})
@@ -8,7 +9,7 @@
{
public PFERPessimisticReplAsyncTest()
{
- optimistic = false;
+ nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
cacheMode = Configuration.CacheMode.REPL_ASYNC;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticReplSyncTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticReplSyncTest.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PFERPessimisticReplSyncTest.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -1,6 +1,7 @@
package org.jboss.cache.api.pfer;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.testng.annotations.Test;
@Test(groups = {"functional", "pessimistic"})
@@ -8,7 +9,7 @@
{
public PFERPessimisticReplSyncTest()
{
- optimistic = false;
+ nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
cacheMode = Configuration.CacheMode.REPL_SYNC;
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-06-27
16:01:12 UTC (rev 6101)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-06-27
16:55:10 UTC (rev 6102)
@@ -11,7 +11,7 @@
import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.NodeLock;
@@ -35,6 +35,8 @@
@Test(groups = {"functional", "jgroups", "transaction"})
public abstract class PutForExternalReadTestBase
{
+ // TODO: Refactor this test so it isn't bound to using Thread.sleep() calls.
+
protected CacheSPI<String, String> cache1, cache2;
ReplicationListener replListener1;
@@ -48,24 +50,25 @@
protected String key = "k", value = "v", value2 = "v2";
- protected boolean useTx, optimistic;
+ protected boolean useTx;
protected Configuration.CacheMode cacheMode;
+ protected NodeLockingScheme nodeLockingScheme;
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- CacheFactory<String, String> cf = new DefaultCacheFactory();
+ CacheFactory<String, String> cf = new DefaultCacheFactory<String,
String>();
cache1 = (CacheSPI<String, String>)
cf.createCache(UnitTestCacheConfigurationFactory.createConfiguration(cacheMode), false);
cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache1.getConfiguration().setNodeLockingScheme(optimistic ?
Configuration.NodeLockingScheme.OPTIMISTIC :
Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache1.start();
tm1 = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
cache2 = (CacheSPI<String, String>)
cf.createCache(UnitTestCacheConfigurationFactory.createConfiguration(cacheMode), false);
cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache2.getConfiguration().setNodeLockingScheme(optimistic ?
Configuration.NodeLockingScheme.OPTIMISTIC :
Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache2.start();
tm2 = cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -93,7 +96,7 @@
NodeSPI parentNode = null;
TransactionWorkspace workspace = null;
- if (optimistic)
+ if (isOptimistic())
workspace = extractTransactionWorkspace(cache1);
else
parentNode = (NodeSPI<String, String>)
cache1.getRoot().getChild(parentFqn);
@@ -122,9 +125,9 @@
else
assertEquals("Parent node write should have replicated", value2,
cache2.get(parentFqn, key));
- if (!optimistic)
+ if (!isOptimistic())
{
- // doesn't apply with optimistic locking since both gtx2EntryMap will
succeed here.
+ // doesn't apply with isOptimistic() locking since both gtx2EntryMap will
succeed here.
assertNull("PFER should have been a no-op", cache1.get(fqn, key));
assertNull("PFER should have been a no-op", cache2.get(fqn, key));
}
@@ -178,7 +181,7 @@
cr.registerComponent(rpcManager, RPCManager.class);
cr.rewire();
- // invalidations will not trigger any rpc call sfor PFER
+ // invalidations will not trigger any rpc calls for PFER
if (!isUsingInvalidation())
{
// specify what we expect called on the mock Rpc Manager. For params we
don't care about, just use ANYTHING.
@@ -207,7 +210,7 @@
cache1.get(parentFqn, key);
NodeSPI parentNode = null;
TransactionWorkspace workspace = null;
- if (optimistic)
+ if (isOptimistic())
workspace = extractTransactionWorkspace(cache1);
else
parentNode = (NodeSPI<String, String>)
cache1.getRoot().getChild(parentFqn);
@@ -228,8 +231,6 @@
tm1.resume(t);
tm1.commit();
- asyncWait();
-
assertEquals("parent fqn tx should have completed", value,
cache1.get(parentFqn, key));
if (isUsingInvalidation())
assertNull("parent fqn tx should have invalidated cache2",
cache2.get(parentFqn, key));
@@ -256,13 +257,13 @@
try
{
cache1.put(fqn, key, value);
- if (!optimistic) fail("Should have barfed");
+ if (!isOptimistic()) fail("Should have barfed");
}
catch (RuntimeException re)
{
}
- if (optimistic && !isUsingInvalidation())
+ if (isOptimistic() && !isUsingInvalidation())
{
// proves that the put did, in fact, barf. Doesn't work for
invalidations since the inability to invalidate will not cause a rollback.
assertNull(cache1.get(fqn, key));
@@ -305,10 +306,9 @@
Object expected = isUsingInvalidation() ? null : value;
assertEquals("PFER propagated to cache2 as expected", expected,
cache2.get(fqn, key));
+ // replication to cache 1 should NOT happen.
cache2.putForExternalRead(fqn, key, value);
- asyncWait();
-
assertEquals("PFER updated cache2", value, cache2.get(fqn, key));
assertEquals("Cache1 should be unaffected", value, cache1.get(fqn,
key));
}
@@ -346,7 +346,7 @@
cache1.putForExternalRead(fqn, key, value);
tm1.commit();
- asyncWait();
+ TestingUtil.sleepThread(500);
assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1
should have no stale global TXs";
assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1
should have no stale local TXs";
@@ -464,14 +464,24 @@
return null;
}
- protected void asyncWait()
+ protected boolean isUsingInvalidation()
{
- TestingUtil.sleepThread(500);
+ return cacheMode.isInvalidation();
}
- protected boolean isUsingInvalidation()
+ protected boolean isAsync()
{
- return cacheMode == CacheMode.INVALIDATION_ASYNC
- || cacheMode == CacheMode.INVALIDATION_SYNC;
+ return !cacheMode.isSynchronous();
}
+
+ protected boolean isOptimistic()
+ {
+ return nodeLockingScheme == NodeLockingScheme.OPTIMISTIC;
+ }
+
+ protected void asyncWait()
+ {
+ // always needs to do this since PFER will force async comms.
+ TestingUtil.sleepThread(500);
+ }
}