[exo-jcr-commits] exo-jcr SVN: r721 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Nov 17 11:08:08 EST 2009
Author: sergiykarpenko
Date: 2009-11-17 11:08:08 -0500 (Tue, 17 Nov 2009)
New Revision: 721
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-245: JBossCacheStorageConnectionTest updated
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-17 16:07:53 UTC (rev 720)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-17 16:08:08 UTC (rev 721)
@@ -457,34 +457,31 @@
String nodeUUID = data.getIdentifier();
- //1. Update renamed node and also get old parent node UUID
+ //1. Update renamed node and also get old nodeData
Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeUUID));
if (node == null)
{
throw new RepositoryException("FATAL renamed node is not exist" + data.getQPath().getAsString());
}
- String oldParentIdentifier = null;
- Object itemData = node.put(ITEM_DATA, data);
- if (itemData != null)
+
+ NodeData oldNodeData = (NodeData)node.put(ITEM_DATA, data);
+ if (oldNodeData == null)
{
- oldParentIdentifier = ((NodeData)itemData).getParentIdentifier();
- }
- else
- {
throw new RepositoryException("FATAL NodeData is empty " + data.getQPath().getAsString());
}
// 2. remove renamed node from child list of previous parent node
// check if parent is cached
- Node<Serializable, Object> oldparent = nodesRoot.getChild(makeNodeFqn(oldParentIdentifier));
+ Node<Serializable, Object> oldparent = nodesRoot.getChild(makeNodeFqn(oldNodeData.getParentIdentifier()));
if (oldparent == null)
{
throw new RepositoryException("Nodes old parent doesn't exist " + data.getQPath().getAsString());
}
- // remove child on old Parent
+ // remove node form old parent child list
boolean removed =
- oldparent.removeChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length - 1]));
+ oldparent
+ .removeChild(makeChildNodeFqn(oldNodeData.getQPath().getEntries()[oldNodeData.getQPath().getEntries().length - 1]));
if (!removed)
{
throw new RepositoryException("Node was not removed from child list of old parent "
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-17 16:07:53 UTC (rev 720)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-17 16:08:08 UTC (rev 721)
@@ -26,7 +26,6 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
@@ -717,4 +716,64 @@
}
}
+ public void testMoveNode() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, null, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]firstParent:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ String node2id = "2";
+ QPath node2path = QPath.parse("[]:1[]secondParent:1");
+ conn.add(new TransientNodeData(node2path, node2id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ String node3id = "3";
+ QPath node3path = QPath.parse("[]:1[]firstParent:1[]node:1");
+ conn.add(new TransientNodeData(node3path, node3id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ node1id, new AccessControlList()));
+
+ // check in nodes
+ treePrint(nodes);
+
+ // get root node ([]:1)
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ assertNotNull("Node expected", rootNode);
+
+ // check root Node
+ checkNode(rootNode, Constants.ROOT_UUID, Constants.ROOT_PATH);
+
+ // cechk childs
+ assertEquals("Childs expected", 2, rootNode.getChildren().size());
+ checkChildNode(rootNode, node1id, node1path);
+ checkChildNode(rootNode, node2id, node2path);
+
+ Node<Serializable, Object> firstParent = nodes.getChild(Fqn.fromElements(node1id));
+ assertEquals("Childs expected", 1, firstParent.getChildren().size());
+ checkChildNode(firstParent, node3id, node3path);
+
+ Node<Serializable, Object> secondParent = nodes.getChild(Fqn.fromElements(node2id));
+ assertEquals("Childs expected", 0, secondParent.getChildren().size());
+
+ // lets move node
+
+ QPath newnode3path = QPath.parse("[]:1[]secondParent:1[]nodesec:1");
+ conn.rename(new TransientNodeData(newnode3path, node3id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ node2id, new AccessControlList()));
+
+ //check results
+ firstParent = nodes.getChild(Fqn.fromElements(node1id));
+ assertEquals("Childs expected", 0, firstParent.getChildren().size());
+
+ secondParent = nodes.getChild(Fqn.fromElements(node2id));
+ assertEquals("Childs expected", 1, secondParent.getChildren().size());
+ checkChildNode(secondParent, node3id, newnode3path);
+
+ }
+
}
More information about the exo-jcr-commits
mailing list