1 // Tags: JDK1.4 |
|
2 |
|
3 // Copyright (c) Object Oriented Concepts, Inc. Billerica, MA, USA |
|
4 |
|
5 // Adapted for Mauve by Audrius Meskauskas <audriusa@bluewin.ch> |
|
6 |
|
7 // This file is part of Mauve. |
|
8 |
|
9 // Mauve is free software; you can redistribute it and/or modify |
|
10 // it under the terms of the GNU General Public License as published by |
|
11 // the Free Software Foundation; either version 2, or (at your option) |
|
12 // any later version. |
|
13 |
|
14 // Mauve is distributed in the hope that it will be useful, |
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 // GNU General Public License for more details. |
|
18 |
|
19 // You should have received a copy of the GNU General Public License |
|
20 // along with Mauve; see the file COPYING. If not, write to |
|
21 // the Free Software Foundation, 59 Temple Place - Suite 330, |
|
22 // Boston, MA 02111-1307, USA. |
|
23 |
|
24 /* |
|
25 This code originally came from the OMG's CORBA Open Source Testing project, |
|
26 which lived at cost.omg.org. That site no longer exists. |
|
27 |
|
28 All the contributing companies agreed to release their tests under the |
|
29 terms of the GNU Lesser General Public License, available in the file |
|
30 COPYING.LIB. |
|
31 |
|
32 The code has been modified integrating into Mauve test environment and |
|
33 removing tests that are not yet supported by Suns jre 1.4. Hence the license |
|
34 is now GPL. |
|
35 |
|
36 We downloaded the code from http://sourceforge.net/projects/corba-cost/, |
|
37 administrated by Duncan Grisby. |
|
38 */ |
|
39 |
|
40 |
|
41 // ********************************************************************** |
|
42 // |
|
43 // Copyright (c) 2000 |
|
44 // Object Oriented Concepts, Inc. |
|
45 // Billerica, MA, USA |
|
46 // |
|
47 // All Rights Reserved |
|
48 // |
|
49 // ********************************************************************** |
|
50 |
|
51 |
|
52 package gnu.testlet.org.omg.PortableServer.POA; |
|
53 |
|
54 import gnu.testlet.TestHarness; |
|
55 import gnu.testlet.Testlet; |
|
56 |
|
57 import org.omg.CORBA.ORB; |
|
58 import org.omg.CORBA.Policy; |
|
59 import org.omg.PortableServer.POA; |
|
60 import org.omg.PortableServer.POAManager; |
|
61 import org.omg.PortableServer.POAPackage.AdapterAlreadyExists; |
|
62 import org.omg.PortableServer.POAPackage.AdapterNonExistent; |
|
63 import org.omg.PortableServer.POAPackage.InvalidPolicy; |
|
64 |
|
65 public final class TestFind |
|
66 extends TestBase |
|
67 implements Testlet |
|
68 { |
|
69 void run(ORB orb, POA root) |
|
70 { |
|
71 org.omg.CORBA.Object obj; |
|
72 Policy[] policies = new Policy[ 0 ]; |
|
73 POA poa; |
|
74 POA parent; |
|
75 POA poa2; |
|
76 POA poa3; |
|
77 POAManager mgr; |
|
78 String str; |
|
79 |
|
80 POAManager rootMgr = root.the_POAManager(); |
|
81 TEST(rootMgr != null); |
|
82 |
|
83 // |
|
84 // Create child POA |
|
85 // |
|
86 try |
|
87 { |
|
88 poa = root.create_POA("poa1", rootMgr, policies); |
|
89 } |
|
90 catch (InvalidPolicy ex) |
|
91 { |
|
92 fail(ex); |
|
93 throw new RuntimeException(ex); |
|
94 } |
|
95 catch (AdapterAlreadyExists ex) |
|
96 { |
|
97 fail(ex); |
|
98 throw new RuntimeException(ex); |
|
99 } |
|
100 |
|
101 // |
|
102 // Test: find_POA |
|
103 // |
|
104 try |
|
105 { |
|
106 poa2 = root.find_POA("poa1", false); |
|
107 } |
|
108 catch (AdapterNonExistent ex) |
|
109 { |
|
110 fail(ex); |
|
111 throw new RuntimeException(ex); |
|
112 } |
|
113 TEST(poa2 != null); |
|
114 TEST(poa2._is_equivalent(poa)); |
|
115 |
|
116 // |
|
117 // Test: AdapterNonExistent exception |
|
118 // |
|
119 try |
|
120 { |
|
121 poa2 = root.find_POA("poaX", false); |
|
122 TEST(false); // find_POA should not have succeeded |
|
123 } |
|
124 catch (AdapterNonExistent ex) |
|
125 { |
|
126 // expected |
|
127 } |
|
128 |
|
129 // |
|
130 // Create child POA |
|
131 // |
|
132 try |
|
133 { |
|
134 poa2 = root.create_POA("poa2", rootMgr, policies); |
|
135 } |
|
136 catch (InvalidPolicy ex) |
|
137 { |
|
138 fail(ex); |
|
139 throw new RuntimeException(ex); |
|
140 } |
|
141 catch (AdapterAlreadyExists ex) |
|
142 { |
|
143 fail(ex); |
|
144 throw new RuntimeException(ex); |
|
145 } |
|
146 |
|
147 // |
|
148 // Test: Confirm parent knows about child |
|
149 // |
|
150 try |
|
151 { |
|
152 poa3 = root.find_POA("poa2", false); |
|
153 } |
|
154 catch (AdapterNonExistent ex) |
|
155 { |
|
156 fail(ex); |
|
157 throw new RuntimeException(ex); |
|
158 } |
|
159 |
|
160 TEST(poa3 != null); |
|
161 TEST(poa3._is_equivalent(poa2)); |
|
162 } |
|
163 |
|
164 public void testIt() |
|
165 { |
|
166 java.util.Properties props = System.getProperties(); |
|
167 |
|
168 int status = 0; |
|
169 ORB orb = null; |
|
170 |
|
171 // |
|
172 // Create ORB |
|
173 // |
|
174 orb = ORB.init(new String[ 0 ], props); |
|
175 |
|
176 POA root = TestUtil.GetRootPOA(orb); |
|
177 |
|
178 // |
|
179 // Run the test |
|
180 // |
|
181 run(orb, root); |
|
182 |
|
183 if (orb != null) |
|
184 orb.destroy(); |
|
185 } |
|
186 |
|
187 public void test(TestHarness a_harness) |
|
188 { |
|
189 harness = a_harness; |
|
190 testIt(); |
|
191 } |
|
192 } |
|