diff options
author | Jesse Wilson <jessewilson@google.com> | 2012-03-23 15:55:03 -0400 |
---|---|---|
committer | Jesse Wilson <jessewilson@google.com> | 2012-03-25 19:43:01 -0400 |
commit | f5fb5e80963abeabdf0ff10dcee068344235082e (patch) | |
tree | ef713b85110ef14f52a982ea63c7086de30625b4 /core/tests | |
parent | 370f2dbc372116f986274ff2552b5ecfdce7d29a (diff) | |
download | frameworks_base-f5fb5e80963abeabdf0ff10dcee068344235082e.zip frameworks_base-f5fb5e80963abeabdf0ff10dcee068344235082e.tar.gz frameworks_base-f5fb5e80963abeabdf0ff10dcee068344235082e.tar.bz2 |
Add an API to expose Next Protocol Negotiation (NPN).
Bug: http://b/4190756
Change-Id: If904f7ff440391a6adb2963eb2ecb990140ab7cc
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/coretests/src/android/net/SSLTest.java | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/core/tests/coretests/src/android/net/SSLTest.java b/core/tests/coretests/src/android/net/SSLTest.java index 810ed0d..c573498 100644 --- a/core/tests/coretests/src/android/net/SSLTest.java +++ b/core/tests/coretests/src/android/net/SSLTest.java @@ -16,17 +16,16 @@ package android.net; -import android.net.SSLCertificateSocketFactory; import android.test.suitebuilder.annotation.Suppress; -import junit.framework.TestCase; - import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; +import java.util.Arrays; +import junit.framework.TestCase; -//This test relies on network resources. -@Suppress public class SSLTest extends TestCase { + //This test relies on network resources. + @Suppress public void testCertificate() throws Exception { // test www.fortify.net/sslcheck.html Socket ssl = SSLCertificateSocketFactory.getDefault().createSocket("www.fortify.net",443); @@ -49,4 +48,35 @@ public class SSLTest extends TestCase { // System.out.println(new String(b)); } + + public void testStringsToNpnBytes() { + byte[] expected = { + 6, 's', 'p', 'd', 'y', '/', '2', + 8, 'h', 't', 't', 'p', '/', '1', '.', '1', + }; + assertTrue(Arrays.equals(expected, SSLCertificateSocketFactory.toNpnProtocolsList( + new byte[] { 's', 'p', 'd', 'y', '/', '2' }, + new byte[] { 'h', 't', 't', 'p', '/', '1', '.', '1' }))); + } + + public void testStringsToNpnBytesEmptyByteArray() { + try { + SSLCertificateSocketFactory.toNpnProtocolsList(new byte[0]); + fail(); + } catch (IllegalArgumentException expected) { + } + } + + public void testStringsToNpnBytesEmptyArray() { + byte[] expected = {}; + assertTrue(Arrays.equals(expected, SSLCertificateSocketFactory.toNpnProtocolsList())); + } + + public void testStringsToNpnBytesOversizedInput() { + try { + SSLCertificateSocketFactory.toNpnProtocolsList(new byte[256]); + fail(); + } catch (IllegalArgumentException expected) { + } + } } |