Source:
<code>public void TestBuildSslContextFactoryExplicitTrustStoreNullPassword() throws Exception { String basedir = System.getProperty("basedir"); if (basedir == null) { basedir = new File(".").getCanonicalPath(); } Path identityKeystorePath = Paths.get(basedir, "target", "test-classes", "keystores", "server-keystore.jks"); String identityKeystoreType = "jks"; char[] identityKeystorePassword = "horton".toCharArray(); char[] identityKeyPassphrase = "horton".toCharArray(); String identityKeyAlias = "server"; Path truststorePath = Paths.get(basedir, "target", "test-classes", "keystores", "server-truststore.jks"); String truststoreType = "jks"; String truststorePasswordAlias = "trust_store_password"; GatewayConfig config = createGatewayConfig(true, true, identityKeystorePath, identityKeystoreType, identityKeyAlias, truststorePath, truststoreType, truststorePasswordAlias); AliasService aliasService = createMock(AliasService.class); expect(aliasService.getGatewayIdentityKeystorePassword()).andReturn(identityKeystorePassword).atLeastOnce(); expect(aliasService.getGatewayIdentityPassphrase()).andReturn(identityKeyPassphrase).atLeastOnce(); <START> expect(aliasService.getPasswordFromAliasForGateway(eq("trust_store_password"))).andReturn(null).atLeastOnce(); <END> KeystoreService keystoreService = createMock(KeystoreService.class); replay(config, aliasService, keystoreService); JettySSLService sslService = new JettySSLService(); sslService.setAliasService(aliasService); sslService.setKeystoreService(keystoreService); Object result = sslService.buildSslContextFactory(config); assertNotNull(result); assertTrue(result instanceof SslContextFactory); SslContextFactory sslContextFactory = (SslContextFactory) result; sslContextFactory.start(); assertEquals(identityKeystorePath.toUri().toString(), sslContextFactory.getKeyStorePath()); assertEquals(identityKeystoreType, sslContextFactory.getKeyStoreType()); assertNotNull(sslContextFactory.getKeyStore()); assertEquals(truststorePath.toUri().toString(), sslContextFactory.getTrustStorePath()); assertEquals(truststoreType, sslContextFactory.getTrustStoreType()); assertNotNull(sslContextFactory.getTrustStore()); assertTrue(sslContextFactory.getKeyStore().containsAlias(identityKeyAlias)); assertFalse(sslContextFactory.getTrustStore().containsAlias(identityKeyAlias)); verify(config, aliasService, keystoreService); }</code><technical_language>I this truststorePasswordAlias instead of string</technical_language>

Target:
public void TestBuildSslContextFactoryExplicitTrustStoreNullPassword() throws Exception { String basedir = System.getProperty("basedir"); if (basedir == null) { basedir = new File(".").getCanonicalPath(); } Path identityKeystorePath = Paths.get(basedir, "target", "test-classes", "keystores", "server-keystore.jks"); String identityKeystoreType = "jks"; char[] identityKeystorePassword = "horton".toCharArray(); char[] identityKeyPassphrase = "horton".toCharArray(); String identityKeyAlias = "server"; Path truststorePath = Paths.get(basedir, "target", "test-classes", "keystores", "server-truststore.jks"); String truststoreType = "jks"; String truststorePasswordAlias = "trust_store_password"; GatewayConfig config = createGatewayConfig(true, true, identityKeystorePath, identityKeystoreType, identityKeyAlias, truststorePath, truststoreType, truststorePasswordAlias); AliasService aliasService = createMock(AliasService.class); expect(aliasService.getGatewayIdentityKeystorePassword()).andReturn(identityKeystorePassword).atLeastOnce(); expect(aliasService.getGatewayIdentityPassphrase()).andReturn(identityKeyPassphrase).atLeastOnce(); expect(aliasService.getPasswordFromAliasForGateway(eq(truststorePasswordAlias))).andReturn(null).atLeastOnce(); KeystoreService keystoreService = createMock(KeystoreService.class); replay(config, aliasService, keystoreService); JettySSLService sslService = new JettySSLService(); sslService.setAliasService(aliasService); sslService.setKeystoreService(keystoreService); Object result = sslService.buildSslContextFactory(config); assertNotNull(result); assertTrue(result instanceof SslContextFactory); SslContextFactory sslContextFactory = (SslContextFactory) result; sslContextFactory.start(); assertEquals(identityKeystorePath.toUri().toString(), sslContextFactory.getKeyStorePath()); assertEquals(identityKeystoreType, sslContextFactory.getKeyStoreType()); assertNotNull(sslContextFactory.getKeyStore()); assertEquals(truststorePath.toUri().toString(), sslContextFactory.getTrustStorePath()); assertEquals(truststoreType, sslContextFactory.getTrustStoreType()); assertNotNull(sslContextFactory.getTrustStore()); assertTrue(sslContextFactory.getKeyStore().containsAlias(identityKeyAlias)); assertFalse(sslContextFactory.getTrustStore().containsAlias(identityKeyAlias)); verify(config, aliasService, keystoreService); }