n2.setProperty("desc", "Description");
session.save();
Query q;
RowIterator it;
Row row;
String s;
String xpath = "//*[jcr:contains(., 'hello')]/rep:excerpt(.) order by jcr:path descending";
q = qm.createQuery(xpath, "xpath");
it = q.execute().getRows();
row = it.nextRow();
s = row.getValue("rep:excerpt(.)").getString();
assertTrue(s, s.indexOf("<strong>hello</strong> world") >= 0);
assertTrue(s, s.indexOf("description") >= 0);
row = it.nextRow();
s = row.getValue("rep:excerpt(.)").getString();
// TODO is this expected?
assertTrue(s, s.indexOf("Hello World") >= 0);
assertTrue(s, s.indexOf("Description") >= 0);
xpath = "//*[jcr:contains(., 'hello')]/rep:excerpt(.) order by jcr:path descending";
q = qm.createQuery(xpath, "xpath");
it = q.execute().getRows();
row = it.nextRow();
s = row.getValue("rep:excerpt(text)").getString();
assertTrue(s, s.indexOf("<strong>hello</strong> world") >= 0);
assertTrue(s, s.indexOf("description") < 0);
row = it.nextRow();
s = row.getValue("rep:excerpt(text)").getString();
// TODO is this expected?
assertTrue(s, s.indexOf("Hello World") >= 0);
assertTrue(s, s.indexOf("Description") < 0);
}