Polish "Include cookies in the HTTP response snippet"

See gh-340
Closes gh-305
This commit is contained in:
Andy Wilkinson
2017-03-13 20:45:23 +00:00
parent 46190535f7
commit 1b5e75ff2c
5 changed files with 22 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ public class MockMvcResponseConverterTests {
private final MockMvcResponseConverter factory = new MockMvcResponseConverter();
@Test
public void httpResponse() {
public void basicResponse() {
MockHttpServletResponse response = new MockHttpServletResponse();
response.setStatus(HttpServletResponse.SC_OK);
@@ -67,6 +67,7 @@ public class MockMvcResponseConverterTests {
assertThat(operationResponse.getHeaders().size(), is(1));
assertTrue(operationResponse.getHeaders().containsKey(HttpHeaders.SET_COOKIE));
assertThat(operationResponse.getHeaders().get(HttpHeaders.SET_COOKIE), equalTo(Collections.singletonList("name=value;domain=localhost;HttpOnly")));
assertThat(operationResponse.getHeaders().get(HttpHeaders.SET_COOKIE), equalTo(
Collections.singletonList("name=value;domain=localhost;HttpOnly")));
}
}

View File

@@ -371,17 +371,16 @@ public class MockMvcRestDocumentationIntegrationTests {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(documentationConfiguration(this.restDocumentation)).build();
mockMvc.perform(get("/set-cookie"))
.andExpect(status().isOk())
mockMvc.perform(get("/set-cookie")).andExpect(status().isOk())
.andDo(document("set-cookie",
responseHeaders(headerWithName(HttpHeaders.SET_COOKIE).description("set-cookie"))));
responseHeaders(headerWithName(HttpHeaders.SET_COOKIE)
.description("set-cookie"))));
assertThat(
new File("build/generated-snippets/set-cookie/http-response.adoc"),
assertThat(new File("build/generated-snippets/set-cookie/http-response.adoc"),
is(snippet(asciidoctor())
.withContents(
httpResponse(asciidoctor(), HttpStatus.OK)
.header(HttpHeaders.SET_COOKIE, "name=value;domain=localhost;HttpOnly"))));
.withContents(httpResponse(asciidoctor(), HttpStatus.OK).header(
HttpHeaders.SET_COOKIE,
"name=value;domain=localhost;HttpOnly"))));
}
@Test