Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/rmi/transport/proxy/DisableHttpDefaultValue.java
38855 views
/*1* Copyright (c) 2013, 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/* @test24* @bug 802386225* @summary Verify that the default value of the java.rmi.server.disableHttp26* has been changed from false to true.27* @compile -XDignore.symbol.file DisableHttpDefaultValue.java28*29* @run main/othervm DisableHttpDefaultValue true30* @run main/othervm -Djava.rmi.server.disableHttp DisableHttpDefaultValue false31* @run main/othervm -Djava.rmi.server.disableHttp=false DisableHttpDefaultValue false32* @run main/othervm -Djava.rmi.server.disableHttp=xyzzy DisableHttpDefaultValue false33* @run main/othervm -Djava.rmi.server.disableHttp=true DisableHttpDefaultValue true34*/3536import sun.rmi.transport.proxy.RMIMasterSocketFactory;3738public class DisableHttpDefaultValue {39/**40* Subclass RMIMasterSocketFactory to get access to41* protected field altFactoryList. This list has a42* zero size if proxying is disabled.43*/44static class SocketFactory extends RMIMasterSocketFactory {45boolean proxyDisabled() {46return altFactoryList.size() == 0;47}48}4950/**51* Takes a single arg, which is the expected boolean value of52* java.rmi.server.disableHttp.53*/54public static void main(String[] args) throws Exception {55// Force there to be a proxy host, so that we are able to56// tell whether proxying is enabled or disabled.57System.setProperty("http.proxyHost", "proxy.example.com");5859String propval = System.getProperty("java.rmi.server.disableHttp");60String propdisp = (propval == null) ? "null" : ("\"" + propval + "\"");61boolean expected = Boolean.parseBoolean(args[0]);62boolean actual = new SocketFactory().proxyDisabled();63System.out.printf("### prop=%s exp=%s act=%s%n", propdisp, expected, actual);64if (expected != actual)65throw new AssertionError();66}67}686970