Home | History | Annotate | Download | only in ssl
      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 public class DefaultSSLServerSocketFactoryTest extends TestCase {
     32 
     33     /*
     34      * Class under test for ServerSocket createServerSocket(int)
     35      */
     36     public void testCreateServerSocketint() {
     37         DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
     38         try {
     39             f.createServerSocket(0);
     40             fail("No expected SocketException");
     41         } catch (SocketException e) {
     42         } catch (IOException e) {
     43             fail(e.toString());
     44         }
     45     }
     46 
     47     /*
     48      * Class under test for ServerSocket createServerSocket(int, int)
     49      */
     50     public void testCreateServerSocketintint() {
     51         DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
     52         try {
     53             f.createServerSocket(0, 10);
     54             fail("No expected SocketException");
     55         } catch (SocketException e) {
     56         } catch (IOException e) {
     57             fail(e.toString());
     58         }
     59     }
     60 
     61     /*
     62      * Class under test for ServerSocket createServerSocket(int, int, InetAddress)
     63      */
     64     public void testCreateServerSocketintintInetAddress() {
     65         DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
     66         try {
     67             f.createServerSocket(0, 10, InetAddress.getLocalHost());
     68             fail("No expected SocketException");
     69         } catch (SocketException e) {
     70         } catch (IOException e) {
     71             fail(e.toString());
     72         }
     73     }
     74 
     75     public void testGetDefaultCipherSuites() {
     76         DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
     77         String[] res = f.getDefaultCipherSuites();
     78         if (res == null || res.length != 0) {
     79             fail("incorrect result");
     80         }
     81     }
     82 
     83     public void testGetSupportedCipherSuites() {
     84         DefaultSSLServerSocketFactory f = new DefaultSSLServerSocketFactory("ERROR");
     85         String[] res = f.getSupportedCipherSuites();
     86         if (res == null || res.length != 0) {
     87             fail("incorrect result");
     88         }
     89     }
     90 
     91 }
     92