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

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

Introduction

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

Prototype

public static Request Get(final String uri) 

Source Link

Usage

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:fm.last.peyote.cacti.JmxInputProcessor.java

private String[] fetchCactiDataItemsFromUrl(String url) throws ClientProtocolException, IOException {
    String content = Request.Get(url).execute().returnContent().asString();
    String[] keyValues = content.split(" ");
    List<String> result = Lists.newArrayList();
    for (String keyValue : keyValues) {
        result.add(keyValue.split(":")[0]);
    }//from w  w  w . ja  va2s  .  c  o  m
    return result.toArray(new String[0]);
}

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

@Test
public void stoppedListenerReturns503() throws Exception {
    HttpListener httpListener = (HttpListener) ((Flow) getFlowConstruct("testPathFlow")).getMessageSource();
    httpListener.stop();//  w  w  w . j  a v a2  s  . com
    final Response response = Request.Get(getLifecycleConfigUrl("/path/subpath")).execute();
    assertThat(response.returnResponse().getStatusLine().getStatusCode(), is(503));
}

From source file:com.qwazr.cluster.client.ClusterSingleClient.java

@Override
public ClusterStatusJson list() {
    UBuilder uriBuilder = new UBuilder("/cluster");
    Request request = Request.Get(uriBuilder.build());
    return commonServiceRequest(request, null, null, ClusterStatusJson.class, 200);
}

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.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:org.wildfly.swarm.microprofile.jwtauth.roles.AbstractRolesAllowedTest.java

@RunAsClient
@Test//from  w w  w . ja v  a 2s.c om
public void testRolesAllowed() throws Exception {
    String response = Request.Get("http://localhost:8080/mpjwt/rolesClass")
            .setHeader("Authorization", "Bearer " + createToken("Echoer")).execute().returnContent().asString();
    Assert.assertEquals(response, "Hello jdoe@example.com");
}

From source file:com.px100systems.util.IpLocator.java

public static Info locateIpOrHost(String ipOrHost) {
    try {/*from w w w . j  ava2s .  c  o  m*/
        JsonObject jso = new com.google.gson.JsonParser().parse(
                Request.Get("http://freegeoip.net/json/" + ipOrHost).execute().returnContent().asString())
                .getAsJsonObject();

        return new Info(jso.getAsJsonPrimitive("ip").getAsString(),
                jso.getAsJsonPrimitive("country_code").getAsString(),
                jso.getAsJsonPrimitive("country_name").getAsString(),
                jso.getAsJsonPrimitive("region_code").getAsString(),
                jso.getAsJsonPrimitive("region_name").getAsString(),
                jso.getAsJsonPrimitive("city").getAsString(), jso.getAsJsonPrimitive("zip_code").getAsString(),
                jso.getAsJsonPrimitive("latitude").getAsDouble(),
                jso.getAsJsonPrimitive("longitude").getAsDouble());
    } catch (IOException e) {
        return null;
    }
}

From source file:com.softinstigate.restheart.integrationtest.SecurityIT.java

@Test
public void testAuthentication() throws Exception {
    Response resp = adminExecutor.execute(Request.Get(rootUri));

    HttpResponse httpResp = resp.returnResponse();
    assertNotNull(httpResp);/*from   w  w w . j a  v a 2s.  c  o m*/

    StatusLine statusLine = httpResp.getStatusLine();
    assertNotNull(statusLine);

    assertEquals("check authorized", HttpStatus.SC_OK, statusLine.getStatusCode());
}

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

protected void testResponseIsContentLengthEncoding(String url, HttpVersion httpVersion) throws IOException {
    final Response response = Request.Get(url).version(httpVersion).connectTimeout(1000).socketTimeout(1000)
            .execute();// www.jav a 2s.co m
    final HttpResponse httpResponse = response.returnResponse();
    final Header transferEncodingHeader = httpResponse.getFirstHeader(TRANSFER_ENCODING);
    final Header contentLengthHeader = httpResponse.getFirstHeader(CONTENT_LENGTH);
    assertThat(contentLengthHeader, notNullValue());
    assertThat(transferEncodingHeader, nullValue());
    assertThat(IOUtils.toString(httpResponse.getEntity().getContent()), is(TEST_BODY));
}