4904N/A/*
4904N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4904N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4904N/A *
4904N/A * This code is free software; you can redistribute it and/or modify it
4904N/A * under the terms of the GNU General Public License version 2 only, as
4904N/A * published by the Free Software Foundation.
4904N/A *
4904N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4904N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4904N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4904N/A * version 2 for more details (a copy is included in the LICENSE file that
4904N/A * accompanied this code).
4904N/A *
4904N/A * You should have received a copy of the GNU General Public License version
4904N/A * 2 along with this work; if not, write to the Free Software Foundation,
4904N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4904N/A *
4904N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4904N/A * or visit www.oracle.com if you need additional information or have any
4904N/A * questions.
4904N/A */
4904N/A
4904N/A/*
4904N/A * @test
4904N/A * @bug 7074616
4904N/A * @summary Basic unit test of the
4904N/A * ManagementFactory.getPlatformManagementInterfaces() method
4904N/A * @author Frederic Parain
4904N/A *
4904N/A * @run main GetPlatformManagementInterfaces
4904N/A */
4904N/A
4904N/Aimport java.lang.management.*;
4904N/Aimport java.io.IOException;
4904N/Aimport java.util.*;
4904N/Aimport javax.management.*;
4904N/A
4904N/Aimport static java.lang.management.ManagementFactory.*;
4904N/A
4904N/Apublic class GetPlatformManagementInterfaces {
4904N/A
4904N/A private static enum ManagementInterfaces {
4904N/A CLASS_LOADING_MXBEAN(ClassLoadingMXBean.class),
4904N/A COMPILATION_MXBEAN(CompilationMXBean.class),
4904N/A MEMORY_MXBEAN(MemoryMXBean.class),
4904N/A OPERATING_SYSTEM_MXBEAN(OperatingSystemMXBean.class),
4904N/A RUNTIME_MXBEAN(RuntimeMXBean.class),
4904N/A THREAD_MXBEAN(ThreadMXBean.class),
4904N/A GARBAGE_COLLECTOR_MXBEAN(GarbageCollectorMXBean.class),
4904N/A MEMORY_MANAGER_MXBEAN(MemoryManagerMXBean.class),
4904N/A MEMORY_POOL_MXBEAN(MemoryPoolMXBean.class);
4904N/A
4904N/A private final Class<? extends PlatformManagedObject> managementInterface;
4904N/A private ManagementInterfaces(Class<? extends PlatformManagedObject> minterface) {
4904N/A managementInterface = minterface;
4904N/A }
4904N/A public Class<? extends PlatformManagedObject> getManagementInterface() {
4904N/A return managementInterface;
4904N/A }
4904N/A };
4904N/A
4904N/A public static void main(String[] args) {
4904N/A Set<Class<? extends PlatformManagedObject>> interfaces =
4904N/A ManagementFactory.getPlatformManagementInterfaces();
4904N/A for(Class<? extends PlatformManagedObject> pom : interfaces) {
4904N/A List<? extends PlatformManagedObject> list =
4904N/A ManagementFactory.getPlatformMXBeans(pom);
4904N/A }
4904N/A for(ManagementInterfaces mi : ManagementInterfaces.values()) {
4904N/A if(!interfaces.contains(mi.getManagementInterface())) {
4904N/A throw new RuntimeException(mi.getManagementInterface() + " not in ManagementInterfaces set");
4904N/A }
4904N/A }
4904N/A }
4904N/A}