Skip to content

Commit 988973d

Browse files
committed
Fix broken test case on Windows in JsonEncoder
The test case for pretty printed JSON output assumed that lines are always terminated with a new-line only. This is, however, not the case on Windows.
1 parent b1e7e5d commit 988973d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

metafacture-json/src/test/java/org/metafacture/json/JsonEncoderTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ public void testShouldNotPrefixPrettyPrintedOutputWithSpaces() {
193193
encoder.endRecord();
194194

195195
final InOrder ordered = inOrder(receiver);
196-
ordered.verify(receiver).process(fixQuotes("{\n 'L1' : 'V1'\n}"));
197-
ordered.verify(receiver).process(fixQuotes("{\n 'L2' : 'V2'\n}"));
196+
ordered.verify(receiver).process(useSystemSpecificLineSeparator(fixQuotes("{\n 'L1' : 'V1'\n}")));
197+
ordered.verify(receiver).process(useSystemSpecificLineSeparator(fixQuotes("{\n 'L2' : 'V2'\n}")));
198198
}
199199

200200
/*
@@ -206,4 +206,13 @@ private String fixQuotes(final String str) {
206206
return str.replace('\'', '"');
207207
}
208208

209+
/*
210+
* Utility method which replaces the new-line character with the platform-specific
211+
* line separator. This is necessary since Jackson uses different line separators
212+
* depending on the system environment.
213+
*/
214+
private String useSystemSpecificLineSeparator(final String str) {
215+
return str.replace("\n", System.lineSeparator());
216+
}
217+
209218
}

0 commit comments

Comments
 (0)