Cope with different content length due to Windows line endings
Windows uses \r\n for line endings whereas Unix-like platforms us \n. This causes the content length of a pretty-printed response to be longer on Windows.
This commit is contained in:
@@ -265,16 +265,21 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
.header("Accept", MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("Content-Length", "13")
|
||||
.content("{\"a\":\"alpha\"}"))));
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\"%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/preprocessed-request/http-request.adoc"),
|
||||
is(snippet().withContents(
|
||||
httpRequest(RequestMethod.GET, "/").header("Host", "localhost")
|
||||
.header("b", "bravo")
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Accept", MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("Content-Length", "22")
|
||||
.content(String.format("{%n \"a\" : \"<<beta>>\"%n}")))));
|
||||
is(snippet()
|
||||
.withContents(
|
||||
httpRequest(RequestMethod.GET, "/")
|
||||
.header("Host", "localhost")
|
||||
.header("b", "bravo")
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Accept",
|
||||
MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("Content-Length",
|
||||
Integer.toString(prettyPrinted.getBytes().length))
|
||||
.content(prettyPrinted))));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user