[exo-jcr-commits] exo-jcr SVN: r2446 - in jcr/trunk/exo.jcr.component.core: src/test/java/org/exoplatform/services/jcr/usecases and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jun 1 04:53:21 EDT 2010


Author: sergiykarpenko
Date: 2010-06-01 04:53:20 -0400 (Tue, 01 Jun 2010)
New Revision: 2446

Added:
   jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestOrderBeforeOnTree.java
Modified:
   jcr/trunk/exo.jcr.component.core/pom.xml
Log:
EXOJCR-763: TestOrderBeforeOnTree added

Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml	2010-05-28 14:47:38 UTC (rev 2445)
+++ jcr/trunk/exo.jcr.component.core/pom.xml	2010-06-01 08:53:20 UTC (rev 2446)
@@ -423,7 +423,8 @@
                   <exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCacheMetrics.java</exclude>
                   <exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
                   <exclude>org/exoplatform/services/jcr/**/impl/**/TestLockPerstistentDataManager.java</exclude>
-                  <exclude>org/exoplatform/services/jcr/**/impl/**/TestCleanableFileStreamValueData.java</exclude>                  
+                  <exclude>org/exoplatform/services/jcr/**/impl/**/TestCleanableFileStreamValueData.java</exclude>      
+                  <exclude>org/exoplatform/services/jcr/**/usecases/TestOrderBeforeOnTree.java</exclude>      
                </excludes>
             </configuration>
          </plugin>
@@ -693,6 +694,7 @@
                         <exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
                         <exclude>org/exoplatform/services/jcr/**/impl/**/TestCleanableFileStreamValueData.java</exclude>
                         <exclude>org/exoplatform/services/jcr/**/impl/**/TestLockPerstistentDataManager.java</exclude>
+                        <exclude>org/exoplatform/services/jcr/**/usecases/TestOrderBeforeOnTree.java</exclude> 
                         <!-- From TCK -->
                         <exclude>org/apache/jackrabbit/test/api/TestAll.java</exclude>
                         <exclude>org/apache/jackrabbit/test/api/**/Abstract*.java</exclude>

Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestOrderBeforeOnTree.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestOrderBeforeOnTree.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestOrderBeforeOnTree.java	2010-06-01 08:53:20 UTC (rev 2446)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.usecases;
+
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+
+import javax.jcr.Node;
+
+/**
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 
+ *
+ * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a> 
+ * @version $Id: TestOrderBeforeOnTree.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestOrderBeforeOnTree extends BaseUsecasesTest
+{
+
+   public void testOrderBefore() throws Exception
+   {
+      final int LAYER_COUNT = 2;
+
+      final int SIBLINGS_COUNT = 5;
+
+      final String baseName = "subnode";
+
+      int[] currentIndexes = new int[LAYER_COUNT];
+
+      String[] uuids = new String[LAYER_COUNT];
+
+      Node testRoot = root.addNode("testRoot");
+      session.save();
+      Node curParent = testRoot;
+      for (int i = 0; i < LAYER_COUNT; i++)
+      {
+         Node n = null;
+         for (int j = 0; j < SIBLINGS_COUNT; j++)
+         {
+            n = curParent.addNode(baseName + i);
+            session.save();
+         }
+         curParent = n;
+         uuids[i] = ((NodeImpl)n).getIdentifier();
+
+         ItemData nd = ((NodeImpl)n).getData();
+         currentIndexes[i] = nd.getQPath().getEntries()[nd.getQPath().getEntries().length - 1].getIndex();
+      }
+
+      final int timesToCheck = 3;
+      final int layer = 0;
+      for (int c = 0; c < timesToCheck; c++)
+      {
+
+         // reorder             
+         int prevIndex = currentIndexes[layer];
+
+         int newIndex = currentIndexes[layer] != 1 ? currentIndexes[layer] - 1 : SIBLINGS_COUNT;
+
+         testRoot.orderBefore(baseName + layer + "[" + prevIndex + "]", (currentIndexes[layer] != 1 ? baseName + layer
+            + "[" + newIndex + "]" : null));
+         session.save();
+         currentIndexes[layer] = newIndex;
+
+         System.out.println("was " + prevIndex + "  now " + newIndex);
+
+         // check
+         // make path
+         StringBuilder str = new StringBuilder();
+         str.append("[]:1[]testRoot:1");
+         for (int i = 0; i < LAYER_COUNT; i++)
+         {
+            str.append("[]subnode" + i + ":" + currentIndexes[i]);
+         }
+
+         QPath expectedPath = QPath.parse(str.toString());
+
+         NodeImpl n = (NodeImpl)session.getNodeByIdentifier(uuids[LAYER_COUNT - 1]);
+         QPath realPath = n.getInternalPath();
+         if (!expectedPath.equals(realPath))
+         {
+            fail("Expected path " + expectedPath + " but was " + realPath);
+         }
+
+      }
+
+   }
+
+}



More information about the exo-jcr-commits mailing list