提交 63a5d5ed 编写于 作者: J jbachorik

8024613:...

8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
Summary: RMID needs a varying amount of time to start its socket server. We need to cater for it.
Reviewed-by: sjiang, dfuchs, sla
上级 cfd26cc9
/* /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2013 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
...@@ -25,49 +25,48 @@ ...@@ -25,49 +25,48 @@
* @test * @test
* @summary NPE IN RMIConnector.connect * @summary NPE IN RMIConnector.connect
* @bug 6984520 * @bug 6984520
* @library /java/rmi/testlibrary
* @run clean RMIConnector_NPETest * @run clean RMIConnector_NPETest
* @run build TestLibrary RMID
* @run build RMIConnector_NPETest * @run build RMIConnector_NPETest
* @run main RMIConnector_NPETest * @run main RMIConnector_NPETest
*/ */
import java.io.IOException;
import java.io.*;
import java.lang.management.*;
import java.rmi.registry.*;
import javax.management.*; import javax.management.*;
import javax.management.remote.*;
import javax.management.remote.rmi.*; import javax.management.remote.rmi.*;
public class RMIConnector_NPETest { public class RMIConnector_NPETest {
public static void main(String argv[]) throws Exception { public static void main(String argv[]) throws Exception {
boolean testFailed = false; RMID rmid = RMID.createRMID();
String rmidCmd = System.getProperty("java.home") + File.separator + rmid.start();
"bin" + File.separator + "rmid -port 3333"; int rmidPort = rmid.getPort();
String stopRmidCmd = System.getProperty("java.home") + File.separator + Exception failureCause = null;
"bin" + File.separator + "rmid -stop -port 3333"; RMIConnector agent = null;
try {
//start an rmid daemon and give it some time
System.out.println("Starting rmid");
Runtime.getRuntime().exec(rmidCmd);
Thread.sleep(5000);
MBeanServer mbs = MBeanServerFactory.createMBeanServer(); try {
RMIJRMPServerImpl rmiserver = new RMIJRMPServerImpl(3333, null, null, null); MBeanServer mbs = MBeanServerFactory.createMBeanServer();
rmiserver.setMBeanServer(mbs); RMIJRMPServerImpl rmiserver = new RMIJRMPServerImpl(rmidPort, null, null, null);
RMIConnector agent = new RMIConnector(rmiserver, null); rmiserver.setMBeanServer(mbs);
agent.connect(); agent = new RMIConnector(rmiserver, null);
} catch(NullPointerException npe) { agent.connect();
npe.printStackTrace(); } catch (NullPointerException npe) {
testFailed = true; failureCause = npe;
} catch (Exception e) { } catch (Exception e) {
// OK // OK
} finally { } finally {
System.out.println("Stopping rmid"); if (agent != null) {
Runtime.getRuntime().exec(stopRmidCmd); try {
agent.close();
} catch (IOException e) {
// ignore
}
}
rmid.shutdown(rmidPort);
} }
if(testFailed) if (failureCause != null) {
throw new Exception("Test failed"); TestLibrary.bomb("Test failed", failureCause);
}
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册