ReflectionExceptionTest.java revision 0
0N/A * Copyright 2005 Sun Microsystems, Inc. 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. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * @summary Test that the jmx.monitor.error.runtime monitor notification 0N/A * is emitted when getAttribute throws ReflectionException. 0N/A * @author Luis-Miguel Alventosa 0N/A * @run clean ReflectionExceptionTest MBeanServerBuilderImpl 0N/A * MBeanServerForwarderInvocationHandler 0N/A * @run build ReflectionExceptionTest MBeanServerBuilderImpl 0N/A * MBeanServerForwarderInvocationHandler 0N/A * @run main ReflectionExceptionTest 0N/A // Notification handler 0N/A * Update the counter and check for notifications 0N/A // Create a new CounterMonitor MBean and add it to the MBeanServer. 0N/A echo(
">>> CREATE a new CounterMonitor MBean");
0N/A echo(
">>> ADD a listener to the CounterMonitor");
0N/A // MANAGEMENT OF A STANDARD MBEAN 0N/A echo(
">>> SET the attributes of the CounterMonitor:");
0N/A echo(
"\tATTRIBUTE \"ObservedAttribute\" = IntegerAttribute");
0N/A echo(
"\tATTRIBUTE \"NotifyFlag\" = false");
0N/A echo(
">>> START the CounterMonitor");
0N/A // Wait for granularity period (multiplied by 2 for sure) 0N/A // Check if notification was received 0N/A echo(
"\tOK: CounterMonitor got RUNTIME_ERROR notification!");
0N/A echo(
"\tKO: CounterMonitor did not get " +
0N/A "RUNTIME_ERROR notification!");
0N/A * Update the gauge and check for notifications 0N/A // Create a new GaugeMonitor MBean and add it to the MBeanServer. 0N/A echo(
">>> CREATE a new GaugeMonitor MBean");
0N/A echo(
">>> ADD a listener to the GaugeMonitor");
0N/A // MANAGEMENT OF A STANDARD MBEAN 0N/A echo(
">>> SET the attributes of the GaugeMonitor:");
0N/A echo(
"\tATTRIBUTE \"ObservedAttribute\" = IntegerAttribute");
0N/A echo(
"\tATTRIBUTE \"Notify Low Flag\" = false");
0N/A echo(
"\tATTRIBUTE \"Notify High Flag\" = false");
0N/A echo(
">>> START the GaugeMonitor");
0N/A // Wait for granularity period (multiplied by 2 for sure) 0N/A // Check if notification was received 0N/A echo(
"\tOK: GaugeMonitor got RUNTIME_ERROR notification!");
0N/A echo(
"\tKO: GaugeMonitor did not get " +
0N/A "RUNTIME_ERROR notification!");
0N/A * Update the string and check for notifications 0N/A // Create a new StringMonitor MBean and add it to the MBeanServer. 0N/A echo(
">>> CREATE a new StringMonitor MBean");
0N/A echo(
">>> ADD a listener to the StringMonitor");
0N/A // MANAGEMENT OF A STANDARD MBEAN 0N/A echo(
">>> SET the attributes of the StringMonitor:");
0N/A echo(
"\tATTRIBUTE \"ObservedAttribute\" = StringAttribute");
0N/A echo(
"\tATTRIBUTE \"NotifyMatch\" = false");
0N/A echo(
"\tATTRIBUTE \"NotifyDiffer\" = false");
0N/A echo(
"\tATTRIBUTE \"StringToCompare\" = \"dummy\"");
0N/A echo(
">>> START the StringMonitor");
0N/A // Wait for granularity period (multiplied by 2 for sure) 0N/A // Check if notification was received 0N/A echo(
"\tOK: StringMonitor got RUNTIME_ERROR notification!");
0N/A echo(
"\tKO: StringMonitor did not get " +
0N/A "RUNTIME_ERROR notification!");
0N/A * Test the monitor notifications. 0N/A "Test ReflectionException"));
0N/A echo(
">>> ----------------------------------------");
0N/A echo(
">>> ----------------------------------------");
0N/A echo(
">>> ----------------------------------------");
0N/A echo(
">>> ----------------------------------------");
0N/A * Standalone entry point. 0N/A * Run the test and report to stdout. 0N/A "the notifications that were " +
0N/A "expected by the test!");
0N/A // Flag to notify that a message has been received