use of javax.jcr.query.InvalidQueryException 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
}
}
use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class NodeNameTest method testWeakReferenceLiteral.
public void testWeakReferenceLiteral() throws RepositoryException, NotExecutableException {
ensureMixinType(node1, mixReferenceable);
superuser.save();
Value literal = vf.createValue(node1, true);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with WEAKREFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS WEAKREFERENCE)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with absolute WEAKREFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class NodeNameTest method testReferenceLiteral.
public void testReferenceLiteral() throws RepositoryException, NotExecutableException {
ensureMixinType(node1, mixReferenceable);
superuser.save();
Value literal = vf.createValue(node1);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with REFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS REFERENCE)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with REFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class NodeNameTest method testDecimalLiteral.
public void testDecimalLiteral() throws RepositoryException {
Value literal = vf.createValue(new BigDecimal(283));
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with DECIMAL must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS DECIMAL)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with DECIMAL must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class NodeNameTest method testURILiteral.
/**
* If the URI consists of a single path segment without a colon (for
* example, simply bar) it is converted to a NAME by percent-unescaping
* followed by UTF-8-decoding of the byte sequence. If it has a redundant
* leading ./ followed by a single segment (with or without a colon, like
* ./bar or ./foo:bar ) the redundant ./ is removed and the remainder is
* converted to a NAME in the same way. Otherwise a ValueFormatException is
* thrown.
*/
public void testURILiteral() throws RepositoryException {
Value literal = vf.createValue("./" + nodeName1, PropertyType.URI);
QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
checkQOM(qom, new Node[] { node1 });
literal = vf.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
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS URI)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with URI that cannot be converted to NAME must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
Aggregations