Search in sources :

Example 6 with QueryRootNode

use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.

the class XPathOrderByTest method testAscending.

public void testAscending() throws Exception {
    String stmt = "//* order by @bar ascending";
    QueryRootNode root = QueryParser.parse(stmt, Query.XPATH, RESOLVER, FACTORY);
    OrderQueryNode.OrderSpec[] specs = root.getOrderNode().getOrderSpecs();
    assertEquals(1, specs.length);
    assertTrue(specs[0].isAscending());
}
Also used : QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Example 7 with QueryRootNode

use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.

the class XPathOrderByTest method testSimpleOrderBy.

public void testSimpleOrderBy() throws Exception {
    String stmt = "//* order by @bar";
    QueryRootNode root = QueryParser.parse(stmt, Query.XPATH, RESOLVER, FACTORY);
    OrderQueryNode.OrderSpec[] specs = root.getOrderNode().getOrderSpecs();
    assertEquals(1, specs.length);
    assertTrue(specs[0].isAscending());
    checkName(Name.NS_DEFAULT_URI, "bar", specs[0].getProperty());
    Path propPath = specs[0].getPropertyPath();
    assertEquals(1, propPath.getLength());
    checkName(Name.NS_DEFAULT_URI, "bar", propPath.getName());
}
Also used : Path(org.apache.jackrabbit.spi.Path) QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Example 8 with QueryRootNode

use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.

the class XPathOrderByTest method testRoundTrip.

public void testRoundTrip() throws Exception {
    String stmt = "//* order by foo_x0020_bar/@bar";
    QueryRootNode root = QueryParser.parse(stmt, Query.XPATH, RESOLVER, FACTORY);
    assertEquals(stmt, QueryFormat.toString(root, RESOLVER));
}
Also used : QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Example 9 with QueryRootNode

use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.

the class QueryFormatTest method checkStatement.

protected void checkStatement(String stmt) throws InvalidQueryException {
    QueryRootNode root = QueryParser.parse(stmt, Query.XPATH, RESOLVER, FACTORY);
    assertEquals(stmt, QueryFormat.toString(root, RESOLVER));
}
Also used : QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Example 10 with QueryRootNode

use of org.apache.jackrabbit.spi.commons.query.QueryRootNode in project jackrabbit by apache.

the class XPathOrderByTest method testDescending.

public void testDescending() throws Exception {
    String stmt = "//* order by @bar descending";
    QueryRootNode root = QueryParser.parse(stmt, Query.XPATH, RESOLVER, FACTORY);
    OrderQueryNode.OrderSpec[] specs = root.getOrderNode().getOrderSpecs();
    assertEquals(1, specs.length);
    assertFalse(specs[0].isAscending());
}
Also used : QueryRootNode(org.apache.jackrabbit.spi.commons.query.QueryRootNode)

Aggregations

QueryRootNode (org.apache.jackrabbit.spi.commons.query.QueryRootNode)10 Path (org.apache.jackrabbit.spi.Path)2 OrderQueryNode (org.apache.jackrabbit.spi.commons.query.OrderQueryNode)1