summaryrefslogtreecommitdiff
path: root/python/test/Ice/timeout/Server.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/test/Ice/timeout/Server.py')
-rwxr-xr-xpython/test/Ice/timeout/Server.py85
1 files changed, 38 insertions, 47 deletions
diff --git a/python/test/Ice/timeout/Server.py b/python/test/Ice/timeout/Server.py
index 872d7cf485b..5f504d19266 100755
--- a/python/test/Ice/timeout/Server.py
+++ b/python/test/Ice/timeout/Server.py
@@ -8,17 +8,14 @@
#
# **********************************************************************
-import os, sys, traceback, time, threading
-
+from TestHelper import TestHelper
+TestHelper.loadSlice("Test.ice")
+import threading
+import time
import Ice
-slice_dir = Ice.getSliceDir()
-if not slice_dir:
- print(sys.argv[0] + ': Slice directory not found.')
- sys.exit(1)
-
-Ice.loadSlice("'-I" + slice_dir + "' Test.ice")
import Test
+
class ActivateAdapterThread(threading.Thread):
def __init__(self, adapter, timeout):
threading.Thread.__init__(self)
@@ -57,42 +54,36 @@ class ControllerI(Test.Controller):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
-def run(args, communicator):
- communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
- communicator.getProperties().setProperty("ControllerAdapter.Endpoints", "default -p 12011");
- communicator.getProperties().setProperty("ControllerAdapter.ThreadPool.Size", "1");
-
- adapter = communicator.createObjectAdapter("TestAdapter")
- adapter.add(TimeoutI(), Ice.stringToIdentity("timeout"))
- adapter.activate()
-
- controllerAdapter = communicator.createObjectAdapter("ControllerAdapter")
- controllerAdapter.add(ControllerI(adapter), Ice.stringToIdentity("controller"))
- controllerAdapter.activate()
-
- communicator.waitForShutdown()
- return True
-
-try:
- initData = Ice.InitializationData()
- initData.properties = Ice.createProperties(sys.argv)
- initData.properties.setProperty("Ice.Warn.Connections", "0");
-
- #
- # The client sends large messages to cause the transport
- # buffers to fill up.
- #
- initData.properties.setProperty("Ice.MessageSizeMax", "10000");
-
- #
- # Limit the recv buffer size, this test relies on the socket
- # send() blocking after sending a given amount of data.
- #
- initData.properties.setProperty("Ice.TCP.RcvSize", "50000");
- with Ice.initialize(sys.argv, initData) as communicator:
- status = run(sys.argv, communicator)
-except:
- traceback.print_exc()
- status = False
-
-sys.exit(not status)
+
+class Server(TestHelper):
+
+ def run(self, args):
+ properties = self.createTestProperties(args)
+ properties.setProperty("Ice.Warn.Connections", "0")
+
+ #
+ # The client sends large messages to cause the transport
+ # buffers to fill up.
+ #
+ properties.setProperty("Ice.MessageSizeMax", "10000")
+
+ #
+ # Limit the recv buffer size, this test relies on the socket
+ # send() blocking after sending a given amount of data.
+ #
+ properties.setProperty("Ice.TCP.RcvSize", "50000")
+
+ with self.initialize(properties=properties) as communicator:
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint())
+ communicator.getProperties().setProperty("ControllerAdapter.Endpoints", self.getTestEndpoint(num=1))
+ communicator.getProperties().setProperty("ControllerAdapter.ThreadPool.Size", "1")
+
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(TimeoutI(), Ice.stringToIdentity("timeout"))
+ adapter.activate()
+
+ controllerAdapter = communicator.createObjectAdapter("ControllerAdapter")
+ controllerAdapter.add(ControllerI(adapter), Ice.stringToIdentity("controller"))
+ controllerAdapter.activate()
+
+ communicator.waitForShutdown()