ICE 3.4.2
[php5-ice-freebsdport.git] / java / test / Ice / inheritance / AllTests.java
blob2bdd9974fd2081d6d96a7872b237e0e3580bcba2
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 package test.Ice.inheritance;
12 import java.io.PrintStream;
13 import java.io.PrintWriter;
15 import test.Ice.inheritance.Test.InitialPrx;
16 import test.Ice.inheritance.Test.InitialPrxHelper;
17 import test.Ice.inheritance.Test.MA.CAPrx;
18 import test.Ice.inheritance.Test.MA.CCPrx;
19 import test.Ice.inheritance.Test.MA.CDPrx;
20 import test.Ice.inheritance.Test.MA.IAPrx;
21 import test.Ice.inheritance.Test.MA.ICPrx;
22 import test.Ice.inheritance.Test.MB.CBPrx;
23 import test.Ice.inheritance.Test.MB.IB1Prx;
24 import test.Ice.inheritance.Test.MB.IB2Prx;
26 public class AllTests
28 private static void
29 test(boolean b)
31 if(!b)
33 throw new RuntimeException();
37 public static InitialPrx
38 allTests(Ice.Communicator communicator, PrintWriter out)
40 out.print("testing stringToProxy... ");
41 out.flush();
42 String ref = "initial:default -p 12010";
43 Ice.ObjectPrx base = communicator.stringToProxy(ref);
44 test(base != null);
45 out.println("ok");
47 out.print("testing checked cast... ");
48 out.flush();
49 InitialPrx initial = InitialPrxHelper.checkedCast(base);
50 test(initial != null);
51 test(initial.equals(base));
52 out.println("ok");
54 out.print("getting proxies for class hierarchy... ");
55 out.flush();
56 CAPrx ca = initial.caop();
57 CBPrx cb = initial.cbop();
58 CCPrx cc = initial.ccop();
59 CDPrx cd = initial.cdop();
60 test(ca != cb);
61 test(ca != cc);
62 test(ca != cd);
63 test(cb != cc);
64 test(cb != cd);
65 test(cc != cd);
66 out.println("ok");
68 out.print("getting proxies for interface hierarchy... ");
69 out.flush();
70 IAPrx ia = initial.iaop();
71 IB1Prx ib1 = initial.ib1op();
72 IB2Prx ib2 = initial.ib2op();
73 ICPrx ic = initial.icop();
74 test(ia != ib1);
75 test(ia != ib2);
76 test(ia != ic);
77 test(ib1 != ic);
78 test(ib2 != ic);
79 out.println("ok");
81 out.print("invoking proxy operations on class hierarchy... ");
82 out.flush();
83 CAPrx cao;
84 CBPrx cbo;
85 CCPrx cco;
87 cao = ca.caop(ca);
88 test(cao.equals(ca));
89 cao = ca.caop(cb);
90 test(cao.equals(cb));
91 cao = ca.caop(cc);
92 test(cao.equals(cc));
93 cao = cb.caop(ca);
94 test(cao.equals(ca));
95 cao = cb.caop(cb);
96 test(cao.equals(cb));
97 cao = cb.caop(cc);
98 test(cao.equals(cc));
99 cao = cc.caop(ca);
100 test(cao.equals(ca));
101 cao = cc.caop(cb);
102 test(cao.equals(cb));
103 cao = cc.caop(cc);
104 test(cao.equals(cc));
106 cao = cb.cbop(cb);
107 test(cao.equals(cb));
108 cbo = cb.cbop(cb);
109 test(cbo.equals(cb));
110 cao = cb.cbop(cc);
111 test(cao.equals(cc));
112 cbo = cb.cbop(cc);
113 test(cbo.equals(cc));
114 cao = cc.cbop(cb);
115 test(cao.equals(cb));
116 cbo = cc.cbop(cb);
117 test(cbo.equals(cb));
118 cao = cc.cbop(cc);
119 test(cao.equals(cc));
120 cbo = cc.cbop(cc);
121 test(cbo.equals(cc));
123 cao = cc.ccop(cc);
124 test(cao.equals(cc));
125 cbo = cc.ccop(cc);
126 test(cbo.equals(cc));
127 cco = cc.ccop(cc);
128 test(cco.equals(cc));
129 out.println("ok");
131 out.print("ditto, but for interface hierarchy... ");
132 out.flush();
133 IAPrx iao;
134 IB1Prx ib1o;
135 IB2Prx ib2o;
136 ICPrx ico;
138 iao = ia.iaop(ia);
139 test(iao.equals(ia));
140 iao = ia.iaop(ib1);
141 test(iao.equals(ib1));
142 iao = ia.iaop(ib2);
143 test(iao.equals(ib2));
144 iao = ia.iaop(ic);
145 test(iao.equals(ic));
146 iao = ib1.iaop(ia);
147 test(iao.equals(ia));
148 iao = ib1.iaop(ib1);
149 test(iao.equals(ib1));
150 iao = ib1.iaop(ib2);
151 test(iao.equals(ib2));
152 iao = ib1.iaop(ic);
153 test(iao.equals(ic));
154 iao = ib2.iaop(ia);
155 test(iao.equals(ia));
156 iao = ib2.iaop(ib1);
157 test(iao.equals(ib1));
158 iao = ib2.iaop(ib2);
159 test(iao.equals(ib2));
160 iao = ib2.iaop(ic);
161 test(iao.equals(ic));
162 iao = ic.iaop(ia);
163 test(iao.equals(ia));
164 iao = ic.iaop(ib1);
165 test(iao.equals(ib1));
166 iao = ic.iaop(ib2);
167 test(iao.equals(ib2));
168 iao = ic.iaop(ic);
169 test(iao.equals(ic));
171 iao = ib1.ib1op(ib1);
172 test(iao.equals(ib1));
173 ib1o = ib1.ib1op(ib1);
174 test(ib1o.equals(ib1));
175 iao = ib1.ib1op(ic);
176 test(iao.equals(ic));
177 ib1o = ib1.ib1op(ic);
178 test(ib1o.equals(ic));
179 iao = ic.ib1op(ib1);
180 test(iao.equals(ib1));
181 ib1o = ic.ib1op(ib1);
182 test(ib1o.equals(ib1));
183 iao = ic.ib1op(ic);
184 test(iao.equals(ic));
185 ib1o = ic.ib1op(ic);
186 test(ib1o.equals(ic));
188 iao = ib2.ib2op(ib2);
189 test(iao.equals(ib2));
190 ib2o = ib2.ib2op(ib2);
191 test(ib2o.equals(ib2));
192 iao = ib2.ib2op(ic);
193 test(iao.equals(ic));
194 ib2o = ib2.ib2op(ic);
195 test(ib2o.equals(ic));
196 iao = ic.ib2op(ib2);
197 test(iao.equals(ib2));
198 ib2o = ic.ib2op(ib2);
199 test(ib2o.equals(ib2));
200 iao = ic.ib2op(ic);
201 test(iao.equals(ic));
202 ib2o = ic.ib2op(ic);
203 test(ib2o.equals(ic));
205 iao = ic.icop(ic);
206 test(iao.equals(ic));
207 ib1o = ic.icop(ic);
208 test(ib1o.equals(ic));
209 ib2o = ic.icop(ic);
210 test(ib2o.equals(ic));
211 ico = ic.icop(ic);
212 test(ico.equals(ic));
213 out.println("ok");
215 out.print("ditto, but for class implementing interfaces... ");
216 out.flush();
217 CDPrx cdo;
219 cao = cd.caop(cd);
220 test(cao.equals(cd));
221 cbo = cd.cbop(cd);
222 test(cbo.equals(cd));
223 cco = cd.ccop(cd);
224 test(cco.equals(cd));
226 iao = cd.iaop(cd);
227 test(iao.equals(cd));
228 ib1o = cd.ib1op(cd);
229 test(ib1o.equals(cd));
230 ib2o = cd.ib2op(cd);
231 test(ib2o.equals(cd));
233 cao = cd.cdop(cd);
234 test(cao.equals(cd));
235 cbo = cd.cdop(cd);
236 test(cbo.equals(cd));
237 cco = cd.cdop(cd);
238 test(cco.equals(cd));
240 iao = cd.cdop(cd);
241 test(iao.equals(cd));
242 ib1o = cd.cdop(cd);
243 test(ib1o.equals(cd));
244 ib2o = cd.cdop(cd);
245 test(ib2o.equals(cd));
246 out.println("ok");
248 return initial;