jdk/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java
author lmalvent
Mon, 10 Mar 2008 23:13:31 +0100
changeset 52 752ebbd838ad
child 5506 202f599c92aa
permissions -rw-r--r--
4981215: Publishing a port number for management console to access Reviewed-by: emcmanus, dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     1
/*
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     2
 * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     4
 *
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     7
 * published by the Free Software Foundation.
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     8
 *
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    13
 * accompanied this code).
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    14
 *
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    18
 *
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    21
 * have any questions.
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    22
 */
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    23
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    24
/*
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    25
 * @test
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    26
 * @bug 4981215
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    27
 * @summary Tests that the jvmstat counters published by the out-of-the-box
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    28
 *          management agent for the JMX connection details are correct.
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    29
 * @author Luis-Miguel Alventosa
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    30
 * @run clean JvmstatCountersTest
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    31
 * @run build JvmstatCountersTest
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    32
 * @run main/othervm JvmstatCountersTest 1
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    33
 * @run main/othervm -Dcom.sun.management.jmxremote JvmstatCountersTest 2
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    34
 * @run main/othervm -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JvmstatCountersTest 3
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    35
 * @run main/othervm JvmstatCountersTest 4
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    36
 */
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    37
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    38
import java.io.*;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    39
import java.lang.management.*;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    40
import java.util.*;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    41
import javax.management.*;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    42
import javax.management.remote.*;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    43
import com.sun.tools.attach.*;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    44
import sun.management.ConnectorAddressLink;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    45
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    46
public class JvmstatCountersTest {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    47
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    48
    public static void checkAddress(String address) throws IOException {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    49
        System.out.println("Address = " + address);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    50
        JMXServiceURL url = new JMXServiceURL(address);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    51
        JMXConnector jmxc = JMXConnectorFactory.connect(url);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    52
        MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    53
        System.out.println("MBean Count = " + mbsc.getMBeanCount());
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    54
    }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    55
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    56
    public static void checkKey(Map<String, String> data, int index,
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    57
            String key, String expectedValue) throws Exception {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    58
        String counter = "sun.management.JMXConnectorServer." + index + "." + key;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    59
        if (!data.containsKey(counter)) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    60
            System.out.println("Test FAILED! Missing counter " + counter);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    61
            throw new IllegalArgumentException("Test case failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    62
        }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    63
        String value = data.get(counter);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    64
        if (key.equals("remoteAddress")) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    65
            checkAddress(value);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    66
        } else if (!expectedValue.equals(value)) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    67
            System.out.println("Test FAILED! Invalid counter " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    68
                    counter + "=" + value);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    69
            throw new IllegalArgumentException("Test case failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    70
        }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    71
        System.out.println("OK: " + counter + "=" + value);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    72
    }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    73
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    74
    public static void main(String args[]) throws Exception {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    75
        String localAddress = ConnectorAddressLink.importFrom(0);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    76
        Map<String, String> remoteData = ConnectorAddressLink.importRemoteFrom(0);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    77
        final int testCase = Integer.parseInt(args[0]);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    78
        switch (testCase) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    79
            case 1:
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    80
                if (localAddress == null && remoteData.isEmpty()) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    81
                    System.out.println("Test PASSED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    82
                            "agent didn't publish any jvmstat counter.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    83
                } else {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    84
                    System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    85
                            "agent unexpectedly published jvmstat counters.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    86
                    throw new IllegalArgumentException("Test case 1 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    87
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    88
                break;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    89
            case 2:
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    90
                if (localAddress == null) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    91
                    System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    92
                            "agent didn't publish the local connector.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    93
                    throw new IllegalArgumentException("Test case 2 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    94
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    95
                checkAddress(localAddress);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    96
                if (!remoteData.isEmpty()) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    97
                    System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    98
                            "agent shouldn't publish the remote connector.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
    99
                    throw new IllegalArgumentException("Test case 2 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   100
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   101
                System.out.println("Test PASSED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   102
                        "agent only publishes the local connector through " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   103
                        "a jvmstat counter.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   104
                break;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   105
            case 3:
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   106
                if (localAddress == null) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   107
                    System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   108
                            "agent didn't publish the local connector.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   109
                    throw new IllegalArgumentException("Test case 3 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   110
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   111
                checkAddress(localAddress);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   112
                if (remoteData.isEmpty()) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   113
                    System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   114
                            "agent didnn't publish the remote connector.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   115
                    throw new IllegalArgumentException("Test case 3 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   116
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   117
                for (String key : remoteData.keySet()) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   118
                    if (!key.startsWith("sun.management.JMXConnectorServer.0.")) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   119
                        System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   120
                                "agent shouldn't publish anything which isn't " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   121
                                "related to the remote connector.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   122
                        throw new IllegalArgumentException("Test case 3 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   123
                    }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   124
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   125
                checkKey(remoteData, 0, "remoteAddress", null);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   126
                checkKey(remoteData, 0, "authenticate", "false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   127
                checkKey(remoteData, 0, "ssl", "false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   128
                checkKey(remoteData, 0, "sslRegistry", "false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   129
                checkKey(remoteData, 0, "sslNeedClientAuth", "false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   130
                System.out.println("Test PASSED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   131
                        "agent publishes both the local and remote " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   132
                        "connector info through jvmstat counters.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   133
                break;
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   134
            case 4:
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   135
                if (localAddress != null || !remoteData.isEmpty()) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   136
                    System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   137
                            "agent unexpectedly published jvmstat counters.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   138
                    throw new IllegalArgumentException("Test case 4 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   139
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   140
                RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   141
                String name = rt.getName();
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   142
                System.out.println("name = " + name);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   143
                String vmid = name.substring(0, name.indexOf("@"));
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   144
                System.out.println("vmid = " + vmid);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   145
                VirtualMachine vm = VirtualMachine.attach(vmid);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   146
                String agent = vm.getSystemProperties().getProperty("java.home") +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   147
                        File.separator + "lib" + File.separator + "management-agent.jar";
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   148
                vm.loadAgent(agent, "com.sun.management.jmxremote.port=0,com.sun.management.jmxremote.authenticate=false,com.sun.management.jmxremote.ssl=false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   149
                vm.detach();
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   150
                String localAddress2 = ConnectorAddressLink.importFrom(0);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   151
                if (localAddress2 == null) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   152
                    System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   153
                            "agent didn't publish the local connector.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   154
                    throw new IllegalArgumentException("Test case 4 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   155
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   156
                checkAddress(localAddress2);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   157
                Map<String, String> remoteData2 = ConnectorAddressLink.importRemoteFrom(0);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   158
                if (remoteData2.isEmpty()) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   159
                    System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   160
                            "agent didnn't publish the remote connector.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   161
                    throw new IllegalArgumentException("Test case 4 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   162
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   163
                for (String key : remoteData2.keySet()) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   164
                    if (!key.startsWith("sun.management.JMXConnectorServer.0.")) {
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   165
                        System.out.println("Test FAILED! The OOTB management " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   166
                                "agent shouldn't publish anything which isn't " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   167
                                "related to the remote connector.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   168
                        throw new IllegalArgumentException("Test case 4 failed");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   169
                    }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   170
                }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   171
                checkKey(remoteData2, 0, "remoteAddress", null);
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   172
                checkKey(remoteData2, 0, "authenticate", "false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   173
                checkKey(remoteData2, 0, "ssl", "false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   174
                checkKey(remoteData2, 0, "sslRegistry", "false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   175
                checkKey(remoteData2, 0, "sslNeedClientAuth", "false");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   176
                System.out.println("Test PASSED! The OOTB management agent " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   177
                        "publishes both the local and remote connector " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   178
                        "info through jvmstat counters when the agent is " +
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   179
                        "loaded through the Attach API.");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   180
        }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   181
        System.out.println("Bye! Bye!");
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   182
    }
752ebbd838ad 4981215: Publishing a port number for management console to access
lmalvent
parents:
diff changeset
   183
}