1 /*
2  * Copyright (C) 2007 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 org.apache.harmony.tests.javax.net.ssl;
18 
19 import java.io.IOException;
20 import java.net.InetAddress;
21 import java.net.ServerSocket;
22 
23 import javax.net.ssl.SSLServerSocketFactory;
24 
25 import junit.framework.TestCase;
26 
27 public class SSLServerSocketFactoryTest extends TestCase {
28 
29     private class MockSSLServerSocketFactory extends SSLServerSocketFactory {
MockSSLServerSocketFactory()30         public MockSSLServerSocketFactory() {
31             super();
32         }
33 
34         @Override
getDefaultCipherSuites()35         public String[] getDefaultCipherSuites() {
36             return null;
37         }
38 
39         @Override
getSupportedCipherSuites()40         public String[] getSupportedCipherSuites() {
41             return null;
42         }
43 
44         @Override
createServerSocket(int arg0)45         public ServerSocket createServerSocket(int arg0) throws IOException {
46             return null;
47         }
48 
49         @Override
createServerSocket(int arg0, int arg1)50         public ServerSocket createServerSocket(int arg0, int arg1)
51                 throws IOException {
52             return null;
53         }
54 
55         @Override
createServerSocket(int arg0, int arg1, InetAddress arg2)56         public ServerSocket createServerSocket(int arg0, int arg1,
57                 InetAddress arg2) throws IOException {
58             return null;
59         }
60     }
61 
62     /**
63      * javax.net.ssl.SSLServerSocketFactory#SSLServerSocketFactory()
64      */
test_Constructor()65     public void test_Constructor() {
66         try {
67             MockSSLServerSocketFactory ssf = new MockSSLServerSocketFactory();
68         } catch (Exception e) {
69             fail("Unexpected exception " + e.toString());
70         }
71     }
72 
73     /**
74      * javax.net.ssl.SSLServerSocketFactory#getDefault()
75      */
test_getDefault()76     public void test_getDefault() {
77         assertNotNull("Incorrect default socket factory",
78                 SSLServerSocketFactory.getDefault());
79     }
80 
81     /**
82      * javax.net.ssl.SSLServerSocketFactory#getDefaultCipherSuites()
83      */
test_getDefaultCipherSuites()84     public void test_getDefaultCipherSuites() {
85         SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory
86                 .getDefault();
87         try {
88             assertTrue(ssf.getDefaultCipherSuites().length > 0);
89         } catch (Exception e) {
90             fail("Unexpected exception " + e);
91         }
92     }
93 
94     /**
95      * javax.net.ssl.SSLServerSocketFactory#getSupportedCipherSuites()
96      */
test_getSupportedCipherSuites()97     public void test_getSupportedCipherSuites() {
98         SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory
99                 .getDefault();
100         try {
101             assertTrue(ssf.getSupportedCipherSuites().length > 0);
102         } catch (Exception e) {
103             fail("Unexpected exception " + e);
104         }
105     }
106 }
107