kevinoneill 2003/08/04 16:56:36
Modified: java/tests/src/org/apache/xindice/integration/client/services XPathQueryTest.java Log: PR: 22122 - Added a test that exposes the src prefix overwrite bug Revision Changes Path 1.6 +39 -2 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- XPathQueryTest.java 4 Aug 2003 22:45:25 -0000 1.5 +++ XPathQueryTest.java 4 Aug 2003 23:56:36 -0000 1.6 @@ -339,6 +339,43 @@ XMLAssert.assertXMLEqual(john, TextWriter.toString(resource.getContentAsDOM())); } + + public void testConflictingPrefix() throws Exception + { + String document3 = "<?xml version=\"1.0\"?>" + + "<src:person xmlns:src='http://example.net/person' >" + + "<src:first>Sally</src:first>" + + "<src:last>Smith</src:last>" + + "<src:phone type=\"work\">555-345-6789</src:phone>" + + "</src:person>"; + this.client.insertDocument(TEST_COLLECTION_PATH, "doc3", document3); + + String query = "//h:person[h:first='Sally' and h:last='Smith']/h:first"; + + Collection col = this.client.getCollection(TEST_COLLECTION_PATH); + XPathQueryService xpathservice = (XPathQueryService) col.getService("XPathQueryService", "1.0"); + xpathservice.setNamespace("h", "http://example.net/person"); + + ResourceSet resultSet = xpathservice.query(query); + + ResourceIterator results = resultSet.getIterator(); + List res = asList(results); + assertEquals(1, res.size()); + + XMLResource resource = (XMLResource) resultSet.getResource(0); + + // ensure that the resource has the correct doc id. + assertEquals("doc3", resource.getDocumentId()); + + Node node = resource.getContentAsDOM(); + + // add source node information to the compared xml as it's added by + // the query processor. + XMLAssert.assertXMLEqual("<first xmlns:src='http://xml.apache.org/xindice/Query' src:col='/db/testing/current' src:key='doc3' xmlns='http://example.net/person'>Sally</first>", TextWriter.toString(node)); + + this.client.removeDocument(TEST_COLLECTION_PATH, "doc3"); + } + public static List asList(ResourceIterator iter) throws Exception {