Search in sources :

Example 26 with Query

use of javax.jcr.query.Query in project jackrabbit by apache.

the class DescendantNodeTest method testRelativePath.

public void testRelativePath() throws RepositoryException {
    try {
        Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("s", testPath), null, null);
        q.execute();
        fail("DescendantNode with relative path argument must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
    try {
        String stmt = "SELECT * FROM [" + testNodeType + "] AS s WHERE " + "ISDESCENDANTNODE(s, [" + testPath + "])";
        qm.createQuery(stmt, Query.JCR_SQL2).execute();
        fail("ISDESCENDANTNODE() with relative path argument must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
}
Also used : Query(javax.jcr.query.Query) InvalidQueryException(javax.jcr.query.InvalidQueryException)

Example 27 with Query

use of javax.jcr.query.Query in project jackrabbit by apache.

the class DescendantNodeTest method testSyntacticallyInvalidPath.

public void testSyntacticallyInvalidPath() throws RepositoryException {
    String invalidPath = testRoot + "/" + nodeName1 + "[";
    try {
        Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("s", invalidPath), null, null);
        q.execute();
        fail("DescendantNode with syntactically invalid path argument must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
    try {
        String stmt = "SELECT * FROM [" + testNodeType + "] AS s WHERE " + "ISDESCENDANTNODE(s, [" + invalidPath + "])";
        qm.createQuery(stmt, Query.JCR_SQL2).execute();
        fail("ISDESCENDANTNODE() with syntactically invalid path argument must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
}
Also used : Query(javax.jcr.query.Query) InvalidQueryException(javax.jcr.query.InvalidQueryException)

Example 28 with Query

use of javax.jcr.query.Query in project jackrabbit by apache.

the class ChildNodeTest method testRelativePath.

public void testRelativePath() throws RepositoryException {
    try {
        Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("s", testPath), null, null);
        q.execute();
        fail("ChildNode with relative path argument must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
    try {
        String stmt = "SELECT * FROM [" + testNodeType + "] AS s WHERE " + "ISCHILDNODE(s, [" + testPath + "])";
        qm.createQuery(stmt, Query.JCR_SQL2).execute();
        fail("ISCHILDNODE() with relative path argument must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
}
Also used : Query(javax.jcr.query.Query) InvalidQueryException(javax.jcr.query.InvalidQueryException)

Example 29 with Query

use of javax.jcr.query.Query in project jackrabbit by apache.

the class ChildNodeTest method testNotASelectorName.

public void testNotASelectorName() throws RepositoryException {
    try {
        Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.childNode("x", testRoot), null, null);
        q.execute();
        fail("ChildNode with an unknown selector name must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
    try {
        String stmt = "SELECT * FROM [" + testNodeType + "] AS s WHERE " + "ISCHILDNODE(x, [" + testRoot + "])";
        qm.createQuery(stmt, Query.JCR_SQL2).execute();
        fail("ISCHILDNODE() with an unknown selector name must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
}
Also used : Query(javax.jcr.query.Query) InvalidQueryException(javax.jcr.query.InvalidQueryException)

Example 30 with Query

use of javax.jcr.query.Query in project jackrabbit by apache.

the class DescendantNodeTest method testNotASelectorName.

public void testNotASelectorName() throws RepositoryException {
    try {
        Query q = qf.createQuery(qf.selector(testNodeType, "s"), qf.descendantNode("x", testRoot), null, null);
        q.execute();
        fail("DescendantNode with an unknown selector name must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
    try {
        String stmt = "SELECT * FROM [" + testNodeType + "] AS s WHERE " + "ISDESCENDANTNODE(x, [" + testRoot + "])";
        qm.createQuery(stmt, Query.JCR_SQL2).execute();
        fail("ISDESCENDANTNODE() with an unknown selector name must throw InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
}
Also used : Query(javax.jcr.query.Query) InvalidQueryException(javax.jcr.query.InvalidQueryException)

Aggregations

Query (javax.jcr.query.Query)198 Node (javax.jcr.Node)122 QueryResult (javax.jcr.query.QueryResult)97 QueryManager (javax.jcr.query.QueryManager)68 Session (javax.jcr.Session)58 NodeIterator (javax.jcr.NodeIterator)40 Test (org.junit.Test)35 RowIterator (javax.jcr.query.RowIterator)26 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)24 RepositoryException (javax.jcr.RepositoryException)20 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)15 InvalidQueryException (javax.jcr.query.InvalidQueryException)13 ArrayList (java.util.ArrayList)11 Row (javax.jcr.query.Row)9 FacetResult (org.apache.jackrabbit.oak.query.facet.FacetResult)9 ValueFactory (javax.jcr.ValueFactory)8 QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)7 Value (javax.jcr.Value)6 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)5 Name (org.apache.jackrabbit.spi.Name)4