use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class ExcerptTest method testMatchMultipleNonMatchingTokens.
/**
* <p>
* Test when there are multiple tokens that match the fulltext search (which
* will generate multiple lucene terms for the highlighter to use) in the
* repository but not all of them are present in the current property.
* </p>
*
*/
public void testMatchMultipleNonMatchingTokens() throws RepositoryException {
String text = "lorem ipsum";
String fragmentText = "lorem <strong>ipsum</strong>";
String terms = "ipsu*";
String excerpt = createExcerpt(fragmentText);
// here we'll add more matching garbage data so we have more tokens
// passed to the highlighter
Node parent = testRootNode.addNode(nodeName1);
Node n = parent.addNode("test");
n.setProperty("text", text);
testRootNode.addNode(nodeName2).setProperty("foo", "ipsuFoo");
testRootNode.addNode(nodeName3).setProperty("bar", "ipsuBar");
superuser.save();
// --
String stmt = testPath + "/" + nodeName1 + "//*[jcr:contains(., '" + terms + "')]/rep:excerpt(.)";
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 LimitAndOffsetTest method testOffsetAndLimit.
public void testOffsetAndLimit() throws Exception {
query.setOffset(0);
query.setLimit(1);
QueryResult result = query.execute();
checkResult(result, new Node[] { node1 });
query.setOffset(1);
query.setLimit(1);
result = query.execute();
checkResult(result, new Node[] { node2 });
query.setOffset(1);
query.setLimit(2);
result = query.execute();
checkResult(result, new Node[] { node2, node3 });
query.setOffset(0);
query.setLimit(2);
result = query.execute();
checkResult(result, new Node[] { node1, node2 });
// Added for JCR-1323
query.setOffset(0);
query.setLimit(4);
result = query.execute();
checkResult(result, new Node[] { node1, node2, node3 });
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testOffsetAndLimitWithGetSize.
public void testOffsetAndLimitWithGetSize() throws Exception {
query.setOffset(1);
QueryResult result = query.execute();
NodeIterator nodes = result.getNodes();
assertEquals(2, nodes.getSize());
if (result instanceof JackrabbitQueryResult) {
assertEquals(3, ((JackrabbitQueryResult) result).getTotalSize());
}
// JCR-2684: offset higher than total result => size == 0
query.setOffset(10);
result = query.execute();
nodes = result.getNodes();
assertFalse(nodes.hasNext());
assertEquals(0, nodes.getSize());
if (result instanceof JackrabbitQueryResult) {
assertEquals(3, ((JackrabbitQueryResult) result).getTotalSize());
}
query.setOffset(1);
query.setLimit(1);
result = query.execute();
nodes = result.getNodes();
assertEquals(1, nodes.getSize());
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testOffsetAndSkip.
public void testOffsetAndSkip() throws Exception {
query.setOffset(1);
QueryResult result = query.execute();
NodeIterator nodes = result.getNodes();
nodes.skip(1);
assertTrue(node3.isSame(nodes.nextNode()));
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testOffset.
public void testOffset() throws Exception {
query.setOffset(0);
QueryResult result = query.execute();
checkResult(result, new Node[] { node1, node2, node3 });
query.setOffset(1);
result = query.execute();
checkResult(result, new Node[] { node2, node3 });
query.setOffset(2);
result = query.execute();
checkResult(result, new Node[] { node3 });
}
Aggregations