use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class NodeLocalNameTest method testPathLiteral.
public void testPathLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(nodeLocalName, PropertyType.PATH);
QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
checkQOM(qom, new Node[] { node1 });
literal = superuser.getValueFactory().createValue(node1.getPath(), PropertyType.PATH);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with absolute PATH must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
literal = superuser.getValueFactory().createValue(nodeName1 + "/" + nodeName1, PropertyType.PATH);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with PATH length >1 must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class FullTextSearchScoreTest method testConstraint.
public void testConstraint() throws RepositoryException {
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), qf.and(qf.and(qf.fullTextSearch("s", null, qf.literal(vf.createValue("fox"))), qf.comparison(qf.fullTextSearchScore("s"), QueryObjectModelFactory.JCR_OPERATOR_GREATER_THAN, qf.literal(vf.createValue(Double.MIN_VALUE)))), qf.descendantNode("s", testRootNode.getPath())), new Ordering[] { qf.descending(qf.fullTextSearchScore("s")) }, null);
forQOMandSQL2(qom, new Callable() {
public Object call(Query query) throws RepositoryException {
RowIterator rows = query.execute().getRows();
while (rows.hasNext()) {
double score = rows.nextRow().getScore("s");
if (!Double.isNaN(score)) {
assertTrue("wrong full text search score", Double.MIN_VALUE < score);
}
}
return null;
}
});
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class NodeNameTest method testBinaryLiteral.
public void testBinaryLiteral() throws RepositoryException {
Value literal = vf.createValue(nodeName1, PropertyType.BINARY);
QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
checkQOM(qom, new Node[] { node1 });
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class NodeNameTest method testNameLiteral.
public void testNameLiteral() throws RepositoryException {
Value literal = vf.createValue(nodeName1, PropertyType.NAME);
QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
checkQOM(qom, new Node[] { node1 });
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryFromSourceWithConstraint.
public void testCreateQueryFromSourceWithConstraint() throws RepositoryException {
Source selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
QueryObjectModel qom = qf.createQuery(selector, propExist, null, null);
assertTrue("Not a selector source", qom.getSource() instanceof Selector);
assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
assertEquals("Wrong size of orderings", 0, qom.getOrderings().length);
assertEquals("Wrong size of columns", 0, qom.getColumns().length);
}
Aggregations