1
1
// **********************************************************************
3
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
8
8
// **********************************************************************
10
package test.Ice.servantLocator;
12
import java.io.PrintWriter;
14
import test.Ice.servantLocator.Test.TestImpossibleException;
15
import test.Ice.servantLocator.Test.TestIntfUserException;
16
import test.Ice.servantLocator.Test.TestIntfPrx;
17
import test.Ice.servantLocator.Test.TestIntfPrxHelper;
18
import test.Ice.servantLocator.Test.TestActivationPrx;
19
import test.Ice.servantLocator.Test.TestActivationPrxHelper;
21
import Ice.ObjectNotExistException;
23
import Ice.UnknownException;
24
import Ice.UnknownLocalException;
25
import Ice.UnknownUserException;
13
27
public class AllTests
180
194
public static TestIntfPrx
181
allTests(Ice.Communicator communicator, boolean collocated)
195
allTests(Ice.Communicator communicator, boolean collocated, PrintWriter out)
183
System.out.print("testing stringToProxy... ");
185
String ref = "asm:default -p 12010 -t 10000";
197
out.print("testing stringToProxy... ");
199
String ref = "asm:default -p 12010";
186
200
Ice.ObjectPrx base = communicator.stringToProxy(ref);
187
201
test(base != null);
188
System.out.println("ok");
190
System.out.print("testing checked cast... ");
204
out.print("testing checked cast... ");
192
206
TestIntfPrx obj = TestIntfPrxHelper.checkedCast(base);
193
207
test(obj != null);
194
208
test(obj.equals(base));
195
System.out.println("ok");
197
System.out.print("testing ice_ids... ");
201
ObjectPrx o = communicator.stringToProxy("category/locate:default -p 12010 -t 10000");
205
catch(UnknownUserException ex)
207
test(ex.unknown.equals("Test::TestIntfUserException"));
216
ObjectPrx o = communicator.stringToProxy("category/finished:default -p 12010 -t 10000");
220
catch(UnknownUserException ex)
222
test(ex.unknown.equals("Test::TestIntfUserException"));
228
System.out.println("ok");
230
System.out.print("testing servant locator... ");
232
base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000");
233
obj = TestIntfPrxHelper.checkedCast(base);
236
TestIntfPrxHelper.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010 -t 10000"));
238
catch(ObjectNotExistException ex)
241
System.out.println("ok");
243
System.out.print("testing default servant locator... ");
245
base = communicator.stringToProxy("anothercat/locate:default -p 12010 -t 10000");
246
obj = TestIntfPrxHelper.checkedCast(base);
247
base = communicator.stringToProxy("locate:default -p 12010 -t 10000");
248
obj = TestIntfPrxHelper.checkedCast(base);
251
TestIntfPrxHelper.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010 -t 10000"));
253
catch(ObjectNotExistException ex)
258
TestIntfPrxHelper.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000"));
260
catch(ObjectNotExistException ex)
263
System.out.println("ok");
265
System.out.print("testing locate exceptions... ");
267
base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000");
268
obj = TestIntfPrxHelper.checkedCast(base);
269
testExceptions(obj, collocated);
270
System.out.println("ok");
272
System.out.print("testing finished exceptions... ");
274
base = communicator.stringToProxy("category/finished:default -p 12010 -t 10000");
275
obj = TestIntfPrxHelper.checkedCast(base);
276
testExceptions(obj, collocated);
277
System.out.println("ok");
211
out.print("testing ice_ids... ");
215
ObjectPrx o = communicator.stringToProxy("category/locate:default -p 12010");
219
catch(UnknownUserException ex)
221
test(ex.unknown.equals("Test::TestIntfUserException"));
230
ObjectPrx o = communicator.stringToProxy("category/finished:default -p 12010");
234
catch(UnknownUserException ex)
236
test(ex.unknown.equals("Test::TestIntfUserException"));
244
out.print("testing servant locator... ");
246
base = communicator.stringToProxy("category/locate:default -p 12010");
247
obj = TestIntfPrxHelper.checkedCast(base);
250
TestIntfPrxHelper.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010"));
252
catch(ObjectNotExistException ex)
257
out.print("testing default servant locator... ");
259
base = communicator.stringToProxy("anothercat/locate:default -p 12010");
260
obj = TestIntfPrxHelper.checkedCast(base);
261
base = communicator.stringToProxy("locate:default -p 12010");
262
obj = TestIntfPrxHelper.checkedCast(base);
265
TestIntfPrxHelper.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010"));
267
catch(ObjectNotExistException ex)
272
TestIntfPrxHelper.checkedCast(communicator.stringToProxy("unknown:default -p 12010"));
274
catch(ObjectNotExistException ex)
279
out.print("testing locate exceptions... ");
281
base = communicator.stringToProxy("category/locate:default -p 12010");
282
obj = TestIntfPrxHelper.checkedCast(base);
283
testExceptions(obj, collocated);
286
out.print("testing finished exceptions... ");
288
base = communicator.stringToProxy("category/finished:default -p 12010");
289
obj = TestIntfPrxHelper.checkedCast(base);
290
testExceptions(obj, collocated);
293
// Only call these for category/finished.
299
catch(TestIntfUserException ex)
303
catch(TestImpossibleException ex)
306
// Called by finished().
311
// Only call these for category/finished.
315
obj.asyncException();
317
catch(TestIntfUserException ex)
321
catch(TestImpossibleException ex)
324
// Called by finished().
330
out.print("testing servant locator removal... ");
332
base = communicator.stringToProxy("test/activation:default -p 12010");
333
TestActivationPrx activation = TestActivationPrxHelper.checkedCast(base);
334
activation.activateServantLocator(false);
340
catch(ObjectNotExistException ex)
344
out.print("testing servant locator addition... ");
346
activation.activateServantLocator(true);