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:org.wildfly.swarm.servlet.jpa.jta.test.ServletJpaJtaTest.java

@Test
@RunAsClient//  w w w  . j  a  v a  2  s. co m
@InSequence(3)
public void notEmpty() throws IOException {
    String result = Request.Get("http://localhost:8080/").execute().returnContent().asString().trim();
    assertThat(result).isNotEmpty().contains("1 Author: Title");
}

From source file:com.googlesource.gerrit.plugins.auditsl4j.LoggerAuditToCsvTest.java

@Test
public void testHttpCsvAudit() throws Exception {
    AuditWriterToStringList auditStrings = getPluginInstance(AuditWriterToStringList.class);

    Request.Get(webUrl + "config/server/version").execute().returnResponse();

    assertThat(waitFor(() -> auditStrings.strings.size() == 2)).isTrue();
    assertThat(auditStrings.strings.get(1)).contains(Version.getVersion());
}

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

@Test
public void callWithMethod() throws Exception {
    final String url = String.format("http://localhost:%s/%s", listenPort.getNumber(), path.getValue());
    Request request = null;//from   w  w  w.j  av  a 2 s  .c  om
    switch (method) {
    case "GET":
        request = Request.Get(url);
        break;
    case "POST":
        request = Request.Post(url);
        break;
    case "OPTIONS":
        request = Request.Options(url);
        break;
    case "DELETE":
        request = Request.Delete(url);
        break;
    case "PUT":
        request = Request.Put(url);
        break;
    }
    final Response response = request.connectTimeout(1000).execute();
    final HttpResponse httpResponse = response.returnResponse();
    assertThat(httpResponse.getStatusLine().getStatusCode(), is(200));
    assertThat(IOUtils.toString(httpResponse.getEntity().getContent()), is(expectedContent));
}

From source file:org.apache.james.jmap.ContainerTest.java

@Test
public void containerShouldBeReachableOnExposedPort() throws IOException, URISyntaxException {
    String containerIpAddress = container.getContainerIpAddress();
    Integer containerPort = container.getMappedPort(80);
    Response response = Request
            .Get(new URIBuilder().setScheme("http").setHost(containerIpAddress).setPort(containerPort).build())
            .execute();/*from ww  w.  j  a  v a2  s.co  m*/
    assertThat(response.returnResponse().getStatusLine().getStatusCode()).isEqualTo(200);
}

From source file:org.wildfly.swarm.microprofile.jwtauth.roles.AbstractRolesAllowedTest.java

@RunAsClient
@Test// w  ww . j  a va2 s  .c  o m
public void testRolesNotAllowed() throws Exception {
    Assert.assertEquals(403,
            Request.Get("http://localhost:8080/mpjwt/rolesClass")
                    .setHeader("Authorization", "Bearer " + createToken("Echoer2")).execute().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:com.qwazr.cluster.client.ClusterSingleClient.java

@Override
public Map<String, ClusterNodeJson> getNodes() {
    UBuilder uriBuilder = new UBuilder("/cluster/nodes");
    Request request = Request.Get(uriBuilder.build());
    return commonServiceRequest(request, null, null, MapStringClusterNodeJsonTypeRef, 200);
}

From source file:info.losd.galenweb.client.GalenClient.java

@Override
public List<GalenHealthCheck> getHealthChecks() {
    try {// ww w. j a v a 2s . c  o m
        HttpResponse response = Request.Get(String.format("%s/tasks", url)).execute().returnResponse();

        ReadContext ctx = JsonPath.parse(response.getEntity().getContent());

        JSONArray tasks = ctx.read("$._embedded.tasks");

        return new ObjectMapper().readValue(tasks.toJSONString(), new TypeReference<List<GalenHealthCheck>>() {
        });
    } catch (IOException e) {
        LOG.error("Problem getting health check list", e);
    } catch (PathNotFoundException e) {
        LOG.debug("There are no healthchecks");
    }

    return Collections.emptyList();
}

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

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

    HttpResponse httpResp = resp.returnResponse();
    assertNotNull(httpResp);//from ww  w .  j av  a  2  s. co m
    HttpEntity entity = httpResp.getEntity();
    assertNotNull(entity);
    StatusLine statusLine = httpResp.getStatusLine();
    assertNotNull(statusLine);

    assertEquals("check status code", HttpStatus.SC_OK, statusLine.getStatusCode());
    assertNotNull("content type not null", entity.getContentType());
    assertEquals("check content type", Representation.HAL_JSON_MEDIA_TYPE, entity.getContentType().getValue());

    String content = EntityUtils.toString(entity);

    assertNotNull("", content);

    JsonObject json = null;

    try {
        json = JsonObject.readFrom(content);
    } catch (Throwable t) {
        fail("parsing received json");
    }

    assertNotNull("check json not null", json);

    assertNotNull("check not null _link", json.get("_links"));
    assertTrue("check _link to be a json object", (json.get("_links") instanceof JsonObject));

    assertNotNull("check not null _returned property", json.get("_returned"));
    assertNotNull("check not null _size value", json.get("_size"));
    assertNotNull("check not null _total_pages", json.get("_total_pages"));

    assertEquals("check _returned value to be 1", 1, json.get("_returned").asInt());
    assertEquals("check _size value to be 2", 3, json.get("_size").asInt());
    assertEquals("check _total_pages value to be 2", 3, json.get("_total_pages").asInt());

    JsonObject links = (JsonObject) json.get("_links");

    assertNotNull("check not null self", links.get("self"));
    assertNotNull("check not null rh:root", links.get("rh:root"));
    assertNotNull("check not null rh:paging", links.get("rh:paging"));
    assertNotNull("check not null next", links.get("next"));
    assertNotNull("check not null first", links.get("first"));
    assertNotNull("check not null last", links.get("last"));
    assertNull("check null previous", links.get("previous"));

    Response respSelf = adminExecutor
            .execute(Request.Get(dbUriPaging.resolve(links.get("self").asObject().get("href").asString())));
    HttpResponse httpRespSelf = respSelf.returnResponse();
    assertNotNull(httpRespSelf);

    Response respRoot = adminExecutor
            .execute(Request.Get(dbUriPaging.resolve(links.get("rh:root").asObject().get("href").asString())));
    HttpResponse httpRespRoot = respRoot.returnResponse();
    assertNotNull(httpRespRoot);

    Response respNext = adminExecutor
            .execute(Request.Get(dbUriPaging.resolve(links.get("next").asObject().get("href").asString())));
    HttpResponse httpRespNext = respNext.returnResponse();
    assertNotNull(httpRespNext);

    Response respFirst = adminExecutor
            .execute(Request.Get(dbUriPaging.resolve(links.get("first").asObject().get("href").asString())));
    HttpResponse respRespFirst = respFirst.returnResponse();
    assertNotNull(respRespFirst);

    Response respLast = adminExecutor
            .execute(Request.Get(dbUriPaging.resolve(links.get("last").asObject().get("href").asString())));
    HttpResponse httpRespLast = respLast.returnResponse();
    assertNotNull(httpRespLast);
}

From source file:org.n52.iceland.skeleton.Base.java

public String kvp(String query) throws IOException {
    String url = getEndpointURL() + "?" + query;
    return Request.Get(url).execute().returnContent().asString();
}