summaryrefslogtreecommitdiff
path: root/python/test/Ice/scope/Server.py
blob: 895d26cf0bf0b2d35b53953f0de3ffb8ba3e9691 (plain)
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
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2018 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


class I1(Test.I):

    def opS(self, s1, current=None):
        return (s1, s1)

    def opSSeq(self, sseq1, current=None):
        return (sseq1, sseq1)

    def opSMap(self, smap1, current=None):
        return (smap1, smap1)

    def opC(self, c1, current=None):
        return (c1, c1)

    def opCSeq(self, cseq1, current=None):
        return (cseq1, cseq1)

    def opCMap(self, cmap1, current=None):
        return (cmap1, cmap1)

    def shutdown(self, current=None):
        current.adapter.getCommunicator().shutdown()


class I2(Test.Inner.Inner2.I):

    def opS(self, s1, current=None):
        return (s1, s1)

    def opSSeq(self, sseq1, current=None):
        return (sseq1, sseq1)

    def opSMap(self, smap1, current=None):
        return (smap1, smap1)

    def opC(self, c1, current=None):
        return (c1, c1)

    def opCSeq(self, cseq1, current=None):
        return (cseq1, cseq1)

    def opCMap(self, cmap1, current=None):
        return (cmap1, cmap1)

    def shutdown(self, current=None):
        current.adapter.getCommunicator().shutdown()


class I3(Test.Inner.I):

    def opS(self, s1, current=None):
        return (s1, s1)

    def opSSeq(self, sseq1, current=None):
        return (sseq1, sseq1)

    def opSMap(self, smap1, current=None):
        return (smap1, smap1)

    def opC(self, c1, current=None):
        return (c1, c1)

    def opCSeq(self, cseq1, current=None):
        return (cseq1, cseq1)

    def opCMap(self, cmap1, current=None):
        return (cmap1, cmap1)

    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")
    adapter.add(I1(), Ice.stringToIdentity("i1"))
    adapter.add(I2(), Ice.stringToIdentity("i2"))
    adapter.add(I3(), Ice.stringToIdentity("i3"))
    adapter.activate()
    communicator.waitForShutdown()
    return True


try:
    with Ice.initialize(sys.argv) as communicator:
        status = run(sys.argv, communicator)
except:
    traceback.print_exc()
    status = False

sys.exit(not status)