Configure PayloadDiffMatcher to ignore whitespace by default.

Resolves #1203.
This commit is contained in:
Mikołaj Fejzer
2023-06-07 17:02:48 +02:00
committed by Greg L. Turnquist
parent de54c2c796
commit 72ef3ad5ea
2 changed files with 17 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ public class PayloadDiffMatcher extends DiffMatcher {
Document actualDocument = createDocumentFromSource(payload);
return DiffBuilder.compare(expectedDocument) //
.withTest(actualDocument) //
.ignoreWhitespace() //
.checkForSimilar() //
.build();
}

View File

@@ -46,6 +46,22 @@ public class PayloadDiffMatcherTest {
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() {