-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Closed
Copy link
Labels
Milestone
Description
Matthew Depue opened SPR-15156 and commented
XmlExpectationsHelper.assertXmlEqual
does not work "regardless of order" as stated in the JavaDoc and as was supported in 4.x.
#18615 shows an example of using the XMLUnit DiffBuilder
with a NodeMatcher
that seems to have not made it into the current code. However, my local fix uses ElementSelectors.byNameAndText
instead of just ElementSelectors.byName
.
public void assertXmlEqual(String expected, String actual) throws Exception {
Diff diffSimilar = DiffBuilder.compare(expected).withTest(actual)
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
.ignoreWhitespace().ignoreComments()
.checkForSimilar()
.build();
if (diffSimilar.hasDifferences()) {
AssertionErrors.fail("Body content " + diffSimilar.toString());
}
}
There is also a unit test missing, something along the lines of the attached file is needed.
Affects: 5.0 M4
Attachments:
- XmlExpectationsHelperTests.java (3.19 kB)
Issue Links:
- XMLUnit 2.x support [SPR-14043] #18615 XMLUnit 2.x support