use of javax.jcr.query.RowIterator in project jackrabbit by apache.
the class GQLTest method testExcerpt.
public void testExcerpt() throws RepositoryException {
Node file = addFile(testRootNode, "file1.txt", SAMPLE_CONTENT);
superuser.save();
String stmt = createStatement("quick");
checkResultWithRetries(stmt, "jcr:content", new Node[] { file });
RowIterator rows = GQL.execute(stmt, superuser, "jcr:content");
assertTrue("Expected result", rows.hasNext());
String excerpt = rows.nextRow().getValue("rep:excerpt()").getString();
assertTrue("No excerpt returned", excerpt.startsWith("<div><span>"));
stmt = createStatement("type:resource quick");
rows = GQL.execute(stmt, superuser);
assertTrue("Expected result", rows.hasNext());
excerpt = rows.nextRow().getValue("rep:excerpt()").getString();
assertTrue("No excerpt returned", excerpt.startsWith("<div><span>"));
}
use of javax.jcr.query.RowIterator in project jackrabbit by apache.
the class GQLTest method testApostrophe.
/**
* Test for JCR-3157
*/
public void testApostrophe() throws RepositoryException {
Node n1 = testRootNode.addNode("node1");
n1.setProperty("text", "let's go");
superuser.save();
String stmt = createStatement("\"let's go\"");
RowIterator rows = GQL.execute(stmt, superuser);
checkResult(rows, new Node[] { n1 });
}
use of javax.jcr.query.RowIterator in project jackrabbit by apache.
the class GQLTest method testLimit.
public void testLimit() throws RepositoryException {
Node n1 = testRootNode.addNode("node1");
n1.setProperty("p", 1);
Node n2 = testRootNode.addNode("node2");
n2.setProperty("p", 2);
Node n3 = testRootNode.addNode("node3");
n3.setProperty("p", 3);
superuser.save();
// only 2 results
String stmt = createStatement("order:p limit:2");
RowIterator rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n1, n2 });
// range with open start
stmt = createStatement("order:p limit:..2");
rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n1, n2 });
// range with open end
stmt = createStatement("order:p limit:1..");
rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n2, n3 });
// range
stmt = createStatement("order:p limit:1..2");
rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n2 });
// range with end larger than max results
stmt = createStatement("order:p limit:1..7");
rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n2, n3 });
// range start larger than end
// end is ignored in that case
stmt = createStatement("order:p limit:2..1");
rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n3 });
// range with start larger than max results
stmt = createStatement("order:p limit:6..10");
rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] {});
}
use of javax.jcr.query.RowIterator in project jackrabbit by apache.
the class GQLTest method testOrderDeep.
public void testOrderDeep() throws RepositoryException {
Node n1 = testRootNode.addNode("node1");
n1.setProperty("prop", "value");
n1.addNode("sub").setProperty("p", 1);
Node n2 = testRootNode.addNode("node2");
n2.setProperty("prop", "value");
n2.addNode("sub").setProperty("p", 2);
Node n3 = testRootNode.addNode("node3");
n3.setProperty("prop", "value");
n3.addNode("sub").setProperty("p", 3);
superuser.save();
// default: ascending
String stmt = createStatement("prop:value order:sub/p");
RowIterator rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n1, n2, n3 });
// explicit ascending
stmt = createStatement("prop:value order:+sub/p");
rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n1, n2, n3 });
// explicit descending
stmt = createStatement("prop:value order:-sub/p");
rows = GQL.execute(stmt, superuser);
checkResultSequence(rows, new Node[] { n3, n2, n1 });
}
use of javax.jcr.query.RowIterator in project jackrabbit by apache.
the class ExcerptTest method testQuotedPhraseNoMatchGap.
/**
* Verifies excerpt generation on a node property that does not contain the
* exact quoted phrase, but contains fragments of it.
*
*/
public void testQuotedPhraseNoMatchGap() throws RepositoryException {
String text = "one two three four";
String excerpt = createExcerpt("one two three four");
String terms = "\"two four\"";
Node n = testRootNode.addNode(nodeName1);
n.setProperty("text", text);
n.setProperty("other", terms);
superuser.save();
String stmt = getStatement(terms);
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