jdk/test/javax/management/remote/mandatory/connectorServer/SetMBeanServerForwarder.java
author lana
Thu, 26 Dec 2013 12:04:16 -0800
changeset 23010 6dadb192ad81
parent 14917 bf08557604f8
child 30376 2ccf2cf7ea48
permissions -rw-r--r--
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013 Summary: updated files with 2011, 2012 and 2013 years according to the file's last updated date Reviewed-by: tbell, lancea, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 14917
diff changeset
     2
 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 4944680
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Tests that IllegalArgumentException is thrown when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *          MBeanServerForwrder is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @author Daniel Fuchs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @run clean SetMBeanServerForwarder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * @run build SetMBeanServerForwarder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * @run main SetMBeanServerForwarder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.management.remote.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.remote.rmi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.jmx.remote.security.MBeanServerAccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public class SetMBeanServerForwarder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
    43
    static boolean isPresent(String cn) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        try {
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
    45
            Class.forName(cn);
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
    46
            return true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        } catch (ClassNotFoundException x) {
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
    48
            return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
    52
    public static int test(String... urls) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        int errorCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        for (int i=0;i<urls.length;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                final MBeanServer mbs = MBeanServerFactory.newMBeanServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                final JMXConnectorServer cs1,cs2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                final JMXServiceURL      url;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                System.out.println("*** -----------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                System.out.println("*** JMXConnectorServer("+urls[i]+")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                System.out.println("*** -----------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                    url = new JMXServiceURL(urls[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                    cs1 = JMXConnectorServerFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                        .newJMXConnectorServer(url,(Map)null,mbs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                    cs2 = JMXConnectorServerFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                        .newJMXConnectorServer(url,(Map)null,null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                } catch (Throwable thr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                    System.out.println("Failed to create ConnectorServer "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                                       "from [" + urls[i] +"]: " + thr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                    thr.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                    errorCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                // Test using a JMXConnectorServer already connected to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                // MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                // Set null MBeanServerForwarder - expect exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                    cs1.setMBeanServerForwarder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                    errorCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                    System.out.println("Expected IllegalArgumentException "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                                       " not thrown (null forwarder) for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                       url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                    System.out.println("\t\t[connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                } catch (IllegalArgumentException iae) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                    System.out.println("Received expected exception: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                                       iae);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                // Now try with a real MBSF - should not throw exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                    final MBeanServerForwarder fwd = new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                        MBeanServerAccessController() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                            protected void checkRead() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                            protected void checkWrite() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                    cs1.setMBeanServerForwarder(fwd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                    // Verify that the MBSF was correctly set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                    if (cs1.getMBeanServer() != fwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                        System.out.println("MBeanServerForwarder not set "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                                           "for " + url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                        System.out.println("\t\t[connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                        throw new AssertionError("cs1.getMBeanServer()!=fwd");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                    // Verify that the MBS was correctly forwarded to the MBSF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                    if (fwd.getMBeanServer() != mbs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                        System.out.println("MBeanServer not set in Forwarder"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                                           " for " + url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                        System.out.println("\t\t[connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                        throw new AssertionError("fwd.getMBeanServer()!=mbs");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    System.out.println("MBeanServerForwarder successfully "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                                       "set for " + url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    System.out.println("\t\t[connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                } catch (Throwable x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    errorCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    System.out.println("Failed to set forwarder for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                       url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                    System.out.println("\t\t[connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    System.out.println("Unexpected exception: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                       x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                    x.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                // Test using a JMXConnectorServer not connected to any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                // MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                // Set null MBeanServerForwarder - expect exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                    cs2.setMBeanServerForwarder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                    errorCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                    System.out.println("Expected IllegalArgumentException "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                       " not thrown (null forwarder) for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                                       url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                    System.out.println("\t\t[not connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                } catch (IllegalArgumentException iae) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                    System.out.println("Received expected exception: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                                       iae);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                // Now try with a real MBSF - should not throw exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    final MBeanServerForwarder fwd = new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                        MBeanServerAccessController() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                            protected void checkRead() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                            protected void checkWrite() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    cs2.setMBeanServerForwarder(fwd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    // Verify that the MBSF was correctly set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    if (cs2.getMBeanServer() != fwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                        System.out.println("MBeanServerForwarder not set "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                           "for " + url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                        System.out.println("\t\t[not connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                        throw new AssertionError("cs2.getMBeanServer()!=fwd");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    // Now register the connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    final ObjectName name =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                        new ObjectName(":type="+cs2.getClass().getName()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                                       ",url="+ObjectName.quote(urls[i]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    mbs.registerMBean(cs2,name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                        // Verify that the MBSF was not disconnected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                        if (cs2.getMBeanServer() != fwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                            System.out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                                println("MBeanServerForwarder changed "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                                        "for " + url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                            System.out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                                println("\t\t[registerMBean]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                            throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                                AssertionError("cs2.getMBeanServer()!=fwd");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        // Verify that the MBS was not forwarded to the MBSF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                        if (fwd.getMBeanServer() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                            System.out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                println("MBeanServer changed in Forwarder"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                                        " for " + url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                            System.out.println("\t\t[registerMBean]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                            throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                AssertionError("fwd.getMBeanServer()!=null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                        mbs.unregisterMBean(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                    System.out.println("MBeanServerForwarder successfully "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                                       "set for " + url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                    System.out.println("\t\t[not connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                } catch (Throwable x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    errorCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    System.out.println("Failed to set forwarder for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                       url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                    System.out.println("\t\t[not connected to MBeanServer]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                    System.out.println("Unexpected exception: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                                       x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                    x.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            } catch (Exception x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                System.err.println("Unexpected exception for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                   urls[i] + ": " + x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                x.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                errorCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        return errorCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public static void main(String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        int errCount = 0;
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   233
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   234
        // mandatory
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   235
        errCount += test("service:jmx:rmi://");
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   236
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   237
        // optional
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   238
        if (isPresent("javax.management.remote.rmi._RMIConnectionImpl_Tie"))
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   239
            errCount += test("service:jmx:iiop://");
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   240
        if (isPresent("javax.management.remote.generic.GenericConnector"))
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   241
            errCount += test("service:jmx:jmxmp://");
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   242
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        if (errCount > 0) {
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   244
            throw new RuntimeException("SetMBeanServerForwarder failed: " +
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 5506
diff changeset
   245
                                       errCount + " error(s) reported.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        System.out.println("SetMBeanServerForwarder passed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
}