author | sjiang |
Tue, 24 Jun 2014 11:09:57 +0200 | |
changeset 25160 | 6f841ed9f1ec |
parent 21302 | c36804b5d972 |
child 27800 | 8578596f74a4 |
permissions | -rw-r--r-- |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
1 |
/* |
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
2 |
* Copyright (c) 2010, 2013 Oracle and/or its affiliates. All rights reserved. |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
4 |
* |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
8 |
* |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
13 |
* accompanied this code). |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
14 |
* |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
18 |
* |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
21 |
* questions. |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
22 |
*/ |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
23 |
|
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
24 |
/* |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
25 |
* @test |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
26 |
* @summary NPE IN RMIConnector.connect |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
27 |
* @bug 6984520 |
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
28 |
* @library /java/rmi/testlibrary |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
29 |
* @run clean RMIConnector_NPETest |
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
30 |
* @run build TestLibrary RMID |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
31 |
* @run build RMIConnector_NPETest |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
32 |
* @run main RMIConnector_NPETest |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
33 |
*/ |
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
34 |
import java.io.IOException; |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
35 |
import javax.management.*; |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
36 |
import javax.management.remote.rmi.*; |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
37 |
|
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
38 |
public class RMIConnector_NPETest { |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
39 |
public static void main(String argv[]) throws Exception { |
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
40 |
RMID rmid = RMID.createRMID(); |
25160
6f841ed9f1ec
8038321: RMIConnector_NPETest.java can't start rmid if running on fastdebug or Solaris-sparc
sjiang
parents:
21302
diff
changeset
|
41 |
rmid.start(Long.MAX_VALUE); |
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
42 |
int rmidPort = rmid.getPort(); |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
43 |
Exception failureCause = null; |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
44 |
RMIConnector agent = null; |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
45 |
|
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
46 |
try { |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
47 |
MBeanServer mbs = MBeanServerFactory.createMBeanServer(); |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
48 |
RMIJRMPServerImpl rmiserver = new RMIJRMPServerImpl(rmidPort, null, null, null); |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
49 |
rmiserver.setMBeanServer(mbs); |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
50 |
agent = new RMIConnector(rmiserver, null); |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
51 |
agent.connect(); |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
52 |
} catch (NullPointerException npe) { |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
53 |
failureCause = npe; |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
54 |
} catch (Exception e) { |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
55 |
// OK |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
56 |
} finally { |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
57 |
if (agent != null) { |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
58 |
try { |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
59 |
agent.close(); |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
60 |
} catch (IOException e) { |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
61 |
// ignore |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
62 |
} |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
63 |
} |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
64 |
rmid.shutdown(rmidPort); |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
65 |
} |
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
66 |
|
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
67 |
if (failureCause != null) { |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
68 |
TestLibrary.bomb("Test failed", failureCause); |
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
69 |
} |
7167
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
70 |
|
f5a0fca591f8
6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents:
diff
changeset
|
71 |
} |
21302
c36804b5d972
8024613: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java failing intermittently
jbachorik
parents:
7167
diff
changeset
|
72 |
} |