1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2013 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)
|