Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeType


    }

    @Test
    public void shouldNotAllowInvalidPathValues() throws Exception {
        NodeType constrainedType = validateTypeDefinition();
        JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_PATH);

        Value[] values = new Value[] {valueFor("b", PropertyType.PATH), valueFor("/a/b/c/d", PropertyType.PATH),};
        assertThat(satisfiesConstraints(prop, new Value[] {valueFor("/a", PropertyType.PATH)}), is(false));
        assertThat(satisfiesConstraints(prop, values), is(false));
View Full Code Here


        assertThat(satisfiesConstraints(prop, values), is(false));
    }

    @Test
    public void shouldAllowValidReferenceValue() throws Exception {
        NodeType constrainedType = validateTypeDefinition();
        JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE);

        Value value = session.getValueFactory().createValue(session.getRootNode());

        assertThat(prop.satisfiesConstraints(value), is(true));
View Full Code Here

        assertThat(prop.satisfiesConstraints(value), is(true));
    }

    @Test
    public void shouldAllowValidReferenceValues() throws Exception {
        NodeType constrainedType = validateTypeDefinition();
        JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE);

        Value value = session.getValueFactory().createValue(session.getRootNode());

        assertThat(satisfiesConstraints(prop, new Value[] {}), is(true));
View Full Code Here

        assertThat(satisfiesConstraints(prop, new Value[] {value}), is(true));
    }

    @Test
    public void shouldNotAllowInvalidReferenceValue() throws Exception {
        NodeType constrainedType = validateTypeDefinition();
        JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE);

        Value value = session.getValueFactory().createValue(session.getRootNode().getNode("a"));

        assertThat(prop.satisfiesConstraints(value), is(false));
View Full Code Here

        assertThat(prop.satisfiesConstraints(value), is(false));
    }

    @Test
    public void shouldNotAllowInvalidReferenceValues() throws Exception {
        NodeType constrainedType = validateTypeDefinition();
        JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE);

        Value value = session.getValueFactory().createValue(session.getRootNode().getNode("a"));

        assertThat(satisfiesConstraints(prop, new Value[] {value}), is(false));
View Full Code Here

     * Primary-type and -item methods
     */

    @Test
    public void shouldReturnItemFromGetPrimaryNodeType() throws Exception {
        NodeType carType = nodeTypes.getNodeType("vehix:car");
        assertThat(carType, is(notNullValue()));
        assertThat(prius.getPrimaryNodeType(), is(carType));
    }
View Full Code Here

        assertThat(prius.getPrimaryNodeType(), is(carType));
    }

    @Test
    public void shouldReturnItemFromGetPrimaryItemIfItExists() throws Exception {
        NodeType carType = nodeTypes.getNodeType("vehix:car");
        assertThat(carType, is(notNullValue()));
        assertThat(carType.getPrimaryItemName(), is("vehix:model"));
        assertThat(prius.getPrimaryItem(), is(sameInstance((Item)prius.getProperty("vehix:model"))));
    }
View Full Code Here

    }

    @Test( expected = ItemNotFoundException.class )
    public void shouldFailToReturnItemFromGetPrimaryItemIfPrimaryTypeDoesNotHavePrimaryItemName() throws Exception {
        // Get nt:unstructured and verify it has no primary item name ...
        NodeType ntUnstructured = nodeTypes.getNodeType("nt:unstructured");
        assertThat(ntUnstructured, is(notNullValue()));
        assertThat(ntUnstructured.getPrimaryItemName(), is(nullValue()));

        // Now check using a node that has the "nt:unstructured" primary type ...
        cars.getPrimaryItem();
    }
View Full Code Here

    @Test( expected = ItemNotFoundException.class )
    public void shouldFailToReturnItemFromGetPrimaryItemIfTheNodeHasNoItemMatchingThatSpecifiedByThePrimaryType()
        throws Exception {
        // Find the "vehix:car" type ...
        NodeType carType = nodeTypes.getNodeType("vehix:car");
        assertThat(carType, is(notNullValue()));
        assertThat(carType.getPrimaryItemName(), is("vehix:model"));
        assertThat(prius.getPrimaryItem(), is(sameInstance((Item)prius.getProperty("vehix:model"))));

        // Now remove the "vehix:model" property so there is no such item ...
        prius.getProperty("vehix:model").remove();
        prius.getPrimaryItem();
View Full Code Here

            fileNodeType = defaultFileNodeType;
         }

         String contentNodeType = NodeTypeUtil.getContentNodeType(contentNodeTypeHeader);
         NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager();
         NodeType nodeType = ntm.getNodeType(contentNodeType);
         NodeTypeUtil.checkContentResourceType(nodeType);

         return new PutCommand(nullResourceLocks, uriInfo.getBaseUriBuilder().path(getClass()).path(repoName)).put(
            session, path(repoPath), inputStream, fileNodeType, contentNodeType,
            NodeTypeUtil.getMixinTypes(mixinTypes), mimeType, encoding, updatePolicyType, autoVersionType, tokens);
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.