Path: blob/master/test/jdk/java/net/httpclient/ALPNProxyFailureTest.java
41149 views
/*1* Copyright (c) 2019, 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* @summary This test will timeout if the ALPN CF is not completed26* when a 'Connection reset by peer' exception is raised27* during the handshake.28* @bug 821709429* @library /test/lib http2/server30* @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer31* ALPNFailureTest ALPNProxyFailureTest32* @modules java.net.http/jdk.internal.net.http.common33* java.net.http/jdk.internal.net.http.frame34* java.net.http/jdk.internal.net.http.hpack35* java.logging36* java.base/sun.net.www.http37* java.base/sun.net.www38* java.base/sun.net39* @build ALPNFailureTest40* @run main/othervm -Djdk.internal.httpclient.debug=true -Dtest.nolinger=true ALPNProxyFailureTest HTTP_1_141* @run main/othervm -Dtest.nolinger=true ALPNProxyFailureTest HTTP_242*/43import javax.net.ServerSocketFactory;44import javax.net.ssl.SSLContext;45import jdk.test.lib.net.SimpleSSLContext;46import java.net.InetAddress;47import java.net.ProxySelector;48import java.net.ServerSocket;49import java.net.http.HttpClient;5051public class ALPNProxyFailureTest extends ALPNFailureTest {5253static final SSLContext context;54static {55try {56context = new SimpleSSLContext().get();57SSLContext.setDefault(context);58} catch (Exception x) {59throw new ExceptionInInitializerError(x);60}61}6263public static void main(String[] args) throws Exception{64if (args == null || args.length == 0) {65args = new String[] {HttpClient.Version.HTTP_1_1.name()};66}67ServerSocket socket = ServerSocketFactory.getDefault()68.createServerSocket(0, 10, InetAddress.getLoopbackAddress());6970DigestEchoServer.TunnelingProxy proxy = DigestEchoServer.createHttpsProxyTunnel(71DigestEchoServer.HttpAuthSchemeType.NONE);72ProxySelector ps = ProxySelector.of(proxy.getProxyAddress());7374try {75test(socket, context, ps, args);76} finally {77proxy.stop();78}79}8081}828384