Path: blob/master/test/jdk/javax/net/ssl/FixingJavadocs/JavaxURLNulls.java
41153 views
/*1* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 438788226* @summary Need to revisit the javadocs for JSSE, especially the27* promoted classes28* @author Brad Wetmore29*/3031import java.net.*;32import java.io.*;33import javax.net.ssl.*;343536/*37* Tests that the javax null argument changes made it in ok.38*/3940public class JavaxURLNulls {4142public static void main(String[] args) throws Exception {4344HostnameVerifier reservedHV =45HttpsURLConnection.getDefaultHostnameVerifier();46try {47/**48* This test does not establish any connection to the specified49* URL, hence a dummy URL is used.50*/51URL foobar = new URL("https://example.com/");5253HttpsURLConnection urlc =54(HttpsURLConnection) foobar.openConnection();5556try {57urlc.getCipherSuite();58} catch (IllegalStateException e) {59System.out.print("Caught proper exception: ");60System.out.println(e.getMessage());61}6263try {64urlc.getLocalCertificates();65} catch (IllegalStateException e) {66System.out.print("Caught proper exception: ");67System.out.println(e.getMessage());68}6970try {71urlc.getServerCertificates();72} catch (IllegalStateException e) {73System.out.print("Caught proper exception: ");74System.out.println(e.getMessage());75}7677try {78urlc.setDefaultHostnameVerifier(null);79} catch (IllegalArgumentException e) {80System.out.print("Caught proper exception: ");81System.out.println(e.getMessage());82}8384try {85urlc.setHostnameVerifier(null);86} catch (IllegalArgumentException e) {87System.out.print("Caught proper exception: ");88System.out.println(e.getMessage());89}9091try {92urlc.setDefaultSSLSocketFactory(null);93} catch (IllegalArgumentException e) {94System.out.print("Caught proper exception: ");95System.out.println(e.getMessage());96}9798try {99urlc.setSSLSocketFactory(null);100} catch (IllegalArgumentException e) {101System.out.print("Caught proper exception: ");102System.out.println(e.getMessage());103}104System.out.println("TESTS PASSED");105} finally {106HttpsURLConnection.setDefaultHostnameVerifier(reservedHV);107}108}109}110111112