Skip to content

XmlExpectationsHelper.assertXmlEqual missing "regardless of order" case [SPR-15156] #19722

@spring-projects-issues

Description

@spring-projects-issues

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:

Issue Links:

Metadata

Metadata

Assignees

Labels

in: testIssues in the test moduletype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions