jdk/test/sun/rmi/transport/proxy/DisableHttpDefaultValue.java
author stefank
Mon, 25 Aug 2014 09:10:13 +0200
changeset 26314 f8bc1966fb30
parent 21359 2d32ce9ea2b4
child 30820 0d4717a011d3
permissions -rw-r--r--
8055416: Several vm/gc/heap/summary "After GC" events emitted for the same GC ID Reviewed-by: brutisso, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21359
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     1
/*
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     4
 *
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     8
 *
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    13
 * accompanied this code).
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    14
 *
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    18
 *
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    21
 * questions.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    22
 */
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    23
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    24
/* @test
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    25
 * @bug 8023862
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    26
 * @summary Verify that the default value of the java.rmi.server.disableHttp
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    27
 *          has been changed from false to true.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    28
 * @compile -XDignore.symbol.file DisableHttpDefaultValue.java
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    29
 *
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    30
 * @run main/othervm                                     DisableHttpDefaultValue true
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    31
 * @run main/othervm -Djava.rmi.server.disableHttp       DisableHttpDefaultValue false
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    32
 * @run main/othervm -Djava.rmi.server.disableHttp=false DisableHttpDefaultValue false
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    33
 * @run main/othervm -Djava.rmi.server.disableHttp=xyzzy DisableHttpDefaultValue false
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    34
 * @run main/othervm -Djava.rmi.server.disableHttp=true  DisableHttpDefaultValue true
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    35
 */
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    36
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    37
import sun.rmi.transport.proxy.RMIMasterSocketFactory;
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    38
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    39
public class DisableHttpDefaultValue {
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    40
    /**
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    41
     * Subclass RMIMasterSocketFactory to get access to
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    42
     * protected field altFactoryList. This list has a
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    43
     * zero size if proxying is disabled.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    44
     */
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    45
    static class SocketFactory extends RMIMasterSocketFactory {
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    46
        boolean proxyDisabled() {
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    47
            return altFactoryList.size() == 0;
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    48
        }
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    49
    }
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    50
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    51
    /**
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    52
     * Takes a single arg, which is the expected boolean value of
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    53
     * java.rmi.server.disableHttp.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    54
     */
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    55
    public static void main(String[] args) throws Exception {
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    56
        // Force there to be a proxy host, so that we are able to
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    57
        // tell whether proxying is enabled or disabled.
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    58
        System.setProperty("http.proxyHost", "proxy.example.com");
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    59
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    60
        String propval = System.getProperty("java.rmi.server.disableHttp");
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    61
        String propdisp = (propval == null) ? "null" : ("\"" + propval + "\"");
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    62
        boolean expected = Boolean.parseBoolean(args[0]);
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    63
        boolean actual = new SocketFactory().proxyDisabled();
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    64
        System.out.printf("### prop=%s exp=%s act=%s%n", propdisp, expected, actual);
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    65
        if (expected != actual)
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    66
            throw new AssertionError();
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    67
    }
2d32ce9ea2b4 8023862: deprecate HTTP proxying from RMI
smarks
parents:
diff changeset
    68
}