use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.
the class HttpServerTest method requireThatFormAndUriParametersAreMerged.
@Test
public void requireThatFormAndUriParametersAreMerged() throws Exception {
final TestDriver driver = TestDrivers.newInstance(new ParameterPrinterRequestHandler());
final ResponseValidator response = driver.client().newPost("/status.html?a=b&c=d1").addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED).setContent("c=d2&e=f").execute();
response.expectStatusCode(is(OK)).expectContent(startsWith("{a=[b], c=[d1, d2], e=[f]}"));
assertThat(driver.close(), is(true));
}
use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.
the class HttpServerTest method requireThatRequestCookiesAreReceived.
@Test
public void requireThatRequestCookiesAreReceived() throws Exception {
final TestDriver driver = TestDrivers.newInstance(new CookiePrinterRequestHandler());
final ResponseValidator response = driver.client().newPost("/status.html").addHeader(COOKIE, "foo=bar").execute();
response.expectStatusCode(is(OK)).expectContent(containsString("[foo=bar]"));
assertThat(driver.close(), is(true));
}
use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.
the class HttpServerTest method requireThatFormPostWithThrowingHandlerIsExceptionSafe.
@Test
public void requireThatFormPostWithThrowingHandlerIsExceptionSafe() throws Exception {
final TestDriver driver = TestDrivers.newInstance(new ThrowingHandler());
final ResponseValidator response = driver.client().newPost("/status.html").addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED).setContent("a=b").execute();
response.expectStatusCode(is(INTERNAL_SERVER_ERROR));
assertThat(driver.close(), is(true));
}
use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.
the class HttpServerTest method requireThatFormPostWithCharsetSpecifiedWorks.
@Test
public void requireThatFormPostWithCharsetSpecifiedWorks() throws Exception {
final TestDriver driver = TestDrivers.newInstance(new ParameterPrinterRequestHandler());
final String requestContent = generateContent('a', 30);
final ResponseValidator response = driver.client().newPost("/status.html").addHeader(X_DISABLE_CHUNKING, "true").addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED + ";charset=UTF-8").setContent(requestContent).execute();
response.expectStatusCode(is(OK)).expectContent(startsWith('{' + requestContent + "=[]}"));
assertThat(driver.close(), is(true));
}
use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.
the class JDiscFilterForServletTest method request_can_be_forwarded_through_request_filter_to_servlet.
@Test
public void request_can_be_forwarded_through_request_filter_to_servlet() throws IOException {
TestDriver testDriver = requestFilterTestDriver();
ResponseValidator response = httpGet(testDriver, TestServlet.PATH).addHeader(TestRequestFilter.BYPASS_FILTER_HEADER, Boolean.TRUE.toString()).execute();
response.expectContent(containsString(TestServlet.RESPONSE_CONTENT));
}
Aggregations