FileDocCategorySizeDatePackage
SSLTest.javaAPI DocAndroid 5.1 API2826Thu Mar 12 22:22:12 GMT 2015android.net

SSLTest

public class SSLTest extends TestCase

Fields Summary
Constructors Summary
Methods Summary
public voidtestCertificate()

        // test www.fortify.net/sslcheck.html
        Socket ssl = SSLCertificateSocketFactory.getDefault().createSocket("www.fortify.net",443);
        assertNotNull(ssl);

        OutputStream out = ssl.getOutputStream();
        assertNotNull(out);

        InputStream in = ssl.getInputStream();
        assertNotNull(in);

        String get = "GET /sslcheck.html HTTP/1.1\r\nHost: 68.178.217.222\r\n\r\n";

        // System.out.println("going for write...");
        out.write(get.getBytes());

        byte[] b = new byte[1024];
        // System.out.println("going for read...");
        int ret = in.read(b);

        // System.out.println(new String(b));
    
public voidtestStringsToLengthPrefixedBytes()

        byte[] expected = {
                6, 's", 'p", 'd", 'y", '/", '2",
                8, 'h", 't", 't", 'p", '/", '1", '.", '1",
        };
        assertTrue(Arrays.equals(expected, SSLCertificateSocketFactory.toLengthPrefixedList(
                new byte[] { 's", 'p", 'd", 'y", '/", '2" },
                new byte[] { 'h", 't", 't", 'p", '/", '1", '.", '1" })));
    
public voidtestStringsToLengthPrefixedBytesEmptyArray()

        try {
            SSLCertificateSocketFactory.toLengthPrefixedList();
            fail();
        } catch (IllegalArgumentException expected) {
        }
    
public voidtestStringsToLengthPrefixedBytesEmptyByteArray()

        try {
            SSLCertificateSocketFactory.toLengthPrefixedList(new byte[0]);
            fail();
        } catch (IllegalArgumentException expected) {
        }
    
public voidtestStringsToLengthPrefixedBytesOversizedInput()

        try {
            SSLCertificateSocketFactory.toLengthPrefixedList(new byte[256]);
            fail();
        } catch (IllegalArgumentException expected) {
        }