test/jdk/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java
changeset 58108 5302477c8285
parent 47216 71c04702a3d5
equal deleted inserted replaced
58106:79186d82463e 58108:5302477c8285
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    40 
    40 
    41 import java.io.InputStream;
    41 import java.io.InputStream;
    42 import java.io.BufferedWriter;
    42 import java.io.BufferedWriter;
    43 import java.io.OutputStreamWriter;
    43 import java.io.OutputStreamWriter;
    44 import java.net.HttpURLConnection;
    44 import java.net.HttpURLConnection;
       
    45 import java.net.InetAddress;
       
    46 import java.net.Proxy;
    45 import java.net.URL;
    47 import java.net.URL;
       
    48 import java.net.UnknownHostException;
    46 
    49 
    47 import javax.net.ssl.HttpsURLConnection;
    50 import javax.net.ssl.HttpsURLConnection;
    48 import javax.net.ssl.SSLContext;
    51 import javax.net.ssl.SSLContext;
    49 import javax.net.ssl.SSLSocket;
    52 import javax.net.ssl.SSLSocket;
    50 
    53 
    60     public static void main(String[] args) throws Exception {
    63     public static void main(String[] args) throws Exception {
    61         // Get the customized arguments.
    64         // Get the customized arguments.
    62         initialize(args);
    65         initialize(args);
    63 
    66 
    64         (new ServerIdentityTest()).run();
    67         (new ServerIdentityTest()).run();
       
    68     }
       
    69 
       
    70     ServerIdentityTest() throws UnknownHostException {
       
    71         serverAddress = InetAddress.getByName(hostname);
    65     }
    72     }
    66 
    73 
    67     @Override
    74     @Override
    68     protected boolean isCustomizedClientConnection() {
    75     protected boolean isCustomizedClientConnection() {
    69         return true;
    76         return true;
    86                 "https://" + hostname + ":" + serverPort + "/index.html");
    93                 "https://" + hostname + ":" + serverPort + "/index.html");
    87 
    94 
    88         HttpURLConnection urlc = null;
    95         HttpURLConnection urlc = null;
    89         InputStream is = null;
    96         InputStream is = null;
    90         try {
    97         try {
    91             urlc = (HttpURLConnection)url.openConnection();
    98             urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
    92             is = urlc.getInputStream();
    99             is = urlc.getInputStream();
    93         } finally {
   100         } finally {
    94             if (is != null) {
   101             if (is != null) {
    95                 is.close();
   102                 is.close();
    96             }
   103             }