javax.jcr.nodetype.NodeType

Here are the examples of the java api class javax.jcr.nodetype.NodeType taken from open source projects.

1. UserProviderTest#assertAutoCreatedItems()

Project: jackrabbit-oak
File: UserProviderTest.java
private static void assertAutoCreatedItems(@Nonnull Tree authorizableTree, @Nonnull String ntName, @Nonnull Root root) throws Exception {
    NodeType repUser = ReadOnlyNodeTypeManager.getInstance(root, NamePathMapper.DEFAULT).getNodeType(ntName);
    for (NodeDefinition cnd : repUser.getChildNodeDefinitions()) {
        if (cnd.isAutoCreated()) {
            assertTrue(authorizableTree.hasChild(cnd.getName()));
        }
    }
    for (PropertyDefinition pd : repUser.getPropertyDefinitions()) {
        if (pd.isAutoCreated()) {
            assertTrue(authorizableTree.hasProperty(pd.getName()));
        }
    }
}

2. MockNodeTypeGenerator#getCompleteChildNodeDef()

Project: sling
File: MockNodeTypeGenerator.java
public NodeDefinition getCompleteChildNodeDef(String name) {
    NodeDefinition childNodeDef1 = mock(NodeDefinition.class);
    NodeType requiredPrimaryType1 = getSimpleNodeTypeWithName(NODETYPE_REQ_PRIMARY_TYPE_NAME1);
    NodeType requiredPrimaryType2 = getSimpleNodeTypeWithName(NODETYPE_REQ_PRIMARY_TYPE_NAME2);
    NodeType[] reqPrimaryTypes = { requiredPrimaryType1, requiredPrimaryType2 };
    when(childNodeDef1.getRequiredPrimaryTypes()).thenReturn(reqPrimaryTypes);
    when(childNodeDef1.getName()).thenReturn(name);
    when(childNodeDef1.getOnParentVersion()).thenReturn(OnParentVersionAction.VERSION);
    when(childNodeDef1.getDefaultPrimaryType()).thenReturn(requiredPrimaryType1);
    when(childNodeDef1.allowsSameNameSiblings()).thenReturn(Boolean.TRUE);
    when(childNodeDef1.isAutoCreated()).thenReturn(Boolean.TRUE);
    when(childNodeDef1.isMandatory()).thenReturn(Boolean.TRUE);
    when(childNodeDef1.isProtected()).thenReturn(Boolean.TRUE);
    return childNodeDef1;
}

3. NodeCanAddMixinTest#testAddInheritedMixin()

Project: jackrabbit
File: NodeCanAddMixinTest.java
/**
     * Test if an inherited mixin could be added.
     *
     * @throws RepositoryException
     * @since JCR 2.0
     */
public void testAddInheritedMixin() throws RepositoryException {
    Session session = testRootNode.getSession();
    Node node = testRootNode.addNode(nodeName1, testNodeType);
    session.save();
    NodeType nt = node.getPrimaryNodeType();
    NodeType[] superTypes = nt.getSupertypes();
    for (int i = 0; i < superTypes.length; i++) {
        if (superTypes[i].isMixin()) {
            String mixinName = superTypes[i].getName();
            // adding again must be possible (though it has no effect)
            assertTrue(node.canAddMixin(mixinName));
        }
    }
}

4. NodeAddMixinTest#testAddInheritedMixin()

Project: jackrabbit
File: NodeAddMixinTest.java
/**
     * Test if adding an inherited mixin type has no effect.
     *
     * @throws RepositoryException
     * @since JCR 2.0
     */
public void testAddInheritedMixin() throws RepositoryException, NotExecutableException {
    Session session = testRootNode.getSession();
    Node node = testRootNode.addNode(nodeName1, testNodeType);
    session.save();
    String inheritedMixin = null;
    NodeType nt = node.getPrimaryNodeType();
    NodeType[] superTypes = nt.getSupertypes();
    for (int i = 0; i < superTypes.length && inheritedMixin == null; i++) {
        if (superTypes[i].isMixin()) {
            inheritedMixin = superTypes[i].getName();
        }
    }
    if (inheritedMixin != null) {
        node.addMixin(inheritedMixin);
        assertFalse(node.isModified());
    } else {
        throw new NotExecutableException("Primary node type does not have a mixin supertype");
    }
}

5. NodeDefinitionImpl#toXml()

Project: jackrabbit
File: NodeDefinitionImpl.java
//-------------------------------------< implementation specific method >---
/**
     * Returns xml representation
     *
     * @return xml representation
     * @param document
     */
@Override
public Element toXml(Document document) {
    Element elem = super.toXml(document);
    elem.setAttribute(SAMENAMESIBLINGS_ATTRIBUTE, Boolean.toString(allowsSameNameSiblings()));
    // defaultPrimaryType can be 'null'
    NodeType defaultPrimaryType = getDefaultPrimaryType();
    if (defaultPrimaryType != null) {
        elem.setAttribute(DEFAULTPRIMARYTYPE_ATTRIBUTE, defaultPrimaryType.getName());
    }
    // reqPrimaryTypes: minimal set is nt:base.
    Element reqPrimaryTypes = document.createElement(REQUIREDPRIMARYTYPES_ELEMENT);
    for (NodeType nt : getRequiredPrimaryTypes()) {
        Element rptElem = document.createElement(REQUIREDPRIMARYTYPE_ELEMENT);
        DomUtil.setText(rptElem, nt.getName());
        reqPrimaryTypes.appendChild(rptElem);
    }
    elem.appendChild(reqPrimaryTypes);
    return elem;
}

6. JcrServiceImpl#type()

Project: modeshape
File: JcrServiceImpl.java
private int type(Node node, String propertyName) throws RepositoryException {
    PropertyDefinition[] defs = node.getPrimaryNodeType().getPropertyDefinitions();
    for (PropertyDefinition def : defs) {
        if (def.getName().equals(propertyName)) {
            return def.getRequiredType();
        }
    }
    NodeType[] mixins = node.getMixinNodeTypes();
    for (NodeType type : mixins) {
        defs = type.getPropertyDefinitions();
        for (PropertyDefinition def : defs) {
            if (def.getName().equals(propertyName)) {
                return def.getRequiredType();
            }
        }
    }
    return -1;
}

7. NodeTypeDefinitionTest#testIndexedPropertyDefinition()

Project: jackrabbit-oak
File: NodeTypeDefinitionTest.java
public void testIndexedPropertyDefinition() throws Exception {
    String ntPath = NodeTypeConstants.NODE_TYPES_PATH + '/' + NodeTypeConstants.NT_VERSION;
    assertTrue(superuser.nodeExists(ntPath + "/jcr:propertyDefinition"));
    assertTrue(superuser.nodeExists(ntPath + "/jcr:propertyDefinition[1]"));
    Node pdNode = superuser.getNode(ntPath + "/jcr:propertyDefinition[1]");
    assertEquals(ntPath + "/jcr:propertyDefinition", pdNode.getPath());
    List<String> defNames = new ArrayList();
    NodeType nt = superuser.getWorkspace().getNodeTypeManager().getNodeType(NodeTypeConstants.NT_VERSION);
    for (PropertyDefinition nd : nt.getDeclaredPropertyDefinitions()) {
        defNames.add(nd.getName());
    }
    Node ntNode = superuser.getNode(ntPath);
    NodeIterator it = ntNode.getNodes("jcr:propertyDefinition*");
    while (it.hasNext()) {
        Node def = it.nextNode();
        int index = getIndex(def);
        String name = (def.hasProperty(NodeTypeConstants.JCR_NAME)) ? def.getProperty(NodeTypeConstants.JCR_NAME).getString() : NodeTypeConstants.RESIDUAL_NAME;
        assertEquals(name, defNames.get(index - 1));
    }
}

8. NodeTypeDefinitionTest#testIndexedChildDefinition()

Project: jackrabbit-oak
File: NodeTypeDefinitionTest.java
public void testIndexedChildDefinition() throws Exception {
    String ntPath = NodeTypeConstants.NODE_TYPES_PATH + '/' + NodeTypeConstants.NT_VERSIONHISTORY;
    assertTrue(superuser.nodeExists(ntPath + "/jcr:childNodeDefinition"));
    assertTrue(superuser.nodeExists(ntPath + "/jcr:childNodeDefinition[1]"));
    Node cdNode = superuser.getNode(ntPath + "/jcr:childNodeDefinition[1]");
    assertEquals(ntPath + "/jcr:childNodeDefinition", cdNode.getPath());
    List<String> defNames = new ArrayList();
    NodeType nt = superuser.getWorkspace().getNodeTypeManager().getNodeType(NodeTypeConstants.NT_VERSIONHISTORY);
    for (NodeDefinition nd : nt.getDeclaredChildNodeDefinitions()) {
        defNames.add(nd.getName());
    }
    Node ntNode = superuser.getNode(ntPath);
    NodeIterator it = ntNode.getNodes("jcr:childNodeDefinition*");
    while (it.hasNext()) {
        Node def = it.nextNode();
        int index = getIndex(def);
        String name = (def.hasProperty(NodeTypeConstants.JCR_NAME)) ? def.getProperty(NodeTypeConstants.JCR_NAME).getString() : NodeTypeConstants.RESIDUAL_NAME;
        assertEquals(name, defNames.get(index - 1));
    }
}

9. NodeImpl#isOrderable()

Project: jackrabbit-oak
File: NodeImpl.java
private static boolean isOrderable(Node node) throws RepositoryException {
    if (node.getPrimaryNodeType().hasOrderableChildNodes()) {
        return true;
    }
    NodeType[] types = node.getMixinNodeTypes();
    for (NodeType type : types) {
        if (type.hasOrderableChildNodes()) {
            return true;
        }
    }
    return false;
}

10. ReorderChildNodesCommand#execute0()

Project: sling
File: ReorderChildNodesCommand.java
@Override
protected Void execute0(Session session) throws RepositoryException, IOException {
    boolean nodeExists = session.nodeExists(getPath());
    if (!nodeExists) {
        return null;
    }
    Node node = session.getNode(getPath());
    NodeType primaryNodeType = node.getPrimaryNodeType();
    if (primaryNodeType.hasOrderableChildNodes()) {
        reorderChildNodes(node, resource);
    }
    return null;
}

