use of javax.jcr.nodetype.NodeTypeIterator in project jackrabbit by apache.
the class PropertyDefTest method testIsAutoCreate.
/**
* Tests if auto create properties are not a residual set definition
* (getName() does not return "*")
*/
public void testIsAutoCreate() throws RepositoryException {
NodeTypeIterator types = manager.getAllNodeTypes();
// loop all node types
while (types.hasNext()) {
NodeType type = types.nextNodeType();
PropertyDefinition[] defs = type.getPropertyDefinitions();
for (int i = 0; i < defs.length; i++) {
if (defs[i].isAutoCreated()) {
assertFalse("An auto create property must not be a " + "residual set definition.", defs[i].getName().equals("*"));
}
}
}
}
use of javax.jcr.nodetype.NodeTypeIterator in project jackrabbit by apache.
the class PropertyDefTest method testGetDeclaringNodeType.
/**
* Test getDeclaringNodeType() returns the node type which is defining the
* requested property def. Test runs for all existing node types.
*/
public void testGetDeclaringNodeType() throws RepositoryException {
NodeTypeIterator types = manager.getAllNodeTypes();
// loop all node types
while (types.hasNext()) {
NodeType currentType = types.nextNodeType();
PropertyDefinition[] defsOfCurrentType = currentType.getPropertyDefinitions();
// loop all property defs of each node type
for (int i = 0; i < defsOfCurrentType.length; i++) {
PropertyDefinition def = defsOfCurrentType[i];
NodeType type = def.getDeclaringNodeType();
// check if def is part of the property defs of the
// declaring node type
PropertyDefinition[] defs = type.getPropertyDefinitions();
boolean hasType = false;
for (int j = 0; j < defs.length; j++) {
if (defs[j].getName().equals(def.getName())) {
hasType = true;
break;
}
}
assertTrue("getDeclaringNodeType() must return the node " + "which defines the corresponding property def.", hasType);
}
}
}
use of javax.jcr.nodetype.NodeTypeIterator in project jackrabbit by apache.
the class PropertyDefTest method testIsRequiredType.
/**
* Tests if isRequiredType() returns a valid PropertyType.
* <p>
* The test runs for all available node types.
*/
public void testIsRequiredType() throws RepositoryException {
NodeTypeIterator types = manager.getAllNodeTypes();
// loop all node types
while (types.hasNext()) {
NodeType type = types.nextNodeType();
PropertyDefinition[] defs = type.getPropertyDefinitions();
for (int i = 0; i < defs.length; i++) {
switch(defs[i].getRequiredType()) {
case PropertyType.STRING:
case PropertyType.BINARY:
case PropertyType.DATE:
case PropertyType.LONG:
case PropertyType.DOUBLE:
case PropertyType.NAME:
case PropertyType.PATH:
case PropertyType.REFERENCE:
case PropertyType.BOOLEAN:
case PropertyType.UNDEFINED:
case PropertyType.WEAKREFERENCE:
case PropertyType.DECIMAL:
case PropertyType.URI:
// success
break;
default:
fail("getRequiredType() returns an " + "invalid PropertyType.");
}
}
}
}
use of javax.jcr.nodetype.NodeTypeIterator in project jackrabbit by apache.
the class PropertyDefTest method testGetDefaultValues.
/**
* Tests if single-valued properties do have not more than one default
* value.
* <p>
* The test runs for all default values of all properties of all available
* node types.
*/
public void testGetDefaultValues() throws RepositoryException {
NodeTypeIterator types = manager.getAllNodeTypes();
// loop all node types
while (types.hasNext()) {
NodeType type = types.nextNodeType();
PropertyDefinition[] defs = type.getPropertyDefinitions();
for (int i = 0; i < defs.length; i++) {
PropertyDefinition def = defs[i];
Value[] values = def.getDefaultValues();
if (values != null) {
for (int j = 0; j < values.length; j++) {
if (!def.isMultiple()) {
assertEquals("Single-valued property " + type.getName() + "/" + def.getName() + " must not have more than one default value.", 1, values.length);
}
}
}
}
}
}
use of javax.jcr.nodetype.NodeTypeIterator in project jackrabbit by apache.
the class NodeTypeTest method testIsNodeTypeQName.
/**
* Like {@link #testIsNodeType()}, but using qualified names
*/
public void testIsNodeTypeQName() throws RepositoryException {
// find a primary node type but not "nt:base"
NodeTypeIterator types = manager.getPrimaryNodeTypes();
while (types.hasNext()) {
NodeType type = types.nextNodeType();
String typename = type.getName();
String ns = session.getNamespaceURI(AbstractJCRTest.getPrefix(typename));
if (ns.length() != 0 && !ns.contains(":")) {
log.warn("Node type '" + typename + "' has invalid namespace '" + ns + "', thus skipping testIsNodeTypeQName() for this type");
} else {
String qn = AbstractJCRTest.getQualifiedName(session, typename);
assertTrue("isNodeType(String nodeTypeName) must return true if " + "NodeType is nodeTypeName", type.isNodeType(qn));
}
if (type.isMixin()) {
assertFalse("isNodeType(String nodeTypeName) must return " + "false if NodeType is not a subtype of " + "nodeTypeName", type.isNodeType(NodeType.NT_BASE));
} else {
assertTrue("isNodeType(String nodeTypeName) must return true if " + "NodeType is a subtype of nodeTypeName", type.isNodeType(NodeType.NT_BASE));
}
}
}
Aggregations