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);
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class ExcerptTest method checkExcerpt.
private void checkExcerpt(String text, String fragmentText, String terms) throws RepositoryException {
String excerpt = createExcerpt(fragmentText);
createTestData(text);
String stmt = getStatement(terms);
QueryResult result = executeQuery(stmt);
RowIterator rows = result.getRows();
assertEquals(1, rows.getSize());
assertEquals(excerpt, getExcerpt(rows.nextRow()));
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class SelectorTest method testSelector.
public void testSelector() throws RepositoryException {
// make sure there's at least one node with this node type
testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), null, null, null);
forQOMandSQL2(qom, new Callable() {
public Object call(Query query) throws RepositoryException {
QueryResult result = query.execute();
String[] names = result.getSelectorNames();
assertNotNull(names);
assertEquals(1, names.length);
assertEquals("s", names[0]);
NodeIterator it = result.getNodes();
while (it.hasNext()) {
assertTrue("Wrong node type", it.nextNode().isNodeType(testNodeType));
}
return null;
}
});
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class QueryTest method testSQL2Simple.
/**
* https://issues.apache.org/jira/browse/JCR-3089
*/
public void testSQL2Simple() throws Exception {
Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
QueryResult r = q.execute();
assertTrue(r.getNodes().hasNext());
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class QueryTest method testSQL2Limit.
/**
* https://issues.apache.org/jira/browse/JCR-2543
*/
public void testSQL2Limit() throws Exception {
Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
q.setLimit(1);
QueryResult r = q.execute();
NodeIterator it = r.getNodes();
assertTrue(it.hasNext());
it.next();
assertFalse(it.hasNext());
}
Aggregations