Search in sources :

Example 16 with ResponseValidator

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));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) Test(org.testng.annotations.Test)

Example 17 with ResponseValidator

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));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) Test(org.testng.annotations.Test)

Example 18 with ResponseValidator

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));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) Test(org.testng.annotations.Test)

Example 19 with ResponseValidator

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));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.testng.annotations.Test)

Example 20 with ResponseValidator

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));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) TestDriver(com.yahoo.jdisc.http.server.jetty.TestDriver) Test(org.testng.annotations.Test)

Aggregations

ResponseValidator (com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator)20 Test (org.testng.annotations.Test)20 TestDriver (com.yahoo.jdisc.http.server.jetty.TestDriver)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3