FileDocCategorySizeDatePackage
X509TrustManagerExtensionsTest.javaAPI DocAndroid 5.1 API2551Thu Mar 12 22:22:12 GMT 2015android.net.http

X509TrustManagerExtensionsTest

public class X509TrustManagerExtensionsTest extends TestCase

Fields Summary
Constructors Summary
Methods Summary
public voidtestBadCast()

        NotATrustManagerImpl ntmi = new NotATrustManagerImpl();
        try {
            X509TrustManagerExtensions tme = new X509TrustManagerExtensions(ntmi);
            fail();
        } catch (IllegalArgumentException expected) {
        }
    
public voidtestGoodCast()

        String defaultType = KeyStore.getDefaultType();
        TrustManagerImpl tmi = new TrustManagerImpl(KeyStore.getInstance(defaultType));
        X509TrustManagerExtensions tme = new X509TrustManagerExtensions(tmi);
    
public voidtestNormalUseCase()

        String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(defaultAlgorithm);
        String defaultKeystoreType = KeyStore.getDefaultType();
        tmf.init(KeyStore.getInstance(defaultKeystoreType));
        TrustManager[] tms = tmf.getTrustManagers();
        for (TrustManager tm : tms) {
            if (tm instanceof X509TrustManager) {
                new X509TrustManagerExtensions((X509TrustManager)tm);
                return;
            }
        }
        fail();