@Test public void testCreateContext() throws Exception { factoryBean.setKeyManagerFactory(keyManagerFactory); factoryBean.setKeyStore(keyStore); factoryBean.setTrustManagerFactory(trustManagerFactory); factoryBean.setTrustStore(trustStore); factoryBean.setSecureRandom(secureRandom); assertNotNull(factoryBean.createContext(context)); assertTrue(keyManagerFactory.isFactoryCreated()); assertTrue(trustManagerFactory.isFactoryCreated()); assertTrue(keyStore.isKeyStoreCreated()); assertTrue(trustStore.isKeyStoreCreated()); assertTrue(secureRandom.isSecureRandomCreated()); // it's important that each configured component output an appropriate // informational message to the context; i.e. this logging is not just // for programmers, it's there for systems administrators to use in // verifying that SSL is configured properly assertTrue(context.hasInfoMatching(SSL_CONFIGURATION_MESSAGE_PATTERN)); assertTrue(context.hasInfoMatching(KEY_MANAGER_FACTORY_MESSAGE_PATTERN)); assertTrue(context.hasInfoMatching(TRUST_MANAGER_FACTORY_MESSAGE_PATTERN)); assertTrue(context.hasInfoMatching(KEY_STORE_MESSAGE_PATTERN)); assertTrue(context.hasInfoMatching(TRUST_STORE_MESSAGE_PATTERN)); assertTrue(context.hasInfoMatching(SECURE_RANDOM_MESSAGE_PATTERN)); }