Example usage for org.apache.http.impl.client HttpClientBuilder build

List of usage examples for org.apache.http.impl.client HttpClientBuilder build

Introduction

In this page you can find the example usage for org.apache.http.impl.client HttpClientBuilder build.

Prototype

public CloseableHttpClient build() 

Source Link

Usage

From source file:com.gooddata.authentication.SstAuthenticationTest.java

@Test
public void shouldCreateHttpClient() {
    final HttpClientBuilder clientBuilder = mock(HttpClientBuilder.class);
    when(clientBuilder.build()).thenReturn(mock(CloseableHttpClient.class));

    final HttpClient httpClient = sstAuthentication.createHttpClient(new GoodDataEndpoint("host", 1, "http"),
            clientBuilder);/*from  w  w w.j  av a2s  .  c o m*/

    assertThat(httpClient, notNullValue());
    assertThat(httpClient, is(instanceOf(GoodDataHttpClient.class)));
}

From source file:com.gooddata.authentication.LoginPasswordAuthenticationTest.java

@Test
public void shouldCreateHttpClient() {
    final HttpClientBuilder clientBuilder = mock(HttpClientBuilder.class);
    when(clientBuilder.build()).thenReturn(mock(CloseableHttpClient.class));

    final HttpClient httpClient = loginPasswordAuthentication
            .createHttpClient(new GoodDataEndpoint("host", 1, "http"), clientBuilder);

    assertThat(httpClient, notNullValue());
    assertThat(httpClient, is(instanceOf(GoodDataHttpClient.class)));
}

From source file:com.intuit.wasabi.export.rest.impl.DefaultRestDriver.java

private CloseableHttpClient createCloseableHttpClient(final HttpClientBuilder httpClientBuilder) {
    return httpClientBuilder.build();
}

From source file:org.wildfly.swarm.topology.consul.AdvertisingTestBase.java

protected Map<?, ?> getDefinedServicesAsMap() throws IOException {
    HttpClientBuilder builder = HttpClientBuilder.create();
    CloseableHttpClient client = builder.build();

    HttpUriRequest request = new HttpGet(servicesUrl);
    CloseableHttpResponse response = client.execute(request);

    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
    String content = EntityUtils.toString(response.getEntity());
    return mapper.readValue(content, Map.class);
}

From source file:com.urswolfer.gerrit.client.rest.http.HttpRequestExecutor.java

public HttpResponse execute(HttpClientBuilder client, HttpRequestBase method, HttpContext context)
        throws IOException {
    return client.build().execute(method, context);
}

From source file:org.eclipse.cft.server.core.internal.ExternalRestTemplate.java

protected ClientHttpRequestFactory createRequestFactory() {
    HttpClientBuilder httpClientBuilder = HttpClients.custom().useSystemProperties();
    HttpClient httpClient = httpClientBuilder.build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);/*from  w w w . j ava 2  s  . c  o  m*/

    return requestFactory;
}

From source file:com.jkoolcloud.tnt4j.streams.fields.ActivityCacheTest.java

@Test
public void runStreams() throws Exception {
    InputStreamListener streamListener = mock(InputStreamListener.class);
    StreamTasksListener streamTasksListener = mock(StreamTasksListener.class);
    StreamsAgent.runFromAPI(cfgFile, streamListener, streamTasksListener);

    Thread.sleep(3000);/*  w w  w .ja v a  2s .  c  om*/

    HttpClientBuilder builder = HttpClientBuilder.create();
    HttpClient client = builder.build();

    Thread.sleep(500);

    sendRequest(client, PROGRESS_FILE);
    sendRequest(client, START_FILE);

    Thread.sleep(50000);

    verify(streamListener, times(2)).onStatusChange(any(TNTInputStream.class), (StreamStatus) any());
}

From source file:com.gooddata.authentication.SstAuthentication.java

@Override
public HttpClient createHttpClient(final GoodDataEndpoint endpoint, final HttpClientBuilder builder) {
    notNull(endpoint, "endpoint");
    notNull(builder, "builder");

    final HttpClient httpClient = builder.build();
    final SSTRetrievalStrategy strategy = new SimpleSSTRetrievalStrategy(sst);
    final HttpHost httpHost = new HttpHost(endpoint.getHostname(), endpoint.getPort(), endpoint.getProtocol());
    return new GoodDataHttpClient(httpClient, httpHost, strategy);
}

From source file:com.gooddata.authentication.LoginPasswordAuthentication.java

@Override
public HttpClient createHttpClient(final GoodDataEndpoint endpoint, final HttpClientBuilder builder) {
    notNull(endpoint, "endpoint");
    notNull(builder, "builder");

    final HttpClient httpClient = builder.build();
    final SSTRetrievalStrategy strategy = new LoginSSTRetrievalStrategy(login, password);
    final HttpHost httpHost = new HttpHost(endpoint.getHostname(), endpoint.getPort(), endpoint.getProtocol());
    return new GoodDataHttpClient(httpClient, httpHost, strategy);
}