11. FallbackNodeTypeRegistryTest#nodesuperTypesAreFound()

Project: sling
File: FallbackNodeTypeRegistryTest.java
@Test
public void nodesuperTypesAreFound() {
    FallbackNodeTypeRegistry registry = FallbackNodeTypeRegistry.createRegistryWithDefaultNodeTypes();
    NodeType nodeType = registry.getNodeType("sling:Folder");
    assertThat("nodeType", nodeType, notNullValue());
    assertThat("nodeType.name", nodeType.getName(), equalTo("sling:Folder"));
    assertThat("nodeType.declaredSupertypeNames", nodeType.getDeclaredSupertypeNames(), equalTo(new String[] { "nt:folder" }));
    NodeType[] superTypes = nodeType.getSupertypes();
    assertThat("nodeType.superTypes", superTypes, notNullValue());
    assertThat("nodeType.superTypes.length", superTypes.length, equalTo(1));
    assertThat("nodeType.superTypes[0].name", superTypes[0].getName(), equalTo("nt:folder"));
}

12. VltNodeTypeFactory#initSuperTypes()

Project: sling
File: VltNodeTypeFactory.java
private void initSuperTypes(Set<NodeType> allSuperTypes, VltNodeType nt) {
    final NodeType[] declaredSupertypes = nt.getDeclaredSupertypes();
    if (declaredSupertypes == null) {
        return;
    }
    for (int i = 0; i < declaredSupertypes.length; i++) {
        VltNodeType superType = (VltNodeType) declaredSupertypes[i];
        allSuperTypes.add(superType);
        nt.addSuperType(superType);
        initSuperTypes(allSuperTypes, (VltNodeType) superType);
    }
}

13. VltNodeType#getChildNodeDefinitions()

Project: sling
File: VltNodeType.java
@Override
public NodeDefinition[] getChildNodeDefinitions() {
    List<NodeDefinition> childNodeDefs = new LinkedList<>();
    childNodeDefs.addAll(Arrays.asList(getDeclaredChildNodeDefinitions()));
    NodeType[] supers = getSupertypes();
    if (supers != null) {
        for (int i = 0; i < supers.length; i++) {
            NodeType aSuperNodeType = supers[i];
            NodeDefinition[] superChildNodeDefs = aSuperNodeType.getChildNodeDefinitions();
            if (superChildNodeDefs != null) {
                childNodeDefs.addAll(Arrays.asList(superChildNodeDefs));
            }
        }
    }
    return childNodeDefs.toArray(new NodeDefinition[0]);
}

14. AddOrUpdateNodeCommand#hasPrimaryNodeType()

Project: sling
File: AddOrUpdateNodeCommand.java
private boolean hasPrimaryNodeType(Node node, String... nodeTypeNames) throws RepositoryException {
    String primaryNodeTypeName = node.getPrimaryNodeType().getName();
    for (String nodeTypeName : nodeTypeNames) {
        if (primaryNodeTypeName.equals(nodeTypeName)) {
            return true;
        }
    }
    for (NodeType supertype : node.getPrimaryNodeType().getSupertypes()) {
        String superTypeName = supertype.getName();
        for (String nodeTypeName : nodeTypeNames) {
            if (superTypeName.equals(nodeTypeName)) {
                return true;
            }
        }
    }
    return false;
}

15. JcrNode#getPropertyDefinition()

Project: sling
File: JcrNode.java
public PropertyDefinition getPropertyDefinition(String propertyName) {
    NodeType nt0 = getNodeType();
    if (nt0 == null) {
        return null;
    }
    List<NodeType> nodeTypes = new LinkedList<>();
    nodeTypes.add(nt0);
    // add all supertypes
    nodeTypes.addAll(Arrays.asList(nt0.getSupertypes()));
    for (Iterator<NodeType> it = nodeTypes.iterator(); it.hasNext(); ) {
        NodeType nt = it.next();
        PropertyDefinition[] pds = nt.getPropertyDefinitions();
        for (int i = 0; i < pds.length; i++) {
            PropertyDefinition propertyDefinition = pds[i];
            if (propertyDefinition.getName().equals(propertyName)) {
                return propertyDefinition;
            }
        }
    }
    return null;
}

16. PropertyDefGenerationTest#testMultipleConstraints()

Project: sling
File: PropertyDefGenerationTest.java
@Test
public void testMultipleConstraints() throws ValueFormatException, IllegalStateException, RepositoryException, JSONException, ServletException, IOException {
    PropertyDefinition propertyDef = getPropertyGenerator().getPropertyDef("stringProp", PropertyType.STRING, new String[] { "banana", "apple" }, null);
    NodeType ntWithChildNodeDefs = getSimpleNodeTypeWithName("ntWithPropertyDefs");
    when(ntWithChildNodeDefs.getDeclaredPropertyDefinitions()).thenReturn(new PropertyDefinition[] { propertyDef });
    when(nodeTypeIterator.nextNodeType()).thenReturn(ntWithChildNodeDefs);
    when(nodeTypeIterator.hasNext()).thenReturn(Boolean.TRUE, Boolean.FALSE);
    assertEqualsWithServletResult("testMultipleConstraints");
}

17. PropertyDefGenerationTest#testMultipleDefaultValues()

Project: sling
File: PropertyDefGenerationTest.java
@Test
public void testMultipleDefaultValues() throws ValueFormatException, IllegalStateException, RepositoryException, JSONException, ServletException, IOException {
    Value defaultValue1 = mock(Value.class);
    when(defaultValue1.getString()).thenReturn(DEFAULT_VALUE_STRING);
    Value defaultValue2 = mock(Value.class);
    when(defaultValue2.getString()).thenReturn(DEFAULT_VALUE_STRING + "2");
    PropertyDefinition propertyDef = getPropertyGenerator().getPropertyDef("stringProp", PropertyType.STRING, new String[] { CONSTRAINT_STRING }, new Value[] { defaultValue1, defaultValue2 });
    NodeType ntWithChildNodeDefs = getSimpleNodeTypeWithName("ntWithPropertyDefs");
    when(ntWithChildNodeDefs.getDeclaredPropertyDefinitions()).thenReturn(new PropertyDefinition[] { propertyDef });
    when(nodeTypeIterator.nextNodeType()).thenReturn(ntWithChildNodeDefs);
    when(nodeTypeIterator.hasNext()).thenReturn(Boolean.TRUE, Boolean.FALSE);
    assertEqualsWithServletResult("testMultipleDefaultValues");
}

18. PropertyDefGenerationTest#testTwoResidualPropertyDefinitions()

Project: sling
File: PropertyDefGenerationTest.java
@Test
public void testTwoResidualPropertyDefinitions() throws ValueFormatException, IllegalStateException, RepositoryException, JSONException, ServletException, IOException {
    //Is only be possible for multi valued property defs
    PropertyDefinition[] residualPropertyDefs = { getPropertyGenerator().getCompleteStringPropertyDef("*"), getPropertyGenerator().getCompleteDatePropertyDef("*") };
    NodeType ntWithChildNodeDefs = getSimpleNodeTypeWithName("ntWithPropertyDefs");
    when(ntWithChildNodeDefs.getDeclaredPropertyDefinitions()).thenReturn(residualPropertyDefs);
    when(nodeTypeIterator.nextNodeType()).thenReturn(ntWithChildNodeDefs);
    when(nodeTypeIterator.hasNext()).thenReturn(Boolean.TRUE, Boolean.FALSE);
    assertEqualsWithServletResult("testTwoResidualPropertyDefinitions");
}

19. MockPropertyDefGenerator#getPropertyDef()

Project: sling
File: MockPropertyDefGenerator.java
public PropertyDefinition getPropertyDef(String propertyName, Integer type, Boolean isAutoCreated, Boolean isMandatory, Boolean isProtected, Boolean isMultiple, Integer onParentVersionAction, String[] valueConstraints, Value[] defaultValues) throws ValueFormatException, RepositoryException {
    PropertyDefinition propertyDef = mock(PropertyDefinition.class);
    when(propertyDef.getOnParentVersion()).thenReturn(onParentVersionAction);
    when(propertyDef.getName()).thenReturn(propertyName);
    when(propertyDef.getRequiredType()).thenReturn(type);
    when(propertyDef.getValueConstraints()).thenReturn(valueConstraints);
    when(propertyDef.isMultiple()).thenReturn(isMultiple);
    when(propertyDef.isProtected()).thenReturn(isProtected);
    NodeType declaringNodeType = mock(NodeType.class);
    when(declaringNodeType.getName()).thenReturn("ntName");
    when(propertyDef.getDeclaringNodeType()).thenReturn(declaringNodeType);
    if (defaultValues != null) {
        for (Value defaultValue : defaultValues) {
            when(defaultValue.getType()).thenReturn(type);
        }
    }
    when(propertyDef.getDefaultValues()).thenReturn(defaultValues);
    when(propertyDef.isAutoCreated()).thenReturn(isAutoCreated);
    when(propertyDef.isMandatory()).thenReturn(isMandatory);
    return propertyDef;
}

20. ChildNodeDefGenerationTest#testResidualChildNodeDefinitions()

Project: sling
File: ChildNodeDefGenerationTest.java
@Test
public void testResidualChildNodeDefinitions() throws JSONException, ServletException, IOException {
    NodeType ntWithChildNOdeDefs = getSimpleNodeTypeWithName("ntWithChildNodeDefs");
    NodeDefinition childNodeDef1 = getSimpleChildNodeDef("*");
    NodeDefinition childNodeDef2 = getSimpleChildNodeDef("*");
    NodeDefinition childNodeDef3 = getSimpleChildNodeDef("childNodeDef");
    NodeDefinition[] childNodeDefs = { childNodeDef1, childNodeDef2, childNodeDef3 };
    when(ntWithChildNOdeDefs.getDeclaredChildNodeDefinitions()).thenReturn(childNodeDefs);
    when(nodeTypeIterator.nextNodeType()).thenReturn(ntWithChildNOdeDefs);
    when(nodeTypeIterator.hasNext()).thenReturn(Boolean.TRUE, Boolean.FALSE);
    assertEqualsWithServletResult("testResidualChildNodeDefinitions");
}

