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);
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class ExcerptTest method testEncodeIllegalCharsNoHighlights.
/**
* Verifies character encoding on a node property that does not contain any
* excerpt info
*/
public void testEncodeIllegalCharsNoHighlights() throws RepositoryException {
String text = "bla <strong>bla</strong> bla";
String excerpt = createExcerpt("bla <strong>bla</strong> bla");
Node n = testRootNode.addNode(nodeName1);
n.setProperty("text", text);
n.setProperty("other", "foo");
superuser.save();
String stmt = getStatement("foo");
QueryResult result = executeQuery(stmt);
RowIterator rows = result.getRows();
assertEquals(1, rows.getSize());
String ex = rows.nextRow().getValue("rep:excerpt(text)").getString();
assertEquals("Expected " + excerpt + ", but got ", excerpt, ex);
}
Aggregations