use of org.custommonkey.xmlunit.NodeDetail 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;
}
Aggregations