Configure PayloadDiffMatcher to ignore whitespace by default.
Resolves #1203.
This commit is contained in:
committed by
Greg L. Turnquist
parent
de54c2c796
commit
72ef3ad5ea
@@ -60,6 +60,7 @@ public class PayloadDiffMatcher extends DiffMatcher {
|
||||
Document actualDocument = createDocumentFromSource(payload);
|
||||
return DiffBuilder.compare(expectedDocument) //
|
||||
.withTest(actualDocument) //
|
||||
.ignoreWhitespace() //
|
||||
.checkForSimilar() //
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user