I have a problem in comparing xml strings.
My compare function is
public static boolean compareXMLs(String xmlSource, String xmlCompareWith){
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setNormalizeWhitespace(true);
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
Diff myDiff = new Diff(xmlSource, xmlCompareWith);
myDiff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener());
return myDiff.similar();
}
My unit test is
String xml1 = "<a>f</a>";
String xml2 = "<a>1</a>";
assertEquals(true, RestCommonUtility.compareXMLs(xml1, xml2));
xml1 = "<a></a>";
xml2 = "<a>1</a>";
assertEquals(true, RestCommonUtility.compareXMLs(xml1, xml2));
My unit test passed in first assert, but fails in 2nd assert. I set IgnoreTextAndAttributeValuesDifferenceListener
but still my 2nd assert fails. Is there any way to solve this problem.? Or is there any other framework could help in these kind of comparison?
No comments:
Post a Comment