Copy cookies and hints to ServerResponse builders

Closes gh-22351
This commit is contained in:
Arjen Poutsma
2019-03-26 16:19:13 +01:00
parent 6324a1b3fa
commit c152d246a8
5 changed files with 64 additions and 7 deletions

View File

@@ -41,6 +41,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse
import org.springframework.mock.web.test.server.MockServerWebExchange;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.result.view.ViewResolver;
import static org.junit.Assert.*;
@@ -302,6 +303,23 @@ public class DefaultServerResponseBuilderTests {
.verify();
}
@Test
public void copyCookies() {
Mono<ServerResponse> serverResponse = ServerResponse.ok()
.cookie(ResponseCookie.from("foo", "bar").build())
.syncBody("body");
assertFalse(serverResponse.block().cookies().isEmpty());
serverResponse = ServerResponse.ok()
.cookie(ResponseCookie.from("foo", "bar").build())
.body(BodyInserters.fromObject("body"));
assertFalse(serverResponse.block().cookies().isEmpty());
}
@Test
public void build() {
ResponseCookie cookie = ResponseCookie.from("name", "value").build();