21. ChildNodeDefGenerationTest#testCompleteChildNodeDefinitions()

Project: sling
File: ChildNodeDefGenerationTest.java
@Test
public void testCompleteChildNodeDefinitions() throws ServletException, IOException, JSONException {
    NodeType ntWithChildNodeDefs = getSimpleNodeTypeWithName("ntWithChildNodeDefs");
    NodeDefinition childNodeDef1 = getCompleteChildNodeDef("childNodeDef1");
    NodeDefinition childNodeDef2 = getCompleteChildNodeDef("childNodeDef2");
    NodeDefinition[] childNodeDefs = { childNodeDef1, childNodeDef2 };
    when(ntWithChildNodeDefs.getDeclaredChildNodeDefinitions()).thenReturn(childNodeDefs);
    when(nodeTypeIterator.nextNodeType()).thenReturn(ntWithChildNodeDefs);
    when(nodeTypeIterator.hasNext()).thenReturn(Boolean.TRUE, Boolean.FALSE);
    assertEqualsWithServletResult("testCompleteChildNodeDefinitions");
}

22. ChildNodeDefGenerationTest#testSimpleChildNodeDefinitions()

Project: sling
File: ChildNodeDefGenerationTest.java
@Test
public void testSimpleChildNodeDefinitions() throws ServletException, IOException, JSONException {
    NodeType ntWithChildNodeDefs = getSimpleNodeTypeWithName("ntWithChildNodeDefs");
    NodeDefinition childNodeDef1 = getSimpleChildNodeDef("childNodeDef1");
    NodeDefinition childNodeDef2 = getSimpleChildNodeDef("childNodeDef2");
    NodeDefinition[] childNodeDefs = { childNodeDef1, childNodeDef2 };
    when(ntWithChildNodeDefs.getDeclaredChildNodeDefinitions()).thenReturn(childNodeDefs);
    when(nodeTypeIterator.nextNodeType()).thenReturn(ntWithChildNodeDefs);
    when(nodeTypeIterator.hasNext()).thenReturn(Boolean.TRUE, Boolean.FALSE);
    assertEqualsWithServletResult("testSimpleChildNodeDefinitions");
}

23. ChildNodeDefGenerationTest#testOneSimpleChildNodeDefinition()

Project: sling
File: ChildNodeDefGenerationTest.java
@Test
public void testOneSimpleChildNodeDefinition() throws ServletException, IOException, JSONException {
    NodeType ntWithChildNodeDefs = getSimpleNodeTypeWithName("ntWithChildNodeDefs");
    NodeDefinition[] childNodeDefs = { getSimpleChildNodeDef("childNodeDef1") };
    when(ntWithChildNodeDefs.getDeclaredChildNodeDefinitions()).thenReturn(childNodeDefs);
    when(nodeTypeIterator.nextNodeType()).thenReturn(ntWithChildNodeDefs);
    when(nodeTypeIterator.hasNext()).thenReturn(Boolean.TRUE, Boolean.FALSE);
    assertEqualsWithServletResult("testOneSimpleChildNodeDefinition");
}

24. NodeUtil#handleMixinTypes()

Project: sling
File: NodeUtil.java
/**
     * Update the mixin node types
     *
     * @param node the node
     * @param mixinTypes the mixins
     * @throws RepositoryException if the repository's namespaced prefixes cannot be retrieved
     */
public static void handleMixinTypes(final Node node, final String[] mixinTypes) throws RepositoryException {
    final Set<String> newTypes = new HashSet<String>();
    if (mixinTypes != null) {
        for (final String value : mixinTypes) {
            newTypes.add(value);
        }
    }
    final Set<String> oldTypes = new HashSet<String>();
    for (final NodeType mixinType : node.getMixinNodeTypes()) {
        oldTypes.add(mixinType.getName());
    }
    for (final String name : oldTypes) {
        if (!newTypes.contains(name)) {
            node.removeMixin(name);
        } else {
            newTypes.remove(name);
        }
    }
    for (final String name : newTypes) {
        node.addMixin(name);
    }
}

25. HttpRepositoryDelegate#nodeType()

Project: modeshape
File: HttpRepositoryDelegate.java
@Override
public NodeType nodeType(String name) throws RepositoryException {
    if (nodeTypes.get() == null) {
        // load the node types
        nodeTypes();
    }
    NodeType nodetype = nodeTypes.get().get(name);
    if (nodetype == null) {
        throw new RepositoryException(JdbcLocalI18n.unableToGetNodeType.text(name));
    }
    return nodetype;
}

26. JcrPropertyDefinitionTest#shouldAllowValidPathValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldAllowValidPathValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_PATH);
    assertThat(prop.satisfiesConstraints(valueFor("b", PropertyType.PATH), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("/a/b/c", PropertyType.PATH), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("/jcr:system/mode:namespace", PropertyType.PATH), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("/a/b/c/", PropertyType.PATH), session), is(true));
    // Test that constraints work after session rename
    session.setNamespacePrefix("jcr2", JcrLexicon.Namespace.URI);
    assertThat(prop.satisfiesConstraints(valueFor("/jcr2:system/mode:foo", PropertyType.PATH), session), is(true));
}

27. JcrPropertyDefinitionTest#shouldNotAllowInvalidStringValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldNotAllowInvalidStringValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_STRING);
    assertThat(prop.satisfiesConstraints(valueFor("", PropertyType.STRING), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor("foot", PropertyType.STRING), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor("abar", PropertyType.STRING), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor("bard", PropertyType.STRING), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor("baz!", PropertyType.STRING), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor("bazzat", PropertyType.STRING), session), is(false));
}

28. JcrPropertyDefinitionTest#shouldAllowValidStringValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldAllowValidStringValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_STRING);
    assertThat(prop.satisfiesConstraints(valueFor("foo", PropertyType.STRING), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("bar", PropertyType.STRING), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("barr", PropertyType.STRING), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("barrrrrrrrr", PropertyType.STRING), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("baz", PropertyType.STRING), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("shabaz", PropertyType.STRING), session), is(true));
}

29. JcrPropertyDefinitionTest#shouldNotAllowInvalidNameValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test(expected = ValueFormatException.class)
public void shouldNotAllowInvalidNameValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_NAME);
    assertThat(prop.satisfiesConstraints(valueFor("system", PropertyType.NAME), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor("jcr:system2", PropertyType.NAME), session), is(false));
    // Test that old names fail after namespace remaps
    session.setNamespacePrefix("newprefix", TestLexicon.Namespace.URI);
    assertThat(prop.satisfiesConstraints(valueFor("modetest:constrainedType", PropertyType.NAME), session), is(false));
}

30. JcrPropertyDefinitionTest#shouldAllowValidNameValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldAllowValidNameValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_NAME);
    assertThat(prop.satisfiesConstraints(valueFor("jcr:system", PropertyType.NAME), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("modetest:constrainedType", PropertyType.NAME), session), is(true));
    // Test that names work across namespace remaps
    session.setNamespacePrefix("newprefix", TestLexicon.Namespace.URI);
    assertThat(prop.satisfiesConstraints(valueFor("newprefix:constrainedType", PropertyType.NAME), session), is(true));
}

31. JcrPropertyDefinitionTest#shouldNotAllowInvalidLongValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldNotAllowInvalidLongValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_LONG);
    assertThat(prop.satisfiesConstraints(valueFor(5, PropertyType.LONG), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(9, PropertyType.LONG), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(20, PropertyType.LONG), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(30, PropertyType.LONG), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(41, PropertyType.LONG), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(49, PropertyType.LONG), session), is(false));
}

32. JcrPropertyDefinitionTest#shouldAllowValidLongValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldAllowValidLongValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_LONG);
    assertThat(prop.satisfiesConstraints(valueFor(Long.MIN_VALUE, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(0, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(0.1, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(4.99, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(10, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(10.100, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(19, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(31, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(40, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(50, PropertyType.LONG), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(Long.MAX_VALUE, PropertyType.LONG), session), is(true));
}

33. JcrPropertyDefinitionTest#shouldNotAllowInvalidDoubleValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldNotAllowInvalidDoubleValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DOUBLE);
    assertThat(prop.satisfiesConstraints(valueFor(5, PropertyType.DOUBLE), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(9.99999999, PropertyType.DOUBLE), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(20.2, PropertyType.DOUBLE), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(30.3, PropertyType.DOUBLE), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(40.41, PropertyType.DOUBLE), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(49.9, PropertyType.DOUBLE), session), is(false));
}

34. JcrPropertyDefinitionTest#shouldAllowValidDoubleValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldAllowValidDoubleValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DOUBLE);
    assertThat(prop.satisfiesConstraints(valueFor(Double.MIN_VALUE, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(0, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(0.1, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(4.99, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(10.100, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(20.19, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(30.31, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(40.4, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(50.5, PropertyType.DOUBLE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(Double.MAX_VALUE, PropertyType.DOUBLE), session), is(true));
}

35. JcrPropertyDefinitionTest#shouldAllowValidDateValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldAllowValidDateValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DATE);
    assertThat(prop.satisfiesConstraints(valueFor("-1945-08-01T01:30:00.000Z", PropertyType.DATE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("+1945-07-31T01:30:00.000Z", PropertyType.DATE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("+0001-08-01T01:30:00.000Z", PropertyType.DATE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("+1975-08-01T01:30:00.000Z", PropertyType.DATE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("+1975-08-01T01:31:00.000Z", PropertyType.DATE), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor("+2009-08-01T01:30:00.000Z", PropertyType.DATE), session), is(true));
}

36. JcrPropertyDefinitionTest#shouldNotAllowInvalidBinaryValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldNotAllowInvalidBinaryValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY);
    // Making assumption that String.getBytes().length = String.length() on the platform's default encoding
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(5), PropertyType.BINARY), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(9), PropertyType.BINARY), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(20), PropertyType.BINARY), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(30), PropertyType.BINARY), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(41), PropertyType.BINARY), session), is(false));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(49), PropertyType.BINARY), session), is(false));
}

37. JcrPropertyDefinitionTest#shouldAllowValidBinaryValues()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldAllowValidBinaryValues() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY);
    // Making assumption that String.getBytes().length = String.length() on the platform's default encoding
    Value[] values = new Value[] { valueFor(stringOfLength(4), PropertyType.BINARY), valueFor(stringOfLength(10), PropertyType.BINARY), valueFor(stringOfLength(19), PropertyType.BINARY) };
    assertThat(satisfiesConstraints(prop, new Value[] {}), is(true));
    assertThat(satisfiesConstraints(prop, new Value[] { valueFor(stringOfLength(0), PropertyType.BINARY) }), is(true));
    assertThat(satisfiesConstraints(prop, values), is(true));
}

38. JcrPropertyDefinitionTest#shouldAllowValidBinaryValue()

Project: modeshape
File: JcrPropertyDefinitionTest.java
@Test
public void shouldAllowValidBinaryValue() throws Exception {
    NodeType constrainedType = validateTypeDefinition();
    JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY);
    // Making assumption that String.getBytes().length = String.length() on the platform's default encoding
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(0), PropertyType.BINARY), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(4), PropertyType.BINARY), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(10), PropertyType.BINARY), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(19), PropertyType.BINARY), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(31), PropertyType.BINARY), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(40), PropertyType.BINARY), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(50), PropertyType.BINARY), session), is(true));
    assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(99), PropertyType.BINARY), session), is(true));
}

