@Test public void testConfigureStoreWithoutSSL() throws Exception { GetMailInput input = inputBuilder.build(); doReturn(objectMock).when(propertiesMock).put(String.format(PropNames.MAIL_HOST, Constants.POP3), HOST); doReturn(objectMock).when(propertiesMock).put(String.format(PropNames.MAIL_PORT, Constants.POP3), Short.parseShort(Constants.POP3_PORT)); PowerMockito.mockStatic(Session.class); PowerMockito.doReturn(sessionMock) .when(Session.class, "getInstance", Matchers.<Properties>any(), Matchers.<Authenticator>any()); doReturn(storeMock).when(sessionMock).getStore(Constants.POP3); PowerMockito.mockStatic(SSLUtils.class); when(SSLUtils.configureStoreWithoutSSL(propertiesMock, authenticatorMock, input)).thenCallRealMethod(); Store store = SSLUtils.configureStoreWithoutSSL(propertiesMock, authenticatorMock, input); assertEquals(storeMock, store); verify(propertiesMock).put(String.format(PropNames.MAIL_HOST, Constants.POP3), HOST); verify(propertiesMock).put(String.format(PropNames.MAIL_PORT, Constants.POP3), Short.parseShort(Constants.POP3_PORT)); PowerMockito.verifyStatic(); Session.getInstance(Matchers.<Properties>any(), Matchers.<Authenticator>any()); verify(sessionMock).getStore(Constants.POP3); }
static Store configureStoreWithoutSSL(Properties props, Authenticator auth, GetMailInput input) throws NoSuchProviderException { props.put(String.format(PropNames.MAIL_HOST, input.getProtocol()), input.getHostname()); props.put(String.format(PropNames.MAIL_PORT, input.getProtocol()), input.getPort()); Session session = Session.getInstance(props, auth); return session.getStore(input.getProtocol()); }
SSLUtils { static Store configureStoreWithoutSSL(Properties props, Authenticator auth, GetMailInput input) throws NoSuchProviderException { props.put(String.format(PropNames.MAIL_HOST, input.getProtocol()), input.getHostname()); props.put(String.format(PropNames.MAIL_PORT, input.getProtocol()), input.getPort()); Session session = Session.getInstance(props, auth); return session.getStore(input.getProtocol()); } }
SSLUtils { static Store configureStoreWithoutSSL(Properties props, Authenticator auth, GetMailInput input) throws NoSuchProviderException { props.put(String.format(PropNames.MAIL_HOST, input.getProtocol()), input.getHostname()); props.put(String.format(PropNames.MAIL_PORT, input.getProtocol()), input.getPort()); Session session = Session.getInstance(props, auth); return session.getStore(input.getProtocol()); }  }
SSLUtils { static Store configureStoreWithoutSSL(Properties props, Authenticator auth, GetMailInput input) throws NoSuchProviderException { props.put(String.format(PropNames.MAIL_HOST, input.getProtocol()), input.getHostname()); props.put(String.format(PropNames.MAIL_PORT, input.getProtocol()), input.getPort()); Session session = Session.getInstance(props, auth); return session.getStore(input.getProtocol()); }  static KeyStore createKeyStore(final URL url, final String password); static KeyManager[] createKeyManagers(final KeyStore keystore, final String password); static TrustManager[] createAuthTrustManagers(final KeyStore keystore); static Store createMessageStore(GetMailInput input); static void addSSLSettings(boolean trustAllRoots, String keystore,
                                      String keystorePassword, String trustKeystore, String trustPassword); static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input); static Store tryTLSOtherwiseTrySSL(Authenticator auth, Properties props, GetMailInput input); static Store configureStoreWithTLS(Properties props, Authenticator auth, MailInput input); static void configureWithTLS(Properties props, final MailInput input); static void clearTLSProperties(Properties props, MailInput input); }
SSLUtils { static Store configureStoreWithoutSSL(Properties props, Authenticator auth, GetMailInput input) throws NoSuchProviderException { props.put(String.format(PropNames.MAIL_HOST, input.getProtocol()), input.getHostname()); props.put(String.format(PropNames.MAIL_PORT, input.getProtocol()), input.getPort()); Session session = Session.getInstance(props, auth); return session.getStore(input.getProtocol()); }  static KeyStore createKeyStore(final URL url, final String password); static KeyManager[] createKeyManagers(final KeyStore keystore, final String password); static TrustManager[] createAuthTrustManagers(final KeyStore keystore); static Store createMessageStore(GetMailInput input); static void addSSLSettings(boolean trustAllRoots, String keystore,
                                      String keystorePassword, String trustKeystore, String trustPassword); static Store configureStoreWithSSL(Properties props, Authenticator auth, MailInput input); static Store tryTLSOtherwiseTrySSL(Authenticator auth, Properties props, GetMailInput input); static Store configureStoreWithTLS(Properties props, Authenticator auth, MailInput input); static void configureWithTLS(Properties props, final MailInput input); static void clearTLSProperties(Properties props, MailInput input);  }