use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class JDiscContainerRequestTest method requireThatRequestHandlerThatThrowsInWriteWorks.
@Test(expected = WriteException.class)
public void requireThatRequestHandlerThatThrowsInWriteWorks() throws InterruptedException {
String DATA = "we have no bananas today";
Request req = new Request("http://banana/throwwrite", DATA.getBytes(Utf8.getCharset()));
try (JDisc container = JDisc.fromServicesXml(getXML(ThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/throwwrite"), Networking.disable)) {
Response response = container.handleRequest(req);
req.toString();
}
}
use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class RestApiTest method testbasicUpdate.
@Test
public void testbasicUpdate() throws Exception {
Request request = new Request("http://localhost:" + getFirstListenPort() + update_test_uri);
HttpPut httpPut = new HttpPut(request.getUri());
StringEntity entity = new StringEntity(update_test_doc, ContentType.create("application/json"));
httpPut.setEntity(entity);
assertThat(doRest(httpPut), is(update_test_response));
assertThat(getLog(), not(containsString("CREATE IF NON EXISTING IS TRUE")));
}
use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class RestApiTest method testConditionalPost.
@Test
public void testConditionalPost() throws Exception {
Request request = new Request("http://localhost:" + getFirstListenPort() + post_test_uri_cond);
HttpPost httpPost = new HttpPost(request.getUri());
StringEntity entity = new StringEntity(post_test_doc_cond, ContentType.create("application/json"));
httpPost.setEntity(entity);
String x = doRest(httpPost);
assertThat(x, is(post_test_response_cond));
}
use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class RestApiTest method testbasicGet.
@Test
public void testbasicGet() throws Exception {
Request request = new Request("http://localhost:" + getFirstListenPort() + get_test_uri);
HttpGet get = new HttpGet(request.getUri());
final String rest = doRest(get);
assertThat(rest, containsString(get_response_part1));
assertThat(rest, containsString(get_response_part2));
}
use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.
the class RestApiTest method testCreateIfNonExistingUpdateInDocTrue.
@Test
public void testCreateIfNonExistingUpdateInDocTrue() throws Exception {
Request request = new Request("http://localhost:" + getFirstListenPort() + update_test_create_if_non_existient_uri);
HttpPut httpPut = new HttpPut(request.getUri());
StringEntity entity = new StringEntity(update_test_create_if_non_existient_doc, ContentType.create("application/json"));
httpPut.setEntity(entity);
assertThat(doRest(httpPut), is(update_test_create_if_non_existing_response));
assertThat(getLog(), containsString("CREATE IF NON EXISTENT IS TRUE"));
}
Aggregations