use of org.custommonkey.xmlunit.DetailedDiff in project zm-mailbox by Zimbra.
the class JaxbToElementTest method jaxBToElementTest.
@Test
public void jaxBToElementTest() throws Exception {
for (int cnt = 1; cnt <= iterationNum; cnt++) {
Element el = JaxbUtil.jaxbToElement(getInfoRespJaxb);
String actual = el.prettyPrint();
String expected = getInfoResponseXml;
DetailedDiff myDiff = new DetailedDiff(XMLUnit.compareXML(expected, actual));
List allDifferences = myDiff.getAllDifferences();
if (allDifferences.size() > 0) {
ZimbraLog.test.debug("Iteration:%s - %s differences found. Compare below with '%s'\n%s\n", cnt, allDifferences.size(), getInfoResponseXMLfileName, actual);
int diffnum = 0;
for (Object obj : allDifferences) {
ZimbraLog.test.info("Difference:%s [%s]", diffnum++, obj);
}
XMLAssert.assertXMLEqual(expected, actual);
}
}
}
use of org.custommonkey.xmlunit.DetailedDiff in project cayenne by apache.
the class DbImporterTaskTest method verifyResult.
@SuppressWarnings("unchecked")
private void verifyResult(File map, File mapFileCopy) {
try {
FileReader control = new FileReader(map.getAbsolutePath() + "-result");
FileReader test = new FileReader(mapFileCopy);
DetailedDiff diff = new DetailedDiff(new Diff(control, test));
if (!diff.similar()) {
for (Difference d : ((List<Difference>) diff.getAllDifferences())) {
System.out.println("-------------------------------------------");
System.out.println(d.getTestNodeDetail().getNode());
System.out.println(d.getControlNodeDetail().getValue());
}
fail(diff.toString());
}
} catch (SAXException | IOException e) {
e.printStackTrace();
fail();
}
}
use of org.custommonkey.xmlunit.DetailedDiff in project opennms by OpenNMS.
the class XmlTest method getDifferences.
protected List<Difference> getDifferences(final String xmlA, final String xmlB) {
DetailedDiff myDiff;
try {
myDiff = new DetailedDiff(XMLUnit.compareXML(xmlA, xmlB));
} catch (final Exception e) {
throw new RuntimeException(e);
}
final List<Difference> retDifferences = new ArrayList<Difference>();
@SuppressWarnings("unchecked") final List<Difference> allDifferences = myDiff.getAllDifferences();
if (allDifferences.size() > 0) {
DIFFERENCES: for (final Difference d : allDifferences) {
final NodeDetail controlNodeDetail = d.getControlNodeDetail();
final String control = controlNodeDetail.getValue();
final NodeDetail testNodeDetail = d.getTestNodeDetail();
final String test = testNodeDetail.getValue();
if (d.getDescription().equals("namespace URI")) {
if (control != null && !"null".equals(control)) {
if (ignoreNamespace(control.toLowerCase())) {
LOG.trace("Ignoring {}: {}", d.getDescription(), d);
continue DIFFERENCES;
}
}
if (test != null && !"null".equals(test)) {
if (ignoreNamespace(test.toLowerCase())) {
LOG.trace("Ignoring {}: {}", d.getDescription(), d);
continue DIFFERENCES;
}
}
} else if (d.getDescription().equals("namespace prefix")) {
if (control != null && !"null".equals(control)) {
if (ignorePrefix(control.toLowerCase())) {
LOG.trace("Ignoring {}: {}", d.getDescription(), d);
continue DIFFERENCES;
}
}
if (test != null && !"null".equals(test)) {
if (ignorePrefix(test.toLowerCase())) {
LOG.trace("Ignoring {}: {}", d.getDescription(), d);
continue DIFFERENCES;
}
}
} else if (d.getDescription().equals("xsi:schemaLocation attribute")) {
LOG.debug("Schema location '{}' does not match. Ignoring.", controlNodeDetail.getValue() == null ? testNodeDetail.getValue() : controlNodeDetail.getValue());
continue DIFFERENCES;
}
if (ignoreDifference(d)) {
LOG.debug("ignoreDifference matched. Ignoring difference: {}: {}", d.getDescription(), d);
continue DIFFERENCES;
} else {
LOG.warn("Found difference: {}: {}", d.getDescription(), d);
retDifferences.add(d);
}
}
}
return retDifferences;
}
use of org.custommonkey.xmlunit.DetailedDiff in project opennms by OpenNMS.
the class JdbcDataCollectionConfigTest method getDiff.
@SuppressWarnings("unchecked")
private DetailedDiff getDiff(StringWriter objectXML, StringBuffer exampleXML) throws SAXException, IOException {
DetailedDiff myDiff = new DetailedDiff(XMLUnit.compareXML(exampleXML.toString(), objectXML.toString()));
List<Difference> allDifferences = myDiff.getAllDifferences();
if (allDifferences.size() > 0) {
for (Difference d : allDifferences) {
System.err.println(d);
}
}
return myDiff;
}
use of org.custommonkey.xmlunit.DetailedDiff in project opennms by OpenNMS.
the class PersistenceSerializationTest method getDiff.
@SuppressWarnings("unchecked")
private static DetailedDiff getDiff(StringWriter objectXML, StringBuffer exampleXML) throws SAXException, IOException {
DetailedDiff myDiff = new DetailedDiff(XMLUnit.compareXML(exampleXML.toString(), objectXML.toString()));
List<Difference> allDifferences = myDiff.getAllDifferences();
if (allDifferences.size() > 0) {
for (Difference d : allDifferences) {
System.err.println(d);
}
}
return myDiff;
}
Aggregations