summaryrefslogtreecommitdiff
path: root/python/test/Ice/location/Server.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/test/Ice/location/Server.py')
-rwxr-xr-xpython/test/Ice/location/Server.py94
1 files changed, 43 insertions, 51 deletions
diff --git a/python/test/Ice/location/Server.py b/python/test/Ice/location/Server.py
index 9ae243b45be..52475e42314 100755
--- a/python/test/Ice/location/Server.py
+++ b/python/test/Ice/location/Server.py
@@ -8,17 +8,12 @@
#
# **********************************************************************
-import os, sys, traceback
-
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")
+from TestHelper import TestHelper
+TestHelper.loadSlice("Test.ice")
import Test
+
class ServerLocatorRegistry(Test.TestLocatorRegistry):
def __init__(self):
self._adapters = {}
@@ -56,6 +51,7 @@ class ServerLocatorRegistry(Test.TestLocatorRegistry):
raise Ice.ObjectNotFoundException()
return self._objects[id]
+
class ServerLocator(Test.TestLocator):
def __init__(self, registry, registryPrx):
@@ -77,6 +73,7 @@ class ServerLocator(Test.TestLocator):
def getRequestCount(self, current=None):
return self._requestCount
+
class ServerManagerI(Test.ServerManager):
def __init__(self, registry, initData):
self._registry = registry
@@ -97,7 +94,7 @@ class ServerManagerI(Test.ServerManager):
# its endpoints with the locator and create references containing
# the adapter id instead of the endpoints.
#
- serverCommunicator = Ice.initialize(data=initData)
+ serverCommunicator = Ice.initialize(self._initData)
self._communicators.append(serverCommunicator)
def getTestEndpoint():
@@ -143,10 +140,12 @@ class ServerManagerI(Test.ServerManager):
i.destroy()
current.adapter.getCommunicator().shutdown()
+
class HelloI(Test.Hello):
def sayHello(self, current=None):
pass
+
class TestI(Test.TestIntf):
def __init__(self, adapter, adapter2, registry):
self._adapter1 = adapter
@@ -170,45 +169,38 @@ class TestI(Test.TestIntf):
except Ice.NotRegisteredException:
self._registry.addObject(self._adapter1.add(self._adapter2.remove(id), id))
-def run(args, communicator, initData):
- #
- # Register the server manager. The server manager creates a new
- # 'server' (a server isn't a different process, it's just a new
- # communicator and object adapter).
- #
- properties = communicator.getProperties()
- properties.setProperty("Ice.ThreadPool.Server.Size", "2")
- properties.setProperty("ServerManager.Endpoints", "default -p 12010")
-
- adapter = communicator.createObjectAdapter("ServerManager")
-
- #
- # We also register a sample server locator which implements the
- # locator interface, this locator is used by the clients and the
- # 'servers' created with the server manager interface.
- #
- registry = ServerLocatorRegistry()
- registry.addObject(adapter.createProxy(Ice.stringToIdentity("ServerManager")))
- object = ServerManagerI(registry, initData)
- adapter.add(object, Ice.stringToIdentity("ServerManager"))
-
- registryPrx = Ice.LocatorRegistryPrx.uncheckedCast(adapter.add(registry, Ice.stringToIdentity("registry")))
-
- locator = ServerLocator(registry, registryPrx)
- adapter.add(locator, Ice.stringToIdentity("locator"))
-
- adapter.activate()
- communicator.waitForShutdown()
-
- return True
-
-try:
- initData = Ice.InitializationData()
- initData.properties = Ice.createProperties(sys.argv)
- with Ice.initialize(sys.argv, initData) as communicator:
- status = run(sys.argv, communicator, initData)
-except:
- traceback.print_exc()
- status = False
-
-sys.exit(not status)
+
+class Server(TestHelper):
+
+ def run(self, args):
+
+ initData = Ice.InitializationData()
+ initData.properties = self.createTestProperties(args)
+
+ with self.initialize(initData=initData) as communicator:
+ #
+ # Register the server manager. The server manager creates a new
+ # 'server' (a server isn't a different process, it's just a new
+ # communicator and object adapter).
+ #
+ communicator.getProperties().setProperty("Ice.ThreadPool.Server.Size", "2")
+ communicator.getProperties().setProperty("ServerManager.Endpoints", self.getTestEndpoint())
+
+ adapter = communicator.createObjectAdapter("ServerManager")
+
+ #
+ # We also register a sample server locator which implements the
+ # locator interface, this locator is used by the clients and the
+ # 'servers' created with the server manager interface.
+ #
+ registry = ServerLocatorRegistry()
+ registry.addObject(adapter.createProxy(Ice.stringToIdentity("ServerManager")))
+ adapter.add(ServerManagerI(registry, initData), Ice.stringToIdentity("ServerManager"))
+
+ registryPrx = Ice.LocatorRegistryPrx.uncheckedCast(adapter.add(registry, Ice.stringToIdentity("registry")))
+
+ locator = ServerLocator(registry, registryPrx)
+ adapter.add(locator, Ice.stringToIdentity("locator"))
+
+ adapter.activate()
+ communicator.waitForShutdown()