equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
31 * @run build AddRemoveTest |
31 * @run build AddRemoveTest |
32 * @run main AddRemoveTest |
32 * @run main AddRemoveTest |
33 */ |
33 */ |
34 |
34 |
35 import java.net.MalformedURLException; |
35 import java.net.MalformedURLException; |
|
36 import java.io.IOException; |
36 |
37 |
37 import java.util.Collections; |
|
38 import java.util.Map; |
|
39 import javax.management.*; |
38 import javax.management.*; |
40 import javax.management.remote.*; |
39 import javax.management.remote.*; |
41 import javax.management.remote.rmi.RMIConnectorServer; |
|
42 |
40 |
43 public class AddRemoveTest { |
41 public class AddRemoveTest { |
44 private static final String[] protocols = {"rmi", "iiop", "jmxmp"}; |
42 private static final String[] protocols = {"rmi", "iiop", "jmxmp"}; |
45 private static final MBeanServer mbs = MBeanServerFactory.createMBeanServer(); |
43 private static final MBeanServer mbs = MBeanServerFactory.createMBeanServer(); |
46 |
44 |
69 System.out.println(">>> TEST FAILED"); |
67 System.out.println(">>> TEST FAILED"); |
70 System.exit(1); |
68 System.exit(1); |
71 } |
69 } |
72 } |
70 } |
73 |
71 |
74 private static boolean test(String proto) throws Exception { |
72 private static boolean test(String proto) |
75 boolean ok = test(proto, false); |
|
76 ok &= test(proto, true); |
|
77 return ok; |
|
78 } |
|
79 |
|
80 private static boolean test(String proto, boolean eventService) |
|
81 throws Exception { |
73 throws Exception { |
82 System.out.println(">>> Test for protocol " + proto + " with" + |
74 System.out.println(">>> Test for protocol " + proto); |
83 (eventService ? "" : "out") + " event service"); |
|
84 JMXServiceURL u = new JMXServiceURL(proto, null, 0); |
75 JMXServiceURL u = new JMXServiceURL(proto, null, 0); |
85 JMXConnectorServer server; |
76 JMXConnectorServer server; |
86 JMXServiceURL addr; |
77 JMXServiceURL addr; |
87 JMXConnector client; |
78 JMXConnector client; |
88 MBeanServerConnection mserver; |
79 MBeanServerConnection mserver; |
96 } |
87 } |
97 }; |
88 }; |
98 |
89 |
99 try { |
90 try { |
100 // with a client listener, but close the server first |
91 // with a client listener, but close the server first |
101 Map<String, String> env = Collections.singletonMap( |
92 server = JMXConnectorServerFactory.newJMXConnectorServer(u, null, mbs); |
102 RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, |
|
103 Boolean.toString(eventService)); |
|
104 server = JMXConnectorServerFactory.newJMXConnectorServer(u, env, mbs); |
|
105 server.start(); |
93 server.start(); |
106 |
94 |
107 addr = server.getAddress(); |
95 addr = server.getAddress(); |
108 client = JMXConnectorFactory.newJMXConnector(addr, null); |
96 client = JMXConnectorFactory.newJMXConnector(addr, null); |
109 client.connect(null); |
97 client.connect(null); |