1#!/usr/bin/env python
2#
3# Copyright (c) ZeroC, Inc. All rights reserved.
4#
5
6from TestHelper import TestHelper
7TestHelper.loadSlice("Test.ice")
8import Ice
9import Test
10
11
12class InitialI(Test.Initial):
13
14    def shutdown(self, current=None):
15        current.adapter.getCommunicator().shutdown()
16
17    def pingPong(self, o, current=None):
18        return Ice.Future.completed(o)
19
20    def opOptionalException(self, a, b, o, current=None):
21        f = Ice.Future()
22        f.set_exception(Test.OptionalException(False, a, b, o))
23        return f
24
25    def opDerivedException(self, a, b, o, current=None):
26        f = Ice.Future()
27        f.set_exception(Test.DerivedException(False, a, b, o, b, o))
28        return f
29
30    def opRequiredException(self, a, b, o, current=None):
31        e = Test.RequiredException()
32        e.a = a
33        e.b = b
34        e.o = o
35        if b is not Ice.Unset:
36            e.ss = b
37        if o is not Ice.Unset:
38            e.o2 = o
39        f = Ice.Future()
40        f.set_exception(e)
41        return f
42
43    def opByte(self, p1, current=None):
44        return Ice.Future.completed((p1, p1))
45
46    def opBool(self, p1, current=None):
47        return Ice.Future.completed((p1, p1))
48
49    def opShort(self, p1, current=None):
50        return Ice.Future.completed((p1, p1))
51
52    def opInt(self, p1, current=None):
53        return Ice.Future.completed((p1, p1))
54
55    def opLong(self, p1, current=None):
56        return Ice.Future.completed((p1, p1))
57
58    def opFloat(self, p1, current=None):
59        return Ice.Future.completed((p1, p1))
60
61    def opDouble(self, p1, current=None):
62        return Ice.Future.completed((p1, p1))
63
64    def opString(self, p1, current=None):
65        return Ice.Future.completed((p1, p1))
66
67    def opMyEnum(self, p1, current=None):
68        return Ice.Future.completed((p1, p1))
69
70    def opSmallStruct(self, p1, current=None):
71        return Ice.Future.completed((p1, p1))
72
73    def opFixedStruct(self, p1, current=None):
74        return Ice.Future.completed((p1, p1))
75
76    def opVarStruct(self, p1, current=None):
77        return Ice.Future.completed((p1, p1))
78
79    def opOneOptional(self, p1, current=None):
80        return Ice.Future.completed((p1, p1))
81
82    def opOneOptionalProxy(self, p1, current=None):
83        return Ice.Future.completed((p1, p1))
84
85    def opByteSeq(self, p1, current=None):
86        return Ice.Future.completed((p1, p1))
87
88    def opBoolSeq(self, p1, current=None):
89        return Ice.Future.completed((p1, p1))
90
91    def opShortSeq(self, p1, current=None):
92        return Ice.Future.completed((p1, p1))
93
94    def opIntSeq(self, p1, current=None):
95        return Ice.Future.completed((p1, p1))
96
97    def opLongSeq(self, p1, current=None):
98        return Ice.Future.completed((p1, p1))
99
100    def opFloatSeq(self, p1, current=None):
101        return Ice.Future.completed((p1, p1))
102
103    def opDoubleSeq(self, p1, current=None):
104        return Ice.Future.completed((p1, p1))
105
106    def opStringSeq(self, p1, current=None):
107        return Ice.Future.completed((p1, p1))
108
109    def opSmallStructSeq(self, p1, current=None):
110        return Ice.Future.completed((p1, p1))
111
112    def opSmallStructList(self, p1, current=None):
113        return Ice.Future.completed((p1, p1))
114
115    def opFixedStructSeq(self, p1, current=None):
116        return Ice.Future.completed((p1, p1))
117
118    def opFixedStructList(self, p1, current=None):
119        return Ice.Future.completed((p1, p1))
120
121    def opVarStructSeq(self, p1, current=None):
122        return Ice.Future.completed((p1, p1))
123
124    def opSerializable(self, p1, current=None):
125        return Ice.Future.completed((p1, p1))
126
127    def opIntIntDict(self, p1, current=None):
128        return Ice.Future.completed((p1, p1))
129
130    def opStringIntDict(self, p1, current=None):
131        return Ice.Future.completed((p1, p1))
132
133    def opIntOneOptionalDict(self, p1, current=None):
134        return Ice.Future.completed((p1, p1))
135
136    def opClassAndUnknownOptional(self, p, current=None):
137        return Ice.Future.completed(None)
138
139    def sendOptionalClass(self, req, o, current=None):
140        return Ice.Future.completed(None)
141
142    def returnOptionalClass(self, req, current=None):
143        return Ice.Future.completed(Test.OneOptional(53))
144
145    def opG(self, g, current=None):
146        return Ice.Future.completed(g)
147
148    def opVoid(self, current=None):
149        return Ice.Future.completed(None)
150
151    def opMStruct1(self, current):
152        return Ice.Future.completed(Test.Initial.OpMStruct1MarshaledResult(Test.SmallStruct(), current))
153
154    def opMStruct2(self, p1, current):
155        return Ice.Future.completed(Test.Initial.OpMStruct2MarshaledResult((p1, p1), current))
156
157    def opMSeq1(self, current):
158        return Ice.Future.completed(Test.Initial.OpMSeq1MarshaledResult([], current))
159
160    def opMSeq2(self, p1, current):
161        return Ice.Future.completed(Test.Initial.OpMSeq2MarshaledResult((p1, p1), current))
162
163    def opMDict1(self, current):
164        return Ice.Future.completed(Test.Initial.OpMDict1MarshaledResult({}, current))
165
166    def opMDict2(self, p1, current):
167        return Ice.Future.completed(Test.Initial.OpMDict2MarshaledResult((p1, p1), current))
168
169    def opMG1(self, current):
170        return Ice.Future.completed(Test.Initial.OpMG1MarshaledResult(Test.G(), current))
171
172    def opMG2(self, p1, current):
173        return Ice.Future.completed(Test.Initial.OpMG2MarshaledResult((p1, p1), current))
174
175    def supportsRequiredParams(self, current=None):
176        return Ice.Future.completed(False)
177
178    def supportsJavaSerializable(self, current=None):
179        return Ice.Future.completed(True)
180
181    def supportsCsharpSerializable(self, current=None):
182        return Ice.Future.completed(False)
183
184    def supportsCppStringView(self, current=None):
185        return Ice.Future.completed(False)
186
187    def supportsNullOptional(self, current=None):
188        return Ice.Future.completed(True)
189
190
191class ServerAMD(TestHelper):
192
193    def run(self, args):
194        with self.initialize(args=args) as communicator:
195            communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint())
196            adapter = communicator.createObjectAdapter("TestAdapter")
197            initial = InitialI()
198            adapter.add(initial, Ice.stringToIdentity("initial"))
199            adapter.activate()
200
201            communicator.waitForShutdown()
202