### Question:
JKSCertInfo implements CertInfo<HttpClientFactory.Builder> { @Override public void applyTo(HttpClientFactory.Builder httpClientFactoryBuilder) { try ( FileInputStream keystoreFile = new FileInputStream(new File(keystorePath)); FileInputStream truststoreFile = new FileInputStream(new File(truststorePath)) ) { KeyStore keyStore = KeyStore.getInstance("jks"); keyStore.load(keystoreFile, keystorePassword.toCharArray()); KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, keystorePassword.toCharArray()); KeyStore trustStore = KeyStore.getInstance("jks"); trustStore.load(truststoreFile, truststorePassword.toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); httpClientFactoryBuilder.withSslSocketFactory(new SSLConnectionSocketFactory(sslContext)); httpClientFactoryBuilder.withHttpsIOSessionStrategy(new SSLIOSessionStrategy(sslContext, new NoopHostnameVerifier())); } catch (IOException | GeneralSecurityException e) { throw new ConfigurationException(configExceptionMessage, e); } } protected  JKSCertInfo(String keystorePath, String keystorePassword, String truststorePath, String truststorePassword); @Override void applyTo(HttpClientFactory.Builder httpClientFactoryBuilder); @PluginBuilderFactory static Builder newBuilder();  }### Answer:
@Test public void paramsArePassedToConfiguredObject() { JKSCertInfo certInfo = createTestCertInfoBuilder() .withKeystorePath(TEST_KEYSTORE_PATH) .withKeystorePassword(TEST_KEYSTORE_PASSWORD) .withTruststorePath(TEST_TRUSTSTORE_PATH) .withTruststorePassword(TEST_TRUSTSTORE_PASSWORD) .build(); HttpClientFactory.Builder httpClientFactoryBuilder = Mockito.spy(createDefaultHttpClientFactoryBuilder()); certInfo.applyTo(httpClientFactoryBuilder); verify(httpClientFactoryBuilder).withHttpsIOSessionStrategy((SchemeIOSessionStrategy) notNull()); Assert.assertNotNull(httpClientFactoryBuilder.build().httpsIOSessionStrategy); }
@Test public void builderThrowsIfKeyIsInvalid() throws IOException { expectedException.expect(ConfigurationException.class); expectedException.expectMessage(PEMCertInfo.configExceptionMessage); File invalidKey = createInvalidKey(); JKSCertInfo testCertInfo = createTestCertInfoBuilder() .withKeystorePath(invalidKey.getAbsolutePath()) .build(); testCertInfo.applyTo(mock(HttpClientFactory.Builder.class)); }