jdk/test/com/sun/jdi/CompatibleConnectors.java
author ykantser
Thu, 07 May 2015 09:11:49 +0200
changeset 30376 2ccf2cf7ea48
parent 5506 202f599c92aa
child 44423 306c020eb154
permissions -rw-r--r--
8078896: Add @modules as needed to the jdk_svc tests Reviewed-by: alanb, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 2015, 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
/* @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @bug 4287596
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @summary Unit test for "Pluggable Connectors and Transports" feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * This test checks that VirtualMachineManager creates Connectors that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * are "compatible" those created by 1.4 or earilier releases.
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 5506
diff changeset
    30
 * @modules jdk.jdi
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.jdi.connect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public class CompatibleConnectors {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    // number of tests that fail
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    static int failures;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    static void fail(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        System.out.println(msg + " - test failed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        failures++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    // the AttachingConnectors that we expect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static Object[][] attachingConnectors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        return new Object[][] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            { "com.sun.jdi.SocketAttach",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
              "dt_socket",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
              new String[] { "hostname", "Connector.StringArgument", "false" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
              new String[] { "port",     "Connector.IntegerArgument", "true" }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            { "com.sun.jdi.SharedMemoryAttach",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
              "dt_shmem",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
              new String[] { "name", "Connector.StringArgument", "true" }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    // the ListeningConnectors that we expect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    static Object[][] listeningConnectors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        return new Object[][] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            { "com.sun.jdi.SocketListen",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
              "dt_socket",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
              new String[] { "port", "Connector.IntegerArgument", "true" }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            { "com.sun.jdi.SharedMemoryListen",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
              "dt_shmem",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
              new String[] { "name", "Connector.StringArgument", "false" }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    // the LaunchingConnectors that we expect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    // - note that we don't indicate the transport name (as it varies
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    // for these connectors)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    static Object[][] launchingConnectors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        return new Object[][] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            { "com.sun.jdi.CommandLineLaunch",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
              null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
              new String[] { "home",    "Connector.StringArgument",     "false" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
              new String[] { "options", "Connector.StringArgument",     "false" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
              new String[] { "main",    "Connector.StringArgument",     "true"  },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
              new String[] { "suspend", "Connector.BooleanArgument",    "false" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
              new String[] { "quote",   "Connector.StringArgument",     "true"  },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
              new String[] { "vmexec",  "Connector.StringArgument",     "true" }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            { "com.sun.jdi.RawCommandLineLaunch",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
              null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
              new String[] { "command",  "Connector.StringArgument",     "true" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
              new String[] { "address",  "Connector.StringArgument",     "true" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
              new String[] { "quote",    "Connector.StringArgument",     "true" }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    // find Connector by name, return null if not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    static Connector find(String name, List l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        Iterator i = l.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        while (i.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            Connector c = (Connector)i.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            if (c.name().equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                return c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    // check that a connector is of the expected type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    static void type_match(String arg_name, String arg_type, Connector.Argument arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        boolean fail = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        if (arg_type.equals("Connector.StringArgument")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            if (!(arg instanceof Connector.StringArgument)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                fail = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (arg_type.equals("Connector.IntegerArgument")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            if (!(arg instanceof Connector.IntegerArgument)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                fail = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (arg_type.equals("Connector.BooleanArgument")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            if (!(arg instanceof Connector.BooleanArgument)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                fail = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        if (arg_type.equals("Connector.SelectedArgument")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            if (!(arg instanceof Connector.IntegerArgument)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                fail = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        if (fail) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            fail(arg_name + " is of type: " + arg.getClass() + ", expected: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                 + arg_type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    // check that a Connector is compatible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    static void check(Object[] desc, Connector connector) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        String name = (String)desc[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        String transport_name = (String)desc[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        // if the transport name is "null" it means its transport may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        // vary (eg: SunCommandLineLauncher will choose shared memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        // on Windows and dt_socket on Solaris). In that case we can't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        // check the transport name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        if (transport_name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            System.out.println("Checking transpot name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            if (!(transport_name.equals(connector.transport().name()))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                fail("transport().name() returns: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                    connector.transport().name() + ", expected: " + transport_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        // check that all the old arguments still exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        for (int i=2; i<desc.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            String[] args = (String[])desc[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            String arg_name = args[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            String arg_type = args[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            String arg_mandatory = args[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            System.out.println("Checking argument: " + arg_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            // check that the arg still exists
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            Map defaultArgs = connector.defaultArguments();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            Object value = defaultArgs.get(arg_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            if (value == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                fail(name + " is missing Connector.Argument: " + arg_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            // next check that the type matches
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            Connector.Argument connector_arg = (Connector.Argument)value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            // check that the argument type hasn't changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            type_match(arg_name, arg_type, connector_arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            // check that an optional argument has been made mandatory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            if (arg_mandatory.equals("false")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                if (connector_arg.mustSpecify()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    fail(arg_name + " is now mandatory");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        // next we check for new arguments that are mandatory but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        // have no default value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        System.out.println("Checking for new arguments");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        Map dfltArgs = connector.defaultArguments();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        Iterator iter = dfltArgs.keySet().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            String arg_name = (String)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            // see if the argument is new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            for (int j=2; j<desc.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                String[] args = (String[])desc[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                if (args[0].equals(arg_name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                    found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                Connector.Argument connector_arg =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                    (Connector.Argument)dfltArgs.get(arg_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                if (connector_arg.mustSpecify()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                    String value = connector_arg.value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    if (value.equals("")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                        value = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                    if (value == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                        fail("New Connector.Argument \"" + connector_arg.name() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                            "\" added - argument is mandatory");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    // compare the actual list of Connectors against the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    // expected list of Connectors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    static void compare(Object[][] prev, List list) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        String os = System.getProperty("os.name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        for (int i=0; i<prev.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            Object[] desc = prev[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            String name = (String)desc[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            // ignore Windows specific Connectors are non-Windows machines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            if (!(os.startsWith("Windows"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                if (name.equals("com.sun.jdi.SharedMemoryAttach") ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                    name.equals("com.sun.jdi.SharedMemoryListen")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            System.out.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            System.out.println("Checking Connector " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            // check that the Connector exists
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            Connector c = find(name, list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            if (c == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                fail("Connector is missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            check(desc, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public static void main(String args[]) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        // in 1.2/1.3/1.4 the defualtConnector was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        // com.sun.jdi.CommandLineLaunch. Many debuggers probably
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        // depend on this so check that it's always the default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        String expected = "com.sun.jdi.CommandLineLaunch";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        System.out.println("Checking that defaultConnector is: " + expected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        String dflt = vmm.defaultConnector().name();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        if (!(dflt.equals(expected))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            System.err.println("defaultConnector() is: " + dflt +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                ", expected:" + expected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            failures++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            System.out.println("Okay");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        compare(attachingConnectors(), vmm.attachingConnectors());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        compare(listeningConnectors(), vmm.listeningConnectors());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        compare(launchingConnectors(), vmm.launchingConnectors());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        // test results
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        if (failures > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            System.out.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            throw new RuntimeException(failures + " test(s) failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
}