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 tests.api.javax.net.ssl; 18 19 import dalvik.annotation.TestTargetClass; 20 import dalvik.annotation.TestLevel; 21 import dalvik.annotation.TestTargetNew; 22 23 import java.io.IOException; 24 import java.net.InetAddress; 25 import java.net.ServerSocket; 26 27 import javax.net.ssl.SSLServerSocketFactory; 28 29 import junit.framework.TestCase; 30 31 @TestTargetClass(SSLServerSocketFactory.class) 32 public class SSLServerSocketFactoryTest extends TestCase { 33 34 private class MockSSLServerSocketFactory extends SSLServerSocketFactory { 35 public MockSSLServerSocketFactory() { 36 super(); 37 } 38 39 @Override 40 public String[] getDefaultCipherSuites() { 41 return null; 42 } 43 44 @Override 45 public String[] getSupportedCipherSuites() { 46 return null; 47 } 48 49 @Override 50 public ServerSocket createServerSocket(int arg0) throws IOException { 51 return null; 52 } 53 54 @Override 55 public ServerSocket createServerSocket(int arg0, int arg1) 56 throws IOException { 57 return null; 58 } 59 60 @Override 61 public ServerSocket createServerSocket(int arg0, int arg1, 62 InetAddress arg2) throws IOException { 63 return null; 64 } 65 } 66 67 /** 68 * @tests javax.net.ssl.SSLServerSocketFactory#SSLServerSocketFactory() 69 */ 70 @TestTargetNew( 71 level = TestLevel.COMPLETE, 72 notes = "", 73 method = "SSLServerSocketFactory", 74 args = {} 75 ) 76 public void test_Constructor() { 77 try { 78 MockSSLServerSocketFactory ssf = new MockSSLServerSocketFactory(); 79 } catch (Exception e) { 80 fail("Unexpected exception " + e.toString()); 81 } 82 } 83 84 /** 85 * @tests javax.net.ssl.SSLServerSocketFactory#getDefault() 86 */ 87 @TestTargetNew( 88 level = TestLevel.COMPLETE, 89 notes = "", 90 method = "getDefault", 91 args = {} 92 ) 93 public void test_getDefault() { 94 assertNotNull("Incorrect default socket factory", 95 SSLServerSocketFactory.getDefault()); 96 } 97 98 /** 99 * @tests javax.net.ssl.SSLServerSocketFactory#getDefaultCipherSuites() 100 */ 101 @TestTargetNew( 102 level = TestLevel.COMPLETE, 103 notes = "", 104 method = "getDefaultCipherSuites", 105 args = {} 106 ) 107 public void test_getDefaultCipherSuites() { 108 SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory 109 .getDefault(); 110 try { 111 assertTrue(ssf.getDefaultCipherSuites().length > 0); 112 } catch (Exception e) { 113 fail("Unexpected exception " + e); 114 } 115 } 116 117 /** 118 * @tests javax.net.ssl.SSLServerSocketFactory#getSupportedCipherSuites() 119 */ 120 @TestTargetNew( 121 level = TestLevel.COMPLETE, 122 notes = "", 123 method = "getSupportedCipherSuites", 124 args = {} 125 ) 126 public void test_getSupportedCipherSuites() { 127 SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory 128 .getDefault(); 129 try { 130 assertTrue(ssf.getSupportedCipherSuites().length > 0); 131 } catch (Exception e) { 132 fail("Unexpected exception " + e); 133 } 134 } 135 } 136