39. JcrPropertyDefinitionTest#validateTypeDefinition()

Project: modeshape
File: JcrPropertyDefinitionTest.java
private NodeType validateTypeDefinition() throws Exception {
    NamespaceRegistry nsr = context.getNamespaceRegistry();
    NodeType constrainedType = nodeTypeManager.getNodeType(TestLexicon.CONSTRAINED_TYPE.getString(nsr));
    assertThat(constrainedType, notNullValue());
    assertThat(propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY), notNullValue());
    assertThat(propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DATE), notNullValue());
    assertThat(propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DOUBLE), notNullValue());
    assertThat(propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_LONG), notNullValue());
    assertThat(propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_NAME), notNullValue());
    assertThat(propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_PATH), notNullValue());
    assertThat(propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE), notNullValue());
    assertThat(propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_STRING), notNullValue());
    checkConstraints(constrainedType, TestLexicon.CONSTRAINED_BINARY, EXPECTED_BINARY_CONSTRAINTS);
    checkConstraints(constrainedType, TestLexicon.CONSTRAINED_DATE, EXPECTED_DATE_CONSTRAINTS);
    checkConstraints(constrainedType, TestLexicon.CONSTRAINED_DOUBLE, EXPECTED_DOUBLE_CONSTRAINTS);
    checkConstraints(constrainedType, TestLexicon.CONSTRAINED_LONG, EXPECTED_LONG_CONSTRAINTS);
    checkConstraints(constrainedType, TestLexicon.CONSTRAINED_NAME, EXPECTED_NAME_CONSTRAINTS);
    checkConstraints(constrainedType, TestLexicon.CONSTRAINED_PATH, EXPECTED_PATH_CONSTRAINTS);
    checkConstraints(constrainedType, TestLexicon.CONSTRAINED_REFERENCE, EXPECTED_REFERENCE_CONSTRAINTS);
    checkConstraints(constrainedType, TestLexicon.CONSTRAINED_STRING, EXPECTED_STRING_CONSTRAINTS);
    return constrainedType;
}

40. JcrNodeTypesTest#shouldRegisterNodeTypeWithUriPropertyType()

Project: modeshape
File: JcrNodeTypesTest.java
@Test
@FixFor("MODE-1722")
public void shouldRegisterNodeTypeWithUriPropertyType() throws Exception {
    startRepository();
    registerNodeTypes("cnd/nodetype-with-uri-property.cnd");
    NodeTypeManager ntmgr = session.getWorkspace().getNodeTypeManager();
    NodeType nt = ntmgr.getNodeType("ex:myNodeType");
    PropertyDefinition uriPropDefn = nt.getDeclaredPropertyDefinitions()[0];
    assertLocalNameAndNamespace(nt, "myNodeType", "ex");
    assertThat(uriPropDefn.getName(), is("ex:path"));
    assertThat(uriPropDefn.getRequiredType(), is(PropertyType.URI));
}

41. MockConnectorTest#shouldUpdateExternalNodeMixins()

Project: modeshape
File: MockConnectorTest.java
@Test
public void shouldUpdateExternalNodeMixins() throws Exception {
    federationManager.createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC1_LOCATION, "federated1");
    Node doc1Federated = session.getNode("/testRoot/federated1");
    Node externalNode1 = doc1Federated.addNode("federated1_1", null);
    externalNode1.addMixin("mix:created");
    session.save();
    externalNode1 = session.getNode("/testRoot/federated1/federated1_1");
    NodeType[] mixins = externalNode1.getMixinNodeTypes();
    assertEquals(1, mixins.length);
    assertEquals("mix:created", mixins[0].getName());
    externalNode1.removeMixin("mix:created");
    externalNode1.addMixin("mix:lastModified");
    session.save();
    externalNode1 = session.getNode("/testRoot/federated1/federated1_1");
    mixins = externalNode1.getMixinNodeTypes();
    assertEquals(1, mixins.length);
    assertEquals("mix:lastModified", mixins[0].getName());
}

42. PreconfiguredRepositoryIntegrationTest#shouldHavePrePublishedArtifacts()

Project: modeshape
File: PreconfiguredRepositoryIntegrationTest.java
@Test
@FixFor("MODE-1919")
public void shouldHavePrePublishedArtifacts() throws Exception {
    Session session = artifactsRepository.login();
    Node filesFolder = session.getNode("/files");
    assertNotNull(filesFolder);
    assertEquals("nt:folder", filesFolder.getPrimaryNodeType().getName());
    NodeType[] mixins = filesFolder.getMixinNodeTypes();
    assertEquals(1, mixins.length);
    assertEquals("mode:publishArea", mixins[0].getName());
    session = artifactsRepository.login("other");
    session.logout();
    session = artifactsRepository.login("extra");
    session.logout();
}

43. FederationIntegrationTest#shouldHaveJdbcMetadataSourceConfigured()

Project: modeshape
File: FederationIntegrationTest.java
@Test
public void shouldHaveJdbcMetadataSourceConfigured() throws Exception {
    Session defaultSession = repository.login();
    // predefined
    Node dbRoot = defaultSession.getNode("/ModeShapeTestDb");
    assertNotNull(dbRoot);
    assertEquals("nt:unstructured", dbRoot.getPrimaryNodeType().getName());
    assertNotNull(dbRoot.getProperty(JdbcMetadataLexicon.DATABASE_PRODUCT_NAME.toString()));
    assertNotNull(dbRoot.getProperty(JdbcMetadataLexicon.DATABASE_PRODUCT_VERSION.toString()));
    assertNotNull(dbRoot.getProperty(JdbcMetadataLexicon.DATABASE_MAJOR_VERSION.toString()));
    assertNotNull(dbRoot.getProperty(JdbcMetadataLexicon.DATABASE_MINOR_VERSION.toString()));
    for (NodeType mixin : dbRoot.getMixinNodeTypes()) {
        if (mixin.getName().equalsIgnoreCase("mj:databaseRoot")) {
            return;
        }
    }
    fail("mj:databaseRoot not found on the root database node");
}

44. NodeTypeManagerImplTest#testCreateSingleNodeTypeWithPropertyForBeanDefinitionConflict()

Project: jackrabbit-ocm
File: NodeTypeManagerImplTest.java
public void testCreateSingleNodeTypeWithPropertyForBeanDefinitionConflict() throws Exception {
    ClassDescriptor classDescriptor = new ClassDescriptor();
    classDescriptor.setClassName("test.Test14Class");
    classDescriptor.setJcrType("ocm:test14");
    classDescriptor.setJcrSuperTypes("nt:base");
    BeanDescriptor bean1 = new BeanDescriptor();
    bean1.setFieldName("a");
    bean1.setJcrName("a");
    bean1.setJcrType("String");
    classDescriptor.addBeanDescriptor(bean1);
    nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);
    NodeType test14 = getSession().getWorkspace().getNodeTypeManager().getNodeType("ocm:test14");
    assertNotNull(test14);
    // not check node type definition, assuming other tests have done that
    // assert property definition a
    PropertyDefinition propDef = getPropertyDefinition(test14.getPropertyDefinitions(), "a");
    assertNotNull(propDef);
    assertEquals(propDef.getRequiredType(), PropertyType.STRING);
}

45. NodeTypeManagerImplTest#testCreateSingleNodeTypeWithPropertyForCollectionDefinitionConflict()

Project: jackrabbit-ocm
File: NodeTypeManagerImplTest.java
public void testCreateSingleNodeTypeWithPropertyForCollectionDefinitionConflict() throws Exception {
    ClassDescriptor classDescriptor = new ClassDescriptor();
    classDescriptor.setClassName("test.Test13Class");
    classDescriptor.setJcrType("ocm:test13");
    classDescriptor.setJcrSuperTypes("nt:base");
    CollectionDescriptor collection1 = new CollectionDescriptor();
    collection1.setFieldName("a");
    collection1.setJcrName("a");
    collection1.setJcrType("String");
    classDescriptor.addCollectionDescriptor(collection1);
    nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);
    NodeType test13 = getSession().getWorkspace().getNodeTypeManager().getNodeType("ocm:test13");
    assertNotNull(test13);
    // not check node type definition, assuming other tests have done that
    // assert property definition a
    PropertyDefinition propDef = getPropertyDefinition(test13.getPropertyDefinitions(), "a");
    assertNotNull(propDef);
    assertEquals(propDef.getRequiredType(), PropertyType.STRING);
}

46. NodeTypeManagerImplTest#testCreateSingleNodeTypeWithPropertyForBean()

