use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class NodeNameTest method checkOperatorSingleLiteral.
private void checkOperatorSingleLiteral(String literal, String operator, boolean matches) throws RepositoryException {
Value value = vf.createValue(literal);
QueryObjectModel qom = createQuery(operator, value);
checkQOM(qom, matches ? new Node[] { node1 } : new Node[0]);
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class NodeNameTest method testURILiteral.
/**
* If the URI consists of a single path segment without a colon (for
* example, simply bar) it is converted to a NAME by percent-unescaping
* followed by UTF-8-decoding of the byte sequence. If it has a redundant
* leading ./ followed by a single segment (with or without a colon, like
* ./bar or ./foo:bar ) the redundant ./ is removed and the remainder is
* converted to a NAME in the same way. Otherwise a ValueFormatException is
* thrown.
*/
public void testURILiteral() throws RepositoryException {
Value literal = vf.createValue("./" + nodeName1, PropertyType.URI);
QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
checkQOM(qom, new Node[] { node1 });
literal = vf.createValue("http://example.com", PropertyType.URI);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with URI that cannot be converted to NAME must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS URI)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with URI that cannot be converted to NAME must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class ChildNodeTest method testChildNodesDoNotMatchSelector.
public void testChildNodesDoNotMatchSelector() throws RepositoryException, NotExecutableException {
testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
NodeType testNt = ntMgr.getNodeType(testNodeType);
while (it.hasNext()) {
NodeType nt = it.nextNodeType();
if (!testNt.isNodeType(nt.getName())) {
// perform test
QueryObjectModel qom = qf.createQuery(qf.selector(nt.getName(), "s"), qf.childNode("s", testRoot), null, null);
checkQOM(qom, new Node[] {});
return;
}
}
throw new NotExecutableException("No suitable node type found to " + "perform test against '" + testNodeType + "' nodes");
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class ChildNodeTest method testPathDoesNotExist.
public void testPathDoesNotExist() throws RepositoryException {
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testRoot + "/" + nodeName1), null, null);
checkQOM(qom, new Node[] {});
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class ChildNodeTest method testChildNode.
public void testChildNode() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testRoot), null, null);
checkQOM(qom, new Node[] { n });
}
Aggregations