Example usage for org.apache.http.config Registry lookup

List of usage examples for org.apache.http.config Registry lookup

Introduction

In this page you can find the example usage for org.apache.http.config Registry lookup.

Prototype

public I lookup(String str) 

Source Link

Usage

From source file:io.wcm.caravan.commons.httpclient.impl.HttpClientItemAsyncTest.java

@Test
public void testWithClientCertificate() {
    HttpClientConfigImpl config = context.registerInjectActivateService(new HttpClientConfigImpl(),
            ImmutableMap.<String, Object>builder()
                    .put(KEYSTORE_PATH_PROPERTY, CertificateLoaderTest.KEYSTORE_PATH)
                    .put(KEYSTORE_PASSWORD_PROPERTY, CertificateLoaderTest.KEYSTORE_PASSWORD)
                    .put(TRUSTSTORE_PATH_PROPERTY, CertificateLoaderTest.TRUSTSTORE_PATH)
                    .put(TRUSTSTORE_PASSWORD_PROPERTY, CertificateLoaderTest.TRUSTSTORE_PASSWORD).build());

    HttpClientItem item = new HttpClientItem(config);
    HttpAsyncClient client = item.getHttpAsyncClient();

    Registry<SchemeIOSessionStrategy> schemeRegistry = HttpClientTestUtils.getSchemeRegistry(client);
    SchemeIOSessionStrategy schemeSocketFactory = schemeRegistry.lookup("https");

    assertNotEquals(schemeSocketFactory, SSLConnectionSocketFactory.getSocketFactory());
    item.close();//from ww w.ja  va 2  s  .  c  om
}

From source file:io.wcm.caravan.commons.httpasyncclient.impl.HttpClientItemAsyncTest.java

@Test
public void testWithClientCertificate() {
    HttpClientConfigImpl config = context.registerInjectActivateService(new HttpClientConfigImpl(),
            ImmutableMap.<String, Object>builder()
                    .put(KEYSTORE_PATH_PROPERTY, CertificateLoaderTest.KEYSTORE_PATH)
                    .put(KEYSTORE_PASSWORD_PROPERTY, CertificateLoaderTest.KEYSTORE_PASSWORD)
                    .put(TRUSTSTORE_PATH_PROPERTY, CertificateLoaderTest.TRUSTSTORE_PATH)
                    .put(TRUSTSTORE_PASSWORD_PROPERTY, CertificateLoaderTest.TRUSTSTORE_PASSWORD).build());

    HttpAsyncClientItem item = new HttpAsyncClientItem(config);
    HttpAsyncClient client = item.getHttpAsyncClient();

    Registry<SchemeIOSessionStrategy> schemeRegistry = HttpClientTestUtils.getSchemeRegistry(client);
    SchemeIOSessionStrategy schemeSocketFactory = schemeRegistry.lookup("https");

    assertNotEquals(schemeSocketFactory, SSLConnectionSocketFactory.getSocketFactory());
    item.close();//  w  w  w. ja  v a  2  s  . c  om
}

From source file:org.artifactory.util.HttpClientConfiguratorTest.java

public void testTokenAuthentication() throws IOException {
    CloseableHttpClient client = new HttpClientConfigurator().host("bob")
            .enableTokenAuthentication(true, null, null).getClient();
    Registry<AuthSchemeProvider> registry = getAuthSchemeRegistry(client);
    assertThat(registry.lookup("bearer")).isInstanceOf(BearerSchemeFactory.class);
    RequestConfig defaultConfig = getDefaultConfig(client);
    assertThat(defaultConfig.getTargetPreferredAuthSchemes().size()).isEqualTo(1);
    assertThat(defaultConfig.getTargetPreferredAuthSchemes().iterator().next()).isEqualTo("Bearer");
    client.close();/*w w w .  j a va2s  . c o  m*/
}

From source file:io.wcm.caravan.commons.httpclient.impl.HttpClientItemTest.java

@Test
public void testWithClientCertificate() {
    HttpClientConfigImpl config = context.registerInjectActivateService(new HttpClientConfigImpl(),
            ImmutableMap.<String, Object>builder()
                    .put(KEYSTORE_PATH_PROPERTY, CertificateLoaderTest.KEYSTORE_PATH)
                    .put(KEYSTORE_PASSWORD_PROPERTY, CertificateLoaderTest.KEYSTORE_PASSWORD)
                    .put(TRUSTSTORE_PATH_PROPERTY, CertificateLoaderTest.TRUSTSTORE_PATH)
                    .put(TRUSTSTORE_PASSWORD_PROPERTY, CertificateLoaderTest.TRUSTSTORE_PASSWORD).build());

    HttpClientItem item = new HttpClientItem(config);
    HttpClient client = item.getHttpClient();

    Registry<ConnectionSocketFactory> schemeRegistry = HttpClientTestUtils.getSchemeRegistry(client);
    ConnectionSocketFactory schemeSocketFactory = schemeRegistry.lookup("https");

    assertNotEquals(schemeSocketFactory, SSLConnectionSocketFactory.getSocketFactory());
    item.close();/*from  ww w  .j  a v  a 2s .co  m*/
}