Project: jackrabbit-ocm
File: NodeTypeManagerImplTest.java
public void testCreateSingleNodeTypeWithPropertyForBean() throws Exception {
    ClassDescriptor classDescriptor = new ClassDescriptor();
    classDescriptor.setClassName("test.Test10Class");
    classDescriptor.setJcrType("ocm:test10");
    classDescriptor.setJcrSuperTypes("nt:base");
    BeanDescriptor bean1 = new BeanDescriptor();
    bean1.setFieldName("a");
    bean1.setJcrName("a");
    bean1.setJcrType("String");
    classDescriptor.addBeanDescriptor(bean1);
    nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);
    NodeType test10 = getSession().getWorkspace().getNodeTypeManager().getNodeType("ocm:test10");
    assertNotNull(test10);
    // not check node type definition, assuming other tests have done that
    // assert property definition a
    PropertyDefinition propDef = getPropertyDefinition(test10.getPropertyDefinitions(), "a");
    assertNotNull(propDef);
    assertEquals(propDef.getRequiredType(), PropertyType.STRING);
}

47. NodeTypeManagerImplTest#testCreateSingleNodeTypeWithPropertyForCollection()

Project: jackrabbit-ocm
File: NodeTypeManagerImplTest.java
public void testCreateSingleNodeTypeWithPropertyForCollection() throws Exception {
    ClassDescriptor classDescriptor = new ClassDescriptor();
    classDescriptor.setClassName("test.Test9Class");
    classDescriptor.setJcrType("ocm:test9");
    classDescriptor.setJcrSuperTypes("nt:base");
    CollectionDescriptor collection1 = new CollectionDescriptor();
    collection1.setFieldName("a");
    collection1.setJcrName("a");
    collection1.setJcrType("String");
    classDescriptor.addCollectionDescriptor(collection1);
    nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);
    NodeType test9 = getSession().getWorkspace().getNodeTypeManager().getNodeType("ocm:test9");
    assertNotNull(test9);
    // not check node type definition, assuming other tests have done that
    // assert property definition a
    PropertyDefinition propDef = getPropertyDefinition(test9.getPropertyDefinitions(), "a");
    assertNotNull(propDef);
    assertEquals(propDef.getRequiredType(), PropertyType.STRING);
}

48. NodeTypeManagerImplTest#testCreateSingleNodeTypeIncompleteFieldDescriptorProperties()

Project: jackrabbit-ocm
File: NodeTypeManagerImplTest.java
public void testCreateSingleNodeTypeIncompleteFieldDescriptorProperties() throws Exception {
    ClassDescriptor classDescriptor = new ClassDescriptor();
    classDescriptor.setClassName("test.Test5Class");
    classDescriptor.setJcrType("ocm:test5");
    classDescriptor.setJcrSuperTypes("ocm:test2");
    FieldDescriptor field1 = new FieldDescriptor();
    field1.setFieldName("abc");
    classDescriptor.addFieldDescriptor(field1);
    nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);
    NodeType test5 = getSession().getWorkspace().getNodeTypeManager().getNodeType("ocm:test5");
    assertNotNull(test5);
    assertFalse(test5.isMixin());
    assertEquals(test5.getName(), "ocm:test5");
    // nt:base and ocm:test2
    assertEquals(test5.getSupertypes().length, 2);
    assertTrue(containsSuperType("ocm:test2", test5.getSupertypes()));
    assertTrue(containsSuperType("nt:base", test5.getSupertypes()));
    assertTrue(containsProperty("abc", test5.getPropertyDefinitions()));
}

49. NodeTypeManagerImplTest#testCreateSingleNodeTypeNoJcrNodeTypeSet()

Project: jackrabbit-ocm
File: NodeTypeManagerImplTest.java
public void testCreateSingleNodeTypeNoJcrNodeTypeSet() throws Exception {
    ClassDescriptor classDescriptor = new ClassDescriptor();
    classDescriptor.setClassName("test.Test4Class");
    classDescriptor.setJcrSuperTypes("nt:base");
    FieldDescriptor field1 = new FieldDescriptor();
    field1.setFieldName("a");
    field1.setJcrName("a");
    field1.setJcrType("String");
    classDescriptor.addFieldDescriptor(field1);
    nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);
    NodeType test4 = getSession().getWorkspace().getNodeTypeManager().getNodeType("test.Test4Class");
    assertNotNull(test4);
    assertFalse(test4.isMixin());
    assertEquals(test4.getName(), "test.Test4Class");
    assertEquals(test4.getSupertypes().length, 1);
    assertEquals(test4.getSupertypes()[0].getName(), "nt:base");
}

50. NodeTypeManagerImplTest#testCreateSingleNodeTypeNoNamespace()

Project: jackrabbit-ocm
File: NodeTypeManagerImplTest.java
public void testCreateSingleNodeTypeNoNamespace() throws Exception {
    ClassDescriptor classDescriptor = new ClassDescriptor();
    classDescriptor.setClassName("test.Test3Class");
    classDescriptor.setJcrType("test3");
    classDescriptor.setJcrSuperTypes("nt:base");
    FieldDescriptor field1 = new FieldDescriptor();
    field1.setFieldName("a");
    field1.setJcrName("a");
    field1.setJcrType("String");
    classDescriptor.addFieldDescriptor(field1);
    nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);
    NodeType test3 = getSession().getWorkspace().getNodeTypeManager().getNodeType("test3");
    assertNotNull(test3);
    assertFalse(test3.isMixin());
    assertEquals(test3.getName(), "test3");
    assertEquals(test3.getSupertypes().length, 1);
    assertEquals(test3.getSupertypes()[0].getName(), "nt:base");
}

51. ObjectConverterImpl#getActualNode()

Project: jackrabbit-ocm
File: ObjectConverterImpl.java
private Node getActualNode(Session session, Node node) throws RepositoryException {
    NodeType type = node.getPrimaryNodeType();
    if (type.getName().equals("nt:versionedChild")) {
        String uuid = node.getProperty("jcr:childVersionHistory").getValue().getString();
        Node actualNode = session.getNodeByIdentifier(uuid);
        String name = actualNode.getName();
        actualNode = session.getNodeByIdentifier(name);
        return actualNode;
    }
    return node;
}

52. ObjectConverterImpl#checkCompatibleNodeTypes()

Project: jackrabbit-ocm
File: ObjectConverterImpl.java
/**
	 * Node types compatibility check.
	 *
	 * @param nodeType
	 *            target node type
	 * @param descriptor
	 *            descriptor containing source node type
	 * @return <tt>true</tt> if nodes are considered compatible,
	 *         <tt>false</tt> otherwise
	 */
private boolean checkCompatibleNodeTypes(NodeType nodeType, ClassDescriptor descriptor) {
    //return true if node type is not used
    if (descriptor.getJcrType() == null || descriptor.getJcrType().equals("")) {
        return true;
    }
    if (nodeType.getName().equals(descriptor.getJcrType())) {
        return true;
    }
    NodeType[] superTypes = nodeType.getSupertypes();
    for (int i = 0; i < superTypes.length; i++) {
        if (superTypes[i].getName().equals(descriptor.getJcrType())) {
            return true;
        }
    }
    return false;
}

53. CopyNodeTypesUpgradeTest#customNodeTypesAreRegistered()

Project: jackrabbit-oak
File: CopyNodeTypesUpgradeTest.java
@Test
public void customNodeTypesAreRegistered() throws RepositoryException {
    final JackrabbitSession adminSession = createAdminSession();
    final NodeTypeManager nodeTypeManager = adminSession.getWorkspace().getNodeTypeManager();
    final NodeType testFolderNodeType = nodeTypeManager.getNodeType("test:Folder");
    final NodeDefinition[] cnd = testFolderNodeType.getChildNodeDefinitions();
    final PropertyDefinition[] pd = testFolderNodeType.getPropertyDefinitions();
    assertEquals("More than one child node definition", 1, cnd.length);
    assertEquals("Incorrect default primary type", "test:Folder", cnd[0].getDefaultPrimaryTypeName());
    assertEquals("More than two property definitions", 4, pd.length);
    adminSession.logout();
}

54. ReadNodeTypeTest#testGetMixinFromNewNode()

Project: jackrabbit-oak
File: ReadNodeTypeTest.java
/**
     * @see <a href="https://issues.apache.org/jira/browse/OAK-2488">OAK-2488</a>
     */
public void testGetMixinFromNewNode() throws Exception {
    superuser.getNode(path).addMixin(JcrConstants.MIX_LOCKABLE);
    superuser.save();
    deny(path, privilegesFromName(PrivilegeConstants.REP_READ_PROPERTIES));
    testSession.getNode(path).remove();
    Node newNode = testSession.getNode(testRoot).addNode(Text.getName(path));
    assertFalse(newNode.hasProperty(JcrConstants.JCR_MIXINTYPES));
    NodeType[] mixins = newNode.getMixinNodeTypes();
    assertEquals(0, mixins.length);
}

55. ReadNodeTypeTest#testNodeGetMixinTypes()

Project: jackrabbit-oak
File: ReadNodeTypeTest.java
/**
     * @see <a href="https://issues.apache.org/jira/browse/OAK-2441">OAK-2441</a>
     */
public void testNodeGetMixinTypes() throws Exception {
    superuser.getNode(path).addMixin(JcrConstants.MIX_LOCKABLE);
    superuser.save();
    assertTrue(testSession.propertyExists(path + '/' + JcrConstants.JCR_MIXINTYPES));
    deny(path, privilegesFromName(PrivilegeConstants.REP_READ_PROPERTIES));
    assertFalse(testSession.propertyExists(path + '/' + JcrConstants.JCR_MIXINTYPES));
    Node n = testSession.getNode(path);
    assertFalse(n.hasProperty(JcrConstants.JCR_MIXINTYPES));
    int noMixins = superuser.getNode(path).getMixinNodeTypes().length;
    NodeType[] mixins = n.getMixinNodeTypes();
    assertEquals(noMixins, mixins.length);
}

56. RepositoryTest#importNodeType()

