Document control = XMLUnit.buildDocument(XMLUnit.newControlParser(), new StringReader(xml)); Document test = XMLUnit.buildDocument(XMLUnit.newTestParser(), new StringReader(xml2)); Diff diff = new Diff(control, test, null, new ElementNameAndAttributeQualifier("name"));
/** * Get the <code>DocumentBuilder</code> instance used to parse the test XML * in an XMLTestCase. * @return parser for control values * @deprecated use newControlParser() * @throws ConfigurationException */ public static DocumentBuilder getControlParser() throws ConfigurationException { return newControlParser(); }
/** * Utility method to build a Document using the control DocumentBuilder * to parse the specified String. * @param fromXML * @return Document representation of the String content * @throws SAXException * @throws IOException */ public static Document buildControlDocument(String fromXML) throws SAXException, IOException { return buildDocument(newControlParser(), new StringReader(fromXML)); }
/** * Utility method to build a Document using the control DocumentBuilder * and the specified InputSource * @param fromSource * @return Document representation of the String content * @throws SAXException * @throws IOException */ public static Document buildControlDocument(InputSource fromSource) throws IOException, SAXException { return buildDocument(newControlParser(), fromSource); }
/** * Construct a NodeTest for the DOM built using the Reader and JAXP */ public NodeTest(Reader reader) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), reader)); }
/** * Construct a NodeTest for the DOM built using the Reader and JAXP */ public NodeTest(Reader reader) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), reader)); }
/** * Utility method to build a Document using the control DocumentBuilder * to parse the specified String. * @param fromXML * @return Document representation of the String content * @throws SAXException * @throws IOException */ public static Document buildControlDocument(String fromXML) throws SAXException, IOException { return buildDocument(newControlParser(), new StringReader(fromXML)); }
/** * Utility method to build a Document using the control DocumentBuilder * and the specified InputSource * @param fromSource * @return Document representation of the String content * @throws SAXException * @throws IOException */ public static Document buildControlDocument(InputSource fromSource) throws IOException, SAXException { return buildDocument(newControlParser(), fromSource); }
/** * Construct a NodeTest for the DOM built using the InputSource. */ public NodeTest(InputSource src) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), src)); }
/** * Construct a NodeTest for the DOM built using the InputSource. */ public NodeTest(InputSource src) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), src)); }
/** * Construct a Diff that compares the XML read from two Readers */ public Diff(Reader control, Reader test) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), control), XMLUnit.buildDocument(XMLUnit.newTestParser(), test)); }
/** * Construct a Diff that compares the XML read from two JAXP InputSources */ public Diff(InputSource control, InputSource test) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), control), XMLUnit.buildDocument(XMLUnit.newTestParser(), test)); }
/** * Construct a Diff that compares the XML read from two Readers */ public Diff(Reader control, Reader test) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), control), XMLUnit.buildDocument(XMLUnit.newTestParser(), test)); }
/** * Construct a Diff that compares the XML read from two JAXP InputSources */ public Diff(InputSource control, InputSource test) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), control), XMLUnit.buildDocument(XMLUnit.newTestParser(), test)); }
/** * Assert that the node lists of two Xpaths in two documents are * equal or not. * @param xpathOne * @param xpathTwo * @param document * @param equality whether the values should be equal. * @see XpathEngine */ private static void assertXpathEquality(String controlXpath, Document controlDocument, String testXpath, Document testDocument, boolean equal) throws XpathException { XpathEngine xpath = XMLUnit.newXpathEngine(); Diff diff = new Diff(asXpathResultDocument(XMLUnit.newControlParser(), xpath.getMatchingNodes(controlXpath, controlDocument)), asXpathResultDocument(XMLUnit.newTestParser(), xpath.getMatchingNodes(testXpath, testDocument))); assertXMLEqual(diff, equal); }
/** * Assert that the node lists of two Xpaths in two documents are * equal or not. * @param controlXpath * @param testXpath * @param controlDocument * @param testDocument * @param equal whether the values should be equal. * @see XpathEngine */ private static void assertXpathEquality(String controlXpath, Document controlDocument, String testXpath, Document testDocument, boolean equal) throws XpathException { XpathEngine xpath = XMLUnit.newXpathEngine(); Diff diff = new Diff(asXpathResultDocument(XMLUnit.newControlParser(), xpath.getMatchingNodes(controlXpath, controlDocument)), asXpathResultDocument(XMLUnit.newTestParser(), xpath.getMatchingNodes(testXpath, testDocument))); assertXMLEqual(diff, equal); }