jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r157794 [2/2] - in incubator/jackrabbit/trunk: applications/test/ applications/test/repository/nodetypes/ src/test/org/apache/jackrabbit/test/api/
Date Wed, 16 Mar 2005 20:01:53 GMT
Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java?view=auto&rev=157794
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
Wed Mar 16 12:01:45 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.test.api;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>WorkspaceMoveReferenceableTest</code> contains tests for moving
+ * referenceable nodes in one workspace.
+ *
+ * @test
+ * @sources WorkspaceMoveReferenceableTest.java
+ * @executeClass org.apache.jackrabbit.test.api.WorkspaceMoveReferenceableTest
+ * @keywords level2
+ */
+public class WorkspaceMoveReferenceableTest extends AbstractWorkspaceReferenceableTest {
+
+    /**
+     * Copies of referenceable nodes (nodes with UUIDs) remains their original
+     * UUIDs.
+     */
+    public void testMoveNodesReferenceableNodesNewUUID() throws RepositoryException {
+        // add mixin referenceable to node1
+        addMixinReferenceableToNode(testRootNode, node1);
+        
+        // copy referenceable node below non-referenceable node
+        String dstAbsPath = node2.getPath() + "/" + node1.getName();
+        String originalUUID = node1.getUUID(); // remember for check
+        workspace.move(node1.getPath(), dstAbsPath);
+
+        // uuid of copied node should be different than original node uuid
+        Node movedNode = node2.getNode(node1.getName());
+        String movedUUID = movedNode.getUUID();
+
+        assertTrue(originalUUID.equals(movedUUID));
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java?view=auto&rev=157794
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java
Wed Mar 16 12:01:45 2005
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.test.api;
+
+import javax.jcr.ItemExistsException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>WorkspaceMoveSameNameSibsTest</code> contains tests for moving nodes
+ * with same name siblings supported in one workspace.
+ *
+ * @test
+ * @sources WorkspaceMoveSameNameSibsTest.java
+ * @executeClass org.apache.jackrabbit.test.api.WorkspaceMoveSameNameSibsTest
+ * @keywords level2
+ */
+public class WorkspaceMoveSameNameSibsTest extends AbstractWorkspaceSameNameSibsTest {
+
+    /**
+     * If ordering is supported by the node type of the parent node of the new
+     * location, then the newly moved node is appended to the end of the child
+     * node list.
+     */
+    public void testMoveNodesOrderingSupportedByParent() throws RepositoryException {
+        // test assumes that repositry supports Orderable Child Node Support (optional)
+        String[] orderList = {nodeName1, nodeName2, nodeName3};
+
+        // create a new node to move node three times
+        Node newNode = testRootNode.addNode(nodeName2, testNodeType);
+        testRootNode.save();
+
+        // copy node three times below a node and check the order
+        for (int i = 0; i < orderList.length; i++) {
+            workspace.copy(node1.getPath(), newNode.getPath() + "/" + orderList[i]);
+        }
+
+        // check regarding orderList with the counter if nodes are added at the end
+        int cnt = 0;
+        NodeIterator iter = node2.getNodes();
+        while (iter.hasNext()) {
+            Node n = (Node) iter.nextNode();
+
+            assertTrue(n.getName().equals(orderList[cnt]));
+            cnt++;
+        }
+    }
+
+    /**
+     * An ItemExistsException is thrown if a node or property already exists at
+     * destAbsPath.
+     * @tck.config sameNameSibsFalseNodeType name of a node type that does not
+     * allows same name siblings.
+     * @tck.config nodeName3 name of a child node that does not allow same name
+     * siblings..
+     */
+    public void testMoveNodesNodeExistsAtDestPath() throws RepositoryException {
+        // create a parent node where allowSameNameSiblings are set to false
+        Node snsfNode = testRootNode.addNode(nodeName3, sameNameSibsFalseNodeType.getName());
+        testRootNode.save();
+
+        String dstAbsPath = snsfNode.getPath() + "/" + node1.getName();
+        workspace.copy(node1.getPath(), dstAbsPath);
+
+        // try to copy again the node to same destAbsPath
+        // property already exist
+        try {
+            workspace.move(node1.getPath(), dstAbsPath);
+            fail("Node exists below '" + dstAbsPath + "'. Test should fail.");
+        } catch (ItemExistsException e) {
+            // successful
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveSameNameSibsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java?view=auto&rev=157794
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
Wed Mar 16 12:01:45 2005
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.test.api;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+/**
+ * <code>WorkspaceMoveTest</code> contains tests for copying nodes in one
+ * workspace.
+ *
+ * @test
+ * @sources WorkspaceMoveTest.java
+ * @executeClass org.apache.jackrabbit.test.api.WorkspaceMoveTest
+ * @keywords level2
+ */
+public class WorkspaceMoveTest extends AbstractWorkspaceCopyTest {
+
+    /**
+     * Operation is performed entirely within the persistent workspace, it does
+     * not involve transient storage and therefore does not require a save
+     */
+    public void testMoveNodes() throws RepositoryException {
+        String dstAbsPath = node2.getPath() + "/" + node1.getName();
+        workspace.move(node1.getPath(), dstAbsPath);
+
+        // there should not be any pending changes after copy
+        assertFalse(superuser.hasPendingChanges());
+    }
+
+    /**
+     * The destAbsPath provided must not have an index on its final element. If
+     * it does, then a RepositoryException is thrown. Strictly speaking, the
+     * destAbsPath parameter is actually an absolute path to the parent node of
+     * the new location, appended with the new name desired for the copied node.
+     * It does not specify a position within the child node ordering.
+     */
+    public void testMoveNodesAbsolutePath() {
+        try {
+            // copy referenceable node to an absolute path containing index
+            String dstAbsPath = node2.getPath() + "/" + node1.getName() + "[2]";
+            workspace.move(node1.getPath(), dstAbsPath);
+            fail("Moving a node to an absolute path containing index should not be possible.");
+        } catch (RepositoryException e) {
+            // successful
+
+        }
+    }
+
+    /**
+     * A ConstraintViolationException is thrown if the operation would violate a
+     * node-type or other implementation-specific constraint.
+     */
+    public void testMoveNodesConstraintViolationException() throws RepositoryException {
+        // if parent node is nt:base then no sub nodes can be created
+        Node subNodesNotAllowedNode = testRootNode.addNode(nodeName3, ntBase);
+        testRootNode.save();
+        try {
+            String dstAbsPath = subNodesNotAllowedNode.getPath() + "/" + node2.getName();
+            workspace.move(node2.getPath(), dstAbsPath);
+            fail("Moving a node below a node which can not have any sub nodes should throw
a ConstraintViolationException.");
+        } catch (ConstraintViolationException e) {
+            // successful
+        }
+    }
+
+
+    /**
+     * An AccessDeniedException is thrown if the current session (i.e., the
+     * session that was used to acquire this Workspace object) does not have
+     * sufficient access permissions to complete the operation.
+     */
+    public void testMoveNodesAccessDenied() throws RepositoryException {
+        // logout and get read only session
+        superuser.logout();
+        Session readOnlySuperuser = helper.getReadOnlySession();
+
+        String dstAbsPath = node2.getPath() + "/" + node1.getName();
+        try {
+            readOnlySuperuser.getWorkspace().move(node1.getPath(), dstAbsPath);
+            fail("Copy in a read-only session should throw an AccessDeniedException.");
+        } catch (AccessDeniedException e) {
+            // successful
+        }
+    }
+
+    /**
+     * A PathNotFoundException is thrown if the node at srcAbsPath or the parent
+     * of the new node at destAbsPath does not exist.
+     */
+    public void testMoveNodesPathNotExisting() throws RepositoryException {
+
+        String srcAbsPath = node1.getPath();
+        String dstAbsPath = node2.getPath() + "/" + node1.getName();
+
+        // srcAbsPath is not existing
+        String unvalidSrcPath = srcAbsPath + "unvalid";
+        try {
+            workspace.move(unvalidSrcPath, dstAbsPath);
+            fail("Not existing source path '" + unvalidSrcPath + "' should throw PathNotFoundException.");
+        } catch (PathNotFoundException e) {
+            // successful
+        }
+
+        // dstAbsPath parent is not existing
+        String unvalidDstParentPath = node2.getPath() + "unvalid/" + node1.getName();
+        try {
+            workspace.move(srcAbsPath, unvalidDstParentPath);
+            fail("Not existing destination parent path '" + unvalidDstParentPath + "' should
throw PathNotFoundException.");
+        } catch (PathNotFoundException e) {
+            // successful
+        }
+    }
+
+
+    /**
+     * A LockException is thrown if a lock prevents the copy.
+     */
+    public void testMoveNodesLocked() throws RepositoryException {
+        // we assume repository supports locking
+        String dstAbsPath = node2.getPath() + "/" + node1.getName();
+
+        // add mixin "lockable" to be able to lock the node
+        if (!node2.getPrimaryNodeType().isNodeType(mixLockable)) {
+            node2.addMixin(mixLockable);
+            testRootNode.save();
+        }
+
+        // lock dst parent node
+        node2.lock(true, true);
+
+        try {
+            workspace.move(node1.getPath(), dstAbsPath);
+            fail("LockException was expected.");
+        } catch (LockException e) {
+            // successful
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveVersionableTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveVersionableTest.java?view=auto&rev=157794
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveVersionableTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveVersionableTest.java
Wed Mar 16 12:01:45 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.test.api;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.version.VersionException;
+
+
+/**
+ * <code>WorkspaceMoveVersionableTest</code> contains tests for moving
+ * versionable nodes in one workspace.
+ *
+ * @test
+ * @sources WorkspaceMoveVersionableTest.java
+ * @executeClass org.apache.jackrabbit.test.api.WorkspaceMoveVersionableTest
+ * @keywords level2 versioning
+ */
+public class WorkspaceMoveVersionableTest extends AbstractWorkspaceVersionableTest {
+
+    /**
+     * A VersionException is thrown if the parent node of destAbsPath is
+     * versionable and checked-in, or is non-versionable but its nearest
+     * versionable ancestor is checked-in.
+     */
+    public void testMoveNodesVersionableAndCheckedIn() throws RepositoryException {
+        // prepare the test data
+        // create a non-versionable node below a versionable node
+        // required for having a nearest versionable ancestor to a nonversionable sub node
+        String dstAbsPath = node1.getPath() + "/" + node2.getName();
+        workspace.copy(node2.getPath(), dstAbsPath);
+
+        // make parent node versionable and check-in
+        addMixinVersionableToNode(testRootNode, node1);
+        node1.checkin();
+
+        // 1. parent node of destAbsPath is non-versionable but its nearest versionable ancestor
is checked-in
+        try {
+            workspace.move(node2.getPath(), dstAbsPath + "/" + node2.getName());
+            fail("Copying a node to a node's versionable and checked-in nearest ancestor
node of destAbsPath should throw VersionException.");
+        } catch (VersionException e) {
+            // successful
+        }
+
+        // 2. parent node of destAbsPath is versionable and checked-in
+        try {
+            workspace.move(node2.getPath(), node1.getPath() + "/" + node2.getName());
+            fail("Copying a node to a versionable and checked-in parent node of destAbsPath
should throw VersionException.");
+        } catch (VersionException e) {
+            // successful
+        }
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveVersionableTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message