Project: jackrabbit-oak
File: RepositoryTest.java
// Regression test for OAK-299
@Test
public void importNodeType() throws RepositoryException, IOException, ParseException {
    Session session = getAdminSession();
    NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
    if (!manager.hasNodeType("myNodeType")) {
        StringBuilder defs = new StringBuilder();
        defs.append("[\"myNodeType\"]\n");
        defs.append("  - prop1\n");
        defs.append("  + * (nt:base) = nt:unstructured \n");
        Reader cndReader = new InputStreamReader(new ByteArrayInputStream(defs.toString().getBytes()));
        CndImporter.registerNodeTypes(cndReader, session);
    }
    NodeType myNodeType = manager.getNodeType("myNodeType");
    assertTrue(myNodeType.isNodeType("nt:base"));
}

57. CRUDTest#testMixins()

Project: jackrabbit-oak
File: CRUDTest.java
/**
     * @see <a href="https://issues.apache.org/jira/browse/OAK-2488">OAK-2488</a>
     */
@Test
public void testMixins() throws Exception {
    Session session = getAdminSession();
    String nodename = "mixintest";
    Node mixinTest = session.getRootNode().addNode(nodename, "nt:folder");
    NodeType[] types;
    types = mixinTest.getMixinNodeTypes();
    assertEquals(Arrays.toString(types), 0, types.length);
    mixinTest.addMixin("mix:versionable");
    types = mixinTest.getMixinNodeTypes();
    assertEquals(Arrays.toString(types), 1, types.length);
    session.save();
    mixinTest = session.getRootNode().getNode(nodename);
    mixinTest.remove();
    mixinTest = session.getRootNode().addNode(nodename, "nt:folder");
    types = mixinTest.getMixinNodeTypes();
    assertEquals(Arrays.toString(types), 0, types.length);
}

58. NodeImpl#internalSetPrimaryType()

Project: jackrabbit-oak
File: NodeImpl.java
private void internalSetPrimaryType(final String nodeTypeName) throws RepositoryException {
    // TODO: figure out the right place for this check
    // throws on not found
    NodeType nt = getNodeTypeManager().getNodeType(nodeTypeName);
    if (nt.isAbstract() || nt.isMixin()) {
        throw new ConstraintViolationException(getNodePath());
    }
    // TODO: END
    PropertyState state = PropertyStates.createProperty(JCR_PRIMARYTYPE, getOakName(nodeTypeName), NAME);
    dlg.setProperty(state, true, true);
    dlg.setOrderableChildren(nt.hasOrderableChildNodes());
}

59. NodeTypeImpl#getDeclaredSupertypes()

Project: jackrabbit-oak
File: NodeTypeImpl.java
@Override
public NodeType[] getDeclaredSupertypes() {
    NodeType[] supertypes = NO_NODE_TYPES;
    String[] oakNames = getNames(JCR_SUPERTYPES);
    if (oakNames != null && oakNames.length > 0) {
        supertypes = new NodeType[oakNames.length];
        Tree root = definition.getParent();
        for (int i = 0; i < oakNames.length; i++) {
            Tree type = root.getChild(oakNames[i]);
            checkState(type.exists());
            supertypes[i] = new NodeTypeImpl(type, mapper);
        }
    }
    return supertypes;
}

60. NodeDefinitionImpl#getRequiredPrimaryTypes()

Project: jackrabbit-oak
File: NodeDefinitionImpl.java
@Override
public NodeType[] getRequiredPrimaryTypes() {
    String[] oakNames = getNames(JcrConstants.JCR_REQUIREDPRIMARYTYPES);
    if (oakNames == null) {
        oakNames = new String[] { JcrConstants.NT_BASE };
    }
    NodeType[] types = new NodeType[oakNames.length];
    Tree root = definition.getParent();
    while (!JCR_NODE_TYPES.equals(root.getName())) {
        root = root.getParent();
    }
    for (int i = 0; i < oakNames.length; i++) {
        Tree type = root.getChild(oakNames[i]);
        checkState(type.exists());
        types[i] = new NodeTypeImpl(type, mapper);
    }
    return types;
}

61. EffectiveNodeType#checkMandatoryItems()

Project: jackrabbit-oak
File: EffectiveNodeType.java
public void checkMandatoryItems(Tree tree) throws ConstraintViolationException {
    for (NodeType nodeType : nodeTypes.values()) {
        for (PropertyDefinition pd : nodeType.getPropertyDefinitions()) {
            String name = pd.getName();
            if (pd.isMandatory() && !pd.isProtected() && tree.getProperty(name) == null) {
                throw new ConstraintViolationException("Property '" + name + "' in '" + nodeType.getName() + "' is mandatory");
            }
        }
        for (NodeDefinition nd : nodeType.getChildNodeDefinitions()) {
            String name = nd.getName();
            if (nd.isMandatory() && !nd.isProtected() && !tree.hasChild(name)) {
                throw new ConstraintViolationException("Node '" + name + "' in '" + nodeType.getName() + "' is mandatory");
            }
        }
    }
}

62. EffectiveNodeType#checkSetProperty()

Project: jackrabbit-oak
File: EffectiveNodeType.java
public void checkSetProperty(PropertyState property) throws RepositoryException {
    PropertyDefinition definition = getDefinition(property);
    if (definition.isProtected()) {
        return;
    }
    NodeType nt = definition.getDeclaringNodeType();
    if (definition.isMultiple()) {
        List<Value> values = ValueFactoryImpl.createValues(property, ntMgr.getNamePathMapper());
        if (!nt.canSetProperty(property.getName(), values.toArray(new Value[values.size()]))) {
            throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + values + '\'');
        }
    } else {
        Value v = ValueFactoryImpl.createValue(property, ntMgr.getNamePathMapper());
        if (!nt.canSetProperty(property.getName(), v)) {
            throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + v + '\'');
        }
    }
}

63. EffectiveNodeType#supportsMixin()

Project: jackrabbit-oak
File: EffectiveNodeType.java
/**
     * Determines whether this effective node type supports adding
     * the specified mixin.
     * @param mixin name of mixin type
     * @return {@code true} if the mixin type is supported, otherwise {@code false}
     */
public boolean supportsMixin(String mixin) {
    if (includesNodeType(mixin)) {
        return true;
    }
    NodeType mixinType = null;
    try {
        mixinType = ntMgr.internalGetNodeType(mixin);
        if (!mixinType.isMixin() || mixinType.isAbstract()) {
            return false;
        }
    } catch (NoSuchNodeTypeException e) {
        log.debug("Unknown mixin type " + mixin);
    }
    return true;
}

64. AbstractNodeType#getDeclaredSupertypes()

Project: jackrabbit
File: AbstractNodeType.java
/**
     * {@inheritDoc}
     */
public NodeType[] getDeclaredSupertypes() {
    Name[] ntNames = ntd.getSupertypes();
    NodeType[] supertypes = new NodeType[ntNames.length];
    for (int i = 0; i < ntNames.length; i++) {
        try {
            supertypes[i] = ntMgr.getNodeType(ntNames[i]);
        } catch (NoSuchNodeTypeException e) {
            log.error("undefined supertype", e);
            return new NodeType[0];
        }
    }
    return supertypes;
}

65. NodeTypeImplTest#testIsNodeType()

Project: jackrabbit
File: NodeTypeImplTest.java
public void testIsNodeType() throws RepositoryException {
    NodeType[] superTypes = nodeType.getSupertypes();
    for (int i = 0; i < superTypes.length; i++) {
        String name = superTypes[i].getName();
        assertTrue(nodeType.isNodeType(resolver.getQName(name)));
    }
    // unknown nt
    String unknownName = "unknown";
    assertFalse(nodeType.isNodeType(unknownName));
    // all non-mixin node types must be derived from nt base.
    if (!nodeType.isMixin()) {
        assertTrue(nodeType.isNodeType("nt:base"));
    }
}

66. NodeTypeImplTest#setUp()

Project: jackrabbit
File: NodeTypeImplTest.java
@Override
protected void setUp() throws Exception {
    super.setUp();
    ntMgr = superuser.getWorkspace().getNodeTypeManager();
    NodeType nt = ntMgr.getNodeType(testNodeType);
    if (nt instanceof NodeTypeImpl) {
        nodeType = (NodeTypeImpl) nt;
    } else {
        cleanUp();
        throw new NotExecutableException("NodeTypeImpl expected.");
    }
    if (superuser instanceof NameResolver) {
        resolver = (NameResolver) superuser;
    } else {
        cleanUp();
        throw new NotExecutableException();
    }
}

67. MandatoryItemTest#setUp()

Project: jackrabbit
File: MandatoryItemTest.java
@Override
protected void setUp() throws Exception {
    super.setUp();
    NodeType nt = superuser.getWorkspace().getNodeTypeManager().getNodeType(testNodeType);
    NodeDefinition[] ndefs = nt.getChildNodeDefinitions();
    for (int i = 0; i < ndefs.length; i++) {
        if (ndefs[i].isMandatory() && !ndefs[i].isProtected() && !ndefs[i].isAutoCreated()) {
            childNodeDef = ndefs[i];
            break;
        }
    }
    PropertyDefinition[] pdefs = nt.getPropertyDefinitions();
    for (int i = 0; i < pdefs.length; i++) {
        if (pdefs[i].isMandatory() && !pdefs[i].isProtected() && !pdefs[i].isAutoCreated()) {
            childPropDef = pdefs[i];
            break;
        }
    }
    if (childPropDef == null && childNodeDef == null) {
        cleanUp();
        throw new NotExecutableException();
    }
}

68. AddMixinTest#testImplicitMixinOnNewNode()

Project: jackrabbit
File: AddMixinTest.java
/**
     * Implementation specific test adding a new Node with a nodeType, that has
     * a mixin-supertype. The mixin must only take effect upon save.
     *
     * @throws NotExecutableException
     * @throws RepositoryException
     */
public void testImplicitMixinOnNewNode() throws NotExecutableException, RepositoryException {
    Node newNode;
    try {
        String ntResource = superuser.getNamespacePrefix(NS_NT_URI) + ":resource";
        newNode = testRootNode.addNode(nodeName1, ntResource);
    } catch (RepositoryException e) {
        throw new NotExecutableException();
    }
    assertFalse("Implict Mixin inherited by primary Nodetype must not be active before Node has been saved.", newNode.isNodeType(mixReferenceable));
    NodeType[] mixins = newNode.getMixinNodeTypes();
    for (int i = 0; i < mixins.length; i++) {
        if (mixins[i].getName().equals(testNodeType)) {
            fail("Implict Mixin inherited by primary Nodetype must not be active before Node has been saved.");
        }
    }
}

