diff options
author | Geremy Condra <gcondra@google.com> | 2012-09-18 14:41:39 -0700 |
---|---|---|
committer | Geremy Condra <gcondra@google.com> | 2012-09-18 14:44:54 -0700 |
commit | fd5a80f6e98124d908643a14d33b8d2fa5238da6 (patch) | |
tree | f1e08401b2dc8180867d239aab2b09998b5d0ad9 /core/tests/coretests | |
parent | 94998c9c4e19d5b439228646f1b283201367b7a0 (diff) | |
download | frameworks_base-fd5a80f6e98124d908643a14d33b8d2fa5238da6.zip frameworks_base-fd5a80f6e98124d908643a14d33b8d2fa5238da6.tar.gz frameworks_base-fd5a80f6e98124d908643a14d33b8d2fa5238da6.tar.bz2 |
Code cleanup for X509TrustManagerExtensionsTest.java
Change-Id: I85584f7a9dbc726be811f783d125efcf70c9f6af
Diffstat (limited to 'core/tests/coretests')
-rw-r--r-- | core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java b/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java index b2e1895..60c40db 100644 --- a/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java +++ b/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java @@ -19,6 +19,8 @@ package android.net.http; import java.security.KeyStore; import java.security.cert.X509Certificate; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; import junit.framework.TestCase; @@ -42,10 +44,9 @@ public class X509TrustManagerExtensionsTest extends TestCase { NotATrustManagerImpl ntmi = new NotATrustManagerImpl(); try { X509TrustManagerExtensions tme = new X509TrustManagerExtensions(ntmi); - } catch (IllegalArgumentException ignored) { - return; + fail(); + } catch (IllegalArgumentException expected) { } - fail(); } public void testGoodCast() throws Exception { @@ -53,4 +54,19 @@ public class X509TrustManagerExtensionsTest extends TestCase { TrustManagerImpl tmi = new TrustManagerImpl(KeyStore.getInstance(defaultType)); X509TrustManagerExtensions tme = new X509TrustManagerExtensions(tmi); } + + public void testNormalUseCase() throws Exception { + 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(); + } } |