summaryrefslogtreecommitdiff
path: root/python/test/Ice/acm/TestI.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/test/Ice/acm/TestI.py')
-rw-r--r--python/test/Ice/acm/TestI.py74
1 files changed, 27 insertions, 47 deletions
diff --git a/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py
index 21ab6444384..53158e42a28 100644
--- a/python/test/Ice/acm/TestI.py
+++ b/python/test/Ice/acm/TestI.py
@@ -9,7 +9,22 @@
import Ice, Test, threading
-class RemoteCommunicatorI(Test.RemoteCommunicator):
+class ConnectionCallbackI():
+ def __init__(self):
+ self.m = threading.Condition()
+ self.count = 0
+
+ def heartbeat(self, con):
+ with self.m:
+ self.count += 1
+ self.m.notifyAll()
+
+ def waitForCount(self, count):
+ with self.m:
+ while self.count < count:
+ self.m.wait()
+
+class RemoteCommunicatorI(Test._RemoteCommunicatorDisp):
def createObjectAdapter(self, timeout, close, heartbeat, current=None):
com = current.adapter.getCommunicator()
properties = com.getProperties()
@@ -29,11 +44,11 @@ class RemoteCommunicatorI(Test.RemoteCommunicator):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
-class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
+class RemoteObjectAdapterI(Test._RemoteObjectAdapterDisp):
def __init__(self, adapter):
self._adapter = adapter
self._testIntf = Test.TestIntfPrx.uncheckedCast(adapter.add(TestIntfI(),
- adapter.getCommunicator().stringToIdentity("test")))
+ Ice.stringToIdentity("test")))
adapter.activate()
def getTestIntf(self, current=None):
@@ -51,61 +66,26 @@ class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
except Ice.ObjectAdapterDeactivatedException:
pass
-class TestIntfI(Test.TestIntf):
+class TestIntfI(Test._TestIntfDisp):
def __init__(self):
self.m = threading.Condition()
def sleep(self, delay, current=None):
- self.m.acquire()
- try:
+ with self.m:
self.m.wait(delay)
- finally:
- self.m.release()
def sleepAndHold(self, delay, current=None):
- self.m.acquire()
- try:
+ with self.m:
current.adapter.hold()
self.m.wait(delay)
- finally:
- self.m.release()
def interruptSleep(self, delay, current=None):
- self.m.acquire()
- try:
+ with self.m:
self.m.notifyAll()
- finally:
- self.m.release()
-
- def waitForHeartbeat(self, count, current=None):
-
- class ConnectionCallbackI(Ice.ConnectionCallback):
-
- def __init__(self):
- self.m = threading.Condition()
- self.count = 0
-
- def heartbeat(self, con):
- self.m.acquire()
- try:
- self.count -= 1
- self.m.notifyAll()
- finally:
- self.m.release()
-
- def closed(self, con):
- pass
-
- def waitForCount(self, count):
- self.m.acquire()
- self.count = count
- try:
- while self.count > 0:
- self.m.wait()
- finally:
- self.m.release()
- callback = ConnectionCallbackI()
- current.con.setCallback(callback)
- callback.waitForCount(2)
+ def startHeartbeatCount(self, current=None):
+ self.callback = ConnectionCallbackI()
+ current.con.setHeartbeatCallback(lambda con: self.callback.heartbeat(con))
+ def waitForHeartbeatCount(self, count, current=None):
+ self.callback.waitForCount(2)