69. AddMixinTest#testAddMixinToNewNode()

Project: jackrabbit
File: AddMixinTest.java
/**
     * Implementation specific test for 'addMixin' only taking effect upon
     * save.
     *
     * @throws NotExecutableException
     * @throws RepositoryException
     */
public void testAddMixinToNewNode() throws NotExecutableException, RepositoryException {
    Node newNode;
    try {
        newNode = testRootNode.addNode(nodeName1, testNodeType);
        newNode.addMixin(mixReferenceable);
    } catch (RepositoryException e) {
        throw new NotExecutableException();
    }
    assertFalse("Mixin must not be active before Node has been saved.", newNode.isNodeType(mixReferenceable));
    NodeType[] mixins = newNode.getMixinNodeTypes();
    for (int i = 0; i < mixins.length; i++) {
        if (mixins[i].getName().equals(testNodeType)) {
            fail("Mixin must not be active before Node has been saved.");
        }
    }
}

70. NodeTypeImpl#getSupertypes()

Project: jackrabbit
File: NodeTypeImpl.java
//-----------------------------------------------------------< NodeType >---
/**
     * @see javax.jcr.nodetype.NodeType#getSupertypes()
     */
public NodeType[] getSupertypes() {
    Name[] ntNames = ent.getInheritedNodeTypes();
    NodeType[] supertypes = new NodeType[ntNames.length];
    for (int i = 0; i < ntNames.length; i++) {
        try {
            supertypes[i] = ntMgr.getNodeType(ntNames[i]);
        } catch (NoSuchNodeTypeException e) {
            log.error("undefined supertype", e);
            return new NodeType[0];
        }
    }
    return supertypes;
}

71. NodeImpl#setPrimaryType()

Project: jackrabbit
File: NodeImpl.java
/**
     * @see javax.jcr.Node#setPrimaryType(String)
     */
public void setPrimaryType(String nodeTypeName) throws RepositoryException {
    checkStatus();
    if (getNodeState().isRoot()) {
        String msg = "The primary type of the root node may not be changed.";
        log.debug(msg);
        throw new RepositoryException(msg);
    }
    Name ntName = getQName(nodeTypeName);
    if (ntName.equals(getPrimaryNodeTypeName())) {
        log.debug("Changing the primary type has no effect: '" + nodeTypeName + "' already is the primary node type.");
        return;
    }
    NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
    NodeType nt = ntMgr.getNodeType(ntName);
    if (nt.isMixin() || nt.isAbstract()) {
        throw new ConstraintViolationException("Cannot change the primary type: '" + nodeTypeName + "' is a mixin type or abstract.");
    }
    // perform the operation
    Operation op = SetPrimaryType.create(getNodeState(), ntName);
    session.getSessionItemStateManager().execute(op);
}

72. ConfigurationsTest#testCreateConfiguration()

Project: jackrabbit
File: ConfigurationsTest.java
public void testCreateConfiguration() throws Exception {
    Node config = vm.createConfiguration(versionableNode.getPath());
    assertNotNull(config);
    NodeType nt = config.getPrimaryNodeType();
    assertTrue("created node must be subtype of nt:configuration", nt.isNodeType(ntConfiguration));
    // check if the configuration points to the versionable
    assertTrue("jcr:root property of the configuration must reference the versionable node", config.getProperty("jcr:root").getNode().isSame(versionableNode));
    // check if the versionable points to the configuration
    assertTrue("jcr:configuration property of the versionable node must reference the configuration", versionableNode.getProperty("jcr:configuration").getNode().isSame(config));
}

73. SameNodeTest#testChildNodesDoNotMatchSelector()

Project: jackrabbit
File: SameNodeTest.java
public void testChildNodesDoNotMatchSelector() throws RepositoryException, NotExecutableException {
    testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
    NodeType testNt = ntMgr.getNodeType(testNodeType);
    while (it.hasNext()) {
        NodeType nt = it.nextNodeType();
        if (!testNt.isNodeType(nt.getName())) {
            // perform test
            QueryObjectModel qom = qf.createQuery(qf.selector(nt.getName(), "s"), qf.sameNode("s", testRoot + "/" + nodeName1), null, null);
            checkQOM(qom, new Node[] {});
            return;
        }
    }
    throw new NotExecutableException("No suitable node type found to " + "perform test against '" + testNodeType + "' nodes");
}

74. DescendantNodeTest#testDescendantNodesDoNotMatchSelector()

Project: jackrabbit
File: DescendantNodeTest.java
public void testDescendantNodesDoNotMatchSelector() throws RepositoryException, NotExecutableException {
    testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
    NodeType testNt = ntMgr.getNodeType(testNodeType);
    while (it.hasNext()) {
        NodeType nt = it.nextNodeType();
        if (!testNt.isNodeType(nt.getName())) {
            // perform test
            QueryObjectModel qom = qf.createQuery(qf.selector(nt.getName(), "s"), qf.descendantNode("s", testRoot), null, null);
            checkQOM(qom, new Node[] {});
            return;
        }
    }
    throw new NotExecutableException("No suitable node type found to " + "perform test against '" + testNodeType + "' nodes");
}

75. ChildNodeTest#testChildNodesDoNotMatchSelector()

Project: jackrabbit
File: ChildNodeTest.java
public void testChildNodesDoNotMatchSelector() throws RepositoryException, NotExecutableException {
    testRootNode.addNode(nodeName1, testNodeType);
    superuser.save();
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
    NodeType testNt = ntMgr.getNodeType(testNodeType);
    while (it.hasNext()) {
        NodeType nt = it.nextNodeType();
        if (!testNt.isNodeType(nt.getName())) {
            // perform test
            QueryObjectModel qom = qf.createQuery(qf.selector(nt.getName(), "s"), qf.childNode("s", testRoot), null, null);
            checkQOM(qom, new Node[] {});
            return;
        }
    }
    throw new NotExecutableException("No suitable node type found to " + "perform test against '" + testNodeType + "' nodes");
}

76. AbstractQueryLevel2Test#setUpMultiValueTest()

Project: jackrabbit
File: AbstractQueryLevel2Test.java
/**
     * Creates three nodes with names: {@link #nodeName1}, {@link #nodeName2}
     * and {@link #nodeName3}. All nodes are of node type {@link #testNodeType}.
     * the node type must allow a String property with name {@link
     * #propertyName1} and a multi valued String property with name {@link
     * #propertyName2}.
     * <p>
     * If the node type does not support multi values for {@link #propertyName2}
     * a {@link org.apache.jackrabbit.test.NotExecutableException} is thrown.
     */
protected void setUpMultiValueTest() throws RepositoryException, NotExecutableException {
    // check if NodeType supports mvp
    NodeType nt = superuser.getWorkspace().getNodeTypeManager().getNodeType(testNodeType);
    Value[] testValue = new Value[] { superuser.getValueFactory().createValue("one"), superuser.getValueFactory().createValue("two"), superuser.getValueFactory().createValue("three") };
    if (!nt.canSetProperty(propertyName2, testValue)) {
        throw new NotExecutableException("Property " + propertyName2 + " of NodeType " + testNodeType + " does not allow multi values");
    }
    Node node = testRootNode.addNode(nodeName1, testNodeType);
    node.setProperty(propertyName1, "existence");
    node.setProperty(propertyName2, testValue);
    node = testRootNode.addNode(nodeName2, testNodeType);
    node.setProperty(propertyName1, "nonexistence");
    node.setProperty(propertyName2, new String[] { "one", "three" });
    Node cNode = node.addNode(nodeName3, testNodeType);
    cNode.setProperty(propertyName1, "existence");
    testRootNode.getSession().save();
}

77. NodeTypeTest#testGetPrimaryItemNameNotExisting()

Project: jackrabbit
File: NodeTypeTest.java
/**
     * Test if node.getPrimaryItemName() returns null if no primary item is
     * defined
     */
public void testGetPrimaryItemNameNotExisting() throws NotExecutableException, RepositoryException {
    Node node = locateNodeWithoutPrimaryItem(rootNode);
    if (node == null) {
        throw new NotExecutableException("Workspace does not contain a node without primary item defined");
    }
    NodeType type = node.getPrimaryNodeType();
    assertNull("getPrimaryItemName() must return null if NodeType " + "does not define a primary item", type.getPrimaryItemName());
}

78. NodeTypeTest#testGetPrimaryItemName()

Project: jackrabbit
File: NodeTypeTest.java
/**
     * Test if node.getPrimaryItemName() returns the same name as
     * node.getPrimaryItem().getName()
     */
public void testGetPrimaryItemName() throws NotExecutableException, RepositoryException {
    Node node = locateNodeWithPrimaryItem(rootNode);
    if (node == null) {
        throw new NotExecutableException("Workspace does not contain a node with primary item defined");
    }
    String name = node.getPrimaryItem().getName();
    NodeType type = node.getPrimaryNodeType();
    assertEquals("node.getPrimaryNodeType().getPrimaryItemName() " + "must return the same name as " + "node.getPrimaryItem().getName()", name, type.getPrimaryItemName());
}

79. NodeTypeManagerTest#testGetNodeType()

Project: jackrabbit
File: NodeTypeManagerTest.java
/**
     * Test if getNodeType(String nodeTypeName) returns the expected NodeType and
     * if a NoSuchTypeException is thrown if no according node type is existing
     */
public void testGetNodeType() throws RepositoryException {
    NodeType type = manager.getAllNodeTypes().nextNodeType();
    assertEquals("getNodeType(String nodeTypeName) does not return correct " + "NodeType", manager.getNodeType(type.getName()).getName(), type.getName());
    StringBuffer notExistingName = new StringBuffer("X");
    NodeTypeIterator types = manager.getAllNodeTypes();
    while (types.hasNext()) {
        // build a name which is for sure not existing
        // (":" of namespace prefix will be replaced later on)
        notExistingName.append(types.nextNodeType().getName());
    }
    try {
        manager.getNodeType(notExistingName.toString().replaceAll(":", ""));
        fail("getNodeType(String nodeTypeName) must throw a " + "NoSuchNodeTypeException if no according NodeType " + "does exist");
    } catch (NoSuchNodeTypeException e) {
    }
}

