[exo-jcr-commits] exo-jcr SVN: r442 - 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 11:08:09 EDT 2009


Author: pnedonosko
Date: 2009-10-29 11:08:09 -0400 (Thu, 29 Oct 2009)
New Revision: 442

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 deletes, adds with full check

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 09:34:52 UTC (rev 441)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java	2009-10-29 15:08:09 UTC (rev 442)
@@ -165,8 +165,7 @@
    {
       startBatch();
       // delete attr on parent by key=PropertyName
-      cache.remove(makeParentFqn(data.getQPath()),
-         data.getQPath().getEntries()[data.getQPath().getEntries().length - 1].getAsString(true));
+      cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
       cache.removeNode(makeIdFqn(data.getIdentifier()));
    }
 
@@ -220,7 +219,7 @@
       {
          if (!key.equals(ITEM_ID))
          {
-            String propId = (String) parentNode.get(key);
+            String propId = (String)parentNode.get(key);
             // TODO NodeData or PropertyData? As ItemData check then and cast.               
             PropertyData property = (PropertyData)cache.get(makeIdFqn(propId), ITEM_DATA);
             if (property == null)

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 09:34:52 UTC (rev 441)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java	2009-10-29 15:08:09 UTC (rev 442)
@@ -158,7 +158,7 @@
       conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
          new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
 
-      // test
+      // check in tree
       treePrint(tree);
 
       // get root node ([]:1)
@@ -189,6 +189,12 @@
             fail("Wrong Node name " + nodeName);
          }
       }
+
+      // check in items
+      treePrint(items);
+
+      Node<Serializable, Object> itemsNode = items.getChild(Fqn.fromElements(node1id));
+      assertNotNull("Node item data should exists", itemsNode);
    }
 
    public void testAddProperty() throws Exception
@@ -207,9 +213,9 @@
       conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
          1, 1, Constants.ROOT_UUID, false));
 
-      // test
+      // 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)));
@@ -231,6 +237,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)));
    }
 
    public void testDeleteNode() throws Exception
@@ -254,15 +266,15 @@
          tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
             .getAsString(true)));
 
-      assertEquals("Childs expected", 2, rootNode.getChildren().size());
+      assertEquals("Number of childs wrong", 2, rootNode.getChildren().size());
 
       // delete /node
       conn.delete(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
          Constants.ROOT_UUID, new AccessControlList()));
 
-      // test
+      // check in tree
       treePrint(tree);
-
+      
       Node<Serializable, Object> node =
          rootNode.getChild(Fqn
             .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
@@ -277,8 +289,55 @@
          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)));
    }
 
+   public void testDeleteProperty() throws Exception
+   {
+      // 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";
+      conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
+         1, 1, Constants.ROOT_UUID, false));
+
+      // add property (/jcr:mixinTypes)
+      String propId2 = "2";
+      conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
+         1, 1, Constants.ROOT_UUID, false));
+
+      // get root node ([]:1)
+      Node<Serializable, Object> rootNode =
+         tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+            .getAsString(true)));
+
+      // delete /jcr:primaryType
+      conn.delete(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE),
+         propId1, 1, 1, Constants.ROOT_UUID, false));
+
+      // check in tree
+      treePrint(tree);
+
+      assertEquals("Number of childs wrong", 2, rootNode.getKeys().size());
+
+      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)));
+   }
+
    public void testGetChildNodes() throws Exception
    {
       // prepare using JCR WDC API (not right way, JBC API better... but read assumes the write works)
@@ -296,7 +355,9 @@
       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
+      // 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()));
@@ -317,7 +378,7 @@
          {
             fail("Wrong Node found");
          }
-      }
+      }      
    }
 
    public void testGetChildProperties() throws Exception
@@ -351,7 +412,7 @@
 
       // check
       treePrint(tree);
-      
+
       List<PropertyData> childs =
          conn.getChildPropertiesData(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