Search in sources :

Example 31 with Request

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

the class RestApiTest method get_fieldset_parameter_is_propagated.

@Test
public void get_fieldset_parameter_is_propagated() throws IOException {
    Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/bar?fieldSet=foo,baz", getFirstListenPort()));
    HttpGet get = new HttpGet(request.getUri());
    String rest = doRest(get);
    assertThat(rest, containsString("\"fieldset\":\"foo,baz\""));
}
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 32 with Request

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

the class RestApiTest method invalid_wanted_document_count_parameter_returns_error_response.

@Test
public void invalid_wanted_document_count_parameter_returns_error_response() throws IOException {
    Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?wantedDocumentCount=aardvark", 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 33 with Request

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

the class RestApiTest method getLog.

// Get logs through some hackish fetch method. Logs is something the mocked backend write.
String getLog() throws IOException {
    // The mocked backend will throw a runtime exception wtih a log if delete is called three times..
    Request request = new Request("http://localhost:" + getFirstListenPort() + remove_test_uri);
    HttpDelete delete = new HttpDelete(request.getUri());
    doRest(delete);
    return doRest(delete);
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) Request(com.yahoo.application.container.handler.Request)

Example 34 with Request

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

the class RestApiTest method visit_concurrency_parameter_is_propagated.

@Test
public void visit_concurrency_parameter_is_propagated() throws IOException {
    Request request = new Request(String.format("http://localhost:%s/document/v1/namespace/document-type/docid/?concurrency=42", getFirstListenPort()));
    HttpGet get = new HttpGet(request.getUri());
    String rest = doRest(get);
    assertThat(rest, containsString("concurrency: 42"));
}
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 35 with Request

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

the class RestApiTest method testBadVisit.

@Test
public void testBadVisit() throws Exception {
    Request request = new Request("http://localhost:" + getFirstListenPort() + visit_test_bad_uri);
    HttpGet get = new HttpGet(request.getUri());
    String rest = doRest(get);
    assertThat(rest, containsString(visit_test_bad_response));
}
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