use of javax.jcr.nodetype.NodeDefinition in project jackrabbit by apache.
the class CanAddChildNodeCallWithoutNodeTypeTest method testDefinedWithDefault.
/**
* Tests if <code>NodeType.canAddChildNode(String childNodeName)</code> returns
* true if <code>NodeType</code> contains a <code>NodeDef</code> named
* <code>childNodeName</code> with a default primary type.
*/
public void testDefinedWithDefault() throws NotExecutableException, RepositoryException {
NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, true, false);
if (nodeDef == null) {
throw new NotExecutableException("No child node def with " + "defaultPrimaryType found");
}
NodeType nodeType = nodeDef.getDeclaringNodeType();
assertTrue("NodeType.canAddChildNode(String childNodeName) must return " + "true if child node def 'childNodeName' defines a defaultPrimaryType.", nodeType.canAddChildNode(nodeDef.getName()));
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit by apache.
the class CanRemoveItemTest method testProtectedChildNode.
/**
* Tests if {@link NodeType#canRemoveItem(String)} and
* {@link NodeType#canRemoveNode(String)} return
* false if the specified node is a protected child node.
*/
public void testProtectedChildNode() throws NotExecutableException, RepositoryException {
NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, false);
if (nodeDef == null) {
throw new NotExecutableException("No mandatory property def found.");
}
NodeType type = nodeDef.getDeclaringNodeType();
assertFalse("NodeType.canRemoveItem(String itemName) must return false " + "if itemName is a protected child node def.", type.canRemoveItem(nodeDef.getName()));
assertFalse("NodeType.canRemoveNode(String nodeName) must return false " + "if nodeName is a protected child node def.", type.canRemoveNode(nodeDef.getName()));
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit by apache.
the class CanAddChildNodeCallWithNodeTypeTest method testUndefined.
/**
* Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
* returns false if <code>childNodeName</code> does not match the <code>NodeDef</code>.
*/
public void testUndefined() throws NotExecutableException, RepositoryException {
NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, true, false);
if (nodeDef == null) {
throw new NotExecutableException("No testable node type found.");
}
String type = nodeDef.getRequiredPrimaryTypes()[0].getName();
NodeType nodeType = nodeDef.getDeclaringNodeType();
String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType);
assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " + "must return false if childNodeName does not match the " + "child node def of NodeType.", nodeType.canAddChildNode(undefinedName, type));
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit by apache.
the class CanAddChildNodeCallWithNodeTypeTest method testCanAddAbstractType.
/**
* Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
* returns false if <code>nodeTypeName</code> represents an abstract node type.
*/
public void testCanAddAbstractType() throws NotExecutableException, RepositoryException {
NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, false);
if (nodeDef == null) {
throw new NotExecutableException("No testable node type found.");
}
NodeType nodeType = nodeDef.getDeclaringNodeType();
String childNodeName = nodeDef.getName();
String abstractName = null;
NodeTypeIterator it = manager.getPrimaryNodeTypes();
while (it.hasNext() && abstractName == null) {
NodeType nt = it.nextNodeType();
if (nt.isAbstract()) {
abstractName = nt.getName();
}
}
if (abstractName == null) {
throw new NotExecutableException("No abstract type found.");
}
assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " + "must return false if nodeTypeName represents an abstract node type.", nodeType.canAddChildNode(childNodeName, abstractName));
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit by apache.
the class NodeTypeDefinitionImpl method getDeclaredChildNodeDefinitions.
/**
* {@inheritDoc}
*/
public NodeDefinition[] getDeclaredChildNodeDefinitions() {
QItemDefinition[] cnda = ntd.getChildNodeDefs();
NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length];
for (int i = 0; i < cnda.length; i++) {
nodeDefs[i] = new NodeDefinitionImpl(cnda[i], null, resolver);
}
return nodeDefs;
}
Aggregations