Search in sources :

Example 11 with ResponseValidator

use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.

the class HttpServerTest method requireThatFormPostDoesNotRemoveContentByDefault.

@Test
public void requireThatFormPostDoesNotRemoveContentByDefault() throws Exception {
    final TestDriver driver = TestDrivers.newInstance(new ParameterPrinterRequestHandler());
    final ResponseValidator response = driver.client().newPost("/status.html").addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED).setContent("foo=bar").execute();
    response.expectStatusCode(is(OK)).expectContent(is("{foo=[bar]}foo=bar"));
    assertThat(driver.close(), is(true));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) Test(org.testng.annotations.Test)

Example 12 with ResponseValidator

use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.

the class HttpServerTest method requireThatFormPostRemovesContentWhenConfiguredTo.

@Test
public void requireThatFormPostRemovesContentWhenConfiguredTo() throws Exception {
    final TestDriver driver = newDriverWithFormPostContentRemoved(new ParameterPrinterRequestHandler(), true);
    final ResponseValidator response = driver.client().newPost("/status.html").addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED).setContent("foo=bar").execute();
    response.expectStatusCode(is(OK)).expectContent(is("{foo=[bar]}"));
    assertThat(driver.close(), is(true));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) Test(org.testng.annotations.Test)

Example 13 with ResponseValidator

use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.

the class HttpServerTest method requireThatUriParametersAreParsed.

@Test
public void requireThatUriParametersAreParsed() throws Exception {
    final TestDriver driver = TestDrivers.newInstance(new ParameterPrinterRequestHandler());
    final ResponseValidator response = driver.client().newPost("/status.html?a=b&c=d").addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED).execute();
    response.expectStatusCode(is(OK)).expectContent(is("{a=[b], c=[d]}"));
    assertThat(driver.close(), is(true));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) Test(org.testng.annotations.Test)

Example 14 with ResponseValidator

use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.

the class HttpServerTest method requireThatFormCharsetIsHonored.

@Test
public void requireThatFormCharsetIsHonored() throws Exception {
    final TestDriver driver = newDriverWithFormPostContentRemoved(new ParameterPrinterRequestHandler(), true);
    final ResponseValidator response = driver.client().newPost("/status.html").addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED + ";charset=ISO-8859-1").setBinaryContent(new byte[] { 66, (byte) 230, 114, 61, 98, 108, (byte) 229 }).execute();
    response.expectStatusCode(is(OK)).expectContent(is("{B\u00e6r=[bl\u00e5]}"));
    assertThat(driver.close(), is(true));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) Test(org.testng.annotations.Test)

Example 15 with ResponseValidator

use of com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator in project vespa by vespa-engine.

the class HttpServerTest method requireThatEmptyFormPostWorks.

@Test
public void requireThatEmptyFormPostWorks() throws Exception {
    final TestDriver driver = TestDrivers.newInstance(new ParameterPrinterRequestHandler());
    final ResponseValidator response = driver.client().newPost("/status.html").addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED).execute();
    response.expectStatusCode(is(OK)).expectContent(is("{}"));
    assertThat(driver.close(), is(true));
}
Also used : ResponseValidator(com.yahoo.jdisc.http.server.jetty.SimpleHttpClient.ResponseValidator) 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