use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class NodeNameTest method testBooleanLiteral.
public void testBooleanLiteral() throws RepositoryException {
Value literal = vf.createValue(true);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with BOOLEAN must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST(" + literal.getString() + " AS BOOLEAN)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with BOOLEAN must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class NodeNameTest method testDateLiteral.
public void testDateLiteral() throws RepositoryException {
Value literal = vf.createValue(Calendar.getInstance());
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with DATE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS DATE)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with DATE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class NodeNameTest method testDoubleLiteral.
public void testDoubleLiteral() throws RepositoryException {
Value literal = vf.createValue(Math.PI);
try {
createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with DOUBLE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + testNodeType + "] AS s " + "WHERE NAME(s) = CAST('" + literal.getString() + "' AS DOUBLE)";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("NAME() comparison with DOUBLE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
use of javax.jcr.query.InvalidQueryException 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
}
}
use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class SelectorTest method testUnknownNodeType.
public void testUnknownNodeType() throws RepositoryException {
NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
String ntName = testNodeType;
for (; ; ) {
try {
ntMgr.getNodeType(ntName);
ntName += "x";
} catch (NoSuchNodeTypeException e) {
break;
}
}
try {
qf.createQuery(qf.selector(ntName, "s"), null, null, null).execute();
fail("Selector with unknown node type must throw InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
try {
String stmt = "SELECT * FROM [" + ntName + "] AS nt";
qm.createQuery(stmt, Query.JCR_SQL2).execute();
fail("Selector with unknown node type must throw InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
}
}
Aggregations