|
15 | 15 | */ |
16 | 16 | package com.marklogic.client.test; |
17 | 17 |
|
| 18 | +import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; |
18 | 19 | import static org.junit.Assert.assertEquals; |
19 | 20 |
|
| 21 | +import org.custommonkey.xmlunit.XpathEngine; |
| 22 | +import org.custommonkey.xmlunit.SimpleNamespaceContext; |
| 23 | +import org.custommonkey.xmlunit.XMLUnit; |
| 24 | + |
20 | 25 | import java.io.ByteArrayInputStream; |
21 | 26 | import java.io.FileInputStream; |
22 | 27 | import java.io.IOException; |
23 | 28 | import java.io.InputStream; |
| 29 | +import java.util.HashMap; |
24 | 30 |
|
25 | 31 | import javax.xml.XMLConstants; |
26 | 32 | import javax.xml.parsers.ParserConfigurationException; |
|
30 | 36 | import javax.xml.validation.Schema; |
31 | 37 | import javax.xml.validation.SchemaFactory; |
32 | 38 |
|
| 39 | +import org.junit.BeforeClass; |
33 | 40 | import org.junit.Test; |
34 | 41 | import org.xml.sax.SAXException; |
35 | 42 | import org.xml.sax.SAXParseException; |
|
42 | 49 | import com.marklogic.client.util.EditableNamespaceContext; |
43 | 50 |
|
44 | 51 | public class StructuredQueryBuilderTest { |
| 52 | + static private XpathEngine xpather; |
| 53 | + |
| 54 | + @BeforeClass |
| 55 | + public static void beforeClass() { |
| 56 | + XMLUnit.setIgnoreAttributeOrder(true); |
| 57 | + XMLUnit.setIgnoreWhitespace(true); |
| 58 | + XMLUnit.setNormalize(true); |
| 59 | + XMLUnit.setNormalizeWhitespace(true); |
| 60 | + XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); |
| 61 | + |
| 62 | + HashMap<String,String> namespaces = new HashMap<String, String>(); |
| 63 | + namespaces.put("rapi", "http://marklogic.com/rest-api"); |
| 64 | + namespaces.put("prop", "http://marklogic.com/xdmp/property"); |
| 65 | + namespaces.put("xs", "http://www.w3.org/2001/XMLSchema"); |
| 66 | + namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
| 67 | + namespaces.put("search", "http://marklogic.com/appservices/search"); |
| 68 | + |
| 69 | + |
| 70 | + SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(namespaces); |
| 71 | + |
| 72 | + xpather = XMLUnit.newXpathEngine(); |
| 73 | + xpather.setNamespaceContext(namespaceContext); |
| 74 | + } |
| 75 | + |
45 | 76 | // remove dependency on org.apache.tools.ant.filters.StringInputStream |
46 | 77 | static class StringInputStream extends ByteArrayInputStream { |
47 | 78 | StringInputStream(String input) { |
@@ -508,7 +539,7 @@ public void testBuilder() throws IOException, SAXException, ParserConfigurationE |
508 | 539 | xml = new StringInputStream(q); |
509 | 540 | parser.parse(xml, handler); |
510 | 541 |
|
511 | | - assertEquals( |
| 542 | + assertXMLEqual("Geospatial query malformed", |
512 | 543 | "<query xmlns=\"http://marklogic.com/appservices/search\" " |
513 | 544 | + "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" " |
514 | 545 | + "xmlns:search=\"http://marklogic.com/appservices/search\" " |
|
0 commit comments