test/javax/management/monitor/ReflectionExceptionTest.java

Print this page

        

*** 85,95 **** --- 85,99 ---- echo("\tTimeStamp: " + mn.getTimeStamp()); echo("\tObservedObject: " + mn.getObservedObject()); echo("\tObservedAttribute: " + mn.getObservedAttribute()); echo("\tDerivedGauge: " + mn.getDerivedGauge()); echo("\tTrigger: " + mn.getTrigger()); + + synchronized (this) { messageReceived = true; + notifyAll(); + } } } } /**
*** 133,148 **** echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod); echo(">>> START the CounterMonitor"); counterMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - // Check if notification was received // if (messageReceived) { echo("\tOK: CounterMonitor got RUNTIME_ERROR notification!"); } else { echo("\tKO: CounterMonitor did not get " + "RUNTIME_ERROR notification!"); --- 137,149 ---- echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod); echo(">>> START the CounterMonitor"); counterMonitor.start(); // Check if notification was received // + doWait(); if (messageReceived) { echo("\tOK: CounterMonitor got RUNTIME_ERROR notification!"); } else { echo("\tKO: CounterMonitor did not get " + "RUNTIME_ERROR notification!");
*** 201,216 **** echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod); echo(">>> START the GaugeMonitor"); gaugeMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - // Check if notification was received // if (messageReceived) { echo("\tOK: GaugeMonitor got RUNTIME_ERROR notification!"); } else { echo("\tKO: GaugeMonitor did not get " + "RUNTIME_ERROR notification!"); --- 202,214 ---- echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod); echo(">>> START the GaugeMonitor"); gaugeMonitor.start(); // Check if notification was received // + doWait(); if (messageReceived) { echo("\tOK: GaugeMonitor got RUNTIME_ERROR notification!"); } else { echo("\tKO: GaugeMonitor did not get " + "RUNTIME_ERROR notification!");
*** 268,283 **** echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod); echo(">>> START the StringMonitor"); stringMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - // Check if notification was received // if (messageReceived) { echo("\tOK: StringMonitor got RUNTIME_ERROR notification!"); } else { echo("\tKO: StringMonitor did not get " + "RUNTIME_ERROR notification!"); --- 266,278 ---- echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod); echo(">>> START the StringMonitor"); stringMonitor.start(); // Check if notification was received // + doWait(); if (messageReceived) { echo("\tOK: StringMonitor got RUNTIME_ERROR notification!"); } else { echo("\tKO: StringMonitor did not get " + "RUNTIME_ERROR notification!");
*** 347,358 **** } else { echo(">>> Happy Bye, Bye!"); } } // Flag to notify that a message has been received ! private boolean messageReceived = false; private MBeanServer server; private ObjectName obsObjName; private String domain; } --- 342,368 ---- } else { echo(">>> Happy Bye, Bye!"); } } + /* + * Wait messageReceived to be true + */ + synchronized void doWait() { + while (!messageReceived) { + try { + wait(); + } catch (InterruptedException e) { + System.err.println("Got unexpected exception: " + e); + e.printStackTrace(); + break; + } + } + } + // Flag to notify that a message has been received ! private volatile boolean messageReceived = false; private MBeanServer server; private ObjectName obsObjName; private String domain; }