Search in sources :

Example 1 with MockServerHttpRequest

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

the class MockServerHttpRequestTests method cookieHeaderSet.

@Test
void cookieHeaderSet() {
    HttpCookie foo11 = new HttpCookie("foo1", "bar1");
    HttpCookie foo12 = new HttpCookie("foo1", "bar2");
    HttpCookie foo21 = new HttpCookie("foo2", "baz1");
    HttpCookie foo22 = new HttpCookie("foo2", "baz2");
    MockServerHttpRequest request = MockServerHttpRequest.get("/").cookie(foo11, foo12, foo21, foo22).build();
    assertThat(request.getCookies().get("foo1")).isEqualTo(Arrays.asList(foo11, foo12));
    assertThat(request.getCookies().get("foo2")).isEqualTo(Arrays.asList(foo21, foo22));
    assertThat(request.getHeaders().get(HttpHeaders.COOKIE)).isEqualTo(Arrays.asList("foo1=bar1", "foo1=bar2", "foo2=baz1", "foo2=baz2"));
}
Also used : MockServerHttpRequest(cn.taketoday.mock.http.server.reactive.MockServerHttpRequest) HttpCookie(cn.taketoday.http.HttpCookie) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with MockServerHttpRequest

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

the class MockServerHttpRequestTests method queryParams.

@Test
void queryParams() {
    MockServerHttpRequest request = MockServerHttpRequest.get("/foo bar?a=b").queryParam("name A", "value A1", "value A2").queryParam("name B", "value B1").build();
    assertThat(request.getURI().toString()).isEqualTo("/foo%20bar?a=b&name%20A=value%20A1&name%20A=value%20A2&name%20B=value%20B1");
}
Also used : MockServerHttpRequest(cn.taketoday.mock.http.server.reactive.MockServerHttpRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with MockServerHttpRequest

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

the class MockServerHttpRequestTests method queryParams.

@Test
void queryParams() {
    MockServerHttpRequest request = MockServerHttpRequest.get("/foo bar?a=b").queryParam("name A", "value A1", "value A2").queryParam("name B", "value B1").build();
    assertThat(request.getURI().toString()).isEqualTo("/foo%20bar?a=b&name%20A=value%20A1&name%20A=value%20A2&name%20B=value%20B1");
}
Also used : MockServerHttpRequest(cn.taketoday.mock.http.server.reactive.MockServerHttpRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with MockServerHttpRequest

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

the class MockServerHttpRequestTests method cookieHeaderSet.

@Test
void cookieHeaderSet() {
    HttpCookie foo11 = new HttpCookie("foo1", "bar1");
    HttpCookie foo12 = new HttpCookie("foo1", "bar2");
    HttpCookie foo21 = new HttpCookie("foo2", "baz1");
    HttpCookie foo22 = new HttpCookie("foo2", "baz2");
    MockServerHttpRequest request = MockServerHttpRequest.get("/").cookie(foo11, foo12, foo21, foo22).build();
    assertThat(request.getCookies().get("foo1")).isEqualTo(Arrays.asList(foo11, foo12));
    assertThat(request.getCookies().get("foo2")).isEqualTo(Arrays.asList(foo21, foo22));
    assertThat(request.getHeaders().get(HttpHeaders.COOKIE)).isEqualTo(Arrays.asList("foo1=bar1", "foo1=bar2", "foo2=baz1", "foo2=baz2"));
}
Also used : MockServerHttpRequest(cn.taketoday.mock.http.server.reactive.MockServerHttpRequest) HttpCookie(cn.taketoday.http.HttpCookie) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MockServerHttpRequest (cn.taketoday.mock.http.server.reactive.MockServerHttpRequest)4 Test (org.junit.jupiter.api.Test)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 HttpCookie (cn.taketoday.http.HttpCookie)2