[exo-jcr-commits] exo-jcr SVN: r444 - 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
Thu Oct 29 12:49:04 EDT 2009
Author: pnedonosko
Date: 2009-10-29 12:49:03 -0400 (Thu, 29 Oct 2009)
New Revision: 444
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-200: storage connection getItem(s) tests
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-10-29 15:19:46 UTC (rev 443)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-29 16:49:03 UTC (rev 444)
@@ -214,7 +214,6 @@
List<PropertyData> childs = new ArrayList<PropertyData>();
- // TODO keys Serializable shoudl be!!!
for (Serializable key : parentNode.getKeys())
{
if (!key.equals(ITEM_ID))
@@ -255,9 +254,7 @@
// TODO check performance of Node vs Property get
- String itemName = name.getAsString(true);
-
- String propertyId = (String)parentNode.get(itemName);
+ String propertyId = (String)parentNode.get(name.getAsString());
if (propertyId != null)
{
// it's Property Item
@@ -266,7 +263,7 @@
else
{
// it's Node Item
- Node<Serializable, Object> node = parentNode.getChild(itemName); // TODO String not Fqn?
+ Node<Serializable, Object> node = parentNode.getChild(name.getAsString(true)); // TODO String not Fqn?
if (node != null)
{
String nodeId = (String)node.get(ITEM_ID);
@@ -275,7 +272,6 @@
return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
}
}
-
}
return null;
@@ -308,7 +304,6 @@
startBatch();
// TODO move Node to a new position at the tree,
// but prev location was in prev DELETE.
-
}
/**
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-10-29 15:19:46 UTC (rev 443)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-10-29 16:49:03 UTC (rev 444)
@@ -36,13 +36,11 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.io.Serializable;
-import java.util.List;
-
import junit.framework.TestCase;
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -55,6 +53,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import java.io.Serializable;
+import java.util.List;
+
/**
* Created by The eXo Platform SAS.
*
@@ -215,7 +216,7 @@
// check in tree
treePrint(tree);
-
+
Node<Serializable, Object> rootNode =
tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
.getAsString(true)));
@@ -237,12 +238,12 @@
//System.out.println(key);
//index++;
}
-
+
// check in items
treePrint(items);
- assertNotNull("Property item data should exists",items.getChild(Fqn.fromElements(propId1)));
- assertNotNull("Property item data should exists",items.getChild(Fqn.fromElements(propId2)));
+ assertNotNull("Property item data should exists", items.getChild(Fqn.fromElements(propId1)));
+ assertNotNull("Property item data should exists", items.getChild(Fqn.fromElements(propId2)));
}
public void testDeleteNode() throws Exception
@@ -274,7 +275,7 @@
// check in tree
treePrint(tree);
-
+
Node<Serializable, Object> node =
rootNode.getChild(Fqn
.fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
@@ -289,12 +290,12 @@
child.getFqn().getLastElementAsString());
assertEquals("Node id wrong", Constants.SYSTEM_UUID, (String)child.get(JBossCacheStorageConnection.ITEM_ID));
-
+
// check in items
treePrint(items);
assertNull("Node item data should not exists", items.getChild(Fqn.fromElements(node1id)));
- assertNotNull("Node item data should not exists", items.getChild(Fqn.fromElements(Constants.SYSTEM_UUID)));
+ assertNotNull("Node item data should exists", items.getChild(Fqn.fromElements(Constants.SYSTEM_UUID)));
}
public void testDeleteProperty() throws Exception
@@ -330,17 +331,123 @@
assertNull("Property should be deleted", rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString()));
assertNotNull("Property should exists", rootNode.get(Constants.JCR_MIXINTYPES.getAsString()));
-
+
// check in items
treePrint(items);
- assertNull("Property item data should not exists",items.getChild(Fqn.fromElements(propId1)));
- assertNotNull("Property item data should not exists",items.getChild(Fqn.fromElements(propId2)));
+ assertNull("Property item data should not exists", items.getChild(Fqn.fromElements(propId1)));
+ assertNotNull("Property item data should exists", items.getChild(Fqn.fromElements(propId2)));
}
+ public void testGetNodeByName() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
+ // check
+ ItemData nodeItem =
+ conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()),
+ node1path.getEntries()[node1path.getEntries().length - 1]);
+
+ assertTrue("Node expected", nodeItem.isNode());
+ assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
+ assertEquals("Node path wrong", node1path, nodeItem.getQPath());
+ }
+
+ public void testGetPropertyByName() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 = "1";
+ QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
+ conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 = "2";
+ QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
+ conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
+
+ // check
+ ItemData propItem =
+ conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()),
+ propPath1.getEntries()[propPath1.getEntries().length - 1]);
+
+ assertFalse("Proeprty expected", propItem.isNode());
+ assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
+ assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
+ }
+
+ public void testGetNodeById() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
+ // check
+ ItemData nodeItem = conn.getItemData(node1id);
+
+ assertTrue("Node expected", nodeItem.isNode());
+ assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
+ assertEquals("Node path wrong", node1path, nodeItem.getQPath());
+ }
+
+ public void testGetPropertyById() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 = "1";
+ QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
+ conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 = "2";
+ QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
+ conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
+
+ // check
+ ItemData propItem = conn.getItemData(propId1);
+
+ assertFalse("Proeprty expected", propItem.isNode());
+ assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
+ assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
+ }
+
public void testGetChildNodes() throws Exception
{
- // prepare using JCR WDC API (not right way, JBC API better... but read assumes the write works)
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
// add root (/)
conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
@@ -357,7 +464,7 @@
// check in tree
treePrint(tree);
-
+
List<NodeData> childs =
conn.getChildNodesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
@@ -378,12 +485,12 @@
{
fail("Wrong Node found");
}
- }
+ }
}
public void testGetChildProperties() throws Exception
{
- // prepare using JCR WDC API (not right way, JBC API better... but read assumes the write works)
+ // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
// add root (/)
conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
More information about the exo-jcr-commits
mailing list