use of javax.jcr.Node in project jackrabbit by apache.
the class FulltextQueryTest method testContainsStarXPath.
public void testContainsStarXPath() throws RepositoryException {
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[] { "The quick brown Fox jumps over the lazy dog." });
n.setProperty("mytext", new String[] { "text text" });
testRootNode.save();
String sql = "/jcr:root" + testRoot + "/element(*, nt:unstructured)" + "[jcr:contains(., 'quick fox')]";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.XPATH);
checkResult(q.execute(), 2);
}
use of javax.jcr.Node 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.Node in project jackrabbit by apache.
the class FulltextQueryTest method testContainsPropScopeSQL.
public void testContainsPropScopeSQL() throws RepositoryException {
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[] { "The quick brown Fox jumps over the lazy dog." });
n.setProperty("mytext", new String[] { "text text" });
testRootNode.save();
String sql = "SELECT * FROM nt:unstructured" + " WHERE jcr:path LIKE '" + testRoot + "/%" + "' AND CONTAINS(title, 'fox jumps')";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
checkResult(q.execute(), 1);
}
use of javax.jcr.Node 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.Node in project jackrabbit by apache.
the class FnNameQueryTest method testSimple.
public void testSimple() throws RepositoryException {
Node n1 = testRootNode.addNode(nodeName1);
n1.setProperty(propertyName1, 1);
Node n2 = testRootNode.addNode(nodeName2);
n2.setProperty(propertyName1, 2);
Node n3 = testRootNode.addNode(nodeName3);
n3.setProperty(propertyName1, 3);
superuser.save();
String base = testPath + "/*[@" + propertyName1;
executeXPathQuery(base + " = 1 and fn:name() = '" + nodeName1 + "']", new Node[] { n1 });
executeXPathQuery(base + " = 1 and fn:name() = '" + nodeName2 + "']", new Node[] {});
executeXPathQuery(base + " > 0 and fn:name() = '" + nodeName2 + "']", new Node[] { n2 });
executeXPathQuery(base + " > 0 and (fn:name() = '" + nodeName1 + "' or fn:name() = '" + nodeName2 + "')]", new Node[] { n1, n2 });
executeXPathQuery(base + " > 0 and not(fn:name() = '" + nodeName1 + "')]", new Node[] { n2, n3 });
}
Aggregations