kevinoneill 2003/08/04 15:45:25
Modified: java/tests/src/org/apache/xindice/integration/client/services
XPathQueryTest.java
Log:
PR: 13746
Test to ensure that the xindice src namespace and prefix are added only to
the top level node.
Revision Changes Path
1.5 +31 -3
xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/XPathQueryTest.java
Index: XPathQueryTest.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/XPathQueryTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XPathQueryTest.java 4 Aug 2003 03:01:57 -0000 1.4
+++ XPathQueryTest.java 4 Aug 2003 22:45:25 -0000 1.5
@@ -310,7 +310,35 @@
this.client.removeDocument(TEST_COLLECTION_PATH, "doc3");
}
-
+
+ public void testSrcAddedToRootOnly() throws Exception
+ {
+ String query = "//person[first='John' and last='Smith']";
+
+ Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
+ XPathQueryService xpathservice = (XPathQueryService)
col.getService("XPathQueryService", "1.0");
+ ResourceSet resultSet = xpathservice.query(query);
+
+ ResourceIterator results = resultSet.getIterator();
+
+ List res = asList(results);
+ assertEquals(1, res.size());
+
+ XMLResource resource = (XMLResource) resultSet.getResource(0);
+
+ String john = "<?xml version=\"1.0\"?>" +
+ "<person xmlns:src='http://xml.apache.org/xindice/Query'
src:col='/db/testing/current' src:key='doc1'>" +
+ "<first>John</first>" +
+ "<last>Smith</last>" +
+ "<age>30</age>" +
+ "<phone type=\"work\">555-345-6789</phone>" +
+ "</person>";
+
+ // ensure that the resource has the correct doc id.
+ assertEquals("doc1", resource.getDocumentId());
+
+ XMLAssert.assertXMLEqual(john,
TextWriter.toString(resource.getContentAsDOM()));
+ }
public static List asList(ResourceIterator iter)
throws Exception {