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());
}
use of javax.jcr.query.QueryResult in project jackrabbit-oak by apache.
the class OrderedIndexQueryBaseTest method runTest.
@Override
protected void runTest() throws Exception {
QueryManager qm = session.getWorkspace().getQueryManager();
Query q = qm.createQuery(getQuery(), Query.JCR_SQL2);
QueryResult r = q.execute();
NodeIterator nodes = r.getNodes();
int counter = 0;
while (nodes.hasNext() && counter++ < FETCH_NODES) {
nodes.next();
}
}
Aggregations