HttpClientFactory { public static HttpClientConnectionManager createHttpClientConnectionManager(final Client client) throws GeneralSecurityException, IOException { final Connections connections = client.getConnections(); final PoolingHttpClientConnectionManager manager = new PoolingHttpClientConnectionManager( RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", new SSLConnectionSocketFactory(createSSLContext(client))) .build(), null, null, null, connections.getTimeToLive().getAmount(), connections.getTimeToLive().getUnit()); manager.setMaxTotal(connections.getMaxTotal()); manager.setDefaultMaxPerRoute(connections.getMaxPerRoute()); return manager; } private  HttpClientFactory(); static HttpClientConnectionManager createHttpClientConnectionManager(final Client client); static CloseableHttpClient createHttpClient(final Client client,
            final List<HttpRequestInterceptor> firstRequestInterceptors,
            final HttpClientConnectionManager connectionManager,
            @Nullable final HttpClientCustomizer customizer,
            @Nullable final Object cacheStorage);  }
@Test void shouldFailOnInvalidKeystore() { final Keystore invalidKeystore = new Keystore(); invalidKeystore.setPath("application-default.yml"); final RiptideProperties.Client client = new RiptideProperties.Client(); client.setCertificatePinning(new CertificatePinning(true, invalidKeystore)); assertThrows(IOException.class, () -> HttpClientFactory.createHttpClientConnectionManager(withDefaults(client))); }
@Test void shouldFailOnKeystoreNotFound() { final Keystore nonExistingKeystore = new Keystore(); nonExistingKeystore.setPath("i-do-not-exist.keystore"); final RiptideProperties.Client client = new RiptideProperties.Client(); client.setCertificatePinning(new CertificatePinning(true, nonExistingKeystore)); final FileNotFoundException exception = assertThrows(FileNotFoundException.class, () -> HttpClientFactory.createHttpClientConnectionManager(withDefaults(client))); assertThat(exception.getMessage(), containsString("i-do-not-exist.keystore")); }