diff options
author | Matthew Newhook <matthew@zeroc.com> | 2015-03-21 15:35:40 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2015-03-21 15:35:40 -0230 |
commit | 630a37d2fe66f24518299e705f958b571803c522 (patch) | |
tree | 969723791bdc4d73bb099c19d45554d0ca241ad9 /python/test/Ice/custom/Server.py | |
parent | Fix some README.md markdown formatting (diff) | |
download | ice-630a37d2fe66f24518299e705f958b571803c522.tar.bz2 ice-630a37d2fe66f24518299e705f958b571803c522.tar.xz ice-630a37d2fe66f24518299e705f958b571803c522.zip |
py -> python
rb -> ruby
objc -> objective-c
cs -> csharp
Diffstat (limited to 'python/test/Ice/custom/Server.py')
-rwxr-xr-x | python/test/Ice/custom/Server.py | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/python/test/Ice/custom/Server.py b/python/test/Ice/custom/Server.py new file mode 100755 index 00000000000..af0f49ebb76 --- /dev/null +++ b/python/test/Ice/custom/Server.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2015 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 + +import Ice +Ice.loadSlice('Test.ice') +import Test + +def test(b): + if not b: + raise RuntimeError('test assertion failed') + +class CustomI(Test.Custom): + def opByteString1(self, b1, current=None): + if sys.version_info[0] == 2: + test(isinstance(b1, str)) + else: + test(isinstance(b1, bytes)) + return (b1, b1) + + def opByteString2(self, b1, current=None): + test(isinstance(b1, list)) + return (b1, b1) + + def opByteList1(self, b1, current=None): + test(isinstance(b1, list)) + return (b1, b1) + + def opByteList2(self, b1, current=None): + test(isinstance(b1, tuple)) + return (b1, b1) + + def opStringList1(self, s1, current=None): + test(isinstance(s1, list)) + return (s1, s1) + + def opStringList2(self, s1, current=None): + test(isinstance(s1, tuple)) + return (s1, s1) + + def opStringTuple1(self, s1, current=None): + test(isinstance(s1, tuple)) + return (s1, s1) + + def opStringTuple2(self, s1, current=None): + test(isinstance(s1, list)) + return (s1, s1) + + def sendS(self, val, current=None): + if sys.version_info[0] == 2: + test(isinstance(val.b1, str)) + else: + test(isinstance(val.b1, bytes)) + test(isinstance(val.b2, list)) + if sys.version_info[0] == 2: + test(isinstance(val.b3, str)) + else: + test(isinstance(val.b3, bytes)) + test(isinstance(val.b4, list)) + test(isinstance(val.s1, list)) + test(isinstance(val.s2, tuple)) + test(isinstance(val.s3, tuple)) + test(isinstance(val.s4, list)) + + def sendC(self, val, current=None): + if sys.version_info[0] == 2: + test(isinstance(val.b1, str)) + else: + test(isinstance(val.b1, bytes)) + test(isinstance(val.b2, list)) + if sys.version_info[0] == 2: + test(isinstance(val.b3, str)) + else: + test(isinstance(val.b3, bytes)) + test(isinstance(val.b4, list)) + test(isinstance(val.s1, list)) + test(isinstance(val.s2, tuple)) + test(isinstance(val.s3, tuple)) + test(isinstance(val.s4, list)) + + def shutdown(self, current=None): + current.adapter.getCommunicator().shutdown() + +def run(args, communicator): + communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010") + adapter = communicator.createObjectAdapter("TestAdapter") + object = CustomI() + adapter.add(object, communicator.stringToIdentity("test")) + adapter.activate() + communicator.waitForShutdown() + return True + +try: + communicator = Ice.initialize(sys.argv) + status = run(sys.argv, communicator) +except: + traceback.print_exc() + status = False + +if communicator: + try: + communicator.destroy() + except: + traceback.print_exc() + status = False + +sys.exit(not status) |