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 1895087) +++ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java (working copy) @@ -499,6 +499,36 @@ } /** + * 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.