2362N/A * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary Test that JMX classes use fully-qualified class names 0N/A * in MBeanNotificationInfo 0N/A * @author Eamonn McManus 0N/A * @run clean NotificationInfoTest 0N/A * @run build NotificationInfoTest 0N/A * @run main NotificationInfoTest 0N/A * This test finds all classes in the same code-base as the JMX 0N/A * classes that look like Standard MBeans, and checks that if they are 0N/A * NotificationBroadcasters they declare existent notification types. 0N/A * A class looks like a Standard MBean if both Thing and ThingMBean 0N/A * classes exist. So for example javax.management.timer.Timer looks 0N/A * like a Standard MBean because javax.management.timer.TimerMBean 0N/A * exists. Timer is instanceof NotificationBroadcaster, so we expect 0N/A * that ((NotificationBroadcaster) timer).getNotificationInfo() will 0N/A * return an array of MBeanNotificationInfo where each entry has a 0N/A * getName() that names an existent Java class that is a Notification. 0N/A * An MBean is "suspicious" if it is a NotificationBroadcaster but its 0N/A * MBeanNotificationInfo[] is empty. This is legal, but surprising. 0N/A * In order to call getNotificationInfo(), we need an instance of the 0N/A * class. We attempt to make one by calling a public no-arg 0N/A * constructor. But the "construct" method below can be extended to 0N/A * construct specific MBean classes for which the no-arg constructor 0N/A * The test is obviously not exhaustive, but does catch the cases that 0N/A * failed in 5012634. 0N/A // class or object names where the test failed 0N/A // class or object names where there were no MBeanNotificationInfo entries 0N/A "NotificationBroadcasters have sane " +
0N/A "MBeanInfo.getNotifications()");
0N/A check(new RequiredModelMBean()); 0N/A because the Model MBean spec more or less forces us to use the 0N/A names GENERIC and ATTRIBUTE_CHANGE for its standard notifs. 0N/A // Each MBeanNotificationInfo.getName() should be an existent 0N/A // Java class that is Notification or a subclass of it 0N/A ": not a Notification) ");