use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryWithConstraintOrderingAndColumn.
public void testCreateQueryWithConstraintOrderingAndColumn() throws RepositoryException {
Selector selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
Ordering ordering = qf.ascending(propValue);
Column column = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, new Column[] { column });
assertTrue("Not a selector source", qom.getSource() instanceof Selector);
assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
assertEquals("Wrong size of columns", 1, qom.getColumns().length);
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryFromSourceWithConstraintOrderingAndColumn.
public void testCreateQueryFromSourceWithConstraintOrderingAndColumn() throws RepositoryException {
Source selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
Ordering ordering = qf.ascending(propValue);
Column column = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, new Column[] { column });
assertTrue("Not a selector source", qom.getSource() instanceof Selector);
assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
assertEquals("Wrong size of columns", 1, qom.getColumns().length);
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testCreateQueryWithConstraintAndOrdering.
public void testCreateQueryWithConstraintAndOrdering() throws RepositoryException {
Selector selector = qf.selector(testNodeType, SELECTOR_NAME1);
PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
Ordering ordering = qf.ascending(propValue);
QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, 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", 1, qom.getOrderings().length);
assertEquals("Wrong size of columns", 0, qom.getColumns().length);
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class NodeNameTest method testStringLiteral.
public void testStringLiteral() throws RepositoryException {
Value literal = vf.createValue(nodeName1);
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 testPathLiteral.
public void testPathLiteral() throws RepositoryException {
Value literal = vf.createValue(nodeName1, PropertyType.PATH);
QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
checkQOM(qom, new Node[] { node1 });
literal = vf.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
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS PATH)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with absolute PATH must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
literal = vf.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
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS PATH)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with PATH length >1 must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
Aggregations