Source:
public void TestBuildSslContextFactoryExplicitTrustStoreErrorGettingPassword() 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("trust_store_password"))).andThrow(new AliasServiceException(null)).atLeastOnce(); KeystoreService keystoreService = createMock(KeystoreService.class); replay(config, aliasService, keystoreService); JettySSLService sslService = new JettySSLService(); sslService.setAliasService(aliasService); sslService.setKeystoreService(keystoreService); sslService.buildSslContextFactory(config); fail("AliasServiceException should have been thrown"); }

Target:
public void TestBuildSslContextFactoryExplicitTrustStoreErrorGettingPassword() 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))).andThrow(new AliasServiceException(null)).atLeastOnce(); KeystoreService keystoreService = createMock(KeystoreService.class); replay(config, aliasService, keystoreService); JettySSLService sslService = new JettySSLService(); sslService.setAliasService(aliasService); sslService.setKeystoreService(keystoreService); sslService.buildSslContextFactory(config); fail("AliasServiceException should have been thrown"); }