/**
* Full-text query tests
*/
public void testFullTextSearch() throws Exception
{
JCRWebdavConnection conn = getConnection();
// Nodes with some text, with unique words in each one in form of <name><content>
Map<String, String> nodes = new HashMap<String, String>();
nodes
.put(
"JCR_Overview",
"A JCR is a type of Object Database tailored to the storage, searching, and retrieval of hierarchical data. The JCR API grew o"
+ "ut of the needs of content management systems, which require storage of documents and other binary objects with associated me"
+ "tadata; however, the API is applicable to many additional types of application. In addition to object storage, the JCR provid"
+ "es: APIs for versioning of data; transactions; observation of changes in data; and import or export of data to XML in a standard way.");
nodes
.put(
"JCR_Structure",
"The data in a JCR consists of a tree of Nodes with associated Properties. Data is stored in the Properties, which may hold simple "
+ "values such as numbers and strings or binary data of arbitrary length. Nodes may optionally have one or more types associated with"
+ " them which dictate the kinds of properties, number and type of child nodes, and certain behavioral characteristics of the nodes. API");
nodes
.put(
"JCR_Queries",
"A JCR can be queried with XPathQuery, can export portions of its tree to XML in two standard formats and can import hierarchies directly"
+ " from XML. A JCR may optionally support a standardized form of SQL for queries. The Apache Jackrabbit reference implementation of "
+ "JCR also supports the integration of the Apache Lucene search engine to give full text searches of data in the repository.");
nodes.put("JCR_Impl",
"eXo Platform JCR implementation on the company wiki. eXo Platform 2 article on theserverside");
// add nodes
for (Entry<String, String> entry : nodes.entrySet())
{
conn.addNode(entry.getKey(), entry.getValue().getBytes(), MIME_TEXT_PLAIN);
}
// wait for indexer to flush volatile index
sleep();
// map containing test-case: <SQL query> : <expected nodes>
Map<String, String[]> sqlCases = new HashMap<String, String[]>();
sqlCases.put("SELECT * FROM nt:base WHERE CONTAINS(*,'tailored')", new String[]{"JCR_Overview"});
sqlCases.put("SELECT * FROM nt:base WHERE CONTAINS(*,'XPathQuery')", new String[]{"JCR_Queries"});
sqlCases.put("SELECT * FROM nt:resource WHERE CONTAINS(*,'API')", new String[]{"JCR_Structure", "JCR_Overview"});
assertQuery(sqlCases, Query.SQL);
// map containing test-case: <XPATH query> : <expected nodes>
Map<String, String[]> xpathCases = new HashMap<String, String[]>();
xpathCases.put("//element(*, nt:base)[jcr:contains(.,'tailored')]", new String[]{"JCR_Overview"});
xpathCases.put("//element(*, nt:base)[jcr:contains(.,'XPathQuery')]", new String[]{"JCR_Queries"});
xpathCases.put("//element(*, nt:resource)[jcr:contains(.,'API')]", new String[]{"JCR_Structure", "JCR_Overview"});
assertQuery(xpathCases, Query.XPATH);
// remove created nodes
for (Entry<String, String> entry : nodes.entrySet())
{
conn.removeNode(entry.getKey());
}
}