jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1680841 [5/6] - in /jackrabbit/branches/2.0: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/ jac...
Date Thu, 21 May 2015 12:12:13 GMT
Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/WorkspaceImport.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/WorkspaceImport.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/WorkspaceImport.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/WorkspaceImport.java Thu May 21 12:12:11 2015
@@ -1,110 +1,110 @@
-/*
- * 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.operation;
-
-import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
-import org.apache.jackrabbit.spi.NodeId;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.AccessDeniedException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.ImportUUIDBehavior;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import java.io.InputStream;
-
-/**
- * <code>WorkspaceImport</code>...
- */
-public class WorkspaceImport extends AbstractOperation {
-
-    private final NodeState nodeState;
-    private final InputStream xmlStream;
-    private final int uuidBehaviour;
-
-    private WorkspaceImport(NodeState nodeState, InputStream xmlStream, int uuidBehaviour) {
-        if (nodeState == null || xmlStream == null) {
-            throw new IllegalArgumentException();
-        }
-        this.nodeState = nodeState;
-        this.xmlStream = xmlStream;
-        this.uuidBehaviour = uuidBehaviour;
-
-        // NOTE: affected-states only needed for transient modifications
-    }
-
-    //----------------------------------------------------------< Operation >---
-    /**
-     * @see Operation#accept(OperationVisitor)
-     */
-    public void accept(OperationVisitor visitor) throws RepositoryException, ConstraintViolationException, AccessDeniedException, ItemExistsException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException, VersionException {
-        assert status == STATUS_PENDING;
-        visitor.visit(this);
-    }
-
-    /**
-     * Invalidates the <code>NodeState</code> that has been updated and all
-     * its decendants.
-     *
-     * @see Operation#persisted()
-     */
-    public void persisted() {
-        assert status == STATUS_PENDING;
-        status = STATUS_PERSISTED;
-        NodeEntry entry;
-        if (uuidBehaviour == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING ||
-                uuidBehaviour == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING) {
-            // invalidate the complete tree
-            entry = nodeState.getNodeEntry();
-            while (entry.getParent() != null) {
-                entry = entry.getParent();
-            }
-            entry.invalidate(true);
-        } else {
-            // import only added new items below the import target. therefore
-            // recursive invalidation is not required. // TODO correct?
-            nodeState.getNodeEntry().invalidate(false);
-        }
-    }
-
-    //----------------------------------------< Access Operation Parameters >---
-    public NodeId getNodeId() throws RepositoryException {
-        return nodeState.getNodeId();
-    }
-
-    public InputStream getXmlStream() {
-        return xmlStream;
-    }
-
-    public int getUuidBehaviour() {
-        return uuidBehaviour;
-    }
-
-    //------------------------------------------------------------< Factory >---
-    /**
-     *
-     * @param nodeState
-     * @param xmlStream
-     * @return
-     */
-    public static Operation create(NodeState nodeState, InputStream xmlStream, int uuidBehaviour) {
-        return new WorkspaceImport(nodeState, xmlStream, uuidBehaviour);
-    }
-}
+/*
+ * 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.operation;
+
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
+import org.apache.jackrabbit.spi.NodeId;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import java.io.InputStream;
+
+/**
+ * <code>WorkspaceImport</code>...
+ */
+public class WorkspaceImport extends AbstractOperation {
+
+    private final NodeState nodeState;
+    private final InputStream xmlStream;
+    private final int uuidBehaviour;
+
+    private WorkspaceImport(NodeState nodeState, InputStream xmlStream, int uuidBehaviour) {
+        if (nodeState == null || xmlStream == null) {
+            throw new IllegalArgumentException();
+        }
+        this.nodeState = nodeState;
+        this.xmlStream = xmlStream;
+        this.uuidBehaviour = uuidBehaviour;
+
+        // NOTE: affected-states only needed for transient modifications
+    }
+
+    //----------------------------------------------------------< Operation >---
+    /**
+     * @see Operation#accept(OperationVisitor)
+     */
+    public void accept(OperationVisitor visitor) throws RepositoryException, ConstraintViolationException, AccessDeniedException, ItemExistsException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException, VersionException {
+        assert status == STATUS_PENDING;
+        visitor.visit(this);
+    }
+
+    /**
+     * Invalidates the <code>NodeState</code> that has been updated and all
+     * its decendants.
+     *
+     * @see Operation#persisted()
+     */
+    public void persisted() {
+        assert status == STATUS_PENDING;
+        status = STATUS_PERSISTED;
+        NodeEntry entry;
+        if (uuidBehaviour == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING ||
+                uuidBehaviour == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING) {
+            // invalidate the complete tree
+            entry = nodeState.getNodeEntry();
+            while (entry.getParent() != null) {
+                entry = entry.getParent();
+            }
+            entry.invalidate(true);
+        } else {
+            // import only added new items below the import target. therefore
+            // recursive invalidation is not required. // TODO correct?
+            nodeState.getNodeEntry().invalidate(false);
+        }
+    }
+
+    //----------------------------------------< Access Operation Parameters >---
+    public NodeId getNodeId() throws RepositoryException {
+        return nodeState.getNodeId();
+    }
+
+    public InputStream getXmlStream() {
+        return xmlStream;
+    }
+
+    public int getUuidBehaviour() {
+        return uuidBehaviour;
+    }
+
+    //------------------------------------------------------------< Factory >---
+    /**
+     *
+     * @param nodeState
+     * @param xmlStream
+     * @return
+     */
+    public static Operation create(NodeState nodeState, InputStream xmlStream, int uuidBehaviour) {
+        return new WorkspaceImport(nodeState, xmlStream, uuidBehaviour);
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/WorkspaceImport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMixedTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMixedTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMixedTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMixedTest.java Thu May 21 12:12:11 2015
@@ -1,44 +1,44 @@
-/*
- * 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 javax.jcr.RepositoryException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.lock.LockException;
-
-/**
- * <code>ReorderMixedTest</code>...
- */
-public class ReorderMixedTest extends ReorderTest {
-
-    private static Logger log = LoggerFactory.getLogger(ReorderMixedTest.class);
-
-    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
-        child1 = testRootNode.addNode(nodeName2, testNodeType);
-        child2 = testRootNode.addNode(nodeName4, testNodeType);
-        child3 = testRootNode.addNode(nodeName2, testNodeType);
-        child4 = testRootNode.addNode(nodeName2, testNodeType);
-
-        testRootNode.save();
-    }
-}
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.lock.LockException;
+
+/**
+ * <code>ReorderMixedTest</code>...
+ */
+public class ReorderMixedTest extends ReorderTest {
+
+    private static Logger log = LoggerFactory.getLogger(ReorderMixedTest.class);
+
+    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
+        child1 = testRootNode.addNode(nodeName2, testNodeType);
+        child2 = testRootNode.addNode(nodeName4, testNodeType);
+        child3 = testRootNode.addNode(nodeName2, testNodeType);
+        child4 = testRootNode.addNode(nodeName2, testNodeType);
+
+        testRootNode.save();
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMixedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMoveTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMoveTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMoveTest.java Thu May 21 12:12:11 2015
@@ -1,257 +1,257 @@
-/*
- * 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.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.apache.jackrabbit.test.NotExecutableException;
-import org.apache.jackrabbit.util.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-/**
- * <code>ReorderMoveTest</code> testing various combinations of move/rename
- * and reorder with and without intermediate save, revert and other transient
- * modifications.
- */
-public class ReorderMoveTest extends AbstractJCRTest {
-
-    private static Logger log = LoggerFactory.getLogger(ReorderMoveTest.class);
-
-    private Node destParent;
-    private Node srcParent;
-    private String destPath;
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        if (!testRootNode.getPrimaryNodeType().hasOrderableChildNodes()) {
-            throw new NotExecutableException("Test node does not have orderable children.");
-        }
-
-        // create move-destination
-        destParent = testRootNode.addNode(nodeName4, testNodeType);
-        srcParent = testRootNode.addNode(nodeName2, testNodeType);
-
-        destPath = destParent.getPath() + "/" + nodeName3;
-        testRootNode.save();
-    }
-
-    protected void tearDown() throws Exception {
-        destParent = null;
-        srcParent = null;
-        super.tearDown();
-    }
-
-   private Node[] createOrderableChildren(boolean sns) throws RepositoryException {
-        String[] childNames;
-        if (sns) {
-            childNames = new String[] {nodeName2, nodeName2, nodeName2, nodeName2};
-        } else {
-            childNames = new String[] {nodeName1, nodeName2, nodeName3, nodeName4};
-        }
-        Node[] children = new Node[4];
-        children[0] = srcParent.addNode(childNames[0], testNodeType);
-        children[1] = srcParent.addNode(childNames[1], testNodeType);
-        children[2] = srcParent.addNode(childNames[2], testNodeType);
-        children[3] = srcParent.addNode(childNames[3], testNodeType);
-
-        testRootNode.save();
-        return children;
-   }
-
-    private static String getRelPath(Node child) throws RepositoryException {
-        if (child == null) {
-            return null;
-        }
-        String path = child.getPath();
-        return path.substring(path.lastIndexOf('/')+1);
-    }
-
-    private static void testOrder(Node parent, Node[] children) throws RepositoryException {
-        NodeIterator it = parent.getNodes();
-        int i = 0;
-        while (it.hasNext()) {
-            Node child = it.nextNode();
-            // TODO: check for sameNess must be replaced by 'isSame' for generic JCR impl
-            // assertTrue(child.isSame(children[i]));
-            assertSame(child, children[i]);
-            i++;
-        }
-    }
-
-    /**
-     * Move a orderable child node and reorder the remaining nodes.
-     */
-    public void testMoveAndReorder() throws RepositoryException {
-        Node[] children = createOrderableChildren(false);
-        String oldName = children[2].getName();
-        // move
-        testRootNode.getSession().move(children[2].getPath(), destPath);
-        // reorder
-        srcParent.orderBefore(getRelPath(children[1]), null);
-        testOrder(srcParent, new Node[] {children[0], children[3], children[1]});
-
-        testRootNode.save();
-        testOrder(srcParent, new Node[] {children[0], children[3], children[1]});
-        assertFalse(srcParent.hasNode(oldName));
-    }
-
-    /**
-     * Move a orderable SNS-node and reorder the remaining nodes at source-parent.
-     */
-    public void testMoveAndReorderSNS() throws RepositoryException {
-        Node[] children = createOrderableChildren(true);
-        String snsName = children[0].getName();
-
-        // move
-        testRootNode.getSession().move(children[2].getPath(), destPath);
-        testRootNode.getSession().move(children[1].getPath(), destPath);
-
-        // reorder
-        srcParent.orderBefore(getRelPath(children[0]), null);
-        testOrder(srcParent, new Node[] {children[3], children[0]});
-        assertTrue(srcParent.hasNode(snsName+"[1]"));
-        assertTrue(srcParent.hasNode(snsName+"[2]"));
-        assertFalse(srcParent.hasNode(snsName+"[3]"));
-        assertFalse(srcParent.hasNode(snsName+"[4]"));
-        assertFalse(srcParent.hasNode(snsName+"[5]"));
-
-        testRootNode.save();
-        testOrder(srcParent, new Node[] {children[3], children[0]});
-        assertTrue(srcParent.hasNode(snsName+"[1]"));
-        assertTrue(srcParent.hasNode(snsName+"[2]"));
-        assertFalse(srcParent.hasNode(snsName+"[3]"));
-        assertFalse(srcParent.hasNode(snsName+"[4]"));
-        assertFalse(srcParent.hasNode(snsName+"[5]"));
-
-        // check if move have been successful
-        assertEquals(children[2].getPath(), destPath);
-        assertTrue(children[2].getIndex() == Path.INDEX_DEFAULT);
-        assertEquals(children[1].getPath(), destPath+"[2]");
-    }
-
-    /**
-     * Reorder nodes and move one of the reordered siblings
-     * away. Test the ordering of the remaining siblings.
-     */
-    public void testReorderAndMove() throws RepositoryException {
-        Node[] children = createOrderableChildren(false);
-
-        // reorder first
-        srcParent.orderBefore(getRelPath(children[0]), null);
-        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[1]));
-        // move
-        testRootNode.getSession().move(children[3].getPath(), destPath);
-
-        testOrder(srcParent, new Node[] {children[1], children[2], children[0]});
-
-        testRootNode.save();
-        testOrder(srcParent, new Node[] {children[1], children[2], children[0]});
-    }
-
-    /**
-     * Reorder same-name-sibling nodes and move one of the reordered siblings
-     * away. Test the ordering of the remaining siblings.
-     */
-    public void testReorderAndMoveSNS() throws RepositoryException {
-        Node[] children = createOrderableChildren(true);
-
-        // reorder first
-        srcParent.orderBefore(getRelPath(children[0]), null);
-        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[1]));
-        // move
-        testRootNode.getSession().move(children[3].getPath(), destPath);
-
-        testOrder(srcParent, new Node[] {children[1], children[2], children[0]});
-
-        testRootNode.save();
-        testOrder(srcParent, new Node[] {children[1], children[2], children[0]});
-    }
-
-    /**
-     * Any attempt reorder a moved node at its original position must fail.
-     */
-    public void testReorderMovedNode() throws RepositoryException {
-        Node[] children = createOrderableChildren(false);
-
-        String relPath = getRelPath(children[2]);
-        testRootNode.getSession().move(children[2].getPath(), destPath);
-
-        try {
-            srcParent.orderBefore(relPath, null);
-            fail("Reordering a child node that has been moved away must fail.");
-        } catch (ItemNotFoundException e) {
-            // ok
-        }
-    }
-
-    /**
-     * Move a SNS-node and reorder its original siblings afterwards.
-     * Test if reverting the changes results in the original ordering and
-     * hierarchy.
-     */
-    public void testRevertMoveAndReorderSNS() throws RepositoryException {
-        Node[] children = createOrderableChildren(true);
-        // move then reorder
-        testRootNode.getSession().move(children[2].getPath(), destPath);
-        srcParent.orderBefore(getRelPath(children[1]), null);
-        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[0]));
-
-        testRootNode.refresh(false);
-        testOrder(srcParent, new Node[] {children[0], children[1], children[2], children[3]});
-        assertFalse(destParent.hasNode(Text.getName(destPath)));
-    }
-
-    /**
-     * Move a SNS-node, that got its siblings reordered before.
-     * Test if reverting the changes results in the original ordering and
-     * hierarchy.
-     */
-    public void testRevertReorderAndMoveSNS() throws RepositoryException {
-        Node[] children = createOrderableChildren(true);
-        // reorder then move
-        srcParent.orderBefore(getRelPath(children[1]), null);
-        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[2]));
-        srcParent.getSession().move(children[2].getPath(), destPath);
-
-        testRootNode.refresh(false);
-        testOrder(srcParent, new Node[] {children[0], children[1], children[2], children[3]});
-        assertFalse(destParent.hasNode(Text.getName(destPath)));
-    }
-
-    /**
-     * Move a SNS-node, that has been reordered before.
-     * Test if reverting the changes results in the original ordering and
-     * hierarchy.
-     */
-    public void testRevertMoveReorderedSNS() throws RepositoryException {
-        Node[] children = createOrderableChildren(true);
-        // reorder then move
-        srcParent.orderBefore(getRelPath(children[1]), null);
-        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[2]));
-        srcParent.getSession().move(children[1].getPath(), destPath);
-
-        testRootNode.refresh(false);
-        testOrder(srcParent, new Node[] {children[0], children[1], children[2], children[3]});
-        assertFalse(destParent.hasNode(Text.getName(destPath)));
-    }
-}
+/*
+ * 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.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.util.Text;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>ReorderMoveTest</code> testing various combinations of move/rename
+ * and reorder with and without intermediate save, revert and other transient
+ * modifications.
+ */
+public class ReorderMoveTest extends AbstractJCRTest {
+
+    private static Logger log = LoggerFactory.getLogger(ReorderMoveTest.class);
+
+    private Node destParent;
+    private Node srcParent;
+    private String destPath;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (!testRootNode.getPrimaryNodeType().hasOrderableChildNodes()) {
+            throw new NotExecutableException("Test node does not have orderable children.");
+        }
+
+        // create move-destination
+        destParent = testRootNode.addNode(nodeName4, testNodeType);
+        srcParent = testRootNode.addNode(nodeName2, testNodeType);
+
+        destPath = destParent.getPath() + "/" + nodeName3;
+        testRootNode.save();
+    }
+
+    protected void tearDown() throws Exception {
+        destParent = null;
+        srcParent = null;
+        super.tearDown();
+    }
+
+   private Node[] createOrderableChildren(boolean sns) throws RepositoryException {
+        String[] childNames;
+        if (sns) {
+            childNames = new String[] {nodeName2, nodeName2, nodeName2, nodeName2};
+        } else {
+            childNames = new String[] {nodeName1, nodeName2, nodeName3, nodeName4};
+        }
+        Node[] children = new Node[4];
+        children[0] = srcParent.addNode(childNames[0], testNodeType);
+        children[1] = srcParent.addNode(childNames[1], testNodeType);
+        children[2] = srcParent.addNode(childNames[2], testNodeType);
+        children[3] = srcParent.addNode(childNames[3], testNodeType);
+
+        testRootNode.save();
+        return children;
+   }
+
+    private static String getRelPath(Node child) throws RepositoryException {
+        if (child == null) {
+            return null;
+        }
+        String path = child.getPath();
+        return path.substring(path.lastIndexOf('/')+1);
+    }
+
+    private static void testOrder(Node parent, Node[] children) throws RepositoryException {
+        NodeIterator it = parent.getNodes();
+        int i = 0;
+        while (it.hasNext()) {
+            Node child = it.nextNode();
+            // TODO: check for sameNess must be replaced by 'isSame' for generic JCR impl
+            // assertTrue(child.isSame(children[i]));
+            assertSame(child, children[i]);
+            i++;
+        }
+    }
+
+    /**
+     * Move a orderable child node and reorder the remaining nodes.
+     */
+    public void testMoveAndReorder() throws RepositoryException {
+        Node[] children = createOrderableChildren(false);
+        String oldName = children[2].getName();
+        // move
+        testRootNode.getSession().move(children[2].getPath(), destPath);
+        // reorder
+        srcParent.orderBefore(getRelPath(children[1]), null);
+        testOrder(srcParent, new Node[] {children[0], children[3], children[1]});
+
+        testRootNode.save();
+        testOrder(srcParent, new Node[] {children[0], children[3], children[1]});
+        assertFalse(srcParent.hasNode(oldName));
+    }
+
+    /**
+     * Move a orderable SNS-node and reorder the remaining nodes at source-parent.
+     */
+    public void testMoveAndReorderSNS() throws RepositoryException {
+        Node[] children = createOrderableChildren(true);
+        String snsName = children[0].getName();
+
+        // move
+        testRootNode.getSession().move(children[2].getPath(), destPath);
+        testRootNode.getSession().move(children[1].getPath(), destPath);
+
+        // reorder
+        srcParent.orderBefore(getRelPath(children[0]), null);
+        testOrder(srcParent, new Node[] {children[3], children[0]});
+        assertTrue(srcParent.hasNode(snsName+"[1]"));
+        assertTrue(srcParent.hasNode(snsName+"[2]"));
+        assertFalse(srcParent.hasNode(snsName+"[3]"));
+        assertFalse(srcParent.hasNode(snsName+"[4]"));
+        assertFalse(srcParent.hasNode(snsName+"[5]"));
+
+        testRootNode.save();
+        testOrder(srcParent, new Node[] {children[3], children[0]});
+        assertTrue(srcParent.hasNode(snsName+"[1]"));
+        assertTrue(srcParent.hasNode(snsName+"[2]"));
+        assertFalse(srcParent.hasNode(snsName+"[3]"));
+        assertFalse(srcParent.hasNode(snsName+"[4]"));
+        assertFalse(srcParent.hasNode(snsName+"[5]"));
+
+        // check if move have been successful
+        assertEquals(children[2].getPath(), destPath);
+        assertTrue(children[2].getIndex() == Path.INDEX_DEFAULT);
+        assertEquals(children[1].getPath(), destPath+"[2]");
+    }
+
+    /**
+     * Reorder nodes and move one of the reordered siblings
+     * away. Test the ordering of the remaining siblings.
+     */
+    public void testReorderAndMove() throws RepositoryException {
+        Node[] children = createOrderableChildren(false);
+
+        // reorder first
+        srcParent.orderBefore(getRelPath(children[0]), null);
+        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[1]));
+        // move
+        testRootNode.getSession().move(children[3].getPath(), destPath);
+
+        testOrder(srcParent, new Node[] {children[1], children[2], children[0]});
+
+        testRootNode.save();
+        testOrder(srcParent, new Node[] {children[1], children[2], children[0]});
+    }
+
+    /**
+     * Reorder same-name-sibling nodes and move one of the reordered siblings
+     * away. Test the ordering of the remaining siblings.
+     */
+    public void testReorderAndMoveSNS() throws RepositoryException {
+        Node[] children = createOrderableChildren(true);
+
+        // reorder first
+        srcParent.orderBefore(getRelPath(children[0]), null);
+        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[1]));
+        // move
+        testRootNode.getSession().move(children[3].getPath(), destPath);
+
+        testOrder(srcParent, new Node[] {children[1], children[2], children[0]});
+
+        testRootNode.save();
+        testOrder(srcParent, new Node[] {children[1], children[2], children[0]});
+    }
+
+    /**
+     * Any attempt reorder a moved node at its original position must fail.
+     */
+    public void testReorderMovedNode() throws RepositoryException {
+        Node[] children = createOrderableChildren(false);
+
+        String relPath = getRelPath(children[2]);
+        testRootNode.getSession().move(children[2].getPath(), destPath);
+
+        try {
+            srcParent.orderBefore(relPath, null);
+            fail("Reordering a child node that has been moved away must fail.");
+        } catch (ItemNotFoundException e) {
+            // ok
+        }
+    }
+
+    /**
+     * Move a SNS-node and reorder its original siblings afterwards.
+     * Test if reverting the changes results in the original ordering and
+     * hierarchy.
+     */
+    public void testRevertMoveAndReorderSNS() throws RepositoryException {
+        Node[] children = createOrderableChildren(true);
+        // move then reorder
+        testRootNode.getSession().move(children[2].getPath(), destPath);
+        srcParent.orderBefore(getRelPath(children[1]), null);
+        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[0]));
+
+        testRootNode.refresh(false);
+        testOrder(srcParent, new Node[] {children[0], children[1], children[2], children[3]});
+        assertFalse(destParent.hasNode(Text.getName(destPath)));
+    }
+
+    /**
+     * Move a SNS-node, that got its siblings reordered before.
+     * Test if reverting the changes results in the original ordering and
+     * hierarchy.
+     */
+    public void testRevertReorderAndMoveSNS() throws RepositoryException {
+        Node[] children = createOrderableChildren(true);
+        // reorder then move
+        srcParent.orderBefore(getRelPath(children[1]), null);
+        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[2]));
+        srcParent.getSession().move(children[2].getPath(), destPath);
+
+        testRootNode.refresh(false);
+        testOrder(srcParent, new Node[] {children[0], children[1], children[2], children[3]});
+        assertFalse(destParent.hasNode(Text.getName(destPath)));
+    }
+
+    /**
+     * Move a SNS-node, that has been reordered before.
+     * Test if reverting the changes results in the original ordering and
+     * hierarchy.
+     */
+    public void testRevertMoveReorderedSNS() throws RepositoryException {
+        Node[] children = createOrderableChildren(true);
+        // reorder then move
+        srcParent.orderBefore(getRelPath(children[1]), null);
+        srcParent.orderBefore(getRelPath(children[3]), getRelPath(children[2]));
+        srcParent.getSession().move(children[1].getPath(), destPath);
+
+        testRootNode.refresh(false);
+        testOrder(srcParent, new Node[] {children[0], children[1], children[2], children[3]});
+        assertFalse(destParent.hasNode(Text.getName(destPath)));
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderMoveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewAndSavedTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewAndSavedTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewAndSavedTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewAndSavedTest.java Thu May 21 12:12:11 2015
@@ -1,61 +1,61 @@
-/*
- * 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 javax.jcr.RepositoryException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.Node;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.lock.LockException;
-
-/**
- * <code>ReorderNewAndSavedTest</code>...
- */
-public class ReorderNewAndSavedTest extends ReorderTest {
-
-    private static Logger log = LoggerFactory.getLogger(ReorderNewAndSavedTest.class);
-
-    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
-        child1 = testRootNode.addNode(nodeName1, testNodeType);
-        child2 = testRootNode.addNode(nodeName2, testNodeType);
-        testRootNode.save();
-
-        child3 = testRootNode.addNode(nodeName3, testNodeType);
-        child4 = testRootNode.addNode(nodeName4, testNodeType);
-    }
-
-    public void testRevertReorder() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child4), getRelPath(child2));
-        testOrder(testRootNode, new Node[] { child1, child4, child2, child3});
-
-        testRootNode.refresh(false);
-        testOrder(testRootNode, new Node[] { child1, child2 });
-    }
-
-    public void testRevertReorderToEnd() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child1), null);
-        testOrder(testRootNode, new Node[] { child2, child3, child4, child1});
-
-        testRootNode.refresh(false);
-        testOrder(testRootNode, new Node[] { child1, child2 });
-    }
-}
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.Node;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.lock.LockException;
+
+/**
+ * <code>ReorderNewAndSavedTest</code>...
+ */
+public class ReorderNewAndSavedTest extends ReorderTest {
+
+    private static Logger log = LoggerFactory.getLogger(ReorderNewAndSavedTest.class);
+
+    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
+        child1 = testRootNode.addNode(nodeName1, testNodeType);
+        child2 = testRootNode.addNode(nodeName2, testNodeType);
+        testRootNode.save();
+
+        child3 = testRootNode.addNode(nodeName3, testNodeType);
+        child4 = testRootNode.addNode(nodeName4, testNodeType);
+    }
+
+    public void testRevertReorder() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child4), getRelPath(child2));
+        testOrder(testRootNode, new Node[] { child1, child4, child2, child3});
+
+        testRootNode.refresh(false);
+        testOrder(testRootNode, new Node[] { child1, child2 });
+    }
+
+    public void testRevertReorderToEnd() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child1), null);
+        testOrder(testRootNode, new Node[] { child2, child3, child4, child1});
+
+        testRootNode.refresh(false);
+        testOrder(testRootNode, new Node[] { child1, child2 });
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewAndSavedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewSNSTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewSNSTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewSNSTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewSNSTest.java Thu May 21 12:12:11 2015
@@ -1,68 +1,68 @@
-/*
- * 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 javax.jcr.RepositoryException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.lock.LockException;
-
-/**
- * <code>ReorderNewSNSTest</code>...
- */
-public class ReorderNewSNSTest extends ReorderTest {
-
-    private static Logger log = LoggerFactory.getLogger(ReorderNewSNSTest.class);
-
-    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
-        child1 = testRootNode.addNode(nodeName2, testNodeType);
-        child2 = testRootNode.addNode(nodeName2, testNodeType);
-        child3 = testRootNode.addNode(nodeName2, testNodeType);
-        child4 = testRootNode.addNode(nodeName2, testNodeType);
-    }
-
-    public void testRevertReorder() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child4), getRelPath(child2));
-        testOrder(testRootNode, new Node[] { child1, child4, child2, child3});
-
-        // NEW child nodes -> must be removed upon refresh
-        testRootNode.refresh(false);
-        NodeIterator it = testRootNode.getNodes(nodeName2);
-        if (it.hasNext()) {
-            fail("Reverting creation and reordering of new SNSs must remove the children again.");
-        }
-    }
-
-    public void testRevertReorderToEnd() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child1), null);
-        testOrder(testRootNode, new Node[] { child2, child3, child4, child1});
-
-        // NEW child nodes -> must be removed upon refresh
-        testRootNode.refresh(false);
-        NodeIterator it = testRootNode.getNodes(nodeName2);
-        if (it.hasNext()) {
-            fail("Reverting creation and reordering of new SNSs must remove the children again.");
-        }
-    }
-}
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.lock.LockException;
+
+/**
+ * <code>ReorderNewSNSTest</code>...
+ */
+public class ReorderNewSNSTest extends ReorderTest {
+
+    private static Logger log = LoggerFactory.getLogger(ReorderNewSNSTest.class);
+
+    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
+        child1 = testRootNode.addNode(nodeName2, testNodeType);
+        child2 = testRootNode.addNode(nodeName2, testNodeType);
+        child3 = testRootNode.addNode(nodeName2, testNodeType);
+        child4 = testRootNode.addNode(nodeName2, testNodeType);
+    }
+
+    public void testRevertReorder() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child4), getRelPath(child2));
+        testOrder(testRootNode, new Node[] { child1, child4, child2, child3});
+
+        // NEW child nodes -> must be removed upon refresh
+        testRootNode.refresh(false);
+        NodeIterator it = testRootNode.getNodes(nodeName2);
+        if (it.hasNext()) {
+            fail("Reverting creation and reordering of new SNSs must remove the children again.");
+        }
+    }
+
+    public void testRevertReorderToEnd() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child1), null);
+        testOrder(testRootNode, new Node[] { child2, child3, child4, child1});
+
+        // NEW child nodes -> must be removed upon refresh
+        testRootNode.refresh(false);
+        NodeIterator it = testRootNode.getNodes(nodeName2);
+        if (it.hasNext()) {
+            fail("Reverting creation and reordering of new SNSs must remove the children again.");
+        }
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewSNSTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewTest.java Thu May 21 12:12:11 2015
@@ -1,68 +1,68 @@
-/*
- * 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 javax.jcr.RepositoryException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.lock.LockException;
-
-/**
- * <code>ReorderNewTest</code>...
- */
-public class ReorderNewTest extends ReorderTest {
-
-    private static Logger log = LoggerFactory.getLogger(ReorderNewTest.class);
-
-    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
-        child1 = testRootNode.addNode(nodeName1, testNodeType);
-        child2 = testRootNode.addNode(nodeName2, testNodeType);
-        child3 = testRootNode.addNode(nodeName3, testNodeType);
-        child4 = testRootNode.addNode(nodeName4, testNodeType);
-    }
-
-    public void testRevertReorder() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child4), getRelPath(child2));
-        testOrder(testRootNode, new Node[] { child1, child4, child2, child3});
-
-        // NEW child nodes -> must be removed upon refresh
-        testRootNode.refresh(false);
-        NodeIterator it = testRootNode.getNodes();
-        if (it.hasNext()) {
-            fail("Reverting creation and reordering of new children must remove the children again.");
-        }
-    }
-
-    public void testRevertReorderToEnd() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child1), null);
-        testOrder(testRootNode, new Node[] { child2, child3, child4, child1});
-
-        // NEW child nodes -> must be removed upon refresh
-        testRootNode.refresh(false);
-        NodeIterator it = testRootNode.getNodes();
-        if (it.hasNext()) {
-            fail("Reverting creation and reordering of new children must remove the children again.");
-        }
-    }
-}
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.lock.LockException;
+
+/**
+ * <code>ReorderNewTest</code>...
+ */
+public class ReorderNewTest extends ReorderTest {
+
+    private static Logger log = LoggerFactory.getLogger(ReorderNewTest.class);
+
+    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
+        child1 = testRootNode.addNode(nodeName1, testNodeType);
+        child2 = testRootNode.addNode(nodeName2, testNodeType);
+        child3 = testRootNode.addNode(nodeName3, testNodeType);
+        child4 = testRootNode.addNode(nodeName4, testNodeType);
+    }
+
+    public void testRevertReorder() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child4), getRelPath(child2));
+        testOrder(testRootNode, new Node[] { child1, child4, child2, child3});
+
+        // NEW child nodes -> must be removed upon refresh
+        testRootNode.refresh(false);
+        NodeIterator it = testRootNode.getNodes();
+        if (it.hasNext()) {
+            fail("Reverting creation and reordering of new children must remove the children again.");
+        }
+    }
+
+    public void testRevertReorderToEnd() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child1), null);
+        testOrder(testRootNode, new Node[] { child2, child3, child4, child1});
+
+        // NEW child nodes -> must be removed upon refresh
+        testRootNode.refresh(false);
+        NodeIterator it = testRootNode.getNodes();
+        if (it.hasNext()) {
+            fail("Reverting creation and reordering of new children must remove the children again.");
+        }
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderNewTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderReferenceableSNSTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderReferenceableSNSTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderReferenceableSNSTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderReferenceableSNSTest.java Thu May 21 12:12:11 2015
@@ -1,48 +1,48 @@
-/*
- * 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.NotExecutableException;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Node;
-
-/**
- * <code>ReorderSNSTest</code>...
- */
-public class ReorderReferenceableSNSTest extends ReorderTest {
-
-    private static Logger log = LoggerFactory.getLogger(ReorderReferenceableSNSTest.class);
-
-    protected void createOrderableChildren() throws RepositoryException, NotExecutableException {
-        child1 = testRootNode.addNode(nodeName2, testNodeType);
-        child2 = testRootNode.addNode(nodeName2, testNodeType);
-        child3 = testRootNode.addNode(nodeName2, testNodeType);
-        child4 = testRootNode.addNode(nodeName2, testNodeType);
-        Node[] children = new Node[] { child1, child2, child3, child4};
-        for (int i = 0; i < children.length; i++) {
-            if (children[i].canAddMixin(mixReferenceable)) {
-                children[i].addMixin(mixReferenceable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
-        testRootNode.save();
-    }
-}
+/*
+ * 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.NotExecutableException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+
+/**
+ * <code>ReorderSNSTest</code>...
+ */
+public class ReorderReferenceableSNSTest extends ReorderTest {
+
+    private static Logger log = LoggerFactory.getLogger(ReorderReferenceableSNSTest.class);
+
+    protected void createOrderableChildren() throws RepositoryException, NotExecutableException {
+        child1 = testRootNode.addNode(nodeName2, testNodeType);
+        child2 = testRootNode.addNode(nodeName2, testNodeType);
+        child3 = testRootNode.addNode(nodeName2, testNodeType);
+        child4 = testRootNode.addNode(nodeName2, testNodeType);
+        Node[] children = new Node[] { child1, child2, child3, child4};
+        for (int i = 0; i < children.length; i++) {
+            if (children[i].canAddMixin(mixReferenceable)) {
+                children[i].addMixin(mixReferenceable);
+            } else {
+                throw new NotExecutableException();
+            }
+        }
+        testRootNode.save();
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderReferenceableSNSTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderSNSTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderSNSTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderSNSTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderSNSTest.java Thu May 21 12:12:11 2015
@@ -1,72 +1,72 @@
-/*
- * 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 javax.jcr.RepositoryException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.Item;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.lock.LockException;
-
-/**
- * <code>ReorderSNSTest</code>...
- */
-public class ReorderSNSTest extends ReorderTest {
-
-    private static Logger log = LoggerFactory.getLogger(ReorderSNSTest.class);
-
-    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
-        child1 = testRootNode.addNode(nodeName2, testNodeType);
-        child2 = testRootNode.addNode(nodeName2, testNodeType);
-        child3 = testRootNode.addNode(nodeName2, testNodeType);
-        child4 = testRootNode.addNode(nodeName2, testNodeType);
-
-        testRootNode.save();
-    }
-
-    public void testIndexAfterReorder() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child1), getRelPath(child3));
-        assertTrue(child1.getIndex() == 2);
-        assertTrue(child2.getIndex() == 1);
-        assertTrue(child3.getIndex() == 3);
-        assertTrue(child4.getIndex() == 4);
-
-        testRootNode.save();
-        assertTrue(child1.getIndex() == 2);
-        assertTrue(child2.getIndex() == 1);
-        assertTrue(child3.getIndex() == 3);
-        assertTrue(child4.getIndex() == 4);
-    }
-
-    public void testReorder3() throws RepositoryException {
-        String pathBefore = child3.getPath();
-
-        testRootNode.orderBefore(getRelPath(child3), getRelPath(child1));
-        testRootNode.save();
-
-        Item itemIndex3 = testRootNode.getSession().getItem(pathBefore);
-        assertTrue(itemIndex3.isSame(child2));
-
-        Item item3 = testRootNode.getSession().getItem(child3.getPath());
-        assertTrue(item3.isSame(child3));
-    }
-}
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.Item;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.lock.LockException;
+
+/**
+ * <code>ReorderSNSTest</code>...
+ */
+public class ReorderSNSTest extends ReorderTest {
+
+    private static Logger log = LoggerFactory.getLogger(ReorderSNSTest.class);
+
+    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException {
+        child1 = testRootNode.addNode(nodeName2, testNodeType);
+        child2 = testRootNode.addNode(nodeName2, testNodeType);
+        child3 = testRootNode.addNode(nodeName2, testNodeType);
+        child4 = testRootNode.addNode(nodeName2, testNodeType);
+
+        testRootNode.save();
+    }
+
+    public void testIndexAfterReorder() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child1), getRelPath(child3));
+        assertTrue(child1.getIndex() == 2);
+        assertTrue(child2.getIndex() == 1);
+        assertTrue(child3.getIndex() == 3);
+        assertTrue(child4.getIndex() == 4);
+
+        testRootNode.save();
+        assertTrue(child1.getIndex() == 2);
+        assertTrue(child2.getIndex() == 1);
+        assertTrue(child3.getIndex() == 3);
+        assertTrue(child4.getIndex() == 4);
+    }
+
+    public void testReorder3() throws RepositoryException {
+        String pathBefore = child3.getPath();
+
+        testRootNode.orderBefore(getRelPath(child3), getRelPath(child1));
+        testRootNode.save();
+
+        Item itemIndex3 = testRootNode.getSession().getItem(pathBefore);
+        assertTrue(itemIndex3.isSame(child2));
+
+        Item item3 = testRootNode.getSession().getItem(child3.getPath());
+        assertTrue(item3.isSame(child3));
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderSNSTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderTest.java Thu May 21 12:12:11 2015
@@ -1,164 +1,164 @@
-/*
- * 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.RepositoryException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.Session;
-import javax.jcr.ItemExistsException;
-import javax.jcr.lock.LockException;
-import javax.jcr.version.VersionException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-
-/**
- * <code>ReorderTest</code>...
- */
-public class ReorderTest extends AbstractJCRTest {
-
-    private static Logger log = LoggerFactory.getLogger(ReorderTest.class);
-
-    protected Node child1;
-    protected Node child2;
-    protected Node child3;
-    protected Node child4;
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        if (!testRootNode.getPrimaryNodeType().hasOrderableChildNodes()) {
-            throw new NotExecutableException("Test node does not have orderable children.");
-        }
-        NodeIterator it = testRootNode.getNodes();
-        if (it.hasNext()) {
-            throw new NotExecutableException("Test node already contains child nodes");
-        }
-        createOrderableChildren();
-    }
-
-    protected void tearDown() throws Exception {
-        child1 = null;
-        child2 = null;
-        child3 = null;
-        child4 = null;
-        super.tearDown();
-    }
-
-    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException, NotExecutableException {
-        child1 = testRootNode.addNode(nodeName1, testNodeType);
-        child2 = testRootNode.addNode(nodeName2, testNodeType);
-        child3 = testRootNode.addNode(nodeName3, testNodeType);
-        child4 = testRootNode.addNode(nodeName4, testNodeType);
-
-        testRootNode.save();
-    }
-
-    protected static String getRelPath(Node child) throws RepositoryException {
-        if (child == null) {
-            return null;
-        }
-        String path = child.getPath();
-        return path.substring(path.lastIndexOf('/')+1);
-    }
-
-    protected static void testOrder(Node parent, Node[] children) throws RepositoryException {
-        NodeIterator it = parent.getNodes();
-        int i = 0;
-        while (it.hasNext()) {
-            Node child = it.nextNode();
-            if (i >= children.length) {
-                fail("Reorder added a child node.");
-            }
-            assertTrue("Wrong order of children: " + child + " is not the same as " + children[i], child.isSame(children[i]));
-            i++;
-        }
-
-        if (i < children.length-1) {
-            fail("Reorder removed a child node.");
-        }
-    }
-
-    public void testReorder() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child1), getRelPath(child3));
-        testOrder(testRootNode, new Node[] { child2, child1, child3, child4});
-
-        testRootNode.save();
-        testOrder(testRootNode, new Node[] { child2, child1, child3, child4});
-    }
-
-    public void testReorderToEnd() throws RepositoryException, ConstraintViolationException, UnsupportedRepositoryOperationException, VersionException {
-        testRootNode.orderBefore(getRelPath(child2), null);
-        testOrder(testRootNode, new Node[] { child1, child3, child4, child2});
-
-        testRootNode.save();
-        testOrder(testRootNode, new Node[] { child1, child3, child4, child2});
-    }
-
-    public void testRevertReorder() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child4), getRelPath(child2));
-        testOrder(testRootNode, new Node[] { child1, child4, child2, child3});
-
-        testRootNode.refresh(false);
-        testOrder(testRootNode, new Node[] { child1, child2, child3, child4});
-    }
-
-    public void testRevertReorderToEnd() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child1), null);
-        testOrder(testRootNode, new Node[] { child2, child3, child4, child1});
-
-        testRootNode.refresh(false);
-        testOrder(testRootNode, new Node[] { child1, child2, child3, child4});
-    }
-
-    public void testReorder2() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child3), getRelPath(child1));
-        testRootNode.save();
-
-        Session otherSession = getHelper().getReadOnlySession();
-        try {
-            testOrder((Node) otherSession.getItem(testRootNode.getPath()), new Node[] {child3, child1, child2, child4});
-        } finally {
-            otherSession.logout();
-        }
-    }
-
-    public void testReorderTwice() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child2), null);
-        testRootNode.orderBefore(getRelPath(child4), getRelPath(child1));
-
-        testOrder(testRootNode, new Node[] { child4, child1, child3, child2});
-        testRootNode.save();
-        testOrder(testRootNode, new Node[] { child4, child1, child3, child2});
-    }
-
-    public void testReorderFinallyOriginalOrder() throws RepositoryException {
-        testRootNode.orderBefore(getRelPath(child4), getRelPath(child1));
-        testRootNode.orderBefore(getRelPath(child3), getRelPath(child4));
-        testRootNode.orderBefore(getRelPath(child2), getRelPath(child3));
-        testRootNode.orderBefore(getRelPath(child1), getRelPath(child2));
-
-        testOrder(testRootNode, new Node[] { child1, child2, child3, child4});
-        testRootNode.save();
-        testOrder(testRootNode, new Node[] { child1, child2, child3, child4});
-    }
-}
+/*
+ * 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.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Session;
+import javax.jcr.ItemExistsException;
+import javax.jcr.lock.LockException;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+
+/**
+ * <code>ReorderTest</code>...
+ */
+public class ReorderTest extends AbstractJCRTest {
+
+    private static Logger log = LoggerFactory.getLogger(ReorderTest.class);
+
+    protected Node child1;
+    protected Node child2;
+    protected Node child3;
+    protected Node child4;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (!testRootNode.getPrimaryNodeType().hasOrderableChildNodes()) {
+            throw new NotExecutableException("Test node does not have orderable children.");
+        }
+        NodeIterator it = testRootNode.getNodes();
+        if (it.hasNext()) {
+            throw new NotExecutableException("Test node already contains child nodes");
+        }
+        createOrderableChildren();
+    }
+
+    protected void tearDown() throws Exception {
+        child1 = null;
+        child2 = null;
+        child3 = null;
+        child4 = null;
+        super.tearDown();
+    }
+
+    protected void createOrderableChildren() throws RepositoryException, LockException, ConstraintViolationException, NoSuchNodeTypeException, ItemExistsException, VersionException, NotExecutableException {
+        child1 = testRootNode.addNode(nodeName1, testNodeType);
+        child2 = testRootNode.addNode(nodeName2, testNodeType);
+        child3 = testRootNode.addNode(nodeName3, testNodeType);
+        child4 = testRootNode.addNode(nodeName4, testNodeType);
+
+        testRootNode.save();
+    }
+
+    protected static String getRelPath(Node child) throws RepositoryException {
+        if (child == null) {
+            return null;
+        }
+        String path = child.getPath();
+        return path.substring(path.lastIndexOf('/')+1);
+    }
+
+    protected static void testOrder(Node parent, Node[] children) throws RepositoryException {
+        NodeIterator it = parent.getNodes();
+        int i = 0;
+        while (it.hasNext()) {
+            Node child = it.nextNode();
+            if (i >= children.length) {
+                fail("Reorder added a child node.");
+            }
+            assertTrue("Wrong order of children: " + child + " is not the same as " + children[i], child.isSame(children[i]));
+            i++;
+        }
+
+        if (i < children.length-1) {
+            fail("Reorder removed a child node.");
+        }
+    }
+
+    public void testReorder() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child1), getRelPath(child3));
+        testOrder(testRootNode, new Node[] { child2, child1, child3, child4});
+
+        testRootNode.save();
+        testOrder(testRootNode, new Node[] { child2, child1, child3, child4});
+    }
+
+    public void testReorderToEnd() throws RepositoryException, ConstraintViolationException, UnsupportedRepositoryOperationException, VersionException {
+        testRootNode.orderBefore(getRelPath(child2), null);
+        testOrder(testRootNode, new Node[] { child1, child3, child4, child2});
+
+        testRootNode.save();
+        testOrder(testRootNode, new Node[] { child1, child3, child4, child2});
+    }
+
+    public void testRevertReorder() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child4), getRelPath(child2));
+        testOrder(testRootNode, new Node[] { child1, child4, child2, child3});
+
+        testRootNode.refresh(false);
+        testOrder(testRootNode, new Node[] { child1, child2, child3, child4});
+    }
+
+    public void testRevertReorderToEnd() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child1), null);
+        testOrder(testRootNode, new Node[] { child2, child3, child4, child1});
+
+        testRootNode.refresh(false);
+        testOrder(testRootNode, new Node[] { child1, child2, child3, child4});
+    }
+
+    public void testReorder2() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child3), getRelPath(child1));
+        testRootNode.save();
+
+        Session otherSession = getHelper().getReadOnlySession();
+        try {
+            testOrder((Node) otherSession.getItem(testRootNode.getPath()), new Node[] {child3, child1, child2, child4});
+        } finally {
+            otherSession.logout();
+        }
+    }
+
+    public void testReorderTwice() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child2), null);
+        testRootNode.orderBefore(getRelPath(child4), getRelPath(child1));
+
+        testOrder(testRootNode, new Node[] { child4, child1, child3, child2});
+        testRootNode.save();
+        testOrder(testRootNode, new Node[] { child4, child1, child3, child2});
+    }
+
+    public void testReorderFinallyOriginalOrder() throws RepositoryException {
+        testRootNode.orderBefore(getRelPath(child4), getRelPath(child1));
+        testRootNode.orderBefore(getRelPath(child3), getRelPath(child4));
+        testRootNode.orderBefore(getRelPath(child2), getRelPath(child3));
+        testRootNode.orderBefore(getRelPath(child1), getRelPath(child2));
+
+        testOrder(testRootNode, new Node[] { child1, child2, child3, child4});
+        testRootNode.save();
+        testOrder(testRootNode, new Node[] { child1, child2, child3, child4});
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/ReorderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java?rev=1680841&r1=1680840&r2=1680841&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java Thu May 21 12:12:11 2015
@@ -1,76 +1,76 @@
-/*
- * 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.version;
-
-import org.apache.jackrabbit.test.api.version.VersionLabelTest;
-
-import java.util.Arrays;
-import java.util.List;
-import javax.jcr.RepositoryException;
-import javax.jcr.version.Version;
-
-public class LabelTest extends VersionLabelTest {
-
-    public void testRemovedLabel2() throws RepositoryException {
-        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
-        vHistory.removeVersionLabel(versionLabel);
-
-        List labels = Arrays.asList(vHistory.getVersionLabels());
-        assertFalse("VersionHistory.getVersionLabels() must not return a removed label.",labels.contains(versionLabel));
-    }
-
-    public void testRemovedLabel3() throws RepositoryException {
-        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
-        vHistory.removeVersionLabel(versionLabel);
-
-        List labels = Arrays.asList(vHistory.getVersionLabels(rootVersion));
-        assertFalse("VersionHistory.getVersionLabels(Version) must not return a removed label.",labels.contains(versionLabel));
-    }
-
-    public void testMoveLabel2() throws RepositoryException {
-        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
-
-        versionableNode.checkout();
-        Version v = versionableNode.checkin();
-        vHistory.addVersionLabel(v.getName(), versionLabel, true);
-
-        List labels = Arrays.asList(vHistory.getVersionLabels(v));
-        assertTrue(labels.contains(versionLabel));
-    }
-
-    public void testMoveLabel3() throws RepositoryException {
-        versionableNode.checkout();
-        Version v = versionableNode.checkin();
-
-        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
-        vHistory.addVersionLabel(v.getName(), versionLabel, true);
-
-        List labels = Arrays.asList(vHistory.getVersionLabels(rootVersion));
-        assertFalse(labels.contains(versionLabel));
-    }
-
-    public void testMoveLabel4() throws RepositoryException {
-        versionableNode.checkout();
-        Version v = versionableNode.checkin();
-
-        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
-        vHistory.addVersionLabel(v.getName(), versionLabel, true);
-
-        Version v2 = vHistory.getVersionByLabel(versionLabel);
-        assertTrue(v2.isSame(v));
-    }
-}
+/*
+ * 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.version;
+
+import org.apache.jackrabbit.test.api.version.VersionLabelTest;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.jcr.RepositoryException;
+import javax.jcr.version.Version;
+
+public class LabelTest extends VersionLabelTest {
+
+    public void testRemovedLabel2() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.removeVersionLabel(versionLabel);
+
+        List labels = Arrays.asList(vHistory.getVersionLabels());
+        assertFalse("VersionHistory.getVersionLabels() must not return a removed label.",labels.contains(versionLabel));
+    }
+
+    public void testRemovedLabel3() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.removeVersionLabel(versionLabel);
+
+        List labels = Arrays.asList(vHistory.getVersionLabels(rootVersion));
+        assertFalse("VersionHistory.getVersionLabels(Version) must not return a removed label.",labels.contains(versionLabel));
+    }
+
+    public void testMoveLabel2() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+
+        versionableNode.checkout();
+        Version v = versionableNode.checkin();
+        vHistory.addVersionLabel(v.getName(), versionLabel, true);
+
+        List labels = Arrays.asList(vHistory.getVersionLabels(v));
+        assertTrue(labels.contains(versionLabel));
+    }
+
+    public void testMoveLabel3() throws RepositoryException {
+        versionableNode.checkout();
+        Version v = versionableNode.checkin();
+
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.addVersionLabel(v.getName(), versionLabel, true);
+
+        List labels = Arrays.asList(vHistory.getVersionLabels(rootVersion));
+        assertFalse(labels.contains(versionLabel));
+    }
+
+    public void testMoveLabel4() throws RepositoryException {
+        versionableNode.checkout();
+        Version v = versionableNode.checkin();
+
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.addVersionLabel(v.getName(), versionLabel, true);
+
+        Version v2 = vHistory.getVersionByLabel(versionLabel);
+        assertTrue(v2.isSame(v));
+    }
+}

Propchange: jackrabbit/branches/2.0/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.0/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/IdentifierResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.0/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/HashCache.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message