question: public void test_createSocket ( ) { SSLSocketFactory sf = ( SSLSocketFactory ) SSLSocketFactory . getDefault ( ) ; int sport = startServer ( "test_createSocket()" ) ; int [ ] invalid = { Integer . MIN_VALUE , - 1 , 65536 , Integer . MAX_VALUE } ; try { Socket st = new Socket ( "localhost" , sport ) ; Socket s = sf . createSocket ( st , "localhost" , sport , false ) ; assertFalse ( s . isClosed ( ) ) ; } catch ( Exception ex ) { fail ( "Unexpected exception " + ex ) ; } try { Socket st = new Socket ( "localhost" , sport ) ; Socket s = sf . createSocket ( st , "localhost" , sport , true ) ; s . close ( ) ; assertTrue ( st . isClosed ( ) ) ; } catch ( Exception ex ) { fail ( "Unexpected exception " + ex ) ; } try { sf . createSocket ( null , "localhost" , sport , true ) ; fail ( "IOException wasn't thrown" ) ; } catch ( IOException ioe ) { } catch ( NullPointerException e ) { } for ( int i = 0 ; i < invalid . length ; i ++ ) { try { Socket s = sf . createSocket ( new Socket ( ) , "localhost" , 1080 , false ) ; fail ( "IOException wasn't thrown" ) ; } catch ( IOException ioe ) { } } try { Socket st = new Socket ( "bla-bla" , sport ) ; Socket s = sf . createSocket ( st , "bla-bla" , sport , false ) ; fail ( "UnknownHostException wasn't thrown: " + "bla-bla" ) ; } catch ( UnknownHostException uhe ) { } catch ( Exception e ) { fail ( e + " was thrown instead of UnknownHostException" ) ; } }
target:  javax.net.ssl.SSLSocketFactory#createSocket(Socket s, String host, int port, boolean autoClose)