- //Diff diff = new Diff(getCompareDoc(controlXml), getCompareDoc(testXml));
- final org.xmlunit.diff.Diff documentDiff = DiffBuilder
- .compare(controlXml)
- .withTest(testXml)
- .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName))
- .checkForSimilar()
- .withDifferenceEvaluator((comparison, outcome) -> {
- if (outcome != ComparisonResult.EQUAL && comparison.getType() == ComparisonType.ATTR_VALUE) {
- Attr a = (Attr) comparison.getControlDetails().getTarget();
- if ("commit-seconds".equals(Nodes.getQName(a).getLocalPart()) || "commit-localtime".equals(Nodes.getQName(a).getLocalPart())
- && "configuration".equals(Nodes.getQName(a.getOwnerElement()).getLocalPart())) {
- return ComparisonResult.EQUAL;
- }
- }
- else
- return ComparisonResult.SIMILAR;
-
- return outcome;
- })
- .ignoreComments()
- .ignoreWhitespace()
- .build();
- if(documentDiff.hasDifferences())
- return false;
- else
- return true;
+ Diff diff = new Diff(getCompareDoc(controlXml), getCompareDoc(testXml));
+ diff.overrideElementQualifier(new ElementNameQualifier() {
+ @Override
+ protected boolean equalsNamespace(Node control, Node test) {
+ return true;
+ }
+ });
+ diff.overrideDifferenceListener(new DifferenceListener() {
+ @Override
+ public int differenceFound(Difference diff) {
+ if (diff.getId() == DifferenceConstants.ATTR_VALUE_ID) {
+ return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
+ }
+ return RETURN_ACCEPT_DIFFERENCE;
+ }
+ @Override
+ public void skippedComparison(Node arg0, Node arg1) { }
+ });
+ if(diff.similar())
+ return true;
+ else
+ return false;
+ }
+ catch(SAXException se)
+ {
+ se.printStackTrace();
+ throw new Exception(se.getMessage());