Search in sources :

Example 1 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class ClusterRecordTest method testNodeTypeReregistration.

/**
 * Test producing and consuming a node type reregistration.
 * @throws Exception
 */
public void testNodeTypeReregistration() throws Exception {
    QNodeTypeDefinitionBuilder ntd = new QNodeTypeDefinitionBuilder();
    ntd.setName(NameFactoryImpl.getInstance().create("", "test"));
    ntd.setSupertypes(new Name[] { NameConstants.NT_BASE });
    ArrayList<QNodeTypeDefinition> list = new ArrayList<QNodeTypeDefinition>();
    list.add(ntd.build());
    NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.REREGISTER, list);
    master.reregistered(ntd.build());
    SimpleEventListener listener = new SimpleEventListener();
    slave.setListener((NodeTypeEventListener) listener);
    slave.sync();
    assertEquals(1, listener.getClusterEvents().size());
    assertEquals(listener.getClusterEvents().get(0), event);
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) NodeTypeEvent(org.apache.jackrabbit.core.cluster.SimpleEventListener.NodeTypeEvent) ArrayList(java.util.ArrayList) QNodeTypeDefinitionBuilder(org.apache.jackrabbit.spi.commons.nodetype.QNodeTypeDefinitionBuilder)

Example 2 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class TestAll method testItemNodeType.

/**
 * Test for node type item definitions.
 */
public void testItemNodeType() {
    QNodeTypeDefinition def = getNodeType("itemNodeType");
    assertEquals("itemNodeType primaryItemName", FACTORY.create(TEST_NAMESPACE, "emptyItem"), def.getPrimaryItemName());
    assertEquals("itemNodeType propertyDefs", 10, def.getPropertyDefs().length);
    QPropertyDefinition pdef = getPropDef("itemNodeType", null);
    assertTrue("itemNodeType wildcard property", pdef.definesResidual());
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 3 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class TestAll method testPropertyNodeType.

/**
 * Test for node type property definitions.
 */
public void testPropertyNodeType() {
    QNodeTypeDefinition def = getNodeType("propertyNodeType");
    assertEquals("propertyNodeType propertyDefs", 13, def.getPropertyDefs().length);
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition)

Example 4 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class TestAll method testOrderedNodeType.

/**
 * Test for the <code>hasOrderableChildNodes</code> node type attribute.
 */
public void testOrderedNodeType() {
    QNodeTypeDefinition def = getNodeType("orderedNodeType");
    assertEquals("orderedNodeType hasOrderableChildNodes", true, def.hasOrderableChildNodes());
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition)

Example 5 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class TestAll method getChildNode.

/**
 * Returns the named child node definition from the named node type
 * definition. If either of the definitions do not exist, an assertion
 * failure is generated.
 *
 * @param typeName node type name
 * @param nodeName child node name
 * @return child node definition
 */
private QNodeDefinition getChildNode(String typeName, String nodeName) {
    Name name = FACTORY.create(TEST_NAMESPACE, nodeName);
    QNodeTypeDefinition def = getNodeType(typeName);
    QNodeDefinition[] defs = def.getChildNodeDefs();
    for (int i = 0; i < defs.length; i++) {
        if (name.equals(defs[i].getName())) {
            return defs[i];
        }
    }
    throw new AssertionFailedError("Child node " + nodeName + " does not exist");
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) QNodeDefinition(org.apache.jackrabbit.spi.QNodeDefinition) AssertionFailedError(junit.framework.AssertionFailedError) Name(org.apache.jackrabbit.spi.Name)

Aggregations

QNodeTypeDefinition (org.apache.jackrabbit.spi.QNodeTypeDefinition)58 Name (org.apache.jackrabbit.spi.Name)21 ArrayList (java.util.ArrayList)13 RepositoryException (javax.jcr.RepositoryException)11 NoSuchNodeTypeException (javax.jcr.nodetype.NoSuchNodeTypeException)9 NodeType (javax.jcr.nodetype.NodeType)7 QNodeTypeDefinitionImpl (org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl)6 HashMap (java.util.HashMap)5 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)5 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)5 NodeTypeDefinition (javax.jcr.nodetype.NodeTypeDefinition)4 InvalidNodeTypeDefException (org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException)4 NodeTypeRegistry (org.apache.jackrabbit.core.nodetype.NodeTypeRegistry)4 QValueConstraint (org.apache.jackrabbit.spi.QValueConstraint)4 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)4 QNodeTypeDefinitionBuilder (org.apache.jackrabbit.spi.commons.nodetype.QNodeTypeDefinitionBuilder)4 CompactNodeTypeDefReader (org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader)3 NamespaceMapping (org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping)3 QDefinitionBuilderFactory (org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory)3 QNodeDefinitionBuilder (org.apache.jackrabbit.spi.commons.nodetype.QNodeDefinitionBuilder)3