Index: jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties =================================================================== --- jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties (revision 1902459) +++ jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties (working copy) @@ -184,6 +184,11 @@ 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 Index: jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java =================================================================== --- jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java (revision 1902459) +++ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java (working copy) @@ -499,6 +499,34 @@ } /** + * Creates a node without its mandatory child node using {@link + * Node#addNode(String, String)} and then saves. + *

+ * This should throw a {@link ConstraintViolationException}. + *

+ * Prerequisites:

+ */ + 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.