You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2022/07/05 14:18:41 UTC

svn commit: r1902488 - in /jackrabbit/trunk: jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java

Author: kwin
Date: Tue Jul  5 14:18:41 2022
New Revision: 1902488

URL: http://svn.apache.org/viewvc?rev=1902488&view=rev
Log:
JCR-4741: add test for creating node without mandatory non-residual child node

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties?rev=1902488&r1=1902487&r2=1902488&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties Tue Jul  5 14:18:41 2022
@@ -184,6 +184,11 @@ javax.jcr.tck.SessionUUIDTest.testSaveMo
 javax.jcr.tck.NodeTest.testAddNodeItemExistsException.nodetype=nt:folder
 
 # Test class: NodeTest
+# Test method: testAddNodeLackingMandatoryChildNode
+# nodetype that has a mandatory child node definition
+javax.jcr.tck.NodeTest.testAddNodeLackingMandatoryChildNode.nodetype2=nt:file
+
+# Test class: NodeTest
 # Test method: testRemoveMandatoryNode
 # nodetype that has a mandatory child node definition
 javax.jcr.tck.NodeTest.testRemoveMandatoryNode.nodetype2=nt:file

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java?rev=1902488&r1=1902487&r2=1902488&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java Tue Jul  5 14:18:41 2022
@@ -499,6 +499,34 @@ public class NodeTest extends AbstractJC
     }
 
     /**
+     * Creates a node without its mandatory child node using {@link
+     * Node#addNode(String, String)} and then saves.
+     * <p>
+     * This should throw a {@link ConstraintViolationException}.
+     * <p>
+     * Prerequisites: <ul>
+     * <li><code>javax.jcr.tck.NodeTest.testAddNodeLackingMandatoryChildNode.nodetype2</code>
+     * a node type that has a mandatory child node</li>
+     * </ul>
+     */
+    public void testAddNodeLackingMandatoryChildNode() throws RepositoryException {
+
+        // get default workspace test root node using superuser session
+        Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
+
+        // create the node without the mandatory child node definition
+        defaultRootNode.addNode(nodeName2, getProperty("nodetype2"));
+
+        try {
+            // save changes
+            superuser.save();
+            fail("Adding a node without its mandatory child node should throw a ConstraintViolationException");
+        } catch (ConstraintViolationException e) {
+            // ok, works as expected
+        }
+    }
+
+    /**
      * Creates a node with a mandatory child node using {@link
      * Node#addNode(String, String)}, saves on parent node then tries to delete
      * the mandatory child node.