diff options
author | Matthew Newhook <matthew@zeroc.com> | 2007-09-20 14:56:29 +0800 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2007-09-20 14:56:29 +0800 |
commit | 1122cb76c9d14c00e892d76ba088e33da3b81d11 (patch) | |
tree | d753f950b1dda0f6a48a431f13f21c22cb12727f /py/test/Ice/blobject/Client.py | |
parent | http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=2478 (diff) | |
download | ice-1122cb76c9d14c00e892d76ba088e33da3b81d11.tar.bz2 ice-1122cb76c9d14c00e892d76ba088e33da3b81d11.tar.xz ice-1122cb76c9d14c00e892d76ba088e33da3b81d11.zip |
added blobject support to python.
Diffstat (limited to 'py/test/Ice/blobject/Client.py')
-rw-r--r-- | py/test/Ice/blobject/Client.py | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/py/test/Ice/blobject/Client.py b/py/test/Ice/blobject/Client.py new file mode 100644 index 00000000000..f646f65514a --- /dev/null +++ b/py/test/Ice/blobject/Client.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys, traceback + +for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "python", "Ice.py")): + break +else: + raise "can't find toplevel directory!" + +sys.path.insert(0, os.path.join(toplevel, "python")) +sys.path.insert(0, os.path.join(toplevel, "lib")) + +import Ice +Ice.loadSlice('Test.ice') +import Test +import RouterI + +def test(b): + if not b: + raise RuntimeError('test assertion failed') + +def run(args, communicator, sync): + hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("test:default -p 12010 -t 10000")) + hello.sayHello(False) + hello.sayHello(False, { "_fwd":"o" } ) + test(hello.add(10, 20) == 30) + try: + hello.raiseUE() + test(False) + except Test.UE: + pass + + try: + Test.HelloPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000")) + test(False) + except Ice.ObjectNotExistException: + pass + + # First try an object at a non-existent endpoint. + try: + Test.HelloPrx.checkedCast(communicator.stringToProxy("missing:default -p 12000 -t 10000")) + test(False) + except Ice.UnknownLocalException, e: + test(e.unknown.find('ConnectionRefusedException')) + if sync: + hello.shutdown() + return True + +try: + initData = Ice.InitializationData() + initData.properties = Ice.createProperties(sys.argv) + initData.properties.setProperty('Ice.Warn.Dispatch', '0') + communicator = Ice.initialize(sys.argv, initData) + router = RouterI.RouterI(communicator, False) + print "testing async blobject... ", + sys.stdout.flush() + status = run(sys.argv, communicator, False) + print "ok" + router.destroy() +except: + traceback.print_exc() + status = False + +if communicator: + try: + communicator.destroy() + except: + traceback.print_exc() + status = False + +if status: + try: + initData = Ice.InitializationData() + initData.properties = Ice.createProperties(sys.argv) + initData.properties.setProperty('Ice.Warn.Dispatch', '0') + communicator = Ice.initialize(sys.argv, initData) + router = RouterI.RouterI(communicator, True) + print "testing sync blobject... ", + sys.stdout.flush() + status = run(sys.argv, communicator, True) + print "ok" + router.destroy() + except: + traceback.print_exc() + status = False + + if communicator: + try: + communicator.destroy() + except: + traceback.print_exc() + status = False + +sys.exit(not status) |