HttpClientConfig extends ClientConfig { public CredentialsProvider getCredentialsProvider() { return credentialsProvider; } HttpClientConfig(Builder builder); Map<HttpRoute, Integer> getMaxTotalConnectionPerRoute(); Integer getMaxTotalConnection(); Integer getDefaultMaxTotalConnectionPerRoute(); CredentialsProvider getCredentialsProvider(); LayeredConnectionSocketFactory getSslSocketFactory(); ConnectionSocketFactory getPlainSocketFactory(); HttpRoutePlanner getHttpRoutePlanner(); AuthenticationStrategy getProxyAuthenticationStrategy(); SchemeIOSessionStrategy getHttpIOSessionStrategy(); SchemeIOSessionStrategy getHttpsIOSessionStrategy(); Set<HttpHost> getPreemptiveAuthTargetHosts(); ElasticsearchVersion getElasticsearchVersion();  }
@Test public void defaultCredentials() { String user = "ceo"; String password = "12345"; HttpClientConfig httpClientConfig = new HttpClientConfig.Builder("localhost") .defaultCredentials(user, password) .build(); CredentialsProvider credentialsProvider = httpClientConfig.getCredentialsProvider(); Credentials credentials = credentialsProvider.getCredentials(new AuthScope("localhost", 80)); assertEquals(user, credentials.getUserPrincipal().getName()); assertEquals(password, credentials.getPassword()); }
@Test public void customCredentialProvider() { CredentialsProvider customCredentialsProvider = new BasicCredentialsProvider(); HttpClientConfig httpClientConfig = new HttpClientConfig.Builder("localhost") .credentialsProvider(customCredentialsProvider) .build(); assertEquals(customCredentialsProvider, httpClientConfig.getCredentialsProvider()); }