protected CommonNameLoggingTrustManagerFactoryWrapper(String kmfAlgorithm) throws NoSuchAlgorithmException {
        this.origTmf = TrustManagerFactory.getInstance(kmfAlgorithm);
    }
@Test
    public void testCommonNameLoggingTrustManagerFactoryWrapper() throws Exception {
        // We need to construct a trust store for testing
        X509Certificate caCert = chainWithValidEndCertificate[2];
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        trustStore.setCertificateEntry("CA", caCert);

        String kmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
        TrustManagerFactory origTmFactory = TrustManagerFactory.getInstance(kmfAlgorithm);
        origTmFactory.init(trustStore);
        TrustManager[] origTrustManagers = origTmFactory.getTrustManagers();
        // Create wrapped trust manager factory
        CommonNameLoggingTrustManagerFactoryWrapper testTmFactory = CommonNameLoggingTrustManagerFactoryWrapper.getInstance(kmfAlgorithm);
        testTmFactory.init(trustStore);
        TrustManager[] wrappendTrustManagers = testTmFactory.getTrustManagers();
        // Number of trust managers must be equal (usually "1")
        assertEquals(origTrustManagers.length, wrappendTrustManagers.length);
        // Algorithms must be equal
        assertEquals(origTmFactory.getAlgorithm(), testTmFactory.getAlgorithm());
        // Compare trust managers. Only for X509 there must be a difference
        for (int i = 0; i < origTrustManagers.length; i++) {
            TrustManager origTrustManager = origTrustManagers[i];
            TrustManager testTrustManager = wrappendTrustManagers[i];
            if (origTrustManager instanceof X509TrustManager) {
                assertInstanceOf(CommonNameLoggingTrustManager.class, testTrustManager);
                CommonNameLoggingTrustManager commonNameLoggingTrustManager = (CommonNameLoggingTrustManager) testTrustManager;
                // Two different instances of X509TrustManager wouldn't be considered equal. Thus we at least check that their classes are equal
                assertEquals(origTrustManager.getClass(), commonNameLoggingTrustManager.getOriginalTrustManager().getClass());
            } else {
                // Two different instances of X509TrustManager wouldn't be considered equal. Thus we at least check that their classes are equal
                assertEquals(origTrustManager.getClass(), testTrustManager.getClass());
            }
        }
    }