Example usage for org.apache.http.osgi.services HttpClientBuilderFactory HttpClientBuilderFactory

List of usage examples for org.apache.http.osgi.services HttpClientBuilderFactory HttpClientBuilderFactory

Introduction

In this page you can find the example usage for org.apache.http.osgi.services HttpClientBuilderFactory HttpClientBuilderFactory.

Prototype

HttpClientBuilderFactory

Source Link

Usage

From source file:com.adobe.acs.commons.http.impl.HttpClientFactoryImplTest.java

@Before
public void setup() throws Exception {
    config = new HashMap<String, Object>();
    username = RandomStringUtils.randomAlphabetic(5);
    password = RandomStringUtils.randomAlphabetic(6);
    final String authHeaderValue = Base64.encodeBase64String((username + ":" + password).getBytes());

    config.put("hostname", "localhost");
    config.put("port", mockServerRule.getPort().intValue());

    mockServerClient.when(request().withMethod("GET").withPath("/anon"))
            .respond(response().withStatusCode(200).withBody("OK"));
    mockServerClient.when(request().withMethod("GET").withPath("/anonJson"))
            .respond(response().withStatusCode(200).withBody("{ 'foo' : 'bar' }"));
    mockServerClient.when(request().withMethod("GET").withPath("/auth").withHeader("Authorization",
            "Basic " + authHeaderValue)).respond(response().withStatusCode(200).withBody("OK"));
    impl = new HttpClientFactoryImpl();
    PrivateAccessor.setField(impl, "httpClientBuilderFactory", new HttpClientBuilderFactory() {
        @Override/*from  w  w  w  .  j  a  v  a2 s .c om*/
        public HttpClientBuilder newBuilder() {
            return HttpClients.custom();
        }
    });
}