You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2006/11/16 20:05:59 UTC
svn commit: r475876 - in
/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi:
AccessByRelativePathTest.java MoveSNSTest.java RemoveReferenceableTest.java
RemoveSNSTest.java
Author: angela
Date: Thu Nov 16 11:05:58 2006
New Revision: 475876
URL: http://svn.apache.org/viewvc?view=rev&rev=475876
Log:
work in progress
- tests
Added:
jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/AccessByRelativePathTest.java (with props)
jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveSNSTest.java (with props)
jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveReferenceableTest.java (with props)
jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveSNSTest.java (with props)
Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/AccessByRelativePathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/AccessByRelativePathTest.java?view=auto&rev=475876
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/AccessByRelativePathTest.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/AccessByRelativePathTest.java Thu Nov 16 11:05:58 2006
@@ -0,0 +1,240 @@
+/*
+ * 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 org.apache.jackrabbit.name.Path;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.NodeIterator;
+
+/**
+ * <code>AccessByRelativePathTest</code>...
+ */
+public class AccessByRelativePathTest extends AbstractJCRTest {
+
+ private static Logger log = LoggerFactory.getLogger(AccessByRelativePathTest.class);
+
+ private static String DOT = Path.CURRENT_ELEMENT.getName().getLocalName();
+ private static String DOTDOT = Path.PARENT_ELEMENT.getName().getLocalName();
+
+ /**
+ * <code>Node.hasNode(".") </code> applied to the root node must return
+ * <code>true</code>.
+ *
+ * @throws RepositoryException
+ */
+ public void testRootHasNodeDot() throws RepositoryException {
+ Node root = superuser.getRootNode();
+ assertTrue("Node.hasNode(\".\") must return true.", root.hasNode(DOT));
+ }
+
+ /**
+ * <code>Node.getNode(".") </code> applied to the root node must return
+ * the same <code>Node</code> again.
+ *
+ * @throws RepositoryException
+ */
+ public void testRootGetNodeDot() throws RepositoryException {
+ Node root = superuser.getRootNode();
+ assertTrue("Node.getNode(\".\") must return the same node", root.getNode(DOT).isSame(root));
+ }
+
+ /**
+ * <code>Node.getNode("..") </code> applied to the root node must throw
+ * <code>PathNotFoundException</code>.
+ *
+ * @throws RepositoryException
+ */
+ public void testRootGetNodeDotDot() throws RepositoryException {
+ Node root = superuser.getRootNode();
+ try {
+ root.getNode(DOTDOT);
+ fail("Root does not have a parent node. <root>.getNode(\"..\") must fail.");
+ } catch (PathNotFoundException e) {
+ // ok.
+ }
+ }
+
+ /**
+ * <code>Node.hasNode(".") </code> applied to any test node must return
+ * <code>true</code>.
+ *
+ * @throws RepositoryException
+ */
+ public void testHasNodeDot() throws RepositoryException {
+ assertTrue("Node.hasNode(\".\") must return true.", testRootNode.hasNode(DOT));
+ }
+
+ /**
+ * <code>Node.getNode(".") </code> applied to any test node must return
+ * the same <code>Node</code> again.
+ *
+ * @throws RepositoryException
+ */
+ public void GetNodeDot() throws RepositoryException {
+ assertTrue("Node.getNode(\".\") must return the same node.", testRootNode.getNode(DOT).isSame(testRootNode));
+ }
+
+ /**
+ * <code>Node.getNode("..") </code> applied to any test node must the same
+ * node as {@link Node#getParent()}.
+ *
+ * @throws RepositoryException
+ * @throws NotExecutableException if the parent node cannot be retrieved
+ * with {@link Node#getParent()}.
+ */
+ public void testGetNodeDotDot() throws RepositoryException, NotExecutableException {
+ Node parent;
+ try {
+ parent = testRootNode.getParent();
+ } catch (Exception e) {
+ throw new NotExecutableException();
+ }
+ assertTrue("Node.getNode(\"..\") must return the parent.", testRootNode.getNode(DOTDOT).isSame(parent));
+ }
+
+ /**
+ * <code>Node.hasProperty(".") </code> applied to any test node must return
+ * <code>false</code>.
+ *
+ * @throws RepositoryException
+ */
+ public void testHasPropertyDot() throws RepositoryException {
+ assertFalse("Node.hasProperty(\".\") must return false.", testRootNode.hasProperty(DOT));
+ }
+
+ /**
+ * <code>Node.getProperty(".") </code> applied to any test node must throw
+ * <code>PathNotFoundException</code>.
+ *
+ * @throws RepositoryException
+ */
+ public void testGetPropertyDot() throws RepositoryException {
+ try {
+ testRootNode.getProperty(DOT);
+ fail("A node must never have a property \".\".");
+ } catch (PathNotFoundException e) {
+ // ok.
+ }
+ }
+
+ /**
+ * <code>Node.hasProperty("..") </code> applied to any test node must return
+ * <code>false</code>.
+ *
+ * @throws RepositoryException
+ */
+ public void testHasPropertyDotDot() throws RepositoryException {
+ assertFalse("Node.hasProperty(\"..\") must return false.", testRootNode.hasProperty(DOTDOT));
+ }
+
+ /**
+ * <code>Node.getProperty("..") </code> applied to any test node must throw
+ * <code>PathNotFoundException</code>.
+ *
+ * @throws RepositoryException
+ */
+ public void testGetPropertyDotDot() throws RepositoryException {
+ try {
+ testRootNode.getProperty(DOTDOT);
+ fail("A node must never have a property \"..\".");
+ } catch (PathNotFoundException e) {
+ // ok.
+ }
+ }
+
+ /**
+ * <code>Node.getNode("./testNodeName") </code> applied to the parent
+ * of any node with name 'testNodeName' must return the same node.
+ *
+ * @throws RepositoryException
+ * @throws NotExecutableException if the parent cannot be retrieved or if
+ * the parent has more than 1 node with the given name.
+ */
+ public void testGetNodeDotSlashName() throws RepositoryException, NotExecutableException {
+ Node parent;
+ try {
+ parent = testRootNode.getParent();
+ NodeIterator it = parent.getNodes(testRootNode.getName());
+ int cnt = 0;
+ while (it.hasNext() && cnt <= 1) {
+ it.nextNode();
+ cnt++;
+ }
+ if (cnt > 1) {
+ throw new NotExecutableException();
+ }
+ } catch (Exception e) {
+ throw new NotExecutableException();
+ }
+ String otherRelPath = DOT + "/" + testRootNode.getName();
+ assertTrue(testRootNode.isSame(parent.getNode(otherRelPath)));
+ }
+
+ /**
+ * <code>Node.getNode("../" + Node.getName()) </code> applied to any test
+ * node must return the test node.
+ *
+ * @throws RepositoryException
+ */
+ public void testGetNodeDotDotSlashName() throws RepositoryException, NotExecutableException {
+ // TODO: NotExecutableException if sns exist for testRootNode
+ String otherRelPath = DOTDOT + "/" + testRootNode.getName();
+ assertTrue(testRootNode.isSame(testRootNode.getNode(otherRelPath)));
+ }
+
+ /**
+ * <code>Node.getProperty("./jcr:primaryType") </code> applied to any
+ * test node must return the same Property as
+ * {@link Node#getProperty(String) Node.getProperty("jcr:primaryType")}.
+ *
+ * @throws RepositoryException
+ */
+ public void testGetPropertyDotSlashName() throws RepositoryException {
+ Property pt = testRootNode.getProperty(jcrPrimaryType);
+ String otherRelPath = DOT + "/" + jcrPrimaryType;
+ assertTrue(pt.isSame(testRootNode.getProperty(otherRelPath)));
+ }
+
+ /**
+ * <code>Node.getProperty("../jcr:primaryType") </code> applied to any
+ * test node must return the same Property as
+ * {@link Node#getProperty(String) Node.getParent().getProperty("jcr:primaryType")}.
+ *
+ * @throws RepositoryException
+ * @throws NotExecutableException if the parent cannot be retrieved.
+ */
+ public void testGetPropertyDotDotSlashName() throws RepositoryException, NotExecutableException {
+ Node parent;
+ try {
+ parent = testRootNode.getParent();
+ } catch (Exception e) {
+ throw new NotExecutableException();
+ }
+
+ Property pt = parent.getProperty(jcrPrimaryType);
+ String otherRelPath = DOTDOT + "/" + jcrPrimaryType;
+ assertTrue(pt.isSame(testRootNode.getProperty(otherRelPath)));
+ }
+}
\ No newline at end of file
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/AccessByRelativePathTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/AccessByRelativePathTest.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveSNSTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveSNSTest.java?view=auto&rev=475876
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveSNSTest.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveSNSTest.java Thu Nov 16 11:05:58 2006
@@ -0,0 +1,165 @@
+/*
+ * 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.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Item;
+
+/**
+ * <code>MoveSNSTest</code> (Implementation specific tests. JSR170 only
+ * expects orderable same-name-siblings to have a consistent and testable
+ * order.)
+ */
+public class MoveSNSTest extends MoveTest {
+
+ private static Logger log = LoggerFactory.getLogger(MoveSNSTest.class);
+
+ private Node sourceSibling;
+ private Node destSibling;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ if (destParentNode.hasNode(nodeName2)) {
+ fail("Setup: Move destination already contains a child node with name " + nodeName2);
+ }
+
+ if (!moveNode.getDefinition().allowsSameNameSiblings()) {
+ fail("Setup: Unable to create SNS-node for MoveSNSTest.");
+ }
+ sourceSibling = srcParentNode.addNode(nodeName2, testNodeType);
+ destSibling = destParentNode.addNode(nodeName2, testNodeType);
+
+ if (!destSibling.getDefinition().allowsSameNameSiblings()) {
+ fail("Setup: Unable to create SNS-node at move destination.");
+ }
+ testRootNode.save();
+ }
+
+ /**
+ * Implementation specific:
+ * Test if the path of a moved node, contains the index of the last sibling.
+ */
+ public void testMovedNodeGetPath() throws RepositoryException, NotExecutableException {
+ int index = destSibling.getIndex() + 1;
+ //move the node
+ superuser.move(moveNode.getPath(),destinationPath);
+ assertEquals("After successful move the moved node must return the destination path.", destinationPath + "["+ index +"]", moveNode.getPath());
+ }
+
+ /**
+ * Implementation specific:
+ * Same as {@link #testMovedNodeGetPath()}, but calls save prior to the
+ * test.
+ */
+ public void testMovedNodeGetPath2() throws RepositoryException, NotExecutableException {
+ int index = destSibling.getIndex() + 1;
+ //move the node
+ superuser.move(moveNode.getPath(), destParentNode.getPath() + "/" + nodeName2);
+ superuser.save();
+ assertEquals("After successful move the moved node must return the destination path.", destinationPath + "["+ index +"]", moveNode.getPath());
+ }
+
+
+ /**
+ * Test if a moved node is 'replaced' by its SNS.
+ */
+ public void testAccessMovedNodeByOldPath() throws RepositoryException, NotExecutableException {
+ String oldPath = moveNode.getPath();
+ //move the node
+ superuser.move(oldPath, destinationPath);
+ try {
+ Item item = superuser.getItem(oldPath);
+ // Implementation specific:
+ assertTrue("A moved SNS node must be 'replaced' but is successor sibling.", item.isSame(sourceSibling));
+ } catch (PathNotFoundException e) {
+ fail("A moved SNS node must be 'replaced' but is successor sibling.");
+ }
+ }
+
+ /**
+ * Same as {@link #testAccessMovedNodeByOldPath()} but calls save() prior to
+ * the test.
+ */
+ public void testAccessMovedNodeByOldPath2() throws RepositoryException, NotExecutableException {
+ String oldPath = moveNode.getPath();
+ //move the node
+ superuser.move(oldPath, destinationPath);
+ superuser.save();
+ try {
+ Item item = superuser.getItem(oldPath);
+ // Implementation specific:
+ assertTrue("A moved SNS node must be 'replaced' but is successor sibling.", item.isSame(sourceSibling));
+ } catch (PathNotFoundException e) {
+ fail("A moved SNS node must be 'replaced' but is successor sibling.");
+ }
+ }
+
+ /**
+ * Implementation specific:
+ * Test if the moved node is appended to the list of SNSs at the destination.
+ *
+ * @throws RepositoryException
+ * @throws NotExecutableException
+ */
+ public void testMovedNodeIsSame() throws RepositoryException, NotExecutableException {
+ //move the node
+ superuser.move(moveNode.getPath(), destinationPath);
+
+ int cnt = 0;
+ for (NodeIterator it = destParentNode.getNodes(nodeName2); it.hasNext();) {
+ Node n = it.nextNode();
+ if (cnt == 0) {
+ assertTrue("Moved node must be appended to list of SNSs.", destSibling.isSame(n));
+ } else {
+ assertTrue("Moved node must be appended to list of SNSs.", moveNode.isSame(n));
+ }
+ cnt++;
+ }
+ }
+
+ /**
+ * Implementation specific:
+ * Same as {@link #testMovedNodeIsSame()}, but calls save() before executing
+ * the comparison.
+ *
+ * @throws RepositoryException
+ * @throws NotExecutableException
+ */
+ public void testMovedNodeIsSame2() throws RepositoryException, NotExecutableException {
+ //move the node
+ superuser.move(moveNode.getPath(), destinationPath);
+ superuser.save();
+
+ int cnt = 0;
+ for (NodeIterator it = destParentNode.getNodes(nodeName2); it.hasNext();) {
+ Node n = it.nextNode();
+ if (cnt == 0) {
+ assertTrue("Moved node must be appended to list of SNSs.", destSibling.isSame(n));
+ } else {
+ assertTrue("Moved node must be appended to list of SNSs.", moveNode.isSame(n));
+ }
+ cnt++;
+ }
+ }
+}
\ No newline at end of file
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveSNSTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveSNSTest.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveReferenceableTest.java?view=auto&rev=475876
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveReferenceableTest.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveReferenceableTest.java Thu Nov 16 11:05:58 2006
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ *
+ * Copyright 1997-2005 Day Management AG
+ * Barfuesserplatz 6, 4001 Basel, Switzerland
+ * All Rights Reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * Day Management AG, ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with Day.
+ */
+package org.apache.jackrabbit.jcr2spi;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Item;
+import javax.jcr.Node;
+
+/**
+ * <code>RemoveNodeTest</code>...
+ */
+public class RemoveReferenceableTest extends RemoveNodeTest {
+
+ private static Logger log = LoggerFactory.getLogger(RemoveReferenceableTest.class);
+
+ private String uuid;
+
+ protected Item createRemoveItem() throws NotExecutableException, RepositoryException {
+ Node removeItem = (Node) super.createRemoveItem();
+ // assert removeNode is referenceable
+ if (!removeItem.isNodeType(mixReferenceable)) {
+ if (!removeItem.canAddMixin(mixReferenceable)) {
+ throw new NotExecutableException("Cannot make remove-node '" + nodeName1 + "' mix:referenceable.");
+ }
+ removeItem.addMixin(mixReferenceable);
+ }
+
+ // make sure the new node is persisted.
+ testRootNode.save();
+ uuid = removeItem.getUUID();
+ return removeItem;
+ }
+
+ /**
+ * Transiently removes a persisted node using {@link javax.jcr.Node#remove()}
+ * and test, whether that node cannot be access by the UUID any more.
+ */
+ public void testAccessByUUID() throws RepositoryException {
+ removeItem.remove();
+ // check if the node has been properly removed
+ try {
+ superuser.getNodeByUUID(uuid);
+ fail("Permanently removed node should no longer be accessible from parent node.");
+ } catch (ItemNotFoundException e) {
+ // ok , works as expected
+ }
+ }
+
+ /**
+ * Same as {@link #testRemoveNode()}, but calls save() before executing the
+ * test.
+ */
+ public void testAccessByUUID2() throws RepositoryException, NotExecutableException {
+ removeItem.remove();
+ testRootNode.save();
+ try {
+ superuser.getNodeByUUID(uuid);
+ fail("Transiently removed node should no longer be accessible from parent node.");
+ } catch (ItemNotFoundException e) {
+ // ok , works as expected
+ }
+ }
+}
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveReferenceableTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveReferenceableTest.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveSNSTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveSNSTest.java?view=auto&rev=475876
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveSNSTest.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveSNSTest.java Thu Nov 16 11:05:58 2006
@@ -0,0 +1,127 @@
+/*
+ * 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.Item;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+
+/**
+ * <code>RemoveSNSTest</code> (Implementation specific tests. JSR170 only
+ * expects orderable same-name-siblings to have a consistent and testable
+ * order.)
+ */
+public class RemoveSNSTest extends RemoveNodeTest {
+
+ private static Logger log = LoggerFactory.getLogger(RemoveSNSTest.class);
+
+ private Node firstSiblingNode;
+ private String firstSiblingPath;
+
+ protected Item createRemoveItem() throws NotExecutableException, RepositoryException {
+ if (testRootNode.hasNode(nodeName1)) {
+ fail("Setup: Parent node must not yet contain a child node '" + nodeName1 + "'.");
+ }
+ firstSiblingNode = testRootNode.addNode(nodeName1, testNodeType);
+ if (!firstSiblingNode.getDefinition().allowsSameNameSiblings()) {
+ fail("Setup: RemoveSNSTest cannot be execute. Unable to create SameNameSiblings.");
+ }
+ firstSiblingPath = firstSiblingNode.getPath();
+
+ Node removeNode = testRootNode.addNode(nodeName1, testNodeType);
+ // make sure the new node is persisted.
+ testRootNode.save();
+ return removeNode;
+ }
+
+ /**
+ * Transiently removes the first SNS-node using {@link javax.jcr.Node#remove()}
+ * and test, whether the remaining sibling 'replaces' the removed node and
+ * is the same as the node added as second sibling.
+ */
+ public void testRemoveFirstSibling() throws RepositoryException {
+ firstSiblingNode.remove();
+
+ // check if the node has been properly removed
+ try {
+ Node secondSibling = testRootNode.getNode(nodeName1);
+ // implementation specific:
+ assertTrue("", removeItem.isSame(secondSibling));
+ } catch (PathNotFoundException e) {
+ fail("Second sibling must still be available.");
+ }
+ }
+
+ /**
+ * Same as {@link #testRemoveNode()}, but calls save() (persisting the removal)
+ * before executing the test.
+ */
+ public void testRemoveFirstSibling2() throws RepositoryException, NotExecutableException {
+ firstSiblingNode.remove();
+ testRootNode.save();
+
+ // check if the node has been properly removed
+ try {
+ Node secondSibling = testRootNode.getNode(nodeName1);
+ // implementation specific:
+ assertTrue("", removeItem.isSame(secondSibling));
+ } catch (PathNotFoundException e) {
+ fail("Second sibling must still be available.");
+ }
+ }
+
+ /**
+ * Transiently removes a persisted item using {@link javax.jcr.Item#remove()}
+ * and test, whether the successor sibling is returned when retrieving the
+ * item with the path of the removed node.
+ */
+ public void testRemoveFirstSibling3() throws RepositoryException {
+ firstSiblingNode.remove();
+
+ // check if the node has been properly removed
+ try {
+ Item secondSibling = superuser.getItem(firstSiblingPath);
+ // implementation specific:
+ assertTrue("", removeItem.isSame(secondSibling));
+ } catch (PathNotFoundException e) {
+ fail("Removing a SNS Node -> successor must be accessible from the session by removed path.");
+ }
+ }
+
+ /**
+ * Same as {@link #testRemoveFirstSibling3()} but calls save() before
+ * executing the test.
+ */
+ public void testRemoveFirstSibling4() throws RepositoryException {
+ firstSiblingNode.remove();
+ testRootNode.save();
+
+ // check if the node has been properly removed
+ try {
+ Item secondSibling = superuser.getItem(firstSiblingPath);
+ // implementation specific:
+ assertTrue("", removeItem.isSame(secondSibling));
+ } catch (PathNotFoundException e) {
+ fail("Removing a SNS Node -> successor must be accessible from the session by removed path.");
+ }
+ }
+}
\ No newline at end of file
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveSNSTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/RemoveSNSTest.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url