Home | History | Annotate | Download | only in net
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.net;
     18 
     19 import android.net.SSLCertificateSocketFactory;
     20 import android.test.suitebuilder.annotation.Suppress;
     21 import junit.framework.TestCase;
     22 
     23 import java.io.InputStream;
     24 import java.io.OutputStream;
     25 import java.net.Socket;
     26 
     27 //This test relies on network resources.
     28 @Suppress
     29 public class SSLTest extends TestCase {
     30     public void testCertificate() throws Exception {
     31         // test www.fortify.net/sslcheck.html
     32         Socket ssl = SSLCertificateSocketFactory.getDefault().createSocket("www.fortify.net",443);
     33         assertNotNull(ssl);
     34 
     35         OutputStream out = ssl.getOutputStream();
     36         assertNotNull(out);
     37 
     38         InputStream in = ssl.getInputStream();
     39         assertNotNull(in);
     40 
     41         String get = "GET /sslcheck.html HTTP/1.1\r\nHost: 68.178.217.222\r\n\r\n";
     42 
     43         // System.out.println("going for write...");
     44         out.write(get.getBytes());
     45 
     46         byte[] b = new byte[1024];
     47         // System.out.println("going for read...");
     48         int ret = in.read(b);
     49 
     50         // System.out.println(new String(b));
     51     }
     52 }
     53