提交 2c210c98 编写于 作者: S sjiang

8077408: javax/management/remote/mandatory/notif/NotSerializableNotifTest.java...

8077408: javax/management/remote/mandatory/notif/NotSerializableNotifTest.java fails due to Port already in use: 2468
Reviewed-by: jbachorik
上级 5c3ed695
/* /*
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -34,37 +34,31 @@ ...@@ -34,37 +34,31 @@
// java imports // java imports
// //
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.Map; import javax.management.MBeanNotificationInfo;
import javax.management.MBeanServer;
// JMX imports import javax.management.MBeanServerConnection;
// import javax.management.MBeanServerFactory;
import javax.management.* ; import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
import javax.management.remote.*; import javax.management.NotificationListener;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL; import javax.management.remote.JMXServiceURL;
public class NotSerializableNotifTest { public class NotSerializableNotifTest {
private static final MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); private static final MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
private static ObjectName emitter; private static ObjectName emitter;
private static int port = 2468;
private static String[] protocols; private static String[] protocols;
private static final int sentNotifs = 10; private static final int sentNotifs = 10;
private static double timeoutFactor = 1.0;
private static final double defaultTimeout = 10;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
System.out.println(">>> Test to send a not serializable notification"); System.out.println(">>> Test to send a not serializable notification");
String timeoutVal = System.getProperty("test.timeout.factor");
if (timeoutVal != null) {
timeoutFactor = Double.parseDouble(
System.getProperty("test.timeout.factor")
);
}
// IIOP fails on JDK1.4, see 5034318 // IIOP fails on JDK1.4, see 5034318
final String v = System.getProperty("java.version"); final String v = System.getProperty("java.version");
float f = Float.parseFloat(v.substring(0, 3)); float f = Float.parseFloat(v.substring(0, 3));
...@@ -77,35 +71,18 @@ public class NotSerializableNotifTest { ...@@ -77,35 +71,18 @@ public class NotSerializableNotifTest {
emitter = new ObjectName("Default:name=NotificationEmitter"); emitter = new ObjectName("Default:name=NotificationEmitter");
mbeanServer.registerMBean(new NotificationEmitter(), emitter); mbeanServer.registerMBean(new NotificationEmitter(), emitter);
boolean ok = true;
for (int i = 0; i < protocols.length; i++) { for (int i = 0; i < protocols.length; i++) {
try { test(protocols[i]);
if (!test(protocols[i])) {
System.out.println(">>> Test failed for " + protocols[i]);
ok = false;
} else {
System.out.println(">>> Test successed for " + protocols[i]);
}
} catch (Exception e) {
System.out.println(">>> Test failed for " + protocols[i]);
e.printStackTrace(System.out);
ok = false;
}
} }
if (ok) { System.out.println(">>> Test passed");
System.out.println(">>> Test passed");
} else {
System.out.println(">>> TEST FAILED");
System.exit(1);
}
} }
private static boolean test(String proto) throws Exception { private static void test(String proto) throws Exception {
System.out.println("\n>>> Test for protocol " + proto); System.out.println("\n>>> Test for protocol " + proto);
JMXServiceURL url = new JMXServiceURL(proto, null, port++); JMXServiceURL url = new JMXServiceURL(proto, null, 0);
System.out.println(">>> Create a server: "+url); System.out.println(">>> Create a server: "+url);
...@@ -115,7 +92,7 @@ public class NotSerializableNotifTest { ...@@ -115,7 +92,7 @@ public class NotSerializableNotifTest {
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
System.out.println("System does not recognize URL: " + url + System.out.println("System does not recognize URL: " + url +
"; ignoring"); "; ignoring");
return true; return;
} }
server.start(); server.start();
...@@ -146,25 +123,10 @@ public class NotSerializableNotifTest { ...@@ -146,25 +123,10 @@ public class NotSerializableNotifTest {
// waiting ... // waiting ...
synchronized (listener) { synchronized (listener) {
int top = (int)Math.ceil(timeoutFactor * defaultTimeout); while (listener.received() < sentNotifs) {
for (int i=0; i<top; i++) { listener.wait(); // either pass or test timeout (killed by test harness)
if (listener.received() < sentNotifs) {
listener.wait(1000);
} else {
break;
}
}
}
// check }
boolean ok = true;
if (listener.received() != sentNotifs) {
System.out.println("Failed: received "+listener.received()+
" but should be "+sentNotifs);
ok = false;
} else {
System.out.println("The client received all notifications.");
} }
// clean // clean
...@@ -172,8 +134,6 @@ public class NotSerializableNotifTest { ...@@ -172,8 +134,6 @@ public class NotSerializableNotifTest {
conn.close(); conn.close();
server.stop(); server.stop();
return ok;
} }
//-------------------------- //--------------------------
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册