Skip to content

Commit 72ef3ad

Browse files
mfejzergregturn
authored andcommitted
Configure PayloadDiffMatcher to ignore whitespace by default.
Resolves #1203.
1 parent de54c2c commit 72ef3ad

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

spring-ws-test/src/main/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcher.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ protected Diff createDiff(Source payload) {
6060
Document actualDocument = createDocumentFromSource(payload);
6161
return DiffBuilder.compare(expectedDocument) //
6262
.withTest(actualDocument) //
63+
.ignoreWhitespace() //
6364
.checkForSimilar() //
6465
.build();
6566
}

spring-ws-test/src/test/java/org/springframework/ws/test/support/matcher/xmlunit2/PayloadDiffMatcherTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ public void match() {
4646
verify(message);
4747
}
4848

49+
@Test
50+
public void matchIgnoringWhitespace() {
51+
52+
String xml = "<response><success>true</success></response>";
53+
String xmlWithAdditionalWhitespace = "<response> <success>true</success> </response>";
54+
WebServiceMessage message = createMock(WebServiceMessage.class);
55+
expect(message.getPayloadSource()).andReturn(new StringSource(xml)).times(2);
56+
replay(message);
57+
58+
PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource(xmlWithAdditionalWhitespace));
59+
matcher.match(message);
60+
61+
verify(message);
62+
}
63+
64+
4965
@Test
5066
public void nonMatch() {
5167

0 commit comments

Comments
 (0)