diff options
Diffstat (limited to 'test/javax/management')
5 files changed, 45 insertions, 83 deletions
diff --git a/test/javax/management/monitor/CounterMonitorThresholdTest.java b/test/javax/management/monitor/CounterMonitorThresholdTest.java index a1f93d8c4..b56d314af 100644 --- a/test/javax/management/monitor/CounterMonitorThresholdTest.java +++ b/test/javax/management/monitor/CounterMonitorThresholdTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6229368 + * @bug 6229368 8025207 * @summary Wrong threshold value in CounterMonitor with offset and modulus. * @author Luis-Miguel Alventosa * @run clean CounterMonitorThresholdTest @@ -144,16 +144,14 @@ public class CounterMonitorThresholdTest { for (int i = 0; i < counter.length; i++) { mbean.setCounter(counter[i]); System.out.println("\nCounter = " + mbean.getCounter()); - Thread.sleep(300); - Integer derivedGaugeValue = (Integer) cm.getDerivedGauge(name); - System.out.println("Derived Gauge = " + derivedGaugeValue); - if (derivedGaugeValue.intValue() != derivedGauge[i]) { - System.out.println("Wrong derived gauge! Current value = " + - derivedGaugeValue + " Expected value = " + derivedGauge[i]); - System.out.println("\nStop monitoring..."); - cm.stop(); - throw new IllegalArgumentException("wrong derived gauge"); - } + Integer derivedGaugeValue; + // either pass or test timeout (killed by test harness) + // see 8025207 + do { + Thread.sleep(150); + derivedGaugeValue = (Integer) cm.getDerivedGauge(name); + } while (derivedGaugeValue.intValue() != derivedGauge[i]); + Number thresholdValue = cm.getThreshold(name); System.out.println("Threshold = " + thresholdValue); if (thresholdValue.intValue() != threshold[i]) { @@ -163,7 +161,6 @@ public class CounterMonitorThresholdTest { cm.stop(); throw new IllegalArgumentException("wrong threshold"); } - Thread.sleep(300); } // Stop the monitor diff --git a/test/javax/management/monitor/NullAttributeValueTest.java b/test/javax/management/monitor/NullAttributeValueTest.java index e1661186a..01ab275fa 100644 --- a/test/javax/management/monitor/NullAttributeValueTest.java +++ b/test/javax/management/monitor/NullAttributeValueTest.java @@ -23,11 +23,12 @@ /* * @test - * @bug 6200031 + * @bug 6200031 8025206 * @summary Test that the counter/gauge/string monitors emit a * jmx.monitor.error.type notification when the attribute * being monitored returns a null value. * @author Luis-Miguel Alventosa + * @author Shanliang JIANG * @run clean NullAttributeValueTest * @run build NullAttributeValueTest * @run main NullAttributeValueTest @@ -39,7 +40,7 @@ import javax.management.monitor.*; public class NullAttributeValueTest implements NotificationListener { // Flag to notify that a message has been received - private boolean messageReceived = false; + private volatile boolean messageReceived = false; // MBean class public class ObservedObject implements ObservedObjectMBean { @@ -83,7 +84,6 @@ public class NullAttributeValueTest implements NotificationListener { * Update the counter and check for notifications */ public int counterMonitorNotification() throws Exception { - CounterMonitor counterMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -134,31 +134,17 @@ public class NullAttributeValueTest implements NotificationListener { 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 notification received"); - } else { - echo("\tKO: CounterMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "CounterMonitor"); } finally { if (counterMonitor != null) counterMonitor.stop(); } - - return 0; } /** * Update the gauge and check for notifications */ public int gaugeMonitorNotification() throws Exception { - GaugeMonitor gaugeMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -212,31 +198,17 @@ public class NullAttributeValueTest implements NotificationListener { 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 notification received"); - } else { - echo("\tKO: GaugeMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "GaugeMonitor"); } finally { if (gaugeMonitor != null) gaugeMonitor.stop(); } - - return 0; } /** * Update the string and check for notifications */ public int stringMonitorNotification() throws Exception { - StringMonitor stringMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -289,24 +261,11 @@ public class NullAttributeValueTest implements NotificationListener { 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 notification received"); - } else { - echo("\tKO: StringMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "StringMonitor"); } finally { if (stringMonitor != null) stringMonitor.stop(); } - - return 0; } /** @@ -326,6 +285,21 @@ public class NullAttributeValueTest implements NotificationListener { return error; } + private int checkReceived(long granularityperiod, String caller) throws InterruptedException { + int i = 100; + do { + Thread.sleep(granularityperiod); + } while (!messageReceived && i-- > 0); + + if (messageReceived) { + echo("\tOK: " + caller + " notification received"); + } else { + echo("\tKO: " + caller + " notification missed or not emitted"); + } + + return messageReceived ? 0 : 1; + } + /* * Print message */ diff --git a/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java b/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java index 1ada5fb3b..42bed8570 100644 --- a/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java +++ b/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4940957 + * @bug 4940957 8025205 * @summary Tests behaviour when connections break * @author Eamonn McManus * @run clean BrokenConnectionTest @@ -485,14 +485,13 @@ public class BrokenConnectionTest { } if (thisok) { System.out.println("Waiting for failure notif"); - long deadline = System.currentTimeMillis() + 5000; - while (failureListener.count < 1 - && System.currentTimeMillis() < deadline) - Thread.sleep(500); - if (failureListener.count < 1) { - System.out.println("Did not get failure notif!"); - thisok = false; - } else if (failureListener.count > 1) { + // pass or test timeout. see 8025205 + do { + Thread.sleep(100); + } while (failureListener.count < 1); + + Thread.sleep(1000); // if more notif coming ... + if (failureListener.count > 1) { System.out.println("Got too many failure notifs: " + failureListener.count); thisok = false; diff --git a/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java b/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java index 854a211a7..9bd9a741c 100644 --- a/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java +++ b/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4886838 4886830 + * @bug 4886838 4886830 8025204 * @summary Tests that idle timeouts happen at appropriate times * @author Eamonn McManus * @run clean IdleTimeoutTest @@ -278,19 +278,11 @@ public class IdleTimeoutTest { } System.out.println("Waiting for id list to drop ours"); - deadline = System.currentTimeMillis() + timeout*2 + 10000; - while (true) { - ids = Arrays.asList(server.getConnectionIds()); - if (!ids.contains(connId) - || System.currentTimeMillis() >= deadline) - break; - Thread.sleep(500); - } - if (ids.contains(connId)) { - System.out.println("Client id still in list after " + - "deadline: " + ids); - return false; - } + // pass or timed out by test harness - see 8025204 + do { + Thread.sleep(100); + ids = Arrays.asList(server.getConnectionIds()); + } while (ids.contains(connId)); conn.getDefaultDomain(); if (connId.equals(client.getConnectionId())) { diff --git a/test/javax/management/remote/mandatory/loading/MissingClassTest.java b/test/javax/management/remote/mandatory/loading/MissingClassTest.java index e70d0adfe..98eead895 100644 --- a/test/javax/management/remote/mandatory/loading/MissingClassTest.java +++ b/test/javax/management/remote/mandatory/loading/MissingClassTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4915825 4921009 4934965 4977469 + * @bug 4915825 4921009 4934965 4977469 8019584 * @summary Tests behavior when client or server gets object of unknown class * @author Eamonn McManus * @run clean MissingClassTest SingleClassLoader |