use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testLimit.
public void testLimit() throws Exception {
query.setLimit(1);
QueryResult result = query.execute();
checkResult(result, new Node[] { node1 });
query.setLimit(2);
result = query.execute();
checkResult(result, new Node[] { node1, node2 });
query.setLimit(3);
result = query.execute();
checkResult(result, new Node[] { node1, node2, node3 });
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class AbstractQueryTest method executeSQLQuery.
/**
* Executes the <code>sql</code> query and checks the results against
* the specified <code>nodes</code>.
* @param sql the sql query.
* @param nodes the expected result nodes.
* @throws RepositoryException if an error occurs while executing the query
* or checking the result.
*/
protected void executeSQLQuery(String sql, Node[] nodes) throws RepositoryException {
QueryResult res = qm.createQuery(sql, Query.SQL).execute();
checkResult(res, nodes);
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class FulltextQueryTest method testFulltextOrSQL.
public void testFulltextOrSQL() throws Exception {
Node n = testRootNode.addNode("node1");
n.setProperty("title", new String[] { "test text" });
n.setProperty("mytext", new String[] { "the quick brown fox jumps over the lazy dog." });
n = testRootNode.addNode("node2");
n.setProperty("title", new String[] { "other text" });
n.setProperty("mytext", new String[] { "the quick brown fox jumps over the lazy dog." });
testRootNode.save();
String sql = "SELECT * FROM nt:unstructured" + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%" + "' AND CONTAINS(., '''fox jumps'' test OR other')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
QueryResult result = q.execute();
checkResult(result, 2);
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class FulltextQueryTest method testFulltextPhraseSQL.
public void testFulltextPhraseSQL() throws Exception {
Node n = testRootNode.addNode("node1");
n.setProperty("title", new String[] { "test text" });
n.setProperty("mytext", new String[] { "the quick brown jumps fox over the lazy dog." });
n = testRootNode.addNode("node2");
n.setProperty("title", new String[] { "other text" });
n.setProperty("mytext", new String[] { "the quick brown fox jumps over the lazy dog." });
testRootNode.save();
String sql = "SELECT * FROM nt:unstructured" + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%" + "' AND CONTAINS(., 'text \"fox jumps\"')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
QueryResult result = q.execute();
checkResult(result, 1);
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class FulltextQueryTest method testFulltextIntercapSQL.
public void testFulltextIntercapSQL() throws Exception {
Node n = testRootNode.addNode("node1");
n.setProperty("title", new String[] { "tEst text" });
n.setProperty("mytext", new String[] { "The quick brown Fox jumps over the lazy dog." });
n = testRootNode.addNode("node2");
n.setProperty("title", new String[] { "Other text" });
n.setProperty("mytext", new String[] { "the quick brown FOX jumPs over the lazy dog." });
testRootNode.save();
String sql = "SELECT * FROM nt:unstructured" + " WHERE \"jcr:path\" LIKE '" + testRoot + "/%" + "' AND CONTAINS(., '''fox juMps'' Test OR otheR')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
QueryResult result = q.execute();
checkResult(result, 2);
}
Aggregations