1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 19 package javax.net.ssl; 20 21 import java.io.IOException; 22 import java.net.InetAddress; 23 import java.net.SocketException; 24 25 import junit.framework.TestCase; 26 27 28 /** 29 * Tests for <code>DefaultSSLServerSocketFactory</code> class constructors and methods. 30 * 31 */ 32 public class DefaultSSLServerSocketFactoryTest extends TestCase { 33 34 /* 35 * Class under test for ServerSocket createServerSocket(int) 36 */ 37 public void testCreateServerSocketint() { 38 DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR"); 39 try { 40 f.createServerSocket(0); 41 fail("No expected SocketException"); 42 } catch (SocketException e) { 43 } catch (IOException e) { 44 fail(e.toString()); 45 } 46 } 47 48 /* 49 * Class under test for ServerSocket createServerSocket(int, int) 50 */ 51 public void testCreateServerSocketintint() { 52 DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR"); 53 try { 54 f.createServerSocket(0, 10); 55 fail("No expected SocketException"); 56 } catch (SocketException e) { 57 } catch (IOException e) { 58 fail(e.toString()); 59 } 60 } 61 62 /* 63 * Class under test for ServerSocket createServerSocket(int, int, InetAddress) 64 */ 65 public void testCreateServerSocketintintInetAddress() { 66 DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR"); 67 try { 68 f.createServerSocket(0, 10, InetAddress.getLocalHost()); 69 fail("No expected SocketException"); 70 } catch (SocketException e) { 71 } catch (IOException e) { 72 fail(e.toString()); 73 } 74 } 75 76 public void testGetDefaultCipherSuites() { 77 DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR"); 78 String[] res = f.getDefaultCipherSuites(); 79 if (res == null || res.length != 0) { 80 fail("incorrect result"); 81 } 82 } 83 84 public void testGetSupportedCipherSuites() { 85 DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR"); 86 String[] res = f.getSupportedCipherSuites(); 87 if (res == null || res.length != 0) { 88 fail("incorrect result"); 89 } 90 } 91 92 } 93