summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2012-03-26 10:14:44 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-26 10:14:44 -0700
commite300d828282645759abfbc5725c5ccc448e8c053 (patch)
treec0df2305d7c30a0bc1a6f35c34ad9ca91fa406da /core/tests
parent6af84f678dbe38e36a70f53e199057612c8c1cb4 (diff)
parentf5fb5e80963abeabdf0ff10dcee068344235082e (diff)
downloadframeworks_base-e300d828282645759abfbc5725c5ccc448e8c053.zip
frameworks_base-e300d828282645759abfbc5725c5ccc448e8c053.tar.gz
frameworks_base-e300d828282645759abfbc5725c5ccc448e8c053.tar.bz2
Merge "Add an API to expose Next Protocol Negotiation (NPN)."
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/coretests/src/android/net/SSLTest.java40
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) {
+ }
+ }
}