Search in sources :

Example 26 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method testbasicEncodingV1.

@Test
public void testbasicEncodingV1() throws Exception {
    Request request = new Request("http://localhost:" + getFirstListenPort() + get_enc_test_uri_v1);
    HttpGet get = new HttpGet(request.getUri());
    final String rest = doRest(get);
    assertThat(rest, containsString(get_enc_response_part1));
    assertThat(rest, containsString(get_enc_response_part2));
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) Request(com.yahoo.application.container.handler.Request) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 27 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method testbasicPost.

@Test
public void testbasicPost() throws Exception {
    Request request = new Request("http://localhost:" + getFirstListenPort() + post_test_uri);
    HttpPost httpPost = new HttpPost(request.getUri());
    StringEntity entity = new StringEntity(post_test_doc, ContentType.create("application/json"));
    httpPost.setEntity(entity);
    String x = doRest(httpPost);
    assertThat(x, is(post_test_response));
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) Request(com.yahoo.application.container.handler.Request) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 28 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method testEmptyPost.

@Test
public void testEmptyPost() throws Exception {
    Request request = new Request("http://localhost:" + getFirstListenPort() + post_test_uri);
    HttpPost httpPost = new HttpPost(request.getUri());
    StringEntity entity = new StringEntity("", ContentType.create("application/json"));
    httpPost.setEntity(entity);
    String x = doRest(httpPost);
    assertThat(x, containsString("Could not read document, no document?"));
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) Request(com.yahoo.application.container.handler.Request) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 29 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method negative_document_count_parameter_returns_error_response.

@Test
public void negative_document_count_parameter_returns_error_response() throws IOException {
    Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?wantedDocumentCount=-1", getFirstListenPort()));
    HttpGet get = new HttpGet(request.getUri());
    String rest = doRest(get);
    assertThat(rest, containsString("Invalid 'wantedDocumentCount' value. Expected positive integer"));
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) Request(com.yahoo.application.container.handler.Request) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 30 with Request

use of com.yahoo.application.container.handler.Request in project vespa by vespa-engine.

the class RestApiTest method invalid_visit_concurrency_parameter_returns_error_response.

@Test
public void invalid_visit_concurrency_parameter_returns_error_response() throws IOException {
    Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?concurrency=badgers", getFirstListenPort()));
    HttpGet get = new HttpGet(request.getUri());
    String rest = doRest(get);
    assertThat(rest, containsString("Invalid 'concurrency' value. Expected positive integer"));
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) Request(com.yahoo.application.container.handler.Request) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Aggregations

Request (com.yahoo.application.container.handler.Request)46 Test (org.junit.Test)44 StringContains.containsString (org.hamcrest.core.StringContains.containsString)17 HttpGet (org.apache.http.client.methods.HttpGet)14 Response (com.yahoo.application.container.handler.Response)7 StringEntity (org.apache.http.entity.StringEntity)7 HttpPut (org.apache.http.client.methods.HttpPut)4 HttpPost (org.apache.http.client.methods.HttpPost)3 Application (com.yahoo.vespa.hosted.controller.Application)2 ContainerControllerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester)2 ControllerContainerTest (com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest)2 HttpResponse (org.apache.http.HttpResponse)2 HttpDelete (org.apache.http.client.methods.HttpDelete)2 MockHttpHandler (com.yahoo.application.container.handlers.MockHttpHandler)1 MockRenderer (com.yahoo.application.container.renderers.MockRenderer)1 Version (com.yahoo.component.Version)1 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)1 HttpRequest (com.yahoo.jdisc.http.HttpRequest)1 DiscFilterRequest (com.yahoo.jdisc.http.filter.DiscFilterRequest)1 ServletOrJdiscHttpRequest (com.yahoo.jdisc.http.servlet.ServletOrJdiscHttpRequest)1