[exo-jcr-commits] exo-jcr SVN: r470 - in jcr/branches/1.12.0-JBC/component/core: src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Nov 4 11:05:18 EST 2009


Author: pnedonosko
Date: 2009-11-04 11:05:15 -0500 (Wed, 04 Nov 2009)
New Revision: 470

Added:
   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/JBossCacheTreeStorageConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java
   jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java
Removed:
   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/ExoJCRCacheLoaderTest.java
   jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Modified:
   jcr/branches/1.12.0-JBC/component/core/pom.xml
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
Log:
EXOJCR-200: tree-based connection deprecated, but still works if needed

Modified: jcr/branches/1.12.0-JBC/component/core/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/pom.xml	2009-11-04 14:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/pom.xml	2009-11-04 16:05:15 UTC (rev 470)
@@ -569,9 +569,9 @@
                      </systemProperties>
                      <includes>
                         <include>**/**/JBossCacheServiceTest__.java</include>
-                        <include>**/**/TestItem_.java</include>
+                        <include>**/**/TestItem__.java</include>
                         
-                        <include>**/**/JBossCacheStorageConnectionTest.java</include>
+                        <include>**/**/JBossCacheTreeStorageConnectionTest.java</include>
                      </includes>
                   </configuration>
                </plugin>

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java	2009-11-04 14:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -114,7 +114,7 @@
             {
                QPathEntry nodeName = QPathEntry.parse(name.getLastElementAsString());
 
-               // TODO non effective, in this way 1) all subtree will be cached
+               // 1) all subtree will be cached
                // 2) all subtree will be read from DB (with allprops) for only Ids.
                // The effective way DON NOT use calls to cache and use special SQLs for Ids only read. 
                String parentId = (String)cache.get(name.getParent(), JBossCacheStorage.ITEM_ID);

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java	2009-11-04 14:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -59,13 +59,13 @@
 
    public static final String ITEM_ID = "$id".intern();
 
-   protected final Fqn<String> treeRoot;
+   protected final Fqn<String> namesRoot;
 
    protected final Fqn<String> itemsRoot;
 
-   protected JBossCacheStorage(Fqn<String> treeRoot, Fqn<String> itemsRoot)
+   protected JBossCacheStorage(Fqn<String> namesRoot, Fqn<String> itemsRoot)
    {
-      this.treeRoot = treeRoot;
+      this.namesRoot = namesRoot;
       this.itemsRoot = itemsRoot;
    }
 
@@ -79,7 +79,7 @@
          fqns[i] = path[i].getAsString(true);
       }
 
-      return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+      return Fqn.fromRelativeFqn(namesRoot, Fqn.fromElements(fqns));
    }
 
    protected Fqn<String> makeParentFqn(QPath propertyPath)
@@ -93,7 +93,7 @@
          fqns[i] = path[i].getAsString(true);
       }
 
-      return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+      return Fqn.fromRelativeFqn(namesRoot, Fqn.fromElements(fqns));
    }
 
    protected Fqn<String> makeIdFqn(String itemId)

Deleted: 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-04 14:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -1,404 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-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.QPathEntry;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-
-/**
- * Created by The eXo Platform SAS.
- * 
- * <br/>Date: 23.10.2009<br/>
- *
- * Cache contains several regions:<br/>
- * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id stored.<br/>
- * Items map. /$ITEMS: Key=Id, Value = ItemData.<br/>
- * References map ??? /$REFS: Key=NodeId, Value = PropertyId.<br/>
- *
- * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
- * @version $Id$
- */
-public class JBossCacheStorageConnection extends JBossCacheStorage implements WorkspaceStorageConnection
-{
-
-   protected static final Log LOG = ExoLogger.getLogger("jcr.JBossCacheStorageConnection");
-
-   private final Cache<Serializable, Object> cache;
-
-   //private final Node<Serializable, Object> treeRoot;
-
-   //private final Node<Serializable, Object> itemsRoot;
-
-   /**
-    *  Start batching flag. 'true' if batching was started, 'false' if batching is not start. 
-    */
-   private boolean batchStarted = false;
-
-   /**
-    * JBossCacheStorageConnection  constructor.
-    *
-    * @param cache Cache<Serializable, Object>
-    */
-   public JBossCacheStorageConnection(Cache<Serializable, Object> cache, Node<Serializable, Object> treeRoot,
-      Node<Serializable, Object> itemsRoot)
-   {
-      super(treeRoot.getFqn(), itemsRoot.getFqn());
-      
-      this.cache = cache;
-      //this.itemsRoot = itemsRoot;
-      //this.treeRoot = treeRoot;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void add(NodeData data) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
-      IllegalStateException
-   {
-      startBatch();
-      cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
-      cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
-      InvalidItemStateException, IllegalStateException
-   {
-      startBatch();
-      Fqn<String> parentFqn = makeParentFqn(data.getQPath());
-
-      // add an attr to the parent node as key=PropertyName value=PropertyId
-      cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
-      cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
-      InvalidItemStateException, IllegalStateException
-   {
-      startBatch();
-      cache.removeNode(makeNodeFqn(data.getQPath()));
-      cache.removeNode(makeIdFqn(data.getIdentifier()));
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
-      InvalidItemStateException, IllegalStateException
-   {
-      startBatch();
-      // delete attr on parent by key=PropertyName
-      cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
-      cache.removeNode(makeIdFqn(data.getIdentifier()));
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
-   {
-      //Set<Object> childNames = cache.getChildrenNames(makeNodeFqn(parent.getQPath()));
-      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parent.getQPath()));
-      if (parentNode == null)
-      {
-         throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
-      }
-
-      Set<Node<Serializable, Object>> childNodes = parentNode.getChildren();
-
-      List<NodeData> childs = new ArrayList<NodeData>();
-      for (Node<Serializable, Object> child : childNodes)
-      {
-         String childId = (String)child.get(ITEM_ID);
-
-         // TODO NodeData or PropertyData? As ItemData check then and cast.
-         NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
-         if (node == null)
-         {
-            throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
-         }
-         childs.add(node);
-      }
-
-      return childs;
-   }
-
-   private void treePrint(Node<Serializable, Object> node)
-   {
-      for (Node<Serializable, Object> child : node.getChildren())
-      {
-         System.out.println(child.toString());
-         for (Serializable key : child.getKeys())
-         {
-            System.out.println("\t" + key + "=" + child.get(key));
-         }
-         if (!child.isLeaf())
-         {
-            treePrint(child);
-         }
-      }
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
-   {
-      // TODO treeRoot.getChild(f) possible if f not a direct child??? 
-      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parent.getQPath()));
-      if (parentNode == null)
-      {
-         throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
-      }
-
-      List<PropertyData> childs = new ArrayList<PropertyData>();
-
-      for (Serializable key : parentNode.getKeys())
-      {
-         if (!key.equals(ITEM_ID))
-         {
-            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)
-            {
-               throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
-            }
-            childs.add(property);
-         }
-      }
-
-      return childs;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
-   {
-      // TODO it's same as getChild... now
-      return getChildPropertiesData(parent);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
-   {
-      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parentData.getQPath()));
-      if (parentNode == null)
-      {
-         throw new IllegalStateException("Get Item data error: parent not found " + parentData.getQPath().getAsString());
-      }
-
-      // TODO check performance of Node vs Property get
-
-      String propertyId = (String)parentNode.get(name.getAsString());
-      if (propertyId != null)
-      {
-         // it's Property Item
-         return (PropertyData)cache.get(makeIdFqn(propertyId), ITEM_DATA);
-      }
-      else
-      {
-         // it's Node Item
-         Node<Serializable, Object> node = parentNode.getChild(name.getAsString(true)); // TODO String not Fqn?
-         if (node != null)
-         {
-            String nodeId = (String)node.get(ITEM_ID);
-            if (nodeId != null)
-            {
-               return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
-            }
-         }
-      }
-
-      return null;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
-   {
-      return (ItemData)cache.get(makeIdFqn(identifier), ITEM_DATA);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
-      IllegalStateException, UnsupportedOperationException
-   {
-      // TODO refs impl
-      return new ArrayList<PropertyData>();
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
-      InvalidItemStateException, IllegalStateException
-   {
-      startBatch();
-      // TODO move Node to a new position at the tree,
-      // but prev location was in prev DELETE.
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
-      InvalidItemStateException, IllegalStateException
-   {
-      startBatch();
-
-      // TODO it's put anyway.. but with check?
-      Object prev = cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
-      if (prev == null)
-      {
-         throw new IllegalStateException("Node was deleted (tree)");
-      }
-
-      prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
-      if (prev == null)
-      {
-         throw new IllegalStateException("Node was deleted (items)");
-      }
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
-      InvalidItemStateException, IllegalStateException
-   {
-      startBatch();
-
-      // TODO it's put anyway.. but with check?
-      Fqn<String> parentFqn = makeParentFqn(data.getQPath());
-      Object prev = cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
-      if (prev == null)
-      {
-         throw new IllegalStateException("Property was deleted (tree)");
-      }
-
-      prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
-      if (prev == null)
-      {
-         throw new IllegalStateException("Property was deleted (items)");
-      }
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void commit() throws IllegalStateException, RepositoryException
-   {
-      if (LOG.isDebugEnabled())
-      {
-         LOG.debug("commit " + batchStarted);
-      }
-
-      // end batch
-      if (batchStarted)
-      {
-         this.cache.endBatch(true); // treePrint(treeRoot);
-         batchStarted = false;
-      }
-      else
-      {
-         // TODO
-         LOG.warn("Commit call without changes made.");
-      }
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void rollback() throws IllegalStateException, RepositoryException
-   {
-      if (LOG.isDebugEnabled())
-      {
-         LOG.debug("rollback " + batchStarted);
-      }
-
-      // rollback batch
-      if (batchStarted)
-      {
-         this.cache.endBatch(false);
-         batchStarted = false;
-      }
-      else
-      {
-         // TODO
-         LOG.warn("Rollback call without changes made.");
-      }
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public boolean isOpened()
-   {
-      return true;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void close() throws IllegalStateException, RepositoryException
-   {
-      // TODO Auto-generated method stub
-   }
-
-   /**
-    *  Start batching.
-    */
-   private void startBatch()
-   {
-      if (!batchStarted)
-      {
-         batchStarted = true;
-         this.cache.startBatch();
-      }
-   }
-
-}

Added: 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	                        (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -0,0 +1,404 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+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.QPathEntry;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+/**
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 23.10.2009<br/>
+ *
+ * Cache contains several regions:<br/>
+ * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id stored.<br/>
+ * Items map. /$ITEMS: Key=Id, Value = ItemData.<br/>
+ * References map ??? /$REFS: Key=NodeId, Value = PropertyId.<br/>
+ *
+ * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
+ * @version $Id$
+ */
+public class JBossCacheStorageConnection extends JBossCacheStorage implements WorkspaceStorageConnection
+{
+
+   protected static final Log LOG = ExoLogger.getLogger("jcr.JBossCacheStorageConnection");
+
+   private final Cache<Serializable, Object> cache;
+
+   //private final Node<Serializable, Object> treeRoot;
+
+   //private final Node<Serializable, Object> itemsRoot;
+
+   /**
+    *  Start batching flag. 'true' if batching was started, 'false' if batching is not start. 
+    */
+   private boolean batchStarted = false;
+
+   /**
+    * JBossCacheStorageConnection  constructor.
+    *
+    * @param cache Cache<Serializable, Object>
+    */
+   public JBossCacheStorageConnection(Cache<Serializable, Object> cache, Node<Serializable, Object> treeRoot,
+      Node<Serializable, Object> itemsRoot)
+   {
+      super(treeRoot.getFqn(), itemsRoot.getFqn());
+      
+      this.cache = cache;
+      //this.itemsRoot = itemsRoot;
+      //this.treeRoot = treeRoot;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void add(NodeData data) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
+      IllegalStateException
+   {
+      startBatch();
+      cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
+      cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+      Fqn<String> parentFqn = makeParentFqn(data.getQPath());
+
+      // add an attr to the parent node as key=PropertyName value=PropertyId
+      cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
+      cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+      cache.removeNode(makeNodeFqn(data.getQPath()));
+      cache.removeNode(makeIdFqn(data.getIdentifier()));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+      // delete attr on parent by key=PropertyName
+      cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
+      cache.removeNode(makeIdFqn(data.getIdentifier()));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
+   {
+      //Set<Object> childNames = cache.getChildrenNames(makeNodeFqn(parent.getQPath()));
+      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parent.getQPath()));
+      if (parentNode == null)
+      {
+         throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
+      }
+
+      Set<Node<Serializable, Object>> childNodes = parentNode.getChildren();
+
+      List<NodeData> childs = new ArrayList<NodeData>();
+      for (Node<Serializable, Object> child : childNodes)
+      {
+         String childId = (String)child.get(ITEM_ID);
+
+         // TODO NodeData or PropertyData? As ItemData check then and cast.
+         NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
+         if (node == null)
+         {
+            throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
+         }
+         childs.add(node);
+      }
+
+      return childs;
+   }
+
+   private void treePrint(Node<Serializable, Object> node)
+   {
+      for (Node<Serializable, Object> child : node.getChildren())
+      {
+         System.out.println(child.toString());
+         for (Serializable key : child.getKeys())
+         {
+            System.out.println("\t" + key + "=" + child.get(key));
+         }
+         if (!child.isLeaf())
+         {
+            treePrint(child);
+         }
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
+   {
+      // TODO treeRoot.getChild(f) possible if f not a direct child??? 
+      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parent.getQPath()));
+      if (parentNode == null)
+      {
+         throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
+      }
+
+      List<PropertyData> childs = new ArrayList<PropertyData>();
+
+      for (Serializable key : parentNode.getKeys())
+      {
+         if (!key.equals(ITEM_ID))
+         {
+            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)
+            {
+               throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
+            }
+            childs.add(property);
+         }
+      }
+
+      return childs;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
+   {
+      // TODO it's same as getChild... now
+      return getChildPropertiesData(parent);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
+   {
+      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parentData.getQPath()));
+      if (parentNode == null)
+      {
+         throw new IllegalStateException("Get Item data error: parent not found " + parentData.getQPath().getAsString());
+      }
+
+      // TODO check performance of Node vs Property get
+
+      String propertyId = (String)parentNode.get(name.getAsString());
+      if (propertyId != null)
+      {
+         // it's Property Item
+         return (PropertyData)cache.get(makeIdFqn(propertyId), ITEM_DATA);
+      }
+      else
+      {
+         // it's Node Item
+         Node<Serializable, Object> node = parentNode.getChild(name.getAsString(true)); // TODO String not Fqn?
+         if (node != null)
+         {
+            String nodeId = (String)node.get(ITEM_ID);
+            if (nodeId != null)
+            {
+               return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
+            }
+         }
+      }
+
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
+   {
+      return (ItemData)cache.get(makeIdFqn(identifier), ITEM_DATA);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
+      IllegalStateException, UnsupportedOperationException
+   {
+      // TODO refs impl
+      return new ArrayList<PropertyData>();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+      // TODO move Node to a new position at the tree,
+      // but prev location was in prev DELETE.
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+
+      // TODO it's put anyway.. but with check?
+      Object prev = cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
+      if (prev == null)
+      {
+         throw new IllegalStateException("Node was deleted (tree)");
+      }
+
+      prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+      if (prev == null)
+      {
+         throw new IllegalStateException("Node was deleted (items)");
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+
+      // TODO it's put anyway.. but with check?
+      Fqn<String> parentFqn = makeParentFqn(data.getQPath());
+      Object prev = cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
+      if (prev == null)
+      {
+         throw new IllegalStateException("Property was deleted (tree)");
+      }
+
+      prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+      if (prev == null)
+      {
+         throw new IllegalStateException("Property was deleted (items)");
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit() throws IllegalStateException, RepositoryException
+   {
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("commit " + batchStarted);
+      }
+
+      // end batch
+      if (batchStarted)
+      {
+         this.cache.endBatch(true); // treePrint(treeRoot);
+         batchStarted = false;
+      }
+      else
+      {
+         // TODO
+         LOG.warn("Commit call without changes made.");
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback() throws IllegalStateException, RepositoryException
+   {
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("rollback " + batchStarted);
+      }
+
+      // rollback batch
+      if (batchStarted)
+      {
+         this.cache.endBatch(false);
+         batchStarted = false;
+      }
+      else
+      {
+         // TODO
+         LOG.warn("Rollback call without changes made.");
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean isOpened()
+   {
+      return true;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void close() throws IllegalStateException, RepositoryException
+   {
+      // TODO Auto-generated method stub
+   }
+
+   /**
+    *  Start batching.
+    */
+   private void startBatch()
+   {
+      if (!batchStarted)
+      {
+         batchStarted = true;
+         this.cache.startBatch();
+      }
+   }
+
+}

Copied: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java (from rev 465, 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/JBossCacheTreeStorageConnection.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -0,0 +1,408 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+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.QPathEntry;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+/**
+ * DEPRECATED - DO NOT USE!
+ * 
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 23.10.2009<br/>
+ *
+ * Cache contains several regions:<br/>
+ * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id stored.<br/>
+ * Items map. /$ITEMS: Key=Id, Value = ItemData.<br/>
+ * References map ??? /$REFS: Key=NodeId, Value = PropertyId.<br/>
+ *
+ * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
+ * @version $Id$
+ */
+ at Deprecated
+public class JBossCacheTreeStorageConnection extends JBossCacheStorage implements WorkspaceStorageConnection
+{
+
+   protected static final Log LOG = ExoLogger.getLogger("jcr.JBossCacheStorageConnection");
+
+   private final Cache<Serializable, Object> cache;
+
+   //private final Node<Serializable, Object> treeRoot;
+
+   //private final Node<Serializable, Object> itemsRoot;
+
+   /**
+    *  Start batching flag. 'true' if batching was started, 'false' if batching is not start. 
+    */
+   private boolean batchStarted = false;
+
+   /**
+    * JBossCacheStorageConnection  constructor.
+    *
+    * @param cache Cache<Serializable, Object>
+    */
+   @Deprecated
+   public JBossCacheTreeStorageConnection(Cache<Serializable, Object> cache, Node<Serializable, Object> treeRoot,
+      Node<Serializable, Object> itemsRoot)
+   {
+      super(treeRoot.getFqn(), itemsRoot.getFqn());
+      
+      this.cache = cache;
+      //this.itemsRoot = itemsRoot;
+      //this.treeRoot = treeRoot;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void add(NodeData data) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
+      IllegalStateException
+   {
+      startBatch();
+      cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
+      cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+      Fqn<String> parentFqn = makeParentFqn(data.getQPath());
+
+      // add an attr to the parent node as key=PropertyName value=PropertyId
+      cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
+      cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+      cache.removeNode(makeNodeFqn(data.getQPath()));
+      cache.removeNode(makeIdFqn(data.getIdentifier()));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+      // delete attr on parent by key=PropertyName
+      cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
+      cache.removeNode(makeIdFqn(data.getIdentifier()));
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
+   {
+      //Set<Object> childNames = cache.getChildrenNames(makeNodeFqn(parent.getQPath()));
+      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parent.getQPath()));
+      if (parentNode == null)
+      {
+         throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
+      }
+
+      Set<Node<Serializable, Object>> childNodes = parentNode.getChildren();
+
+      List<NodeData> childs = new ArrayList<NodeData>();
+      for (Node<Serializable, Object> child : childNodes)
+      {
+         String childId = (String)child.get(ITEM_ID);
+
+         // TODO NodeData or PropertyData? As ItemData check then and cast.
+         NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
+         if (node == null)
+         {
+            throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
+         }
+         childs.add(node);
+      }
+
+      return childs;
+   }
+
+   private void treePrint(Node<Serializable, Object> node)
+   {
+      for (Node<Serializable, Object> child : node.getChildren())
+      {
+         System.out.println(child.toString());
+         for (Serializable key : child.getKeys())
+         {
+            System.out.println("\t" + key + "=" + child.get(key));
+         }
+         if (!child.isLeaf())
+         {
+            treePrint(child);
+         }
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
+   {
+      // TODO treeRoot.getChild(f) possible if f not a direct child??? 
+      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parent.getQPath()));
+      if (parentNode == null)
+      {
+         throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
+      }
+
+      List<PropertyData> childs = new ArrayList<PropertyData>();
+
+      for (Serializable key : parentNode.getKeys())
+      {
+         if (!key.equals(ITEM_ID))
+         {
+            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)
+            {
+               throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
+            }
+            childs.add(property);
+         }
+      }
+
+      return childs;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
+   {
+      // TODO it's same as getChild... now
+      return getChildPropertiesData(parent);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
+   {
+      Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parentData.getQPath()));
+      if (parentNode == null)
+      {
+         throw new IllegalStateException("Get Item data error: parent not found " + parentData.getQPath().getAsString());
+      }
+
+      // TODO check performance of Node vs Property get
+
+      String propertyId = (String)parentNode.get(name.getAsString());
+      if (propertyId != null)
+      {
+         // it's Property Item
+         return (PropertyData)cache.get(makeIdFqn(propertyId), ITEM_DATA);
+      }
+      else
+      {
+         // it's Node Item
+         Node<Serializable, Object> node = parentNode.getChild(name.getAsString(true)); // TODO String not Fqn?
+         if (node != null)
+         {
+            String nodeId = (String)node.get(ITEM_ID);
+            if (nodeId != null)
+            {
+               return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
+            }
+         }
+      }
+
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
+   {
+      return (ItemData)cache.get(makeIdFqn(identifier), ITEM_DATA);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
+      IllegalStateException, UnsupportedOperationException
+   {
+      // TODO refs impl
+      return new ArrayList<PropertyData>();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+      // TODO move Node to a new position at the tree,
+      // but prev location was in prev DELETE.
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+
+      // TODO it's put anyway.. but with check?
+      Object prev = cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
+      if (prev == null)
+      {
+         throw new IllegalStateException("Node was deleted (tree)");
+      }
+
+      prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+      if (prev == null)
+      {
+         throw new IllegalStateException("Node was deleted (items)");
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+      InvalidItemStateException, IllegalStateException
+   {
+      startBatch();
+
+      // TODO it's put anyway.. but with check?
+      Fqn<String> parentFqn = makeParentFqn(data.getQPath());
+      Object prev = cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
+      if (prev == null)
+      {
+         throw new IllegalStateException("Property was deleted (tree)");
+      }
+
+      prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+      if (prev == null)
+      {
+         throw new IllegalStateException("Property was deleted (items)");
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit() throws IllegalStateException, RepositoryException
+   {
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("commit " + batchStarted);
+      }
+
+      // end batch
+      if (batchStarted)
+      {
+         this.cache.endBatch(true); // treePrint(treeRoot);
+         batchStarted = false;
+      }
+      else
+      {
+         // TODO
+         LOG.warn("Commit call without changes made.");
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback() throws IllegalStateException, RepositoryException
+   {
+      if (LOG.isDebugEnabled())
+      {
+         LOG.debug("rollback " + batchStarted);
+      }
+
+      // rollback batch
+      if (batchStarted)
+      {
+         this.cache.endBatch(false);
+         batchStarted = false;
+      }
+      else
+      {
+         // TODO
+         LOG.warn("Rollback call without changes made.");
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean isOpened()
+   {
+      return true;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void close() throws IllegalStateException, RepositoryException
+   {
+      // TODO Auto-generated method stub
+   }
+
+   /**
+    *  Start batching.
+    */
+   private void startBatch()
+   {
+      if (!batchStarted)
+      {
+         batchStarted = true;
+         this.cache.startBatch();
+      }
+   }
+
+}


Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id

Deleted: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java	2009-11-04 14:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -1,41 +0,0 @@
-/*
-    * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-
-/**
- * Created by The eXo Platform SAS.
- * 
- * <br/>Date: 30.10.2009
- *
- * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
- * @version $Id$
- */
-public class ExoJCRCacheLoaderTest extends JBossCacheStorageConnectionTest
-{
-
-   @Override
-   protected void initJBCConfig()
-   {
-      jbcConfig = "conf/standalone/test-jbosscache-config-exoloader.xml";
-   }
-
-   
-   
-}

Copied: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java (from rev 468, jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java)
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -0,0 +1,41 @@
+/*
+    * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+
+/**
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 30.10.2009
+ *
+ * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
+ * @version $Id$
+ */
+public class ExoJCRTreeCacheLoaderTest extends JBossCacheTreeStorageConnectionTest
+{
+
+   @Override
+   protected void initJBCConfig()
+   {
+      jbcConfig = "conf/standalone/test-jbosscache-config-exoloader.xml";
+   }
+
+   
+   
+}


Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id

Deleted: 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-04 14:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -1,685 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-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;
-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;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS.
- * 
- * <br/>Date: 25.10.2009
- *
- * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
- * @version $Id$
- */
-public class JBossCacheStorageConnectionTest extends TestCase
-{
-
-   protected JBossCacheStorageConnection conn;
-
-   protected Cache<Serializable, Object> cache;
-
-   protected Node<Serializable, Object> tree;
-
-   protected Node<Serializable, Object> items;
-   
-   protected String jbcConfig; 
-
-   /**
-    * {@inheritDoc}
-    */
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-      // JBossCache 
-      initJBCConfig();
-      
-      cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig);
-
-      Node<Serializable, Object> cacheRoot = cache.getRoot();
-      //Node<Serializable, Object> wsRoot = cacheRoot.addChild(Fqn.fromElements("repo", "ws"));
-
-      // prepare cache structures
-      tree = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
-      items = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS));
-
-      // run cache
-      cache.create();
-      cache.start();
-
-      // JCR connection
-      conn = new JBossCacheStorageConnection(cache, tree, items);
-   }
-   
-   protected void initJBCConfig() {
-      jbcConfig = "conf/standalone/test-jbosscache-config-jdbcloader.xml";
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   protected void tearDown() throws Exception
-   {
-
-      cache.stop();
-      cache.destroy();
-
-      super.tearDown();
-   }
-
-   private void treePrint(Node<Serializable, Object> node)
-   {
-      for (Node<Serializable, Object> child : node.getChildren())
-      {
-         System.out.println(child.toString());
-         for (Serializable key : child.getKeys())
-         {
-            System.out.println("\t" + key + "=" + child.get(key));
-         }
-         if (!child.isLeaf())
-         {
-            treePrint(child);
-         }
-      }
-   }
-
-   private Fqn<String> makeFqn(Node<Serializable, Object> root, QPath nodePath)
-   {
-      QPathEntry[] path = nodePath.getEntries();
-      String[] fqns = new String[path.length];
-
-      for (int i = 0; i < path.length; i++)
-      {
-         fqns[i] = path[i].getAsString(true);
-      }
-
-      return Fqn.fromRelativeFqn(root.getFqn(), Fqn.fromElements(fqns));
-   }
-
-   public void testAddNode() 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 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 in tree
-      treePrint(tree);
-
-      // get root node ([]:1)
-      Node<Serializable, Object> rootNode =
-         tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
-            .getAsString(true)));
-
-      assertNotNull("Node expected", rootNode);
-
-      assertEquals("Childs expected", 2, rootNode.getChildren().size());
-
-      for (Node<Serializable, Object> child : rootNode.getChildren())
-      {
-         String nodeName = child.getFqn().getLastElementAsString();
-         String nodeId = (String)child.get(JBossCacheStorageConnection.ITEM_ID);
-         if (nodeName.equals(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)))
-         {
-            assertEquals("Node id wrong", node1id, nodeId);
-         }
-         else if (nodeName
-            .equals(Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.getEntries().length - 1]
-               .getAsString(true)))
-         {
-            assertEquals("Node id wrong", Constants.SYSTEM_UUID, nodeId);
-         }
-         else
-         {
-            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);
-
-      Object dataObject = itemsNode.get(JBossCacheStorageConnection.ITEM_DATA);
-      assertTrue("Node item data is not a Node", dataObject instanceof NodeData);
-
-      NodeData data = (NodeData)dataObject;
-      assertEquals("Node id wrong", node1id, data.getIdentifier());
-      assertEquals("Node path wrong", node1path, data.getQPath());
-   }
-
-   public void testAddProperty() 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";
-      QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
-      TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
-      String propValue1 = "Property value #1";
-      propData1.setValue(new TransientValueData(propValue1));
-      conn.add(propData1);
-
-      // add property (/jcr:mixinTypes)
-      String propId2 = "2";
-      QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
-      TransientPropertyData propData2 = new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false);
-      String propValue2 = "Property value #2";
-      propData2.setValue(new TransientValueData(propValue2));
-      conn.add(propData2);
-
-      // 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)));
-
-      assertEquals("Attributes ammount wrong", 3, rootNode.getKeys().size());
-
-      String pid1 = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
-      assertNotNull("Property ID should exists", pid1);
-      assertEquals("Property ID wrong", propId1, pid1);
-
-      String pid2 = (String)rootNode.get(Constants.JCR_MIXINTYPES.getAsString());
-      assertNotNull("Property ID should exists", pid2);
-      assertEquals("Property ID wrong", propId2, pid2);
-
-      // TODO check order
-      int index = 0;
-      for (Serializable key : rootNode.getKeys())
-      {
-         //System.out.println(key);
-         //index++;
-      }
-
-      // check in items
-      treePrint(items);
-
-      Node<Serializable, Object> itemsProp1 = items.getChild(Fqn.fromElements(propId1));
-      Object data1Object = itemsProp1.get(JBossCacheStorageConnection.ITEM_DATA);
-      assertNotNull("Property item data should exists", data1Object);
-      assertTrue("Property item data is not a Property", data1Object instanceof PropertyData);
-
-      PropertyData data1 = (PropertyData)data1Object;
-      assertEquals("Property id wrong", propId1, data1.getIdentifier());
-      assertEquals("Property path wrong", propPath1, data1.getQPath());
-      assertEquals("Property Value wrong", propValue1, new String(data1.getValues().get(0).getAsByteArray(),
-         Constants.DEFAULT_ENCODING));
-
-      Node<Serializable, Object> itemsProp2 = items.getChild(Fqn.fromElements(propId2));
-      Object data2Object = itemsProp2.get(JBossCacheStorageConnection.ITEM_DATA);
-      assertNotNull("Property item data should exists", data2Object);
-      assertTrue("Property item data is not a Property", data2Object instanceof PropertyData);
-
-      PropertyData data2 = (PropertyData)data2Object;
-      assertEquals("Property id wrong", propId2, data2.getIdentifier());
-      assertEquals("Property path wrong", propPath2, data2.getQPath());
-      assertEquals("Property Value wrong", propValue2, new String(data2.getValues().get(0).getAsByteArray(),
-         Constants.DEFAULT_ENCODING));
-   }
-
-   public void testDeleteNode() 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 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()));
-
-      // get root node ([]:1)
-      Node<Serializable, Object> rootNode =
-         tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
-            .getAsString(true)));
-
-      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()));
-
-      // check in tree
-      treePrint(tree);
-
-      Node<Serializable, Object> node =
-         rootNode.getChild(Fqn
-            .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
-
-      assertNull("Node should be deleted", node);
-
-      assertEquals("Childs expected", 1, rootNode.getChildren().size());
-
-      Node<Serializable, Object> child = rootNode.getChildren().iterator().next();
-      assertEquals("Node name wrong",
-         Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.getEntries().length - 1].getAsString(true),
-         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 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 exists", items.getChild(Fqn.fromElements(propId2)));
-   }
-
-   public void testUpdateNode() 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 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()));
-
-      // get root node ([]:1)
-      Node<Serializable, Object> rootNode =
-         tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
-            .getAsString(true)));
-
-      // update /node (order number)
-      int nodeOrderNumb = 1;
-      conn.update(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0],
-         nodeOrderNumb, Constants.ROOT_UUID, new AccessControlList()));
-
-      // check in tree
-      treePrint(tree);
-
-      Node<Serializable, Object> node =
-         rootNode.getChild(Fqn
-            .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
-
-      assertNotNull("Node should exists", node);
-      assertEquals("Child expected", 1, rootNode.getChildren().size());
-
-      // check in items
-      treePrint(items);
-
-      Node<Serializable, Object> itemNode = items.getChild(Fqn.fromElements(node1id));
-      assertNotNull("Node item data should exists", itemNode);
-
-      Object dataObject = itemNode.get(JBossCacheStorageConnection.ITEM_DATA);
-      assertTrue("Node item data should be a NodeData", dataObject instanceof NodeData);
-      assertEquals("Node id wrong", node1id, ((NodeData)dataObject).getIdentifier());
-      assertEquals("Node path wrong", node1path, ((NodeData)dataObject).getQPath());
-      assertEquals("Node order number wrong", nodeOrderNumb, ((NodeData)dataObject).getOrderNumber());
-   }
-
-   public void testUpdateProperty() 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 (/prop1)
-      String propId1 = "1";
-      QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
-      TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
-      String propValue1 = "Property value #1";
-      propData1.setValue(new TransientValueData(propValue1));
-      conn.add(propData1);
-
-      // update property (/prop1) with new value
-      TransientPropertyData propDataU = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
-      String propValueU = "Updated Property value #1";
-      propDataU.setValue(new TransientValueData(propValueU));
-      conn.update(propDataU);
-
-      // 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)));
-
-      assertEquals("Attributes ammount wrong", 2, rootNode.getKeys().size());
-
-      String pid = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
-      assertEquals("Property ID wrong", propId1, pid);
-
-      // check in items
-      treePrint(items);
-
-      Node<Serializable, Object> itemsProp1 = items.getChild(Fqn.fromElements(propId1));
-      Object data1Object = itemsProp1.get(JBossCacheStorageConnection.ITEM_DATA);
-      assertNotNull("Property item data should exists", data1Object);
-      assertTrue("Property item data is not a Property", data1Object instanceof PropertyData);
-
-      PropertyData data1 = (PropertyData)data1Object;
-      assertEquals("Property id wrong", propId1, data1.getIdentifier());
-      assertEquals("Property path wrong", propPath1, data1.getQPath());
-      assertEquals("Property Value wrong", propValueU, new String(data1.getValues().get(0).getAsByteArray(),
-         Constants.DEFAULT_ENCODING));
-   }
-
-   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
-   {
-      // 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 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()));
-
-      assertEquals("Childs amount wrong", 2, childs.size());
-
-      for (NodeData child : childs)
-      {
-         if (child.getQPath().equals(node1path))
-         {
-            assertEquals("Node id wrong", node1id, child.getIdentifier());
-         }
-         else if (child.getQPath().equals(Constants.JCR_SYSTEM_PATH))
-         {
-            assertEquals("Node id wrong", Constants.SYSTEM_UUID, child.getIdentifier());
-         }
-         else
-         {
-            fail("Wrong Node found");
-         }
-      }
-   }
-
-   public void testGetChildProperties() 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";
-      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));
-
-      // add property (/a)
-      String propId3 = "3";
-      InternalQName propName3 = InternalQName.parse("[]a");
-      conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName3), propId3, 1, 1,
-         Constants.ROOT_UUID, false));
-
-      // add property (/b)
-      String propId4 = "4";
-      InternalQName propName4 = InternalQName.parse("[]b");
-      conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName4), propId4, 1, 1,
-         Constants.ROOT_UUID, false));
-
-      // 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()));
-
-      assertEquals("Childs amount wrong", 4, childs.size());
-
-      for (PropertyData child : childs)
-      {
-         if (child.getQPath().getName().equals(Constants.JCR_PRIMARYTYPE))
-         {
-            assertEquals("Property id wrong", propId1, child.getIdentifier());
-         }
-         else if (child.getQPath().getName().equals(Constants.JCR_MIXINTYPES))
-         {
-            assertEquals("Property id wrong", propId2, child.getIdentifier());
-         }
-         else if (child.getQPath().getName().equals(propName3))
-         {
-            assertEquals("Property id wrong", propId3, child.getIdentifier());
-         }
-         else if (child.getQPath().getName().equals(propName4))
-         {
-            assertEquals("Property id wrong", propId4, child.getIdentifier());
-         }
-         else
-         {
-            fail("Wrong Property found");
-         }
-      }
-   }
-
-}

Copied: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java (from rev 468, 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/JBossCacheTreeStorageConnectionTest.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java	2009-11-04 16:05:15 UTC (rev 470)
@@ -0,0 +1,685 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+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;
+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;
+import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 25.10.2009
+ *
+ * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
+ * @version $Id$
+ */
+public class JBossCacheTreeStorageConnectionTest extends TestCase
+{
+
+   protected JBossCacheTreeStorageConnection conn;
+
+   protected Cache<Serializable, Object> cache;
+
+   protected Node<Serializable, Object> tree;
+
+   protected Node<Serializable, Object> items;
+   
+   protected String jbcConfig; 
+
+   /**
+    * {@inheritDoc}
+    */
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      // JBossCache 
+      initJBCConfig();
+      
+      cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig);
+
+      Node<Serializable, Object> cacheRoot = cache.getRoot();
+      //Node<Serializable, Object> wsRoot = cacheRoot.addChild(Fqn.fromElements("repo", "ws"));
+
+      // prepare cache structures
+      tree = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
+      items = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS));
+
+      // run cache
+      cache.create();
+      cache.start();
+
+      // JCR connection
+      conn = new JBossCacheTreeStorageConnection(cache, tree, items);
+   }
+   
+   protected void initJBCConfig() {
+      jbcConfig = "conf/standalone/test-jbosscache-config-jdbcloader.xml";
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   protected void tearDown() throws Exception
+   {
+
+      cache.stop();
+      cache.destroy();
+
+      super.tearDown();
+   }
+
+   private void treePrint(Node<Serializable, Object> node)
+   {
+      for (Node<Serializable, Object> child : node.getChildren())
+      {
+         System.out.println(child.toString());
+         for (Serializable key : child.getKeys())
+         {
+            System.out.println("\t" + key + "=" + child.get(key));
+         }
+         if (!child.isLeaf())
+         {
+            treePrint(child);
+         }
+      }
+   }
+
+   private Fqn<String> makeFqn(Node<Serializable, Object> root, QPath nodePath)
+   {
+      QPathEntry[] path = nodePath.getEntries();
+      String[] fqns = new String[path.length];
+
+      for (int i = 0; i < path.length; i++)
+      {
+         fqns[i] = path[i].getAsString(true);
+      }
+
+      return Fqn.fromRelativeFqn(root.getFqn(), Fqn.fromElements(fqns));
+   }
+
+   public void testAddNode() 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 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 in tree
+      treePrint(tree);
+
+      // get root node ([]:1)
+      Node<Serializable, Object> rootNode =
+         tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+            .getAsString(true)));
+
+      assertNotNull("Node expected", rootNode);
+
+      assertEquals("Childs expected", 2, rootNode.getChildren().size());
+
+      for (Node<Serializable, Object> child : rootNode.getChildren())
+      {
+         String nodeName = child.getFqn().getLastElementAsString();
+         String nodeId = (String)child.get(JBossCacheStorageConnection.ITEM_ID);
+         if (nodeName.equals(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)))
+         {
+            assertEquals("Node id wrong", node1id, nodeId);
+         }
+         else if (nodeName
+            .equals(Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.getEntries().length - 1]
+               .getAsString(true)))
+         {
+            assertEquals("Node id wrong", Constants.SYSTEM_UUID, nodeId);
+         }
+         else
+         {
+            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);
+
+      Object dataObject = itemsNode.get(JBossCacheStorageConnection.ITEM_DATA);
+      assertTrue("Node item data is not a Node", dataObject instanceof NodeData);
+
+      NodeData data = (NodeData)dataObject;
+      assertEquals("Node id wrong", node1id, data.getIdentifier());
+      assertEquals("Node path wrong", node1path, data.getQPath());
+   }
+
+   public void testAddProperty() 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";
+      QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
+      TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
+      String propValue1 = "Property value #1";
+      propData1.setValue(new TransientValueData(propValue1));
+      conn.add(propData1);
+
+      // add property (/jcr:mixinTypes)
+      String propId2 = "2";
+      QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
+      TransientPropertyData propData2 = new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false);
+      String propValue2 = "Property value #2";
+      propData2.setValue(new TransientValueData(propValue2));
+      conn.add(propData2);
+
+      // 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)));
+
+      assertEquals("Attributes ammount wrong", 3, rootNode.getKeys().size());
+
+      String pid1 = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
+      assertNotNull("Property ID should exists", pid1);
+      assertEquals("Property ID wrong", propId1, pid1);
+
+      String pid2 = (String)rootNode.get(Constants.JCR_MIXINTYPES.getAsString());
+      assertNotNull("Property ID should exists", pid2);
+      assertEquals("Property ID wrong", propId2, pid2);
+
+      // TODO check order
+      int index = 0;
+      for (Serializable key : rootNode.getKeys())
+      {
+         //System.out.println(key);
+         //index++;
+      }
+
+      // check in items
+      treePrint(items);
+
+      Node<Serializable, Object> itemsProp1 = items.getChild(Fqn.fromElements(propId1));
+      Object data1Object = itemsProp1.get(JBossCacheStorageConnection.ITEM_DATA);
+      assertNotNull("Property item data should exists", data1Object);
+      assertTrue("Property item data is not a Property", data1Object instanceof PropertyData);
+
+      PropertyData data1 = (PropertyData)data1Object;
+      assertEquals("Property id wrong", propId1, data1.getIdentifier());
+      assertEquals("Property path wrong", propPath1, data1.getQPath());
+      assertEquals("Property Value wrong", propValue1, new String(data1.getValues().get(0).getAsByteArray(),
+         Constants.DEFAULT_ENCODING));
+
+      Node<Serializable, Object> itemsProp2 = items.getChild(Fqn.fromElements(propId2));
+      Object data2Object = itemsProp2.get(JBossCacheStorageConnection.ITEM_DATA);
+      assertNotNull("Property item data should exists", data2Object);
+      assertTrue("Property item data is not a Property", data2Object instanceof PropertyData);
+
+      PropertyData data2 = (PropertyData)data2Object;
+      assertEquals("Property id wrong", propId2, data2.getIdentifier());
+      assertEquals("Property path wrong", propPath2, data2.getQPath());
+      assertEquals("Property Value wrong", propValue2, new String(data2.getValues().get(0).getAsByteArray(),
+         Constants.DEFAULT_ENCODING));
+   }
+
+   public void testDeleteNode() 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 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()));
+
+      // get root node ([]:1)
+      Node<Serializable, Object> rootNode =
+         tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+            .getAsString(true)));
+
+      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()));
+
+      // check in tree
+      treePrint(tree);
+
+      Node<Serializable, Object> node =
+         rootNode.getChild(Fqn
+            .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
+
+      assertNull("Node should be deleted", node);
+
+      assertEquals("Childs expected", 1, rootNode.getChildren().size());
+
+      Node<Serializable, Object> child = rootNode.getChildren().iterator().next();
+      assertEquals("Node name wrong",
+         Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.getEntries().length - 1].getAsString(true),
+         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 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 exists", items.getChild(Fqn.fromElements(propId2)));
+   }
+
+   public void testUpdateNode() 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 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()));
+
+      // get root node ([]:1)
+      Node<Serializable, Object> rootNode =
+         tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+            .getAsString(true)));
+
+      // update /node (order number)
+      int nodeOrderNumb = 1;
+      conn.update(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0],
+         nodeOrderNumb, Constants.ROOT_UUID, new AccessControlList()));
+
+      // check in tree
+      treePrint(tree);
+
+      Node<Serializable, Object> node =
+         rootNode.getChild(Fqn
+            .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
+
+      assertNotNull("Node should exists", node);
+      assertEquals("Child expected", 1, rootNode.getChildren().size());
+
+      // check in items
+      treePrint(items);
+
+      Node<Serializable, Object> itemNode = items.getChild(Fqn.fromElements(node1id));
+      assertNotNull("Node item data should exists", itemNode);
+
+      Object dataObject = itemNode.get(JBossCacheStorageConnection.ITEM_DATA);
+      assertTrue("Node item data should be a NodeData", dataObject instanceof NodeData);
+      assertEquals("Node id wrong", node1id, ((NodeData)dataObject).getIdentifier());
+      assertEquals("Node path wrong", node1path, ((NodeData)dataObject).getQPath());
+      assertEquals("Node order number wrong", nodeOrderNumb, ((NodeData)dataObject).getOrderNumber());
+   }
+
+   public void testUpdateProperty() 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 (/prop1)
+      String propId1 = "1";
+      QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
+      TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
+      String propValue1 = "Property value #1";
+      propData1.setValue(new TransientValueData(propValue1));
+      conn.add(propData1);
+
+      // update property (/prop1) with new value
+      TransientPropertyData propDataU = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
+      String propValueU = "Updated Property value #1";
+      propDataU.setValue(new TransientValueData(propValueU));
+      conn.update(propDataU);
+
+      // 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)));
+
+      assertEquals("Attributes ammount wrong", 2, rootNode.getKeys().size());
+
+      String pid = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
+      assertEquals("Property ID wrong", propId1, pid);
+
+      // check in items
+      treePrint(items);
+
+      Node<Serializable, Object> itemsProp1 = items.getChild(Fqn.fromElements(propId1));
+      Object data1Object = itemsProp1.get(JBossCacheStorageConnection.ITEM_DATA);
+      assertNotNull("Property item data should exists", data1Object);
+      assertTrue("Property item data is not a Property", data1Object instanceof PropertyData);
+
+      PropertyData data1 = (PropertyData)data1Object;
+      assertEquals("Property id wrong", propId1, data1.getIdentifier());
+      assertEquals("Property path wrong", propPath1, data1.getQPath());
+      assertEquals("Property Value wrong", propValueU, new String(data1.getValues().get(0).getAsByteArray(),
+         Constants.DEFAULT_ENCODING));
+   }
+
+   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
+   {
+      // 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 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()));
+
+      assertEquals("Childs amount wrong", 2, childs.size());
+
+      for (NodeData child : childs)
+      {
+         if (child.getQPath().equals(node1path))
+         {
+            assertEquals("Node id wrong", node1id, child.getIdentifier());
+         }
+         else if (child.getQPath().equals(Constants.JCR_SYSTEM_PATH))
+         {
+            assertEquals("Node id wrong", Constants.SYSTEM_UUID, child.getIdentifier());
+         }
+         else
+         {
+            fail("Wrong Node found");
+         }
+      }
+   }
+
+   public void testGetChildProperties() 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";
+      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));
+
+      // add property (/a)
+      String propId3 = "3";
+      InternalQName propName3 = InternalQName.parse("[]a");
+      conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName3), propId3, 1, 1,
+         Constants.ROOT_UUID, false));
+
+      // add property (/b)
+      String propId4 = "4";
+      InternalQName propName4 = InternalQName.parse("[]b");
+      conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName4), propId4, 1, 1,
+         Constants.ROOT_UUID, false));
+
+      // 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()));
+
+      assertEquals("Childs amount wrong", 4, childs.size());
+
+      for (PropertyData child : childs)
+      {
+         if (child.getQPath().getName().equals(Constants.JCR_PRIMARYTYPE))
+         {
+            assertEquals("Property id wrong", propId1, child.getIdentifier());
+         }
+         else if (child.getQPath().getName().equals(Constants.JCR_MIXINTYPES))
+         {
+            assertEquals("Property id wrong", propId2, child.getIdentifier());
+         }
+         else if (child.getQPath().getName().equals(propName3))
+         {
+            assertEquals("Property id wrong", propId3, child.getIdentifier());
+         }
+         else if (child.getQPath().getName().equals(propName4))
+         {
+            assertEquals("Property id wrong", propId4, child.getIdentifier());
+         }
+         else
+         {
+            fail("Wrong Property found");
+         }
+      }
+   }
+
+}


Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id



More information about the exo-jcr-commits mailing list