use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class UpperLowerCaseTest method checkQueries.
// -------------------------------< internal >-------------------------------
private void checkQueries(DynamicOperand operand, boolean toUpper, String operator, String[] literals, int type, boolean[] matches) throws RepositoryException {
for (int i = 0; i < literals.length; i++) {
QueryObjectModel qom = createQuery(operand, toUpper, operator, vf.createValue(literals[i], type));
checkQOM(qom, matches[i] ? new Node[] { node } : new Node[0]);
}
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class ParserTest method formatLiteral.
private void formatLiteral(String literal, String cast) throws Exception {
String s = "SELECT TEST.* FROM TEST WHERE ID=" + literal;
QueryObjectModel qom = parser.createQueryObjectModel(s);
String s2 = QOMFormatter.format(qom);
String cast2 = s2.substring(s2.indexOf('=') + 1).trim();
assertEquals(cast, cast2);
qom = parser.createQueryObjectModel(s);
s2 = QOMFormatter.format(qom);
cast2 = s2.substring(s2.indexOf('=') + 1).trim();
assertEquals(cast, cast2);
}
use of javax.jcr.query.qom.QueryObjectModel in project jackrabbit by apache.
the class ParserTest method testParseScript.
public void testParseScript() throws Exception {
LineNumberReader reader = openScript("test.sql2.txt");
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
line = line.trim();
if (line.length() == 0 || line.startsWith("#")) {
continue;
}
// System.out.println(line);
String query = line;
try {
QueryObjectModel qom = parser.createQueryObjectModel(line);
String s = QOMFormatter.format(qom);
qom = parser.createQueryObjectModel(s);
String s2 = QOMFormatter.format(qom);
assertEquals(s, s2);
fuzz(line);
} catch (Exception e) {
line = reader.readLine();
String message = e.getMessage();
message = message.replace('\n', ' ');
if (line == null || !line.startsWith("> exception")) {
e.printStackTrace();
assertTrue("Unexpected exception for query " + query + ": " + e, false);
}
assertEquals("Expected exception message: " + message, "> exception: " + message, line);
}
}
reader.close();
}
Aggregations