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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations