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.debux.webmotion.server.tools.RequestBuilder.java

/**
 * @return a get request
 */
public Request Get() throws URISyntaxException {
    return Request.Get(this.build());
}

From source file:io.gravitee.gateway.standalone.SimpleGatewayTest.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();

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

From source file:com.qwazr.semaphores.SemaphoresSingleClient.java

@Override
public Set<String> getSemaphores(Boolean local, String group, Integer msTimeout) {
    UBuilder uriBuilder = new UBuilder(SCRIPT_PREFIX_SEMAPHORES).setParameters(local, group, msTimeout);
    Request request = Request.Get(uriBuilder.build());
    return commonServiceRequest(request, null, msTimeout, SetStringTypeRef, 200);
}

From source file:net.palette_software.pet.restart.HelperHttpClient.java

static String getPage(String targetURL) throws Exception {
    Request x = Request.Get(targetURL);
    Response y = x.execute();/*from  ww w. jav a2  s .c o m*/
    Content z = y.returnContent();
    return z.toString();
}

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

@Test
public void call_round_robin_lb_multiple_endpoints() throws Exception {
    Request request = Request.Get("http://localhost:8082/echo/helloworld");

    int calls = 20;

    for (int i = 0; i < calls; i++) {
        Response response = request.execute();
        HttpResponse returnResponse = response.returnResponse();

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

        String workerHeader = returnResponse.getFirstHeader("worker").getValue();
        assertEquals("worker#" + (i % 2), workerHeader);
    }//from  w w  w.j a  v  a  2 s.c  o  m

}

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

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

    assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT, 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:edu.xjtu.qxcamerabridge.DescriptorXMLParser.java

/**
 * Read the http cotent detected by the URL.
 *
 * @param deviceURL suppose to be the URL of device descriptor XML.
 * @return  the working instance for chained code style.
 * @throws IOException/*from   w w  w.jav  a2s . c  o m*/
 */
public DescriptorXMLParser getPageContent(String deviceURL) throws IOException {

    Response reply = Request.Get(deviceURL).execute();
    pageContent = reply.returnContent().asString();
    //System.out.println(pageContent);
    return this;
}

From source file:com.qwazr.graph.GraphSingleClient.java

@Override
public Set<String> list() {
    UBuilder uBuilder = new UBuilder(GRAPH_PREFIX);
    Request request = Request.Get(uBuilder.build());
    return commonServiceRequest(request, null, null, SetStringTypeRef, 200);
}

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

@Test
public void call_weighted_lb_multiple_endpoints() throws Exception {
    Request request = Request.Get("http://localhost:8082/echo/helloworld");
    Map<String, Integer> counts = new HashMap<>();
    int calls = 10;

    for (int i = 0; i < calls; i++) {
        Response response = request.execute();
        HttpResponse returnResponse = response.returnResponse();

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

        String workerHeader = returnResponse.getFirstHeader("worker").getValue();

        Integer workerCount = counts.get(workerHeader);
        if (workerCount == null) {
            workerCount = 1;//  w w  w  .ja v a  2s .c om
        } else {
            ++workerCount;
        }
        counts.put(workerHeader, workerCount);

    }

    assertEquals(3, (int) counts.get("worker#0"));
    assertEquals(7, (int) counts.get("worker#1"));
}