0N/A/*
5266N/A * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/* @test
0N/A * @bug 4290727
0N/A * @summary Verify that ConnectException will trigger HTTP fallback if
0N/A * sun.rmi.transport.proxy.eagerHttpFallback system property is set.
5551N/A *
5266N/A * @library ../../../../java/rmi/testlibrary
5266N/A * @build TestLibrary
0N/A * @run main/othervm EagerHttpFallback
0N/A */
0N/A
0N/Aimport java.rmi.*;
0N/Aimport java.rmi.registry.*;
0N/A
0N/Apublic class EagerHttpFallback {
0N/A
5266N/A static final int INITIAL_PORT = TestLibrary.getUnusedRandomPort();
5266N/A static final int FALLBACK_PORT = TestLibrary.getUnusedRandomPort();
0N/A
0N/A public static void main(String[] args) throws Exception {
0N/A System.setProperty("http.proxyHost", "127.0.0.1");
0N/A System.setProperty("http.proxyPort", Integer.toString(FALLBACK_PORT));
0N/A System.setProperty("sun.rmi.transport.proxy.eagerHttpFallback",
0N/A "true");
0N/A LocateRegistry.createRegistry(FALLBACK_PORT);
0N/A
0N/A /*
0N/A * The call below should trigger a ConnectException in the
0N/A * RMIMasterSocketFactory when it attempts a direct connection to
0N/A * INITIAL_PORT, which no one is listening on. Since
0N/A * eagerHttpFallback is set, this ConnectException should trigger HTTP
0N/A * fallback, which will send a call through the HTTP proxy, which is
0N/A * configured to be localhost with a port behind which a registry is
0N/A * listening--so if fallback works properly, the list() call should
0N/A * succeed.
0N/A */
0N/A try {
0N/A LocateRegistry.getRegistry(INITIAL_PORT).list();
0N/A } catch (Exception e) {
0N/A System.err.println(
0N/A "call on registry stub with port " + INITIAL_PORT +
0N/A "did not successfully perform HTTP fallback to " +
0N/A FALLBACK_PORT);
0N/A throw e;
0N/A }
0N/A }
0N/A}