Search in sources :

Example 11 with InvalidQueryException

use of javax.jcr.query.InvalidQueryException 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 12 with InvalidQueryException

use of javax.jcr.query.InvalidQueryException 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 13 with InvalidQueryException

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

the class NodeNameTest method testLongLiteral.

public void testLongLiteral() throws RepositoryException {
    Value literal = vf.createValue(283);
    try {
        createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
        fail("NodeName comparison with LONG must fail with InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
    try {
        String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST(" + literal.getString() + " AS LONG)";
        qm.createQuery(stmt, Query.JCR_SQL2).execute();
        fail("NAME() comparison with LONG must fail with InvalidQueryException");
    } catch (InvalidQueryException e) {
    // expected
    }
}
Also used : Value(javax.jcr.Value) InvalidQueryException(javax.jcr.query.InvalidQueryException)

Example 14 with InvalidQueryException

use of javax.jcr.query.InvalidQueryException 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)

Example 15 with InvalidQueryException

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

the class NodeLocalNameTest method testURILiteral.

public void testURILiteral() throws RepositoryException {
    Value literal = superuser.getValueFactory().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
    }
}
Also used : Value(javax.jcr.Value) InvalidQueryException(javax.jcr.query.InvalidQueryException)

Aggregations

InvalidQueryException (javax.jcr.query.InvalidQueryException)50 Value (javax.jcr.Value)15 Query (javax.jcr.query.Query)13 NamespaceException (javax.jcr.NamespaceException)9 Name (org.apache.jackrabbit.spi.Name)7 LocationStepQueryNode (org.apache.jackrabbit.spi.commons.query.LocationStepQueryNode)6 PathQueryNode (org.apache.jackrabbit.spi.commons.query.PathQueryNode)6 RepositoryException (javax.jcr.RepositoryException)5 Constraint (javax.jcr.query.qom.Constraint)5 IllegalNameException (org.apache.jackrabbit.spi.commons.conversion.IllegalNameException)5 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)5 PropertyFunctionQueryNode (org.apache.jackrabbit.spi.commons.query.PropertyFunctionQueryNode)5 RelationQueryNode (org.apache.jackrabbit.spi.commons.query.RelationQueryNode)5 Path (org.apache.jackrabbit.spi.Path)4 DerefQueryNode (org.apache.jackrabbit.spi.commons.query.DerefQueryNode)4 TextsearchQueryNode (org.apache.jackrabbit.spi.commons.query.TextsearchQueryNode)4 Session (javax.jcr.Session)3 QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)3 NAryQueryNode (org.apache.jackrabbit.spi.commons.query.NAryQueryNode)3 NodeTypeQueryNode (org.apache.jackrabbit.spi.commons.query.NodeTypeQueryNode)3