use of javax.jcr.nodetype.NodeType in project jackrabbit by apache.
the class NodeTypeTest method testGetPrimaryItemName.
/**
* 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());
}
use of javax.jcr.nodetype.NodeType in project jackrabbit by apache.
the class NodeTypeTest method testGetDeclaredChildNodeDefs.
/**
* Test if all node defs returned by getDeclaredChildNodeDefs() are also
* returned by getChildNodeDefs(). All existing node types are tested.
*/
public void testGetDeclaredChildNodeDefs() throws RepositoryException {
NodeTypeIterator types = manager.getAllNodeTypes();
while (types.hasNext()) {
NodeType type = types.nextNodeType();
NodeDefinition[] declaredDefs = type.getDeclaredChildNodeDefinitions();
NodeDefinition[] defs = type.getChildNodeDefinitions();
try {
for (int i = 0; i < declaredDefs.length; i++) {
boolean exists = false;
for (int j = 0; j < defs.length; j++) {
if (defs[j].getName().equals(declaredDefs[i].getName())) {
exists = true;
break;
}
}
assertTrue("All node defs returned by " + "getDeclaredChildNodeDefs() must also be " + "returned by getChildNodeDefs().", exists);
}
} catch (ArrayIndexOutOfBoundsException e) {
fail("The array returned by " + "getDeclaredChildNodeDefs() must not exceed " + "the one returned by getChildNodeDefs()");
}
}
}
use of javax.jcr.nodetype.NodeType in project jackrabbit by apache.
the class CanRemoveItemTest method testRemovableProperty.
/**
* Tests that {@link NodeType#canRemoveItem(String)} and
* {@link NodeType#canRemoveProperty(String)} return true
* if the specified property is not a protected nor a mandatory
* property.
*/
public void testRemovableProperty() throws NotExecutableException, RepositoryException {
PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, false, false);
if (propDef == null) {
throw new NotExecutableException("No mandatory property def found.");
}
NodeType type = propDef.getDeclaringNodeType();
assertTrue("NodeType.canRemoveItem(String itemName) must return true " + "if itemName is not a protected nor a mandatory property def.", type.canRemoveItem(propDef.getName()));
assertTrue("NodeType.canRemoveProperty(String propertyName) must return true " + "if propertyName is not a protected nor a mandatory property def.", type.canRemoveProperty(propDef.getName()));
}
use of javax.jcr.nodetype.NodeType in project jackrabbit by apache.
the class CanRemoveItemTest method testRemovableChildNode.
/**
* Tests if {@link NodeType#canRemoveItem(String)} and
* {@link NodeType#canRemoveNode(String)} return true
* if the specified node is not a protected nor a mandatory
* child node.
*/
public void testRemovableChildNode() throws NotExecutableException, RepositoryException {
NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false);
if (nodeDef == null) {
throw new NotExecutableException("No mandatory property def found.");
}
NodeType type = nodeDef.getDeclaringNodeType();
assertTrue("NodeType.canRemoveItem(String itemName) must return true " + "if itemName is not a protected nor a mandatory child node def.", type.canRemoveItem(nodeDef.getName()));
assertTrue("NodeType.canRemoveNode(String nodeName) must return true " + "if nodeName is not a protected nor a mandatory child node def.", type.canRemoveNode(nodeDef.getName()));
}
use of javax.jcr.nodetype.NodeType in project jackrabbit by apache.
the class CanRemoveItemTest method testMandatoryChildNode.
/**
* Tests if {@link NodeType#canRemoveItem(String)} and
* {@link NodeType#canRemoveNode(String)} return
* false if the specified node is a mandatory child node.
*/
public void testMandatoryChildNode() 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 mandatory child node def.", type.canRemoveItem(nodeDef.getName()));
assertFalse("NodeType.canRemoveNode(String nodeName) must return false " + "if nodeName is a mandatory child node def.", type.canRemoveNode(nodeDef.getName()));
}
Aggregations