~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to java/test/Ice/servantLocator/AllTests.java

  • Committer: Bazaar Package Importer
  • Author(s): Cleto Martin Angelina
  • Date: 2011-04-25 18:44:24 UTC
  • mfrom: (6.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110425184424-sep9i9euu434vq4c
Tags: 3.4.1-7
* Bug fix: "libdb5.1-java.jar was renamed to db.jar", thanks to Ondřej
  Surý (Closes: #623555).
* Bug fix: "causes noise in php5", thanks to Jayen Ashar (Closes:
  #623533).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
4
4
//
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.
7
7
//
8
8
// **********************************************************************
9
9
 
10
 
import Test.*;
11
 
import Ice.*;
 
10
package test.Ice.servantLocator;
 
11
 
 
12
import java.io.PrintWriter;
 
13
 
 
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;
 
20
 
 
21
import Ice.ObjectNotExistException;
 
22
import Ice.ObjectPrx;
 
23
import Ice.UnknownException;
 
24
import Ice.UnknownLocalException;
 
25
import Ice.UnknownUserException;
12
26
 
13
27
public class AllTests
14
28
{
178
192
    }
179
193
 
180
194
    public static TestIntfPrx
181
 
    allTests(Ice.Communicator communicator, boolean collocated)
 
195
    allTests(Ice.Communicator communicator, boolean collocated, PrintWriter out)
182
196
    {
183
 
        System.out.print("testing stringToProxy... ");
184
 
        System.out.flush();
185
 
        String ref = "asm:default -p 12010 -t 10000";
 
197
                out.print("testing stringToProxy... ");
 
198
        out.flush();
 
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");
 
202
        out.println("ok");
189
203
 
190
 
        System.out.print("testing checked cast... ");
191
 
        System.out.flush();
 
204
        out.print("testing checked cast... ");
 
205
        out.flush();
192
206
        TestIntfPrx obj = TestIntfPrxHelper.checkedCast(base);
193
207
        test(obj != null);
194
208
        test(obj.equals(base));
195
 
        System.out.println("ok");
196
 
 
197
 
        System.out.print("testing ice_ids... ");
198
 
        System.out.flush();
199
 
        try
200
 
        {
201
 
            ObjectPrx o = communicator.stringToProxy("category/locate:default -p 12010 -t 10000");
202
 
            o.ice_ids();
203
 
            test(false);
204
 
        }
205
 
        catch(UnknownUserException ex)
206
 
        {
207
 
            test(ex.unknown.equals("Test::TestIntfUserException"));
208
 
        }
209
 
        catch(Throwable ex)
210
 
        {
211
 
            test(false);
212
 
        }
213
 
 
214
 
        try
215
 
        {
216
 
            ObjectPrx o = communicator.stringToProxy("category/finished:default -p 12010 -t 10000");
217
 
            o.ice_ids();
218
 
            test(false);
219
 
        }
220
 
        catch(UnknownUserException ex)
221
 
        {
222
 
            test(ex.unknown.equals("Test::TestIntfUserException"));
223
 
        }
224
 
        catch(Throwable ex)
225
 
        {
226
 
            test(false);
227
 
        }
228
 
        System.out.println("ok");
229
 
 
230
 
        System.out.print("testing servant locator... ");
231
 
        System.out.flush();
232
 
        base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000");
233
 
        obj = TestIntfPrxHelper.checkedCast(base);
234
 
        try
235
 
        {
236
 
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010 -t 10000"));
237
 
        }
238
 
        catch(ObjectNotExistException ex)
239
 
        {
240
 
        }
241
 
        System.out.println("ok");
242
 
 
243
 
        System.out.print("testing default servant locator... ");
244
 
        System.out.flush();
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);
249
 
        try
250
 
        {
251
 
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010 -t 10000"));
252
 
        }
253
 
        catch(ObjectNotExistException ex)
254
 
        {
255
 
        }
256
 
        try
257
 
        {
258
 
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000"));
259
 
        }
260
 
        catch(ObjectNotExistException ex)
261
 
        {
262
 
        }
263
 
        System.out.println("ok");
264
 
 
265
 
        System.out.print("testing locate exceptions... ");
266
 
        System.out.flush();
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");
271
 
 
272
 
        System.out.print("testing finished exceptions... ");
273
 
        System.out.flush();
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");
 
209
        out.println("ok");
 
210
 
 
211
        out.print("testing ice_ids... ");
 
212
        out.flush();
 
213
        try
 
214
        {
 
215
            ObjectPrx o = communicator.stringToProxy("category/locate:default -p 12010");
 
216
            o.ice_ids();
 
217
            test(false);
 
218
        }
 
219
        catch(UnknownUserException ex)
 
220
        {
 
221
            test(ex.unknown.equals("Test::TestIntfUserException"));
 
222
        }
 
223
        catch(Throwable ex)
 
224
        {
 
225
            test(false);
 
226
        }
 
227
 
 
228
        try
 
229
        {
 
230
            ObjectPrx o = communicator.stringToProxy("category/finished:default -p 12010");
 
231
            o.ice_ids();
 
232
            test(false);
 
233
        }
 
234
        catch(UnknownUserException ex)
 
235
        {
 
236
            test(ex.unknown.equals("Test::TestIntfUserException"));
 
237
        }
 
238
        catch(Throwable ex)
 
239
        {
 
240
            test(false);
 
241
        }
 
242
        out.println("ok");
 
243
 
 
244
        out.print("testing servant locator... ");
 
245
        out.flush();
 
246
        base = communicator.stringToProxy("category/locate:default -p 12010");
 
247
        obj = TestIntfPrxHelper.checkedCast(base);
 
248
        try
 
249
        {
 
250
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010"));
 
251
        }
 
252
        catch(ObjectNotExistException ex)
 
253
        {
 
254
        }
 
255
        out.println("ok");
 
256
 
 
257
        out.print("testing default servant locator... ");
 
258
        out.flush();
 
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);
 
263
        try
 
264
        {
 
265
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010"));
 
266
        }
 
267
        catch(ObjectNotExistException ex)
 
268
        {
 
269
        }
 
270
        try
 
271
        {
 
272
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("unknown:default -p 12010"));
 
273
        }
 
274
        catch(ObjectNotExistException ex)
 
275
        {
 
276
        }
 
277
        out.println("ok");
 
278
 
 
279
        out.print("testing locate exceptions... ");
 
280
        out.flush();
 
281
        base = communicator.stringToProxy("category/locate:default -p 12010");
 
282
        obj = TestIntfPrxHelper.checkedCast(base);
 
283
        testExceptions(obj, collocated);
 
284
        out.println("ok");
 
285
 
 
286
        out.print("testing finished exceptions... ");
 
287
        out.flush();
 
288
        base = communicator.stringToProxy("category/finished:default -p 12010");
 
289
        obj = TestIntfPrxHelper.checkedCast(base);
 
290
        testExceptions(obj, collocated);
 
291
 
 
292
        //
 
293
        // Only call these for category/finished.
 
294
        //
 
295
        try
 
296
        {
 
297
            obj.asyncResponse();
 
298
        }
 
299
        catch(TestIntfUserException ex)
 
300
        {
 
301
            test(false);
 
302
        }
 
303
        catch(TestImpossibleException ex)
 
304
        {
 
305
            //
 
306
            // Called by finished().
 
307
            //
 
308
        }
 
309
 
 
310
        //
 
311
        // Only call these for category/finished.
 
312
        //
 
313
        try
 
314
        {
 
315
            obj.asyncException();
 
316
        }
 
317
        catch(TestIntfUserException ex)
 
318
        {
 
319
            test(false);
 
320
        }
 
321
        catch(TestImpossibleException ex)
 
322
        {
 
323
            //
 
324
            // Called by finished().
 
325
            //
 
326
        }
 
327
 
 
328
        out.println("ok");
 
329
 
 
330
        out.print("testing servant locator removal... ");
 
331
        out.flush();
 
332
        base = communicator.stringToProxy("test/activation:default -p 12010");
 
333
        TestActivationPrx activation = TestActivationPrxHelper.checkedCast(base);
 
334
        activation.activateServantLocator(false);
 
335
        try
 
336
        {
 
337
            obj.ice_ping();
 
338
            test(false);
 
339
        }
 
340
        catch(ObjectNotExistException ex)
 
341
        {
 
342
            out.println("ok");
 
343
        }
 
344
        out.print("testing servant locator addition... ");
 
345
        out.flush();
 
346
        activation.activateServantLocator(true);
 
347
        try
 
348
        {
 
349
            obj.ice_ping();
 
350
            out.println("ok");
 
351
        }
 
352
        catch(Exception ex)
 
353
        {
 
354
            test(false);
 
355
        }
278
356
 
279
357
        return obj;
280
358
    }