blob: b24676b317fe2532a0bef6374429229c8a1aa6a9 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 * @test
26 * @bug 6245733
27 *
28 * @summary synopsis: rmid's registry's list operation doesn't include
29 * activation system
30 * @author Ann Wollrath
31 *
32 * @library ../../../testlibrary
33 * @build TestLibrary RMID ActivationLibrary
34 * @build LookupActivationSystem
35 * @run main/othervm/timeout=240 LookupActivationSystem
36 */
37
38import java.rmi.*;
39import java.rmi.activation.*;
40import java.rmi.registry.*;
41import java.rmi.server.*;
42import java.io.Serializable;
43
44public class LookupActivationSystem implements Remote, Serializable {
45
46 private static final String NAME = ActivationSystem.class.getName();
47
48 public static void main(String[] args) throws Exception {
49
50 System.out.println("\nRegression test for bug 6245733\n");
51
52 RMID rmid = null;
53
54 try {
55 RMID.removeLog();
56 rmid = RMID.createRMID();
57 rmid.start();
58
59 System.err.println("look up activation system");
60 Registry rmidRegistry =
61 LocateRegistry.getRegistry(ActivationSystem.SYSTEM_PORT);
62 ActivationSystem system = (ActivationSystem)
63 rmidRegistry.lookup(NAME);
64
65 if (system instanceof ActivationSystem) {
66 System.err.println("test1 passed: lookup succeeded");
67 }
68
69 System.err.println("get list of rmid internal registry");
70 String[] list = rmidRegistry.list();
71 if (list.length == 1 && list[0].equals(NAME)) {
72 System.err.println(
73 "test2 passed: activation system found in list");
74 } else {
75 throw new RuntimeException("test2 FAILED");
76 }
77
78 try {
79 rmidRegistry.bind(NAME, new LookupActivationSystem());
80 throw new RuntimeException("test3 FAILED: bind succeeded!");
81 } catch (ServerException e) {
82 if (e.getCause() instanceof AccessException) {
83 System.err.println(
84 "test3 passed: binding ActivationSystem " +
85 "failed as expected");
86 } else {
87 throw new RuntimeException(
88 "test3 FAILED: incorrect cause: " + e.getCause());
89 }
90
91 }
92
93 try {
94 rmidRegistry.rebind(NAME, new LookupActivationSystem());
95 throw new RuntimeException("test4 FAILED: rebind succeeded!");
96 } catch (ServerException e) {
97 if (e.getCause() instanceof AccessException) {
98 System.err.println(
99 "test4 passed: rebinding ActivationSystem " +
100 "failed as expected");
101 } else {
102 throw new RuntimeException(
103 "test4 FAILED: incorrect cause: " + e.getCause());
104 }
105 }
106
107 try {
108 rmidRegistry.unbind(NAME);
109 throw new RuntimeException("test4 FAILED: unbind succeeded!");
110 } catch (ServerException e) {
111 if (e.getCause() instanceof AccessException) {
112 System.err.println(
113 "test5 passed: unbinding ActivationSystem " +
114 "failed as expected");
115 } else {
116 throw new RuntimeException(
117 "test5 FAILED: incorrect cause: " + e.getCause());
118 }
119 }
120
121
122 } finally {
123 ActivationLibrary.rmidCleanup(rmid);
124 }
125 }
126}