Search in sources :

Example 6 with NodeTypeExistsException

use of javax.jcr.nodetype.NodeTypeExistsException in project jackrabbit by apache.

the class NodeTypeManagerImplTest method testRegisterNodeTypes.

public void testRegisterNodeTypes() throws RepositoryException {
    NodeTypeTemplate test = ntMgr.createNodeTypeTemplate();
    test.setName("testNodeType");
    ntMgr.registerNodeType(test, true);
    NodeType nt = ntMgr.getNodeType("testNodeType");
    assertNotNull(nt);
    assertEquals("testNodeType", nt.getName());
    test.setOrderableChildNodes(true);
    ntMgr.registerNodeType(test, true);
    nt = ntMgr.getNodeType("testNodeType");
    assertNotNull(nt);
    assertEquals("testNodeType", nt.getName());
    assertEquals(test.hasOrderableChildNodes(), nt.hasOrderableChildNodes());
    test.setDeclaredSuperTypeNames(new String[] { "nt:unstructured" });
    try {
        ntMgr.registerNodeType(test, false);
        fail("NodeTypeExistsException expected");
    } catch (NodeTypeExistsException e) {
    // success
    }
}
Also used : NodeTypeTemplate(javax.jcr.nodetype.NodeTypeTemplate) NodeTypeExistsException(javax.jcr.nodetype.NodeTypeExistsException) NodeType(javax.jcr.nodetype.NodeType)

Aggregations

NodeTypeExistsException (javax.jcr.nodetype.NodeTypeExistsException)6 NodeType (javax.jcr.nodetype.NodeType)3 NodeTypeDefinition (javax.jcr.nodetype.NodeTypeDefinition)3 NodeTypeTemplate (javax.jcr.nodetype.NodeTypeTemplate)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 PropertyDefinitionTemplate (javax.jcr.nodetype.PropertyDefinitionTemplate)2 NodeTypeIteratorAdapter (org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter)2 QNodeTypeDefinition (org.apache.jackrabbit.spi.QNodeTypeDefinition)2 RepositoryException (javax.jcr.RepositoryException)1 InvalidNodeTypeDefinitionException (javax.jcr.nodetype.InvalidNodeTypeDefinitionException)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 QNodeTypeDefinitionImpl (org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl)1