Author: natalia
Date: Tue Oct 16 17:37:44 2007
New Revision: 585301
URL: http://svn.apache.org/viewvc?rev=585301&view=rev
Log:
Failing tests for XPathQueryResolver
Modified:
xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/IndexedQueryTest.java
xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java
Modified: xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/IndexedQueryTest.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/IndexedQueryTest.java?rev=585301&r1=585300&r2=585301&view=diff
==============================================================================
--- xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/IndexedQueryTest.java (original)
+++ xml/xindice/trunk/java/tests/src/org/apache/xindice/core/query/IndexedQueryTest.java Tue Oct 16 17:37:44 2007
@@ -95,6 +95,38 @@
assertEquals(9, count);
}
+ /**
+ * Tests specific case with more complex location path to check if
+ * XPathQueryResolver picks the correct index
+ * @throws Exception
+ */
+ public void testStartsWithQuery() throws Exception {
+ String config = "<index name='SpecialTest' " +
+ " class='org.apache.xindice.core.indexer.ValueIndexer' " +
+ " pattern='test1@num'/>";
+ collection.createIndexer(new Configuration(DOMParser.toDocument(config)));
+
+ int iterations = 10;
+ for (int i = 0; i < iterations; i++) {
+ Document document = DOMParser.toDocument("<test num='" + (i + 1) + "'>" +
+ "<test1 num='" + i + "'/>" +
+ "This is a test document</test>");
+ collection.insertDocument("key" + i, document);
+ }
+
+ assertTrue(collection.getFiler().getRecordCount() == iterations);
+
+ XPathQueryResolver service = new XPathQueryResolver();
+ NodeSet result = service.query(collection, "//test1[starts-with(../@num, '8')]", null, null);
+ int count = 0;
+ while (result.hasMoreNodes()) {
+ result.getNextNode();
+ count++;
+ }
+
+ assertEquals(1, count);
+ }
+
public void testValueIndexer_StartsWithNestedContent() throws Exception {
collection.insertDocument("key1", DOMParser.toDocument("<test1>This <i>is</i> a test</test1>"));
collection.insertDocument("key2", DOMParser.toDocument("<test2>This <i>is</i> a test</test2>"));
Modified: xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java?rev=585301&r1=585300&r2=585301&view=diff
==============================================================================
--- xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java (original)
+++ xml/xindice/trunk/java/tests/src/org/apache/xindice/integration/client/services/IndexedSearchTest.java Tue Oct 16 17:37:44 2007
@@ -584,7 +584,44 @@
"WEWA", // index name
"Name", // index type
"*@*", // index pattern
- 0, // indexed query speedup expected (conservative)
+ 6, // indexed query speedup expected (conservative)
+ new String[] { // test docs specifically for this test
+ "<?xml version='1.0'?>" +
+ "<person number3='yes'>" +
+ "<first surname='no' given='yes'>Sally</first>" +
+ "<last surname='yes'>aSm</last>" +
+ "<phone call='no' type='work'>555-345-6789</phone>" +
+ "<address>" +
+ "<street>" +
+ "<number given='no' />" +
+ "</street>" +
+ "</address>" +
+ "</person>"
+ },
+ 2, // expected result count
+ new Object[] { // expected resources to check for (can be empty or partial set)
+ new Integer(0), "<first surname='no' given='yes'>Sally</first>",
+ new Integer(0), "<number given='no' />"
+ });
+
+ aTest.runTest();
+ }
+
+ /**
+ * Tests the functionality of indexed searches on a Collection
+ * with a name index that has a pattern specifying a wildcard Element
+ * name and a wildcard Attribute name (e.g. "*@*"). This kind of index
+ * is probably not useful.
+ */
+ public void testUnnamedElementWildAttributeNameIndexer() throws Exception {
+ // select nodes with an attribute named 'given'
+ IndexerTestDefinition aTest = new IndexerTestDefinition(
+ "testUnnamedElementWildAttributeNameIndexer", // description
+ "//node()[@given]", // query
+ "WEWA", // index name
+ "Name", // index type
+ "*@*", // index pattern
+ 5, // indexed query speedup expected (conservative)
new String[] { // test docs specifically for this test
"<?xml version='1.0'?>" +
"<person number3='yes'>" +
@@ -704,6 +741,40 @@
1, // expected result count
new Object[] { // expected resources to check for (can be empty or partial set)
new Integer(0), "<phone call='no' type='work'>555-345-6789</phone>"
+ });
+
+ aTest.runTest();
+ }
+
+ /**
+ * Tests a starts-with search query for an attribute value that should be resolvable using indexed searching
+ * on a value index. (index pattern like "phone@call")
+ */
+ public void testSelfAxisValueIndexedStartsWithSearch()
+ throws Exception {
+ // search all records whose last name begins with 'Smi'
+ IndexerTestDefinition aTest = new IndexerTestDefinition(
+ "testSelfAxisValueIndexedStartsWithSearch", // description
+ "//phone/@call[starts-with(., 'n')]", // query
+ "SESA", // index name
+ "Value", // index type
+ "phone@call", // index pattern
+ 6, // indexed query speedup expected (conservative)
+ new String[] { // test docs specifically for this test
+ "<?xml version='1.0'?>" +
+ "<person number3='yes'>" +
+ "<first surname='no' given='yes'>Sally</first>" +
+ "<last surname='yes'>aSm</last>" +
+ "<phone call='no' type='work'>555-345-6789</phone>" +
+ "<address> " +
+ "<street>" +
+ "<number given='no' />" +
+ "</street>" +
+ "</address>" +
+ "</person>"
+ },
+ 1, // expected result count
+ new Object[] { // expected resources to check for (can be empty or partial set)
});
aTest.runTest();
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.