Example usage for org.apache.http.client.fluent Request execute

List of usage examples for org.apache.http.client.fluent Request execute

Introduction

In this page you can find the example usage for org.apache.http.client.fluent Request execute.

Prototype

public Response execute() throws ClientProtocolException, IOException 

Source Link

Usage

From source file:org.ow2.proactive.addons.webhook.service.JsonRestApacheRequestService.java

@SuppressWarnings("WeakerAccess")
protected RestResponse executeRequest(final Request request) throws IOException {
    Response requestResponse = request.execute();
    HttpResponse responseObject = requestResponse.returnResponse();
    return new RestResponse(responseObject.getStatusLine().getStatusCode(),
            EntityUtils.toString(responseObject.getEntity()));
}

From source file:io.gravitee.gateway.standalone.MultiTenantGatewayTest.java

@Test
public void call_get_query_params() throws Exception {
    Request request = Request.Get("http://localhost:8082/test/my_team");
    Response response = request.execute();
    HttpResponse returnResponse = response.returnResponse();

    assertEquals(HttpStatus.SC_OK, returnResponse.getStatusLine().getStatusCode());
}

From source file:io.gravitee.gateway.standalone.PolicyNotFoundGatewayTest.java

@Test
public void call_get_started_api() throws Exception {
    Request request = Request.Get("http://localhost:8082/test/my_team");
    Response response = request.execute();
    HttpResponse returnResponse = response.returnResponse();

    // The gateway returns a NOT_FOUND (404) because the API can't be deployed correctly.
    // The API is not correctly deployed because a required policy can not be found
    assertEquals(HttpStatus.SC_NOT_FOUND, returnResponse.getStatusLine().getStatusCode());
}

From source file:io.gravitee.gateway.standalone.NotFoundGatewayTest.java

@Test
public void call_get_not_started_api() throws Exception {
    Request request = Request.Get("http://localhost:8082/not_started_api");
    Response response = request.execute();
    HttpResponse returnResponse = response.returnResponse();

    assertEquals(HttpStatusCode.NOT_FOUND_404, returnResponse.getStatusLine().getStatusCode());
}

From source file:io.gravitee.gateway.platforms.jetty.JettyEmbeddedContainerTest.java

@Test
public void doHttpGet() throws IOException {
    Request request = Request.Get("http://localhost:8082/test");
    Response response = request.execute();
    HttpResponse returnResponse = response.returnResponse();

    //assertEquals(HttpStatus.SC_BAD_REQUEST, returnResponse.getStatusLine().getStatusCode());
}

From source file:io.gravitee.gateway.platforms.jetty.JettyEmbeddedContainerTest.java

@Test
public void doHttp404() throws IOException {
    Request request = Request.Get("http://localhost:8082/unknow");
    Response response = request.execute();
    HttpResponse returnResponse = response.returnResponse();

    assertEquals(HttpStatusCode.NOT_FOUND_404, returnResponse.getStatusLine().getStatusCode());
}

From source file:org.mule.module.http.functional.listener.HttpListenerContentTypeTestCase.java

private void testRejectContentType(Request request, String expectedMessage) throws IOException {
    HttpResponse response = request.execute().returnResponse();
    StatusLine statusLine = response.getStatusLine();

    assertThat(IOUtils.toString(response.getEntity().getContent()), containsString(expectedMessage));
    assertThat(statusLine.getStatusCode(), is(BAD_REQUEST.getStatusCode()));
    assertThat(statusLine.getReasonPhrase(), is(BAD_REQUEST.getReasonPhrase()));
}

From source file:io.gravitee.gateway.standalone.ServiceUnavailableTest.java

@Test
public void call_available_api() throws Exception {
    Request request = Request.Get("http://localhost:8082/test/my_team");
    Response response = request.execute();
    HttpResponse returnResponse = response.returnResponse();

    assertEquals(HttpStatus.SC_OK, returnResponse.getStatusLine().getStatusCode());
}

From source file:io.gravitee.gateway.standalone.ServiceUnavailableTest.java

@Test
public void call_unavailable_api() throws Exception {
    // Set the endpoint as down
    api.getProxy().getEndpoints().get(0).setStatus(Endpoint.Status.DOWN);

    Request request = Request.Get("http://localhost:8082/test/my_team");
    Response response = request.execute();
    HttpResponse returnResponse = response.returnResponse();

    assertEquals(HttpStatus.SC_SERVICE_UNAVAILABLE, returnResponse.getStatusLine().getStatusCode());
}

From source file:io.gravitee.gateway.standalone.ServiceUnavailableTest.java

@Test
public void call_availableAndUnavailable_api() throws Exception {
    // Set the endpoint as down
    api.getProxy().getEndpoints().get(0).setStatus(Endpoint.Status.DOWN);

    Request request = Request.Get("http://localhost:8082/test/my_team");
    Response response = request.execute();
    HttpResponse returnResponse = response.returnResponse();

    assertEquals(HttpStatus.SC_SERVICE_UNAVAILABLE, returnResponse.getStatusLine().getStatusCode());

    // Set the endpoint as up
    api.getProxy().getEndpoints().get(0).setStatus(Endpoint.Status.UP);

    Request request2 = Request.Get("http://localhost:8082/test/my_team");
    Response response2 = request2.execute();
    HttpResponse returnResponse2 = response2.returnResponse();

    assertEquals(HttpStatus.SC_OK, returnResponse2.getStatusLine().getStatusCode());
}