80. NodeDefTest#compareWithRequiredType()

Project: jackrabbit
File: NodeDefTest.java
/**
     * Returns true if defaultType or one of its supertypes is of the same
     * NodeType as requiredType.
     *
     * @param requiredType one of the required primary types of a NodeDef
     * @param defaultType  the default primary type of a NodeDef
     */
private boolean compareWithRequiredType(NodeType requiredType, NodeType defaultType) {
    // rather use:
    if (defaultType.getName().equals(requiredType.getName())) {
        return true;
    }
    NodeType superTypes[] = defaultType.getSupertypes();
    for (int i = 0; i < superTypes.length; i++) {
        // rather use:
        if (superTypes[i].getName().equals(requiredType.getName())) {
            return true;
        }
    }
    return false;
}

81. CanSetPropertyTest#testValueNull()

Project: jackrabbit
File: CanSetPropertyTest.java
/**
     * Tests if canSetProperty(String propertyName, Value value) where value is
     * null returns the same as canRemoveItem
     */
public void testValueNull() throws NotExecutableException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, false, false, false, false);
    if (propDef == null) {
        throw new NotExecutableException("No not protected property def found.");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertEquals("nodeType.canSetProperty(String propertyName, Value value) " + "where value is null must return the same result as " + "nodeType.canRemoveItem(String propertyName).", nodeType.canRemoveItem(propDef.getName()), nodeType.canSetProperty(propDef.getName(), (Value) null));
}

82. CanSetPropertyTest#testReturnFalseBecauseIsMultiple()

Project: jackrabbit
File: CanSetPropertyTest.java
/**
     * Tests if NodeType.canSetProperty(String propertyName, Value value)
     * returns false if the property is multiple
     */
public void testReturnFalseBecauseIsMultiple() throws NotExecutableException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, true, false, false, false);
    if (propDef == null) {
        throw new NotExecutableException("No multiple, not protected property def found.");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value value = NodeTypeUtil.getValueOfType(superuser, propDef.getRequiredType());
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if the property is multiple.", nodeType.canSetProperty(propDef.getName(), value));
}

83. CanSetPropertyTest#testReturnFalseBecauseIsProtected()

Project: jackrabbit
File: CanSetPropertyTest.java
/**
     * Tests if NodeType.canSetProperty(String propertyName, Value value)
     * returns false if the property is protected.
     */
public void testReturnFalseBecauseIsProtected() throws NotExecutableException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, false, true, false, false);
    // will never happen since at least jcr:primaryType of nt:base accomplish the request
    if (propDef == null) {
        throw new NotExecutableException("No protected property def found.");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value value = NodeTypeUtil.getValueOfType(superuser, propDef.getRequiredType());
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if the property is protected.", nodeType.canSetProperty(propDef.getName(), value));
}

84. CanSetPropertyStringTest#testValueConstraintNotSatisfiedMultiple()

Project: jackrabbit
File: CanSetPropertyStringTest.java
/**
     * Tests if canSetProperty(String propertyName, Value[] values) returns
     * false if values do not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.STRING, true, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No multiple string property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No multiple string property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value values[] = new Value[] { value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values));
}

85. CanSetPropertyStringTest#testValueConstraintNotSatisfied()

Project: jackrabbit
File: CanSetPropertyStringTest.java
/**
     * Tests if canSetProperty(String propertyName, Value value) returns false
     * if value does not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.STRING, false, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No string property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No string property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value));
}

86. CanSetPropertyPathTest#testValueConstraintNotSatisfiedMultiple()

Project: jackrabbit
File: CanSetPropertyPathTest.java
/**
     * Tests if canSetProperty(String propertyName, Value[] values) returns
     * false if values do not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.PATH, true, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No multiple path property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No multiple path property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value values[] = new Value[] { value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values));
}

87. CanSetPropertyPathTest#testValueConstraintNotSatisfied()

Project: jackrabbit
File: CanSetPropertyPathTest.java
/**
     * Tests if canSetProperty(String propertyName, Value value) returns false
     * if value does not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.PATH, false, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No path property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No path property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value));
}

88. CanSetPropertyNameTest#testValueConstraintNotSatisfiedMultiple()

Project: jackrabbit
File: CanSetPropertyNameTest.java
/**
     * Tests if canSetProperty(String propertyName, Value[] values) returns
     * false if values do not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.NAME, true, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No multiple name property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No multiple name property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value values[] = new Value[] { value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values));
}

89. CanSetPropertyNameTest#testValueConstraintNotSatisfied()

Project: jackrabbit
File: CanSetPropertyNameTest.java
/**
     * Tests if canSetProperty(String propertyName, Value value) returns false
     * if value does not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.NAME, false, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No name property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No name property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value));
}

90. CanSetPropertyMultipleTest#testMultipleValuesNull()

Project: jackrabbit
File: CanSetPropertyMultipleTest.java
/**
     * Tests if canSetProperty(String propertyName, Value[] values) where values
     * is null returns the same as canRemoveItem
     */
public void testMultipleValuesNull() throws NotExecutableException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, true, false, false, false);
    if (propDef == null) {
        throw new NotExecutableException("No not protected, multiple property def found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertEquals("nodeType.canSetProperty(String propertyName, Value[] values) " + "where values is null must return the same result as " + "nodeType.canRemoveItem(String propertyName)", nodeType.canRemoveItem(propDef.getName()), nodeType.canSetProperty(propDef.getName(), (Value[]) null));
}

91. CanSetPropertyMultipleTest#testReturnFalseBecauseIsNotMultiple()

Project: jackrabbit
File: CanSetPropertyMultipleTest.java
/**
     * Tests if NodeType.canSetProperty(String propertyName, Value[] values)
     * returns false if the property is not multiple
     */
public void testReturnFalseBecauseIsNotMultiple() throws NotExecutableException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, false, false, false, false);
    if (propDef == null) {
        throw new NotExecutableException("No not multiple, not protected property def found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value value = NodeTypeUtil.getValueOfType(superuser, propDef.getRequiredType());
    Value values[] = new Value[] { value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if the property is not multiple", nodeType.canSetProperty(propDef.getName(), values));
}

92. CanSetPropertyMultipleTest#testReturnFalseBecauseIsProtected()

Project: jackrabbit
File: CanSetPropertyMultipleTest.java
/**
     * Tests if NodeType.canSetProperty(String propertyName, Value[] values)
     * returns false if the property is protected.
     */
public void testReturnFalseBecauseIsProtected() throws NotExecutableException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, true, true, false, false);
    // will never happen since at least jcr:mixinTypes of nt:base accomplish the request
    if (propDef == null) {
        throw new NotExecutableException("No protected, multiple property def found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value value = NodeTypeUtil.getValueOfType(superuser, propDef.getRequiredType());
    Value values[] = new Value[] { value, value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return true if the property is protected.", nodeType.canSetProperty(propDef.getName(), values));
}

93. CanSetPropertyLongTest#testValueConstraintNotSatisfiedMultiple()

Project: jackrabbit
File: CanSetPropertyLongTest.java
/**
     * Tests if canSetProperty(String propertyName, Value[] values) returns
     * false if values do not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.LONG, true, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No multiple long property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No multiple long property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value values[] = new Value[] { value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values));
}

94. CanSetPropertyLongTest#testValueConstraintNotSatisfied()

Project: jackrabbit
File: CanSetPropertyLongTest.java
/**
     * Tests if canSetProperty(String propertyName, Value value) returns false
     * if value does not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.LONG, false, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No long property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No long property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value));
}

95. CanSetPropertyDoubleTest#testValueConstraintNotSatisfiedMultiple()

Project: jackrabbit
File: CanSetPropertyDoubleTest.java
/**
     * Tests if canSetProperty(String propertyName, Value[] values) returns
     * false if values do not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, true, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No multiple double property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No multiple double property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value values[] = new Value[] { value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values));
}

96. CanSetPropertyDoubleTest#testValueConstraintNotSatisfied()

Project: jackrabbit
File: CanSetPropertyDoubleTest.java
/**
     * Tests if canSetProperty(String propertyName, Value value) returns false
     * if value does not satsfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, false, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No double property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No double property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value));
}

97. CanSetPropertyDateTest#testValueConstraintNotSatisfiedMultiple()

Project: jackrabbit
File: CanSetPropertyDateTest.java
/**
     * Tests if canSetProperty(String propertyName, Value[] values) returns
     * false if values do not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.DATE, true, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No multiple date property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No multiple date property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value values[] = new Value[] { value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values));
}

98. CanSetPropertyDateTest#testValueConstraintNotSatisfied()

Project: jackrabbit
File: CanSetPropertyDateTest.java
/**
     * Tests if canSetProperty(String propertyName, Value value) returns false
     * if value does not match the value constraints of the property def
     */
public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.DATE, false, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No date property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No date property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value));
}

99. CanSetPropertyBooleanTest#testValueConstraintNotSatisfiedMultiple()

Project: jackrabbit
File: CanSetPropertyBooleanTest.java
/**
     * Tests if canSetProperty(String propertyName, Value[] values) returns
     * false if values do not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, true, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No multiple boolean property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No multiple boolean property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    Value values[] = new Value[] { value };
    assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values));
}

100. CanSetPropertyBooleanTest#testValueConstraintNotSatisfied()

Project: jackrabbit
File: CanSetPropertyBooleanTest.java
/**
     * Tests if canSetProperty(String propertyName, Value value) returns false
     * if value does not satisfy the value constraints of the property def
     */
public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException {
    PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, false, false, true, false);
    if (propDef == null) {
        throw new NotExecutableException("No boolean property def with " + "testable value constraints has been found");
    }
    Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false);
    if (value == null) {
        throw new NotExecutableException("No boolean property def with " + "testable value constraints has been found");
    }
    NodeType nodeType = propDef.getDeclaringNodeType();
    assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value));
}