use of javax.jcr.Value in project jackrabbit by apache.
the class NodeDiscoveringNodeTypesTest method testGetMixinNodeTypes.
/**
* Test if getMixinNodeType returns the node types according to the property
* "jcr:mixinTypes". Therefore a node with mixin types is located recursively
* in the entire repository. A NotExecutableException is thrown when no such
* node is found.
*/
public void testGetMixinNodeTypes() throws NotExecutableException, RepositoryException {
if (childNode == null) {
throw new NotExecutableException("Workspace does not have sufficient content for this test. " + "Root node must have at least one child node.");
}
Node node = locateNodeWithMixinNodeTypes(testRootNode);
if (node == null) {
throw new NotExecutableException("Workspace does not contain a node with mixin node types defined");
}
Value[] names = node.getProperty(jcrMixinTypes).getValues();
NodeType[] types = node.getMixinNodeTypes();
assertEquals("getMixinNodeTypes() does not return the same number of " + "node types as " + "getProperty(\"jcr:mixinTypes\").getValues()", types.length, names.length);
StringBuffer namesString = new StringBuffer();
for (int i = 0; i < names.length; i++) {
namesString.append("|" + names[i].getString() + "|");
}
for (int i = 0; i < types.length; i++) {
String pattern = "|" + types[i].getName() + "|";
assertTrue("getMixinNodeTypes() does not return the same node" + "types as getProperty(\"jcr:mixinTypes\").getValues()", namesString.indexOf(pattern) != -1);
assertTrue("All nodes returned by getMixinNodeTypes() must be" + "mixin", types[i].isMixin());
}
}
use of javax.jcr.Value in project jackrabbit by apache.
the class BindVariableValueTest method testPath.
public void testPath() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
Value path = vf.createValue(n.getPath(), PropertyType.PATH);
n.setProperty(propertyName1, path);
superuser.save();
bindVariableValue(qomQuery, "v", path);
checkResult(qomQuery.execute(), new Node[] { n });
bindVariableValue(sqlQuery, "v", path);
checkResult(sqlQuery.execute(), new Node[] { n });
}
use of javax.jcr.Value in project jackrabbit by apache.
the class BindVariableValueTest method testName.
public void testName() throws RepositoryException {
Value name = vf.createValue(STRING_VALUE, PropertyType.NAME);
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.setProperty(propertyName1, name);
superuser.save();
bindVariableValue(qomQuery, "v", name);
checkResult(qomQuery.execute(), new Node[] { n });
bindVariableValue(sqlQuery, "v", name);
checkResult(sqlQuery.execute(), new Node[] { n });
}
use of javax.jcr.Value in project jackrabbit by apache.
the class NodeNameTest method testWeakReferenceLiteral.
public void testWeakReferenceLiteral() throws RepositoryException, NotExecutableException {
ensureMixinType(node1, mixReferenceable);
superuser.save();
Value literal = vf.createValue(node1, true);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with WEAKREFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS WEAKREFERENCE)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with absolute WEAKREFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.Value in project jackrabbit by apache.
the class NodeNameTest method testReferenceLiteral.
public void testReferenceLiteral() throws RepositoryException, NotExecutableException {
ensureMixinType(node1, mixReferenceable);
superuser.save();
Value literal = vf.createValue(node1);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with REFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS REFERENCE)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with REFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
Aggregations