Skip to content

Commit

Permalink
Configure PayloadDiffMatcher to ignore whitespace by default.
Browse files Browse the repository at this point in the history
Resolves #1203.
  • Loading branch information
mfejzer authored and gregturn committed Jul 14, 2023
1 parent de54c2c commit 72ef3ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected Diff createDiff(Source payload) {
Document actualDocument = createDocumentFromSource(payload);
return DiffBuilder.compare(expectedDocument) //
.withTest(actualDocument) //
.ignoreWhitespace() //
.checkForSimilar() //
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ public void match() {
verify(message);
}

@Test
public void matchIgnoringWhitespace() {

String xml = "<response><success>true</success></response>";
String xmlWithAdditionalWhitespace = "<response> <success>true</success> </response>";
WebServiceMessage message = createMock(WebServiceMessage.class);
expect(message.getPayloadSource()).andReturn(new StringSource(xml)).times(2);
replay(message);

PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource(xmlWithAdditionalWhitespace));
matcher.match(message);

verify(message);
}


@Test
public void nonMatch() {

Expand Down

0 comments on commit 72ef3ad

Please sign in to comment.