jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r541275 - in /jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi: NodeOrderTest.java TestAll.java
Date Thu, 24 May 2007 11:45:12 GMT
Author: angela
Date: Thu May 24 04:45:11 2007
New Revision: 541275

URL: http://svn.apache.org/viewvc?view=rev&rev=541275
Log:
Testing: test if order of orderable child nodes is stable.

Added:
    jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/NodeOrderTest.java
  (with props)
Modified:
    jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java

Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/NodeOrderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/NodeOrderTest.java?view=auto&rev=541275
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/NodeOrderTest.java
(added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/NodeOrderTest.java
Thu May 24 04:45:11 2007
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * <code>NodeOrderTest</code>...
+ */
+public class NodeOrderTest extends AbstractJCRTest {
+
+    private static Logger log = LoggerFactory.getLogger(NodeOrderTest.class);
+
+    private Node[] children;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (!testRootNode.getPrimaryNodeType().hasOrderableChildNodes()) {
+            throw new NotExecutableException("Test node does not have orderable children.");
+        }
+        children = new Node[4];
+        children[0] = testRootNode.addNode(nodeName1, testNodeType);
+        children[1] = testRootNode.addNode(nodeName2, testNodeType);
+        children[2] = testRootNode.addNode(nodeName3, testNodeType);
+        children[3] = testRootNode.addNode(nodeName4, testNodeType);
+        testRootNode.save();
+    }
+
+    private static void checkOrder(NodeIterator it, Node[] children) throws RepositoryException
{
+        int i = 0;
+        while (it.hasNext()) {
+            if (i >= children.length) {
+                fail("Node.getNodes() return more child nodes, that have been created.");
+            }
+            Node n = it.nextNode();
+            assertTrue("Wrong order of child nodes returned by Node.getNodes().", n.isSame(children[i]));
+            i++;
+        }
+
+        if (i != children.length) {
+            fail("Node.getNodes() did not return all child nodes.");
+        }
+    }
+
+    /**
+     * Test if the order of Nodes is maintained across multiple calls to
+     * <code>Node.getNodes()</code>.
+     */
+    public void testOrder() throws RepositoryException {
+        NodeIterator it = testRootNode.getNodes();
+        checkOrder(it, children);
+        it = testRootNode.getNodes();
+        checkOrder(it, children);
+    }
+
+    /**
+     * Test if the order of Nodes is the same when accessed through another
+     * <code>Session</code>.
+     */
+    public void testOrder2() throws RepositoryException {
+        Session another = helper.getReadOnlySession();
+        try {
+            NodeIterator it = ((Node) another.getItem(testRootNode.getPath())).getNodes();
+            checkOrder(it, children);
+        } finally {
+            another.logout();
+        }
+    }
+
+    /**
+     * Test if the order of Nodes is the same when accessed through another
+     * <code>Session</code> after having accessed some of the nodes individually.
+     */
+    public void testOrderAfterIndividualAccess() throws RepositoryException {
+        Session another = helper.getReadOnlySession();
+        try {
+            Node n2 = (Node) another.getItem(children[2].getPath());
+            Node n0 = (Node) another.getItem(children[0].getPath());
+            NodeIterator it = ((Node) another.getItem(testRootNode.getPath())).getNodes();
+            checkOrder(it, children);
+        } finally {
+            another.logout();
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/NodeOrderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/NodeOrderTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java?view=diff&rev=541275&r1=541274&r2=541275
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
(original)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
Thu May 24 04:45:11 2007
@@ -35,6 +35,7 @@
 
         suite.addTestSuite(AccessByRelativePathTest.class);
         suite.addTestSuite(SNSIndexTest.class);
+        suite.addTestSuite(NodeOrderTest.class);
 
         // set/add property
         suite.addTestSuite(AddNewPropertyTest.class);



Mime
View raw message