1 /*
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6610094
27 * @summary Test the OperatingSystemMXBean instance returned by
28 * ManagementFactory.getPlatformMXBeans()
29 * @author Mandy Chung
30 *
31 * @run main PlatformMXBeanTest
32 */
33
34 import java.lang.management.*;
35 import java.util.List;
36
37 public class PlatformMXBeanTest {
38 public static void main(String[] argv) throws Exception {
39 OperatingSystemMXBean osMBean = getOSPlatformMXBean(OperatingSystemMXBean.class);
40
41 // There should have only one single MXBean for the OS MXBean interfaces:
42 // java.lang.management.OperatingSystemMXBean
43 // com.sun.management.OperatingSystemMXBean
44 // com.sun.management.UnixOperatingSystemMXBean
45 if (osMBean != getOSPlatformMXBean(com.sun.management.OperatingSystemMXBean.class)) {
46 throw new RuntimeException(
47 "Invalid com.sun.management.OperatingSystemMXBean instance");
48 }
49
50 if (!System.getProperty("os.name").startsWith("Windows") &&
|
1 /*
2 * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6610094
27 * @summary Test the OperatingSystemMXBean instance returned by
28 * ManagementFactory.getPlatformMXBeans()
29 * @author Mandy Chung
30 *
31 * @modules java.management
32 * jdk.management
33 * @run main PlatformMXBeanTest
34 */
35
36 import java.lang.management.*;
37 import java.util.List;
38
39 public class PlatformMXBeanTest {
40 public static void main(String[] argv) throws Exception {
41 OperatingSystemMXBean osMBean = getOSPlatformMXBean(OperatingSystemMXBean.class);
42
43 // There should have only one single MXBean for the OS MXBean interfaces:
44 // java.lang.management.OperatingSystemMXBean
45 // com.sun.management.OperatingSystemMXBean
46 // com.sun.management.UnixOperatingSystemMXBean
47 if (osMBean != getOSPlatformMXBean(com.sun.management.OperatingSystemMXBean.class)) {
48 throw new RuntimeException(
49 "Invalid com.sun.management.OperatingSystemMXBean instance");
50 }
51
52 if (!System.getProperty("os.name").startsWith("Windows") &&
|