Search in sources :

Example 1 with MockServerHttpResponse

use of cn.taketoday.mock.http.server.reactive.MockServerHttpResponse in project today-framework by TAKETODAY.

the class MockServerHttpResponseTests method cookieHeaderSet.

@Test
void cookieHeaderSet() throws Exception {
    ResponseCookie foo11 = ResponseCookie.from("foo1", "bar1").build();
    ResponseCookie foo12 = ResponseCookie.from("foo1", "bar2").build();
    ResponseCookie foo21 = ResponseCookie.from("foo2", "baz1").build();
    ResponseCookie foo22 = ResponseCookie.from("foo2", "baz2").build();
    MockServerHttpResponse response = new MockServerHttpResponse();
    response.addCookie(foo11);
    response.addCookie(foo12);
    response.addCookie(foo21);
    response.addCookie(foo22);
    response.applyCookies();
    assertThat(response.getHeaders().get(HttpHeaders.SET_COOKIE)).isEqualTo(Arrays.asList("foo1=bar1", "foo1=bar2", "foo2=baz1", "foo2=baz2"));
}
Also used : ResponseCookie(cn.taketoday.http.ResponseCookie) MockServerHttpResponse(cn.taketoday.mock.http.server.reactive.MockServerHttpResponse) Test(org.junit.jupiter.api.Test)

Example 2 with MockServerHttpResponse

use of cn.taketoday.mock.http.server.reactive.MockServerHttpResponse in project today-infrastructure by TAKETODAY.

the class MockServerHttpResponseTests method cookieHeaderSet.

@Test
void cookieHeaderSet() throws Exception {
    ResponseCookie foo11 = ResponseCookie.from("foo1", "bar1").build();
    ResponseCookie foo12 = ResponseCookie.from("foo1", "bar2").build();
    ResponseCookie foo21 = ResponseCookie.from("foo2", "baz1").build();
    ResponseCookie foo22 = ResponseCookie.from("foo2", "baz2").build();
    MockServerHttpResponse response = new MockServerHttpResponse();
    response.addCookie(foo11);
    response.addCookie(foo12);
    response.addCookie(foo21);
    response.addCookie(foo22);
    response.applyCookies();
    assertThat(response.getHeaders().get(HttpHeaders.SET_COOKIE)).isEqualTo(Arrays.asList("foo1=bar1", "foo1=bar2", "foo2=baz1", "foo2=baz2"));
}
Also used : ResponseCookie(cn.taketoday.http.ResponseCookie) MockServerHttpResponse(cn.taketoday.mock.http.server.reactive.MockServerHttpResponse) Test(org.junit.jupiter.api.Test)

Aggregations

ResponseCookie (cn.taketoday.http.ResponseCookie)2 MockServerHttpResponse (cn.taketoday.mock.http.server.reactive.MockServerHttpResponse)2 Test (org.junit.jupiter.api.Test)2