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