You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by th...@apache.org on 2008/04/24 14:48:29 UTC
svn commit: r651247 -
/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/CachingHierarchyManagerTest.java
Author: thomasm
Date: Thu Apr 24 05:48:28 2008
New Revision: 651247
URL: http://svn.apache.org/viewvc?rev=651247&view=rev
Log:
JCR-1380: CachingHierarchyManager synchronization problem - improved test case
Modified:
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/CachingHierarchyManagerTest.java
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/CachingHierarchyManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/CachingHierarchyManagerTest.java?rev=651247&r1=651246&r2=651247&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/CachingHierarchyManagerTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/CachingHierarchyManagerTest.java Thu Apr 24 05:48:28 2008
@@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.HashMap;
-import org.apache.jackrabbit.core.nodetype.NodeDefId;
import org.apache.jackrabbit.core.state.ItemState;
import org.apache.jackrabbit.core.state.ItemStateException;
import org.apache.jackrabbit.core.state.ItemStateManager;
@@ -31,7 +30,6 @@
import org.apache.jackrabbit.core.state.PropertyState;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.spi.PathFactory;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
@@ -45,18 +43,24 @@
volatile boolean stop;
CachingHierarchyManager cache;
+ /**
+ * Test multi-threaded read and write access to the cache.
+ */
public void testResolveNodePath() throws Exception {
- NodeId rootNodeId = new NodeId(UUID.randomUUID());
- ItemStateManager provider = new MyItemStateManager();
- cache = new CachingHierarchyManager(rootNodeId, provider, null);
- final PathFactory factory = PathFactoryImpl.getInstance();
+ StaticItemStateManager ism = new StaticItemStateManager();
+ cache = new CachingHierarchyManager(ism.getRootNodeId(), ism, null);
+ ism.setContainer(cache);
+ ism.addNode(ism.getRoot(), "a");
+ ism.addNode(ism.getRoot(), "b");
+ final Path aPath = toPath("/a");
+ final Path bPath = toPath("/b");
for (int i = 0; i < 3; i++) {
new Thread(new Runnable() {
public void run() {
while (!stop) {
- Path path = factory.create("{}\t{}a1");
try {
- cache.resolveNodePath(path);
+ cache.resolveNodePath(aPath);
+ cache.resolveNodePath(bPath);
} catch (Exception e) {
exception = e;
}
@@ -70,31 +74,6 @@
throw exception;
}
}
-
- static class MyItemStateManager implements ItemStateManager {
-
- public ItemState getItemState(ItemId id)
- throws NoSuchItemStateException, ItemStateException {
- Name name = NameFactoryImpl.getInstance().create("", "a1");
- NodeState ns = new NodeState((NodeId) id, name, null,
- NodeState.STATUS_NEW, false);
- ns.setDefinitionId(NodeDefId.valueOf("1"));
- return ns;
- }
-
- public NodeReferences getNodeReferences(NodeReferencesId id) throws NoSuchItemStateException, ItemStateException {
- return null;
- }
-
- public boolean hasItemState(ItemId id) {
- return false;
- }
-
- public boolean hasNodeReferences(NodeReferencesId id) {
- return false;
- }
-
- };
//-------------------------------------------------------------- basic tests