summaryrefslogtreecommitdiff
path: root/py/test/Ice/ami/TestI.py
blob: d97de26e2357278631255bff0071305722c0cabc (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
# **********************************************************************
#
# Copyright (c) 2003-2009 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 Ice, Test, threading

class TestIntfI(Test.TestIntf):
    def __init__(self):
        self._cond = threading.Condition()
        self._batchCount = 0

    def op(self, current=None):
        pass

    def opWithResult(self, current=None):
        return 15

    def opWithUE(self, current=None):
        raise Test.TestIntfException()

    def opWithPayload(self, bytes, current=None):
        pass

    def opBatch(self, current=None):
        self._cond.acquire()
        try:
            self._batchCount += 1
            self._cond.notify()
        finally:
            self._cond.release()

    def opBatchCount(self, current=None):
        self._cond.acquire()
        try:
            return self._batchCount
        finally:
            self._cond.release()

    def waitForBatch(self, count, current=None):
        self._cond.acquire()
        try:
            while self._batchCount < count:
                self._cond.wait(5)
            result = count == self._batchCount
            self._batchCount = 0
            return result
        finally:
            self._cond.release()

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

class TestIntfControllerI(Test.TestIntfController):
    def __init__(self, adapter):
        self._adapter = adapter

    def holdAdapter(self, current=None):
        self._adapter.hold()

    def resumeAdapter(self, current=None):
        self._adapter.activate()