summaryrefslogtreecommitdiff
path: root/python/test
diff options
context:
space:
mode:
Diffstat (limited to 'python/test')
-rw-r--r--python/test/Ice/acm/AllTests.py399
-rwxr-xr-xpython/test/Ice/acm/Client.py48
-rwxr-xr-xpython/test/Ice/acm/Server.py53
-rw-r--r--python/test/Ice/acm/Test.ice37
-rw-r--r--python/test/Ice/acm/TestI.py78
-rwxr-xr-xpython/test/Ice/acm/run.py23
-rw-r--r--python/test/Ice/adapterDeactivation/AllTests.py72
-rwxr-xr-xpython/test/Ice/adapterDeactivation/Client.py23
-rwxr-xr-xpython/test/Ice/adapterDeactivation/Collocated.py32
-rwxr-xr-xpython/test/Ice/adapterDeactivation/Server.py28
-rw-r--r--python/test/Ice/adapterDeactivation/Test.ice27
-rw-r--r--python/test/Ice/adapterDeactivation/TestI.py56
-rwxr-xr-xpython/test/Ice/adapterDeactivation/run.py24
-rw-r--r--python/test/Ice/admin/AllTests.py347
-rw-r--r--python/test/Ice/admin/Client.py44
-rw-r--r--python/test/Ice/admin/Server.py46
-rw-r--r--python/test/Ice/admin/Test.ice45
-rw-r--r--python/test/Ice/admin/TestI.py105
-rwxr-xr-xpython/test/Ice/admin/run.py23
-rw-r--r--python/test/Ice/ami/AllTests.py1090
-rwxr-xr-xpython/test/Ice/ami/Client.py55
-rwxr-xr-xpython/test/Ice/ami/Collocated.py66
-rwxr-xr-xpython/test/Ice/ami/Server.py68
-rw-r--r--python/test/Ice/ami/Test.ice45
-rw-r--r--python/test/Ice/ami/TestI.py72
-rwxr-xr-xpython/test/Ice/ami/run.py26
-rwxr-xr-xpython/test/Ice/application/Client.py58
-rw-r--r--python/test/Ice/binding/AllTests.py651
-rwxr-xr-xpython/test/Ice/binding/Client.py36
-rwxr-xr-xpython/test/Ice/binding/Server.py41
-rw-r--r--python/test/Ice/binding/Test.ice36
-rw-r--r--python/test/Ice/binding/TestI.py42
-rwxr-xr-xpython/test/Ice/binding/run.py23
-rwxr-xr-xpython/test/Ice/blobject/Client.py96
-rw-r--r--python/test/Ice/blobject/RouterI.py172
-rwxr-xr-xpython/test/Ice/blobject/Server.py63
-rw-r--r--python/test/Ice/blobject/Test.ice28
-rwxr-xr-xpython/test/Ice/blobject/run.py23
-rw-r--r--python/test/Ice/checksum/AllTests.py59
-rw-r--r--python/test/Ice/checksum/CTypes.ice634
-rwxr-xr-xpython/test/Ice/checksum/Client.py41
-rw-r--r--python/test/Ice/checksum/STypes.ice631
-rwxr-xr-xpython/test/Ice/checksum/Server.py52
-rw-r--r--python/test/Ice/checksum/Test.ice24
-rwxr-xr-xpython/test/Ice/checksum/run.py23
-rw-r--r--python/test/Ice/custom/AllTests.py118
-rwxr-xr-xpython/test/Ice/custom/Client.py36
-rwxr-xr-xpython/test/Ice/custom/Server.py115
-rw-r--r--python/test/Ice/custom/Test.ice67
-rwxr-xr-xpython/test/Ice/custom/run.py23
-rw-r--r--python/test/Ice/defaultServant/AllTests.py126
-rwxr-xr-xpython/test/Ice/defaultServant/Client.py36
-rw-r--r--python/test/Ice/defaultServant/MyObjectI.py29
-rw-r--r--python/test/Ice/defaultServant/Test.ice20
-rwxr-xr-xpython/test/Ice/defaultServant/run.py29
-rw-r--r--python/test/Ice/defaultValue/AllTests.py184
-rwxr-xr-xpython/test/Ice/defaultValue/Client.py28
-rw-r--r--python/test/Ice/defaultValue/Test.ice208
-rwxr-xr-xpython/test/Ice/defaultValue/run.py29
-rw-r--r--python/test/Ice/enums/AllTests.py128
-rwxr-xr-xpython/test/Ice/enums/Client.py36
-rwxr-xr-xpython/test/Ice/enums/Server.py60
-rw-r--r--python/test/Ice/enums/Test.ice88
-rwxr-xr-xpython/test/Ice/enums/run.py28
-rw-r--r--python/test/Ice/exceptions/AllTests.py721
-rwxr-xr-xpython/test/Ice/exceptions/Client.py45
-rwxr-xr-xpython/test/Ice/exceptions/Collocated.py52
-rwxr-xr-xpython/test/Ice/exceptions/Server.py60
-rwxr-xr-xpython/test/Ice/exceptions/ServerAMD.py180
-rw-r--r--python/test/Ice/exceptions/Test.ice86
-rw-r--r--python/test/Ice/exceptions/TestAMD.ice81
-rw-r--r--python/test/Ice/exceptions/TestI.py108
-rwxr-xr-xpython/test/Ice/exceptions/run.py48
-rw-r--r--python/test/Ice/facets/AllTests.py183
-rwxr-xr-xpython/test/Ice/facets/Client.py37
-rwxr-xr-xpython/test/Ice/facets/Collocated.py48
-rwxr-xr-xpython/test/Ice/facets/Server.py47
-rw-r--r--python/test/Ice/facets/Test.ice60
-rw-r--r--python/test/Ice/facets/TestI.py51
-rwxr-xr-xpython/test/Ice/facets/run.py24
-rw-r--r--python/test/Ice/faultTolerance/AllTests.py175
-rwxr-xr-xpython/test/Ice/faultTolerance/Client.py67
-rwxr-xr-xpython/test/Ice/faultTolerance/Server.py85
-rw-r--r--python/test/Ice/faultTolerance/Test.ice23
-rwxr-xr-xpython/test/Ice/faultTolerance/run.py47
-rw-r--r--python/test/Ice/info/AllTests.py175
-rwxr-xr-xpython/test/Ice/info/Client.py46
-rwxr-xr-xpython/test/Ice/info/Server.py46
-rw-r--r--python/test/Ice/info/Test.ice26
-rw-r--r--python/test/Ice/info/TestI.py69
-rwxr-xr-xpython/test/Ice/info/run.py23
-rw-r--r--python/test/Ice/inheritance/AllTests.py216
-rwxr-xr-xpython/test/Ice/inheritance/Client.py36
-rwxr-xr-xpython/test/Ice/inheritance/Collocated.py42
-rwxr-xr-xpython/test/Ice/inheritance/Server.py40
-rw-r--r--python/test/Ice/inheritance/Test.ice83
-rw-r--r--python/test/Ice/inheritance/TestI.py80
-rwxr-xr-xpython/test/Ice/inheritance/run.py24
-rw-r--r--python/test/Ice/location/AllTests.py256
-rwxr-xr-xpython/test/Ice/location/Client.py47
-rwxr-xr-xpython/test/Ice/location/Server.py199
-rw-r--r--python/test/Ice/location/Test.ice55
-rwxr-xr-xpython/test/Ice/location/run.py23
-rw-r--r--python/test/Ice/objects/AllTests.py226
-rwxr-xr-xpython/test/Ice/objects/Client.py37
-rw-r--r--python/test/Ice/objects/ClientPrivate.ice68
-rwxr-xr-xpython/test/Ice/objects/Collocated.py48
-rwxr-xr-xpython/test/Ice/objects/Server.py62
-rw-r--r--python/test/Ice/objects/ServerPrivate.ice68
-rw-r--r--python/test/Ice/objects/Test.ice131
-rw-r--r--python/test/Ice/objects/TestI.py162
-rwxr-xr-xpython/test/Ice/objects/run.py35
-rw-r--r--python/test/Ice/operations/AllTests.py57
-rw-r--r--python/test/Ice/operations/BatchOneways.py145
-rw-r--r--python/test/Ice/operations/BatchOnewaysAMI.py90
-rwxr-xr-xpython/test/Ice/operations/Client.py65
-rwxr-xr-xpython/test/Ice/operations/Collocated.py54
-rw-r--r--python/test/Ice/operations/Oneways.py46
-rw-r--r--python/test/Ice/operations/OnewaysAMI.py85
-rwxr-xr-xpython/test/Ice/operations/Server.py51
-rwxr-xr-xpython/test/Ice/operations/ServerAMD.py432
-rw-r--r--python/test/Ice/operations/Test.ice272
-rw-r--r--python/test/Ice/operations/TestAMD.ice270
-rw-r--r--python/test/Ice/operations/TestI.py365
-rw-r--r--python/test/Ice/operations/Twoways.py1334
-rw-r--r--python/test/Ice/operations/TwowaysAMI.py1216
-rwxr-xr-xpython/test/Ice/operations/run.py28
-rw-r--r--python/test/Ice/optional/AllTests.py774
-rwxr-xr-xpython/test/Ice/optional/Client.py36
-rw-r--r--python/test/Ice/optional/ClientPrivate.ice37
-rwxr-xr-xpython/test/Ice/optional/Server.py174
-rwxr-xr-xpython/test/Ice/optional/ServerAMD.py175
-rw-r--r--python/test/Ice/optional/Test.ice269
-rw-r--r--python/test/Ice/optional/TestAMD.ice270
-rwxr-xr-xpython/test/Ice/optional/run.py28
-rw-r--r--python/test/Ice/properties/Client.py84
-rw-r--r--python/test/Ice/properties/config/.gitignore1
-rw-r--r--python/test/Ice/properties/config/config.11
-rw-r--r--python/test/Ice/properties/config/config.21
-rw-r--r--python/test/Ice/properties/config/config.31
-rw-r--r--python/test/Ice/properties/config/escapes.cfg35
-rwxr-xr-xpython/test/Ice/properties/run.py43
-rw-r--r--python/test/Ice/proxy/AllTests.py785
-rwxr-xr-xpython/test/Ice/proxy/Client.py48
-rwxr-xr-xpython/test/Ice/proxy/Collocated.py48
-rwxr-xr-xpython/test/Ice/proxy/Server.py46
-rwxr-xr-xpython/test/Ice/proxy/ServerAMD.py65
-rw-r--r--python/test/Ice/proxy/Test.ice29
-rw-r--r--python/test/Ice/proxy/TestAMD.ice29
-rw-r--r--python/test/Ice/proxy/TestI.py28
-rwxr-xr-xpython/test/Ice/proxy/run.py28
-rw-r--r--python/test/Ice/servantLocator/AllTests.py226
-rwxr-xr-xpython/test/Ice/servantLocator/Client.py24
-rwxr-xr-xpython/test/Ice/servantLocator/Collocated.py36
-rwxr-xr-xpython/test/Ice/servantLocator/Server.py33
-rwxr-xr-xpython/test/Ice/servantLocator/ServerAMD.py33
-rw-r--r--python/test/Ice/servantLocator/Test.ice54
-rw-r--r--python/test/Ice/servantLocator/TestAMD.ice54
-rw-r--r--python/test/Ice/servantLocator/TestAMDI.py157
-rw-r--r--python/test/Ice/servantLocator/TestActivationAMDI.py25
-rw-r--r--python/test/Ice/servantLocator/TestActivationI.py25
-rw-r--r--python/test/Ice/servantLocator/TestI.py158
-rwxr-xr-xpython/test/Ice/servantLocator/run.py28
-rw-r--r--python/test/Ice/slicing/exceptions/AllTests.py589
-rwxr-xr-xpython/test/Ice/slicing/exceptions/Client.py34
-rw-r--r--python/test/Ice/slicing/exceptions/ClientPrivate.ice32
-rwxr-xr-xpython/test/Ice/slicing/exceptions/Server.py179
-rwxr-xr-xpython/test/Ice/slicing/exceptions/ServerAMD.py197
-rw-r--r--python/test/Ice/slicing/exceptions/ServerPrivate.ice52
-rw-r--r--python/test/Ice/slicing/exceptions/ServerPrivateAMD.ice37
-rw-r--r--python/test/Ice/slicing/exceptions/Test.ice98
-rw-r--r--python/test/Ice/slicing/exceptions/TestAMD.ice98
-rwxr-xr-xpython/test/Ice/slicing/exceptions/run.py36
-rw-r--r--python/test/Ice/slicing/objects/AllTests.py1833
-rwxr-xr-xpython/test/Ice/slicing/objects/Client.py34
-rw-r--r--python/test/Ice/slicing/objects/ClientPrivate.ice49
-rw-r--r--python/test/Ice/slicing/objects/Forward.ice27
-rwxr-xr-xpython/test/Ice/slicing/objects/Server.py390
-rwxr-xr-xpython/test/Ice/slicing/objects/ServerAMD.py419
-rw-r--r--python/test/Ice/slicing/objects/ServerPrivate.ice67
-rw-r--r--python/test/Ice/slicing/objects/ServerPrivateAMD.ice67
-rw-r--r--python/test/Ice/slicing/objects/Test.ice164
-rw-r--r--python/test/Ice/slicing/objects/TestAMD.ice158
-rwxr-xr-xpython/test/Ice/slicing/objects/run.py36
-rw-r--r--python/test/Ice/timeout/AllTests.py259
-rwxr-xr-xpython/test/Ice/timeout/Client.py74
-rwxr-xr-xpython/test/Ice/timeout/Server.py81
-rw-r--r--python/test/Ice/timeout/Test.ice28
-rwxr-xr-xpython/test/Ice/timeout/run.py23
-rw-r--r--python/test/Makefile21
-rw-r--r--python/test/Makefile.mak19
-rw-r--r--python/test/Slice/Makefile21
-rw-r--r--python/test/Slice/Makefile.mak19
-rw-r--r--python/test/Slice/import/.depend.mak0
-rw-r--r--python/test/Slice/import/.gitignore3
-rwxr-xr-xpython/test/Slice/import/Client.py43
-rw-r--r--python/test/Slice/import/Makefile32
-rw-r--r--python/test/Slice/import/Makefile.mak29
-rw-r--r--python/test/Slice/import/Test1.ice27
-rw-r--r--python/test/Slice/import/Test2.ice31
-rwxr-xr-xpython/test/Slice/import/run.py28
-rwxr-xr-xpython/test/Slice/keyword/Client.py118
-rw-r--r--python/test/Slice/keyword/Key.ice67
-rwxr-xr-xpython/test/Slice/keyword/run.py28
-rwxr-xr-xpython/test/Slice/macros/Client.py51
-rw-r--r--python/test/Slice/macros/Test.ice54
-rwxr-xr-xpython/test/Slice/macros/run.py28
-rwxr-xr-xpython/test/Slice/structure/Client.py211
-rw-r--r--python/test/Slice/structure/Test.ice47
-rwxr-xr-xpython/test/Slice/structure/run.py28
210 files changed, 25968 insertions, 0 deletions
diff --git a/python/test/Ice/acm/AllTests.py b/python/test/Ice/acm/AllTests.py
new file mode 100644
index 00000000000..6cfae071a24
--- /dev/null
+++ b/python/test/Ice/acm/AllTests.py
@@ -0,0 +1,399 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, threading, time, traceback
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class LoggerI(Ice.Logger):
+ def __init__(self):
+ self._started = False
+ self._messages = []
+ self.m = threading.Lock()
+
+ def start(self):
+ self.m.acquire()
+ try:
+ self._started = True
+ self.dump()
+ finally:
+ self.m.release()
+
+ def _print(self, msg):
+ self.m.acquire()
+ try:
+ self._messages.append(msg)
+ if self._started:
+ self.dump()
+ finally:
+ self.m.release()
+
+ def trace(self, category, msg):
+ self.m.acquire()
+ try:
+ self._messages.append("[" + category + "] " + msg)
+ if self._started:
+ self.dump()
+ finally:
+ self.m.release()
+
+ def warning(self, msg):
+ self.m.acquire()
+ try:
+ self._messages.append("warning: " + msg)
+ if self._started:
+ self.dump()
+ finally:
+ self.m.release()
+
+ def error(self, msg):
+ self.m.acquire()
+ try:
+ self._messages.append("error: " + msg)
+ if self._started:
+ self.dump()
+ finally:
+ self.m.release()
+
+ def getPrefix(self):
+ return ""
+
+ def cloneWithPrefix(self, prefix):
+ return self
+
+ def dump(self):
+ for p in self._messages:
+ print(p)
+ self._messages = []
+
+class TestCase(threading.Thread, Ice.ConnectionCallback):
+ def __init__(self, name, com):
+ threading.Thread.__init__(self)
+ self._name = name
+ self._com = com
+ self._logger = LoggerI()
+ self._clientACMTimeout = -1
+ self._clientACMClose = -1
+ self._clientACMHeartbeat = -1
+ self._serverACMTimeout = -1
+ self._serverACMClose = -1
+ self._serverACMHeartbeat = -1
+ self._heartbeat = 0
+ self._closed = False
+ self._msg = ""
+ self.m = threading.Lock()
+
+ def init(self):
+ self._adapter = \
+ self._com.createObjectAdapter(self._serverACMTimeout, self._serverACMClose, self._serverACMHeartbeat)
+
+ initData = Ice.InitializationData()
+ initData.properties = self._com.ice_getCommunicator().getProperties().clone()
+ initData.logger = self._logger
+ initData.properties.setProperty("Ice.ACM.Timeout", "1")
+ if self._clientACMTimeout >= 0:
+ initData.properties.setProperty("Ice.ACM.Client.Timeout", str(self._clientACMTimeout))
+ if self._clientACMClose >= 0:
+ initData.properties.setProperty("Ice.ACM.Client.Close", str(self._clientACMClose))
+ if self._clientACMHeartbeat >= 0:
+ initData.properties.setProperty("Ice.ACM.Client.Heartbeat", str(self._clientACMHeartbeat))
+ #initData.properties.setProperty("Ice.Trace.Protocol", "2")
+ #initData.properties.setProperty("Ice.Trace.Network", "2")
+ self._communicator = Ice.initialize(initData)
+
+ def destroy(self):
+ self._adapter.deactivate()
+ self._communicator.destroy()
+
+ def joinWithThread(self):
+ sys.stdout.write("testing " + self._name + "... ")
+ sys.stdout.flush()
+ self._logger.start()
+ self.join()
+ if len(self._msg) == 0:
+ print("ok")
+ else:
+ print("failed!\n" + self._msg)
+ test(False)
+
+ def run(self):
+ proxy = Test.TestIntfPrx.uncheckedCast(self._communicator.stringToProxy(
+ self._adapter.getTestIntf().ice_toString()))
+ try:
+ proxy.ice_getConnection().setCallback(self)
+ self.runTestCase(self._adapter, proxy)
+ except Exception as ex:
+ self._msg = "unexpected exception:\n" + traceback.format_exc()
+
+ def heartbeat(self, con):
+ self.m.acquire()
+ try:
+ self._heartbeat = self._heartbeat + 1
+ finally:
+ self.m.release()
+
+ def closed(self, con):
+ self.m.acquire()
+ try:
+ self._closed = True
+ finally:
+ self.m.release()
+
+ def runTestCase(self, adapter, proxy):
+ test(False)
+
+ def setClientACM(self, timeout, close, heartbeat):
+ self._clientACMTimeout = timeout
+ self._clientACMClose = close
+ self._clientACMHeartbeat = heartbeat
+
+ def setServerACM(self, timeout, close, heartbeat):
+ self._serverACMTimeout = timeout
+ self._serverACMClose = close
+ self._serverACMHeartbeat = heartbeat
+
+def allTests(communicator):
+ ref = "communicator:default -p 12010"
+ com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref))
+
+ tests = []
+
+ class InvocationHeartbeatTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "invocation heartbeat", com)
+
+ def runTestCase(self, adapter, proxy):
+ proxy.sleep(2)
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat >= 2)
+ finally:
+ self.m.release()
+
+ class InvocationHeartbeatOnHoldTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "invocation with heartbeat on hold", com)
+ # Use default ACM configuration.
+
+ def runTestCase(self, adapter, proxy):
+ try:
+ # When the OA is put on hold, connections shouldn't
+ # send heartbeats, the invocation should therefore
+ # fail.
+ proxy.sleepAndHold(10)
+ test(False)
+ except Ice.ConnectionTimeoutException:
+ adapter.activate()
+ proxy.interruptSleep()
+
+ self.m.acquire()
+ try:
+ test(self._closed)
+ finally:
+ self.m.release()
+
+ class InvocationNoHeartbeatTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "invocation with no heartbeat", com)
+ self.setServerACM(1, 2, 0) # Disable heartbeat on invocations
+
+ def runTestCase(self, adapter, proxy):
+ try:
+ # Heartbeats are disabled on the server, the
+ # invocation should fail since heartbeats are
+ # expected.
+ proxy.sleep(10)
+ test(False)
+ except Ice.ConnectionTimeoutException:
+ proxy.interruptSleep()
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(self._closed)
+ finally:
+ self.m.release()
+
+ class InvocationHeartbeatCloseOnIdleTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "invocation with no heartbeat and close on idle", com)
+ self.setClientACM(1, 1, 0) # Only close on idle.
+ self.setServerACM(1, 2, 0) # Disable heartbeat on invocations
+
+ def runTestCase(self, adapter, proxy):
+ # No close on invocation, the call should succeed this time.
+ proxy.sleep(2)
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(not self._closed)
+ finally:
+ self.m.release()
+
+ class CloseOnIdleTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "close on idle", com)
+ self.setClientACM(1, 1, 0) # Only close on idle.
+
+ def runTestCase(self, adapter, proxy):
+ time.sleep(1.6) # Idle for 1.6 seconds
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(self._closed)
+ finally:
+ self.m.release()
+
+ class CloseOnInvocationTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "close on invocation", com)
+ self.setClientACM(1, 2, 0) # Only close on invocation.
+
+ def runTestCase(self, adapter, proxy):
+ time.sleep(1.5) # Idle for 1.5 seconds
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(not self._closed)
+ finally:
+ self.m.release()
+
+ class CloseOnIdleAndInvocationTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "close on idle and invocation", com)
+ self.setClientACM(1, 3, 0) # Only close on idle and invocation.
+
+ def runTestCase(self, adapter, proxy):
+ #
+ # Put the adapter on hold. The server will not respond to
+ # the graceful close. This allows to test whether or not
+ # the close is graceful or forceful.
+ #
+ adapter.hold()
+ time.sleep(1.6) # Idle for 1.6 seconds
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(not self._closed) # Not closed yet because of graceful close.
+ finally:
+ self.m.release()
+
+ adapter.activate()
+ time.sleep(0.5)
+
+ self.m.acquire()
+ try:
+ test(self._closed) # Connection should be closed this time.
+ finally:
+ self.m.release()
+
+ class ForcefulCloseOnIdleAndInvocationTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "forceful close on idle and invocation", com)
+ self.setClientACM(1, 4, 0) # Only close on idle and invocation.
+
+ def runTestCase(self, adapter, proxy):
+ adapter.hold()
+ time.sleep(1.6) # Idle for 1.6 seconds
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(self._closed) # Connection closed forcefully by ACM.
+ finally:
+ self.m.release()
+
+ class HeartbeatOnIdleTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "heartbeat on idle", com)
+ self.setServerACM(1, -1, 2) # Enable server heartbeats.
+
+ def runTestCase(self, adapter, proxy):
+ time.sleep(2)
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat >= 3)
+ finally:
+ self.m.release()
+
+ class HeartbeatAlwaysTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "heartbeat always", com)
+ self.setServerACM(1, -1, 3) # Enable server heartbeats.
+
+ def runTestCase(self, adapter, proxy):
+ for i in range(0, 20):
+ proxy.ice_ping()
+ time.sleep(0.1)
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat >= 3)
+ finally:
+ self.m.release()
+
+ class SetACMTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "setACM/getACM", com)
+ self.setClientACM(15, 4, 2)
+
+ def runTestCase(self, adapter, proxy):
+ acm = proxy.ice_getCachedConnection().getACM()
+ test(acm.timeout == 15)
+ test(acm.close == Ice.ACMClose.CloseOnIdleForceful)
+ test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnIdle)
+
+ proxy.ice_getCachedConnection().setACM(Ice.Unset, Ice.Unset, Ice.Unset)
+ acm = proxy.ice_getCachedConnection().getACM()
+ test(acm.timeout == 15)
+ test(acm.close == Ice.ACMClose.CloseOnIdleForceful)
+ test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnIdle)
+
+ proxy.ice_getCachedConnection().setACM(20, Ice.ACMClose.CloseOnInvocationAndIdle,
+ Ice.ACMHeartbeat.HeartbeatOnInvocation)
+ acm = proxy.ice_getCachedConnection().getACM()
+ test(acm.timeout == 20)
+ test(acm.close == Ice.ACMClose.CloseOnInvocationAndIdle)
+ test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnInvocation)
+
+ tests.append(InvocationHeartbeatTest(com))
+ tests.append(InvocationHeartbeatOnHoldTest(com))
+ tests.append(InvocationNoHeartbeatTest(com))
+ tests.append(InvocationHeartbeatCloseOnIdleTest(com))
+
+ tests.append(CloseOnIdleTest(com))
+ tests.append(CloseOnInvocationTest(com))
+ tests.append(CloseOnIdleAndInvocationTest(com))
+ tests.append(ForcefulCloseOnIdleAndInvocationTest(com))
+
+ tests.append(HeartbeatOnIdleTest(com))
+ tests.append(HeartbeatAlwaysTest(com))
+ tests.append(SetACMTest(com))
+
+ for p in tests:
+ p.init()
+ for p in tests:
+ p.start()
+ for p in tests:
+ p.joinWithThread()
+ for p in tests:
+ p.destroy()
+
+ sys.stdout.write("shutting down... ")
+ sys.stdout.flush()
+ com.shutdown()
+ print("ok")
diff --git a/python/test/Ice/acm/Client.py b/python/test/Ice/acm/Client.py
new file mode 100755
index 00000000000..2c49777617b
--- /dev/null
+++ b/python/test/Ice/acm/Client.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+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 AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ AllTests.allTests(communicator)
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty('Ice.Warn.Connections', '0')
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/acm/Server.py b/python/test/Ice/acm/Server.py
new file mode 100755
index 00000000000..1f63722fe09
--- /dev/null
+++ b/python/test/Ice/acm/Server.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ communicator.getProperties().setProperty("TestAdapter.ACM.Timeout", "0")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ id = communicator.stringToIdentity("communicator")
+ adapter.add(TestI.RemoteCommunicatorI(), id)
+ adapter.activate()
+
+ # Disable ready print for further adapters.
+ communicator.getProperties().setProperty("Ice.PrintAdapterReady", "0")
+
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+ initData.properties.setProperty("Ice.ACM.Timeout", "1");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/acm/Test.ice b/python/test/Ice/acm/Test.ice
new file mode 100644
index 00000000000..b1c8b749109
--- /dev/null
+++ b/python/test/Ice/acm/Test.ice
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface TestIntf
+{
+ void sleep(int seconds);
+ void sleepAndHold(int seconds);
+ void interruptSleep();
+};
+
+interface RemoteObjectAdapter
+{
+ TestIntf* getTestIntf();
+ void activate();
+ void hold();
+ void deactivate();
+};
+
+interface RemoteCommunicator
+{
+ RemoteObjectAdapter* createObjectAdapter(int acmTimeout, int close, int heartbeat);
+ void shutdown();
+};
+
+};
+
diff --git a/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py
new file mode 100644
index 00000000000..6b63fd26d07
--- /dev/null
+++ b/python/test/Ice/acm/TestI.py
@@ -0,0 +1,78 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 RemoteCommunicatorI(Test.RemoteCommunicator):
+ def createObjectAdapter(self, timeout, close, heartbeat, current=None):
+ com = current.adapter.getCommunicator()
+ properties = com.getProperties()
+ protocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
+
+ name = Ice.generateUUID()
+ if timeout >= 0:
+ properties.setProperty(name + ".ACM.Timeout", str(timeout))
+ if close >= 0:
+ properties.setProperty(name + ".ACM.Close", str(close))
+ if heartbeat >= 0:
+ properties.setProperty(name + ".ACM.Heartbeat", str(heartbeat))
+ properties.setProperty(name + ".ThreadPool.Size", "2")
+ adapter = com.createObjectAdapterWithEndpoints(name, protocol + " -h 127.0.0.1")
+ return Test.RemoteObjectAdapterPrx.uncheckedCast(current.adapter.addWithUUID(RemoteObjectAdapterI(adapter)))
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
+ def __init__(self, adapter):
+ self._adapter = adapter
+ self._testIntf = Test.TestIntfPrx.uncheckedCast(adapter.add(TestIntfI(),
+ adapter.getCommunicator().stringToIdentity("test")))
+ adapter.activate()
+
+ def getTestIntf(self, current=None):
+ return self._testIntf
+
+ def activate(self, current=None):
+ self._adapter.activate()
+
+ def hold(self, current=None):
+ self._adapter.hold()
+
+ def deactivate(self, current=None):
+ try:
+ self._adapter.destroy()
+ except Ice.ObjectAdapterDeactivatedException:
+ pass
+
+class TestIntfI(Test.TestIntf):
+ def __init__(self):
+ self.m = threading.Condition()
+
+ def sleep(self, delay, current=None):
+ self.m.acquire()
+ try:
+ self.m.wait(delay)
+ finally:
+ self.m.release()
+
+ def sleepAndHold(self, delay, current=None):
+ self.m.acquire()
+ try:
+ current.adapter.hold()
+ self.m.wait(delay)
+ finally:
+ self.m.release()
+
+ def interruptSleep(self, delay, current=None):
+ self.m.acquire()
+ try:
+ self.m.notifyAll()
+ finally:
+ self.m.release()
diff --git a/python/test/Ice/acm/run.py b/python/test/Ice/acm/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/acm/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/adapterDeactivation/AllTests.py b/python/test/Ice/adapterDeactivation/AllTests.py
new file mode 100644
index 00000000000..db92fedbd02
--- /dev/null
+++ b/python/test/Ice/adapterDeactivation/AllTests.py
@@ -0,0 +1,72 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 sys, Ice, Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ base = communicator.stringToProxy("test:default -p 12010")
+ test(base)
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ obj = Test.TestIntfPrx.checkedCast(base)
+ test(obj)
+ test(obj == base)
+ print("ok")
+
+ sys.stdout.write("creating/destroying/recreating object adapter... ")
+ sys.stdout.flush()
+ adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default")
+ try:
+ communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default")
+ test(False)
+ except Ice.LocalException:
+ pass
+ adapter.destroy()
+
+ adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default")
+ adapter.destroy()
+ print("ok")
+
+ sys.stdout.write("creating/activating/deactivating object adapter in one operation... ")
+ sys.stdout.flush()
+ obj.transient()
+ print("ok")
+
+ sys.stdout.write("deactivating object adapter in the server... ")
+ sys.stdout.flush()
+ obj.deactivate()
+ print("ok")
+
+ sys.stdout.write("testing connection closure... ");
+ sys.stdout.flush();
+ for x in range(10):
+ initData = Ice.InitializationData();
+ initData.properties = communicator.getProperties().clone();
+ comm = Ice.initialize(initData);
+ comm.stringToProxy("test:default -p 12010").begin_ice_ping();
+ comm.destroy();
+ print("ok");
+
+ sys.stdout.write("testing whether server is gone... ")
+ sys.stdout.flush()
+ try:
+ obj.ice_ping()
+ test(False)
+ except Ice.LocalException:
+ print("ok")
+
+ return obj
diff --git a/python/test/Ice/adapterDeactivation/Client.py b/python/test/Ice/adapterDeactivation/Client.py
new file mode 100755
index 00000000000..a7aa744ec0a
--- /dev/null
+++ b/python/test/Ice/adapterDeactivation/Client.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+import Ice
+Ice.loadSlice('Test.ice')
+import Test, AllTests
+
+class TestClient(Ice.Application):
+ def run(self, args):
+ AllTests.allTests(self.communicator())
+ return 0
+
+app = TestClient()
+sys.exit(app.main(sys.argv))
diff --git a/python/test/Ice/adapterDeactivation/Collocated.py b/python/test/Ice/adapterDeactivation/Collocated.py
new file mode 100755
index 00000000000..c27c1c0915a
--- /dev/null
+++ b/python/test/Ice/adapterDeactivation/Collocated.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+
+import Ice
+Ice.loadSlice('Test.ice')
+import Test, TestI, AllTests
+
+class TestServer(Ice.Application):
+ def run(self, args):
+ self.communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = self.communicator().createObjectAdapter("TestAdapter")
+ locator = TestI.ServantLocatorI()
+
+ adapter.addServantLocator(locator, "")
+ #adapter.activate() // Don't activate OA to ensure collocation is used.
+
+ AllTests.allTests(self.communicator())
+
+ adapter.waitForDeactivate()
+ return 0
+
+app = TestServer()
+sys.exit(app.main(sys.argv))
diff --git a/python/test/Ice/adapterDeactivation/Server.py b/python/test/Ice/adapterDeactivation/Server.py
new file mode 100755
index 00000000000..53c39294ad3
--- /dev/null
+++ b/python/test/Ice/adapterDeactivation/Server.py
@@ -0,0 +1,28 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+
+import Ice
+Ice.loadSlice('Test.ice')
+import Test, TestI
+
+class TestServer(Ice.Application):
+ def run(self, args):
+ self.communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = self.communicator().createObjectAdapter("TestAdapter")
+ locator = TestI.ServantLocatorI()
+
+ adapter.addServantLocator(locator, "")
+ adapter.activate()
+ adapter.waitForDeactivate()
+ return 0
+
+app = TestServer()
+sys.exit(app.main(sys.argv))
diff --git a/python/test/Ice/adapterDeactivation/Test.ice b/python/test/Ice/adapterDeactivation/Test.ice
new file mode 100644
index 00000000000..7e9fecd5f89
--- /dev/null
+++ b/python/test/Ice/adapterDeactivation/Test.ice
@@ -0,0 +1,27 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface TestIntf
+{
+ void transient();
+
+ void deactivate();
+};
+
+local class Cookie
+{
+ idempotent string message();
+};
+
+};
diff --git a/python/test/Ice/adapterDeactivation/TestI.py b/python/test/Ice/adapterDeactivation/TestI.py
new file mode 100644
index 00000000000..3b61867c0ba
--- /dev/null
+++ b/python/test/Ice/adapterDeactivation/TestI.py
@@ -0,0 +1,56 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+import Ice, Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class TestI(Test.TestIntf):
+ def transient(self, current=None):
+ communicator = current.adapter.getCommunicator()
+ adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9999")
+ adapter.activate()
+ adapter.destroy()
+
+ def deactivate(self, current=None):
+ current.adapter.deactivate()
+ time.sleep(0.1)
+
+class CookieI(Test.Cookie):
+ def message(self):
+ return 'blahblah'
+
+class ServantLocatorI(Ice.ServantLocator):
+ def __init__(self):
+ self._deactivated = False
+
+ def __del__(self):
+ test(self._deactivated)
+
+ def locate(self, current):
+ test(not self._deactivated)
+
+ test(current.id.category == '')
+ test(current.id.name == 'test')
+
+ return (TestI(), CookieI())
+
+ def finished(self, current, servant, cookie):
+ test(not self._deactivated)
+
+ test(isinstance(cookie, Test.Cookie))
+ test(cookie.message() == 'blahblah')
+
+ def deactivate(self, category):
+ test(not self._deactivated)
+
+ self._deactivated = True
diff --git a/python/test/Ice/adapterDeactivation/run.py b/python/test/Ice/adapterDeactivation/run.py
new file mode 100755
index 00000000000..9487c74a4f5
--- /dev/null
+++ b/python/test/Ice/adapterDeactivation/run.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
+TestUtil.collocatedTest()
diff --git a/python/test/Ice/admin/AllTests.py b/python/test/Ice/admin/AllTests.py
new file mode 100644
index 00000000000..c76a7d65325
--- /dev/null
+++ b/python/test/Ice/admin/AllTests.py
@@ -0,0 +1,347 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, TestI
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def testFacets(com, builtInFacets = True):
+
+ if builtInFacets:
+ test(com.findAdminFacet("Properties") != None)
+ test(com.findAdminFacet("Process") != None)
+ test(com.findAdminFacet("Logger") != None)
+ test(com.findAdminFacet("Metrics") != None)
+
+ f1 = TestI.TestFacetI()
+ f2 = TestI.TestFacetI()
+ f3 = TestI.TestFacetI()
+
+ com.addAdminFacet(f1, "Facet1")
+ com.addAdminFacet(f2, "Facet2")
+ com.addAdminFacet(f3, "Facet3")
+
+ test(com.findAdminFacet("Facet1") == f1)
+ test(com.findAdminFacet("Facet2") == f2)
+ test(com.findAdminFacet("Facet3") == f3)
+ test(com.findAdminFacet("Bogus") == None)
+
+ facetMap = com.findAllAdminFacets()
+ if builtInFacets:
+ test(len(facetMap) == 7)
+ test("Properties" in facetMap)
+ test(isinstance(facetMap["Properties"], Ice.NativePropertiesAdmin))
+ test("Process" in facetMap)
+ test("Logger" in facetMap)
+ test("Metrics" in facetMap)
+
+ test(len(facetMap) >=3)
+
+ test("Facet1" in facetMap)
+ test("Facet2" in facetMap)
+ test("Facet3" in facetMap)
+
+ try:
+ com.addAdminFacet(f1, "Facet1")
+ test(False)
+ except Ice.AlreadyRegisteredException:
+ pass # Expected
+
+ try:
+ com.removeAdminFacet("Bogus")
+ test(False)
+ except Ice.NotRegisteredException:
+ pass # Expected
+
+ com.removeAdminFacet("Facet1")
+ com.removeAdminFacet("Facet2")
+ com.removeAdminFacet("Facet3")
+
+ try:
+ com.removeAdminFacet("Facet1")
+ test(False)
+ except Ice.NotRegisteredException:
+ pass # Expected
+
+
+def allTests(communicator):
+ sys.stdout.write("testing communicator operations... ")
+ sys.stdout.flush()
+
+ #
+ # Test: Exercise addAdminFacet, findAdminFacet, removeAdminFacet with a typical configuration.
+ #
+ init = Ice.InitializationData()
+ init.properties = Ice.createProperties()
+ init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1")
+ init.properties.setProperty("Ice.Admin.InstanceName", "Test")
+ init.properties.setProperty("Ice.ProgramName", "MyTestProgram")
+ com = Ice.initialize(init)
+ testFacets(com)
+ test(com.getLogger().getPrefix() == "MyTestProgram")
+ com.destroy()
+
+ #
+ # Test: Verify that the operations work correctly in the presence of facet filters.
+ #
+ init = Ice.InitializationData()
+ init.properties = Ice.createProperties()
+ init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1")
+ init.properties.setProperty("Ice.Admin.InstanceName", "Test")
+ init.properties.setProperty("Ice.Admin.Facets", "Properties")
+ com = Ice.initialize(init)
+ testFacets(com, False)
+ com.destroy()
+
+ #
+ # Test: Verify that the operations work correctly with the Admin object disabled.
+ #
+ com = Ice.initialize()
+ testFacets(com, False)
+ com.destroy()
+
+ #
+ # Test: Verify that the operations work correctly when Ice.Admin is enabled.
+ #
+ init = Ice.InitializationData()
+ init.properties = Ice.createProperties()
+ init.properties.setProperty("Ice.Admin.Enabled", "1")
+ com = Ice.initialize(init)
+ test(com.getAdmin() == None)
+ identity = com.stringToIdentity("test-admin")
+ try:
+ com.createAdmin(None, identity)
+ test(False)
+ except Ice.InitializationException:
+ pass
+
+ adapter = com.createObjectAdapter("")
+ test(com.createAdmin(adapter, identity) != None)
+ test(com.getAdmin() != None)
+
+ testFacets(com)
+ com.destroy()
+
+ #
+ # Test: Verify that the operations work correctly when creation of the Admin object is delayed.
+ #
+ init = Ice.InitializationData()
+ init.properties = Ice.createProperties()
+ init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1")
+ init.properties.setProperty("Ice.Admin.InstanceName", "Test")
+ init.properties.setProperty("Ice.Admin.DelayCreation", "1")
+ com = Ice.initialize(init)
+ testFacets(com)
+ com.getAdmin()
+ testFacets(com)
+ com.destroy()
+ print("ok")
+
+ ref = "factory:default -p 12010 -t 10000"
+ factory = Test.RemoteCommunicatorFactoryPrx.uncheckedCast(communicator.stringToProxy(ref))
+
+ sys.stdout.write("testing process facet... ")
+ sys.stdout.flush()
+
+ #
+ # Test: Verify that Process::shutdown() operation shuts down the communicator.
+ #
+ props = {}
+ props["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"
+ props["Ice.Admin.InstanceName"] = "Test"
+ com = factory.createCommunicator(props)
+ obj = com.getAdmin()
+ proc = Ice.ProcessPrx.checkedCast(obj, "Process")
+ proc.shutdown()
+ com.waitForShutdown()
+ com.destroy()
+
+ print("ok")
+
+ sys.stdout.write("testing properties facet... ")
+ sys.stdout.flush()
+
+ props = {}
+ props["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"
+ props["Ice.Admin.InstanceName"] = "Test"
+ props["Prop1"] = "1"
+ props["Prop2"] = "2"
+ props["Prop3"] = "3"
+ com = factory.createCommunicator(props)
+ obj = com.getAdmin()
+ pa = Ice.PropertiesAdminPrx.checkedCast(obj, "Properties")
+
+ #
+ # Test: PropertiesAdmin::getProperty()
+ #
+ test(pa.getProperty("Prop2") == "2")
+ test(pa.getProperty("Bogus") == "")
+
+ #
+ # Test: PropertiesAdmin::getProperties()
+ #
+ pd = pa.getPropertiesForPrefix("")
+ test(len(pd) == 5)
+ test(pd["Ice.Admin.Endpoints"] == "tcp -h 127.0.0.1")
+ test(pd["Ice.Admin.InstanceName"] == "Test")
+ test(pd["Prop1"] == "1")
+ test(pd["Prop2"] == "2")
+ test(pd["Prop3"] == "3")
+
+ changes = {}
+
+ #
+ # Test: PropertiesAdmin::setProperties()
+ #
+ setProps = {}
+ setProps["Prop1"] = "10" # Changed
+ setProps["Prop2"] = "20" # Changed
+ setProps["Prop3"] = "" # Removed
+ setProps["Prop4"] = "4" # Added
+ setProps["Prop5"] = "5" # Added
+ pa.setProperties(setProps)
+ test(pa.getProperty("Prop1") == "10")
+ test(pa.getProperty("Prop2") == "20")
+ test(pa.getProperty("Prop3") == "")
+ test(pa.getProperty("Prop4") == "4")
+ test(pa.getProperty("Prop5") == "5")
+ changes = com.getChanges()
+ test(len(changes) == 5)
+ test(changes["Prop1"] == "10")
+ test(changes["Prop2"] == "20")
+ test(changes["Prop3"] == "")
+ test(changes["Prop4"] == "4")
+ test(changes["Prop5"] == "5")
+ pa.setProperties(setProps)
+ changes = com.getChanges()
+ test(len(changes) == 0)
+
+ com.destroy()
+
+ print("ok")
+
+ sys.stdout.write("testing custom facet... ")
+ sys.stdout.flush()
+
+ #
+ # Test: Verify that the custom facet is present.
+ #
+ props = {}
+ props["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"
+ props["Ice.Admin.InstanceName"] = "Test"
+ com = factory.createCommunicator(props)
+ obj = com.getAdmin()
+ tf = Test.TestFacetPrx.checkedCast(obj, "TestFacet")
+ tf.op()
+ com.destroy()
+
+ print("ok")
+
+ sys.stdout.write("testing facet filtering... ")
+ sys.stdout.flush()
+
+ #
+ # Test: Set Ice.Admin.Facets to expose only the Properties facet,
+ # meaning no other facet is available.
+ #
+ props = {}
+ props["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"
+ props["Ice.Admin.InstanceName"] = "Test"
+ props["Ice.Admin.Facets"] = "Properties"
+ com = factory.createCommunicator(props)
+ obj = com.getAdmin()
+
+ proc = Ice.ProcessPrx.checkedCast(obj, "Process")
+ test(proc == None)
+ tf = Test.TestFacetPrx.checkedCast(obj, "TestFacet")
+ test(tf == None)
+ com.destroy()
+
+ #
+ # Test: Set Ice.Admin.Facets to expose only the Process facet,
+ # meaning no other facet is available.
+ #
+ props = {}
+ props["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"
+ props["Ice.Admin.InstanceName"] = "Test"
+ props["Ice.Admin.Facets"] = "Process"
+ com = factory.createCommunicator(props)
+ obj = com.getAdmin()
+
+ pa = Ice.PropertiesAdminPrx.checkedCast(obj, "Properties")
+ test(pa == None)
+ tf = Test.TestFacetPrx.checkedCast(obj, "TestFacet")
+ test(tf == None)
+
+ com.destroy()
+
+ #
+ # Test: Set Ice.Admin.Facets to expose only the TestFacet facet,
+ # meaning no other facet is available.
+ #
+ props = {}
+ props["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"
+ props["Ice.Admin.InstanceName"] = "Test"
+ props["Ice.Admin.Facets"] = "TestFacet"
+ com = factory.createCommunicator(props)
+ obj = com.getAdmin()
+
+ pa = Ice.PropertiesAdminPrx.checkedCast(obj, "Properties")
+ test(pa == None)
+
+ proc = Ice.ProcessPrx.checkedCast(obj, "Process")
+ test(proc == None)
+
+ com.destroy()
+
+ #
+ # Test: Set Ice.Admin.Facets to expose two facets. Use whitespace to separate the
+ # facet names.
+ #
+ props = {}
+ props["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"
+ props["Ice.Admin.InstanceName"] = "Test"
+ props["Ice.Admin.Facets"] = "Properties TestFacet"
+ com = factory.createCommunicator(props)
+ obj = com.getAdmin()
+ pa = Ice.PropertiesAdminPrx.checkedCast(obj, "Properties")
+ test(pa.getProperty("Ice.Admin.InstanceName") == "Test")
+ tf = Test.TestFacetPrx.checkedCast(obj, "TestFacet")
+ tf.op()
+
+ proc = Ice.ProcessPrx.checkedCast(obj, "Process")
+ test(proc == None)
+ com.destroy()
+
+ #
+ # Test: Set Ice.Admin.Facets to expose two facets. Use a comma to separate the
+ # facet names.
+ #
+ props = {}
+ props["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"
+ props["Ice.Admin.InstanceName"] = "Test"
+ props["Ice.Admin.Facets"] = "TestFacet, Process"
+ com = factory.createCommunicator(props)
+ obj = com.getAdmin()
+
+ pa = Ice.PropertiesAdminPrx.checkedCast(obj, "Properties")
+ test(pa == None)
+
+ tf = Test.TestFacetPrx.checkedCast(obj, "TestFacet")
+ tf.op()
+ proc = Ice.ProcessPrx.checkedCast(obj, "Process")
+ proc.shutdown()
+ com.waitForShutdown()
+ com.destroy()
+
+ print("ok")
+
+ factory.shutdown()
diff --git a/python/test/Ice/admin/Client.py b/python/test/Ice/admin/Client.py
new file mode 100644
index 00000000000..9a4a8071b56
--- /dev/null
+++ b/python/test/Ice/admin/Client.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+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 AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ AllTests.allTests(communicator)
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/admin/Server.py b/python/test/Ice/admin/Server.py
new file mode 100644
index 00000000000..a310310cc19
--- /dev/null
+++ b/python/test/Ice/admin/Server.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+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, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000");
+ adapter = communicator.createObjectAdapter("TestAdapter");
+ ident = communicator.stringToIdentity("factory");
+ adapter.add(TestI.RemoteCommunicatorFactoryI(), ident);
+ adapter.activate();
+
+ communicator.waitForShutdown();
+ return True;
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/admin/Test.ice b/python/test/Ice/admin/Test.ice
new file mode 100644
index 00000000000..92d1cf94e49
--- /dev/null
+++ b/python/test/Ice/admin/Test.ice
@@ -0,0 +1,45 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#ifndef TEST_ICE
+#define TEST_ICE
+
+#include <Ice/Properties.ice>
+
+module Test
+{
+
+interface RemoteCommunicator
+{
+ Object* getAdmin();
+
+ Ice::PropertyDict getChanges();
+
+ void shutdown();
+
+ void waitForShutdown();
+
+ void destroy();
+};
+
+interface RemoteCommunicatorFactory
+{
+ RemoteCommunicator* createCommunicator(Ice::PropertyDict props);
+
+ void shutdown();
+};
+
+interface TestFacet
+{
+ void op();
+};
+
+};
+
+#endif
diff --git a/python/test/Ice/admin/TestI.py b/python/test/Ice/admin/TestI.py
new file mode 100644
index 00000000000..f1f6f8880ea
--- /dev/null
+++ b/python/test/Ice/admin/TestI.py
@@ -0,0 +1,105 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class TestFacetI(Test.TestFacet):
+ def op(self, current = None):
+ return
+
+class RemoteCommunicatorI(Test.RemoteCommunicator, Ice.PropertiesAdminUpdateCallback):
+ def __init__(self, communicator):
+ self.communicator = communicator
+ self.called = False
+ self.m = threading.Condition()
+
+ def getAdmin(self, current = None):
+ return self.communicator.getAdmin()
+
+ def getChanges(self, current = None):
+ self.m.acquire()
+ try:
+ #
+ # The client calls PropertiesAdmin::setProperties() and then invokes
+ # this operation. Since setProperties() is implemented using AMD, the
+ # client might receive its reply and then call getChanges() before our
+ # updated() method is called. We block here to ensure that updated()
+ # gets called before we return the most recent set of changes.
+ #
+ while not self.called:
+ self.m.wait()
+
+ self.called = False
+
+ return self.changes
+ finally:
+ self.m.release()
+
+ def shutdown(self, current = None):
+ self.communicator.shutdown()
+
+ def waitForShutdown(self, current = None):
+ #
+ # Note that we are executing in a thread of the *main* communicator,
+ # not the one that is being shut down.
+ #
+ self.communicator.waitForShutdown()
+
+ def destroy(self, current = None):
+ self.communicator.destroy()
+
+ def updated(self, changes):
+ self.m.acquire()
+ try:
+ self.changes = changes
+ self.called = True
+ self.m.notify()
+ finally:
+ self.m.release()
+
+class RemoteCommunicatorFactoryI(Test.RemoteCommunicatorFactory):
+
+ def createCommunicator(self, props, current = None):
+ #
+ # Prepare the property set using the given properties.
+ #
+ init = Ice.InitializationData()
+ init.properties = Ice.createProperties()
+ for k, v in props.items():
+ init.properties.setProperty(k, v)
+
+ #
+ # Initialize a new communicator.
+ #
+ communicator = Ice.initialize(init)
+
+ #
+ # Install a custom admin facet.
+ #
+ communicator.addAdminFacet(TestFacetI(), "TestFacet")
+
+ #
+ # The RemoteCommunicator servant also implements PropertiesAdminUpdateCallback.
+ # Set the callback on the admin facet.
+ #
+ servant = RemoteCommunicatorI(communicator)
+ admin = communicator.findAdminFacet("Properties")
+ if admin != None:
+ admin.addUpdateCallback(servant)
+
+ proxy = current.adapter.addWithUUID(servant)
+ return Test.RemoteCommunicatorPrx.uncheckedCast(proxy)
+
+ def shutdown(self, current = None):
+ current.adapter.getCommunicator().shutdown()
+
diff --git a/python/test/Ice/admin/run.py b/python/test/Ice/admin/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/admin/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py
new file mode 100644
index 00000000000..93d7d9573ba
--- /dev/null
+++ b/python/test/Ice/ami/AllTests.py
@@ -0,0 +1,1090 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, threading, random
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class CallbackBase:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def check(self):
+ self._cond.acquire()
+ try:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ finally:
+ self._cond.release()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+ def exception(self, ex):
+ test(False)
+
+class ResponseCallback(CallbackBase):
+ def isA(self, r):
+ test(r)
+ self.called()
+
+ def ping(self):
+ self.called()
+
+ def id(self, id):
+ test(id == "::Test::TestIntf")
+ self.called()
+
+ def ids(self, ids):
+ test(len(ids) == 2)
+ self.called()
+
+ def connection(self, conn):
+ test(conn != None)
+ self.called()
+
+ def op(self):
+ self.called()
+
+ def opWithResult(self, r):
+ test(r == 15)
+ self.called()
+
+ def opWithUE(self, ex):
+ try:
+ raise ex
+ except Test.TestIntfException:
+ self.called()
+ except:
+ test(False)
+
+ def ex(self, ex):
+ pass
+
+class ResponseCallbackWC(CallbackBase):
+ def __init__(self, cookie):
+ CallbackBase.__init__(self)
+ self._cookie = cookie
+
+ def isA(self, r, cookie):
+ test(cookie == self._cookie)
+ test(r)
+ self.called()
+
+ def ping(self, cookie):
+ test(cookie == self._cookie)
+ self.called()
+
+ def id(self, id, cookie):
+ test(cookie == self._cookie)
+ test(id == "::Test::TestIntf")
+ self.called()
+
+ def ids(self, ids, cookie):
+ test(cookie == self._cookie)
+ test(len(ids) == 2)
+ self.called()
+
+ def connection(self, conn, cookie):
+ test(cookie == self._cookie)
+ test(conn != None)
+ self.called()
+
+ def op(self, cookie):
+ test(cookie == self._cookie)
+ self.called()
+
+ def opWithResult(self, r, cookie):
+ test(cookie == self._cookie)
+ test(r == 15)
+ self.called()
+
+ def opWithUE(self, ex, cookie):
+ test(cookie == self._cookie)
+ try:
+ raise ex
+ except Test.TestIntfException:
+ self.called()
+ except:
+ test(False)
+
+ def ex(self, ex, cookie):
+ pass
+
+class ExceptionCallback(CallbackBase):
+ def response(self, *args):
+ test(False)
+
+ def nullResponse(self, *args):
+ pass
+
+ def opWithUE(self, ex):
+ test(isinstance(ex, Test.TestIntfException))
+ self.called()
+
+ def ex(self, ex):
+ test(isinstance(ex, Ice.NoEndpointException))
+ self.called()
+
+ def noEx(self, ex):
+ test(False)
+
+class ExceptionCallbackWC(CallbackBase):
+ def __init__(self, cookie):
+ CallbackBase.__init__(self)
+ self._cookie = cookie
+
+ def response(self, *args):
+ test(False)
+
+ def nullResponse(self, *args):
+ pass
+
+ def opWithUE(self, ex, cookie):
+ test(cookie == self._cookie)
+ test(isinstance(ex, Test.TestIntfException))
+ self.called()
+
+ def ex(self, ex, cookie):
+ test(cookie == self._cookie)
+ test(isinstance(ex, Ice.NoEndpointException))
+ self.called()
+
+ def noEx(self, ex, cookie):
+ test(False)
+
+class SentCallback(CallbackBase):
+ def __init__(self):
+ CallbackBase.__init__(self)
+ self._thread = threading.currentThread()
+
+ def response(self, *args):
+ pass
+
+ def ex(self, ex):
+ pass
+
+ def sent(self, sentSynchronously):
+ test((sentSynchronously and self._thread == threading.currentThread()) or \
+ (not sentSynchronously and self._thread != threading.currentThread()))
+ self.called()
+
+class SentCallbackWC(CallbackBase):
+ def __init__(self, cookie):
+ CallbackBase.__init__(self)
+ self._thread = threading.currentThread()
+ self._cookie = cookie
+
+ def response(self, *args):
+ pass
+
+ def ex(self, ex, cookie):
+ pass
+
+ def sent(self, sentSynchronously, cookie):
+ test(cookie == self._cookie)
+ test((sentSynchronously and self._thread == threading.currentThread()) or \
+ (not sentSynchronously and self._thread != threading.currentThread()))
+ self.called()
+
+class FlushCallback(CallbackBase):
+ def __init__(self, cookie=None):
+ CallbackBase.__init__(self)
+ self._thread = threading.currentThread()
+ self._cookie = cookie
+
+ def exception(self, ex):
+ test(False)
+
+ def exceptionWC(self, ex, cookie):
+ test(False)
+
+ def sent(self, sentSynchronously):
+ test((sentSynchronously and self._thread == threading.currentThread()) or \
+ (not sentSynchronously and self._thread != threading.currentThread()))
+ self.called()
+
+ def sentWC(self, sentSynchronously, cookie):
+ test((sentSynchronously and self._thread == threading.currentThread()) or \
+ (not sentSynchronously and self._thread != threading.currentThread()))
+ test(cookie == self._cookie)
+ self.called()
+
+class FlushExCallback(CallbackBase):
+ def __init__(self, cookie=None):
+ CallbackBase.__init__(self)
+ self._cookie = cookie
+
+ def exception(self, ex):
+ self.called()
+
+ def exceptionWC(self, ex, cookie):
+ test(cookie == self._cookie)
+ self.called()
+
+ def sent(self, sentSynchronously):
+ test(False)
+
+ def sentWC(self, sentSynchronously, cookie):
+ test(False)
+
+LocalException = 0
+UserException = 1
+OtherException = 2
+
+def throwEx(t):
+ if t == LocalException:
+ raise Ice.ObjectNotExistException()
+ elif t == UserException:
+ raise Test.TestIntfException()
+ elif t == OtherException:
+ raise RuntimeError()
+ else:
+ test(False)
+
+class Thrower(CallbackBase):
+ def __init__(self, t):
+ CallbackBase.__init__(self)
+ self._t = t
+
+ def op(self):
+ self.called()
+ throwEx(self._t)
+
+ def opWC(self, cookie):
+ self.called()
+ throwEx(self._t)
+
+ def noOp(self):
+ pass
+
+ def noOpWC(self, cookie):
+ pass
+
+ def ex(self, ex):
+ self.called()
+ throwEx(self._t)
+
+ def exWC(self, ex, cookie):
+ self.called()
+ throwEx(self._t)
+
+ def noEx(self, ex):
+ test(False)
+
+ def noExWC(self, ex, cookie):
+ test(False)
+
+ def sent(self, ss):
+ self.called()
+ throwEx(self._t)
+
+ def sentWC(self, ss, cookie):
+ self.called()
+ throwEx(self._t)
+
+def allTests(communicator, collocated):
+ sref = "test:default -p 12010"
+ obj = communicator.stringToProxy(sref)
+ test(obj)
+
+ p = Test.TestIntfPrx.uncheckedCast(obj)
+
+ sref = "testController:default -p 12011"
+ obj = communicator.stringToProxy(sref)
+ test(obj)
+
+ testController = Test.TestIntfControllerPrx.uncheckedCast(obj)
+
+ sys.stdout.write("testing begin/end invocation... ")
+ sys.stdout.flush()
+ ctx = {}
+
+ result = p.begin_ice_isA("::Test::TestIntf")
+ test(p.end_ice_isA(result))
+ result = p.begin_ice_isA("::Test::TestIntf", _ctx=ctx)
+ test(p.end_ice_isA(result))
+
+ result = p.begin_ice_ping()
+ p.end_ice_ping(result)
+ result = p.begin_ice_ping(_ctx=ctx)
+ p.end_ice_ping(result)
+
+ result = p.begin_ice_id()
+ test(p.end_ice_id(result) == "::Test::TestIntf")
+ result = p.begin_ice_id(_ctx=ctx)
+ test(p.end_ice_id(result) == "::Test::TestIntf")
+
+ result = p.begin_ice_ids()
+ test(len(p.end_ice_ids(result)) == 2)
+ result = p.begin_ice_ids(_ctx=ctx)
+ test(len(p.end_ice_ids(result)) == 2)
+
+ if not collocated:
+ result = p.begin_ice_getConnection()
+ test(p.end_ice_getConnection(result) != None)
+
+ result = p.begin_op()
+ p.end_op(result)
+ result = p.begin_op(_ctx=ctx)
+ p.end_op(result)
+
+ result = p.begin_opWithResult()
+ test(p.end_opWithResult(result) == 15)
+ result = p.begin_opWithResult(_ctx=ctx)
+ test(p.end_opWithResult(result) == 15)
+
+ result = p.begin_opWithUE()
+ try:
+ p.end_opWithUE(result)
+ test(False)
+ except Test.TestIntfException:
+ pass
+ result = p.begin_opWithUE(_ctx=ctx)
+ try:
+ p.end_opWithUE(result)
+ test(False)
+ except Test.TestIntfException:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing response callback... ")
+ sys.stdout.flush()
+
+ ctx = {}
+ cb = ResponseCallback()
+ cookie = 5
+ cbWC = ResponseCallbackWC(cookie)
+
+ p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.isA, cb.ex)
+ cb.check()
+ p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+ p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.isA, cb.ex, _ctx=ctx)
+ cb.check()
+ p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie),
+ _ctx=ctx)
+ cbWC.check()
+
+ p.begin_ice_ping(cb.ping, cb.ex)
+ cb.check()
+ p.begin_ice_ping(lambda: cbWC.ping(cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+ p.begin_ice_ping(cb.ping, cb.ex, _ctx=ctx)
+ cb.check()
+ p.begin_ice_ping(lambda: cbWC.ping(cookie), lambda: cbWC.ex(ex, cookie), _ctx=ctx)
+ cbWC.check()
+
+ p.begin_ice_id(cb.id, cb.ex)
+ cb.check()
+ p.begin_ice_id(lambda id: cbWC.id(id, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+ p.begin_ice_id(cb.id, cb.ex, _ctx=ctx)
+ cb.check()
+ p.begin_ice_id(lambda id: cbWC.id(id, cookie), lambda ex: cbWC.ex(ex, cookie), _ctx=ctx)
+ cbWC.check()
+
+ p.begin_ice_ids(cb.ids, cb.ex)
+ cb.check()
+ p.begin_ice_ids(lambda ids: cbWC.ids(ids, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+ p.begin_ice_ids(cb.ids, cb.ex, _ctx=ctx)
+ cb.check()
+ p.begin_ice_ids(lambda ids: cbWC.ids(ids, cookie), lambda ex: cbWC.ex(ex, cookie), _ctx=ctx)
+ cbWC.check()
+
+ if not collocated:
+ p.begin_ice_getConnection(cb.connection, cb.ex)
+ cb.check()
+ p.begin_ice_getConnection(lambda conn: cbWC.connection(conn, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+
+ p.begin_op(cb.op, cb.ex)
+ cb.check()
+ p.begin_op(lambda: cbWC.op(cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+ p.begin_op(cb.op, cb.ex, _ctx=ctx)
+ cb.check()
+ p.begin_op(lambda: cbWC.op(cookie), lambda ex: cbWC.ex(ex, cookie), _ctx=ctx)
+ cbWC.check()
+
+ p.begin_opWithResult(cb.opWithResult, cb.ex)
+ cb.check()
+ p.begin_opWithResult(lambda r: cbWC.opWithResult(r, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+ p.begin_opWithResult(cb.opWithResult, cb.ex, _ctx=ctx)
+ cb.check()
+ p.begin_opWithResult(lambda r: cbWC.opWithResult(r, cookie), lambda ex: cbWC.ex(ex, cookie), _ctx=ctx)
+ cbWC.check()
+
+ p.begin_opWithUE(cb.op, cb.opWithUE)
+ cb.check()
+ p.begin_opWithUE(lambda: cbWC.op(cookie), lambda ex: cbWC.opWithUE(ex, cookie))
+ cbWC.check()
+ p.begin_opWithUE(cb.op, cb.opWithUE, _ctx=ctx)
+ cb.check()
+ p.begin_opWithUE(lambda: cbWC.op(cookie), lambda ex: cbWC.opWithUE(ex, cookie), _ctx=ctx)
+ cbWC.check()
+
+ print("ok")
+
+ sys.stdout.write("testing local exceptions... ")
+ sys.stdout.flush()
+
+ indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy"))
+
+ r = indirect.begin_op()
+ try:
+ indirect.end_op(r)
+ test(False)
+ except Ice.NoEndpointException:
+ pass
+
+ try:
+ p.ice_oneway().begin_opWithResult()
+ test(False)
+ except RuntimeError:
+ pass
+
+ #
+ # Check that CommunicatorDestroyedException is raised directly.
+ #
+ if p.ice_getConnection():
+ initData = Ice.InitializationData()
+ initData.properties = communicator.getProperties().clone()
+ ic = Ice.initialize(initData)
+ obj = ic.stringToProxy(p.ice_toString())
+ p2 = Test.TestIntfPrx.checkedCast(obj)
+ ic.destroy();
+
+ try:
+ p2.begin_op()
+ test(False)
+ except Ice.CommunicatorDestroyedException:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing local exceptions with response callback... ")
+ sys.stdout.flush()
+
+ i = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy"))
+ cb = ExceptionCallback()
+ cookie = 5
+ cbWC = ExceptionCallbackWC(cookie)
+
+ i.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.response, cb.ex)
+ cb.check()
+ i.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda b: cbWC.response(b, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+
+ i.begin_ice_ping(cb.response, cb.ex)
+ cb.check()
+ i.begin_ice_ping(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+
+ i.begin_ice_id(cb.response, cb.ex)
+ cb.check()
+ i.begin_ice_id(lambda id: cbWC.response(id, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+
+ i.begin_ice_ids(cb.response, cb.ex)
+ cb.check()
+ i.begin_ice_ids(lambda ids: cbWC.response(ids, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+
+ if not collocated:
+ i.begin_ice_getConnection(cb.response, cb.ex)
+ cb.check()
+ i.begin_ice_getConnection(lambda conn: cbWC.response(conn, cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+
+ i.begin_op(cb.response, cb.ex)
+ cb.check()
+ i.begin_op(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie))
+ cbWC.check()
+
+ print("ok")
+
+ sys.stdout.write("testing exception callback... ")
+ sys.stdout.flush()
+
+ cb = ExceptionCallback()
+ cookie = 5
+ cbWC = ExceptionCallbackWC(cookie)
+
+ # Ensures no exception is called when response is received.
+ p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.nullResponse, cb.noEx)
+ p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda b: cbWC.nullResponse(b, cookie),
+ lambda ex: cbWC.noEx(ex, cookie))
+ p.begin_op(cb.nullResponse, cb.noEx)
+ p.begin_op(lambda: cbWC.nullResponse(cookie), lambda ex: cbWC.noEx(ex, cookie))
+
+ # If response is a user exception, it should be received.
+ p.begin_opWithUE(cb.nullResponse, cb.opWithUE)
+ cb.check()
+ p.begin_opWithUE(lambda: cbWC.nullResponse(cookie), lambda ex: cbWC.opWithUE(ex, cookie))
+ cbWC.check()
+
+ print("ok")
+
+ sys.stdout.write("testing sent callback... ")
+ sys.stdout.flush()
+
+ cb = SentCallback()
+ cookie = 5
+ cbWC = SentCallbackWC(cookie)
+
+ p.begin_ice_isA("", cb.response, cb.ex, cb.sent)
+ cb.check()
+ p.begin_ice_isA("", lambda b: cbWC.response(b, cookie), lambda ex: cbWC.ex(ex, cookie),
+ lambda ss: cbWC.sent(ss, cookie))
+ cbWC.check()
+
+ p.begin_ice_ping(cb.response, cb.ex, cb.sent)
+ cb.check()
+ p.begin_ice_ping(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie), lambda ss: cbWC.sent(ss, cookie))
+ cbWC.check()
+
+ p.begin_ice_id(cb.response, cb.ex, cb.sent)
+ cb.check()
+ p.begin_ice_id(lambda id: cbWC.response(id, cookie), lambda ex: cbWC.ex(ex, cookie),
+ lambda ss: cbWC.sent(ss, cookie))
+ cbWC.check()
+
+ p.begin_ice_ids(cb.response, cb.ex, cb.sent)
+ cb.check()
+ p.begin_ice_ids(lambda ids: cbWC.response(ids, cookie), lambda ex: cbWC.ex(ex, cookie),
+ lambda ss: cbWC.sent(ss, cookie))
+ cbWC.check()
+
+ p.begin_op(cb.response, cb.ex, cb.sent)
+ cb.check()
+ p.begin_op(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie), lambda ss: cbWC.sent(ss, cookie))
+ cbWC.check()
+
+ cbs = []
+ if sys.version_info[0] == 2:
+ b = [chr(random.randint(0, 255)) for x in range(0, 1024)]
+ seq = ''.join(b)
+ else:
+ b = [random.randint(0, 255) for x in range(0, 1024)]
+ seq = bytes(b)
+ testController.holdAdapter()
+ try:
+ cb = SentCallback()
+ while(p.begin_opWithPayload(seq, None, cb.ex, cb.sent).sentSynchronously()):
+ cbs.append(cb)
+ cb = SentCallback()
+ except Exception as ex:
+ testController.resumeAdapter()
+ raise ex
+ testController.resumeAdapter()
+ for r in cbs:
+ r.check()
+
+ print("ok")
+
+ sys.stdout.write("testing illegal arguments... ")
+ sys.stdout.flush()
+
+ result = p.begin_op()
+ p.end_op(result)
+ try:
+ p.end_op(result)
+ test(False)
+ except RuntimeError:
+ pass
+
+ result = p.begin_op()
+ try:
+ p.end_opWithResult(result)
+ test(False)
+ except RuntimeError:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing unexpected exceptions from callback... ")
+ sys.stdout.flush()
+
+ q = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy"))
+ throwTypes = [ LocalException, UserException, OtherException ]
+
+ for t in throwTypes:
+ cb = Thrower(t)
+ cookie = 5
+
+ p.begin_op(cb.op, cb.noEx)
+ cb.check()
+
+ p.begin_op(lambda: cb.opWC(cookie), lambda ex: cb.noExWC(ex, cookie))
+ cb.check()
+
+ q.begin_op(cb.op, cb.ex)
+ cb.check()
+
+ q.begin_op(lambda: cb.opWC(cookie), lambda ex: cb.exWC(ex, cookie))
+ cb.check()
+
+ p.begin_op(cb.noOp, cb.ex, cb.sent)
+ cb.check()
+
+ p.begin_op(lambda: cb.noOpWC(cookie), lambda ex: cb.exWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie))
+ cb.check()
+
+ q.begin_op(None, cb.ex)
+ cb.check()
+
+ q.begin_op(None, lambda ex: cb.exWC(ex, cookie))
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("testing batch requests with proxy... ")
+ sys.stdout.flush()
+
+ cookie = 5
+
+ #
+ # Without cookie.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = p.ice_batchOneway()
+ b1.opBatch()
+ b1.opBatch()
+ cb = FlushCallback()
+ r = b1.begin_ice_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(r.isSent())
+ test(r.isCompleted())
+ test(p.waitForBatch(2))
+
+ #
+ # With cookie.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = p.ice_batchOneway()
+ b1.opBatch()
+ b1.opBatch()
+ cb = FlushCallback(cookie)
+ r = b1.begin_ice_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie))
+ cb.check()
+ test(p.waitForBatch(2))
+
+ if p.ice_getConnection(): # No collocation optimization
+ #
+ # Exception without cookie.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = p.ice_batchOneway()
+ b1.opBatch()
+ b1.ice_getConnection().close(False)
+ cb = FlushCallback()
+ r = b1.begin_ice_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(r.isSent())
+ test(r.isCompleted())
+ test(p.waitForBatch(1))
+
+ #
+ # Exception with cookie.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = p.ice_batchOneway()
+ b1.opBatch()
+ b1.ice_getConnection().close(False)
+ cb = FlushCallback(cookie)
+ r = b1.begin_ice_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie))
+ cb.check()
+ test(p.waitForBatch(1))
+
+ print("ok")
+
+ if p.ice_getConnection(): # No collocation optimization
+ sys.stdout.write("testing batch requests with connection... ")
+ sys.stdout.flush()
+
+ cookie = 5
+
+ #
+ # Without cookie.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b1.opBatch()
+ b1.opBatch()
+ cb = FlushCallback()
+ r = b1.ice_getConnection().begin_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(r.isSent())
+ test(r.isCompleted())
+ test(p.waitForBatch(2))
+
+ #
+ # With cookie.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b1.opBatch()
+ b1.opBatch()
+ cb = FlushCallback(cookie)
+ r = b1.ice_getConnection().begin_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie),
+ lambda ss: cb.sentWC(ss, cookie))
+ cb.check()
+ test(p.waitForBatch(2))
+
+ #
+ # Exception without cookie.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b1.opBatch()
+ b1.ice_getConnection().close(False)
+ cb = FlushExCallback()
+ r = b1.ice_getConnection().begin_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(not r.isSent())
+ test(r.isCompleted())
+ test(p.opBatchCount() == 0)
+
+ #
+ # Exception with cookie.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b1.opBatch()
+ b1.ice_getConnection().close(False)
+ cb = FlushExCallback(cookie)
+ r = b1.ice_getConnection().begin_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie),
+ lambda ss: cb.sentWC(ss, cookie))
+ cb.check()
+ test(p.opBatchCount() == 0)
+
+ print("ok")
+
+ sys.stdout.write("testing batch requests with communicator... ")
+ sys.stdout.flush()
+
+ #
+ # 1 connection.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b1.opBatch()
+ b1.opBatch()
+ cb = FlushCallback()
+ r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(r.isSent())
+ test(r.isCompleted())
+ test(p.waitForBatch(2))
+
+ #
+ # 1 connection.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b1.opBatch()
+ b1.ice_getConnection().close(False)
+ cb = FlushCallback()
+ r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(r.isSent()) # Exceptions are ignored!
+ test(r.isCompleted())
+ test(p.opBatchCount() == 0)
+
+ #
+ # 2 connections.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy(
+ p.ice_getIdentity()).ice_batchOneway())
+ b2.ice_getConnection() # Ensure connection is established.
+ b1.opBatch()
+ b1.opBatch()
+ b2.opBatch()
+ b2.opBatch()
+ cb = FlushCallback()
+ r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(r.isSent())
+ test(r.isCompleted())
+ test(p.waitForBatch(4))
+
+ #
+ # 2 connections - 1 failure.
+ #
+ # All connections should be flushed even if there are failures on some connections.
+ # Exceptions should not be reported.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy(
+ p.ice_getIdentity()).ice_batchOneway())
+ b2.ice_getConnection() # Ensure connection is established.
+ b1.opBatch()
+ b2.opBatch()
+ b1.ice_getConnection().close(False)
+ cb = FlushCallback()
+ r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(r.isSent()) # Exceptions are ignored!
+ test(r.isCompleted())
+ test(p.waitForBatch(1))
+
+ #
+ # 2 connections - 2 failures.
+ #
+ # The sent callback should be invoked even if all connections fail.
+ #
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b2 = Test.TestIntfPrx.uncheckedCast(p.ice_connectionId("2").ice_getConnection().createProxy(
+ p.ice_getIdentity()).ice_batchOneway())
+ b2.ice_getConnection() # Ensure connection is established.
+ b1.opBatch()
+ b2.opBatch()
+ b1.ice_getConnection().close(False)
+ b2.ice_getConnection().close(False)
+ cb = FlushCallback()
+ r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ cb.check()
+ test(r.isSent()) # Exceptions are ignored!
+ test(r.isCompleted())
+ test(p.opBatchCount() == 0)
+
+ print("ok")
+
+ sys.stdout.write("testing AsyncResult operations... ")
+ sys.stdout.flush()
+
+ indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy"))
+ r = indirect.begin_op()
+ try:
+ r.waitForCompleted()
+ r.throwLocalException()
+ test(False)
+ except Ice.NoEndpointException:
+ pass
+
+ testController.holdAdapter()
+ r1 = None
+ r2 = None
+ try:
+ r1 = p.begin_op()
+ if sys.version_info[0] == 2:
+ b = [chr(random.randint(0, 255)) for x in range(0, 1024)]
+ seq = ''.join(b)
+ else:
+ b = [random.randint(0, 255) for x in range(0, 1024)]
+ seq = bytes(b)
+ while(True):
+ r2 = p.begin_opWithPayload(seq)
+ if not r2.sentSynchronously():
+ break
+
+ test(r1 == r1)
+ test(r1 != r2)
+
+ if p.ice_getConnection():
+ test((r1.sentSynchronously() and r1.isSent() and not r1.isCompleted()) or
+ (not r1.sentSynchronously() and not r1.isCompleted()));
+
+ test(not r2.sentSynchronously() and not r2.isCompleted());
+ except Exception as ex:
+ testController.resumeAdapter()
+ raise ex
+ testController.resumeAdapter()
+
+ r1.waitForSent()
+ test(r1.isSent())
+
+ r2.waitForSent()
+ test(r2.isSent())
+
+ r1.waitForCompleted()
+ test(r1.isCompleted())
+
+ r2.waitForCompleted()
+ test(r2.isCompleted())
+
+ test(r1.getOperation() == "op")
+ test(r2.getOperation() == "opWithPayload")
+
+ #
+ # Twoway
+ #
+ r = p.begin_ice_ping()
+ test(r.getOperation() == "ice_ping")
+ test(r.getConnection() == None) # Expected
+ test(r.getCommunicator() == communicator)
+ test(r.getProxy() == p)
+ p.end_ice_ping(r)
+
+ #
+ # Oneway
+ #
+ p2 = p.ice_oneway()
+ r = p2.begin_ice_ping()
+ test(r.getOperation() == "ice_ping")
+ test(r.getConnection() == None) # Expected
+ test(r.getCommunicator() == communicator)
+ test(r.getProxy() == p2)
+
+ #
+ # Batch request via proxy
+ #
+ p2 = p.ice_batchOneway()
+ p2.ice_ping()
+ r = p2.begin_ice_flushBatchRequests()
+ test(r.getConnection() == None) # Expected
+ test(r.getCommunicator() == communicator)
+ test(r.getProxy() == p2)
+ p2.end_ice_flushBatchRequests(r)
+
+ if p.ice_getConnection():
+ #
+ # Batch request via connection
+ #
+ con = p.ice_getConnection()
+ p2 = p.ice_batchOneway()
+ p2.ice_ping()
+ r = con.begin_flushBatchRequests()
+ test(r.getConnection() == con)
+ test(r.getCommunicator() == communicator)
+ test(r.getProxy() == None) # Expected
+ con.end_flushBatchRequests(r)
+
+ #
+ # Batch request via communicator
+ #
+ p2 = p.ice_batchOneway()
+ p2.ice_ping()
+ r = communicator.begin_flushBatchRequests()
+ test(r.getConnection() == None) # Expected
+ test(r.getCommunicator() == communicator)
+ test(r.getProxy() == None) # Expected
+ communicator.end_flushBatchRequests(r)
+
+ if(p.ice_getConnection()):
+ r1 = None;
+ r2 = None;
+
+ if sys.version_info[0] == 2:
+ b = [chr(random.randint(0, 255)) for x in range(0, 10024)]
+ seq = ''.join(b)
+ else:
+ b = [random.randint(0, 255) for x in range(0, 10024)]
+ seq = bytes(b)
+
+ testController.holdAdapter()
+
+ for x in range(0, 200): # 2MB
+ r = p.begin_opWithPayload(seq)
+
+ test(not r.isSent())
+
+ r1 = p.begin_ice_ping()
+ r2 = p.begin_ice_id()
+ r1.cancel()
+ r2.cancel()
+ try:
+ p.end_ice_ping(r1)
+ test(false)
+ except(Ice.InvocationCanceledException):
+ pass
+
+ try:
+ p.end_ice_id(r2)
+ test(false)
+ except(Ice.InvocationCanceledException):
+ pass
+
+ testController.resumeAdapter()
+ p.ice_ping()
+ test(not r1.isSent() and r1.isCompleted())
+ test(not r2.isSent() and r2.isCompleted())
+
+ testController.holdAdapter()
+
+ r1 = p.begin_op()
+ r2 = p.begin_ice_id()
+ r1.waitForSent()
+ r2.waitForSent()
+ r1.cancel()
+ r2.cancel()
+ try:
+ p.end_op(r1)
+ test(false)
+ except:
+ pass
+ try:
+ p.end_ice_id(r2)
+ test(false)
+ except:
+ pass
+ testController.resumeAdapter()
+
+ print("ok")
+
+ if p.ice_getConnection():
+ sys.stdout.write("testing close connection with sending queue... ")
+ sys.stdout.flush()
+
+ if sys.version_info[0] == 2:
+ b = [chr(random.randint(0, 255)) for x in range(0, 10*1024)]
+ seq = ''.join(b)
+ else:
+ b = [random.randint(0, 255) for x in range(0, 10*1024)]
+ seq = bytes(b)
+
+ #
+ # Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod.
+ # The goal is to make sure that none of the opWithPayload fail even if the server closes
+ # the connection gracefully in between.
+ #
+ maxQueue = 2
+ done = False
+ while not done and maxQueue < 50:
+ done = True
+ p.ice_ping()
+ results = []
+ for i in range(0, maxQueue):
+ results.append(p.begin_opWithPayload(seq))
+ if not p.begin_close(False).isSent():
+ for i in range(0, maxQueue):
+ r = p.begin_opWithPayload(seq)
+ results.append(r)
+ if r.isSent():
+ done = False
+ maxQueue = maxQueue * 2
+ break
+ else:
+ maxQueue = maxQueue * 2
+ done = False
+ for r in results:
+ r.waitForCompleted()
+ try:
+ r.throwLocalException()
+ except Ice.LocalException:
+ test(False)
+
+ print("ok")
+
+ p.shutdown()
diff --git a/python/test/Ice/ami/Client.py b/python/test/Ice/ami/Client.py
new file mode 100755
index 00000000000..8eeb8ed7ea5
--- /dev/null
+++ b/python/test/Ice/ami/Client.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+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 AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ AllTests.allTests(communicator, False)
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty('Ice.Warn.AMICallback', '0')
+
+ #
+ # Limit the send buffer size, this test relies on the socket
+ # send() blocking after sending a given amount of data.
+ #
+ initData.properties.setProperty("Ice.TCP.SndSize", "50000");
+
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/ami/Collocated.py b/python/test/Ice/ami/Collocated.py
new file mode 100755
index 00000000000..11a885f82f9
--- /dev/null
+++ b/python/test/Ice/ami/Collocated.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI, AllTests
+
+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")
+ adapter2 = communicator.createObjectAdapter("ControllerAdapter")
+
+ testController = TestI.TestIntfControllerI(adapter)
+
+ adapter.add(TestI.TestIntfI(), communicator.stringToIdentity("test"))
+ #adapter.activate() # Collocated test doesn't need to active the OA
+
+ adapter2.add(testController, communicator.stringToIdentity("testController"))
+ #adapter2.activate() # Collocated test doesn't need to active the OA
+
+ AllTests.allTests(communicator, True)
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+
+ initData.properties.setProperty("Ice.Warn.AMICallback", "0");
+
+ #
+ # This test kills connections, so we don't want warnings.
+ #
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/ami/Server.py b/python/test/Ice/ami/Server.py
new file mode 100755
index 00000000000..bae6f92fd7e
--- /dev/null
+++ b/python/test/Ice/ami/Server.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI
+
+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")
+ adapter2 = communicator.createObjectAdapter("ControllerAdapter")
+
+ testController = TestI.TestIntfControllerI(adapter)
+
+ adapter.add(TestI.TestIntfI(), communicator.stringToIdentity("test"))
+ adapter.activate()
+
+ adapter2.add(testController, communicator.stringToIdentity("testController"))
+ adapter2.activate()
+
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+
+ #
+ # This test kills connections, so we don't want warnings.
+ #
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+
+ #
+ # 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");
+
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/ami/Test.ice b/python/test/Ice/ami/Test.ice
new file mode 100644
index 00000000000..1bf95e7798f
--- /dev/null
+++ b/python/test/Ice/ami/Test.ice
@@ -0,0 +1,45 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/BuiltinSequences.ice>
+#include <Ice/Endpoint.ice>
+
+module Test
+{
+
+exception TestIntfException
+{
+};
+
+interface TestIntf
+{
+ void op();
+ void opWithPayload(Ice::ByteSeq seq);
+ int opWithResult();
+ void opWithUE()
+ throws TestIntfException;
+ void opBatch();
+ int opBatchCount();
+ bool waitForBatch(int count);
+ void close(bool force);
+ void shutdown();
+
+ bool supportsFunctionalTests();
+};
+
+interface TestIntfController
+{
+ void holdAdapter();
+ void resumeAdapter();
+};
+
+};
+
diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py
new file mode 100644
index 00000000000..c1f7642220a
--- /dev/null
+++ b/python/test/Ice/ami/TestI.py
@@ -0,0 +1,72 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 close(self, force, current=None):
+ current.con.close(force)
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def supportsFunctionalTests(self, current=None):
+ return False
+
+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()
diff --git a/python/test/Ice/ami/run.py b/python/test/Ice/ami/run.py
new file mode 100755
index 00000000000..2307ecfe0a6
--- /dev/null
+++ b/python/test/Ice/ami/run.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("tests with regular server.")
+TestUtil.clientServerTest()
+print("tests with collocated server.")
+TestUtil.collocatedTest()
diff --git a/python/test/Ice/application/Client.py b/python/test/Ice/application/Client.py
new file mode 100755
index 00000000000..500c03395b0
--- /dev/null
+++ b/python/test/Ice/application/Client.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 sys, Ice, time
+
+class Client(Ice.Application):
+ def interruptCallback(self, sig):
+ print("handling signal " + str(sig))
+
+ # SIGINT interrupts time.sleep so a custom method is needed to
+ # sleep for a given interval.
+ def sleep(self, interval):
+ start = time.time()
+ while True:
+ sleepTime = (start + interval) - time.time()
+ if sleepTime <= 0:
+ break
+ time.sleep(sleepTime)
+
+ def run(self, args):
+ self.ignoreInterrupt()
+ print("Ignore CTRL+C and the like for 5 seconds (try it!)")
+ self.sleep(5)
+
+ self.callbackOnInterrupt()
+
+ self.holdInterrupt()
+ print("Hold CTRL+C and the like for 5 seconds (try it!)")
+ self.sleep(5)
+
+ self.releaseInterrupt()
+ print("Release CTRL+C (any held signals should be released)")
+ self.sleep(5)
+
+ self.holdInterrupt()
+ print("Hold CTRL+C and the like for 5 seconds (try it!)")
+ self.sleep(5)
+
+ self.callbackOnInterrupt()
+ print("Release CTRL+C (any held signals should be released)")
+ self.sleep(5)
+
+ self.shutdownOnInterrupt()
+ print("Test shutdown on destroy. Press CTRL+C to shutdown & terminate")
+ self.communicator().waitForShutdown()
+
+ print("ok")
+ return False
+
+app = Client()
+sys.exit(app.main(sys.argv))
diff --git a/python/test/Ice/binding/AllTests.py b/python/test/Ice/binding/AllTests.py
new file mode 100644
index 00000000000..c1ae07f7d91
--- /dev/null
+++ b/python/test/Ice/binding/AllTests.py
@@ -0,0 +1,651 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, random, threading
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class GetAdapterNameCB:
+ def __init__(self):
+ self._name = ""
+ self._cond = threading.Condition()
+
+ def response(self, name):
+ self._cond.acquire()
+ self._name = name
+ self._cond.notify()
+ self._cond.release()
+
+ def exception(self, ex):
+ test(False)
+
+ def getResult(self):
+ self._cond.acquire()
+ try:
+ while self._name == "":
+ self._cond.wait(5.0)
+ if self._name != "":
+ return self._name
+ else:
+ return ""
+ finally:
+ self._cond.release()
+
+def getAdapterNameWithAMI(proxy):
+ cb = GetAdapterNameCB()
+ proxy.begin_getAdapterName(cb.response, cb.exception)
+ return cb.getResult()
+
+def createTestIntfPrx(adapters):
+ endpoints = []
+ test = None
+ for p in adapters:
+ test = p.getTestIntf()
+ edpts = test.ice_getEndpoints()
+ endpoints.extend(edpts)
+ return Test.TestIntfPrx.uncheckedCast(test.ice_endpoints(endpoints))
+
+def deactivate(com, adapters):
+ for p in adapters:
+ com.deactivateObjectAdapter(p)
+
+def allTests(communicator):
+ ref = "communicator:default -p 12010"
+ com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref))
+
+ sys.stdout.write("testing binding with single endpoint... ")
+ sys.stdout.flush()
+
+ adapter = com.createObjectAdapter("Adapter", "default")
+
+ test1 = adapter.getTestIntf()
+ test2 = adapter.getTestIntf()
+ test(test1.ice_getConnection() == test2.ice_getConnection())
+
+ test1.ice_ping()
+ test2.ice_ping()
+
+ com.deactivateObjectAdapter(adapter)
+
+ test3 = Test.TestIntfPrx.uncheckedCast(test1)
+ test(test3.ice_getConnection() == test1.ice_getConnection())
+ test(test3.ice_getConnection() == test2.ice_getConnection())
+
+ try:
+ test3.ice_ping()
+ test(False)
+ except Ice.ConnectionRefusedException:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing binding with multiple endpoints... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("Adapter11", "default"))
+ adapters.append(com.createObjectAdapter("Adapter12", "default"))
+ adapters.append(com.createObjectAdapter("Adapter13", "default"))
+
+ #
+ # Ensure that when a connection is opened it's reused for new
+ # proxies and that all endpoints are eventually tried.
+ #
+ names = ["Adapter11", "Adapter12", "Adapter13"]
+ while len(names) > 0:
+ adpts = adapters[:]
+
+ test1 = createTestIntfPrx(adpts)
+ random.shuffle(adpts)
+ test2 = createTestIntfPrx(adpts)
+ random.shuffle(adpts)
+ test3 = createTestIntfPrx(adpts)
+
+ test(test1.ice_getConnection() == test2.ice_getConnection())
+ test(test2.ice_getConnection() == test3.ice_getConnection())
+
+ name = test1.getAdapterName()
+ if names.count(name) > 0:
+ names.remove(name)
+ test1.ice_getConnection().close(False)
+
+ #
+ # Ensure that the proxy correctly caches the connection (we
+ # always send the request over the same connection.)
+ #
+ for a in adapters:
+ a.getTestIntf().ice_ping()
+
+ t = createTestIntfPrx(adapters)
+ name = t.getAdapterName()
+ i = 0
+ nRetry = 5
+ while i < nRetry and t.getAdapterName() == name:
+ i = i + 1
+ test(i == nRetry)
+
+ for a in adapters:
+ a.getTestIntf().ice_getConnection().close(False)
+
+ #
+ # Deactivate an adapter and ensure that we can still
+ # establish the connection to the remaining adapters.
+ #
+ com.deactivateObjectAdapter(adapters[0])
+ names.append("Adapter12")
+ names.append("Adapter13")
+ while len(names) > 0:
+ adpts = adapters[:]
+
+ test1 = createTestIntfPrx(adpts)
+ random.shuffle(adpts)
+ test2 = createTestIntfPrx(adpts)
+ random.shuffle(adpts)
+ test3 = createTestIntfPrx(adpts)
+
+ test(test1.ice_getConnection() == test2.ice_getConnection())
+ test(test2.ice_getConnection() == test3.ice_getConnection())
+
+ name = test1.getAdapterName()
+ if names.count(name) > 0:
+ names.remove(name)
+ test1.ice_getConnection().close(False)
+
+ #
+ # Deactivate an adapter and ensure that we can still
+ # establish the connection to the remaining adapters.
+ #
+ com.deactivateObjectAdapter(adapters[2])
+ t = createTestIntfPrx(adapters)
+ test(t.getAdapterName() == "Adapter12")
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ sys.stdout.write("testing binding with multiple endpoints and AMI... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("AdapterAMI11", "default"))
+ adapters.append(com.createObjectAdapter("AdapterAMI12", "default"))
+ adapters.append(com.createObjectAdapter("AdapterAMI13", "default"))
+
+ #
+ # Ensure that when a connection is opened it's reused for new
+ # proxies and that all endpoints are eventually tried.
+ #
+ names = ["AdapterAMI11", "AdapterAMI12", "AdapterAMI13"]
+ while len(names) > 0:
+ adpts = adapters[:]
+
+ test1 = createTestIntfPrx(adpts)
+ random.shuffle(adpts)
+ test2 = createTestIntfPrx(adpts)
+ random.shuffle(adpts)
+ test3 = createTestIntfPrx(adpts)
+
+ test(test1.ice_getConnection() == test2.ice_getConnection())
+ test(test2.ice_getConnection() == test3.ice_getConnection())
+
+ name = getAdapterNameWithAMI(test1)
+ if names.count(name) > 0:
+ names.remove(name)
+ test1.ice_getConnection().close(False)
+
+ #
+ # Ensure that the proxy correctly caches the connection (we
+ # always send the request over the same connection.)
+ #
+ for a in adapters:
+ a.getTestIntf().ice_ping()
+
+ t = createTestIntfPrx(adapters)
+ name = getAdapterNameWithAMI(t)
+ i = 0
+ nRetry = 5
+ while i < nRetry and getAdapterNameWithAMI(t) == name:
+ i = i + 1
+ test(i == nRetry)
+
+ for a in adapters:
+ a.getTestIntf().ice_getConnection().close(False)
+
+ #
+ # Deactivate an adapter and ensure that we can still
+ # establish the connection to the remaining adapters.
+ #
+ com.deactivateObjectAdapter(adapters[0])
+ names.append("AdapterAMI12")
+ names.append("AdapterAMI13")
+ while len(names) > 0:
+ adpts = adapters[:]
+
+ test1 = createTestIntfPrx(adpts)
+ random.shuffle(adpts)
+ test2 = createTestIntfPrx(adpts)
+ random.shuffle(adpts)
+ test3 = createTestIntfPrx(adpts)
+
+ test(test1.ice_getConnection() == test2.ice_getConnection())
+ test(test2.ice_getConnection() == test3.ice_getConnection())
+
+ name = getAdapterNameWithAMI(test1)
+ if names.count(name) > 0:
+ names.remove(name)
+ test1.ice_getConnection().close(False)
+
+ #
+ # Deactivate an adapter and ensure that we can still
+ # establish the connection to the remaining adapters.
+ #
+ com.deactivateObjectAdapter(adapters[2])
+ t = createTestIntfPrx(adapters)
+ test(getAdapterNameWithAMI(t) == "AdapterAMI12")
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ sys.stdout.write("testing random endpoint selection... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("Adapter21", "default"))
+ adapters.append(com.createObjectAdapter("Adapter22", "default"))
+ adapters.append(com.createObjectAdapter("Adapter23", "default"))
+
+ t = createTestIntfPrx(adapters)
+ test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random)
+
+ names = ["Adapter21", "Adapter22", "Adapter23"]
+ while len(names) > 0:
+ name = t.getAdapterName()
+ if names.count(name) > 0:
+ names.remove(name)
+ t.ice_getConnection().close(False)
+
+ t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Random))
+ test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random)
+
+ names.append("Adapter21")
+ names.append("Adapter22")
+ names.append("Adapter23")
+ while len(names) > 0:
+ name = t.getAdapterName()
+ if names.count(name) > 0:
+ names.remove(name)
+ t.ice_getConnection().close(False)
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ sys.stdout.write("testing ordered endpoint selection... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("Adapter31", "default"))
+ adapters.append(com.createObjectAdapter("Adapter32", "default"))
+ adapters.append(com.createObjectAdapter("Adapter33", "default"))
+
+ t = createTestIntfPrx(adapters)
+ t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))
+ test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered)
+ nRetry = 5
+
+ #
+ # Ensure that endpoints are tried in order by deactivating the adapters
+ # one after the other.
+ #
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter31":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[0])
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter32":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[1])
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter33":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[2])
+
+ try:
+ t.getAdapterName()
+ except Ice.ConnectionRefusedException:
+ pass
+
+ endpoints = t.ice_getEndpoints()
+
+ adapters = []
+
+ #
+ # Now, re-activate the adapters with the same endpoints in the opposite
+ # order.
+ #
+ adapters.append(com.createObjectAdapter("Adapter36", endpoints[2].toString()))
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter36":
+ i = i + 1
+ test(i == nRetry)
+ t.ice_getConnection().close(False)
+ adapters.append(com.createObjectAdapter("Adapter35", endpoints[1].toString()))
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter35":
+ i = i + 1
+ test(i == nRetry)
+ t.ice_getConnection().close(False)
+ adapters.append(com.createObjectAdapter("Adapter34", endpoints[0].toString()))
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter34":
+ i = i + 1
+ test(i == nRetry)
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ sys.stdout.write("testing per request binding with single endpoint... ")
+ sys.stdout.flush()
+
+ adapter = com.createObjectAdapter("Adapter41", "default")
+
+ test1 = Test.TestIntfPrx.uncheckedCast(adapter.getTestIntf().ice_connectionCached(False))
+ test2 = Test.TestIntfPrx.uncheckedCast(adapter.getTestIntf().ice_connectionCached(False))
+ test(not test1.ice_isConnectionCached())
+ test(not test2.ice_isConnectionCached())
+ test(test1.ice_getConnection() == test2.ice_getConnection())
+
+ test1.ice_ping()
+
+ com.deactivateObjectAdapter(adapter)
+
+ test3 = Test.TestIntfPrx.uncheckedCast(test1)
+ try:
+ test(test3.ice_getConnection() == test1.ice_getConnection())
+ test(False)
+ except Ice.ConnectionRefusedException:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing per request binding with multiple endpoints... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("Adapter51", "default"))
+ adapters.append(com.createObjectAdapter("Adapter52", "default"))
+ adapters.append(com.createObjectAdapter("Adapter53", "default"))
+
+ t = Test.TestIntfPrx.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(False))
+ test(not t.ice_isConnectionCached())
+
+ names = ["Adapter51", "Adapter52", "Adapter53"]
+ while len(names) > 0:
+ name = t.getAdapterName()
+ if names.count(name) > 0:
+ names.remove(name)
+
+ com.deactivateObjectAdapter(adapters[0])
+
+ names.append("Adapter52")
+ names.append("Adapter53")
+ while len(names) > 0:
+ name = t.getAdapterName()
+ if names.count(name) > 0:
+ names.remove(name)
+
+ com.deactivateObjectAdapter(adapters[2])
+
+ test(t.getAdapterName() == "Adapter52")
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ sys.stdout.write("testing per request binding with multiple endpoints and AMI... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("AdapterAMI51", "default"))
+ adapters.append(com.createObjectAdapter("AdapterAMI52", "default"))
+ adapters.append(com.createObjectAdapter("AdapterAMI53", "default"))
+
+ t = Test.TestIntfPrx.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(False))
+ test(not t.ice_isConnectionCached())
+
+ names = ["AdapterAMI51", "AdapterAMI52", "AdapterAMI53"]
+ while len(names) > 0:
+ name = getAdapterNameWithAMI(t)
+ if names.count(name) > 0:
+ names.remove(name)
+
+ com.deactivateObjectAdapter(adapters[0])
+
+ names.append("AdapterAMI52")
+ names.append("AdapterAMI53")
+ while len(names) > 0:
+ name = getAdapterNameWithAMI(t)
+ if names.count(name) > 0:
+ names.remove(name)
+
+ com.deactivateObjectAdapter(adapters[2])
+
+ test(getAdapterNameWithAMI(t) == "AdapterAMI52")
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ sys.stdout.write("testing per request binding and ordered endpoint selection... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("Adapter61", "default"))
+ adapters.append(com.createObjectAdapter("Adapter62", "default"))
+ adapters.append(com.createObjectAdapter("Adapter63", "default"))
+
+ t = createTestIntfPrx(adapters)
+ t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))
+ test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered)
+ t = Test.TestIntfPrx.uncheckedCast(t.ice_connectionCached(False))
+ test(not t.ice_isConnectionCached())
+ nRetry = 5
+
+ #
+ # Ensure that endpoints are tried in order by deactiving the adapters
+ # one after the other.
+ #
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter61":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[0])
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter62":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[1])
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter63":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[2])
+
+ try:
+ t.getAdapterName()
+ except Ice.ConnectionRefusedException:
+ pass
+
+ endpoints = t.ice_getEndpoints()
+
+ adapters = []
+
+ #
+ # Now, re-activate the adapters with the same endpoints in the opposite
+ # order.
+ #
+ adapters.append(com.createObjectAdapter("Adapter66", endpoints[2].toString()))
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter66":
+ i = i + 1
+ test(i == nRetry)
+ adapters.append(com.createObjectAdapter("Adapter65", endpoints[1].toString()))
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter65":
+ i = i + 1
+ test(i == nRetry)
+ adapters.append(com.createObjectAdapter("Adapter64", endpoints[0].toString()))
+ i = 0
+ while i < nRetry and t.getAdapterName() == "Adapter64":
+ i = i + 1
+ test(i == nRetry)
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ sys.stdout.write("testing per request binding and ordered endpoint selection and AMI... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("AdapterAMI61", "default"))
+ adapters.append(com.createObjectAdapter("AdapterAMI62", "default"))
+ adapters.append(com.createObjectAdapter("AdapterAMI63", "default"))
+
+ t = createTestIntfPrx(adapters)
+ t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))
+ test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered)
+ t = Test.TestIntfPrx.uncheckedCast(t.ice_connectionCached(False))
+ test(not t.ice_isConnectionCached())
+ nRetry = 5
+
+ #
+ # Ensure that endpoints are tried in order by deactiving the adapters
+ # one after the other.
+ #
+ i = 0
+ while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI61":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[0])
+ i = 0
+ while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI62":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[1])
+ i = 0
+ while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI63":
+ i = i + 1
+ test(i == nRetry)
+ com.deactivateObjectAdapter(adapters[2])
+
+ try:
+ t.getAdapterName()
+ except Ice.ConnectionRefusedException:
+ pass
+
+ endpoints = t.ice_getEndpoints()
+
+ adapters = []
+
+ #
+ # Now, re-activate the adapters with the same endpoints in the opposite
+ # order.
+ #
+ adapters.append(com.createObjectAdapter("AdapterAMI66", endpoints[2].toString()))
+ i = 0
+ while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI66":
+ i = i + 1
+ test(i == nRetry)
+ adapters.append(com.createObjectAdapter("AdapterAMI65", endpoints[1].toString()))
+ i = 0
+ while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI65":
+ i = i + 1
+ test(i == nRetry)
+ adapters.append(com.createObjectAdapter("AdapterAMI64", endpoints[0].toString()))
+ i = 0
+ while i < nRetry and getAdapterNameWithAMI(t) == "AdapterAMI64":
+ i = i + 1
+ test(i == nRetry)
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ sys.stdout.write("testing endpoint mode filtering... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("Adapter71", "default"))
+ adapters.append(com.createObjectAdapter("Adapter72", "udp"))
+
+ t = createTestIntfPrx(adapters)
+ test(t.getAdapterName() == "Adapter71")
+
+ testUDP = Test.TestIntfPrx.uncheckedCast(t.ice_datagram())
+ test(t.ice_getConnection() != testUDP.ice_getConnection())
+ try:
+ testUDP.getAdapterName()
+ except Ice.TwowayOnlyException:
+ pass
+
+ print("ok")
+
+ if(len(communicator.getProperties().getProperty("Ice.Plugin.IceSSL")) > 0):
+ sys.stdout.write("testing unsecure vs. secure endpoints... ")
+ sys.stdout.flush()
+
+ adapters = []
+ adapters.append(com.createObjectAdapter("Adapter81", "ssl"))
+ adapters.append(com.createObjectAdapter("Adapter82", "tcp"))
+
+ t = createTestIntfPrx(adapters)
+ for i in range(0, 5):
+ test(t.getAdapterName() == "Adapter82")
+ t.ice_getConnection().close(False)
+
+ testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True))
+ test(testSecure.ice_isSecure())
+ testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(False))
+ test(not testSecure.ice_isSecure())
+ testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True))
+ test(testSecure.ice_isSecure())
+ test(t.ice_getConnection() != testSecure.ice_getConnection())
+
+ com.deactivateObjectAdapter(adapters[1])
+
+ for i in range(0, 5):
+ test(t.getAdapterName() == "Adapter81")
+ t.ice_getConnection().close(False)
+
+ com.createObjectAdapter("Adapter83", (t.ice_getEndpoints()[1]).toString()) # Reactive tcp OA.
+
+ for i in range(0, 5):
+ test(t.getAdapterName() == "Adapter83")
+ t.ice_getConnection().close(False)
+
+ com.deactivateObjectAdapter(adapters[0])
+ try:
+ testSecure.ice_ping()
+ test(False)
+ except Ice.ConnectionRefusedException:
+ pass
+
+ deactivate(com, adapters)
+
+ print("ok")
+
+ com.shutdown()
diff --git a/python/test/Ice/binding/Client.py b/python/test/Ice/binding/Client.py
new file mode 100755
index 00000000000..7cc8180a8fc
--- /dev/null
+++ b/python/test/Ice/binding/Client.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 AllTests
+
+def run(args, communicator):
+ AllTests.allTests(communicator)
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/binding/Server.py b/python/test/Ice/binding/Server.py
new file mode 100755
index 00000000000..25d7602fcb4
--- /dev/null
+++ b/python/test/Ice/binding/Server.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ id = communicator.stringToIdentity("communicator")
+ adapter.add(TestI.RemoteCommunicatorI(), id)
+ adapter.activate()
+
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/binding/Test.ice b/python/test/Ice/binding/Test.ice
new file mode 100644
index 00000000000..bd7cbe1a971
--- /dev/null
+++ b/python/test/Ice/binding/Test.ice
@@ -0,0 +1,36 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface TestIntf
+{
+ string getAdapterName();
+};
+
+interface RemoteObjectAdapter
+{
+ TestIntf* getTestIntf();
+
+ void deactivate();
+};
+
+interface RemoteCommunicator
+{
+ RemoteObjectAdapter* createObjectAdapter(string name, string endpoints);
+
+ void deactivateObjectAdapter(RemoteObjectAdapter* adapter);
+
+ void shutdown();
+};
+
+};
diff --git a/python/test/Ice/binding/TestI.py b/python/test/Ice/binding/TestI.py
new file mode 100644
index 00000000000..c24cf074c4b
--- /dev/null
+++ b/python/test/Ice/binding/TestI.py
@@ -0,0 +1,42 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+class RemoteCommunicatorI(Test.RemoteCommunicator):
+ def createObjectAdapter(self, name, endpoints, current=None):
+ com = current.adapter.getCommunicator()
+ com.getProperties().setProperty(name + ".ThreadPool.Size", "1")
+ adapter = com.createObjectAdapterWithEndpoints(name, endpoints)
+ return Test.RemoteObjectAdapterPrx.uncheckedCast(current.adapter.addWithUUID(RemoteObjectAdapterI(adapter)))
+
+ def deactivateObjectAdapter(self, adapter, current=None):
+ adapter.deactivate()
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
+ def __init__(self, adapter):
+ self._adapter = adapter
+ self._testIntf = Test.TestIntfPrx.uncheckedCast(self._adapter.add(TestI(), adapter.getCommunicator().stringToIdentity("test")))
+ self._adapter.activate()
+
+ def getTestIntf(self, current=None):
+ return self._testIntf
+
+ def deactivate(self, current=None):
+ try:
+ self._adapter.destroy()
+ except Ice.ObjectAdapterDeactivatedException:
+ pass
+
+class TestI(Test.TestIntf):
+ def getAdapterName(self, current=None):
+ return current.adapter.getName()
diff --git a/python/test/Ice/binding/run.py b/python/test/Ice/binding/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/binding/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/blobject/Client.py b/python/test/Ice/blobject/Client.py
new file mode 100755
index 00000000000..8fb5d04c61e
--- /dev/null
+++ b/python/test/Ice/blobject/Client.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+import RouterI
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator, sync):
+ hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("test:default -p 12010"))
+ hello.sayHello(False)
+ hello.sayHello(False, { "_fwd":"o" } )
+ test(hello.add(10, 20) == 30)
+ try:
+ hello.raiseUE()
+ test(False)
+ except Test.UE:
+ pass
+
+ try:
+ Test.HelloPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000"))
+ test(False)
+ except Ice.ObjectNotExistException:
+ pass
+
+ # First try an object at a non-existent endpoint.
+ try:
+ Test.HelloPrx.checkedCast(communicator.stringToProxy("missing:default -p 12000 -t 10000"))
+ test(False)
+ except Ice.UnknownLocalException as e:
+ test(e.unknown.find('ConnectionRefusedException'))
+ if sync:
+ hello.shutdown()
+ return True
+
+argv = sys.argv[:] # Clone the arguments to use again later
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(argv)
+ initData.properties.setProperty('Ice.Warn.Dispatch', '0')
+ communicator = Ice.initialize(argv, initData)
+ router = RouterI.RouterI(communicator, False)
+ sys.stdout.write("testing async blobject... ")
+ sys.stdout.flush()
+ status = run(sys.argv, communicator, False)
+ print("ok")
+ router.destroy()
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+if status:
+ try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty('Ice.Warn.Dispatch', '0')
+ communicator = Ice.initialize(sys.argv, initData)
+ router = RouterI.RouterI(communicator, True)
+ sys.stdout.write("testing sync blobject... ")
+ sys.stdout.flush()
+ status = run(sys.argv, communicator, True)
+ print("ok")
+ router.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+ if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/blobject/RouterI.py b/python/test/Ice/blobject/RouterI.py
new file mode 100644
index 00000000000..47582a06b33
--- /dev/null
+++ b/python/test/Ice/blobject/RouterI.py
@@ -0,0 +1,172 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 threading, Ice
+
+class CallQueue(threading.Thread):
+ def __init__(self):
+ threading.Thread.__init__(self)
+ self._condVar = threading.Condition()
+ self._queue = []
+ self._destroy = False
+
+ def add(self, call):
+ self._condVar.acquire()
+ self._queue.append(call)
+ self._condVar.notify()
+ self._condVar.release()
+
+ def destroy(self):
+ self._condVar.acquire()
+ self._destroy = True
+ self._condVar.notify()
+ self._condVar.release()
+
+ def run(self):
+ while True:
+ self._condVar.acquire()
+ while len(self._queue) == 0 and not self._destroy:
+ self._condVar.wait()
+ if self._destroy:
+ self._condVar.release()
+ break
+ call = self._queue.pop()
+ self._condVar.release()
+ call.execute()
+
+class AsyncCallback(object):
+ def __init__(self, cb):
+ self._cb = cb
+
+ def response(self, ok, results):
+ self._cb.ice_response(ok, results)
+
+ def exception(self, ex):
+ self._cb.ice_exception(ex)
+
+class BlobjectCall(object):
+ def __init__(self, proxy, amdCallback, inParams, curr):
+ self._proxy = proxy
+ self._amdCallback = amdCallback
+ self._inParams = inParams
+ self._curr = curr
+
+ def execute(self):
+ proxy = self._proxy
+ if len(self._curr.facet) > 0:
+ proxy = self._proxy.ice_facet(self._curr.facet)
+
+ if "_fwd" in self._curr.ctx and self._curr.ctx["_fwd"] == "o":
+ proxy = proxy.ice_oneway()
+ try:
+ ok, out = proxy.ice_invoke(self._curr.operation, self._curr.mode, self._inParams, self._curr.ctx)
+ self._amdCallback.ice_response(ok, out)
+ except Ice.Exception as e:
+ self._amdCallback.ice_exception(e)
+ else:
+ cb = AsyncCallback(self._amdCallback)
+ proxy.begin_ice_invoke(self._curr.operation, self._curr.mode, self._inParams, cb.response, cb.exception,
+ None, self._curr.ctx)
+
+class BlobjectAsyncI(Ice.BlobjectAsync):
+ def __init__(self):
+ self._queue = CallQueue()
+ self._queue.start()
+ self._objects = {}
+ self._lock = threading.Lock()
+
+ def ice_invoke_async(self, amdCallback, inParams, curr):
+ self._lock.acquire()
+ proxy = self._objects[curr.id]
+ assert proxy
+ self._lock.release()
+ self._queue.add(BlobjectCall(proxy, amdCallback, inParams, curr))
+
+ def add(self, proxy):
+ self._lock.acquire()
+ self._objects[proxy.ice_getIdentity()] = proxy.ice_facet("").ice_twoway().ice_router(None)
+ self._lock.release()
+
+ def destroy(self):
+ self._lock.acquire()
+ self._queue.destroy()
+ self._queue.join()
+ self._lock.release()
+
+class BlobjectI(Ice.Blobject):
+ def __init__(self):
+ self._objects = {}
+ self._lock = threading.Lock()
+
+ def ice_invoke(self, inParams, curr):
+ self._lock.acquire()
+ proxy = self._objects[curr.id]
+ self._lock.release()
+
+ if len(curr.facet) > 0:
+ proxy = proxy.ice_facet(curr.facet)
+
+ try:
+ if "_fwd" in curr.ctx and curr.ctx["_fwd"] == "o":
+ proxy = proxy.ice_oneway()
+ return proxy.ice_invoke(curr.operation, curr.mode, inParams, curr.ctx)
+ else:
+ return proxy.ice_invoke(curr.operation, curr.mode, inParams, curr.ctx)
+ except Ice.Exception as e:
+ raise
+
+ def add(self, proxy):
+ self._lock.acquire()
+ self._objects[proxy.ice_getIdentity()] = proxy.ice_facet("").ice_twoway().ice_router(None)
+ self._lock.release()
+
+ def destroy(self):
+ pass
+
+class ServantLocatorI(Ice.ServantLocator):
+ def __init__(self, blobject):
+ self._blobject = blobject
+
+ def locate(self, current):
+ return self._blobject # and the cookie
+
+ def finished(self, current, object, cookie):
+ pass
+
+ def deactivate(self, s):
+ pass
+
+class RouterI(Ice.Router):
+ def __init__(self, communicator, sync):
+ self._adapter = communicator.createObjectAdapterWithEndpoints("forward", "default -h 127.0.0.1")
+ if sync:
+ self._blobject = BlobjectI()
+ else:
+ self._blobject = BlobjectAsyncI()
+ self._adapter.addServantLocator(ServantLocatorI(self._blobject), "")
+ self._blobjectProxy = self._adapter.addWithUUID(self._blobject)
+ proxy = Ice.RouterPrx.uncheckedCast(self._adapter.addWithUUID(self))
+ communicator.setDefaultRouter(proxy)
+ self._adapter.activate()
+
+ def useSync(self, sync):
+ self._locator.useSync(sync)
+
+ def getClientProxy(self, current):
+ return self._blobjectProxy
+
+ def getServerProxy(self, current):
+ assert false
+
+ def addProxies(self, proxies, current):
+ for p in proxies:
+ self._blobject.add(p)
+
+ def destroy(self):
+ self._blobject.destroy()
diff --git a/python/test/Ice/blobject/Server.py b/python/test/Ice/blobject/Server.py
new file mode 100755
index 00000000000..0dbd92a4b68
--- /dev/null
+++ b/python/test/Ice/blobject/Server.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 TestI(Test.Hello):
+ def sayHello(self, delay, current=None):
+ if delay != 0:
+ time.sleep(delay / 1000.0)
+
+ def raiseUE(self, current=None):
+ raise Test.UE()
+
+ def add(self, s1, s2, current=None):
+ return s1 + s2
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(TestI(), communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ #
+ # Its possible to have batch oneway requests dispatched after the
+ # adapter is deactivated due to thread scheduling so we supress
+ # this warning.
+ #
+ initData.properties.setProperty("Ice.Warn.Dispatch", "0");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/blobject/Test.ice b/python/test/Ice/blobject/Test.ice
new file mode 100644
index 00000000000..967825ffbf7
--- /dev/null
+++ b/python/test/Ice/blobject/Test.ice
@@ -0,0 +1,28 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+exception UE
+{
+};
+
+interface Hello
+{
+ void sayHello(int delay);
+ int add(int s1, int s2);
+ void raiseUE()
+ throws UE;
+ void shutdown();
+};
+
+};
diff --git a/python/test/Ice/blobject/run.py b/python/test/Ice/blobject/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/blobject/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/checksum/AllTests.py b/python/test/Ice/checksum/AllTests.py
new file mode 100644
index 00000000000..cece6a1d908
--- /dev/null
+++ b/python/test/Ice/checksum/AllTests.py
@@ -0,0 +1,59 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 sys, string, re, traceback, Ice, Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ ref = "test:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+
+ checksum = Test.ChecksumPrx.checkedCast(base)
+ test(checksum)
+
+ #
+ # Verify that no checksums are present for local types.
+ #
+ sys.stdout.write("testing checksums... ")
+ sys.stdout.flush()
+ test(len(Ice.sliceChecksums) > 0)
+ for i in Ice.sliceChecksums:
+ test(i.find("Local") == -1)
+
+ #
+ # Get server's Slice checksums.
+ #
+ d = checksum.getSliceChecksums()
+
+ #
+ # Compare the checksums. For a type FooN whose name ends in an integer N,
+ # we assume that the server's type does not change for N = 1, and does
+ # change for N > 1.
+ #
+ patt = re.compile("\\d+")
+ for i in d:
+ n = 0
+ m = patt.search(i)
+ if m:
+ n = int(i[m.start():])
+
+ test(i in Ice.sliceChecksums)
+
+ if n <= 1:
+ test(Ice.sliceChecksums[i] == d[i])
+ else:
+ test(Ice.sliceChecksums[i] != d[i])
+
+ print("ok")
+
+ return checksum
diff --git a/python/test/Ice/checksum/CTypes.ice b/python/test/Ice/checksum/CTypes.ice
new file mode 100644
index 00000000000..1dfc5f719d5
--- /dev/null
+++ b/python/test/Ice/checksum/CTypes.ice
@@ -0,0 +1,634 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+//
+// TEST: Same
+//
+const int IntConst1 = 100;
+
+//
+// TEST: Value changed
+//
+const int IntConst2 = 100;
+
+//
+// TEST: Type changed
+//
+const int IntConst3 = 100;
+
+//
+// TEST: Same
+//
+enum Enum1 { Enum11, Enum12, Enum13 };
+
+//
+// TEST: Add enumerator
+//
+enum Enum2 { Enum21, Enum22, Enum23 };
+
+//
+// TEST: Remove enumerator
+//
+enum Enum3 { Enum31, Enum32, Enum33 };
+
+//
+// TEST: Change to a different type
+//
+enum Enum4 { Enum41, Enum42, Enum43 };
+
+//
+// TEST: Enum with explicit values.
+//
+enum EnumExplicit0 { EnumExplicit01 = 1, EnumExplicit02 = 2, EnumExplicit03 = 3 };
+
+//
+// TEST: Enum with same explicit values, different order.
+//
+enum EnumExplicit1 { EnumExplicit11 = 1, EnumExplicit12 = 2, EnumExplicit13 = 3 };
+
+//
+// TEST: Enum with different explicit values.
+//
+enum EnumExplicit2 { EnumExplicit21 = 1, EnumExplicit22 = 2, EnumExplicit23 = 3};
+
+//
+// TEST: Enum with explicit values, removed enumerator.
+//
+enum EnumExplicit3 { EnumExplicit31 = 1, EnumExplicit32 = 2, EnumExplicit33 = 3};
+
+//
+// TEST: Same
+//
+sequence<int> Sequence1;
+
+//
+// TEST: Change sequence type
+//
+sequence<int> Sequence2;
+
+//
+// TEST: Change to a different type
+//
+sequence<int> Sequence3;
+
+//
+// TEST: Same
+//
+dictionary<string, int> Dictionary1;
+
+//
+// TEST: Change key type
+//
+dictionary<string, int> Dictionary2;
+
+//
+// TEST: Change value type
+//
+dictionary<string, int> Dictionary3;
+
+//
+// TEST: Change to a different type
+//
+dictionary<string, int> Dictionary4;
+
+//
+// TEST: Same
+//
+struct Struct1
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Add member
+//
+struct Struct2
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Change member type
+//
+struct Struct3
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Remove member
+//
+struct Struct4
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Change to a different type
+//
+struct Struct5
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Same
+//
+interface Interface1
+{
+};
+
+//
+// TEST: Change interface to class
+//
+interface Interface2
+{
+};
+
+//
+// TEST: Add base interface
+//
+interface Interface3
+{
+};
+
+//
+// TEST: Add operation
+//
+interface Interface4
+{
+};
+
+//
+// TEST: Same
+//
+class EmptyClass1
+{
+};
+
+//
+// TEST: Add data member
+//
+class EmptyClass2
+{
+};
+
+//
+// TEST: Add operation
+//
+class EmptyClass3
+{
+};
+
+//
+// TEST: Add base class
+//
+class EmptyClass4
+{
+};
+
+//
+// TEST: Add interface
+//
+class EmptyClass5
+{
+};
+
+//
+// TEST: Same
+//
+class SimpleClass1
+{
+ string str;
+ float f;
+};
+
+//
+// TEST: Add operation
+//
+class SimpleClass2
+{
+ string str;
+ float f;
+};
+
+//
+// TEST: Rename member
+//
+class SimpleClass3
+{
+ string str;
+ float f;
+};
+
+//
+// TEST: Add member
+//
+class SimpleClass4
+{
+ string str;
+ float f;
+};
+
+//
+// TEST: Remove member
+//
+class SimpleClass5
+{
+ string str;
+ float f;
+};
+
+//
+// TEST: Reorder members
+//
+class SimpleClass6
+{
+ string str;
+ float f;
+};
+
+//
+// TEST: Change member type
+//
+class SimpleClass7
+{
+ string str;
+ float f;
+};
+
+//
+// TEST: Same
+//
+exception Exception1
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Add member
+//
+exception Exception2
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Change member type
+//
+exception Exception3
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Remove member
+//
+exception Exception4
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Add base exception
+//
+exception Exception5
+{
+};
+
+//
+// TEST: Change to a different type
+//
+exception Exception6
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Exception with optional members.
+//
+exception OptionalEx0
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Exception with optional members, different order, same tags.
+//
+exception OptionalEx1
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Exception with different optional members.
+//
+exception OptionalEx2
+{
+ string firstName;
+ string secondName;
+ optional(1) string emailAddress;
+};
+
+//
+// TEST: Exception with different optional members.
+//
+exception OptionalEx3
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Exception with optional members using different tags.
+//
+exception OptionalEx4
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Same
+//
+class BaseClass1
+{
+ void baseOp1();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Change return type
+//
+class BaseClass2
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add parameter
+//
+class BaseClass3
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add exception
+//
+class BaseClass4
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Change out parameter to in parameter
+//
+class BaseClass5
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Remove parameter
+//
+class BaseClass6
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Remove exception
+//
+class BaseClass7
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Remove operation
+//
+class BaseClass8
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add base class
+//
+class BaseClass9
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add interface
+//
+class BaseClass10
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add base class and interface
+//
+class BaseClass11
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Class with compact id
+//
+class Compact1(1)
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Derived from class with compact id
+//
+class Derived1 extends Compact1
+{
+};
+
+//
+// TEST: Same class names but different compact id
+//
+class Compact2(2)
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Class with optional members.
+//
+class Optional0
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Class with optional members, different order, same tags.
+//
+class Optional1
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Class with different optional members.
+//
+class Optional2
+{
+ string firstName;
+ string secondName;
+ optional(1) string emailAddress;
+};
+
+//
+// TEST: Class with different optional members.
+//
+class Optional3
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Class with optional members using different tags.
+//
+class Optional4
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Class with optional parameters.
+//
+class OptionalParameters0
+{
+ void op1(string firstName, optional(1) string secondName,
+ optional(2) string emailAddress);
+};
+
+//
+// TEST: Class with optional parameters, different order.
+//
+class OptionalParameters1
+{
+ void op1(string firstName, optional(1) string secondName,
+ optional(2) string emailAddress);
+};
+
+//
+// TEST: Class with optional parameters, different tags.
+//
+class OptionalParameters2
+{
+ void op1(string firstName, optional(1) string emailAddress,
+ optional(2) string secondName);
+};
+
+//
+// TEST: Class with different optional parameters.
+//
+class OptionalParameters3
+{
+ void op1(string firstName, optional(1) string emailAddress,
+ string secondName);
+};
+
+//
+// TEST: Class with optional return type.
+//
+class OptionalReturn0
+{
+ optional(1) int op();
+};
+
+//
+// TEST: Class that changes optional return type.
+//
+class OptionalReturn2
+{
+ optional(1) int op();
+};
+
+//
+// TEST: Local
+//
+local enum LocalEnum { LocalEnum1, LocalEnum2, LocalEnum3 };
+
+//
+// TEST: Local
+//
+local sequence<string> LocalSequence;
+
+//
+// TEST: Local
+//
+local dictionary<string, string> LocalDictionary;
+
+//
+// TEST: Local
+//
+local struct LocalStruct
+{
+ string str;
+};
+
+//
+// TEST: Local
+//
+local class LocalClass
+{
+};
+
+};
diff --git a/python/test/Ice/checksum/Client.py b/python/test/Ice/checksum/Client.py
new file mode 100755
index 00000000000..592c84c632a
--- /dev/null
+++ b/python/test/Ice/checksum/Client.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+slice_dir = Ice.getSliceDir()
+if not slice_dir:
+ print(sys.argv[0] + ': Slice directory not found.')
+ sys.exit(1)
+
+Ice.loadSlice("'-I" + slice_dir + "' --checksum Test.ice CTypes.ice")
+import Test, AllTests
+
+def run(args, communicator):
+ checksum = AllTests.allTests(communicator)
+ checksum.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/checksum/STypes.ice b/python/test/Ice/checksum/STypes.ice
new file mode 100644
index 00000000000..00e0b76c2ea
--- /dev/null
+++ b/python/test/Ice/checksum/STypes.ice
@@ -0,0 +1,631 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+//
+// TEST: Same
+//
+const int IntConst1 = 100;
+
+//
+// TEST: Value changed
+//
+const int IntConst2 = 1000;
+
+//
+// TEST: Type changed
+//
+const short IntConst3 = 100;
+
+//
+// TEST: Same
+//
+enum Enum1 { Enum11, Enum12, Enum13 };
+
+//
+// TEST: Add enumerator
+//
+enum Enum2 { Enum21, Enum22, Enum23, Enum24 };
+
+//
+// TEST: Remove enumerator
+//
+enum Enum3 { Enum32, Enum33 };
+
+//
+// TEST: Enum with explicit values.
+//
+enum EnumExplicit0 { EnumExplicit01 = 1, EnumExplicit02 = 2, EnumExplicit03 = 3 };
+
+//
+// TEST: Enum with same explicit values, different order.
+//
+enum EnumExplicit1 { EnumExplicit11 = 1, EnumExplicit13 = 3, EnumExplicit12 = 2 };
+
+//
+// TEST: Enum with different explicit values.
+//
+enum EnumExplicit2 { EnumExplicit21 = 1, EnumExplicit22 = 3, EnumExplicit23 };
+
+//
+// TEST: Enum with explicit values, removed enumerator.
+//
+enum EnumExplicit3 { EnumExplicit31 = 1, EnumExplicit32 = 2};
+
+//
+// TEST: Change to a different type
+//
+class Enum4 {};
+
+//
+// TEST: Same
+//
+sequence<int> Sequence1;
+
+//
+// TEST: Change sequence type
+//
+sequence<short> Sequence2;
+
+//
+// TEST: Change to a different type
+//
+class Sequence3 {};
+
+//
+// TEST: Same
+//
+dictionary<string, int> Dictionary1;
+
+//
+// TEST: Change key type
+//
+dictionary<long, int> Dictionary2;
+
+//
+// TEST: Change value type
+//
+dictionary<string, bool> Dictionary3;
+
+//
+// TEST: Change to a different type
+//
+class Dictionary4 {};
+
+//
+// TEST: Same
+//
+struct Struct1
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Add member
+//
+struct Struct2
+{
+ string str;
+ bool b;
+ float f;
+};
+
+//
+// TEST: Change member type
+//
+struct Struct3
+{
+ string str;
+ double b;
+};
+
+//
+// TEST: Remove member
+//
+struct Struct4
+{
+ bool b;
+};
+
+//
+// TEST: Change to a different type
+//
+class Struct5 {};
+
+//
+// TEST: Same
+//
+interface Interface1
+{
+};
+
+//
+// TEST: Change interface to class
+//
+class Interface2
+{
+};
+
+//
+// TEST: Add base interface
+//
+interface Interface3 extends Interface1
+{
+};
+
+//
+// TEST: Add operation
+//
+interface Interface4
+{
+ void opInterface4();
+};
+
+//
+// TEST: Same
+//
+class EmptyClass1
+{
+};
+
+//
+// TEST: Add data member
+//
+class EmptyClass2
+{
+ double d;
+};
+
+//
+// TEST: Add operation
+//
+class EmptyClass3
+{
+ void newOp();
+};
+
+//
+// TEST: Add base class
+//
+class EmptyClass4 extends EmptyClass1
+{
+};
+
+//
+// TEST: Add interface
+//
+class EmptyClass5 implements Interface1
+{
+};
+
+//
+// TEST: Same
+//
+class SimpleClass1
+{
+ string str;
+ float f;
+};
+
+//
+// TEST: Add operation
+//
+class SimpleClass2
+{
+ string str;
+ float f;
+ void newOp();
+};
+
+//
+// TEST: Rename member
+//
+class SimpleClass3
+{
+ string str;
+ float g;
+};
+
+//
+// TEST: Add member
+//
+class SimpleClass4
+{
+ string str;
+ float f;
+ bool b;
+};
+
+//
+// TEST: Remove member
+//
+class SimpleClass5
+{
+ string str;
+};
+
+//
+// TEST: Reorder members
+//
+class SimpleClass6
+{
+ float f;
+ string str;
+};
+
+//
+// TEST: Change member type
+//
+class SimpleClass7
+{
+ string str;
+ double f;
+};
+
+//
+// TEST: Same
+//
+exception Exception1
+{
+ string str;
+ bool b;
+};
+
+//
+// TEST: Add member
+//
+exception Exception2
+{
+ string str;
+ bool b;
+ float f;
+};
+
+//
+// TEST: Change member type
+//
+exception Exception3
+{
+ string str;
+ double b;
+};
+
+//
+// TEST: Remove member
+//
+exception Exception4
+{
+ bool b;
+};
+
+//
+// TEST: Add base exception
+//
+exception Exception5 extends Exception1
+{
+};
+
+//
+// TEST: Change to a different type
+//
+class Exception6 {};
+
+//
+// TEST: Exception with optional members.
+//
+exception OptionalEx0
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Exception with optional members, different order, same tags.
+//
+exception OptionalEx1
+{
+ string firstName;
+ optional(2) string emailAddress;
+ optional(1) string secondName;
+};
+
+//
+// TEST: Exception with different optional members.
+//
+exception OptionalEx2
+{
+ string firstName;
+ optional(1) string secondName;
+ string emailAddress;
+};
+
+//
+// TEST: Exception with different optional members.
+//
+exception OptionalEx3
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+ optional(3) string phoneNumber;
+};
+
+//
+// TEST: Exception with optional members using different tags.
+//
+exception OptionalEx4
+{
+ string firstName;
+ optional(2) string secondName;
+ optional(1) string emailAddress;
+};
+
+//
+// TEST: Same
+//
+class BaseClass1
+{
+ void baseOp1();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Change return type
+//
+class BaseClass2
+{
+ int baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add parameter
+//
+class BaseClass3
+{
+ void baseOp(Object o);
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add exception
+//
+class BaseClass4
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1, Exception2;
+};
+
+//
+// TEST: Change out parameter to in parameter
+//
+class BaseClass5
+{
+ void baseOp();
+ void baseOp2(int i, string s) throws Exception1;
+};
+
+//
+// TEST: Remove parameter
+//
+class BaseClass6
+{
+ void baseOp();
+ void baseOp2(out string s) throws Exception1;
+};
+
+//
+// TEST: Remove exception
+//
+class BaseClass7
+{
+ void baseOp();
+ void baseOp2(int i, out string s);
+};
+
+//
+// TEST: Remove operation
+//
+class BaseClass8
+{
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add base class
+//
+class BaseClass9 extends EmptyClass1
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add interface
+//
+class BaseClass10 implements Interface1
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Add base class and interface
+//
+class BaseClass11 extends EmptyClass1 implements Interface1
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Class with compact id
+//
+class Compact1(1)
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Derived from class with compact id
+//
+class Derived1 extends Compact1
+{
+};
+
+//
+// TEST: Same class names but different compact id
+//
+class Compact2(3)
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+};
+
+//
+// TEST: Class with optional members.
+//
+class Optional0
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+};
+
+//
+// TEST: Class with optional members, different order, same tags.
+//
+class Optional1
+{
+ string firstName;
+ optional(2) string emailAddress;
+ optional(1) string secondName;
+};
+
+//
+// TEST: Class with different optional members.
+//
+class Optional2
+{
+ string firstName;
+ optional(1) string secondName;
+ string emailAddress;
+};
+
+//
+// TEST: Class with different optional members.
+//
+class Optional3
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+ optional(3) string phoneNumber;
+};
+
+//
+// TEST: Class with optional members using different tags.
+//
+class Optional4
+{
+ string firstName;
+ optional(2) string secondName;
+ optional(1) string emailAddress;
+};
+
+//
+// TEST: Class with optional parameters.
+//
+class OptionalParameters0
+{
+ void op1(string firstName, optional(1) string secondName,
+ optional(2) string emailAddress);
+};
+
+//
+// TEST: Class with optional parameters, different order.
+//
+class OptionalParameters1
+{
+ void op1(string firstName, optional(2) string emailAddress,
+ optional(1) string secondName);
+};
+
+//
+// TEST: Class with optional parameters, different tags.
+//
+class OptionalParameters2
+{
+ void op1(string firstName, optional(2) string emailAddress,
+ optional(1) string secondName);
+};
+
+//
+// TEST: Class with different optional parameters.
+//
+class OptionalParameters3
+{
+ void op1(string firstName, string emailAddress,
+ optional(1) string secondName);
+};
+
+//
+// TEST: Class with optional return type.
+//
+class OptionalReturn0
+{
+ optional(1) int op();
+};
+
+//
+// TEST: Class that changes optional return type.
+//
+class OptionalReturn2
+{
+ int op();
+};
+
+//
+// TEST: Local
+//
+local enum LocalEnum { LocalEnum1, LocalEnum2, LocalEnum3 };
+
+//
+// TEST: Local
+//
+local sequence<string> LocalSequence;
+
+//
+// TEST: Local
+//
+local dictionary<string, string> LocalDictionary;
+
+//
+// TEST: Local
+//
+local struct LocalStruct
+{
+ string str;
+};
+
+//
+// TEST: Local
+//
+local class LocalClass
+{
+};
+
+};
diff --git a/python/test/Ice/checksum/Server.py b/python/test/Ice/checksum/Server.py
new file mode 100755
index 00000000000..424df6a4826
--- /dev/null
+++ b/python/test/Ice/checksum/Server.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+slice_dir = Ice.getSliceDir()
+if not slice_dir:
+ print(sys.argv[0] + ': Slice directory not found.')
+ sys.exit(1)
+
+Ice.loadSlice("'-I" + slice_dir + "' --checksum Test.ice STypes.ice")
+import Test
+
+class ChecksumI(Test.Checksum):
+ def getSliceChecksums(self, current=None):
+ return Ice.sliceChecksums
+
+ 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")
+ object = ChecksumI()
+ adapter.add(object, communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/checksum/Test.ice b/python/test/Ice/checksum/Test.ice
new file mode 100644
index 00000000000..21639acff0f
--- /dev/null
+++ b/python/test/Ice/checksum/Test.ice
@@ -0,0 +1,24 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/SliceChecksumDict.ice>
+
+module Test
+{
+
+interface Checksum
+{
+ idempotent Ice::SliceChecksumDict getSliceChecksums();
+
+ void shutdown();
+};
+
+};
diff --git a/python/test/Ice/checksum/run.py b/python/test/Ice/checksum/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/checksum/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/custom/AllTests.py b/python/test/Ice/custom/AllTests.py
new file mode 100644
index 00000000000..dd3a1437f90
--- /dev/null
+++ b/python/test/Ice/custom/AllTests.py
@@ -0,0 +1,118 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 sys, string, re, traceback, Ice, Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ ref = "test:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+
+ custom = Test.CustomPrx.checkedCast(base)
+ test(custom)
+
+ byteList = [1, 2, 3, 4, 5]
+ if sys.version_info[0] == 2:
+ byteString = ''.join(map(chr, byteList))
+ else:
+ byteString = bytes(byteList)
+ stringList = ['s1', 's2', 's3']
+
+ sys.stdout.write("testing custom sequences... ")
+ sys.stdout.flush()
+
+ (r, b2) = custom.opByteString1(byteString)
+ if sys.version_info[0] == 2:
+ test(isinstance(r, str))
+ test(isinstance(b2, str))
+ else:
+ test(isinstance(r, bytes))
+ test(isinstance(b2, bytes))
+ test(r == byteString)
+ test(b2 == byteString)
+
+ (r, b2) = custom.opByteString2(byteString)
+ test(isinstance(r, tuple))
+ test(isinstance(b2, list))
+ for i in range(0, len(byteList)):
+ test(r[i] == byteList[i])
+ test(b2[i] == byteList[i])
+
+ (r, b2) = custom.opByteList1(byteList)
+ test(isinstance(r, list))
+ test(isinstance(b2, list))
+ for i in range(0, len(byteList)):
+ test(r[i] == byteList[i])
+ test(b2[i] == byteList[i])
+
+ (r, b2) = custom.opByteList2(byteList)
+ if sys.version_info[0] == 2:
+ test(isinstance(r, str))
+ else:
+ test(isinstance(r, bytes))
+ test(isinstance(b2, tuple))
+ test(r == byteString)
+ for i in range(0, len(byteList)):
+ test(b2[i] == byteList[i])
+
+ (r, b2) = custom.opStringList1(stringList)
+ test(isinstance(r, list))
+ test(isinstance(b2, list))
+ test(r == stringList)
+ test(b2 == stringList)
+
+ (r, b2) = custom.opStringList2(stringList)
+ test(isinstance(r, tuple))
+ test(isinstance(b2, tuple))
+ for i in range(0, len(stringList)):
+ test(r[i] == stringList[i])
+ test(b2[i] == stringList[i])
+
+ (r, b2) = custom.opStringTuple1(stringList)
+ test(isinstance(r, tuple))
+ test(isinstance(b2, tuple))
+ for i in range(0, len(stringList)):
+ test(r[i] == stringList[i])
+ test(b2[i] == stringList[i])
+
+ (r, b2) = custom.opStringTuple2(stringList)
+ test(isinstance(r, list))
+ test(isinstance(b2, list))
+ test(r == stringList)
+ test(b2 == stringList)
+
+ s = Test.S()
+ s.b1 = byteList;
+ s.b2 = byteList;
+ s.b3 = byteList;
+ s.b4 = byteList;
+ s.s1 = stringList;
+ s.s2 = stringList;
+ s.s3 = stringList;
+ s.s4 = stringList;
+ custom.sendS(s)
+
+ c = Test.C()
+ c.b1 = byteList;
+ c.b2 = byteList;
+ c.b3 = byteList;
+ c.b4 = byteList;
+ c.s1 = stringList;
+ c.s2 = stringList;
+ c.s3 = stringList;
+ c.s4 = stringList;
+ custom.sendC(c)
+
+ print("ok")
+
+ return custom
diff --git a/python/test/Ice/custom/Client.py b/python/test/Ice/custom/Client.py
new file mode 100755
index 00000000000..bce846df40f
--- /dev/null
+++ b/python/test/Ice/custom/Client.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, AllTests
+
+def run(args, communicator):
+ custom = AllTests.allTests(communicator)
+ custom.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/custom/Server.py b/python/test/Ice/custom/Server.py
new file mode 100755
index 00000000000..af0f49ebb76
--- /dev/null
+++ b/python/test/Ice/custom/Server.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class CustomI(Test.Custom):
+ def opByteString1(self, b1, current=None):
+ if sys.version_info[0] == 2:
+ test(isinstance(b1, str))
+ else:
+ test(isinstance(b1, bytes))
+ return (b1, b1)
+
+ def opByteString2(self, b1, current=None):
+ test(isinstance(b1, list))
+ return (b1, b1)
+
+ def opByteList1(self, b1, current=None):
+ test(isinstance(b1, list))
+ return (b1, b1)
+
+ def opByteList2(self, b1, current=None):
+ test(isinstance(b1, tuple))
+ return (b1, b1)
+
+ def opStringList1(self, s1, current=None):
+ test(isinstance(s1, list))
+ return (s1, s1)
+
+ def opStringList2(self, s1, current=None):
+ test(isinstance(s1, tuple))
+ return (s1, s1)
+
+ def opStringTuple1(self, s1, current=None):
+ test(isinstance(s1, tuple))
+ return (s1, s1)
+
+ def opStringTuple2(self, s1, current=None):
+ test(isinstance(s1, list))
+ return (s1, s1)
+
+ def sendS(self, val, current=None):
+ if sys.version_info[0] == 2:
+ test(isinstance(val.b1, str))
+ else:
+ test(isinstance(val.b1, bytes))
+ test(isinstance(val.b2, list))
+ if sys.version_info[0] == 2:
+ test(isinstance(val.b3, str))
+ else:
+ test(isinstance(val.b3, bytes))
+ test(isinstance(val.b4, list))
+ test(isinstance(val.s1, list))
+ test(isinstance(val.s2, tuple))
+ test(isinstance(val.s3, tuple))
+ test(isinstance(val.s4, list))
+
+ def sendC(self, val, current=None):
+ if sys.version_info[0] == 2:
+ test(isinstance(val.b1, str))
+ else:
+ test(isinstance(val.b1, bytes))
+ test(isinstance(val.b2, list))
+ if sys.version_info[0] == 2:
+ test(isinstance(val.b3, str))
+ else:
+ test(isinstance(val.b3, bytes))
+ test(isinstance(val.b4, list))
+ test(isinstance(val.s1, list))
+ test(isinstance(val.s2, tuple))
+ test(isinstance(val.s3, tuple))
+ test(isinstance(val.s4, list))
+
+ 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")
+ object = CustomI()
+ adapter.add(object, communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/custom/Test.ice b/python/test/Ice/custom/Test.ice
new file mode 100644
index 00000000000..aa68e90f1c3
--- /dev/null
+++ b/python/test/Ice/custom/Test.ice
@@ -0,0 +1,67 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+ sequence<byte> ByteString; /* By default, sequence<byte> is received as a string. */
+ ["python:seq:list"] sequence<byte> ByteList;
+
+ sequence<string> StringList; /* By default, a sequence is received as a list. */
+ ["python:seq:tuple"] sequence<string> StringTuple;
+
+ struct S
+ {
+ ByteString b1;
+ ["python:seq:list"] ByteString b2;
+ ["python:seq:default"] ByteList b3;
+ ByteList b4;
+ StringList s1;
+ ["python:seq:tuple"] StringList s2;
+ StringTuple s3;
+ ["python:seq:default"] StringTuple s4;
+ };
+
+ class C
+ {
+ ByteString b1;
+ ["python:seq:list"] ByteString b2;
+ ["python:seq:default"] ByteList b3;
+ ByteList b4;
+ StringList s1;
+ ["python:seq:tuple"] StringList s2;
+ StringTuple s3;
+ ["python:seq:default"] StringTuple s4;
+ };
+
+ interface Custom
+ {
+ ByteString opByteString1(ByteString b1, out ByteString b2);
+ ["python:seq:tuple"] ByteString opByteString2(["python:seq:list"] ByteString b1,
+ out ["python:seq:list"] ByteString b2);
+
+ ByteList opByteList1(ByteList b1, out ByteList b2);
+ ["python:seq:default"] ByteList opByteList2(["python:seq:tuple"] ByteList b1,
+ out ["python:seq:tuple"] ByteList b2);
+
+ StringList opStringList1(StringList s1, out StringList s2);
+ ["python:seq:tuple"] StringList opStringList2(["python:seq:tuple"] StringList s1,
+ out ["python:seq:tuple"] StringList s2);
+
+ StringTuple opStringTuple1(StringTuple s1, out StringTuple s2);
+ ["python:seq:list"] StringTuple opStringTuple2(["python:seq:list"] StringTuple s1,
+ out ["python:seq:default"] StringTuple s2);
+
+ void sendS(S val);
+ void sendC(C val);
+
+ void shutdown();
+ };
+};
diff --git a/python/test/Ice/custom/run.py b/python/test/Ice/custom/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/custom/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/defaultServant/AllTests.py b/python/test/Ice/defaultServant/AllTests.py
new file mode 100644
index 00000000000..2b3e1533d84
--- /dev/null
+++ b/python/test/Ice/defaultServant/AllTests.py
@@ -0,0 +1,126 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, MyObjectI, sys
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+
+ oa = communicator.createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost")
+ oa.activate()
+
+ servant = MyObjectI.MyObjectI()
+
+ # Register default servant with category "foo"
+ oa.addDefaultServant(servant, "foo")
+
+ # Start test
+ sys.stdout.write("testing single category... ")
+ sys.stdout.flush()
+
+ r = oa.findDefaultServant("foo")
+ test(r == servant)
+
+ r = oa.findDefaultServant("bar")
+ test(r == None)
+
+ identity = Ice.Identity()
+ identity.category = "foo"
+
+ names = ( "foo", "bar", "x", "y", "abcdefg" )
+
+ for idx in range(0, 5):
+ identity.name = names[idx]
+ prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
+ prx.ice_ping()
+ test(prx.getName() == names[idx])
+
+ identity.name = "ObjectNotExist"
+ prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
+ try:
+ prx.ice_ping()
+ test(false)
+ except Ice.ObjectNotExistException:
+ # Expected
+ pass
+
+ try:
+ prx.getName()
+ test(false)
+ except Ice.ObjectNotExistException:
+ # Expected
+ pass
+
+ identity.name = "FacetNotExist"
+ prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
+ try:
+ prx.ice_ping()
+ test(false)
+ except Ice.FacetNotExistException:
+ # Expected
+ pass
+
+ try:
+ prx.getName()
+ test(false)
+ except Ice.FacetNotExistException:
+ # Expected
+ pass
+
+ identity.category = "bar"
+ for idx in range(0, 5):
+ identity.name = names[idx]
+ prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
+
+ try:
+ prx.ice_ping()
+ test(false)
+ except Ice.ObjectNotExistException:
+ # Expected
+ pass
+
+ try:
+ prx.getName()
+ test(false)
+ except Ice.ObjectNotExistException:
+ # Expected
+ pass
+
+ oa.removeDefaultServant("foo")
+ identity.category = "foo"
+ prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
+ try:
+ prx.ice_ping()
+ except Ice.ObjectNotExistException:
+ # Expected
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing default category... ")
+ sys.stdout.flush()
+
+ oa.addDefaultServant(servant, "")
+
+ r = oa.findDefaultServant("bar")
+ test(r == None)
+
+ r = oa.findDefaultServant("")
+ test(r == servant)
+
+ for idx in range(0, 5):
+ identity.name = names[idx]
+ prx = Test.MyObjectPrx.uncheckedCast(oa.createProxy(identity))
+ prx.ice_ping()
+ test(prx.getName() == names[idx])
+
+ print("ok")
diff --git a/python/test/Ice/defaultServant/Client.py b/python/test/Ice/defaultServant/Client.py
new file mode 100755
index 00000000000..7cc8180a8fc
--- /dev/null
+++ b/python/test/Ice/defaultServant/Client.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 AllTests
+
+def run(args, communicator):
+ AllTests.allTests(communicator)
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/defaultServant/MyObjectI.py b/python/test/Ice/defaultServant/MyObjectI.py
new file mode 100644
index 00000000000..97cbd4bbf3d
--- /dev/null
+++ b/python/test/Ice/defaultServant/MyObjectI.py
@@ -0,0 +1,29 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+class MyObjectI(Test.MyObject):
+ def ice_ping(self, current=None):
+ name = current.id.name
+
+ if name == "ObjectNotExist":
+ raise Ice.ObjectNotExistException()
+ elif name == "FacetNotExist":
+ raise Ice.FacetNotExistException()
+
+ def getName(self, current=None):
+ name = current.id.name
+
+ if name == "ObjectNotExist":
+ raise Ice.ObjectNotExistException()
+ elif name == "FacetNotExist":
+ raise Ice.FacetNotExistException()
+
+ return name
diff --git a/python/test/Ice/defaultServant/Test.ice b/python/test/Ice/defaultServant/Test.ice
new file mode 100644
index 00000000000..cc90e550721
--- /dev/null
+++ b/python/test/Ice/defaultServant/Test.ice
@@ -0,0 +1,20 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface MyObject
+{
+ string getName();
+};
+
+};
diff --git a/python/test/Ice/defaultServant/run.py b/python/test/Ice/defaultServant/run.py
new file mode 100755
index 00000000000..4268e9283e0
--- /dev/null
+++ b/python/test/Ice/defaultServant/run.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+sys.stdout.write("starting client... ")
+sys.stdout.flush()
+clientProc = TestUtil.startClient("Client.py", startReader = False)
+print("ok")
+clientProc.startReader()
+
+clientProc.waitTestSuccess()
diff --git a/python/test/Ice/defaultValue/AllTests.py b/python/test/Ice/defaultValue/AllTests.py
new file mode 100644
index 00000000000..bc529c4b90e
--- /dev/null
+++ b/python/test/Ice/defaultValue/AllTests.py
@@ -0,0 +1,184 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests():
+
+ sys.stdout.write("testing default values... ")
+ sys.stdout.flush()
+
+ v = Test.Struct1()
+ test(not v.boolFalse)
+ test(v.boolTrue)
+ test(v.b == 254)
+ test(v.s == 16000)
+ test(v.i == 3)
+ test(v.l == 4)
+ test(v.f == 5.1)
+ test(v.d == 6.2)
+ test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
+ test(v.c1 == Test.Color.red)
+ test(v.c2 == Test.Color.green)
+ test(v.c3 == Test.Color.blue)
+ test(v.nc1 == Test.Nested.Color.red)
+ test(v.nc2 == Test.Nested.Color.green)
+ test(v.nc3 == Test.Nested.Color.blue)
+ test(v.noDefault == '')
+ test(v.zeroI == 0)
+ test(v.zeroL == 0)
+ test(v.zeroF == 0)
+ test(v.zeroDotF == 0)
+ test(v.zeroD == 0)
+ test(v.zeroDotD == 0)
+
+ v = Test.Struct2()
+ test(v.boolTrue == Test.ConstBool)
+ test(v.b == Test.ConstByte)
+ test(v.s == Test.ConstShort)
+ test(v.i == Test.ConstInt)
+ test(v.l == Test.ConstLong)
+ test(v.f == Test.ConstFloat)
+ test(v.d == Test.ConstDouble)
+ test(v.str == Test.ConstString)
+ test(v.c1 == Test.ConstColor1)
+ test(v.c2 == Test.ConstColor2)
+ test(v.c3 == Test.ConstColor3)
+ test(v.nc1 == Test.ConstNestedColor1)
+ test(v.nc2 == Test.ConstNestedColor2)
+ test(v.nc3 == Test.ConstNestedColor3)
+ test(v.zeroI == Test.ConstZeroI)
+ test(v.zeroL == Test.ConstZeroL)
+ test(v.zeroF == Test.ConstZeroF)
+ test(v.zeroDotF == Test.ConstZeroDotF)
+ test(v.zeroD == Test.ConstZeroD)
+ test(v.zeroDotD == Test.ConstZeroDotD)
+
+ v = Test.Base()
+ test(not v.boolFalse)
+ test(v.boolTrue)
+ test(v.b == 1)
+ test(v.s == 2)
+ test(v.i == 3)
+ test(v.l == 4)
+ test(v.f == 5.1)
+ test(v.d == 6.2)
+ test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
+ test(v.noDefault == '')
+ test(v.zeroI == 0)
+ test(v.zeroL == 0)
+ test(v.zeroF == 0)
+ test(v.zeroDotF == 0)
+ test(v.zeroD == 0)
+ test(v.zeroDotD == 0)
+
+ v = Test.Derived()
+ test(not v.boolFalse)
+ test(v.boolTrue)
+ test(v.b == 1)
+ test(v.s == 2)
+ test(v.i == 3)
+ test(v.l == 4)
+ test(v.f == 5.1)
+ test(v.d == 6.2)
+ test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
+ test(v.c1 == Test.Color.red)
+ test(v.c2 == Test.Color.green)
+ test(v.c3 == Test.Color.blue)
+ test(v.nc1 == Test.Nested.Color.red)
+ test(v.nc2 == Test.Nested.Color.green)
+ test(v.nc3 == Test.Nested.Color.blue)
+ test(v.noDefault == '')
+ test(v.zeroI == 0)
+ test(v.zeroL == 0)
+ test(v.zeroF == 0)
+ test(v.zeroDotF == 0)
+ test(v.zeroD == 0)
+ test(v.zeroDotD == 0)
+
+ v = Test.BaseEx()
+ test(not v.boolFalse)
+ test(v.boolTrue)
+ test(v.b == 1)
+ test(v.s == 2)
+ test(v.i == 3)
+ test(v.l == 4)
+ test(v.f == 5.1)
+ test(v.d == 6.2)
+ test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
+ test(v.noDefault == '')
+ test(v.zeroI == 0)
+ test(v.zeroL == 0)
+ test(v.zeroF == 0)
+ test(v.zeroDotF == 0)
+ test(v.zeroD == 0)
+ test(v.zeroDotD == 0)
+
+ v = Test.DerivedEx()
+ test(not v.boolFalse)
+ test(v.boolTrue)
+ test(v.b == 1)
+ test(v.s == 2)
+ test(v.i == 3)
+ test(v.l == 4)
+ test(v.f == 5.1)
+ test(v.d == 6.2)
+ test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
+ test(v.noDefault == '')
+ test(v.c1 == Test.Color.red)
+ test(v.c2 == Test.Color.green)
+ test(v.c3 == Test.Color.blue)
+ test(v.nc1 == Test.Nested.Color.red)
+ test(v.nc2 == Test.Nested.Color.green)
+ test(v.nc3 == Test.Nested.Color.blue)
+ test(v.zeroI == 0)
+ test(v.zeroL == 0)
+ test(v.zeroF == 0)
+ test(v.zeroDotF == 0)
+ test(v.zeroD == 0)
+ test(v.zeroDotD == 0)
+
+ print("ok")
+
+ sys.stdout.write("testing default constructor... ")
+ sys.stdout.flush()
+ v = Test.StructNoDefaults()
+ test(v.bo == False)
+ test(v.b == 0)
+ test(v.s == 0)
+ test(v.i == 0)
+ test(v.l == 0)
+ test(v.f == 0.0)
+ test(v.d == 0.0)
+ test(v.str == '')
+ test(v.c1 == Test.Color.red)
+ test(v.bs is None)
+ test(v.iseq is None)
+ test(isinstance(v.st, Test.InnerStruct));
+ test(v.dict is None);
+
+ e = Test.ExceptionNoDefaults()
+ test(e.str == '')
+ test(e.c1 == Test.Color.red)
+ test(e.bs is None)
+ test(isinstance(e.st, Test.InnerStruct));
+ test(e.dict is None);
+
+ c = Test.ClassNoDefaults()
+ test(c.str == '')
+ test(c.c1 == Test.Color.red)
+ test(c.bs is None)
+ test(isinstance(c.st, Test.InnerStruct));
+ test(c.dict is None);
+
+ print("ok")
diff --git a/python/test/Ice/defaultValue/Client.py b/python/test/Ice/defaultValue/Client.py
new file mode 100755
index 00000000000..061672f46dc
--- /dev/null
+++ b/python/test/Ice/defaultValue/Client.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 AllTests
+
+def run(args):
+ AllTests.allTests()
+ return True
+
+try:
+ status = run(sys.argv)
+except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/defaultValue/Test.ice b/python/test/Ice/defaultValue/Test.ice
new file mode 100644
index 00000000000..101a42883f3
--- /dev/null
+++ b/python/test/Ice/defaultValue/Test.ice
@@ -0,0 +1,208 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+enum Color { red, green, blue };
+
+module Nested
+{
+
+enum Color { red, green, blue };
+
+};
+
+
+struct Struct1
+{
+ bool boolFalse = false;
+ bool boolTrue = true;
+ byte b = 254;
+ short s = 16000;
+ int i = 3;
+ long l = 4;
+ float f = 5.1;
+ double d = 6.2;
+ string str = "foo \\ \"bar\n \r\n\t\v\f\a\b\? \007 \x07";
+ Color c1 = ::Test::red;
+ Color c2 = Test::green;
+ Color c3 = blue;
+ Nested::Color nc1 = ::Test::Nested::red;
+ Nested::Color nc2 = Nested::green;
+ Nested::Color nc3 = Nested::blue;
+ string noDefault;
+ int zeroI = 0;
+ long zeroL = 0;
+ float zeroF = 0;
+ float zeroDotF = 0.0;
+ double zeroD = 0;
+ double zeroDotD = 0;
+};
+
+const bool ConstBool = true;
+const byte ConstByte = 254;
+const short ConstShort = 16000;
+const int ConstInt = 3;
+const long ConstLong = 4;
+const float ConstFloat = 5.1;
+const double ConstDouble = 6.2;
+const string ConstString = "foo \\ \"bar\n \r\n\t\v\f\a\b\? \007 \x07";
+const Color ConstColor1 = ::Test::red;
+const Color ConstColor2 = Test::green;
+const Color ConstColor3 = blue;
+const Nested::Color ConstNestedColor1 = ::Test::Nested::red;
+const Nested::Color ConstNestedColor2 = Test::Nested::green;
+const Nested::Color ConstNestedColor3 = Nested::blue;
+const int ConstZeroI = 0;
+const long ConstZeroL = 0;
+const float ConstZeroF = 0;
+const float ConstZeroDotF = 0.0;
+const double ConstZeroD = 0;
+const double ConstZeroDotD = 0;
+
+struct Struct2
+{
+ bool boolTrue = ConstBool;
+ byte b = ConstByte;
+ short s = ConstShort;
+ int i = ConstInt;
+ long l = ConstLong;
+ float f = ConstFloat;
+ double d = ConstDouble;
+ string str = ConstString;
+ Color c1 = ConstColor1;
+ Color c2 = ConstColor2;
+ Color c3 = ConstColor3;
+ Nested::Color nc1 = ConstNestedColor1;
+ Nested::Color nc2 = ConstNestedColor2;
+ Nested::Color nc3 = ConstNestedColor3;
+ int zeroI = ConstZeroI;
+ long zeroL = ConstZeroL;
+ float zeroF = ConstZeroF;
+ float zeroDotF = ConstZeroDotF;
+ double zeroD = ConstZeroD;
+ double zeroDotD = ConstZeroDotD;
+};
+
+class Base
+{
+ bool boolFalse = false;
+ bool boolTrue = true;
+ byte b = 1;
+ short s = 2;
+ int i = 3;
+ long l = 4;
+ float f = 5.1;
+ double d = 6.2;
+ string str = "foo \\ \"bar\n \r\n\t\v\f\a\b\? \007 \x07";
+ string noDefault;
+ int zeroI = 0;
+ long zeroL = 0;
+ float zeroF = 0;
+ float zeroDotF = 0.0;
+ double zeroD = 0;
+ double zeroDotD = 0;
+};
+
+class Derived extends Base
+{
+ Color c1 = ::Test::red;
+ Color c2 = Test::green;
+ Color c3 = blue;
+ Nested::Color nc1 = ::Test::Nested::red;
+ Nested::Color nc2 = Nested::green;
+ Nested::Color nc3 = Nested::blue;
+};
+
+exception BaseEx
+{
+ bool boolFalse = false;
+ bool boolTrue = true;
+ byte b = 1;
+ short s = 2;
+ int i = 3;
+ long l = 4;
+ float f = 5.1;
+ double d = 6.2;
+ string str = "foo \\ \"bar\n \r\n\t\v\f\a\b\? \007 \x07";
+ string noDefault;
+ int zeroI = 0;
+ long zeroL = 0;
+ float zeroF = 0;
+ float zeroDotF = 0.0;
+ double zeroD = 0;
+ double zeroDotD = 0;
+};
+
+exception DerivedEx extends BaseEx
+{
+ Color c1 = ConstColor1;
+ Color c2 = ConstColor2;
+ Color c3 = ConstColor3;
+ Nested::Color nc1 = ConstNestedColor1;
+ Nested::Color nc2 = ConstNestedColor2;
+ Nested::Color nc3 = ConstNestedColor3;
+};
+
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq iseq;
+ IntStringDict dict;
+ InnerStruct st;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+};
diff --git a/python/test/Ice/defaultValue/run.py b/python/test/Ice/defaultValue/run.py
new file mode 100755
index 00000000000..4268e9283e0
--- /dev/null
+++ b/python/test/Ice/defaultValue/run.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+sys.stdout.write("starting client... ")
+sys.stdout.flush()
+clientProc = TestUtil.startClient("Client.py", startReader = False)
+print("ok")
+clientProc.startReader()
+
+clientProc.waitTestSuccess()
diff --git a/python/test/Ice/enums/AllTests.py b/python/test/Ice/enums/AllTests.py
new file mode 100644
index 00000000000..a5dae46cff9
--- /dev/null
+++ b/python/test/Ice/enums/AllTests.py
@@ -0,0 +1,128 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 sys, string, re, traceback, Ice, Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ ref = "test:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+
+ proxy = Test.TestIntfPrx.checkedCast(base)
+ test(proxy)
+
+ sys.stdout.write("testing enum values... ")
+ sys.stdout.flush()
+
+ test(Test.ByteEnum.benum1.value == 0);
+ test(Test.ByteEnum.benum2.value == 1);
+ test(Test.ByteEnum.benum3.value == Test.ByteConst1);
+ test(Test.ByteEnum.benum4.value == Test.ByteConst1 + 1);
+ test(Test.ByteEnum.benum5.value == Test.ShortConst1);
+ test(Test.ByteEnum.benum6.value == Test.ShortConst1 + 1);
+ test(Test.ByteEnum.benum7.value == Test.IntConst1);
+ test(Test.ByteEnum.benum8.value == Test.IntConst1 + 1);
+ test(Test.ByteEnum.benum9.value == Test.LongConst1);
+ test(Test.ByteEnum.benum10.value == Test.LongConst1 + 1);
+ test(Test.ByteEnum.benum11.value == Test.ByteConst2);
+
+ test(Test.ByteEnum.valueOf(0) == Test.ByteEnum.benum1);
+ test(Test.ByteEnum.valueOf(1) == Test.ByteEnum.benum2);
+ test(Test.ByteEnum.valueOf(Test.ByteConst1) == Test.ByteEnum.benum3);
+ test(Test.ByteEnum.valueOf(Test.ByteConst1 + 1) == Test.ByteEnum.benum4);
+ test(Test.ByteEnum.valueOf(Test.ShortConst1) == Test.ByteEnum.benum5);
+ test(Test.ByteEnum.valueOf(Test.ShortConst1 + 1) == Test.ByteEnum.benum6);
+ test(Test.ByteEnum.valueOf(Test.IntConst1) == Test.ByteEnum.benum7);
+ test(Test.ByteEnum.valueOf(Test.IntConst1 + 1) == Test.ByteEnum.benum8);
+ test(Test.ByteEnum.valueOf(Test.LongConst1) == Test.ByteEnum.benum9);
+ test(Test.ByteEnum.valueOf(Test.LongConst1 + 1) == Test.ByteEnum.benum10);
+ test(Test.ByteEnum.valueOf(Test.ByteConst2) == Test.ByteEnum.benum11);
+
+ test(Test.ShortEnum.senum1.value == 3);
+ test(Test.ShortEnum.senum2.value == 4);
+ test(Test.ShortEnum.senum3.value == Test.ByteConst1);
+ test(Test.ShortEnum.senum4.value == Test.ByteConst1 + 1);
+ test(Test.ShortEnum.senum5.value == Test.ShortConst1);
+ test(Test.ShortEnum.senum6.value == Test.ShortConst1 + 1);
+ test(Test.ShortEnum.senum7.value == Test.IntConst1);
+ test(Test.ShortEnum.senum8.value == Test.IntConst1 + 1);
+ test(Test.ShortEnum.senum9.value == Test.LongConst1);
+ test(Test.ShortEnum.senum10.value == Test.LongConst1 + 1);
+ test(Test.ShortEnum.senum11.value == Test.ShortConst2);
+
+ test(Test.ShortEnum.valueOf(3) == Test.ShortEnum.senum1);
+ test(Test.ShortEnum.valueOf(4) == Test.ShortEnum.senum2);
+ test(Test.ShortEnum.valueOf(Test.ByteConst1) == Test.ShortEnum.senum3);
+ test(Test.ShortEnum.valueOf(Test.ByteConst1 + 1) == Test.ShortEnum.senum4);
+ test(Test.ShortEnum.valueOf(Test.ShortConst1) == Test.ShortEnum.senum5);
+ test(Test.ShortEnum.valueOf(Test.ShortConst1 + 1) == Test.ShortEnum.senum6);
+ test(Test.ShortEnum.valueOf(Test.IntConst1) == Test.ShortEnum.senum7);
+ test(Test.ShortEnum.valueOf(Test.IntConst1 + 1) == Test.ShortEnum.senum8);
+ test(Test.ShortEnum.valueOf(Test.LongConst1) == Test.ShortEnum.senum9);
+ test(Test.ShortEnum.valueOf(Test.LongConst1 + 1) == Test.ShortEnum.senum10);
+ test(Test.ShortEnum.valueOf(Test.ShortConst2) == Test.ShortEnum.senum11);
+
+ test(Test.IntEnum.ienum1.value == 0);
+ test(Test.IntEnum.ienum2.value == 1);
+ test(Test.IntEnum.ienum3.value == Test.ByteConst1);
+ test(Test.IntEnum.ienum4.value == Test.ByteConst1 + 1);
+ test(Test.IntEnum.ienum5.value == Test.ShortConst1);
+ test(Test.IntEnum.ienum6.value == Test.ShortConst1 + 1);
+ test(Test.IntEnum.ienum7.value == Test.IntConst1);
+ test(Test.IntEnum.ienum8.value == Test.IntConst1 + 1);
+ test(Test.IntEnum.ienum9.value == Test.LongConst1);
+ test(Test.IntEnum.ienum10.value == Test.LongConst1 + 1);
+ test(Test.IntEnum.ienum11.value == Test.IntConst2);
+ test(Test.IntEnum.ienum12.value == Test.LongConst2);
+
+ test(Test.IntEnum.valueOf(0) == Test.IntEnum.ienum1);
+ test(Test.IntEnum.valueOf(1) == Test.IntEnum.ienum2);
+ test(Test.IntEnum.valueOf(Test.ByteConst1) == Test.IntEnum.ienum3);
+ test(Test.IntEnum.valueOf(Test.ByteConst1 + 1) == Test.IntEnum.ienum4);
+ test(Test.IntEnum.valueOf(Test.ShortConst1) == Test.IntEnum.ienum5);
+ test(Test.IntEnum.valueOf(Test.ShortConst1 + 1) == Test.IntEnum.ienum6);
+ test(Test.IntEnum.valueOf(Test.IntConst1) == Test.IntEnum.ienum7);
+ test(Test.IntEnum.valueOf(Test.IntConst1 + 1) == Test.IntEnum.ienum8);
+ test(Test.IntEnum.valueOf(Test.LongConst1) == Test.IntEnum.ienum9);
+ test(Test.IntEnum.valueOf(Test.LongConst1 + 1) == Test.IntEnum.ienum10);
+ test(Test.IntEnum.valueOf(Test.IntConst2) == Test.IntEnum.ienum11);
+ test(Test.IntEnum.valueOf(Test.LongConst2) == Test.IntEnum.ienum12);
+
+ test(Test.SimpleEnum.red.value == 0);
+ test(Test.SimpleEnum.green.value == 1);
+ test(Test.SimpleEnum.blue.value == 2);
+
+ test(Test.SimpleEnum.valueOf(0) == Test.SimpleEnum.red);
+ test(Test.SimpleEnum.valueOf(1) == Test.SimpleEnum.green);
+ test(Test.SimpleEnum.valueOf(2) == Test.SimpleEnum.blue);
+
+ print("ok")
+
+ sys.stdout.write("testing enum operations... ")
+ sys.stdout.flush()
+
+ test(proxy.opByte(Test.ByteEnum.benum1) == (Test.ByteEnum.benum1, Test.ByteEnum.benum1));
+ test(proxy.opByte(Test.ByteEnum.benum11) == (Test.ByteEnum.benum11, Test.ByteEnum.benum11));
+
+ test(proxy.opShort(Test.ShortEnum.senum1) == (Test.ShortEnum.senum1, Test.ShortEnum.senum1));
+ test(proxy.opShort(Test.ShortEnum.senum11) == (Test.ShortEnum.senum11, Test.ShortEnum.senum11));
+
+ test(proxy.opInt(Test.IntEnum.ienum1) == (Test.IntEnum.ienum1, Test.IntEnum.ienum1));
+ test(proxy.opInt(Test.IntEnum.ienum11) == (Test.IntEnum.ienum11, Test.IntEnum.ienum11));
+ test(proxy.opInt(Test.IntEnum.ienum12) == (Test.IntEnum.ienum12, Test.IntEnum.ienum12));
+
+ test(proxy.opSimple(Test.SimpleEnum.green) == (Test.SimpleEnum.green, Test.SimpleEnum.green));
+
+ print("ok")
+
+ return proxy
diff --git a/python/test/Ice/enums/Client.py b/python/test/Ice/enums/Client.py
new file mode 100755
index 00000000000..acff619e914
--- /dev/null
+++ b/python/test/Ice/enums/Client.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, AllTests
+
+def run(args, communicator):
+ proxy = AllTests.allTests(communicator)
+ proxy.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/enums/Server.py b/python/test/Ice/enums/Server.py
new file mode 100755
index 00000000000..f51922e12fc
--- /dev/null
+++ b/python/test/Ice/enums/Server.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class TestIntfI(Test.TestIntf):
+ def opByte(self, b1, current=None):
+ return (b1, b1)
+
+ def opShort(self, s1, current=None):
+ return (s1, s1)
+
+ def opInt(self, i1, current=None):
+ return (i1, i1)
+
+ def opSimple(self, s1, current=None):
+ return (s1, s1)
+
+ 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")
+ object = TestIntfI()
+ adapter.add(object, communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/enums/Test.ice b/python/test/Ice/enums/Test.ice
new file mode 100644
index 00000000000..1cfe8c3eda8
--- /dev/null
+++ b/python/test/Ice/enums/Test.ice
@@ -0,0 +1,88 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+const byte ByteConst1 = 10;
+const short ShortConst1 = 20;
+const int IntConst1 = 30;
+const long LongConst1 = 40;
+
+const byte ByteConst2 = 126;
+const short ShortConst2 = 32766;
+const int IntConst2 = 2147483647;
+const long LongConst2 = 2147483646;
+
+enum ByteEnum
+{
+ benum1,
+ benum2,
+ benum3 = ByteConst1,
+ benum4,
+ benum5 = ShortConst1,
+ benum6,
+ benum7 = IntConst1,
+ benum8,
+ benum9 = LongConst1,
+ benum10,
+ benum11 = ByteConst2
+};
+
+enum ShortEnum
+{
+ senum1 = 3,
+ senum2,
+ senum3 = ByteConst1,
+ senum4,
+ senum5 = ShortConst1,
+ senum6,
+ senum7 = IntConst1,
+ senum8,
+ senum9 = LongConst1,
+ senum10,
+ senum11 = ShortConst2
+};
+
+enum IntEnum
+{
+ ienum1,
+ ienum2,
+ ienum3 = ByteConst1,
+ ienum4,
+ ienum5 = ShortConst1,
+ ienum6,
+ ienum7 = IntConst1,
+ ienum8,
+ ienum9 = LongConst1,
+ ienum10,
+ ienum11 = IntConst2,
+ ienum12 = LongConst2
+};
+
+enum SimpleEnum
+{
+ red,
+ green,
+ blue
+};
+
+interface TestIntf
+{
+ ByteEnum opByte(ByteEnum b1, out ByteEnum b2);
+ ShortEnum opShort(ShortEnum s1, out ShortEnum s2);
+ IntEnum opInt(IntEnum i1, out IntEnum i2);
+ SimpleEnum opSimple(SimpleEnum s1, out SimpleEnum s2);
+
+ void shutdown();
+};
+
+};
diff --git a/python/test/Ice/enums/run.py b/python/test/Ice/enums/run.py
new file mode 100755
index 00000000000..614bfe363bf
--- /dev/null
+++ b/python/test/Ice/enums/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("Running test with 1.0 encoding.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
+
+print("Running test with 1.1 encoding.")
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/exceptions/AllTests.py b/python/test/Ice/exceptions/AllTests.py
new file mode 100644
index 00000000000..4522a0de731
--- /dev/null
+++ b/python/test/Ice/exceptions/AllTests.py
@@ -0,0 +1,721 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, array
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class EmptyI(Test.Empty):
+ pass
+
+class ServantLocatorI(Ice.ServantLocator):
+ def locate(self, current):
+ return None
+
+ def finished(self, current, servant, cookie):
+ pass
+
+ def deactivate(self, category):
+ pass
+
+class ObjectFactoryI(Ice.ObjectFactory):
+ def create(id):
+ return None
+
+ def destroy():
+ pass
+
+class CallbackBase:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def check(self):
+ self._cond.acquire()
+ try:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ finally:
+ self._cond.release()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+class Callback(CallbackBase):
+ def __init__(self, communicator=None):
+ CallbackBase.__init__(self)
+ self._communicator = communicator
+
+ def response(self):
+ test(False)
+
+ def exception_AasA(self, ex):
+ test(isinstance(ex, Test.A))
+ test(ex.aMem == 1)
+ self.called()
+
+ def exception_AorDasAorD(self, ex):
+ try:
+ raise ex
+ except Test.A as ex:
+ test(ex.aMem == 1)
+ except Test.D as ex:
+ test(ex.dMem == -1)
+ except:
+ test(False)
+ self.called()
+
+ def exception_BasB(self, ex):
+ try:
+ raise ex
+ except Test.B as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ test(False)
+ self.called()
+
+ def exception_CasC(self, ex):
+ try:
+ raise ex
+ except Test.C as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ test(False)
+ self.called()
+
+ def exception_ModA(self, ex):
+ try:
+ raise ex
+ except Test.Mod.A as ex:
+ test(ex.aMem == 1)
+ test(ex.a2Mem == 2)
+ except Ice.OperationNotExistException:
+ #
+ # This operation is not supported in Java.
+ #
+ pass
+ except:
+ test(False)
+ self.called()
+
+ def exception_BasA(self, ex):
+ try:
+ raise ex
+ except Test.B as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ test(False)
+ self.called()
+
+ def exception_CasA(self, ex):
+ try:
+ raise ex
+ except Test.C as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ test(False)
+ self.called()
+
+ def exception_CasB(self, ex):
+ try:
+ raise ex
+ except Test.C as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ test(False)
+ self.called()
+
+ def exception_UndeclaredA(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownUserException:
+ pass
+ except:
+ test(False)
+ self.called()
+
+ def exception_UndeclaredB(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownUserException:
+ pass
+ except:
+ test(False)
+ self.called()
+
+ def exception_UndeclaredC(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownUserException:
+ pass
+ except:
+ test(False)
+ self.called()
+
+ def exception_AasAObjectNotExist(self, ex):
+ try:
+ raise ex
+ except Ice.ObjectNotExistException as ex:
+ id = self._communicator.stringToIdentity("does not exist")
+ test(ex.id == id)
+ except:
+ test(False)
+ self.called()
+
+ def exception_AasAFacetNotExist(self, ex):
+ try:
+ raise ex
+ except Ice.FacetNotExistException as ex:
+ test(ex.facet == "no such facet")
+ except:
+ test(False)
+ self.called()
+
+ def exception_noSuchOperation(self, ex):
+ try:
+ raise ex
+ except Ice.OperationNotExistException as ex:
+ test(ex.operation == "noSuchOperation")
+ except:
+ test(False)
+ self.called()
+
+ def exception_LocalException(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownLocalException as ex:
+ pass
+ except Ice.OperationNotExistException as ex:
+ pass
+ except:
+ test(False)
+ self.called()
+
+ def exception_NonIceException(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownException as ex:
+ pass
+ except:
+ test(False)
+ self.called()
+
+def allTests(communicator):
+ sys.stdout.write("testing servant registration exceptions... ")
+ sys.stdout.flush()
+ communicator.getProperties().setProperty("TestAdapter1.Endpoints", "default")
+ adapter = communicator.createObjectAdapter("TestAdapter1")
+ obj = EmptyI()
+ adapter.add(obj, communicator.stringToIdentity("x"))
+ try:
+ adapter.add(obj, communicator.stringToIdentity("x"))
+ test(false)
+ except Ice.AlreadyRegisteredException:
+ pass
+
+ try:
+ adapter.add(obj, communicator.stringToIdentity(""))
+ test(false)
+ except Ice.IllegalIdentityException as ex:
+ test(ex.id.name == "")
+
+ try:
+ adapter.add(None, communicator.stringToIdentity("x"))
+ test(false)
+ except Ice.IllegalServantException:
+ pass
+
+
+ adapter.remove(communicator.stringToIdentity("x"))
+ try:
+ adapter.remove(communicator.stringToIdentity("x"))
+ test(false)
+ except Ice.NotRegisteredException:
+ pass
+
+ adapter.deactivate()
+ print("ok")
+
+ sys.stdout.write("testing servant locator registrations exceptions... ")
+ sys.stdout.flush()
+ communicator.getProperties().setProperty("TestAdapter2.Endpoints", "default")
+ adapter = communicator.createObjectAdapter("TestAdapter2")
+ loc = ServantLocatorI()
+ adapter.addServantLocator(loc, "x")
+ try:
+ adapter.addServantLocator(loc, "x")
+ test(false)
+ except Ice.AlreadyRegisteredException:
+ pass
+
+ adapter.deactivate()
+ print("ok")
+
+ sys.stdout.write("testing object factory registration exception... ")
+ sys.stdout.flush()
+ of = ObjectFactoryI()
+ communicator.addObjectFactory(of, "x")
+ try:
+ communicator.addObjectFactory(of, "x")
+ test(false)
+ except Ice.AlreadyRegisteredException:
+ pass
+ print("ok")
+
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ ref = "thrower:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ thrower = Test.ThrowerPrx.checkedCast(base)
+ test(thrower)
+ test(thrower == base)
+ print("ok")
+
+ sys.stdout.write("catching exact types... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwAasA(1)
+ test(False)
+ except Test.A as ex:
+ test(ex.aMem == 1)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwAorDasAorD(1)
+ test(False)
+ except Test.A as ex:
+ test(ex.aMem == 1)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwAorDasAorD(-1)
+ test(False)
+ except Test.D as ex:
+ test(ex.dMem == -1)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwBasB(1, 2)
+ test(False)
+ except Test.B as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwCasC(1, 2, 3)
+ test(False)
+ except Test.C as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwModA(1, 2)
+ test(False)
+ except Test.Mod.A as ex:
+ test(ex.aMem == 1)
+ test(ex.a2Mem == 2)
+ except Ice.OperationNotExistException:
+ #
+ # This operation is not supported in Java.
+ #
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("catching base types... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwBasB(1, 2)
+ test(False)
+ except Test.A as ex:
+ test(ex.aMem == 1)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwCasC(1, 2, 3)
+ test(False)
+ except Test.B as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwModA(1, 2)
+ test(False)
+ except Test.A as ex:
+ test(ex.aMem == 1)
+ except Ice.OperationNotExistException:
+ #
+ # This operation is not supported in Java.
+ #
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("catching derived types... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwBasA(1, 2)
+ test(False)
+ except Test.B as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwCasA(1, 2, 3)
+ test(False)
+ except Test.C as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwCasB(1, 2, 3)
+ test(False)
+ except Test.C as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ if thrower.supportsUndeclaredExceptions():
+ sys.stdout.write("catching unknown user exception... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwUndeclaredA(1)
+ test(False)
+ except Ice.UnknownUserException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwUndeclaredB(1, 2)
+ test(False)
+ except Ice.UnknownUserException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwUndeclaredC(1, 2, 3)
+ test(False)
+ except Ice.UnknownUserException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+
+ if thrower.ice_getConnection():
+ sys.stdout.write("testing memory limit marshal exception...");
+ sys.stdout.flush();
+
+ try:
+ thrower.throwMemoryLimitException(array.array('B'));
+ test(False)
+ except Ice.MemoryLimitException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwMemoryLimitException(bytearray(20 * 1024)) # 20KB
+ test(False)
+ except Ice.ConnectionLostException:
+ pass
+ except:
+ test(False)
+
+ print("ok");
+
+ sys.stdout.write("catching object not exist exception... ")
+ sys.stdout.flush()
+
+ id = communicator.stringToIdentity("does not exist")
+ try:
+ thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id))
+ thrower2.throwAasA(1)
+# thrower2.ice_ping()
+ test(False)
+ except Ice.ObjectNotExistException as ex:
+ test(ex.id == id)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("catching facet not exist exception... ")
+ sys.stdout.flush()
+
+ try:
+ thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet")
+ try:
+ thrower2.ice_ping()
+ test(False)
+ except Ice.FacetNotExistException as ex:
+ test(ex.facet == "no such facet")
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("catching operation not exist exception... ")
+ sys.stdout.flush()
+
+ try:
+ thrower2 = Test.WrongOperationPrx.uncheckedCast(thrower)
+ thrower2.noSuchOperation()
+ test(False)
+ except Ice.OperationNotExistException as ex:
+ test(ex.operation == "noSuchOperation")
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("catching unknown local exception... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwLocalException()
+ test(False)
+ except Ice.UnknownLocalException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+ try:
+ thrower.throwLocalExceptionIdempotent()
+ test(False)
+ except Ice.UnknownLocalException:
+ pass
+ except Ice.OperationNotExistException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("catching unknown non-Ice exception... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwNonIceException()
+ test(False)
+ except Ice.UnknownException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("testing asynchronous exceptions... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwAfterResponse()
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwAfterException()
+ except Test.A:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("catching exact types with AMI mapping... ")
+ sys.stdout.flush()
+
+ cb = Callback()
+ thrower.begin_throwAasA(1, cb.response, cb.exception_AasA)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwAorDasAorD(1, cb.response, cb.exception_AorDasAorD)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwAorDasAorD(-1, cb.response, cb.exception_AorDasAorD)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwBasB(1, 2, cb.response, cb.exception_BasB)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwCasC(1, 2, 3, cb.response, cb.exception_CasC)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwModA(1, 2, cb.response, cb.exception_ModA)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("catching derived types with AMI mapping... ")
+ sys.stdout.flush()
+
+ cb = Callback()
+ thrower.begin_throwBasA(1, 2, cb.response, cb.exception_BasA)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwCasA(1, 2, 3, cb.response, cb.exception_CasA)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwCasB(1, 2, 3, cb.response, cb.exception_CasB)
+ cb.check()
+
+ print("ok")
+
+ if thrower.supportsUndeclaredExceptions():
+ sys.stdout.write("catching unknown user exception with AMI mapping... ")
+ sys.stdout.flush()
+
+ cb = Callback()
+ thrower.begin_throwUndeclaredA(1, cb.response, cb.exception_UndeclaredA)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwUndeclaredB(1, 2, cb.response, cb.exception_UndeclaredB)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwUndeclaredC(1, 2, 3, cb.response, cb.exception_UndeclaredC)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("catching object not exist exception with AMI mapping... ")
+ sys.stdout.flush()
+
+ id = communicator.stringToIdentity("does not exist")
+ thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id))
+ cb = Callback(communicator)
+ thrower2.begin_throwAasA(1, cb.response, cb.exception_AasAObjectNotExist)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("catching facet not exist exception with AMI mapping... ")
+ sys.stdout.flush()
+
+ thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet")
+ cb = Callback()
+ thrower2.begin_throwAasA(1, cb.response, cb.exception_AasAFacetNotExist)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("catching operation not exist exception with AMI mapping... ")
+ sys.stdout.flush()
+
+ cb = Callback()
+ thrower4 = Test.WrongOperationPrx.uncheckedCast(thrower)
+ thrower4.begin_noSuchOperation(cb.response, cb.exception_noSuchOperation)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("catching unknown local exception with AMI mapping... ")
+ sys.stdout.flush()
+
+ cb = Callback()
+ thrower.begin_throwLocalException(cb.response, cb.exception_LocalException)
+ cb.check()
+
+ cb = Callback()
+ thrower.begin_throwLocalExceptionIdempotent(cb.response, cb.exception_LocalException)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("catching unknown non-Ice exception with AMI mapping... ")
+ sys.stdout.flush()
+
+ cb = Callback()
+ thrower.begin_throwNonIceException(cb.response, cb.exception_NonIceException)
+ cb.check()
+
+ print("ok")
+
+ return thrower
diff --git a/python/test/Ice/exceptions/Client.py b/python/test/Ice/exceptions/Client.py
new file mode 100755
index 00000000000..3f535c2a2d7
--- /dev/null
+++ b/python/test/Ice/exceptions/Client.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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 AllTests
+
+def run(args, communicator):
+ thrower = AllTests.allTests(communicator)
+ thrower.shutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.MessageSizeMax", "10")
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/exceptions/Collocated.py b/python/test/Ice/exceptions/Collocated.py
new file mode 100755
index 00000000000..d60527a3d61
--- /dev/null
+++ b/python/test/Ice/exceptions/Collocated.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI, AllTests
+
+def run(args, communicator):
+ properties = communicator.getProperties()
+ properties.setProperty("Ice.Warn.Dispatch", "0")
+ properties.setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ object = TestI.ThrowerI()
+ adapter.add(object, communicator.stringToIdentity("thrower"))
+ #adapter.activate() // Don't activate OA to ensure collocation is used.
+
+ thrower = AllTests.allTests(communicator)
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.MessageSizeMax", "10")
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/exceptions/Server.py b/python/test/Ice/exceptions/Server.py
new file mode 100755
index 00000000000..ba67f7b1f55
--- /dev/null
+++ b/python/test/Ice/exceptions/Server.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI
+
+def run(args, communicator):
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter2 = communicator.createObjectAdapter("TestAdapter2")
+ adapter3 = communicator.createObjectAdapter("TestAdapter3")
+ object = TestI.ThrowerI()
+ adapter.add(object, communicator.stringToIdentity("thrower"))
+ adapter2.add(object, communicator.stringToIdentity("thrower"))
+ adapter3.add(object, communicator.stringToIdentity("thrower"))
+ adapter.activate()
+ adapter2.activate()
+ adapter3.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.Warn.Dispatch", "0")
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+ initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ initData.properties.setProperty("Ice.MessageSizeMax", "10")
+ initData.properties.setProperty("TestAdapter2.Endpoints", "default -p 12011")
+ initData.properties.setProperty("TestAdapter2.MessageSizeMax", "0")
+ initData.properties.setProperty("TestAdapter3.Endpoints", "default -p 12012")
+ initData.properties.setProperty("TestAdapter3.MessageSizeMax", "1")
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/exceptions/ServerAMD.py b/python/test/Ice/exceptions/ServerAMD.py
new file mode 100755
index 00000000000..9dd180dec06
--- /dev/null
+++ b/python/test/Ice/exceptions/ServerAMD.py
@@ -0,0 +1,180 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, array
+
+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 + '" TestAMD.ice')
+import Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class ThrowerI(Test.Thrower):
+ def shutdown_async(self, cb, current=None):
+ current.adapter.getCommunicator().shutdown()
+ cb.ice_response()
+
+ def supportsUndeclaredExceptions_async(self, cb, current=None):
+ cb.ice_response(True)
+
+ def supportsAssertException_async(self, cb, current=None):
+ cb.ice_response(False)
+
+ def throwAasA_async(self, cb, a, current=None):
+ ex = Test.A()
+ ex.aMem = a
+ cb.ice_exception(ex)
+
+ def throwAorDasAorD_async(self, cb, a, current=None):
+ if a > 0:
+ ex = Test.A()
+ ex.aMem = a
+ cb.ice_exception(ex)
+ else:
+ ex = Test.D()
+ ex.dMem = a
+ cb.ice_exception(ex)
+
+ def throwBasA_async(self, cb, a, b, current=None):
+ ex = Test.B()
+ ex.aMem = a
+ ex.bMem = b
+ raise ex
+ #cb.ice_exception(ex)
+
+ def throwCasA_async(self, cb, a, b, c, current=None):
+ ex = Test.C()
+ ex.aMem = a
+ ex.bMem = b
+ ex.cMem = c
+ cb.ice_exception(ex)
+
+ def throwBasB_async(self, cb, a, b, current=None):
+ ex = Test.B()
+ ex.aMem = a
+ ex.bMem = b
+ raise ex
+ #cb.ice_exception(ex)
+
+ def throwCasB_async(self, cb, a, b, c, current=None):
+ ex = Test.C()
+ ex.aMem = a
+ ex.bMem = b
+ ex.cMem = c
+ cb.ice_exception(ex)
+
+ def throwCasC_async(self, cb, a, b, c, current=None):
+ ex = Test.C()
+ ex.aMem = a
+ ex.bMem = b
+ ex.cMem = c
+ cb.ice_exception(ex)
+
+ def throwModA_async(self, cb, a, a2, current=None):
+ ex = Test.Mod.A()
+ ex.aMem = a
+ ex.a2Mem = a2
+ raise ex
+
+ def throwUndeclaredA_async(self, cb, a, current=None):
+ ex = Test.A()
+ ex.aMem = a
+ cb.ice_exception(ex)
+
+ def throwUndeclaredB_async(self, cb, a, b, current=None):
+ ex = Test.B()
+ ex.aMem = a
+ ex.bMem = b
+ raise ex
+ #cb.ice_exception(ex)
+
+ def throwUndeclaredC_async(self, cb, a, b, c, current=None):
+ ex = Test.C()
+ ex.aMem = a
+ ex.bMem = b
+ ex.cMem = c
+ cb.ice_exception(ex)
+
+ def throwLocalException_async(self, cb, current=None):
+ cb.ice_exception(Ice.TimeoutException())
+
+ def throwNonIceException_async(self, cb, current=None):
+ # Python-specific: make sure the argument is validated.
+ try:
+ cb.ice_exception('foo')
+ test(False)
+ except TypeError:
+ pass
+
+ cb.ice_exception(RuntimeError("12345"))
+
+ def throwAssertException_async(self, cb, current=None):
+ raise RuntimeError("operation `throwAssertException' not supported")
+
+ def throwMemoryLimitException_async(self, cb, seq, current=None):
+ cb.ice_response(bytearray(20 * 1024))
+
+ def throwLocalExceptionIdempotent_async(self, cb, current=None):
+ cb.ice_exception(Ice.TimeoutException())
+
+ def throwAfterResponse_async(self, cb, current=None):
+ cb.ice_response()
+ raise RuntimeError("12345")
+
+ def throwAfterException_async(self, cb, current=None):
+ cb.ice_exception(Test.A())
+ raise RuntimeError("12345")
+
+def run(args, communicator):
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter2 = communicator.createObjectAdapter("TestAdapter2")
+ adapter3 = communicator.createObjectAdapter("TestAdapter3")
+ object = ThrowerI()
+ adapter.add(object, communicator.stringToIdentity("thrower"))
+ adapter2.add(object, communicator.stringToIdentity("thrower"))
+ adapter3.add(object, communicator.stringToIdentity("thrower"))
+ adapter.activate()
+ adapter2.activate()
+ adapter3.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.Warn.Dispatch", "0")
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+ initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ initData.properties.setProperty("Ice.MessageSizeMax", "10")
+ initData.properties.setProperty("TestAdapter2.Endpoints", "default -p 12011")
+ initData.properties.setProperty("TestAdapter2.MessageSizeMax", "0")
+ initData.properties.setProperty("TestAdapter3.Endpoints", "default -p 12012")
+ initData.properties.setProperty("TestAdapter3.MessageSizeMax", "1")
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/exceptions/Test.ice b/python/test/Ice/exceptions/Test.ice
new file mode 100644
index 00000000000..cb519fa50f4
--- /dev/null
+++ b/python/test/Ice/exceptions/Test.ice
@@ -0,0 +1,86 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/BuiltinSequences.ice>
+
+module Test
+{
+
+interface Empty
+{
+};
+
+interface Thrower;
+
+exception A
+{
+ int aMem;
+};
+
+exception B extends A
+{
+ int bMem;
+};
+
+exception C extends B
+{
+ int cMem;
+};
+
+exception D
+{
+ int dMem;
+};
+
+module Mod
+{
+ exception A extends ::Test::A
+ {
+ int a2Mem;
+ };
+};
+
+interface Thrower
+{
+ void shutdown();
+ bool supportsUndeclaredExceptions();
+ bool supportsAssertException();
+
+ void throwAasA(int a) throws A;
+ void throwAorDasAorD(int a) throws A, D;
+ void throwBasA(int a, int b) throws A;
+ void throwCasA(int a, int b, int c) throws A;
+ void throwBasB(int a, int b) throws B;
+ void throwCasB(int a, int b, int c) throws B;
+ void throwCasC(int a, int b, int c) throws C;
+
+ void throwModA(int a, int a2) throws Mod::A;
+
+ void throwUndeclaredA(int a);
+ void throwUndeclaredB(int a, int b);
+ void throwUndeclaredC(int a, int b, int c);
+ void throwLocalException();
+ void throwNonIceException();
+ void throwAssertException();
+ Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq);
+
+ idempotent void throwLocalExceptionIdempotent();
+
+ void throwAfterResponse();
+ void throwAfterException() throws A;
+};
+
+interface WrongOperation
+{
+ void noSuchOperation();
+};
+
+};
diff --git a/python/test/Ice/exceptions/TestAMD.ice b/python/test/Ice/exceptions/TestAMD.ice
new file mode 100644
index 00000000000..6c6cd19342d
--- /dev/null
+++ b/python/test/Ice/exceptions/TestAMD.ice
@@ -0,0 +1,81 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/BuiltinSequences.ice>
+
+module Test
+{
+
+interface Thrower;
+
+exception A
+{
+ int aMem;
+};
+
+exception B extends A
+{
+ int bMem;
+};
+
+exception C extends B
+{
+ int cMem;
+};
+
+exception D
+{
+ int dMem;
+};
+
+module Mod
+{
+ exception A extends ::Test::A
+ {
+ int a2Mem;
+ };
+};
+
+
+["amd"] interface Thrower
+{
+ void shutdown();
+ bool supportsUndeclaredExceptions();
+ bool supportsAssertException();
+
+ void throwAasA(int a) throws A;
+ void throwAorDasAorD(int a) throws A, D;
+ void throwBasA(int a, int b) throws A;
+ void throwCasA(int a, int b, int c) throws A;
+ void throwBasB(int a, int b) throws B;
+ void throwCasB(int a, int b, int c) throws B;
+ void throwCasC(int a, int b, int c) throws C;
+
+ void throwModA(int a, int a2) throws Mod::A;
+
+ void throwUndeclaredA(int a);
+ void throwUndeclaredB(int a, int b);
+ void throwUndeclaredC(int a, int b, int c);
+ void throwLocalException();
+ void throwNonIceException();
+ void throwAssertException();
+ Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq);
+
+ void throwAfterResponse();
+ void throwAfterException() throws A;
+};
+
+["amd"] interface WrongOperation
+{
+ void noSuchOperation();
+};
+
+};
diff --git a/python/test/Ice/exceptions/TestI.py b/python/test/Ice/exceptions/TestI.py
new file mode 100644
index 00000000000..7ff371fc0b1
--- /dev/null
+++ b/python/test/Ice/exceptions/TestI.py
@@ -0,0 +1,108 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, array, sys
+
+class ThrowerI(Test.Thrower):
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def supportsUndeclaredExceptions(self, current=None):
+ return True
+
+ def supportsAssertException(self, current=None):
+ return False
+
+ def throwAasA(self, a, current=None):
+ ex = Test.A()
+ ex.aMem = a
+ raise ex
+
+ def throwAorDasAorD(self, a, current=None):
+ if a > 0:
+ ex = Test.A()
+ ex.aMem = a
+ raise ex
+ else:
+ ex = Test.D()
+ ex.dMem = a
+ raise ex
+
+ def throwBasA(self, a, b, current=None):
+ self.throwBasB(a, b, current)
+
+ def throwCasA(self, a, b, c, current=None):
+ self.throwCasC(a, b, c, current)
+
+ def throwBasB(self, a, b, current=None):
+ ex = Test.B()
+ ex.aMem = a
+ ex.bMem = b
+ raise ex
+
+ def throwCasB(self, a, b, c, current=None):
+ self.throwCasC(a, b, c, current)
+
+ def throwCasC(self, a, b, c, current=None):
+ ex = Test.C()
+ ex.aMem = a
+ ex.bMem = b
+ ex.cMem = c
+ raise ex
+
+ def throwModA(self, a, a2, current=None):
+ ex = Test.Mod.A()
+ ex.aMem = a
+ ex.a2Mem = a2
+ raise ex
+
+ def throwUndeclaredA(self, a, current=None):
+ ex = Test.A()
+ ex.aMem = a
+ raise ex
+
+ def throwUndeclaredB(self, a, b, current=None):
+ ex = Test.B()
+ ex.aMem = a
+ ex.bMem = b
+ raise ex
+
+ def throwUndeclaredC(self, a, b, c, current=None):
+ ex = Test.C()
+ ex.aMem = a
+ ex.bMem = b
+ ex.cMem = c
+ raise ex
+
+ def throwLocalException(self, current=None):
+ raise Ice.TimeoutException()
+
+ def throwNonIceException(self, current=None):
+ raise RuntimeError("12345")
+
+ def throwAssertException(self, current=None):
+ raise RuntimeError("operation `throwAssertException' not supported")
+
+ def throwMemoryLimitException(self, seq, current=None):
+ return bytearray(20 * 1024)
+
+ def throwLocalExceptionIdempotent(self, current=None):
+ raise Ice.TimeoutException()
+
+ def throwAfterResponse(self, current=None):
+ #
+ # Only relevant for AMD.
+ #
+ pass
+
+ def throwAfterException(self, current=None):
+ #
+ # Only relevant for AMD.
+ #
+ raise Test.A()
diff --git a/python/test/Ice/exceptions/run.py b/python/test/Ice/exceptions/run.py
new file mode 100755
index 00000000000..9445951eca9
--- /dev/null
+++ b/python/test/Ice/exceptions/run.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("Running test with compact (default) format.")
+TestUtil.clientServerTest()
+
+print("Running test with sliced format.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.SlicedFormat",
+ additionalServerOptions="--Ice.Default.SlicedFormat")
+
+print("Running test with 1.0 encoding.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
+
+print("Running test with compact (default) format and AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py")
+
+print("Running test with sliced format and AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py",
+ additionalClientOptions="--Ice.Default.SlicedFormat",
+ additionalServerOptions="--Ice.Default.SlicedFormat")
+
+print("Running test with 1.0 encoding and AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py",
+ additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
+
+print("Running collocated test.")
+TestUtil.collocatedTest()
diff --git a/python/test/Ice/facets/AllTests.py b/python/test/Ice/facets/AllTests.py
new file mode 100644
index 00000000000..b1059672d21
--- /dev/null
+++ b/python/test/Ice/facets/AllTests.py
@@ -0,0 +1,183 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class EmptyI(Test.Empty):
+ pass
+
+def allTests(communicator):
+
+ sys.stdout.write("testing Ice.Admin.Facets property... ")
+ sys.stdout.flush()
+ test(len(communicator.getProperties().getPropertyAsList("Ice.Admin.Facets")) == 0)
+ communicator.getProperties().setProperty("Ice.Admin.Facets", "foobar");
+ facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
+ test(len(facetFilter) == 1 and facetFilter[0] == "foobar");
+ communicator.getProperties().setProperty("Ice.Admin.Facets", "foo\\'bar");
+ facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
+ test(len(facetFilter) == 1 and facetFilter[0] == "foo'bar");
+ communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' toto 'titi'");
+ facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
+ test(len(facetFilter) == 3 and facetFilter[0] == "foo bar" and facetFilter[1] == "toto"
+ and facetFilter[2] == "titi");
+ communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar\\' toto' 'titi'");
+ facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
+ test(len(facetFilter) == 2 and facetFilter[0] == "foo bar' toto" and facetFilter[1] == "titi");
+ # communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' 'toto titi");
+ # facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
+ # test(len(facetFilter) == 0);
+ communicator.getProperties().setProperty("Ice.Admin.Facets", "");
+ print("ok")
+
+ sys.stdout.write("testing facet registration exceptions... ")
+ sys.stdout.flush()
+ communicator.getProperties().setProperty("FacetExceptionTestAdapter.Endpoints", "default")
+ adapter = communicator.createObjectAdapter("FacetExceptionTestAdapter")
+ obj = EmptyI()
+ adapter.add(obj, communicator.stringToIdentity("d"))
+ adapter.addFacet(obj, communicator.stringToIdentity("d"), "facetABCD")
+ try:
+ adapter.addFacet(obj, communicator.stringToIdentity("d"), "facetABCD")
+ test(false)
+ except Ice.AlreadyRegisteredException:
+ pass
+ adapter.removeFacet(communicator.stringToIdentity("d"), "facetABCD")
+ try:
+ adapter.removeFacet(communicator.stringToIdentity("d"), "facetABCD")
+ test(false)
+ except Ice.NotRegisteredException:
+ pass
+ print("ok")
+
+ sys.stdout.write("testing removeAllFacets... ")
+ sys.stdout.flush()
+ obj1 = EmptyI()
+ obj2 = EmptyI()
+ adapter.addFacet(obj1, communicator.stringToIdentity("id1"), "f1")
+ adapter.addFacet(obj2, communicator.stringToIdentity("id1"), "f2")
+ obj3 = EmptyI()
+ adapter.addFacet(obj1, communicator.stringToIdentity("id2"), "f1")
+ adapter.addFacet(obj2, communicator.stringToIdentity("id2"), "f2")
+ adapter.addFacet(obj3, communicator.stringToIdentity("id2"), "")
+ fm = adapter.removeAllFacets(communicator.stringToIdentity("id1"))
+ test(len(fm) == 2)
+ test(fm["f1"] == obj1)
+ test(fm["f2"] == obj2)
+ try:
+ adapter.removeAllFacets(communicator.stringToIdentity("id1"))
+ test(false)
+ except Ice.NotRegisteredException:
+ pass
+ fm = adapter.removeAllFacets(communicator.stringToIdentity("id2"))
+ test(len(fm) == 3)
+ test(fm["f1"] == obj1)
+ test(fm["f2"] == obj2)
+ test(fm[""] == obj3)
+ print("ok")
+
+ adapter.deactivate()
+
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ ref = "d:default -p 12010"
+ db = communicator.stringToProxy(ref)
+ test(db)
+ print("ok")
+
+ sys.stdout.write("testing unchecked cast... ")
+ sys.stdout.flush()
+ obj = Ice.ObjectPrx.uncheckedCast(db)
+ test(obj.ice_getFacet() == "")
+ obj = Ice.ObjectPrx.uncheckedCast(db, "facetABCD")
+ test(obj.ice_getFacet() == "facetABCD")
+ obj2 = Ice.ObjectPrx.uncheckedCast(obj)
+ test(obj2.ice_getFacet() == "facetABCD")
+ obj3 = Ice.ObjectPrx.uncheckedCast(obj, "")
+ test(obj3.ice_getFacet() == "")
+ d = Test.DPrx.uncheckedCast(db)
+ test(d.ice_getFacet() == "")
+ df = Test.DPrx.uncheckedCast(db, "facetABCD")
+ test(df.ice_getFacet() == "facetABCD")
+ df2 = Test.DPrx.uncheckedCast(df)
+ test(df2.ice_getFacet() == "facetABCD")
+ df3 = Test.DPrx.uncheckedCast(df, "")
+ test(df3.ice_getFacet() == "")
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ obj = Ice.ObjectPrx.checkedCast(db)
+ test(obj.ice_getFacet() == "")
+ obj = Ice.ObjectPrx.checkedCast(db, "facetABCD")
+ test(obj.ice_getFacet() == "facetABCD")
+ obj2 = Ice.ObjectPrx.checkedCast(obj)
+ test(obj2.ice_getFacet() == "facetABCD")
+ obj3 = Ice.ObjectPrx.checkedCast(obj, "")
+ test(obj3.ice_getFacet() == "")
+ d = Test.DPrx.checkedCast(db)
+ test(d.ice_getFacet() == "")
+ df = Test.DPrx.checkedCast(db, "facetABCD")
+ test(df.ice_getFacet() == "facetABCD")
+ df2 = Test.DPrx.checkedCast(df)
+ test(df2.ice_getFacet() == "facetABCD")
+ df3 = Test.DPrx.checkedCast(df, "")
+ test(df3.ice_getFacet() == "")
+ test(Test.DPrx.checkedCast(df, "bogus") == None)
+ print("ok")
+
+ sys.stdout.write("testing non-facets A, B, C, and D... ")
+ sys.stdout.flush()
+ d = Test.DPrx.checkedCast(db)
+ test(d)
+ test(d == db)
+ test(d.callA() == "A")
+ test(d.callB() == "B")
+ test(d.callC() == "C")
+ test(d.callD() == "D")
+ print("ok")
+
+ sys.stdout.write("testing facets A, B, C, and D... ")
+ sys.stdout.flush()
+ df = Test.DPrx.checkedCast(d, "facetABCD")
+ test(df)
+ test(df.callA() == "A")
+ test(df.callB() == "B")
+ test(df.callC() == "C")
+ test(df.callD() == "D")
+ print("ok")
+
+ sys.stdout.write("testing facets E and F... ")
+ sys.stdout.flush()
+ ff = Test.FPrx.checkedCast(d, "facetEF")
+ test(ff)
+ test(ff.callE() == "E")
+ test(ff.callF() == "F")
+ print("ok")
+
+ sys.stdout.write("testing facet G... ")
+ sys.stdout.flush()
+ gf = Test.GPrx.checkedCast(ff, "facetGH")
+ test(gf)
+ test(gf.callG() == "G")
+ print("ok")
+
+ sys.stdout.write("testing whether casting preserves the facet... ")
+ sys.stdout.flush()
+ hf = Test.HPrx.checkedCast(gf)
+ test(hf)
+ test(hf.callG() == "G")
+ test(hf.callH() == "H")
+ print("ok")
+
+ return gf
diff --git a/python/test/Ice/facets/Client.py b/python/test/Ice/facets/Client.py
new file mode 100755
index 00000000000..7b008b0ad8f
--- /dev/null
+++ b/python/test/Ice/facets/Client.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 AllTests
+
+def run(args, communicator):
+ g = AllTests.allTests(communicator)
+ g.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/facets/Collocated.py b/python/test/Ice/facets/Collocated.py
new file mode 100755
index 00000000000..8fbc45a0f31
--- /dev/null
+++ b/python/test/Ice/facets/Collocated.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, TestI, AllTests
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ d = TestI.DI()
+ adapter.add(d, communicator.stringToIdentity("d"))
+ adapter.addFacet(d, communicator.stringToIdentity("d"), "facetABCD")
+ f = TestI.FI()
+ adapter.addFacet(f, communicator.stringToIdentity("d"), "facetEF")
+ h = TestI.HI(communicator)
+ adapter.addFacet(h, communicator.stringToIdentity("d"), "facetGH")
+
+ #adapter.activate() // Don't activate OA to ensure collocation is used.
+
+ AllTests.allTests(communicator)
+
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/facets/Server.py b/python/test/Ice/facets/Server.py
new file mode 100755
index 00000000000..96145347213
--- /dev/null
+++ b/python/test/Ice/facets/Server.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ d = TestI.DI()
+ adapter.add(d, communicator.stringToIdentity("d"))
+ adapter.addFacet(d, communicator.stringToIdentity("d"), "facetABCD")
+ f = TestI.FI()
+ adapter.addFacet(f, communicator.stringToIdentity("d"), "facetEF")
+ h = TestI.HI(communicator)
+ adapter.addFacet(h, communicator.stringToIdentity("d"), "facetGH")
+
+ adapter.activate()
+ communicator.waitForShutdown()
+
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/facets/Test.ice b/python/test/Ice/facets/Test.ice
new file mode 100644
index 00000000000..d73c6594829
--- /dev/null
+++ b/python/test/Ice/facets/Test.ice
@@ -0,0 +1,60 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface Empty
+{
+};
+
+interface A
+{
+ string callA();
+};
+
+interface B extends A
+{
+ string callB();
+};
+
+interface C extends A
+{
+ string callC();
+};
+
+interface D extends B, C
+{
+ string callD();
+};
+
+interface E
+{
+ string callE();
+};
+
+interface F extends E
+{
+ string callF();
+};
+
+interface G
+{
+ void shutdown();
+ string callG();
+};
+
+interface H extends G
+{
+ string callH();
+};
+
+};
diff --git a/python/test/Ice/facets/TestI.py b/python/test/Ice/facets/TestI.py
new file mode 100644
index 00000000000..9f709245554
--- /dev/null
+++ b/python/test/Ice/facets/TestI.py
@@ -0,0 +1,51 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 Test
+
+class AI(Test.A):
+ def callA(self, current=None):
+ return "A"
+
+class BI(Test.B, AI):
+ def callB(self, current=None):
+ return "B"
+
+class CI(Test.C, AI):
+ def callC(self, current=None):
+ return "C"
+
+class DI(Test.D, BI, CI):
+ def callD(self, current=None):
+ return "D"
+
+class EI(Test.E):
+ def callE(self, current=None):
+ return "E"
+
+class FI(Test.F, EI):
+ def callF(self, current=None):
+ return "F"
+
+class GI(Test.G):
+ def __init__(self, communicator):
+ self._communicator = communicator
+
+ def shutdown(self, current=None):
+ self._communicator.shutdown()
+
+ def callG(self, current=None):
+ return "G"
+
+class HI(Test.H, GI):
+ def __init__(self, communicator):
+ GI.__init__(self, communicator)
+
+ def callH(self, current=None):
+ return "H"
diff --git a/python/test/Ice/facets/run.py b/python/test/Ice/facets/run.py
new file mode 100755
index 00000000000..9487c74a4f5
--- /dev/null
+++ b/python/test/Ice/facets/run.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
+TestUtil.collocatedTest()
diff --git a/python/test/Ice/faultTolerance/AllTests.py b/python/test/Ice/faultTolerance/AllTests.py
new file mode 100644
index 00000000000..04f78961b24
--- /dev/null
+++ b/python/test/Ice/faultTolerance/AllTests.py
@@ -0,0 +1,175 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, threading
+
+Ice.loadSlice('Test.ice')
+import Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class CallbackBase:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def check(self):
+ self._cond.acquire()
+ try:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ finally:
+ self._cond.release()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+class Callback(CallbackBase):
+ def response(self):
+ test(False)
+
+ def exception(self, ex):
+ test(False)
+
+ def opPidI(self, pid):
+ self._pid = pid
+ self.called()
+
+ def opShutdownI(self):
+ self.called()
+
+ def exceptAbortI(self, ex):
+ try:
+ raise ex
+ except Ice.ConnectionLostException:
+ pass
+ except Ice.ConnectFailedException:
+ pass
+ except Ice.Exception as ex:
+ print(ex)
+ test(False)
+ self.called()
+
+ def pid(self):
+ return self._pid
+
+def allTests(communicator, ports):
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ ref = "test"
+ for p in ports:
+ ref = ref + ":default -p " + str(p)
+ base = communicator.stringToProxy(ref)
+ test(base)
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ obj = Test.TestIntfPrx.checkedCast(base)
+ test(obj)
+ test(obj == base)
+ print("ok")
+
+ oldPid = 0
+ ami = False
+ i = 1
+ j = 0
+ while i <= len(ports):
+ if j > 3:
+ j = 0
+ ami = not ami
+
+ if not ami:
+ sys.stdout.write("testing server #%d... " % i)
+ sys.stdout.flush()
+ pid = obj.pid()
+ test(pid != oldPid)
+ print("ok")
+ oldPid = pid
+ else:
+ sys.stdout.write("testing server #%d with AMI... " % i)
+ sys.stdout.flush()
+ cb = Callback()
+ obj.begin_pid(cb.opPidI, cb.exception)
+ cb.check()
+ pid = cb.pid()
+ test(pid != oldPid)
+ print("ok")
+ oldPid = pid
+
+ if j == 0:
+ if not ami:
+ sys.stdout.write("shutting down server #%d... " % i)
+ sys.stdout.flush()
+ obj.shutdown()
+ print("ok")
+ else:
+ sys.stdout.write("shutting down server #%d with AMI... " % i)
+ sys.stdout.flush()
+ cb = Callback()
+ obj.begin_shutdown(cb.opShutdownI, cb.exception)
+ cb.check()
+ print("ok")
+ elif j == 1 or i + 1 > len(ports):
+ if not ami:
+ sys.stdout.write("aborting server #%d... " % i)
+ sys.stdout.flush()
+ try:
+ obj.abort()
+ test(False)
+ except Ice.ConnectionLostException:
+ print("ok")
+ except Ice.ConnectFailedException:
+ print("ok")
+ else:
+ sys.stdout.write("aborting server #%d with AMI... " % i)
+ sys.stdout.flush()
+ cb = Callback()
+ obj.begin_abort(cb.response, cb.exceptAbortI)
+ cb.check()
+ print("ok")
+ elif j == 2 or j == 3:
+ if not ami:
+ sys.stdout.write("aborting server #%d and #%d with idempotent call... " % (i, i + 1))
+ sys.stdout.flush()
+ try:
+ obj.idempotentAbort()
+ test(False)
+ except Ice.ConnectionLostException:
+ print("ok")
+ except Ice.ConnectFailedException:
+ print("ok")
+ else:
+ sys.stdout.write("aborting server #%d and #%d with idempotent AMI call... " % (i, i + 1))
+ sys.stdout.flush()
+ cb = Callback()
+ obj.begin_idempotentAbort(cb.response, cb.exceptAbortI)
+ cb.check()
+ print("ok")
+
+ i = i + 1
+ else:
+ assert(False)
+
+ i = i + 1
+ j = j + 1
+
+ sys.stdout.write("testing whether all servers are gone... ")
+ sys.stdout.flush()
+ try:
+ obj.ice_ping()
+ test(False)
+ except Ice.LocalException:
+ print("ok")
diff --git a/python/test/Ice/faultTolerance/Client.py b/python/test/Ice/faultTolerance/Client.py
new file mode 100755
index 00000000000..9fcd238c561
--- /dev/null
+++ b/python/test/Ice/faultTolerance/Client.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def usage(n):
+ sys.stderr.write("Usage: " + n + " port...\n")
+
+def run(args, communicator):
+ ports = []
+ for arg in args[1:]:
+ if arg[0] == '-':
+ sys.stderr.write(args[0] + ": unknown option `" + arg + "'\n")
+ usage(args[0])
+ return False
+
+ ports.append(int(arg))
+
+ if len(ports) == 0:
+ sys.stderr.write(args[0] + ": no ports specified\n")
+ usage(args[0])
+ return False
+
+ try:
+ AllTests.allTests(communicator, ports)
+ except:
+ traceback.print_exc()
+ test(False)
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+
+ #
+ # This test aborts servers, so we don't want warnings.
+ #
+ initData.properties.setProperty('Ice.Warn.Connections', '0')
+
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/faultTolerance/Server.py b/python/test/Ice/faultTolerance/Server.py
new file mode 100755
index 00000000000..3bf4b269367
--- /dev/null
+++ b/python/test/Ice/faultTolerance/Server.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+def usage(n):
+ sys.stderr.write("Usage: " + n + " port\n")
+
+class TestI(Test.TestIntf):
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def abort(self, current=None):
+ sys.stdout.write("aborting...")
+ os._exit(0)
+
+ def idempotentAbort(self, current=None):
+ os._exit(0)
+
+ def pid(self, current=None):
+ return os.getpid()
+
+def run(args, communicator):
+ port = 0
+ for arg in args[1:]:
+ if arg[0] == '-':
+ sys.stderr.write(args[0] + ": unknown option `" + arg + "'\n")
+ usage(args[0])
+ return False
+ if port > 0:
+ sys.stderr.write(args[0] + ": only one port can be specified\n")
+ usage(args[0])
+ return False
+
+ port = int(arg)
+
+ if port <= 0:
+ sys.stderr.write(args[0] + ": no port specified\n")
+ usage(args[0])
+ return False
+
+ endpts = "default -p " + str(port) + ":udp"
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", endpts)
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ object = TestI()
+ adapter.add(object, communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ #
+ # In this test, we need a longer server idle time, otherwise
+ # our test servers may time out before they are used in the
+ # test.
+ #
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.ServerIdleTime", "120") # Two minutes.
+
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/faultTolerance/Test.ice b/python/test/Ice/faultTolerance/Test.ice
new file mode 100644
index 00000000000..d5488ad5726
--- /dev/null
+++ b/python/test/Ice/faultTolerance/Test.ice
@@ -0,0 +1,23 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface TestIntf
+{
+ void shutdown();
+ void abort();
+ idempotent void idempotentAbort();
+ idempotent int pid();
+};
+
+};
diff --git a/python/test/Ice/faultTolerance/run.py b/python/test/Ice/faultTolerance/run.py
new file mode 100755
index 00000000000..d3db12b4e2f
--- /dev/null
+++ b/python/test/Ice/faultTolerance/run.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+server = os.path.join(os.getcwd(), "Server.py")
+client = os.path.join(os.getcwd(), "Client.py")
+
+num = 12
+base = 12340
+
+serverProc = []
+for i in range(0, num):
+ sys.stdout.write("starting server #%d... " % (i + 1))
+ sys.stdout.flush()
+ serverProc.append(TestUtil.startServer(server, "%d" % (base + i)))
+ print("ok")
+
+ports = ""
+for i in range(0, num):
+ ports = "%s %d" % (ports, base + i)
+sys.stdout.write("starting client... ")
+sys.stdout.flush()
+clientProc = TestUtil.startClient(client, ports, startReader = False)
+print("ok")
+clientProc.startReader()
+
+clientProc.waitTestSuccess()
+for p in serverProc:
+ p.waitTestSuccess()
diff --git a/python/test/Ice/info/AllTests.py b/python/test/Ice/info/AllTests.py
new file mode 100644
index 00000000000..c8c754e804b
--- /dev/null
+++ b/python/test/Ice/info/AllTests.py
@@ -0,0 +1,175 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, threading
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ sys.stdout.write("testing proxy endpoint information... ")
+ sys.stdout.flush()
+
+ p1 = communicator.stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" + \
+ "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:" + \
+ "opaque -e 1.8 -t 100 -v ABCD")
+
+ endps = p1.ice_getEndpoints()
+
+ ipEndpoint = endps[0].getInfo()
+ test(isinstance(ipEndpoint, Ice.IPEndpointInfo))
+ test(ipEndpoint.host == "tcphost")
+ test(ipEndpoint.port == 10000)
+ test(ipEndpoint.sourceAddress == "10.10.10.10")
+ test(ipEndpoint.timeout == 1200)
+ test(ipEndpoint.compress)
+ test(not ipEndpoint.datagram())
+ test((ipEndpoint.type() == Ice.TCPEndpointType and not ipEndpoint.secure()) or
+ (ipEndpoint.type() == Ice.SSLEndpointType and ipEndpoint.secure()) or # SSL
+ (ipEndpoint.type() == Ice.WSEndpointType and not ipEndpoint.secure()) or # WS
+ (ipEndpoint.type() == Ice.WSSEndpointType and ipEndpoint.secure())) # WS
+ test((ipEndpoint.type() == Ice.TCPEndpointType and isinstance(ipEndpoint, Ice.TCPEndpointInfo)) or
+ (ipEndpoint.type() == Ice.SSLEndpointType) or
+ (ipEndpoint.type() == Ice.WSEndpointType and isinstance(ipEndpoint, Ice.WSEndpointInfo)) or
+ (ipEndpoint.type() == Ice.WSSEndpointType and isinstance(ipEndpoint, Ice.WSEndpointInfo)))
+
+ udpEndpoint = endps[1].getInfo()
+ test(isinstance(udpEndpoint, Ice.UDPEndpointInfo))
+ test(udpEndpoint.host == "udphost")
+ test(udpEndpoint.port == 10001)
+ test(udpEndpoint.sourceAddress == "10.10.10.10")
+ test(udpEndpoint.mcastInterface == "eth0")
+ test(udpEndpoint.mcastTtl == 5)
+ test(udpEndpoint.timeout == -1)
+ test(not udpEndpoint.compress)
+ test(not udpEndpoint.secure())
+ test(udpEndpoint.datagram())
+ test(udpEndpoint.type() == Ice.UDPEndpointType)
+
+ opaqueEndpoint = endps[2].getInfo()
+ test(isinstance(opaqueEndpoint, Ice.OpaqueEndpointInfo))
+ test(opaqueEndpoint.rawEncoding == Ice.EncodingVersion(1, 8))
+
+ print("ok")
+
+ defaultHost = communicator.getProperties().getProperty("Ice.Default.Host")
+
+ sys.stdout.write("test object adapter endpoint information... ")
+ sys.stdout.flush()
+
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -t 15000:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ endpoints = adapter.getEndpoints()
+ test(len(endpoints) == 2)
+ publishedEndpoints = adapter.getPublishedEndpoints()
+ test(endpoints == publishedEndpoints)
+
+ ipEndpoint = endpoints[0].getInfo()
+ test(ipEndpoint.type() == Ice.TCPEndpointType or ipEndpoint.type() == 2 or ipEndpoint.type() == 4 or
+ ipEndpoint.type() == 5)
+ test(ipEndpoint.host == defaultHost)
+ test(ipEndpoint.port > 0)
+ test(ipEndpoint.timeout == 15000)
+
+ udpEndpoint = endpoints[1].getInfo()
+ test(udpEndpoint.host == defaultHost)
+ test(udpEndpoint.datagram())
+ test(udpEndpoint.port > 0)
+
+ adapter.destroy()
+
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -h * -p 12020")
+ communicator.getProperties().setProperty("TestAdapter.PublishedEndpoints", "default -h 127.0.0.1 -p 12020")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+
+ endpoints = adapter.getEndpoints()
+ test(len(endpoints) >= 1)
+ publishedEndpoints = adapter.getPublishedEndpoints()
+ test(len(publishedEndpoints) == 1)
+
+ for i in range(0, len(endpoints)):
+ ipEndpoint = endpoints[i].getInfo()
+ test(ipEndpoint.port == 12020)
+
+ ipEndpoint = publishedEndpoints[0].getInfo()
+ test(ipEndpoint.host == "127.0.0.1")
+ test(ipEndpoint.port == 12020)
+
+ adapter.destroy()
+
+ print("ok")
+
+ base = communicator.stringToProxy("test:default -p 12010:udp -p 12010")
+ testIntf = Test.TestIntfPrx.checkedCast(base)
+
+ sys.stdout.write("test connection endpoint information... ")
+ sys.stdout.flush()
+
+ ipinfo = base.ice_getConnection().getEndpoint().getInfo()
+ test(ipinfo.port == 12010)
+ test(not ipinfo.compress)
+ test(ipinfo.host == defaultHost)
+
+ ctx = testIntf.getEndpointInfoAsContext()
+ test(ctx["host"] == ipinfo.host)
+ test(ctx["compress"] == "false")
+ port = int(ctx["port"])
+ test(port > 0)
+
+ udp = base.ice_datagram().ice_getConnection().getEndpoint().getInfo()
+ test(udp.port == 12010)
+ test(udp.host == defaultHost)
+
+ print("ok")
+
+ sys.stdout.write("testing connection information... ")
+ sys.stdout.flush()
+
+ connection = base.ice_getConnection()
+ connection.setBufferSize(1024, 2048)
+
+ info = connection.getInfo()
+ test(not info.incoming)
+ test(len(info.adapterName) == 0)
+ test(info.remotePort == 12010)
+ if defaultHost == '127.0.0.1':
+ test(info.remoteAddress == defaultHost)
+ test(info.localAddress == defaultHost)
+ test(info.rcvSize >= 1024)
+ test(info.sndSize >= 2048)
+
+ ctx = testIntf.getConnectionInfoAsContext()
+ test(ctx["incoming"] == "true")
+ test(ctx["adapterName"] == "TestAdapter")
+ test(ctx["remoteAddress"] == info.localAddress)
+ test(ctx["localAddress"] == info.remoteAddress)
+ test(ctx["remotePort"] == str(info.localPort))
+ test(ctx["localPort"] == str(info.remotePort))
+
+ if(base.ice_getConnection().type() == "ws" or base.ice_getConnection().type() == "wss"):
+ test(isinstance(info, Ice.WSConnectionInfo))
+
+ test(info.headers["Upgrade"] == "websocket")
+ test(info.headers["Connection"] == "Upgrade")
+ test(info.headers["Sec-WebSocket-Protocol"] == "ice.zeroc.com")
+ test("Sec-WebSocket-Accept" in info.headers);
+
+ test(ctx["ws.Upgrade"] == "websocket")
+ test(ctx["ws.Connection"] == "Upgrade")
+ test(ctx["ws.Sec-WebSocket-Protocol"] == "ice.zeroc.com")
+ test(ctx["ws.Sec-WebSocket-Version"] == "13")
+ test("ws.Sec-WebSocket-Key" in ctx)
+
+ print("ok")
+
+ testIntf.shutdown()
+
+ communicator.shutdown()
+ communicator.waitForShutdown()
diff --git a/python/test/Ice/info/Client.py b/python/test/Ice/info/Client.py
new file mode 100755
index 00000000000..cb71229d9da
--- /dev/null
+++ b/python/test/Ice/info/Client.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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 AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ AllTests.allTests(communicator)
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/info/Server.py b/python/test/Ice/info/Server.py
new file mode 100755
index 00000000000..e4d7ccf824f
--- /dev/null
+++ b/python/test/Ice/info/Server.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(TestI.MyDerivedClassI(), communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/info/Test.ice b/python/test/Ice/info/Test.ice
new file mode 100644
index 00000000000..a71990ba3db
--- /dev/null
+++ b/python/test/Ice/info/Test.ice
@@ -0,0 +1,26 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/Current.ice>
+
+module Test
+{
+
+interface TestIntf
+{
+ void shutdown();
+
+ Ice::Context getEndpointInfoAsContext();
+
+ Ice::Context getConnectionInfoAsContext();
+};
+
+};
diff --git a/python/test/Ice/info/TestI.py b/python/test/Ice/info/TestI.py
new file mode 100644
index 00000000000..c0b266a7ba4
--- /dev/null
+++ b/python/test/Ice/info/TestI.py
@@ -0,0 +1,69 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+import time
+
+class MyDerivedClassI(Test.TestIntf):
+ def __init__(self):
+ self.ctx = None
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def getEndpointInfoAsContext(self, current):
+ ctx = {}
+ info = current.con.getEndpoint().getInfo()
+ ctx["timeout"] = str(info.timeout)
+ if info.compress:
+ ctx["compress"] = "true"
+ else:
+ ctx["compress"] ="false"
+ if info.datagram():
+ ctx["datagram"] = "true"
+ else:
+ ctx["datagram"] ="false"
+ if info.secure():
+ ctx["secure"] = "true"
+ else:
+ ctx["secure"] ="false"
+ ctx["type"] = str(info.type())
+
+ ctx["host"] = info.host
+ ctx["port"] = str(info.port)
+
+ if isinstance(info, Ice.UDPEndpointInfo):
+ ctx["protocolMajor"] = str(info.protocolMajor)
+ ctx["protocolMinor"] = str(info.protocolMinor)
+ ctx["encodingMajor"] = str(info.encodingMajor)
+ ctx["encodingMinor"] = str(info.encodingMinor)
+ ctx["mcastInterface"] = info.mcastInterface
+ ctx["mcastTtl"] = str(info.mcastTtl)
+
+ return ctx
+
+ def getConnectionInfoAsContext(self, current):
+ ctx = {}
+ info = current.con.getInfo()
+ ctx["adapterName"] = info.adapterName
+ if info.incoming:
+ ctx["incoming"] = "true"
+ else:
+ ctx["incoming"] ="false"
+
+ ctx["localAddress"] = info.localAddress
+ ctx["localPort"] = str(info.localPort)
+ ctx["remoteAddress"] = info.remoteAddress
+ ctx["remotePort"] = str(info.remotePort)
+
+ if isinstance(info, Ice.WSConnectionInfo):
+ for key, value in info.headers.items():
+ ctx["ws." + key] = value
+
+ return ctx
diff --git a/python/test/Ice/info/run.py b/python/test/Ice/info/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/info/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/inheritance/AllTests.py b/python/test/Ice/inheritance/AllTests.py
new file mode 100644
index 00000000000..67922a33ff5
--- /dev/null
+++ b/python/test/Ice/inheritance/AllTests.py
@@ -0,0 +1,216 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ ref = "initial:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ initial = Test.InitialPrx.checkedCast(base)
+ test(initial)
+ test(initial == base)
+ print("ok")
+
+ sys.stdout.write("getting proxies for class hierarchy... ")
+ sys.stdout.flush()
+ ca = initial.caop()
+ cb = initial.cbop()
+ cc = initial.ccop()
+ cd = initial.cdop()
+ test(ca != cb)
+ test(ca != cc)
+ test(ca != cd)
+ test(cb != cc)
+ test(cb != cd)
+ test(cc != cd)
+ print("ok")
+
+ sys.stdout.write("getting proxies for interface hierarchy... ")
+ sys.stdout.flush()
+ ia = initial.iaop()
+ ib1 = initial.ib1op()
+ ib2 = initial.ib2op()
+ ic = initial.icop()
+ test(ia != ib1)
+ test(ia != ib2)
+ test(ia != ic)
+ test(ib1 != ic)
+ test(ib2 != ic)
+ print("ok")
+
+ sys.stdout.write("invoking proxy operations on class hierarchy... ")
+ sys.stdout.flush()
+ cao = ca.caop(ca)
+ test(cao == ca)
+ cao = ca.caop(cb)
+ test(cao == cb)
+ cao = ca.caop(cc)
+ test(cao == cc)
+ cao = cb.caop(ca)
+ test(cao == ca)
+ cao = cb.caop(cb)
+ test(cao == cb)
+ cao = cb.caop(cc)
+ test(cao == cc)
+ cao = cc.caop(ca)
+ test(cao == ca)
+ cao = cc.caop(cb)
+ test(cao == cb)
+ cao = cc.caop(cc)
+ test(cao == cc)
+
+ cao = cb.cbop(cb)
+ test(cao == cb)
+ cbo = cb.cbop(cb)
+ test(cbo == cb)
+ cao = cb.cbop(cc)
+ test(cao == cc)
+ cbo = cb.cbop(cc)
+ test(cbo == cc)
+ cao = cc.cbop(cb)
+ test(cao == cb)
+ cbo = cc.cbop(cb)
+ test(cbo == cb)
+ cao = cc.cbop(cc)
+ test(cao == cc)
+ cbo = cc.cbop(cc)
+ test(cbo == cc)
+
+ cao = cc.ccop(cc)
+ test(cao == cc)
+ cbo = cc.ccop(cc)
+ test(cbo == cc)
+ cco = cc.ccop(cc)
+ test(cco == cc)
+ print("ok")
+
+ sys.stdout.write("ditto, but for interface hierarchy... ")
+ sys.stdout.flush()
+ iao = ia.iaop(ia)
+ test(iao == ia)
+ iao = ia.iaop(ib1)
+ test(iao == ib1)
+ iao = ia.iaop(ib2)
+ test(iao == ib2)
+ iao = ia.iaop(ic)
+ test(iao == ic)
+ iao = ib1.iaop(ia)
+ test(iao == ia)
+ iao = ib1.iaop(ib1)
+ test(iao == ib1)
+ iao = ib1.iaop(ib2)
+ test(iao == ib2)
+ iao = ib1.iaop(ic)
+ test(iao == ic)
+ iao = ib2.iaop(ia)
+ test(iao == ia)
+ iao = ib2.iaop(ib1)
+ test(iao == ib1)
+ iao = ib2.iaop(ib2)
+ test(iao == ib2)
+ iao = ib2.iaop(ic)
+ test(iao == ic)
+ iao = ic.iaop(ia)
+ test(iao == ia)
+ iao = ic.iaop(ib1)
+ test(iao == ib1)
+ iao = ic.iaop(ib2)
+ test(iao == ib2)
+ iao = ic.iaop(ic)
+ test(iao == ic)
+
+ iao = ib1.ib1op(ib1)
+ test(iao == ib1)
+ ib1o = ib1.ib1op(ib1)
+ test(ib1o == ib1)
+ iao = ib1.ib1op(ic)
+ test(iao == ic)
+ ib1o = ib1.ib1op(ic)
+ test(ib1o == ic)
+ iao = ic.ib1op(ib1)
+ test(iao == ib1)
+ ib1o = ic.ib1op(ib1)
+ test(ib1o == ib1)
+ iao = ic.ib1op(ic)
+ test(iao == ic)
+ ib1o = ic.ib1op(ic)
+ test(ib1o == ic)
+
+ iao = ib2.ib2op(ib2)
+ test(iao == ib2)
+ ib2o = ib2.ib2op(ib2)
+ test(ib2o == ib2)
+ iao = ib2.ib2op(ic)
+ test(iao == ic)
+ ib2o = ib2.ib2op(ic)
+ test(ib2o == ic)
+ iao = ic.ib2op(ib2)
+ test(iao == ib2)
+ ib2o = ic.ib2op(ib2)
+ test(ib2o == ib2)
+ iao = ic.ib2op(ic)
+ test(iao == ic)
+ ib2o = ic.ib2op(ic)
+ test(ib2o == ic)
+
+ iao = ic.icop(ic)
+ test(iao == ic)
+ ib1o = ic.icop(ic)
+ test(ib1o == ic)
+ ib2o = ic.icop(ic)
+ test(ib2o == ic)
+ ico = ic.icop(ic)
+ test(ico == ic)
+
+ print("ok")
+
+ sys.stdout.write("ditto, but for class implementing interfaces... ")
+ sys.stdout.flush()
+ cao = cd.caop(cd)
+ test(cao == cd)
+ cbo = cd.cbop(cd)
+ test(cbo == cd)
+ cco = cd.ccop(cd)
+ test(cco == cd)
+
+ iao = cd.iaop(cd)
+ test(iao == cd)
+ ib1o = cd.ib1op(cd)
+ test(ib1o == cd)
+ ib2o = cd.ib2op(cd)
+ test(ib2o == cd)
+
+ cao = cd.cdop(cd)
+ test(cao == cd)
+ cbo = cd.cdop(cd)
+ test(cbo == cd)
+ cco = cd.cdop(cd)
+ test(cco == cd)
+
+ iao = cd.cdop(cd)
+ test(iao == cd)
+ ib1o = cd.cdop(cd)
+ test(ib1o == cd)
+ ib2o = cd.cdop(cd)
+ test(ib2o == cd)
+
+ print("ok")
+
+ return initial
diff --git a/python/test/Ice/inheritance/Client.py b/python/test/Ice/inheritance/Client.py
new file mode 100755
index 00000000000..d3f92a4e4ed
--- /dev/null
+++ b/python/test/Ice/inheritance/Client.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 AllTests
+
+def run(args, communicator):
+ initial = AllTests.allTests(communicator)
+ initial.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/inheritance/Collocated.py b/python/test/Ice/inheritance/Collocated.py
new file mode 100755
index 00000000000..0652f4d9169
--- /dev/null
+++ b/python/test/Ice/inheritance/Collocated.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, TestI, AllTests
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ object = TestI.InitialI(adapter)
+ adapter.add(object, communicator.stringToIdentity("initial"))
+ #adapter.activate() // Don't activate OA to ensure collocation is used.
+
+ AllTests.allTests(communicator)
+
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/inheritance/Server.py b/python/test/Ice/inheritance/Server.py
new file mode 100755
index 00000000000..381c8e36ba4
--- /dev/null
+++ b/python/test/Ice/inheritance/Server.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ object = TestI.InitialI(adapter)
+ adapter.add(object, communicator.stringToIdentity("initial"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/inheritance/Test.ice b/python/test/Ice/inheritance/Test.ice
new file mode 100644
index 00000000000..7dd63ee98b6
--- /dev/null
+++ b/python/test/Ice/inheritance/Test.ice
@@ -0,0 +1,83 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+module MA
+{
+
+interface IA
+{
+ IA* iaop(IA* p);
+};
+
+class CA
+{
+ CA* caop(CA* p);
+};
+
+};
+
+module MB
+{
+
+interface IB1 extends MA::IA
+{
+ IB1* ib1op(IB1* p);
+};
+
+interface IB2 extends MA::IA
+{
+ IB2* ib2op(IB2* p);
+};
+
+class CB extends MA::CA
+{
+ CB* cbop(CB* p);
+};
+
+};
+
+module MA
+{
+
+interface IC extends MB::IB1, MB::IB2
+{
+ IC* icop(IC* p);
+};
+
+class CC extends MB::CB
+{
+ CC* ccop(CC* p);
+};
+
+class CD extends CC implements MB::IB1, MB::IB2
+{
+ CD* cdop(CD* p);
+};
+
+};
+
+interface Initial
+{
+ void shutdown();
+ MA::CA* caop();
+ MB::CB* cbop();
+ MA::CC* ccop();
+ MA::CD* cdop();
+ MA::IA* iaop();
+ MB::IB1* ib1op();
+ MB::IB2* ib2op();
+ MA::IC* icop();
+};
+
+};
diff --git a/python/test/Ice/inheritance/TestI.py b/python/test/Ice/inheritance/TestI.py
new file mode 100644
index 00000000000..291e1b46414
--- /dev/null
+++ b/python/test/Ice/inheritance/TestI.py
@@ -0,0 +1,80 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+class CAI(Test.MA.CA):
+ def caop(self, p, current=None):
+ return p
+
+class CBI(Test.MB.CB, CAI):
+ def cbop(self, p, current=None):
+ return p
+
+class CCI(Test.MA.CC, CBI):
+ def ccop(self, p, current=None):
+ return p
+
+class IAI(Test.MA.IA):
+ def iaop(self, p, current=None):
+ return p
+
+class IB1I(Test.MB.IB1, IAI):
+ def ib1op(self, p, current=None):
+ return p
+
+class IB2I(Test.MB.IB2, IAI):
+ def ib2op(self, p, current=None):
+ return p
+
+class ICI(Test.MA.IC, IB1I, IB2I):
+ def icop(self, p, current=None):
+ return p
+
+class CDI(Test.MA.CD, CCI, IB1I, IB2I):
+ def cdop(self, p, current=None):
+ return p
+
+class InitialI(Test.Initial):
+ def __init__(self, adapter):
+ self._ca = Test.MA.CAPrx.uncheckedCast(adapter.addWithUUID(CAI()))
+ self._cb = Test.MB.CBPrx.uncheckedCast(adapter.addWithUUID(CBI()))
+ self._cc = Test.MA.CCPrx.uncheckedCast(adapter.addWithUUID(CCI()))
+ self._cd = Test.MA.CDPrx.uncheckedCast(adapter.addWithUUID(CDI()))
+ self._ia = Test.MA.IAPrx.uncheckedCast(adapter.addWithUUID(IAI()))
+ self._ib1 = Test.MB.IB1Prx.uncheckedCast(adapter.addWithUUID(IB1I()))
+ self._ib2 = Test.MB.IB2Prx.uncheckedCast(adapter.addWithUUID(IB2I()))
+ self._ic = Test.MA.ICPrx.uncheckedCast(adapter.addWithUUID(ICI()))
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def caop(self, current=None):
+ return self._ca
+
+ def cbop(self, current=None):
+ return self._cb
+
+ def ccop(self, current=None):
+ return self._cc
+
+ def cdop(self, current=None):
+ return self._cd
+
+ def iaop(self, current=None):
+ return self._ia
+
+ def ib1op(self, current=None):
+ return self._ib1
+
+ def ib2op(self, current=None):
+ return self._ib2
+
+ def icop(self, current=None):
+ return self._ic
diff --git a/python/test/Ice/inheritance/run.py b/python/test/Ice/inheritance/run.py
new file mode 100755
index 00000000000..9487c74a4f5
--- /dev/null
+++ b/python/test/Ice/inheritance/run.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
+TestUtil.collocatedTest()
diff --git a/python/test/Ice/location/AllTests.py b/python/test/Ice/location/AllTests.py
new file mode 100644
index 00000000000..4fd5047e107
--- /dev/null
+++ b/python/test/Ice/location/AllTests.py
@@ -0,0 +1,256 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys
+
+class HelloI(Test.Hello):
+ def sayHello(self, current=None):
+ pass
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator, ref):
+ manager = Test.ServerManagerPrx.checkedCast(communicator.stringToProxy(ref))
+ locator = communicator.getDefaultLocator()
+ test(manager)
+
+ registry = Test.TestLocatorRegistryPrx.checkedCast(locator.getRegistry());
+ test(registry);
+
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ base = communicator.stringToProxy("test @ TestAdapter")
+ base2 = communicator.stringToProxy("test @ TestAdapter")
+ base3 = communicator.stringToProxy("test")
+ base4 = communicator.stringToProxy("ServerManager")
+ base5 = communicator.stringToProxy("test2")
+ print("ok")
+
+ sys.stdout.write("testing ice_locator and ice_getLocator... ")
+ sys.stdout.flush()
+ test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator()));
+ anotherLocator = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("anotherLocator"));
+ base = base.ice_locator(anotherLocator);
+ test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator));
+ communicator.setDefaultLocator(None);
+ base = communicator.stringToProxy("test @ TestAdapter");
+ test(not base.ice_getLocator());
+ base = base.ice_locator(anotherLocator);
+ test(Ice.proxyIdentityEqual(base.ice_getLocator(), anotherLocator));
+ communicator.setDefaultLocator(locator);
+ base = communicator.stringToProxy("test @ TestAdapter");
+ test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator()));
+
+ #
+ # We also test ice_router/ice_getRouter (perhaps we should add a
+ # test/Ice/router test?)
+ #
+ test(not base.ice_getRouter());
+ anotherRouter = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("anotherRouter"));
+ base = base.ice_router(anotherRouter);
+ test(Ice.proxyIdentityEqual(base.ice_getRouter(), anotherRouter));
+ router = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("dummyrouter"));
+ communicator.setDefaultRouter(router);
+ base = communicator.stringToProxy("test @ TestAdapter");
+ test(Ice.proxyIdentityEqual(base.ice_getRouter(), communicator.getDefaultRouter()));
+ communicator.setDefaultRouter(None);
+ base = communicator.stringToProxy("test @ TestAdapter");
+ test(not base.ice_getRouter());
+ print("ok")
+
+ sys.stdout.write("starting server... ")
+ sys.stdout.flush()
+ manager.startServer()
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ obj = Test.TestIntfPrx.checkedCast(base)
+ obj = Test.TestIntfPrx.checkedCast(communicator.stringToProxy("test@TestAdapter"))
+ obj = Test.TestIntfPrx.checkedCast(communicator.stringToProxy("test @TestAdapter"))
+ obj = Test.TestIntfPrx.checkedCast(communicator.stringToProxy("test@ TestAdapter"))
+ test(obj)
+ obj2 = Test.TestIntfPrx.checkedCast(base2)
+ test(obj2)
+ obj3 = Test.TestIntfPrx.checkedCast(base3)
+ test(obj3)
+ obj4 = Test.ServerManagerPrx.checkedCast(base4)
+ test(obj4)
+ obj5 = Test.TestIntfPrx.checkedCast(base5)
+ test(obj5)
+ print("ok")
+
+ sys.stdout.write("testing id@AdapterId indirect proxy... ")
+ sys.stdout.flush()
+ obj.shutdown()
+ manager.startServer()
+ try:
+ obj2 = Test.TestIntfPrx.checkedCast(base2)
+ obj2.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("testing identity indirect proxy... ")
+ sys.stdout.flush()
+ obj.shutdown()
+ manager.startServer()
+ try:
+ obj3 = Test.TestIntfPrx.checkedCast(base3)
+ obj3.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ try:
+ obj2 = Test.TestIntfPrx.checkedCast(base2)
+ obj2.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ obj.shutdown()
+ manager.startServer()
+ try:
+ obj2 = Test.TestIntfPrx.checkedCast(base2)
+ obj2.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ try:
+ obj3 = Test.TestIntfPrx.checkedCast(base3)
+ obj3.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ obj.shutdown()
+ manager.startServer()
+
+ try:
+ obj2 = Test.TestIntfPrx.checkedCast(base2)
+ obj2.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ obj.shutdown()
+ manager.startServer()
+ try:
+ obj3 = Test.TestIntfPrx.checkedCast(base3)
+ obj3.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ obj.shutdown()
+ manager.startServer()
+ try:
+ obj2 = Test.TestIntfPrx.checkedCast(base2)
+ obj2.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ obj.shutdown()
+ manager.startServer()
+
+ try:
+ obj5 = Test.TestIntfPrx.checkedCast(base5)
+ obj5.ice_ping()
+ except Ice.LocalException:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("testing reference with unknown identity... ")
+ sys.stdout.flush()
+ try:
+ base = communicator.stringToProxy("unknown/unknown")
+ base.ice_ping()
+ test(False)
+ except Ice.NotRegisteredException as ex:
+ test(ex.kindOfObject == "object")
+ test(ex.id == "unknown/unknown")
+ print("ok")
+
+ sys.stdout.write("testing reference with unknown adapter... ")
+ sys.stdout.flush()
+ try:
+ base = communicator.stringToProxy("test @ TestAdapterUnknown")
+ base.ice_ping()
+ test(False)
+ except Ice.NotRegisteredException as ex:
+ test(ex.kindOfObject == "object adapter")
+ test(ex.id == "TestAdapterUnknown")
+ print("ok")
+
+ sys.stdout.write("testing object reference from server... ")
+ sys.stdout.flush()
+ hello = obj.getHello()
+ hello.sayHello()
+ print("ok")
+
+ sys.stdout.write("testing object reference from server after shutdown... ")
+ sys.stdout.flush()
+ obj.shutdown()
+ manager.startServer()
+ hello.sayHello()
+ print("ok")
+
+ sys.stdout.write("testing object migration... ")
+ sys.stdout.flush()
+ hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("hello"))
+ obj.migrateHello()
+ hello.ice_getConnection().close(False);
+ hello.sayHello()
+ obj.migrateHello()
+ hello.sayHello()
+ obj.migrateHello()
+ hello.sayHello()
+ print("ok")
+
+ sys.stdout.write("shutdown server... ")
+ sys.stdout.flush()
+ obj.shutdown()
+ print("ok")
+
+ sys.stdout.write("testing whether server is gone... ")
+ sys.stdout.flush()
+ try:
+ obj2.ice_ping()
+ test(False)
+ except Ice.LocalException:
+ pass
+ try:
+ obj3.ice_ping()
+ test(False)
+ except Ice.LocalException:
+ pass
+ try:
+ obj5.ice_ping()
+ test(False)
+ except Ice.LocalException:
+ pass
+ print("ok")
+
+ #
+ # Set up test for calling a collocated object through an indirect, adapterless reference.
+ #
+ sys.stdout.write("testing indirect references to collocated objects... ")
+ sys.stdout.flush()
+ properties = communicator.getProperties();
+ properties.setProperty("Ice.PrintAdapterReady", "0");
+ adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default");
+ adapter.setLocator(locator);
+ assert(adapter.getLocator() == locator)
+
+ id = Ice.Identity();
+ id.name = Ice.generateUUID();
+ registry.addObject(adapter.add(HelloI(), id));
+ adapter.activate();
+
+ helloPrx = Test.HelloPrx.checkedCast(communicator.stringToProxy(communicator.identityToString(id)));
+ test(not helloPrx.ice_getConnection());
+
+ adapter.deactivate();
+ print("ok")
+
+ sys.stdout.write("shutdown server manager... ")
+ sys.stdout.flush()
+ manager.shutdown()
+ print("ok")
diff --git a/python/test/Ice/location/Client.py b/python/test/Ice/location/Client.py
new file mode 100755
index 00000000000..9ac5b7c03d1
--- /dev/null
+++ b/python/test/Ice/location/Client.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ AllTests.allTests(communicator, "ServerManager:default -p 12010")
+ return True
+
+try:
+ data = Ice.InitializationData()
+ data.properties = Ice.createProperties(sys.argv)
+ data.properties.setProperty("Ice.Default.Locator", "locator:default -p 12010")
+ communicator = Ice.initialize(sys.argv, data)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/location/Server.py b/python/test/Ice/location/Server.py
new file mode 100755
index 00000000000..481621a5efc
--- /dev/null
+++ b/python/test/Ice/location/Server.py
@@ -0,0 +1,199 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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 ServerLocatorRegistry(Test.TestLocatorRegistry):
+ def __init__(self):
+ self._adapters = {}
+ self._objects = {}
+
+ def setAdapterDirectProxy_async(self, cb, adapter, obj, current=None):
+ if obj:
+ self._adapters[adapter] = obj
+ else:
+ self._adapters.pop(adapter)
+ cb.ice_response()
+
+ def setReplicatedAdapterDirectProxy_async(self, cb, adapter, replica, obj, current=None):
+ if obj:
+ self._adapters[adapter] = obj
+ self._adapters[replica] = obj
+ else:
+ self._adapters.pop(adapter)
+ self._adapters.pop(replica)
+ cb.ice_response()
+
+ def setServerProcessProxy_async(self, id, proxy, current=None):
+ cb.ice_response()
+
+ def addObject(self, obj, current=None):
+ self._objects[obj.ice_getIdentity()] = obj
+
+ def getAdapter(self, adapter):
+ if adapter not in self._adapters:
+ raise Ice.AdapterNotFoundException()
+ return self._adapters[adapter]
+
+ def getObject(self, id):
+ if id not in self._objects:
+ raise Ice.ObjectNotFoundException()
+ return self._objects[id]
+
+class ServerLocator(Test.TestLocator):
+
+ def __init__(self, registry, registryPrx):
+ self._registry = registry
+ self._registryPrx = registryPrx
+ self._requestCount = 0
+
+ def findObjectById_async(self, response, id, current=None):
+ self._requestCount += 1
+ response.ice_response(self._registry.getObject(id))
+
+ def findAdapterById_async(self, response, id, current=None):
+ self._requestCount += 1
+ response.ice_response(self._registry.getAdapter(id))
+
+ def getRegistry(self, current=None):
+ return self._registryPrx
+
+ def getRequestCount(self, current=None):
+ return self._requestCount
+
+class ServerManagerI(Test.ServerManager):
+ def __init__(self, registry, initData):
+ self._registry = registry
+ self._communicators = []
+ self._initData = initData
+ self._initData.properties.setProperty("TestAdapter.Endpoints", "default")
+ self._initData.properties.setProperty("TestAdapter.AdapterId", "TestAdapter")
+ self._initData.properties.setProperty("TestAdapter.ReplicaGroupId", "ReplicatedAdapter")
+ self._initData.properties.setProperty("TestAdapter2.Endpoints", "default")
+ self._initData.properties.setProperty("TestAdapter2.AdapterId", "TestAdapter2")
+
+ def startServer(self, current=None):
+
+ #
+ # Simulate a server: create a new communicator and object
+ # adapter. The object adapter is started on a system allocated
+ # port. The configuration used here contains the Ice.Locator
+ # configuration variable. The new object adapter will register
+ # its endpoints with the locator and create references containing
+ # the adapter id instead of the endpoints.
+ #
+ serverCommunicator = Ice.initialize(data=initData)
+ self._communicators.append(serverCommunicator)
+ adapter = serverCommunicator.createObjectAdapter("TestAdapter")
+
+ adapter2 = serverCommunicator.createObjectAdapter("TestAdapter2")
+
+ locator = serverCommunicator.stringToProxy("locator:default -p 12010")
+ adapter.setLocator(Ice.LocatorPrx.uncheckedCast(locator))
+ adapter2.setLocator(Ice.LocatorPrx.uncheckedCast(locator))
+
+ object = TestI(adapter, adapter2, self._registry)
+ self._registry.addObject(adapter.add(object, communicator.stringToIdentity("test")))
+ self._registry.addObject(adapter.add(object, communicator.stringToIdentity("test2")))
+ adapter.add(object, communicator.stringToIdentity("test3"))
+
+ adapter.activate()
+ adapter2.activate()
+
+ def shutdown(self, current=None):
+ for i in self._communicators:
+ 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
+ self._adapter2 = adapter2
+ self._registry = registry
+ self._registry.addObject(self._adapter1.add(HelloI(), communicator.stringToIdentity("hello")))
+
+ def shutdown(self, current=None):
+ self._adapter1.getCommunicator().shutdown()
+
+ def getHello(self, current=None):
+ return Test.HelloPrx.uncheckedCast(self._adapter1.createIndirectProxy(communicator.stringToIdentity("hello")))
+
+ def getReplicatedHello(self, current=None):
+ return Test.HelloPrx.uncheckedCast(self._adapter1.createProxy(communicator.stringToIdentity("hello")))
+
+ def migrateHello(self, current=None):
+ id = communicator.stringToIdentity("hello")
+ try:
+ self._registry.addObject(self._adapter2.add(self._adapter1.remove(id), id))
+ 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:udp")
+
+ 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(communicator.stringToIdentity("ServerManager")))
+ object = ServerManagerI(registry, initData)
+ adapter.add(object, communicator.stringToIdentity("ServerManager"))
+
+ registryPrx = Ice.LocatorRegistryPrx.uncheckedCast(adapter.add(registry, communicator.stringToIdentity("registry")))
+
+ locator = ServerLocator(registry, registryPrx)
+ adapter.add(locator, communicator.stringToIdentity("locator"))
+
+ adapter.activate()
+ communicator.waitForShutdown()
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator, initData)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/location/Test.ice b/python/test/Ice/location/Test.ice
new file mode 100644
index 00000000000..82840ead2b6
--- /dev/null
+++ b/python/test/Ice/location/Test.ice
@@ -0,0 +1,55 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/Locator.ice>
+
+module Test
+{
+
+interface TestLocatorRegistry extends ::Ice::LocatorRegistry
+{
+ //
+ // Allow remote addition of objects to the locator registry.
+ //
+ void addObject(Object* obj);
+};
+
+interface TestLocator extends ::Ice::Locator
+{
+ //
+ // Returns the number of request on the locator interface.
+ //
+ ["cpp:const"] idempotent int getRequestCount();
+};
+
+interface ServerManager
+{
+ void startServer();
+ void shutdown();
+};
+
+interface Hello
+{
+ void sayHello();
+};
+
+interface TestIntf
+{
+ void shutdown();
+
+ Hello* getHello();
+
+ Hello* getReplicatedHello();
+
+ void migrateHello();
+};
+
+};
diff --git a/python/test/Ice/location/run.py b/python/test/Ice/location/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/location/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Ice/objects/AllTests.py b/python/test/Ice/objects/AllTests.py
new file mode 100644
index 00000000000..d7de69b901c
--- /dev/null
+++ b/python/test/Ice/objects/AllTests.py
@@ -0,0 +1,226 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, TestI, sys
+
+class MyObjectFactory(Ice.ObjectFactory):
+ def create(self, type):
+ if type == '::Test::B':
+ return TestI.BI()
+ elif type == '::Test::C':
+ return TestI.CI()
+ elif type == '::Test::D':
+ return TestI.DI()
+ elif type == '::Test::E':
+ return TestI.EI()
+ elif type == '::Test::F':
+ return TestI.FI()
+ elif type == '::Test::I':
+ return TestI.II()
+ elif type == '::Test::J':
+ return TestI.JI()
+ elif type == '::Test::H':
+ return TestI.HI()
+ assert(False) # Should never be reached
+
+ def destroy(self):
+ # Nothing to do
+ pass
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ factory = MyObjectFactory()
+ communicator.addObjectFactory(factory, '::Test::B')
+ communicator.addObjectFactory(factory, '::Test::C')
+ communicator.addObjectFactory(factory, '::Test::D')
+ communicator.addObjectFactory(factory, '::Test::E')
+ communicator.addObjectFactory(factory, '::Test::F')
+ communicator.addObjectFactory(factory, '::Test::I')
+ communicator.addObjectFactory(factory, '::Test::J')
+ communicator.addObjectFactory(factory, '::Test::H')
+
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ ref = "initial:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ initial = Test.InitialPrx.checkedCast(base)
+ test(initial)
+ test(initial == base)
+ print("ok")
+
+ sys.stdout.write("getting B1... ")
+ sys.stdout.flush()
+ b1 = initial.getB1()
+ test(b1)
+ print("ok")
+
+ sys.stdout.write("getting B2... ")
+ sys.stdout.flush()
+ b2 = initial.getB2()
+ test(b2)
+ print("ok")
+
+ sys.stdout.write("getting C... ")
+ sys.stdout.flush()
+ c = initial.getC()
+ test(c)
+ print("ok")
+
+ sys.stdout.write("getting D... ")
+ sys.stdout.flush()
+ d = initial.getD()
+ test(d)
+ print("ok")
+
+ sys.stdout.write("testing protected members... ")
+ sys.stdout.flush()
+ e = initial.getE()
+ test(e.checkValues())
+ test(e._i == 1)
+ test(e._s == "hello")
+ f = initial.getF()
+ test(f.checkValues())
+ test(f.e2.checkValues())
+ test(f._e1.checkValues())
+ print("ok")
+
+ sys.stdout.write("getting I, J, H... ")
+ sys.stdout.flush()
+ i = initial.getI()
+ test(i)
+ j = initial.getJ()
+ test(isinstance(j, Test.J))
+ h = initial.getH()
+ test(isinstance(h, Test.H))
+ print("ok")
+
+ sys.stdout.write("setting I... ")
+ sys.stdout.flush()
+ initial.setI(TestI.II())
+ initial.setI(TestI.JI())
+ initial.setI(TestI.HI())
+ print("ok")
+
+ sys.stdout.write("checking consistency... ")
+ sys.stdout.flush()
+ test(b1 != b2)
+ test(b1 != c)
+ test(b1 != d)
+ test(b2 != c)
+ test(b2 != d)
+ test(c != d)
+ test(b1.theB == b1)
+ test(b1.theC == None)
+ test(isinstance(b1.theA, Test.B))
+ test(b1.theA.theA == b1.theA)
+ test(b1.theA.theB == b1)
+ test(b1.theA.theC)
+ test(b1.theA.theC.theB == b1.theA)
+ test(b1.preMarshalInvoked)
+ test(b1.postUnmarshalInvoked())
+ test(b1.theA.preMarshalInvoked)
+ test(b1.theA.postUnmarshalInvoked())
+ test(b1.theA.theC.preMarshalInvoked)
+ test(b1.theA.theC.postUnmarshalInvoked())
+ # More tests possible for b2 and d, but I think this is already sufficient.
+ test(b2.theA == b2)
+ test(d.theC == None)
+ print("ok")
+
+ sys.stdout.write("getting B1, B2, C, and D all at once... ")
+ sys.stdout.flush()
+ b1, b2, c, d = initial.getAll()
+ test(b1)
+ test(b2)
+ test(c)
+ test(d)
+ print("ok")
+
+ sys.stdout.write("checking consistency... ")
+ sys.stdout.flush()
+ test(b1 != b2)
+ test(b1 != c)
+ test(b1 != d)
+ test(b2 != c)
+ test(b2 != d)
+ test(c != d)
+ test(b1.theA == b2)
+ test(b1.theB == b1)
+ test(b1.theC == None)
+ test(b2.theA == b2)
+ test(b2.theB == b1)
+ test(b2.theC == c)
+ test(c.theB == b2)
+ test(d.theA == b1)
+ test(d.theB == b2)
+ test(d.theC == None)
+ test(d.preMarshalInvoked)
+ test(d.postUnmarshalInvoked())
+ test(d.theA.preMarshalInvoked)
+ test(d.theA.postUnmarshalInvoked())
+ test(d.theB.preMarshalInvoked)
+ test(d.theB.postUnmarshalInvoked())
+ test(d.theB.theC.preMarshalInvoked)
+ test(d.theB.theC.postUnmarshalInvoked())
+ print("ok")
+
+ sys.stdout.write("testing sequences... ")
+ try:
+ sys.stdout.flush()
+ initial.opBaseSeq([])
+
+ retS, outS = initial.opBaseSeq([Test.Base()])
+ test(len(retS) == 1 and len(outS) == 1)
+ except Ice.OperationNotExistException:
+ pass
+ print("ok")
+
+ sys.stdout.write("testing compact ID... ")
+ sys.stdout.flush()
+ try:
+ r = initial.getCompact()
+ test(r)
+ except Ice.OperationNotExistException:
+ pass
+ print("ok")
+
+ # Don't run this test with collocation, this should work with collocation
+ # but the test isn't written to support it (we'd need support for the
+ # streaming interface)
+ if initial.ice_getConnection():
+ sys.stdout.write("testing UnexpectedObjectException... ")
+ sys.stdout.flush()
+ ref = "uoet:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+ uoet = Test.UnexpectedObjectExceptionTestPrx.uncheckedCast(base)
+ test(uoet)
+ try:
+ uoet.op()
+ test(False)
+ except Ice.UnexpectedObjectException as ex:
+ test(ex.type == "::Test::AlsoEmpty")
+ test(ex.expectedType == "::Test::Empty")
+ except Ice.Exception as ex:
+ print(ex)
+ test(False)
+ except:
+ print(sys.exc_info())
+ test(False)
+ print("ok")
+
+ return initial
diff --git a/python/test/Ice/objects/Client.py b/python/test/Ice/objects/Client.py
new file mode 100755
index 00000000000..ba3057aed04
--- /dev/null
+++ b/python/test/Ice/objects/Client.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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')
+Ice.loadSlice('ClientPrivate.ice')
+import AllTests
+
+def run(args, communicator):
+ initial = AllTests.allTests(communicator)
+ initial.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/objects/ClientPrivate.ice b/python/test/Ice/objects/ClientPrivate.ice
new file mode 100644
index 00000000000..31d2e12d833
--- /dev/null
+++ b/python/test/Ice/objects/ClientPrivate.ice
@@ -0,0 +1,68 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+class Empty
+{
+};
+
+class AlsoEmpty
+{
+};
+
+interface UnexpectedObjectExceptionTest
+{
+ Empty op();
+};
+
+//
+// Remaining definitions are here to ensure that the generated code compiles.
+//
+
+class COneMember
+{
+ Empty e;
+};
+
+class CTwoMembers
+{
+ Empty e1;
+ Empty e2;
+};
+
+exception EOneMember
+{
+ Empty e;
+};
+
+exception ETwoMembers
+{
+ Empty e1;
+ Empty e2;
+};
+
+struct SOneMember
+{
+ Empty e;
+};
+
+struct STwoMembers
+{
+ Empty e1;
+ Empty e2;
+};
+
+dictionary<int, COneMember> DOneMember;
+dictionary<int, CTwoMembers> DTwoMembers;
+
+};
diff --git a/python/test/Ice/objects/Collocated.py b/python/test/Ice/objects/Collocated.py
new file mode 100755
index 00000000000..321c351de56
--- /dev/null
+++ b/python/test/Ice/objects/Collocated.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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')
+Ice.loadSlice('ClientPrivate.ice')
+import Test, TestI, AllTests
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ initial = TestI.InitialI(adapter)
+ adapter.add(initial, communicator.stringToIdentity("initial"))
+ uoet = TestI.UnexpectedObjectExceptionTestI()
+ adapter.add(uoet, communicator.stringToIdentity("uoet"))
+ #adapter.activate() // Don't activate OA to ensure collocation is used.
+
+ AllTests.allTests(communicator)
+
+ # We must call shutdown even in the collocated case for cyclic dependency cleanup
+ initial.shutdown()
+
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/objects/Server.py b/python/test/Ice/objects/Server.py
new file mode 100755
index 00000000000..d988b501d14
--- /dev/null
+++ b/python/test/Ice/objects/Server.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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')
+Ice.loadSlice('ServerPrivate.ice')
+import Test, TestI
+
+class MyObjectFactory(Ice.ObjectFactory):
+ def create(self, type):
+ if type == '::Test::I':
+ return TestI.II()
+ elif type == '::Test::J':
+ return TestI.JI()
+ elif type == '::Test::H':
+ return TestI.HI()
+ assert(False) # Should never be reached
+
+ def destroy(self):
+ # Nothing to do
+ pass
+
+def run(args, communicator):
+ factory = MyObjectFactory()
+ communicator.addObjectFactory(factory, '::Test::I')
+ communicator.addObjectFactory(factory, '::Test::J')
+ communicator.addObjectFactory(factory, '::Test::H')
+
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ initial = TestI.InitialI(adapter)
+ adapter.add(initial, communicator.stringToIdentity("initial"))
+ uoet = TestI.UnexpectedObjectExceptionTestI()
+ adapter.add(uoet, communicator.stringToIdentity("uoet"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/objects/ServerPrivate.ice b/python/test/Ice/objects/ServerPrivate.ice
new file mode 100644
index 00000000000..f7920ba6de8
--- /dev/null
+++ b/python/test/Ice/objects/ServerPrivate.ice
@@ -0,0 +1,68 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+class Empty
+{
+};
+
+class AlsoEmpty
+{
+};
+
+interface UnexpectedObjectExceptionTest
+{
+ AlsoEmpty op();
+};
+
+//
+// Remaining definitions are here to ensure that the generated code compiles.
+//
+
+class COneMember
+{
+ Empty e;
+};
+
+class CTwoMembers
+{
+ Empty e1;
+ Empty e2;
+};
+
+exception EOneMember
+{
+ Empty e;
+};
+
+exception ETwoMembers
+{
+ Empty e1;
+ Empty e2;
+};
+
+struct SOneMember
+{
+ Empty e;
+};
+
+struct STwoMembers
+{
+ Empty e1;
+ Empty e2;
+};
+
+dictionary<int, COneMember> DOneMember;
+dictionary<int, CTwoMembers> DTwoMembers;
+
+};
diff --git a/python/test/Ice/objects/Test.ice b/python/test/Ice/objects/Test.ice
new file mode 100644
index 00000000000..42852d1f75c
--- /dev/null
+++ b/python/test/Ice/objects/Test.ice
@@ -0,0 +1,131 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+struct S
+{
+ string str;
+};
+
+class Base
+{
+ S theS;
+ string str;
+};
+
+class AbstractBase extends Base
+{
+ void op();
+};
+
+class B;
+class C;
+
+class A
+{
+ B theB;
+ C theC;
+
+ bool preMarshalInvoked;
+ bool postUnmarshalInvoked();
+};
+
+class B extends A
+{
+ A theA;
+};
+
+class C
+{
+ B theB;
+
+ bool preMarshalInvoked;
+ bool postUnmarshalInvoked();
+};
+
+class D
+{
+ A theA;
+ B theB;
+ C theC;
+
+ bool preMarshalInvoked;
+ bool postUnmarshalInvoked();
+};
+
+["protected"] class E
+{
+ int i;
+ string s;
+
+ bool checkValues();
+};
+
+class F
+{
+ ["protected"] E e1;
+ E e2;
+
+ bool checkValues();
+};
+
+interface I
+{
+};
+
+interface J extends I
+{
+};
+
+class H implements I
+{
+};
+
+sequence<Base> BaseSeq;
+
+class CompactExt;
+
+class Compact(1)
+{
+};
+
+const int CompactExtId = 789;
+
+class CompactExt(CompactExtId) extends Compact
+{
+};
+
+class Initial
+{
+ void shutdown();
+ B getB1();
+ B getB2();
+ C getC();
+ D getD();
+ E getE();
+ F getF();
+
+ void getAll(out B b1, out B b2, out C theC, out D theD);
+
+ I getI();
+ I getJ();
+ I getH();
+
+ void setI(I theI);
+
+ BaseSeq opBaseSeq(BaseSeq inSeq, out BaseSeq outSeq);
+
+ Compact getCompact();
+};
+
+};
diff --git a/python/test/Ice/objects/TestI.py b/python/test/Ice/objects/TestI.py
new file mode 100644
index 00000000000..5fc8b0cedca
--- /dev/null
+++ b/python/test/Ice/objects/TestI.py
@@ -0,0 +1,162 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+class BI(Test.B):
+ def __init__(self):
+ self.preMarshalInvoked = False
+ self._postUnmarshalInvoked = False
+
+ def postUnmarshalInvoked(self, current=None):
+ return self._postUnmarshalInvoked
+
+ def ice_preMarshal(self):
+ self.preMarshalInvoked = True
+
+ def ice_postUnmarshal(self):
+ self._postUnmarshalInvoked = True
+
+class CI(Test.C):
+ def __init__(self):
+ self.preMarshalInvoked = False
+ self._postUnmarshalInvoked = False
+
+ def postUnmarshalInvoked(self, current=None):
+ return self._postUnmarshalInvoked
+
+ def ice_preMarshal(self):
+ self.preMarshalInvoked = True
+
+ def ice_postUnmarshal(self):
+ self._postUnmarshalInvoked = True
+
+class DI(Test.D):
+ def __init__(self):
+ self.preMarshalInvoked = False
+ self._postUnmarshalInvoked = False
+
+ def postUnmarshalInvoked(self, current=None):
+ return self._postUnmarshalInvoked
+
+ def ice_preMarshal(self):
+ self.preMarshalInvoked = True
+
+ def ice_postUnmarshal(self):
+ self._postUnmarshalInvoked = True
+
+class EI(Test.E):
+ def __init__(self):
+ Test.E.__init__(self, 1, "hello")
+
+ def checkValues(self, current=None):
+ return self._i == 1 and self._s == "hello"
+
+class FI(Test.F):
+ def __init__(self, e=None):
+ Test.F.__init__(self, e, e)
+
+ def checkValues(self, current=None):
+ return self._e1 != None and self._e1 == self.e2
+
+class II(Test.I):
+ pass
+
+class JI(Test.J):
+ pass
+
+class HI(Test.H):
+ pass
+
+class InitialI(Test.Initial):
+ def __init__(self, adapter):
+ self._adapter = adapter
+ self._b1 = BI()
+ self._b2 = BI()
+ self._c = CI()
+ self._d = DI()
+ self._e = EI()
+ self._f = FI(self._e)
+
+ self._b1.theA = self._b2 # Cyclic reference to another B
+ self._b1.theB = self._b1 # Self reference.
+ self._b1.theC = None # Null reference.
+
+ self._b2.theA = self._b2 # Self reference, using base.
+ self._b2.theB = self._b1 # Cyclic reference to another B
+ self._b2.theC = self._c # Cyclic reference to a C.
+
+ self._c.theB = self._b2 # Cyclic reference to a B.
+
+ self._d.theA = self._b1 # Reference to a B.
+ self._d.theB = self._b2 # Reference to a B.
+ self._d.theC = None # Reference to a C.
+
+ def shutdown(self, current=None):
+ self._adapter.getCommunicator().shutdown()
+
+ def getB1(self, current=None):
+ self._b1.preMarshalInvoked = False
+ self._b2.preMarshalInvoked = False
+ self._c.preMarshalInvoked = False
+ return self._b1
+
+ def getB2(self, current=None):
+ self._b1.preMarshalInvoked = False
+ self._b2.preMarshalInvoked = False
+ self._c.preMarshalInvoked = False
+ return self._b2
+
+ def getC(self, current=None):
+ self._b1.preMarshalInvoked = False
+ self._b2.preMarshalInvoked = False
+ self._c.preMarshalInvoked = False
+ return self._c
+
+ def getD(self, current=None):
+ self._b1.preMarshalInvoked = False
+ self._b2.preMarshalInvoked = False
+ self._c.preMarshalInvoked = False
+ self._d.preMarshalInvoked = False
+ return self._d
+
+ def getE(self, current=None):
+ return self._e
+
+ def getF(self, current=None):
+ return self._f
+
+ def getAll(self, current=None):
+ self._b1.preMarshalInvoked = False
+ self._b2.preMarshalInvoked = False
+ self._c.preMarshalInvoked = False
+ self._d.preMarshalInvoked = False
+ return (self._b1, self._b2, self._c, self._d)
+
+ def getI(self, current=None):
+ return II()
+
+ def getJ(self, current=None):
+ return JI()
+
+ def getH(self, current=None):
+ return HI()
+
+ def setI(self, i, current=None):
+ pass
+
+ def opBaseSeq(self, inSeq, current=None):
+ return (inSeq, inSeq)
+
+ def getCompact(self, current=None):
+ return Test.CompactExt()
+
+class UnexpectedObjectExceptionTestI(Test.UnexpectedObjectExceptionTest):
+ def op(self, current=None):
+ return Test.AlsoEmpty()
diff --git a/python/test/Ice/objects/run.py b/python/test/Ice/objects/run.py
new file mode 100755
index 00000000000..9e92332d98b
--- /dev/null
+++ b/python/test/Ice/objects/run.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("Running test with compact (default) format.")
+TestUtil.clientServerTest()
+
+print("Running test with sliced format.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.SlicedFormat",
+ additionalServerOptions="--Ice.Default.SlicedFormat")
+
+print("Running test with 1.0 encoding.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
+
+print("Running collocated test.")
+TestUtil.collocatedTest()
diff --git a/python/test/Ice/operations/AllTests.py b/python/test/Ice/operations/AllTests.py
new file mode 100644
index 00000000000..a3d3bac823a
--- /dev/null
+++ b/python/test/Ice/operations/AllTests.py
@@ -0,0 +1,57 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, Twoways, TwowaysAMI, Oneways, OnewaysAMI, BatchOneways, sys
+import BatchOnewaysAMI
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ ref = "test:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ cl = Test.MyClassPrx.checkedCast(base)
+ derived = Test.MyDerivedClassPrx.checkedCast(cl)
+
+ sys.stdout.write("testing twoway operations... ")
+ sys.stdout.flush()
+ Twoways.twoways(communicator, cl)
+ Twoways.twoways(communicator, derived)
+ derived.opDerived()
+ print("ok")
+
+ sys.stdout.write("testing oneway operations... ")
+ sys.stdout.flush()
+ Oneways.oneways(communicator, cl)
+ print("ok")
+
+ sys.stdout.write("testing twoway operations with AMI... ")
+ sys.stdout.flush()
+ TwowaysAMI.twowaysAMI(communicator, cl)
+ print("ok")
+
+ sys.stdout.write("testing oneway operations with AMI... ")
+ sys.stdout.flush()
+ OnewaysAMI.onewaysAMI(communicator, cl)
+ print("ok")
+
+ sys.stdout.write("testing batch oneway operations... ")
+ sys.stdout.flush()
+ BatchOneways.batchOneways(cl)
+ BatchOneways.batchOneways(derived)
+ print("ok")
+
+ sys.stdout.write("testing batch AMI oneway operations... ")
+ sys.stdout.flush()
+ BatchOnewaysAMI.batchOneways(cl)
+ BatchOnewaysAMI.batchOneways(derived)
+ print("ok")
+
+ return cl
diff --git a/python/test/Ice/operations/BatchOneways.py b/python/test/Ice/operations/BatchOneways.py
new file mode 100644
index 00000000000..0e73c6f1a2d
--- /dev/null
+++ b/python/test/Ice/operations/BatchOneways.py
@@ -0,0 +1,145 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, array, sys, time
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class BatchRequestInterceptorI(Ice.BatchRequestInterceptor):
+
+ def __init__(self):
+ self._enabled = False
+ self._count = 0
+ self._size = 0
+ self._lastRequestSize = 0
+
+ def enqueue(self, request, count, size):
+ test(request.getOperation() == "opByteSOneway" or request.getOperation() == "ice_ping")
+ test(request.getProxy().ice_isBatchOneway())
+
+ if count > 0:
+ test(self._lastRequestSize + self._size == size)
+
+ self._count = count
+ self._size = size
+
+ if self._size + request.getSize() > 25000:
+ request.getProxy().begin_ice_flushBatchRequests()
+ self._size = 18 # header
+
+ if self._enabled:
+ self._lastRequestSize = request.getSize()
+ self._count += 1
+ request.enqueue()
+
+ def setEnabled(self, v):
+ self._enabled = v
+
+ def count(self):
+ return self._count
+
+def batchOneways(p):
+
+ if sys.version_info[0] == 2:
+ bs1 = []
+ bs1[0:10 * 1024] = range(0, 10 * 1024) # add 100,000 entries.
+ bs1 = ['\x00' for x in bs1] # set them all to \x00
+ bs1 = ''.join(bs1) # make into a byte array
+ else:
+ bs1 = bytes([0 for x in range(0, 10 * 1024)])
+
+ try:
+ p.opByteSOneway(bs1)
+ except Ice.MemoryLimitException:
+ test(False)
+
+ batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
+
+ batch.ice_flushBatchRequests() # Empty flush
+
+ p.opByteSOnewayCallCount() # Reset the call count
+
+ for i in range(30):
+ batch.opByteSOneway(bs1)
+
+ count = 0
+ while count < 27: # 3 * 9 requests auto-flushed.
+ count += p.opByteSOnewayCallCount()
+ time.sleep(0.01)
+
+ if p.ice_getConnection():
+ batch1 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
+ batch2 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
+
+ batch1.ice_ping()
+ batch2.ice_ping()
+ batch1.ice_flushBatchRequests()
+ batch1.ice_getConnection().close(False)
+ batch1.ice_ping()
+ batch2.ice_ping()
+
+ batch1.ice_getConnection()
+ batch2.ice_getConnection()
+
+ batch1.ice_ping()
+ batch1.ice_getConnection().close(False)
+
+ batch1.ice_ping()
+ batch2.ice_ping()
+
+ identity = Ice.Identity()
+ identity.name = "invalid";
+ batch3 = batch.ice_identity(identity)
+ batch3.ice_ping()
+ batch3.ice_flushBatchRequests()
+
+ # Make sure that a bogus batch request doesn't cause troubles to other ones.
+ batch3.ice_ping()
+ batch.ice_ping()
+ batch.ice_flushBatchRequests()
+ batch.ice_ping()
+
+ if batch.ice_getConnection():
+ initData = Ice.InitializationData()
+ initData.properties = p.ice_getCommunicator().getProperties().clone()
+ interceptor = BatchRequestInterceptorI()
+ initData.batchRequestInterceptor = interceptor
+
+ ic = Ice.initialize(data=initData)
+
+ batch = Test.MyClassPrx.uncheckedCast(ic.stringToProxy(p.ice_toString())).ice_batchOneway()
+
+ test(interceptor.count() == 0)
+ batch.ice_ping()
+ batch.ice_ping()
+ batch.ice_ping()
+ test(interceptor.count() == 0)
+
+ interceptor.setEnabled(True)
+ batch.ice_ping()
+ batch.ice_ping()
+ batch.ice_ping()
+ test(interceptor.count() == 3)
+
+ batch.ice_flushBatchRequests()
+ batch.ice_ping()
+ test(interceptor.count() == 1)
+
+ batch.opByteSOneway(bs1)
+ test(interceptor.count() == 2)
+ batch.opByteSOneway(bs1)
+ test(interceptor.count() == 3)
+
+ batch.opByteSOneway(bs1) # This should trigger the flush
+ batch.ice_ping()
+ test(interceptor.count() == 2)
+
+ ic.destroy()
diff --git a/python/test/Ice/operations/BatchOnewaysAMI.py b/python/test/Ice/operations/BatchOnewaysAMI.py
new file mode 100644
index 00000000000..f78bf40db04
--- /dev/null
+++ b/python/test/Ice/operations/BatchOnewaysAMI.py
@@ -0,0 +1,90 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, array, sys, threading, time
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class Callback:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def check(self):
+ self._cond.acquire()
+ try:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ finally:
+ self._cond.release()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+def batchOneways(p):
+
+ if sys.version_info[0] == 2:
+ bs1 = []
+ bs1[0:10 * 1024] = range(0, 10 * 1024) # add 100,000 entries.
+ bs1 = ['\x00' for x in bs1] # set them all to \x00
+ bs1 = ''.join(bs1) # make into a byte array
+ else:
+ bs1 = bytes([0 for x in range(0, 10 * 1024)])
+ batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
+
+ batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests()) # Empty flush
+ test(batch.begin_ice_flushBatchRequests().isSent()) # Empty flush
+ test(batch.begin_ice_flushBatchRequests().isCompleted()) # Empty flush
+ test(batch.begin_ice_flushBatchRequests().sentSynchronously()) # Empty flush
+
+ for i in range(30):
+ batch.begin_opByteSOneway(bs1, lambda: 0, lambda ex: test(False) )
+
+ count = 0
+ while count < 27: # 3 * 9 requests auto-flushed.
+ count += p.opByteSOnewayCallCount()
+ time.sleep(0.01)
+
+ if p.ice_getConnection():
+
+ batch1 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
+ batch2 = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
+
+ batch1.end_ice_ping(batch1.begin_ice_ping())
+ batch2.end_ice_ping(batch2.begin_ice_ping())
+ batch1.end_ice_flushBatchRequests(batch1.begin_ice_flushBatchRequests())
+ batch1.ice_getConnection().close(False)
+ batch1.end_ice_ping(batch1.begin_ice_ping())
+ batch2.end_ice_ping(batch2.begin_ice_ping())
+
+ batch1.ice_getConnection()
+ batch2.ice_getConnection()
+
+ batch1.ice_getConnection().close(False)
+
+ batch1.end_ice_ping(batch1.begin_ice_ping())
+ batch2.end_ice_ping(batch2.begin_ice_ping())
+
+ identity = Ice.Identity()
+ identity.name = "invalid";
+ batch3 = batch.ice_identity(identity)
+ batch3.ice_ping()
+ batch3.end_ice_flushBatchRequests(batch3.begin_ice_flushBatchRequests())
+
+ # Make sure that a bogus batch request doesn't cause troubles to other ones.
+ batch3.ice_ping()
+ batch.ice_ping()
+ batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests())
+ batch.ice_ping()
diff --git a/python/test/Ice/operations/Client.py b/python/test/Ice/operations/Client.py
new file mode 100755
index 00000000000..2c18f66d07d
--- /dev/null
+++ b/python/test/Ice/operations/Client.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+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 AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ myClass = AllTests.allTests(communicator)
+
+ sys.stdout.write("testing server shutdown... ")
+ sys.stdout.flush()
+ myClass.shutdown()
+ try:
+ myClass.opVoid()
+ test(False)
+ except Ice.LocalException:
+ print("ok")
+
+ return True
+
+try:
+ #
+ # In this test, we need at least two threads in the
+ # client side thread pool for nested AMI.
+ #
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty('Ice.ThreadPool.Client.Size', '2')
+ initData.properties.setProperty('Ice.ThreadPool.Client.SizeWarn', '0')
+ initData.properties.setProperty("Ice.BatchAutoFlushSize", "100")
+
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/operations/Collocated.py b/python/test/Ice/operations/Collocated.py
new file mode 100755
index 00000000000..cabd7890618
--- /dev/null
+++ b/python/test/Ice/operations/Collocated.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI, AllTests
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ prx = adapter.add(TestI.MyDerivedClassI(), communicator.stringToIdentity("test"))
+ #adapter.activate() // Don't activate OA to ensure collocation is used.
+
+ if prx.ice_getConnection():
+ raise RuntimeError("collocation doesn't work")
+
+ cl = AllTests.allTests(communicator)
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+
+ initData.properties.setProperty("Ice.BatchAutoFlushSize", "100")
+
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/operations/Oneways.py b/python/test/Ice/operations/Oneways.py
new file mode 100644
index 00000000000..a64d9103ce9
--- /dev/null
+++ b/python/test/Ice/operations/Oneways.py
@@ -0,0 +1,46 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, math, Test, array
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def oneways(communicator, p):
+
+ p = Test.MyClassPrx.uncheckedCast(p.ice_oneway())
+
+ #
+ # ice_ping
+ #
+ p.ice_ping()
+
+ #
+ # opVoid
+ #
+ p.opVoid()
+
+ #
+ # opIdempotent
+ #
+ p.opIdempotent()
+
+ #
+ # opNonmutating
+ #
+ p.opNonmutating()
+
+ #
+ # opByte
+ #
+ try:
+ p.opByte(0xff, 0x0f)
+ except Ice.TwowayOnlyException:
+ pass
diff --git a/python/test/Ice/operations/OnewaysAMI.py b/python/test/Ice/operations/OnewaysAMI.py
new file mode 100644
index 00000000000..1068cb2e9b0
--- /dev/null
+++ b/python/test/Ice/operations/OnewaysAMI.py
@@ -0,0 +1,85 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class CallbackBase:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def check(self):
+ self._cond.acquire()
+ try:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ finally:
+ self._cond.release()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+class Callback(CallbackBase):
+ def sent(self, sentSynchronously):
+ self.called()
+
+ def noException(self, ex):
+ test(False)
+
+def onewaysAMI(communicator, proxy):
+
+ p = Test.MyClassPrx.uncheckedCast(proxy.ice_oneway())
+
+ cb = Callback()
+ p.begin_ice_ping(None, cb.noException, cb.sent)
+ cb.check()
+
+ try:
+ p.begin_ice_isA(Test.MyClass.ice_staticId())
+ test(False)
+ except RuntimeError:
+ pass
+
+ try:
+ p.begin_ice_id()
+ test(False)
+ except RuntimeError:
+ pass
+
+ try:
+ p.begin_ice_ids()
+ test(False)
+ except RuntimeError:
+ pass
+
+ cb = Callback()
+ p.begin_opVoid(None, cb.noException, cb.sent)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opIdempotent(None, cb.noException, cb.sent)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opNonmutating(None, cb.noException, cb.sent)
+ cb.check()
+
+ try:
+ p.begin_opByte(0xff, 0x0f)
+ test(False)
+ except RuntimeError:
+ pass
diff --git a/python/test/Ice/operations/Server.py b/python/test/Ice/operations/Server.py
new file mode 100755
index 00000000000..b7f2045fd1b
--- /dev/null
+++ b/python/test/Ice/operations/Server.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(TestI.MyDerivedClassI(), communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ #
+ # Its possible to have batch oneway requests dispatched after the
+ # adapter is deactivated due to thread scheduling so we supress
+ # this warning.
+ #
+ initData.properties.setProperty("Ice.Warn.Dispatch", "0");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/operations/ServerAMD.py b/python/test/Ice/operations/ServerAMD.py
new file mode 100755
index 00000000000..61565b37353
--- /dev/null
+++ b/python/test/Ice/operations/ServerAMD.py
@@ -0,0 +1,432 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, threading
+
+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 + "' TestAMD.ice")
+import Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class Thread_opVoid(threading.Thread):
+ def __init__(self, cb):
+ threading.Thread.__init__(self)
+ self.cb = cb
+
+ def run(self):
+ self.cb.ice_response()
+
+class MyDerivedClassI(Test.MyDerivedClass):
+ def __init__(self):
+ self.opVoidThread = None
+ self.opVoidThreadLock = threading.Lock()
+ self.lock = threading.Lock()
+ self.opByteSOnewayCount = 0
+
+ def ice_isA(self, id, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_isA(self, id, current)
+
+ def ice_ping(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ Test.MyDerivedClass.ice_ping(self, current)
+
+ def ice_ids(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_ids(self, current)
+
+ def ice_id(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_id(self, current)
+
+ def shutdown_async(self, cb, current=None):
+ self.opVoidThreadLock.acquire()
+ if self.opVoidThread:
+ self.opVoidThread.join()
+ self.opVoidThread = None
+ self.opVoidThreadLock.release()
+
+ current.adapter.getCommunicator().shutdown()
+ cb.ice_response()
+
+ def opVoid_async(self, cb, current=None):
+ test(current.mode == Ice.OperationMode.Normal)
+
+ self.opVoidThreadLock.acquire()
+ if self.opVoidThread:
+ self.opVoidThread.join()
+ self.opVoidThread = None
+
+ self.opVoidThread = Thread_opVoid(cb)
+ self.opVoidThread.start()
+ self.opVoidThreadLock.release()
+
+ def opByte_async(self, cb, p1, p2, current=None):
+ cb.ice_response(p1, p1 ^ p2)
+
+ def opBool_async(self, cb, p1, p2, current=None):
+ cb.ice_response(p2, p1)
+
+ def opShortIntLong_async(self, cb, p1, p2, p3, current=None):
+ cb.ice_response(p3, p1, p2, p3)
+
+ def opFloatDouble_async(self, cb, p1, p2, current=None):
+ cb.ice_response(p2, p1, p2)
+
+ def opString_async(self, cb, p1, p2, current=None):
+ cb.ice_response(p1 + " " + p2, p2 + " " + p1)
+
+ def opMyEnum_async(self, cb, p1, current=None):
+ cb.ice_response(Test.MyEnum.enum3, p1)
+
+ def opMyClass_async(self, cb, p1, current=None):
+ p2 = p1
+ p3 = Test.MyClassPrx.uncheckedCast(current.adapter.createProxy(communicator.stringToIdentity("noSuchIdentity")))
+ cb.ice_response(Test.MyClassPrx.uncheckedCast(current.adapter.createProxy(current.id)), p2, p3)
+
+ def opStruct_async(self, cb, p1, p2, current=None):
+ p1.s.s = "a new string"
+ cb.ice_response(p2, p1)
+
+ def opByteS_async(self, cb, p1, p2, current=None):
+ if sys.version_info[0] == 2:
+ # By default sequence<byte> maps to a string.
+ p3 = map(ord, p1)
+ p3.reverse()
+ r = map(ord, p1)
+ r.extend(map(ord, p2))
+ else:
+ p3 = bytes(reversed(p1))
+ r = p1 + p2
+ cb.ice_response(r, p3)
+
+ def opBoolS_async(self, cb, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p1[0:]
+ r.reverse();
+ cb.ice_response(r, p3)
+
+ def opShortIntLongS_async(self, cb, p1, p2, p3, current=None):
+ p4 = p1[0:]
+ p5 = p2[0:]
+ p5.reverse()
+ p6 = p3[0:]
+ p6.extend(p3)
+ cb.ice_response(p3, p4, p5, p6)
+
+ def opFloatDoubleS_async(self, cb, p1, p2, current=None):
+ p3 = p1[0:]
+ p4 = p2[0:]
+ p4.reverse()
+ r = p2[0:]
+ r.extend(p1)
+ cb.ice_response(r, p3, p4)
+
+ def opStringS_async(self, cb, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p1[0:]
+ r.reverse()
+ cb.ice_response(r, p3)
+
+ def opByteSS_async(self, cb, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.reverse()
+ r = p1[0:]
+ r.extend(p2)
+ cb.ice_response(r, p3)
+
+ def opBoolSS_async(self, cb, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p1[0:]
+ r.reverse()
+ cb.ice_response(r, p3)
+
+ def opShortIntLongSS_async(self, cb, p1, p2, p3, current=None):
+ p4 = p1[0:]
+ p5 = p2[0:]
+ p5.reverse()
+ p6 = p3[0:]
+ p6.extend(p3)
+ cb.ice_response(p3, p4, p5, p6)
+
+ def opFloatDoubleSS_async(self, cb, p1, p2, current=None):
+ p3 = p1[0:]
+ p4 = p2[0:]
+ p4.reverse()
+ r = p2[0:]
+ r.extend(p2)
+ cb.ice_response(r, p3, p4)
+
+ def opStringSS_async(self, cb, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p2[0:]
+ r.reverse()
+ cb.ice_response(r, p3)
+
+ def opStringSSS_async(self, cb, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p2[0:]
+ r.reverse()
+ cb.ice_response(r, p3)
+
+ def opByteBoolD_async(self, cb, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opShortIntD_async(self, cb, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opLongFloatD_async(self, cb, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opStringStringD_async(self, cb, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opStringMyEnumD_async(self, cb, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opMyEnumStringD_async(self, cb, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opMyStructMyEnumD_async(self, cb, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opByteBoolDS_async(self, cb, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ cb.ice_response(r, p3)
+
+ def opShortIntDS_async(self, cb, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ cb.ice_response(r, p3)
+
+ def opLongFloatDS_async(self, cb, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ cb.ice_response(r, p3)
+
+ def opStringStringDS_async(self, cb, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ cb.ice_response(r, p3)
+
+ def opStringMyEnumDS_async(self, cb, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ cb.ice_response(r, p3)
+
+ def opMyEnumStringDS_async(self, cb, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ cb.ice_response(r, p3)
+
+ def opMyStructMyEnumDS_async(self, cb, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ cb.ice_response(r, p3)
+
+ def opByteByteSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opBoolBoolSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opShortShortSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opIntIntSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opLongLongSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opStringFloatSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opStringDoubleSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opStringStringSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opMyEnumMyEnumSD_async(self, cb, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ cb.ice_response(r, p3)
+
+ def opIntS_async(self, cb, s, current=None):
+ cb.ice_response([-x for x in s])
+
+ def opByteSOneway_async(self, cb, s, current=None):
+ self.lock.acquire()
+ self.opByteSOnewayCount += 1
+ self.lock.release()
+ cb.ice_response()
+
+ def opByteSOnewayCallCount_async(self, cb, current=None):
+ self.lock.acquire()
+ count = self.opByteSOnewayCount
+ self.opByteSOnewayCount = 0
+ self.lock.release()
+ cb.ice_response(count)
+
+ def opDoubleMarshaling_async(self, cb, p1, p2, current=None):
+ d = 1278312346.0 / 13.0;
+ test(p1 == d)
+ for i in p2:
+ test(i == d)
+ cb.ice_response()
+
+ def opContext_async(self, cb, current=None):
+ cb.ice_response(current.ctx)
+
+ def opIdempotent_async(self, cb, current=None):
+ test(current.mode == Ice.OperationMode.Idempotent)
+ cb.ice_response()
+
+ def opNonmutating_async(self, cb, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ cb.ice_response()
+
+ def opDerived_async(self, cb, current=None):
+ cb.ice_response()
+
+ def opByte1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opShort1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opInt1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opLong1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opFloat1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opDouble1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opString1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opStringS1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opByteBoolD1_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opStringS2_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opByteBoolD2_async(self, cb, value, current=None):
+ cb.ice_response(value)
+
+ def opMyClass1_async(self, cb, value, current=None):
+ return cb.ice_response(value)
+
+ def opMyStruct1_async(self, cb, value, current=None):
+ return cb.ice_response(value)
+
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(MyDerivedClassI(), communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.Warn.Dispatch", "0");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/operations/Test.ice b/python/test/Ice/operations/Test.ice
new file mode 100644
index 00000000000..324fa1bf633
--- /dev/null
+++ b/python/test/Ice/operations/Test.ice
@@ -0,0 +1,272 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/Current.ice>
+
+module Test
+{
+
+enum MyEnum
+{
+ enum1,
+ enum2,
+ enum3
+};
+
+class MyClass;
+
+struct AnotherStruct
+{
+ string s;
+};
+
+struct Structure
+{
+ MyClass* p;
+ MyEnum e;
+ AnotherStruct s;
+};
+
+sequence<byte> ByteS;
+sequence<bool> BoolS;
+sequence<short> ShortS;
+sequence<int> IntS;
+sequence<long> LongS;
+sequence<float> FloatS;
+sequence<double> DoubleS;
+sequence<string> StringS;
+sequence<MyEnum> MyEnumS;
+sequence<MyClass*> MyClassS;
+
+sequence<ByteS> ByteSS;
+sequence<BoolS> BoolSS;
+sequence<ShortS> ShortSS;
+sequence<IntS> IntSS;
+sequence<LongS> LongSS;
+sequence<FloatS> FloatSS;
+sequence<DoubleS> DoubleSS;
+sequence<StringS> StringSS;
+sequence<MyEnumS> MyEnumSS;
+sequence<MyClassS> MyClassSS;
+
+sequence<StringSS> StringSSS;
+
+struct MyStruct
+{
+ int i;
+ int j;
+};
+
+dictionary<byte, bool> ByteBoolD;
+dictionary<short, int> ShortIntD;
+dictionary<long, float> LongFloatD;
+dictionary<string, string> StringStringD;
+dictionary<string, MyEnum> StringMyEnumD;
+dictionary<MyEnum, string> MyEnumStringD;
+dictionary<MyStruct, MyEnum> MyStructMyEnumD;
+
+sequence<ByteBoolD> ByteBoolDS;
+sequence<ShortIntD> ShortIntDS;
+sequence<LongFloatD> LongFloatDS;
+sequence<StringStringD> StringStringDS;
+sequence<StringMyEnumD> StringMyEnumDS;
+sequence<MyEnumStringD> MyEnumStringDS;
+sequence<MyStructMyEnumD> MyStructMyEnumDS;
+
+dictionary<byte, ByteS> ByteByteSD;
+dictionary<bool, BoolS> BoolBoolSD;
+dictionary<short, ShortS> ShortShortSD;
+dictionary<int, IntS> IntIntSD;
+dictionary<long, LongS> LongLongSD;
+dictionary<string, FloatS> StringFloatSD;
+dictionary<string, DoubleS> StringDoubleSD;
+dictionary<string, StringS> StringStringSD;
+dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD;
+
+class MyClass
+{
+ void shutdown();
+
+ void opVoid();
+
+ byte opByte(byte p1, byte p2,
+ out byte p3);
+
+ bool opBool(bool p1, bool p2,
+ out bool p3);
+
+ long opShortIntLong(short p1, int p2, long p3,
+ out short p4, out int p5, out long p6);
+
+ double opFloatDouble(float p1, double p2,
+ out float p3, out double p4);
+
+ string opString(string p1, string p2,
+ out string p3);
+
+ MyEnum opMyEnum(MyEnum p1, out MyEnum p2);
+
+ MyClass* opMyClass(MyClass* p1, out MyClass* p2, out MyClass* p3);
+
+ Structure opStruct(Structure p1, Structure p2,
+ out Structure p3);
+
+ ByteS opByteS(ByteS p1, ByteS p2,
+ out ByteS p3);
+
+ BoolS opBoolS(BoolS p1, BoolS p2,
+ out BoolS p3);
+
+ LongS opShortIntLongS(Test::ShortS p1, IntS p2, LongS p3,
+ out ::Test::ShortS p4, out IntS p5, out LongS p6);
+
+ DoubleS opFloatDoubleS(FloatS p1, DoubleS p2,
+ out FloatS p3, out DoubleS p4);
+
+ StringS opStringS(StringS p1, StringS p2,
+ out StringS p3);
+
+ ByteSS opByteSS(ByteSS p1, ByteSS p2,
+ out ByteSS p3);
+
+ BoolSS opBoolSS(BoolSS p1, BoolSS p2,
+ out BoolSS p3);
+
+ LongSS opShortIntLongSS(ShortSS p1, IntSS p2, LongSS p3,
+ out ShortSS p4, out IntSS p5, out LongSS p6);
+
+ DoubleSS opFloatDoubleSS(FloatSS p1, DoubleSS p2,
+ out FloatSS p3, out DoubleSS p4);
+
+ StringSS opStringSS(StringSS p1, StringSS p2,
+ out StringSS p3);
+
+ StringSSS opStringSSS(StringSSS p1, StringSSS p2,
+ out StringSSS p3);
+
+ ByteBoolD opByteBoolD(ByteBoolD p1, ByteBoolD p2,
+ out ByteBoolD p3);
+
+ ShortIntD opShortIntD(ShortIntD p1, ShortIntD p2,
+ out ShortIntD p3);
+
+ LongFloatD opLongFloatD(LongFloatD p1, LongFloatD p2,
+ out LongFloatD p3);
+
+ StringStringD opStringStringD(StringStringD p1, StringStringD p2,
+ out StringStringD p3);
+
+ StringMyEnumD opStringMyEnumD(StringMyEnumD p1, StringMyEnumD p2,
+ out StringMyEnumD p3);
+
+ MyEnumStringD opMyEnumStringD(MyEnumStringD p1, MyEnumStringD p2,
+ out MyEnumStringD p3);
+
+ MyStructMyEnumD opMyStructMyEnumD(MyStructMyEnumD p1, MyStructMyEnumD p2,
+ out MyStructMyEnumD p3);
+
+ ByteBoolDS opByteBoolDS(ByteBoolDS p1, ByteBoolDS p2,
+ out ByteBoolDS p3);
+
+ ShortIntDS opShortIntDS(ShortIntDS p1, ShortIntDS p2,
+ out ShortIntDS p3);
+
+ LongFloatDS opLongFloatDS(LongFloatDS p1, LongFloatDS p2,
+ out LongFloatDS p3);
+
+ StringStringDS opStringStringDS(StringStringDS p1, StringStringDS p2,
+ out StringStringDS p3);
+
+ StringMyEnumDS opStringMyEnumDS(StringMyEnumDS p1, StringMyEnumDS p2,
+ out StringMyEnumDS p3);
+
+ MyEnumStringDS opMyEnumStringDS(MyEnumStringDS p1, MyEnumStringDS p2,
+ out MyEnumStringDS p3);
+
+ MyStructMyEnumDS opMyStructMyEnumDS(MyStructMyEnumDS p1, MyStructMyEnumDS p2,
+ out MyStructMyEnumDS p3);
+
+ ByteByteSD opByteByteSD(ByteByteSD p1, ByteByteSD p2,
+ out ByteByteSD p3);
+
+ BoolBoolSD opBoolBoolSD(BoolBoolSD p1, BoolBoolSD p2,
+ out BoolBoolSD p3);
+
+ ShortShortSD opShortShortSD(ShortShortSD p1, ShortShortSD p2,
+ out ShortShortSD p3);
+
+ IntIntSD opIntIntSD(IntIntSD p1, IntIntSD p2,
+ out IntIntSD p3);
+
+ LongLongSD opLongLongSD(LongLongSD p1, LongLongSD p2,
+ out LongLongSD p3);
+
+ StringFloatSD opStringFloatSD(StringFloatSD p1, StringFloatSD p2,
+ out StringFloatSD p3);
+
+ StringDoubleSD opStringDoubleSD(StringDoubleSD p1, StringDoubleSD p2,
+ out StringDoubleSD p3);
+
+ StringStringSD opStringStringSD(StringStringSD p1, StringStringSD p2,
+ out StringStringSD p3);
+
+ MyEnumMyEnumSD opMyEnumMyEnumSD(MyEnumMyEnumSD p1, MyEnumMyEnumSD p2,
+ out MyEnumMyEnumSD p3);
+
+ IntS opIntS(IntS s);
+
+ void opByteSOneway(ByteS s);
+
+ int opByteSOnewayCallCount();
+
+ Ice::Context opContext();
+
+ void opDoubleMarshaling(double p1, DoubleS p2);
+
+ idempotent void opIdempotent();
+
+ ["nonmutating"] idempotent void opNonmutating();
+
+ byte opByte1(byte opByte1);
+ short opShort1(short opShort1);
+ int opInt1(int opInt1);
+ long opLong1(long opLong1);
+ float opFloat1(float opFloat1);
+ double opDouble1(double opDouble1);
+ string opString1(string opString1);
+ StringS opStringS1(StringS opStringS1);
+ ByteBoolD opByteBoolD1(ByteBoolD opByteBoolD1);
+ StringS opStringS2(StringS stringS);
+ ByteBoolD opByteBoolD2(ByteBoolD byteBoolD);
+};
+
+struct MyStruct1
+{
+ string tesT; // Same name as the enclosing module
+ MyClass myClass; // Same name as an already defined class
+ string myStruct1; // Same name as the enclosing struct
+};
+
+class MyClass1
+{
+ string tesT; // Same name as the enclosing module
+ MyClass myClass; // Same name as an already defined class
+ string myClass1; // Same name as the enclosing class
+};
+
+class MyDerivedClass extends MyClass
+{
+ void opDerived();
+ MyClass1 opMyClass1(MyClass1 opMyClass1);
+ MyStruct1 opMyStruct1(MyStruct1 opMyStruct1);
+};
+
+};
diff --git a/python/test/Ice/operations/TestAMD.ice b/python/test/Ice/operations/TestAMD.ice
new file mode 100644
index 00000000000..772343fefbb
--- /dev/null
+++ b/python/test/Ice/operations/TestAMD.ice
@@ -0,0 +1,270 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+enum MyEnum
+{
+ enum1,
+ enum2,
+ enum3
+};
+
+class MyClass;
+
+struct AnotherStruct
+{
+ string s;
+};
+
+struct Structure
+{
+ MyClass* p;
+ MyEnum e;
+ AnotherStruct s;
+};
+
+sequence<byte> ByteS;
+sequence<bool> BoolS;
+sequence<short> ShortS;
+sequence<int> IntS;
+sequence<long> LongS;
+sequence<float> FloatS;
+sequence<double> DoubleS;
+sequence<string> StringS;
+sequence<MyEnum> MyEnumS;
+sequence<MyClass*> MyClassS;
+
+sequence<ByteS> ByteSS;
+sequence<BoolS> BoolSS;
+sequence<ShortS> ShortSS;
+sequence<IntS> IntSS;
+sequence<LongS> LongSS;
+sequence<FloatS> FloatSS;
+sequence<DoubleS> DoubleSS;
+sequence<StringS> StringSS;
+sequence<MyEnumS> MyEnumSS;
+sequence<MyClassS> MyClassSS;
+
+sequence<StringSS> StringSSS;
+
+struct MyStruct
+{
+ int i;
+ int j;
+};
+
+dictionary<byte, bool> ByteBoolD;
+dictionary<short, int> ShortIntD;
+dictionary<long, float> LongFloatD;
+dictionary<string, string> StringStringD;
+dictionary<string, MyEnum> StringMyEnumD;
+dictionary<MyEnum, string> MyEnumStringD;
+dictionary<MyStruct, MyEnum> MyStructMyEnumD;
+
+sequence<ByteBoolD> ByteBoolDS;
+sequence<ShortIntD> ShortIntDS;
+sequence<LongFloatD> LongFloatDS;
+sequence<StringStringD> StringStringDS;
+sequence<StringMyEnumD> StringMyEnumDS;
+sequence<MyEnumStringD> MyEnumStringDS;
+sequence<MyStructMyEnumD> MyStructMyEnumDS;
+
+dictionary<byte, ByteS> ByteByteSD;
+dictionary<bool, BoolS> BoolBoolSD;
+dictionary<short, ShortS> ShortShortSD;
+dictionary<int, IntS> IntIntSD;
+dictionary<long, LongS> LongLongSD;
+dictionary<string, FloatS> StringFloatSD;
+dictionary<string, DoubleS> StringDoubleSD;
+dictionary<string, StringS> StringStringSD;
+dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD;
+
+["amd"] class MyClass
+{
+ void shutdown();
+
+ void opVoid();
+
+ byte opByte(byte p1, byte p2,
+ out byte p3);
+
+ bool opBool(bool p1, bool p2,
+ out bool p3);
+
+ long opShortIntLong(short p1, int p2, long p3,
+ out short p4, out int p5, out long p6);
+
+ double opFloatDouble(float p1, double p2,
+ out float p3, out double p4);
+
+ string opString(string p1, string p2,
+ out string p3);
+
+ MyEnum opMyEnum(MyEnum p1, out MyEnum p2);
+
+ MyClass* opMyClass(MyClass* p1, out MyClass* p2, out MyClass* p3);
+
+ Structure opStruct(Structure p1, Structure p2,
+ out Structure p3);
+
+ ByteS opByteS(ByteS p1, ByteS p2,
+ out ByteS p3);
+
+ BoolS opBoolS(BoolS p1, BoolS p2,
+ out BoolS p3);
+
+ LongS opShortIntLongS(Test::ShortS p1, IntS p2, LongS p3,
+ out ::Test::ShortS p4, out IntS p5, out LongS p6);
+
+ DoubleS opFloatDoubleS(FloatS p1, DoubleS p2,
+ out FloatS p3, out DoubleS p4);
+
+ StringS opStringS(StringS p1, StringS p2,
+ out StringS p3);
+
+ ByteSS opByteSS(ByteSS p1, ByteSS p2,
+ out ByteSS p3);
+
+ BoolSS opBoolSS(BoolSS p1, BoolSS p2,
+ out BoolSS p3);
+
+ LongSS opShortIntLongSS(ShortSS p1, IntSS p2, LongSS p3,
+ out ShortSS p4, out IntSS p5, out LongSS p6);
+
+ DoubleSS opFloatDoubleSS(FloatSS p1, DoubleSS p2,
+ out FloatSS p3, out DoubleSS p4);
+
+ StringSS opStringSS(StringSS p1, StringSS p2,
+ out StringSS p3);
+
+ StringSSS opStringSSS(StringSSS p1, StringSSS p2,
+ out StringSSS p3);
+
+ ByteBoolD opByteBoolD(ByteBoolD p1, ByteBoolD p2,
+ out ByteBoolD p3);
+
+ ShortIntD opShortIntD(ShortIntD p1, ShortIntD p2,
+ out ShortIntD p3);
+
+ LongFloatD opLongFloatD(LongFloatD p1, LongFloatD p2,
+ out LongFloatD p3);
+
+ StringStringD opStringStringD(StringStringD p1, StringStringD p2,
+ out StringStringD p3);
+
+ StringMyEnumD opStringMyEnumD(StringMyEnumD p1, StringMyEnumD p2,
+ out StringMyEnumD p3);
+
+ MyEnumStringD opMyEnumStringD(MyEnumStringD p1, MyEnumStringD p2,
+ out MyEnumStringD p3);
+
+ MyStructMyEnumD opMyStructMyEnumD(MyStructMyEnumD p1, MyStructMyEnumD p2,
+ out MyStructMyEnumD p3);
+
+ ByteBoolDS opByteBoolDS(ByteBoolDS p1, ByteBoolDS p2,
+ out ByteBoolDS p3);
+
+ ShortIntDS opShortIntDS(ShortIntDS p1, ShortIntDS p2,
+ out ShortIntDS p3);
+
+ LongFloatDS opLongFloatDS(LongFloatDS p1, LongFloatDS p2,
+ out LongFloatDS p3);
+
+ StringStringDS opStringStringDS(StringStringDS p1, StringStringDS p2,
+ out StringStringDS p3);
+
+ StringMyEnumDS opStringMyEnumDS(StringMyEnumDS p1, StringMyEnumDS p2,
+ out StringMyEnumDS p3);
+
+ MyEnumStringDS opMyEnumStringDS(MyEnumStringDS p1, MyEnumStringDS p2,
+ out MyEnumStringDS p3);
+
+ MyStructMyEnumDS opMyStructMyEnumDS(MyStructMyEnumDS p1, MyStructMyEnumDS p2,
+ out MyStructMyEnumDS p3);
+
+ ByteByteSD opByteByteSD(ByteByteSD p1, ByteByteSD p2,
+ out ByteByteSD p3);
+
+ BoolBoolSD opBoolBoolSD(BoolBoolSD p1, BoolBoolSD p2,
+ out BoolBoolSD p3);
+
+ ShortShortSD opShortShortSD(ShortShortSD p1, ShortShortSD p2,
+ out ShortShortSD p3);
+
+ IntIntSD opIntIntSD(IntIntSD p1, IntIntSD p2,
+ out IntIntSD p3);
+
+ LongLongSD opLongLongSD(LongLongSD p1, LongLongSD p2,
+ out LongLongSD p3);
+
+ StringFloatSD opStringFloatSD(StringFloatSD p1, StringFloatSD p2,
+ out StringFloatSD p3);
+
+ StringDoubleSD opStringDoubleSD(StringDoubleSD p1, StringDoubleSD p2,
+ out StringDoubleSD p3);
+
+ StringStringSD opStringStringSD(StringStringSD p1, StringStringSD p2,
+ out StringStringSD p3);
+
+ MyEnumMyEnumSD opMyEnumMyEnumSD(MyEnumMyEnumSD p1, MyEnumMyEnumSD p2,
+ out MyEnumMyEnumSD p3);
+
+ IntS opIntS(IntS s);
+
+ void opByteSOneway(ByteS s);
+
+ int opByteSOnewayCallCount();
+
+ StringStringD opContext();
+
+ void opDoubleMarshaling(double p1, DoubleS p2);
+
+ idempotent void opIdempotent();
+
+ ["nonmutating"] idempotent void opNonmutating();
+
+ byte opByte1(byte opByte1);
+ short opShort1(short opShort1);
+ int opInt1(int opInt1);
+ long opLong1(long opLong1);
+ float opFloat1(float opFloat1);
+ double opDouble1(double opDouble1);
+ string opString1(string opString1);
+ StringS opStringS1(StringS opStringS1);
+ ByteBoolD opByteBoolD1(ByteBoolD opByteBoolD1);
+ StringS opStringS2(StringS stringS);
+ ByteBoolD opByteBoolD2(ByteBoolD byteBoolD);
+};
+
+struct MyStruct1
+{
+ string tesT; // Same name as the enclosing module
+ MyClass myClass; // Same name as an already defined class
+ string myStruct1; // Same name as the enclosing struct
+};
+
+class MyClass1
+{
+ string tesT; // Same name as the enclosing module
+ MyClass myClass; // Same name as an already defined class
+ string myClass1; // Same name as the enclosing class
+};
+
+["amd"] class MyDerivedClass extends MyClass
+{
+ void opDerived();
+ MyClass1 opMyClass1(MyClass1 opMyClass1);
+ MyStruct1 opMyStruct1(MyStruct1 opMyStruct1);
+};
+
+};
diff --git a/python/test/Ice/operations/TestI.py b/python/test/Ice/operations/TestI.py
new file mode 100644
index 00000000000..fac1fb228a8
--- /dev/null
+++ b/python/test/Ice/operations/TestI.py
@@ -0,0 +1,365 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, threading
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class MyDerivedClassI(Test.MyDerivedClass):
+ def __init__(self):
+ self.lock = threading.Lock()
+ self.opByteSOnewayCount = 0
+
+ def ice_isA(self, id, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_isA(self, id, current)
+
+ def ice_ping(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ Test.MyDerivedClass.ice_ping(self, current)
+
+ def ice_ids(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_ids(self, current)
+
+ def ice_id(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_id(self, current)
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def opVoid(self, current=None):
+ test(current.mode == Ice.OperationMode.Normal)
+
+ def opByte(self, p1, p2, current=None):
+ return (p1, p1 ^ p2)
+
+ def opBool(self, p1, p2, current=None):
+ return (p2, p1)
+
+ def opShortIntLong(self, p1, p2, p3, current=None):
+ return (p3, p1, p2, p3)
+
+ def opFloatDouble(self, p1, p2, current=None):
+ return (p2, p1, p2)
+
+ def opString(self, p1, p2, current=None):
+ return (p1 + " " + p2, p2 + " " + p1)
+
+ def opMyEnum(self, p1, current=None):
+ return (Test.MyEnum.enum3, p1)
+
+ def opMyClass(self, p1, current=None):
+ return (Test.MyClassPrx.uncheckedCast(current.adapter.createProxy(current.id)), p1,
+ Test.MyClassPrx.uncheckedCast(current.adapter.createProxy(current.adapter.getCommunicator().stringToIdentity("noSuchIdentity"))))
+
+ def opStruct(self, p1, p2, current=None):
+ p1.s.s = "a new string"
+ return (p2, p1)
+
+ def opByteS(self, p1, p2, current=None):
+ if sys.version_info[0] == 2:
+ # By default sequence<byte> maps to a string.
+ p3 = map(ord, p1)
+ p3.reverse()
+ r = map(ord, p1)
+ r.extend(map(ord, p2))
+ else:
+ p3 = bytes(reversed(p1))
+ r = p1 + p2
+ return (r, p3)
+
+ def opBoolS(self, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p1[0:]
+ r.reverse();
+ return (r, p3)
+
+ def opShortIntLongS(self, p1, p2, p3, current=None):
+ p4 = p1[0:]
+ p5 = p2[0:]
+ p5.reverse()
+ p6 = p3[0:]
+ p6.extend(p3)
+ return (p3, p4, p5, p6)
+
+ def opFloatDoubleS(self, p1, p2, current=None):
+ p3 = p1[0:]
+ p4 = p2[0:]
+ p4.reverse()
+ r = p2[0:]
+ r.extend(p1)
+ return (r, p3, p4)
+
+ def opStringS(self, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p1[0:]
+ r.reverse()
+ return (r, p3)
+
+ def opByteSS(self, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.reverse()
+ r = p1[0:]
+ r.extend(p2)
+ return (r, p3)
+
+ def opBoolSS(self, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p1[0:]
+ r.reverse()
+ return (r, p3)
+
+ def opShortIntLongSS(self, p1, p2, p3, current=None):
+ p4 = p1[0:]
+ p5 = p2[0:]
+ p5.reverse()
+ p6 = p3[0:]
+ p6.extend(p3)
+ return (p3, p4, p5, p6)
+
+ def opFloatDoubleSS(self, p1, p2, current=None):
+ p3 = p1[0:]
+ p4 = p2[0:]
+ p4.reverse()
+ r = p2[0:]
+ r.extend(p2)
+ return (r, p3, p4)
+
+ def opStringSS(self, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p2[0:]
+ r.reverse()
+ return (r, p3)
+
+ def opStringSSS(self, p1, p2, current=None):
+ p3 = p1[0:]
+ p3.extend(p2)
+ r = p2[0:]
+ r.reverse()
+ return (r, p3)
+
+ def opByteBoolD(self, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opShortIntD(self, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opLongFloatD(self, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opStringStringD(self, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opStringMyEnumD(self, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opMyEnumStringD(self, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opMyStructMyEnumD(self, p1, p2, current=None):
+ p3 = p1.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opByteBoolDS(self, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ return (r, p3)
+
+ def opShortIntDS(self, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ return (r, p3)
+
+ def opLongFloatDS(self, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ return (r, p3)
+
+ def opStringStringDS(self, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ return (r, p3)
+
+ def opStringMyEnumDS(self, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ return (r, p3)
+
+ def opMyEnumStringDS(self, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ return (r, p3)
+
+ def opMyStructMyEnumDS(self, p1, p2, current=None):
+ p3 = p2[0:]
+ p3.extend(p1)
+ r = p1[::-1]
+ return (r, p3)
+
+ def opByteByteSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opBoolBoolSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opShortShortSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opIntIntSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opLongLongSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opStringFloatSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opStringDoubleSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opStringStringSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opMyEnumMyEnumSD(self, p1, p2, current=None):
+ p3 = p2.copy()
+ r = p1.copy()
+ r.update(p2)
+ return (r, p3)
+
+ def opIntS(self, s, current=None):
+ return [-x for x in s]
+
+ def opByteSOneway(self, s, current=None):
+ self.lock.acquire()
+ self.opByteSOnewayCount += 1
+ self.lock.release()
+
+ def opByteSOnewayCallCount(self, current=None):
+ self.lock.acquire()
+ count = self.opByteSOnewayCount
+ self.opByteSOnewayCount = 0
+ self.lock.release()
+ return count
+
+ def opContext(self, current=None):
+ return current.ctx
+
+ def opDoubleMarshaling(self, p1, p2, current=None):
+ d = 1278312346.0 / 13.0;
+ test(p1 == d)
+ for i in p2:
+ test(i == d)
+
+ def opIdempotent(self, current=None):
+ test(current.mode == Ice.OperationMode.Idempotent)
+
+ def opNonmutating(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+
+ def opDerived(self, current=None):
+ pass
+
+ def opByte1(self, value, current=None):
+ return value
+
+ def opShort1(self, value, current=None):
+ return value
+
+ def opInt1(self, value, current=None):
+ return value
+
+ def opLong1(self, value, current=None):
+ return value
+
+ def opFloat1(self, value, current=None):
+ return value
+
+ def opDouble1(self, value, current=None):
+ return value
+
+ def opString1(self, value, current=None):
+ return value
+
+ def opStringS1(self, value, current=None):
+ return value
+
+ def opByteBoolD1(self, value, current=None):
+ return value
+
+ def opStringS2(self, value, current=None):
+ return value
+
+ def opByteBoolD2(self, value, current=None):
+ return value
+
+ def opMyClass1(self, value, current=None):
+ return value
+
+ def opMyStruct1(self, value, current=None):
+ return value
+
+ \ No newline at end of file
diff --git a/python/test/Ice/operations/Twoways.py b/python/test/Ice/operations/Twoways.py
new file mode 100644
index 00000000000..1299a375d7a
--- /dev/null
+++ b/python/test/Ice/operations/Twoways.py
@@ -0,0 +1,1334 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, math, Test, array, sys
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def twoways(communicator, p):
+ #
+ # ice_ping
+ #
+ p.ice_ping()
+
+ #
+ # ice_isA
+ #
+ test(p.ice_isA(Test.MyClass.ice_staticId()))
+
+ #
+ # ice_ids
+ #
+ ids = p.ice_ids()
+ test(len(ids) == 3)
+ test(ids[0] == "::Ice::Object")
+ test(ids[1] == "::Test::MyClass")
+ test(ids[2] == "::Test::MyDerivedClass")
+
+ #
+ # ice_id
+ #
+ test(p.ice_id() == Test.MyDerivedClass.ice_staticId())
+
+ #
+ # Prx ice_staticId
+ #
+ test(Test.MyClassPrx.ice_staticId() == Test.MyClass.ice_staticId())
+ test(Test.MyDerivedClassPrx.ice_staticId() == Test.MyDerivedClass.ice_staticId())
+ test(Ice.ObjectPrx.ice_staticId() == Ice.Object.ice_staticId())
+
+ #
+ # opVoid
+ #
+ p.opVoid()
+
+ #
+ # opByte
+ #
+ r, b = p.opByte(0xff, 0x0f)
+ test(b == 0xf0)
+ test(r == 0xff)
+
+ #
+ # opBool
+ #
+ r, b = p.opBool(True, False)
+ test(b)
+ test(not r)
+
+ #
+ # opShortIntLong
+ #
+ r, s, i, l = p.opShortIntLong(10, 11, 12)
+ test(s == 10)
+ test(i == 11)
+ test(l == 12)
+ test(r == 12)
+
+ r, s, i, l = p.opShortIntLong(-32768, -2147483648, -9223372036854775808)
+ test(s == -32768)
+ test(i == -2147483648)
+ test(l == -9223372036854775808)
+ test(r == -9223372036854775808)
+
+ r, s, i, l = p.opShortIntLong(32767, 2147483647, 9223372036854775807)
+ test(s == 32767)
+ test(i == 2147483647)
+ test(l == 9223372036854775807)
+ test(r == 9223372036854775807)
+
+ #
+ # opFloatDouble
+ #
+ r, f, d = p.opFloatDouble(3.14, 1.1E10)
+ test(f - 3.14 < 0.001)
+ test(d == 1.1E10)
+ test(r == 1.1E10)
+
+ #
+ # Test invalid ranges for numbers
+ #
+ try:
+ r, b = p.opByte(0x01ff, 0x01ff)
+ test(False)
+ except ValueError:
+ pass
+
+ try:
+ r, s, i, l = p.opShortIntLong(32767 + 1, 0, 0)
+ test(False)
+ except ValueError:
+ pass
+
+ try:
+ r, s, i, l = p.opShortIntLong(-32768 -1, 0, 0)
+ test(False)
+ except ValueError:
+ pass
+
+ try:
+ r, s, i, l = p.opShortIntLong(0, 2147483647 + 1, 0)
+ test(False)
+ except ValueError:
+ pass
+
+ try:
+ r, s, i, l = p.opShortIntLong(0, -2147483648 - 1, 0)
+ test(False)
+ except ValueError:
+ pass
+
+ try:
+ r, s, i, l = p.opShortIntLong(0, 0, 9223372036854775807 + 1)
+ test(False)
+ except ValueError:
+ pass
+
+ try:
+ r, s, i, l = p.opShortIntLong(0, 0, -9223372036854775808 - 1)
+ test(False)
+ except ValueError:
+ pass
+
+ r, f, d = p.opFloatDouble(3.402823466E38, 0.0)
+ r, f, d = p.opFloatDouble(-3.402823466E38, 0.0)
+
+ try:
+ r, f, d = p.opFloatDouble(3.402823466E38*2, 0.0)
+ test(False)
+ except ValueError:
+ pass
+
+ try:
+ r, f, d = p.opFloatDouble(-3.402823466E38*2, 0.0)
+ test(False)
+ except ValueError:
+ pass
+
+ #
+ # opString
+ #
+ r, s = p.opString("hello", "world")
+ test(s == "world hello")
+ test(r == "hello world")
+ if sys.version_info[0] == 2:
+ r, s = p.opString(unicode("hello"), unicode("world"))
+ test(s == "world hello")
+ test(r == "hello world")
+
+ #
+ # opMyEnum
+ #
+ r, e = p.opMyEnum(Test.MyEnum.enum2)
+ test(e == Test.MyEnum.enum2)
+ test(r == Test.MyEnum.enum3)
+
+ #
+ # opMyClass
+ #
+ r, c1, c2 = p.opMyClass(p)
+ test(Ice.proxyIdentityAndFacetEqual(c1, p))
+ test(not Ice.proxyIdentityAndFacetEqual(c2, p))
+ test(Ice.proxyIdentityAndFacetEqual(r, p))
+ test(c1.ice_getIdentity() == communicator.stringToIdentity("test"))
+ test(c2.ice_getIdentity() == communicator.stringToIdentity("noSuchIdentity"))
+ test(r.ice_getIdentity() == communicator.stringToIdentity("test"))
+ r.opVoid()
+ c1.opVoid()
+ try:
+ c2.opVoid()
+ test(False)
+ except Ice.ObjectNotExistException:
+ pass
+
+ r, c1, c2 = p.opMyClass(None)
+ test(not c1)
+ test(c2)
+ test(Ice.proxyIdentityAndFacetEqual(r, p))
+ r.opVoid()
+
+ #
+ # opStruct
+ #
+ si1 = Test.Structure()
+ si1.p = p
+ si1.e = Test.MyEnum.enum3
+ si1.s = Test.AnotherStruct()
+ si1.s.s = "abc"
+ si2 = Test.Structure()
+ si2.p = None
+ si2.e = Test.MyEnum.enum2
+ si2.s = Test.AnotherStruct()
+ si2.s.s = "def"
+
+ rso, so = p.opStruct(si1, si2)
+ test(not rso.p)
+ test(rso.e == Test.MyEnum.enum2)
+ test(rso.s.s == "def")
+ test(so.p == p)
+ test(so.e == Test.MyEnum.enum3)
+ test(so.s.s == "a new string")
+ so.p.opVoid()
+
+ # Test marshalling of null structs and structs with null members.
+ si1 = Test.Structure()
+ si2 = None
+
+ rso, so = p.opStruct(si1, si2)
+ test(rso.p is None)
+ test(rso.e == Test.MyEnum.enum1)
+ test(rso.s.s == "")
+ test(so.p is None)
+ test(so.e == Test.MyEnum.enum1)
+ test(so.s.s == "a new string")
+
+ #
+ # opByteS
+ #
+ bsi1 = (0x01, 0x11, 0x12, 0x22)
+ bsi2 = (0xf1, 0xf2, 0xf3, 0xf4)
+
+ rso, bso = p.opByteS(bsi1, bsi2)
+ test(len(bso) == 4)
+ test(len(rso) == 8)
+ if sys.version_info[0] == 2:
+ test(bso[0] == '\x22')
+ test(bso[1] == '\x12')
+ test(bso[2] == '\x11')
+ test(bso[3] == '\x01')
+ test(rso[0] == '\x01')
+ test(rso[1] == '\x11')
+ test(rso[2] == '\x12')
+ test(rso[3] == '\x22')
+ test(rso[4] == '\xf1')
+ test(rso[5] == '\xf2')
+ test(rso[6] == '\xf3')
+ test(rso[7] == '\xf4')
+ else:
+ test(bso[0] == 0x22)
+ test(bso[1] == 0x12)
+ test(bso[2] == 0x11)
+ test(bso[3] == 0x01)
+ test(rso[0] == 0x01)
+ test(rso[1] == 0x11)
+ test(rso[2] == 0x12)
+ test(rso[3] == 0x22)
+ test(rso[4] == 0xf1)
+ test(rso[5] == 0xf2)
+ test(rso[6] == 0xf3)
+ test(rso[7] == 0xf4)
+
+ #
+ # opByteS (array)
+ #
+ bsi1 = array.array('B')
+ bsi1.fromlist([0x01, 0x11, 0x12, 0x22])
+ bsi2 = array.array('B')
+ bsi2.fromlist([0xf1, 0xf2, 0xf3, 0xf4])
+
+ rso, bso = p.opByteS(bsi1, bsi2)
+ test(len(bso) == 4)
+ test(len(rso) == 8)
+ if sys.version_info[0] == 2:
+ test(bso[0] == '\x22')
+ test(bso[1] == '\x12')
+ test(bso[2] == '\x11')
+ test(bso[3] == '\x01')
+ test(rso[0] == '\x01')
+ test(rso[1] == '\x11')
+ test(rso[2] == '\x12')
+ test(rso[3] == '\x22')
+ test(rso[4] == '\xf1')
+ test(rso[5] == '\xf2')
+ test(rso[6] == '\xf3')
+ test(rso[7] == '\xf4')
+ else:
+ test(bso[0] == 0x22)
+ test(bso[1] == 0x12)
+ test(bso[2] == 0x11)
+ test(bso[3] == 0x01)
+ test(rso[0] == 0x01)
+ test(rso[1] == 0x11)
+ test(rso[2] == 0x12)
+ test(rso[3] == 0x22)
+ test(rso[4] == 0xf1)
+ test(rso[5] == 0xf2)
+ test(rso[6] == 0xf3)
+ test(rso[7] == 0xf4)
+
+ #
+ # opBoolS
+ #
+ bsi1 = (True, True, False)
+ bsi2 = (False,)
+
+ rso, bso = p.opBoolS(bsi1, bsi2)
+ test(len(bso) == 4)
+ test(bso[0])
+ test(bso[1])
+ test(not bso[2])
+ test(not bso[3])
+ test(len(rso) == 3)
+ test(not rso[0])
+ test(rso[1])
+ test(rso[2])
+
+ #
+ # opBoolS (array)
+ #
+ bsi1 = array.array('B')
+ bsi1.fromlist([1, 1, 0])
+ bsi2 = array.array('B')
+ bsi2.fromlist([0])
+
+ rso, bso = p.opBoolS(bsi1, bsi2)
+ test(len(bso) == 4)
+ test(bso[0])
+ test(bso[1])
+ test(not bso[2])
+ test(not bso[3])
+ test(len(rso) == 3)
+ test(not rso[0])
+ test(rso[1])
+ test(rso[2])
+
+ #
+ # opShortIntLongS
+ #
+ ssi = (1, 2, 3)
+ isi = (5, 6, 7, 8)
+ lsi = (10, 30, 20)
+
+ rso, sso, iso, lso = p.opShortIntLongS(ssi, isi, lsi)
+ test(len(sso) == 3)
+ test(sso[0] == 1)
+ test(sso[1] == 2)
+ test(sso[2] == 3)
+ test(len(iso) == 4)
+ test(iso[0] == 8)
+ test(iso[1] == 7)
+ test(iso[2] == 6)
+ test(iso[3] == 5)
+ test(len(lso) == 6)
+ test(lso[0] == 10)
+ test(lso[1] == 30)
+ test(lso[2] == 20)
+ test(lso[3] == 10)
+ test(lso[4] == 30)
+ test(lso[5] == 20)
+ test(len(rso) == 3)
+ test(rso[0] == 10)
+ test(rso[1] == 30)
+ test(rso[2] == 20)
+
+ #
+ # opShortIntLongS (array)
+ #
+ ssi = array.array('h')
+ ssi.fromlist([1, 2, 3])
+ isi = array.array('i')
+ isi.fromlist([5, 6, 7, 8])
+ lsi = (10, 30, 20) # Can't store Ice::Long in an array.
+
+ rso, sso, iso, lso = p.opShortIntLongS(ssi, isi, lsi)
+ test(len(sso) == 3)
+ test(sso[0] == 1)
+ test(sso[1] == 2)
+ test(sso[2] == 3)
+ test(len(iso) == 4)
+ test(iso[0] == 8)
+ test(iso[1] == 7)
+ test(iso[2] == 6)
+ test(iso[3] == 5)
+ test(len(lso) == 6)
+ test(lso[0] == 10)
+ test(lso[1] == 30)
+ test(lso[2] == 20)
+ test(lso[3] == 10)
+ test(lso[4] == 30)
+ test(lso[5] == 20)
+ test(len(rso) == 3)
+ test(rso[0] == 10)
+ test(rso[1] == 30)
+ test(rso[2] == 20)
+
+ #
+ # opFloatDoubleS
+ #
+ fsi = (3.14, 1.11)
+ dsi = (1.1E10, 1.2E10, 1.3E10)
+
+ rso, fso, dso = p.opFloatDoubleS(fsi, dsi)
+ test(len(fso) == 2)
+ test(fso[0] - 3.14 < 0.001)
+ test(fso[1] - 1.11 < 0.001)
+ test(len(dso) == 3)
+ test(dso[0] == 1.3E10)
+ test(dso[1] == 1.2E10)
+ test(dso[2] == 1.1E10)
+ test(len(rso) == 5)
+ test(rso[0] == 1.1E10)
+ test(rso[1] == 1.2E10)
+ test(rso[2] == 1.3E10)
+ test(rso[3] - 3.14 < 0.001)
+ test(rso[4] - 1.11 < 0.001)
+
+ #
+ # opFloatDoubleS (array)
+ #
+ fsi = array.array('f')
+ fsi.fromlist([3.14, 1.11])
+ dsi = array.array('d')
+ dsi.fromlist([1.1E10, 1.2E10, 1.3E10])
+
+ rso, fso, dso = p.opFloatDoubleS(fsi, dsi)
+ test(len(fso) == 2)
+ test(fso[0] - 3.14 < 0.001)
+ test(fso[1] - 1.11 < 0.001)
+ test(len(dso) == 3)
+ test(dso[0] == 1.3E10)
+ test(dso[1] == 1.2E10)
+ test(dso[2] == 1.1E10)
+ test(len(rso) == 5)
+ test(rso[0] == 1.1E10)
+ test(rso[1] == 1.2E10)
+ test(rso[2] == 1.3E10)
+ test(rso[3] - 3.14 < 0.001)
+ test(rso[4] - 1.11 < 0.001)
+
+ #
+ # opStringS
+ #
+ ssi1 = ('abc', 'de', 'fghi')
+ ssi2 = ('xyz',)
+
+ rso, sso = p.opStringS(ssi1, ssi2)
+ test(len(sso) == 4)
+ test(sso[0] == "abc")
+ test(sso[1] == "de")
+ test(sso[2] == "fghi")
+ test(sso[3] == "xyz")
+ test(len(rso) == 3)
+ test(rso[0] == "fghi")
+ test(rso[1] == "de")
+ test(rso[2] == "abc")
+
+ #
+ # opByteSS
+ #
+ bsi1 = ((0x01, 0x11, 0x12), (0xff,))
+ bsi2 = ((0x0e,), (0xf2, 0xf1))
+
+ rso, bso = p.opByteSS(bsi1, bsi2)
+ test(len(bso) == 2)
+ test(len(bso[0]) == 1)
+ test(len(bso[1]) == 3)
+ test(len(rso) == 4)
+ test(len(rso[0]) == 3)
+ test(len(rso[1]) == 1)
+ test(len(rso[2]) == 1)
+ test(len(rso[3]) == 2)
+ if sys.version_info[0] == 2:
+ test(bso[0][0] == '\xff')
+ test(bso[1][0] == '\x01')
+ test(bso[1][1] == '\x11')
+ test(bso[1][2] == '\x12')
+ test(rso[0][0] == '\x01')
+ test(rso[0][1] == '\x11')
+ test(rso[0][2] == '\x12')
+ test(rso[1][0] == '\xff')
+ test(rso[2][0] == '\x0e')
+ test(rso[3][0] == '\xf2')
+ test(rso[3][1] == '\xf1')
+ else:
+ test(bso[0][0] == 0xff)
+ test(bso[1][0] == 0x01)
+ test(bso[1][1] == 0x11)
+ test(bso[1][2] == 0x12)
+ test(rso[0][0] == 0x01)
+ test(rso[0][1] == 0x11)
+ test(rso[0][2] == 0x12)
+ test(rso[1][0] == 0xff)
+ test(rso[2][0] == 0x0e)
+ test(rso[3][0] == 0xf2)
+ test(rso[3][1] == 0xf1)
+
+ #
+ # opBoolSS
+ #
+ bsi1 = ((True,), (False,), (True, True),)
+ bsi2 = ((False, False, True),)
+
+ rso, bso = p.opBoolSS(bsi1, bsi2)
+ test(len(bso) == 4)
+ test(len(bso[0]) == 1)
+ test(bso[0][0])
+ test(len(bso[1]) == 1)
+ test(not bso[1][0])
+ test(len(bso[2]) == 2)
+ test(bso[2][0])
+ test(bso[2][1])
+ test(len(bso[3]) == 3)
+ test(not bso[3][0])
+ test(not bso[3][1])
+ test(bso[3][2])
+ test(len(rso) == 3)
+ test(len(rso[0]) == 2)
+ test(rso[0][0])
+ test(rso[0][1])
+ test(len(rso[1]) == 1)
+ test(not rso[1][0])
+ test(len(rso[2]) == 1)
+ test(rso[2][0])
+
+ #
+ # opShortIntLongSS
+ #
+ ssi = ((1,2,5), (13,), ())
+ isi = ((24, 98), (42,))
+ lsi = ((496, 1729),)
+
+ rso, sso, iso, lso = p.opShortIntLongSS(ssi, isi, lsi)
+ test(len(rso) == 1)
+ test(len(rso[0]) == 2)
+ test(rso[0][0] == 496)
+ test(rso[0][1] == 1729)
+ test(len(sso) == 3)
+ test(len(sso[0]) == 3)
+ test(sso[0][0] == 1)
+ test(sso[0][1] == 2)
+ test(sso[0][2] == 5)
+ test(len(sso[1]) == 1)
+ test(sso[1][0] == 13)
+ test(len(sso[2]) == 0)
+ test(len(iso) == 2)
+ test(len(iso[0]) == 1)
+ test(iso[0][0] == 42)
+ test(len(iso[1]) == 2)
+ test(iso[1][0] == 24)
+ test(iso[1][1] == 98)
+ test(len(lso) == 2)
+ test(len(lso[0]) == 2)
+ test(lso[0][0] == 496)
+ test(lso[0][1] == 1729)
+ test(len(lso[1]) == 2)
+ test(lso[1][0] == 496)
+ test(lso[1][1] == 1729)
+
+ #
+ # opFloatDoubleSS
+ #
+ fsi = ((3.14,), (1.11,), ())
+ dsi = ((1.1E10, 1.2E10, 1.3E10),)
+
+ rso, fso, dso = p.opFloatDoubleSS(fsi, dsi)
+ test(len(fso) == 3)
+ test(len(fso[0]) == 1)
+ test(fso[0][0] - 3.14 < 0.001)
+ test(len(fso[1]) == 1)
+ test(fso[1][0] - 1.11 < 0.001)
+ test(len(fso[2]) == 0)
+ test(len(dso) == 1)
+ test(len(dso[0]) == 3)
+ test(dso[0][0] == 1.1E10)
+ test(dso[0][1] == 1.2E10)
+ test(dso[0][2] == 1.3E10)
+ test(len(rso) == 2)
+ test(len(rso[0]) == 3)
+ test(rso[0][0] == 1.1E10)
+ test(rso[0][1] == 1.2E10)
+ test(rso[0][2] == 1.3E10)
+ test(len(rso[1]) == 3)
+ test(rso[1][0] == 1.1E10)
+ test(rso[1][1] == 1.2E10)
+ test(rso[1][2] == 1.3E10)
+
+ #
+ # opStringSS
+ #
+ ssi1 = (('abc',), ('de', 'fghi'))
+ ssi2 = ((), (), ('xyz',))
+
+ rso, sso = p.opStringSS(ssi1, ssi2)
+ test(len(sso) == 5)
+ test(len(sso[0]) == 1)
+ test(sso[0][0] == "abc")
+ test(len(sso[1]) == 2)
+ test(sso[1][0] == "de")
+ test(sso[1][1] == "fghi")
+ test(len(sso[2]) == 0)
+ test(len(sso[3]) == 0)
+ test(len(sso[4]) == 1)
+ test(sso[4][0] == "xyz")
+ test(len(rso) == 3)
+ test(len(rso[0]) == 1)
+ test(rso[0][0] == "xyz")
+ test(len(rso[1]) == 0)
+ test(len(rso[2]) == 0)
+
+ #
+ # opStringSSS
+ #
+ sssi1 = ((('abc', 'de'), ('xyz',)), (('hello',),))
+ sssi2 = ((('', ''), ('abcd',)), (('',),), ())
+
+ rsso, ssso = p.opStringSSS(sssi1, sssi2)
+ test(len(ssso) == 5)
+ test(len(ssso[0]) == 2)
+ test(len(ssso[0][0]) == 2)
+ test(len(ssso[0][1]) == 1)
+ test(len(ssso[1]) == 1)
+ test(len(ssso[1][0]) == 1)
+ test(len(ssso[2]) == 2)
+ test(len(ssso[2][0]) == 2)
+ test(len(ssso[2][1]) == 1)
+ test(len(ssso[3]) == 1)
+ test(len(ssso[3][0]) == 1)
+ test(len(ssso[4]) == 0)
+ test(ssso[0][0][0] == "abc")
+ test(ssso[0][0][1] == "de")
+ test(ssso[0][1][0] == "xyz")
+ test(ssso[1][0][0] == "hello")
+ test(ssso[2][0][0] == "")
+ test(ssso[2][0][1] == "")
+ test(ssso[2][1][0] == "abcd")
+ test(ssso[3][0][0] == "")
+
+ test(len(rsso) == 3)
+ test(len(rsso[0]) == 0)
+ test(len(rsso[1]) == 1)
+ test(len(rsso[1][0]) == 1)
+ test(len(rsso[2]) == 2)
+ test(len(rsso[2][0]) == 2)
+ test(len(rsso[2][1]) == 1)
+ test(rsso[1][0][0] == "")
+ test(rsso[2][0][0] == "")
+ test(rsso[2][0][1] == "")
+ test(rsso[2][1][0] == "abcd")
+
+ #
+ # opByteBoolD
+ #
+ di1 = {10: True, 100: False}
+ di2 = {10: True, 11: False, 101: True}
+
+ ro, do = p.opByteBoolD(di1, di2)
+
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro[10])
+ test(not ro[11])
+ test(not ro[100])
+ test(ro[101])
+
+ #
+ # opShortIntD
+ #
+ di1 = {110: -1, 1100: 123123}
+ di2 = {110: -1, 111: -100, 1101: 0}
+
+ ro, do = p.opShortIntD(di1, di2)
+
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro[110] == -1)
+ test(ro[111] == -100)
+ test(ro[1100] == 123123)
+ test(ro[1101] == 0)
+
+ #
+ # opLongFloatD
+ #
+ di1 = {999999110: -1.1, 999999111: 123123.2}
+ di2 = {999999110: -1.1, 999999120: -100.4, 999999130: 0.5}
+
+ ro, do = p.opLongFloatD(di1, di2)
+
+ for k in do:
+ test(math.fabs(do[k] - di1[k]) < 0.01)
+ test(len(ro) == 4)
+ test(ro[999999110] - -1.1 < 0.01)
+ test(ro[999999120] - -100.4 < 0.01)
+ test(ro[999999111] - 123123.2 < 0.01)
+ test(ro[999999130] - 0.5 < 0.01)
+
+ #
+ # opStringStringD
+ #
+ di1 = {'foo': 'abc -1.1', 'bar': 'abc 123123.2'}
+ di2 = {'foo': 'abc -1.1', 'FOO': 'abc -100.4', 'BAR': 'abc 0.5'}
+
+ ro, do = p.opStringStringD(di1, di2)
+
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro["foo"] == "abc -1.1")
+ test(ro["FOO"] == "abc -100.4")
+ test(ro["bar"] == "abc 123123.2")
+ test(ro["BAR"] == "abc 0.5")
+
+ #
+ # opStringMyEnumD
+ #
+ di1 = {'abc': Test.MyEnum.enum1, '': Test.MyEnum.enum2}
+ di2 = {'abc': Test.MyEnum.enum1, 'qwerty': Test.MyEnum.enum3, 'Hello!!': Test.MyEnum.enum2}
+
+ ro, do = p.opStringMyEnumD(di1, di2)
+
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro["abc"] == Test.MyEnum.enum1)
+ test(ro["qwerty"] == Test.MyEnum.enum3)
+ test(ro[""] == Test.MyEnum.enum2)
+ test(ro["Hello!!"] == Test.MyEnum.enum2)
+
+ #
+ # opMyEnumStringD
+ #
+ di1 = {Test.MyEnum.enum1: 'abc'}
+ di2 = {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}
+
+ ro, do = p.opMyEnumStringD(di1, di2)
+
+ test(do == di1)
+ test(len(ro) == 3)
+ test(ro[Test.MyEnum.enum1] == "abc")
+ test(ro[Test.MyEnum.enum2] == "Hello!!")
+ test(ro[Test.MyEnum.enum3] == "qwerty")
+
+ #
+ # opMyStructMyEnumD
+ #
+ s11 = Test.MyStruct()
+ s11.i = 1
+ s11.j = 1
+ s12 = Test.MyStruct()
+ s12.i = 1
+ s12.j = 2
+ s22 = Test.MyStruct()
+ s22.i = 2
+ s22.j = 2
+ s23 = Test.MyStruct()
+ s23.i = 2
+ s23.j = 3
+ di1 = {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2}
+ di2 = {s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2}
+
+ ro, do = p.opMyStructMyEnumD(di1, di2)
+
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro[s11] == Test.MyEnum.enum1)
+ test(ro[s12] == Test.MyEnum.enum2)
+ test(ro[s22] == Test.MyEnum.enum3)
+ test(ro[s23] == Test.MyEnum.enum2)
+
+ #
+ # opByteBoolDS
+ #
+ dsi1 = ({ 10: True, 100: False }, { 10: True, 11: False, 101: True })
+ dsi2 = ({ 100: False, 101: False },)
+
+ ro, do = p.opByteBoolDS(dsi1, dsi2)
+
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0][10])
+ test(not ro[0][11])
+ test(ro[0][101])
+ test(len(ro[1]) == 2)
+ test(ro[1][10])
+ test(not ro[1][100])
+ test(len(do) == 3)
+ test(len(do[0]) == 2)
+ test(not do[0][100])
+ test(not do[0][101])
+ test(len(do[1]) == 2)
+ test(do[1][10])
+ test(not do[1][100])
+ test(len(do[2]) == 3)
+ test(do[2][10])
+ test(not do[2][11])
+ test(do[2][101])
+
+ #
+ # opShortIntDS
+ #
+ dsi1 = ({ 110: -1, 1100: 123123 }, { 110: -1, 111: -100, 1101: 0 })
+ dsi2 = ({ 100: -1001 },)
+
+ ro, do = p.opShortIntDS(dsi1, dsi2)
+
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0][110] == -1)
+ test(ro[0][111] == -100)
+ test(ro[0][1101] == 0)
+ test(len(ro[1]) == 2)
+ test(ro[1][110] == -1)
+ test(ro[1][1100] == 123123)
+
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0][100] == -1001)
+ test(len(do[1]) == 2)
+ test(do[1][110] == -1)
+ test(do[1][1100] == 123123)
+ test(len(do[2]) == 3)
+ test(do[2][110] == -1)
+ test(do[2][111] == -100)
+ test(do[2][1101] == 0)
+
+ #
+ # opLongFloatDS
+ #
+ dsi1 = ({ 999999110: -1.1, 999999111: 123123.2 }, { 999999110: -1.1, 999999120: -100.4, 999999130: 0.5 })
+ dsi2 = ({ 999999140: 3.14 },)
+
+ ro, do = p.opLongFloatDS(dsi1, dsi2)
+
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0][999999110] - -1.1 < 0.01)
+ test(ro[0][999999120] - -100.4 < 0.01)
+ test(ro[0][999999130] - 0.5 < 0.01)
+ test(len(ro[1]) == 2)
+ test(ro[1][999999110] - -1.1 < 0.01)
+ test(ro[1][999999111] - 123123.2 < 0.01)
+
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0][999999140] - 3.14 < 0.01)
+ test(len(do[1]) == 2)
+ test(do[1][999999110] - -1.1 < 0.01)
+ test(do[1][999999111] - 123123.2 < 0.01)
+ test(len(do[2]) == 3)
+ test(do[2][999999110] - -1.1 < 0.01)
+ test(do[2][999999120] - -100.4 < 0.01)
+ test(do[2][999999130] - 0.5 < 0.01)
+
+ #
+ # opStringStringDS
+ #
+
+ dsi1 = ({ "foo": "abc -1.1", "bar": "abc 123123.2" }, { "foo": "abc -1.1", "FOO": "abc -100.4", "BAR": "abc 0.5" })
+ dsi2 = ({ "f00": "ABC -3.14" },)
+
+ ro, do = p.opStringStringDS(dsi1, dsi2)
+
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0]["foo"] == "abc -1.1")
+ test(ro[0]["FOO"] == "abc -100.4")
+ test(ro[0]["BAR"] == "abc 0.5")
+ test(len(ro[1]) == 2)
+ test(ro[1]["foo"] == "abc -1.1")
+ test(ro[1]["bar"] == "abc 123123.2")
+
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0]["f00"] == "ABC -3.14")
+ test(len(do[1]) == 2)
+ test(do[1]["foo"] == "abc -1.1")
+ test(do[1]["bar"] == "abc 123123.2")
+ test(len(do[2]) == 3)
+ test(do[2]["foo"] == "abc -1.1")
+ test(do[2]["FOO"] == "abc -100.4")
+ test(do[2]["BAR"] == "abc 0.5")
+
+ #
+ # opStringMyEnumDS
+ #
+ dsi1 = (
+ { "abc": Test.MyEnum.enum1, "": Test.MyEnum.enum2 },
+ { "abc": Test.MyEnum.enum1, "qwerty": Test.MyEnum.enum3, "Hello!!": Test.MyEnum.enum2 }
+ )
+
+ dsi2 = ({ "Goodbye": Test.MyEnum.enum1 },)
+
+ ro, do = p.opStringMyEnumDS(dsi1, dsi2)
+
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0]["abc"] == Test.MyEnum.enum1)
+ test(ro[0]["qwerty"] == Test.MyEnum.enum3)
+ test(ro[0]["Hello!!"] == Test.MyEnum.enum2)
+ test(len(ro[1]) == 2)
+ test(ro[1]["abc"] == Test.MyEnum.enum1)
+ test(ro[1][""] == Test.MyEnum.enum2)
+
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0]["Goodbye"] == Test.MyEnum.enum1)
+ test(len(do[1]) == 2)
+ test(do[1]["abc"] == Test.MyEnum.enum1)
+ test(do[1][""] == Test.MyEnum.enum2)
+ test(len(do[2]) == 3)
+ test(do[2]["abc"] == Test.MyEnum.enum1)
+ test(do[2]["qwerty"] == Test.MyEnum.enum3)
+ test(do[2]["Hello!!"] == Test.MyEnum.enum2)
+
+ #
+ # opMyEnumStringDS
+ #
+ dsi1 = ({ Test.MyEnum.enum1: 'abc' }, { Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'})
+ dsi2 = ({ Test.MyEnum.enum1: 'Goodbye' },)
+
+ ro, do = p.opMyEnumStringDS(dsi1, dsi2)
+
+ test(len(ro) == 2)
+ test(len(ro[0]) == 2)
+ test(ro[0][Test.MyEnum.enum2] == "Hello!!")
+ test(ro[0][Test.MyEnum.enum3] == "qwerty")
+ test(len(ro[1]) == 1)
+ test(ro[1][Test.MyEnum.enum1] == "abc")
+
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0][Test.MyEnum.enum1] == "Goodbye")
+ test(len(do[1]) == 1)
+ test(do[1][Test.MyEnum.enum1] == "abc")
+ test(len(do[2]) == 2)
+ test(do[2][Test.MyEnum.enum2] == "Hello!!")
+ test(do[2][Test.MyEnum.enum3] == "qwerty")
+
+ #
+ # opMyStructMyEnumDS
+ #
+ s11 = Test.MyStruct(1, 1)
+ s12 = Test.MyStruct(1, 2)
+
+ s22 = Test.MyStruct(2, 2)
+ s23 = Test.MyStruct(2, 3)
+
+ dsi1 = (
+ { s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2 },
+ { s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2 }
+ )
+ dsi2 = ({ s23: Test.MyEnum.enum3 },)
+
+ ro, do = p.opMyStructMyEnumDS(dsi1, dsi2)
+
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0][s11] == Test.MyEnum.enum1)
+ test(ro[0][s22] == Test.MyEnum.enum3)
+ test(ro[0][s23] == Test.MyEnum.enum2)
+ test(len(ro[1]) == 2)
+ test(ro[1][s11] == Test.MyEnum.enum1)
+ test(ro[1][s12] == Test.MyEnum.enum2)
+
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0][s23] == Test.MyEnum.enum3)
+ test(len(do[1]) == 2)
+ test(do[1][s11] == Test.MyEnum.enum1)
+ test(do[1][s12] == Test.MyEnum.enum2)
+ test(len(do[2]) == 3)
+ test(do[2][s11] == Test.MyEnum.enum1)
+ test(do[2][s22] == Test.MyEnum.enum3)
+ test(do[2][s23] == Test.MyEnum.enum2)
+
+ #
+ #opByteByteSD
+ #
+ sdi1 = { 0x01: (0x01, 0x11), 0x22: (0x12,) }
+ sdi2 = { 0xf1: (0xf2, 0xf3) }
+
+ ro, do = p.opByteByteSD(sdi1, sdi2)
+
+ if sys.version_info[0] == 2:
+ test(len(do) == 1)
+ test(len(do[0xf1]) == 2)
+ test(do[0xf1][0] == '\xf2')
+ test(do[0xf1][1] == '\xf3')
+ test(len(ro) == 3)
+ test(len(ro[0x01]) == 2)
+ test(ro[0x01][0] == '\x01')
+ test(ro[0x01][1] == '\x11')
+ test(len(ro[0x22]) == 1)
+ test(ro[0x22][0] == '\x12')
+ test(len(ro[0xf1]) == 2)
+ test(ro[0xf1][0] == '\xf2')
+ test(ro[0xf1][1] == '\xf3')
+ else:
+ test(len(do) == 1)
+ test(len(do[0xf1]) == 2)
+ test(do[0xf1][0] == 0xf2)
+ test(do[0xf1][1] == 0xf3)
+ test(len(ro) == 3)
+ test(len(ro[0x01]) == 2)
+ test(ro[0x01][0] == 0x01)
+ test(ro[0x01][1] == 0x11)
+ test(len(ro[0x22]) == 1)
+ test(ro[0x22][0] == 0x12)
+ test(len(ro[0xf1]) == 2)
+ test(ro[0xf1][0] == 0xf2)
+ test(ro[0xf1][1] == 0xf3)
+
+ #
+ # opBoolBoolSD
+ #
+ sdi1 = { False: (True, False), True: (False, True, True) }
+ sdi2 = { False: (True, False) }
+
+ ro, do = p.opBoolBoolSD(sdi1, sdi2)
+
+ test(len(do) == 1)
+ test(len(do[False]) == 2)
+ test(do[False][0])
+ test(not do[False][1])
+ test(len(ro) == 2)
+ test(len(ro[False]) == 2)
+ test(ro[False][0])
+ test(not ro[False][1])
+ test(len(ro[True]) == 3)
+ test(not ro[True][0])
+ test(ro[True][1])
+ test(ro[True][2])
+
+ #
+ # opShortShortSD
+ #
+ sdi1 = { 1: (1, 2, 3), 2: (4, 5) }
+ sdi2 = { 4: (6, 7) }
+
+ ro, do = p.opShortShortSD(sdi1, sdi2)
+
+ test(len(do) == 1)
+ test(len(do[4]) == 2)
+ test(do[4][0] == 6)
+ test(do[4][1] == 7)
+ test(len(ro) == 3)
+ test(len(ro[1]) == 3)
+ test(ro[1][0] == 1)
+ test(ro[1][1] == 2)
+ test(ro[1][2] == 3)
+ test(len(ro[2]) == 2)
+ test(ro[2][0] == 4)
+ test(ro[2][1] == 5)
+ test(len(ro[4]) == 2)
+ test(ro[4][0] == 6)
+ test(ro[4][1] == 7)
+
+ #
+ # opIntIntSD
+ #
+ sdi1 = { 100: (100, 200, 300), 200: (400, 500) }
+ sdi2 = { 400: (600, 700) }
+
+ ro, do = p.opIntIntSD(sdi1, sdi2)
+
+ test(len(do) == 1)
+ test(len(do[400]) == 2)
+ test(do[400][0] == 600)
+ test(do[400][1] == 700)
+ test(len(ro) == 3)
+ test(len(ro[100]) == 3)
+ test(ro[100][0] == 100)
+ test(ro[100][1] == 200)
+ test(ro[100][2] == 300)
+ test(len(ro[200]) == 2)
+ test(ro[200][0] == 400)
+ test(ro[200][1] == 500)
+ test(len(ro[400]) == 2)
+ test(ro[400][0] == 600)
+ test(ro[400][1] == 700)
+
+ #
+ # opLongLongSD
+ #
+ sdi1 = { 999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130) }
+ sdi2 = { 999999992: (999999110, 999999120) }
+
+ ro, do = p.opLongLongSD(sdi1, sdi2)
+
+ test(len(do) == 1)
+ test(len(do[999999992]) == 2)
+ test(do[999999992][0] == 999999110)
+ test(do[999999992][1] == 999999120)
+ test(len(ro) == 3)
+ test(len(ro[999999990]) == 3)
+ test(ro[999999990][0] == 999999110)
+ test(ro[999999990][1] == 999999111)
+ test(ro[999999990][2] == 999999110)
+ test(len(ro[999999991]) == 2)
+ test(ro[999999991][0] == 999999120)
+ test(ro[999999991][1] == 999999130)
+ test(len(ro[999999992]) == 2)
+ test(ro[999999992][0] == 999999110)
+ test(ro[999999992][1] == 999999120)
+
+ #
+ # opStringFloatSD
+ #
+ sdi1 = { "abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61) }
+ sdi2 = { "aBc": (-3.14, 3.14) }
+
+ ro, do = p.opStringFloatSD(sdi1, sdi2)
+
+ test(len(do) == 1)
+ test(len(do["aBc"]) == 2)
+ test(do["aBc"][0] - -3.14 < 0.01)
+ test(do["aBc"][1] - 3.14 < 0.01)
+
+ test(len(ro) == 3)
+ test(len(ro["abc"]) == 3)
+ test(ro["abc"][0] - -1.1 < 0.01)
+ test(ro["abc"][1] - 123123.2 < 0.01)
+ test(ro["abc"][2] - 100.0 < 0.01)
+ test(len(ro["ABC"]) == 2)
+ test(ro["ABC"][0] - 42.24 < 0.01)
+ test(ro["ABC"][1] - -1.61 < 0.01)
+ test(len(ro["aBc"]) == 2)
+ test(ro["aBc"][0] - -3.14 < 0.01)
+ test(ro["aBc"][1] - 3.14 < 0.01)
+
+ #
+ # opStringDoubleSD
+ #
+ sdi1 = { "Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10) }
+ sdi2 = { "": (1.6E10, 1.7E10) }
+
+ ro, do = p.opStringDoubleSD(sdi1, sdi2);
+
+ test(len(do) == 1)
+ test(len(do[""]) == 2)
+ test(do[""][0] == 1.6E10)
+ test(do[""][1] == 1.7E10)
+ test(len(ro) == 3)
+ test(len(ro["Hello!!"]) == 3)
+ test(ro["Hello!!"][0] == 1.1E10)
+ test(ro["Hello!!"][1] == 1.2E10)
+ test(ro["Hello!!"][2] == 1.3E10)
+ test(len(ro["Goodbye"]) == 2)
+ test(ro["Goodbye"][0] == 1.4E10)
+ test(ro["Goodbye"][1] == 1.5E10)
+ test(len(ro[""]) == 2)
+ test(ro[""][0] == 1.6E10)
+ test(ro[""][1] == 1.7E10)
+
+ #
+ # opStringStringSD
+ #
+ sdi1 = { "abc": ("abc", "de", "fghi") , "def": ("xyz", "or") }
+ sdi2 = { "ghi": ("and", "xor") }
+
+ ro, do = p.opStringStringSD(sdi1, sdi2)
+
+ test(len(do) == 1)
+ test(len(do["ghi"]) == 2)
+ test(do["ghi"][0] == "and")
+ test(do["ghi"][1] == "xor")
+ test(len(ro) == 3)
+ test(len(ro["abc"]) == 3)
+ test(ro["abc"][0] == "abc")
+ test(ro["abc"][1] == "de")
+ test(ro["abc"][2] == "fghi")
+ test(len(ro["def"]) == 2)
+ test(ro["def"][0] == "xyz")
+ test(ro["def"][1] == "or")
+ test(len(ro["ghi"]) == 2)
+ test(ro["ghi"][0] == "and")
+ test(ro["ghi"][1] == "xor")
+
+ #
+ # opMyEnumMyEnumSD
+ #
+ sdi1 = {
+ Test.MyEnum.enum3: (Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2),
+ Test.MyEnum.enum2: (Test.MyEnum.enum1, Test.MyEnum.enum2)
+ }
+ sdi2 = { Test.MyEnum.enum1: (Test.MyEnum.enum3, Test.MyEnum.enum3) }
+
+ ro, do = p.opMyEnumMyEnumSD(sdi1, sdi2)
+
+ test(len(do) == 1)
+ test(len(do[Test.MyEnum.enum1]) == 2)
+ test(do[Test.MyEnum.enum1][0] == Test.MyEnum.enum3)
+ test(do[Test.MyEnum.enum1][1] == Test.MyEnum.enum3)
+ test(len(ro) == 3)
+ test(len(ro[Test.MyEnum.enum3]) == 3)
+ test(ro[Test.MyEnum.enum3][0] == Test.MyEnum.enum1)
+ test(ro[Test.MyEnum.enum3][1] == Test.MyEnum.enum1)
+ test(ro[Test.MyEnum.enum3][2] == Test.MyEnum.enum2)
+ test(len(ro[Test.MyEnum.enum2]) == 2)
+ test(ro[Test.MyEnum.enum2][0] == Test.MyEnum.enum1)
+ test(ro[Test.MyEnum.enum2][1] == Test.MyEnum.enum2)
+ test(len(ro[Test.MyEnum.enum1]) == 2)
+ test(ro[Test.MyEnum.enum1][0] == Test.MyEnum.enum3)
+ test(ro[Test.MyEnum.enum1][1] == Test.MyEnum.enum3)
+
+ #
+ # opIntS
+ #
+ lengths = ( 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 )
+ for l in lengths:
+ s = []
+ for i in range(l):
+ s.append(i)
+ r = p.opIntS(s)
+ test(len(r) == l)
+ for j in range(len(r)):
+ test(r[j] == -j)
+
+
+ #
+ # opContext
+ #
+ ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}
+
+ r = p.opContext()
+ test(len(p.ice_getContext()) == 0)
+ test(r != ctx)
+
+ r = p.opContext(ctx)
+ test(len(p.ice_getContext()) == 0)
+ test(r == ctx)
+
+ p2 = Test.MyClassPrx.checkedCast(p.ice_context(ctx))
+ test(p2.ice_getContext() == ctx)
+ r = p2.opContext()
+ test(r == ctx)
+ r = p2.opContext(ctx)
+ test(r == ctx)
+
+ #
+ # Test implicit context propagation
+ #
+ if p.ice_getConnection():
+ impls = ( 'Shared', 'PerThread' )
+ for i in impls:
+ initData = Ice.InitializationData()
+ initData.properties = communicator.getProperties().clone()
+ initData.properties.setProperty('Ice.ImplicitContext', i)
+ ic = Ice.initialize(data=initData)
+
+ ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}
+
+ p1 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy('test:default -p 12010'))
+
+ ic.getImplicitContext().setContext(ctx)
+ test(ic.getImplicitContext().getContext() == ctx)
+ test(p1.opContext() == ctx)
+
+ test(ic.getImplicitContext().containsKey('zero') == False)
+ r = ic.getImplicitContext().put('zero', 'ZERO')
+ test(r == '')
+ test(ic.getImplicitContext().containsKey('zero') == True)
+ test(ic.getImplicitContext().get('zero') == 'ZERO')
+
+ ctx = ic.getImplicitContext().getContext()
+ test(p1.opContext() == ctx)
+
+ prxContext = {'one': 'UN', 'four': 'QUATRE'}
+
+ combined = ctx.copy()
+ combined.update(prxContext)
+ test(combined['one'] == 'UN')
+
+ p2 = Test.MyClassPrx.uncheckedCast(p1.ice_context(prxContext))
+
+ ic.getImplicitContext().setContext({})
+ test(p2.opContext() == prxContext)
+
+ ic.getImplicitContext().setContext(ctx)
+ test(p2.opContext() == combined)
+
+ test(ic.getImplicitContext().remove('one') == 'ONE')
+
+ ic.destroy()
+
+ d = 1278312346.0 / 13.0
+ ds = []
+ for i in range(5):
+ ds.append(d)
+ p.opDoubleMarshaling(d, ds)
+
+ #
+ # opIdempotent
+ #
+ p.opIdempotent()
+
+ #
+ # opNonmutating
+ #
+ p.opNonmutating()
+
+ test(p.opByte1(0xFF) == 0xFF)
+ test(p.opShort1(0x7FFF) == 0x7FFF)
+ test(p.opInt1(0x7FFFFFFF) == 0x7FFFFFFF)
+ test(p.opLong1(0x7FFFFFFFFFFFFFFF) == 0x7FFFFFFFFFFFFFFF)
+ test(p.opFloat1(1.0) == 1.0)
+ test(p.opDouble1(1.0) == 1.0)
+ test(p.opString1("opString1") == "opString1")
+ test(len(p.opStringS1(None)) == 0)
+ test(len(p.opByteBoolD1(None)) == 0)
+ test(len(p.opStringS2(None)) == 0)
+ test(len(p.opByteBoolD2(None)) == 0)
+
+ d = Test.MyDerivedClassPrx.uncheckedCast(p)
+ s = Test.MyStruct1()
+ s.tesT = "Test.MyStruct1.s"
+ s.myClass = None
+ s.myStruct1 = "Test.MyStruct1.myStruct1"
+ s = d.opMyStruct1(s)
+ test(s.tesT == "Test.MyStruct1.s")
+ test(s.myClass == None)
+ test(s.myStruct1 == "Test.MyStruct1.myStruct1")
+ c = Test.MyClass1()
+ c.tesT = "Test.MyClass1.testT"
+ c.myClass = None
+ c.myClass1 = "Test.MyClass1.myClass1"
+ c = d.opMyClass1(c)
+ test(c.tesT == "Test.MyClass1.testT")
+ test(c.myClass == None)
+ test(c.myClass1 == "Test.MyClass1.myClass1")
diff --git a/python/test/Ice/operations/TwowaysAMI.py b/python/test/Ice/operations/TwowaysAMI.py
new file mode 100644
index 00000000000..83ef333dea1
--- /dev/null
+++ b/python/test/Ice/operations/TwowaysAMI.py
@@ -0,0 +1,1216 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, math, sys, threading
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class CallbackBase:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def check(self):
+ self._cond.acquire()
+ try:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ finally:
+ self._cond.release()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+class Callback(CallbackBase):
+ def __init__(self, communicator=None):
+ CallbackBase.__init__(self)
+ self._communicator = communicator
+
+ def ping(self):
+ self.called()
+
+ def isA(self, r):
+ test(r)
+ self.called()
+
+ def id(self, id):
+ test(id == "::Test::MyDerivedClass")
+ self.called()
+
+ def ids(self, ids):
+ test(len(ids) == 3)
+ self.called()
+
+ def opVoid(self):
+ self.called()
+
+ def opByte(self, r, b):
+ test(b == 0xf0)
+ test(r == 0xff)
+ self.called()
+
+ def opBool(self, r, b):
+ test(b)
+ test(not r)
+ self.called()
+
+ def opShortIntLong(self, r, s, i, l):
+ test(s == 10)
+ test(i == 11)
+ test(l == 12)
+ test(r == 12)
+ self.called()
+
+ def opFloatDouble(self, r, f, d):
+ test(f - 3.14 < 0.001)
+ test(d == 1.1E10)
+ test(r == 1.1E10)
+ self.called()
+
+ def opString(self, r, s):
+ test(s == "world hello")
+ test(r == "hello world")
+ self.called()
+
+ def opMyEnum(self, r, e):
+ test(e == Test.MyEnum.enum2)
+ test(r == Test.MyEnum.enum3)
+ self.called()
+
+ def opMyClass(self, r, c1, c2):
+ test(c1.ice_getIdentity() == self._communicator.stringToIdentity("test"))
+ test(c2.ice_getIdentity() == self._communicator.stringToIdentity("noSuchIdentity"))
+ test(r.ice_getIdentity() == self._communicator.stringToIdentity("test"))
+ # We can't do the callbacks below in serialize mode
+ if self._communicator.getProperties().getPropertyAsInt("Ice.Client.ThreadPool.Serialize") == 0:
+ r.opVoid()
+ c1.opVoid()
+ try:
+ c2.opVoid()
+ test(False)
+ except Ice.ObjectNotExistException:
+ pass
+ self.called()
+
+ def opStruct(self, rso, so):
+ test(rso.p == None)
+ test(rso.e == Test.MyEnum.enum2)
+ test(rso.s.s == "def")
+ test(so.e == Test.MyEnum.enum3)
+ test(so.s.s == "a new string")
+ # We can't do the callbacks below in serialize mode.
+ if self._communicator.getProperties().getPropertyAsInt("Ice.ThreadPool.Client.Serialize") == 0:
+ so.p.opVoid()
+ self.called()
+
+ def opByteS(self, rso, bso):
+ test(len(bso) == 4)
+ test(len(rso) == 8)
+ if sys.version_info[0] == 2:
+ test(bso[0] == '\x22')
+ test(bso[1] == '\x12')
+ test(bso[2] == '\x11')
+ test(bso[3] == '\x01')
+ test(rso[0] == '\x01')
+ test(rso[1] == '\x11')
+ test(rso[2] == '\x12')
+ test(rso[3] == '\x22')
+ test(rso[4] == '\xf1')
+ test(rso[5] == '\xf2')
+ test(rso[6] == '\xf3')
+ test(rso[7] == '\xf4')
+ else:
+ test(bso[0] == 0x22)
+ test(bso[1] == 0x12)
+ test(bso[2] == 0x11)
+ test(bso[3] == 0x01)
+ test(rso[0] == 0x01)
+ test(rso[1] == 0x11)
+ test(rso[2] == 0x12)
+ test(rso[3] == 0x22)
+ test(rso[4] == 0xf1)
+ test(rso[5] == 0xf2)
+ test(rso[6] == 0xf3)
+ test(rso[7] == 0xf4)
+ self.called()
+
+ def opBoolS(self, rso, bso):
+ test(len(bso) == 4)
+ test(bso[0])
+ test(bso[1])
+ test(not bso[2])
+ test(not bso[3])
+ test(len(rso) == 3)
+ test(not rso[0])
+ test(rso[1])
+ test(rso[2])
+ self.called()
+
+ def opShortIntLongS(self, rso, sso, iso, lso):
+ test(len(sso) == 3)
+ test(sso[0] == 1)
+ test(sso[1] == 2)
+ test(sso[2] == 3)
+ test(len(iso) == 4)
+ test(iso[0] == 8)
+ test(iso[1] == 7)
+ test(iso[2] == 6)
+ test(iso[3] == 5)
+ test(len(lso) == 6)
+ test(lso[0] == 10)
+ test(lso[1] == 30)
+ test(lso[2] == 20)
+ test(lso[3] == 10)
+ test(lso[4] == 30)
+ test(lso[5] == 20)
+ test(len(rso) == 3)
+ test(rso[0] == 10)
+ test(rso[1] == 30)
+ test(rso[2] == 20)
+ self.called()
+
+ def opFloatDoubleS(self, rso, fso, dso):
+ test(len(fso) == 2)
+ test(fso[0] - 3.14 < 0.001)
+ test(fso[1] - 1.11 < 0.001)
+ test(len(dso) == 3)
+ test(dso[0] == 1.3E10)
+ test(dso[1] == 1.2E10)
+ test(dso[2] == 1.1E10)
+ test(len(rso) == 5)
+ test(rso[0] == 1.1E10)
+ test(rso[1] == 1.2E10)
+ test(rso[2] == 1.3E10)
+ test(rso[3] - 3.14 < 0.001)
+ test(rso[4] - 1.11 < 0.001)
+ self.called()
+
+ def opStringS(self, rso, sso):
+ test(len(sso) == 4)
+ test(sso[0] == "abc")
+ test(sso[1] == "de")
+ test(sso[2] == "fghi")
+ test(sso[3] == "xyz")
+ test(len(rso) == 3)
+ test(rso[0] == "fghi")
+ test(rso[1] == "de")
+ test(rso[2] == "abc")
+ self.called()
+
+ def opByteSS(self, rso, bso):
+ test(len(bso) == 2)
+ test(len(bso[0]) == 1)
+ test(len(bso[1]) == 3)
+ test(len(rso) == 4)
+ test(len(rso[0]) == 3)
+ test(len(rso[1]) == 1)
+ test(len(rso[2]) == 1)
+ test(len(rso[3]) == 2)
+ if sys.version_info[0] == 2:
+ test(bso[0][0] == '\xff')
+ test(bso[1][0] == '\x01')
+ test(bso[1][1] == '\x11')
+ test(bso[1][2] == '\x12')
+ test(rso[0][0] == '\x01')
+ test(rso[0][1] == '\x11')
+ test(rso[0][2] == '\x12')
+ test(rso[1][0] == '\xff')
+ test(rso[2][0] == '\x0e')
+ test(rso[3][0] == '\xf2')
+ test(rso[3][1] == '\xf1')
+ else:
+ test(bso[0][0] == 0xff)
+ test(bso[1][0] == 0x01)
+ test(bso[1][1] == 0x11)
+ test(bso[1][2] == 0x12)
+ test(rso[0][0] == 0x01)
+ test(rso[0][1] == 0x11)
+ test(rso[0][2] == 0x12)
+ test(rso[1][0] == 0xff)
+ test(rso[2][0] == 0x0e)
+ test(rso[3][0] == 0xf2)
+ test(rso[3][1] == 0xf1)
+ self.called()
+
+ def opBoolSS(self, rso, bso):
+ test(len(bso) == 4);
+ test(len(bso[0]) == 1);
+ test(bso[0][0]);
+ test(len(bso[1]) == 1);
+ test(not bso[1][0]);
+ test(len(bso[2]) == 2);
+ test(bso[2][0]);
+ test(bso[2][1]);
+ test(len(bso[3]) == 3);
+ test(not bso[3][0]);
+ test(not bso[3][1]);
+ test(bso[3][2]);
+ test(len(rso) == 3);
+ test(len(rso[0]) == 2);
+ test(rso[0][0]);
+ test(rso[0][1]);
+ test(len(rso[1]) == 1);
+ test(not rso[1][0]);
+ test(len(rso[2]) == 1);
+ test(rso[2][0]);
+ self.called();
+
+ def opShortIntLongSS(self, rso, sso, iso, lso):
+ test(len(rso) == 1);
+ test(len(rso[0]) == 2);
+ test(rso[0][0] == 496);
+ test(rso[0][1] == 1729);
+ test(len(sso) == 3);
+ test(len(sso[0]) == 3);
+ test(sso[0][0] == 1);
+ test(sso[0][1] == 2);
+ test(sso[0][2] == 5);
+ test(len(sso[1]) == 1);
+ test(sso[1][0] == 13);
+ test(len(sso[2]) == 0);
+ test(len(iso) == 2);
+ test(len(iso[0]) == 1);
+ test(iso[0][0] == 42);
+ test(len(iso[1]) == 2);
+ test(iso[1][0] == 24);
+ test(iso[1][1] == 98);
+ test(len(lso) == 2);
+ test(len(lso[0]) == 2);
+ test(lso[0][0] == 496);
+ test(lso[0][1] == 1729);
+ test(len(lso[1]) == 2);
+ test(lso[1][0] == 496);
+ test(lso[1][1] == 1729);
+ self.called();
+
+ def opFloatDoubleSS(self, rso, fso, dso):
+ test(len(fso) == 3)
+ test(len(fso[0]) == 1)
+ test(fso[0][0] - 3.14 < 0.001)
+ test(len(fso[1]) == 1)
+ test(fso[1][0] - 1.11 < 0.001)
+ test(len(fso[2]) == 0)
+ test(len(dso) == 1)
+ test(len(dso[0]) == 3)
+ test(dso[0][0] == 1.1E10)
+ test(dso[0][1] == 1.2E10)
+ test(dso[0][2] == 1.3E10)
+ test(len(rso) == 2)
+ test(len(rso[0]) == 3)
+ test(rso[0][0] == 1.1E10)
+ test(rso[0][1] == 1.2E10)
+ test(rso[0][2] == 1.3E10)
+ test(len(rso[1]) == 3)
+ test(rso[1][0] == 1.1E10)
+ test(rso[1][1] == 1.2E10)
+ test(rso[1][2] == 1.3E10)
+ self.called()
+
+ def opStringSS(self, rso, sso):
+ test(len(sso) == 5)
+ test(len(sso[0]) == 1)
+ test(sso[0][0] == "abc")
+ test(len(sso[1]) == 2)
+ test(sso[1][0] == "de")
+ test(sso[1][1] == "fghi")
+ test(len(sso[2]) == 0)
+ test(len(sso[3]) == 0)
+ test(len(sso[4]) == 1)
+ test(sso[4][0] == "xyz")
+ test(len(rso) == 3)
+ test(len(rso[0]) == 1)
+ test(rso[0][0] == "xyz")
+ test(len(rso[1]) == 0)
+ test(len(rso[2]) == 0)
+ self.called()
+
+ def opByteBoolD(self, ro, do):
+ di1 = {10: True, 100: False}
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro[10])
+ test(not ro[11])
+ test(not ro[100])
+ test(ro[101])
+ self.called()
+
+ def opShortIntD(self, ro, do):
+ di1 = {110: -1, 1100: 123123}
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro[110] == -1)
+ test(ro[111] == -100)
+ test(ro[1100] == 123123)
+ test(ro[1101] == 0)
+ self.called()
+
+ def opLongFloatD(self, ro, do):
+ di1 = {999999110: -1.1, 999999111: 123123.2}
+ for k in do:
+ test(math.fabs(do[k] - di1[k]) < 0.01)
+ test(len(ro) == 4)
+ test(ro[999999110] - -1.1 < 0.01)
+ test(ro[999999120] - -100.4 < 0.01)
+ test(ro[999999111] - 123123.2 < 0.01)
+ test(ro[999999130] - 0.5 < 0.01)
+ self.called()
+
+ def opStringStringD(self, ro, do):
+ di1 = {'foo': 'abc -1.1', 'bar': 'abc 123123.2'}
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro["foo"] == "abc -1.1")
+ test(ro["FOO"] == "abc -100.4")
+ test(ro["bar"] == "abc 123123.2")
+ test(ro["BAR"] == "abc 0.5")
+ self.called()
+
+ def opStringMyEnumD(self, ro, do):
+ di1 = {'abc': Test.MyEnum.enum1, '': Test.MyEnum.enum2}
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro["abc"] == Test.MyEnum.enum1)
+ test(ro["qwerty"] == Test.MyEnum.enum3)
+ test(ro[""] == Test.MyEnum.enum2)
+ test(ro["Hello!!"] == Test.MyEnum.enum2)
+ self.called()
+
+ def opMyEnumStringD(self, ro, do):
+ di1 = {Test.MyEnum.enum1: 'abc'}
+ test(do == di1)
+ test(len(ro) == 3)
+ test(ro[Test.MyEnum.enum1] == "abc")
+ test(ro[Test.MyEnum.enum2] == "Hello!!")
+ test(ro[Test.MyEnum.enum3] == "qwerty")
+ self.called()
+
+ def opMyStructMyEnumD(self, ro, do):
+ s11 = Test.MyStruct()
+ s11.i = 1
+ s11.j = 1
+ s12 = Test.MyStruct()
+ s12.i = 1
+ s12.j = 2
+ s22 = Test.MyStruct()
+ s22.i = 2
+ s22.j = 2
+ s23 = Test.MyStruct()
+ s23.i = 2
+ s23.j = 3
+ di1 = {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2}
+ test(do == di1)
+ test(len(ro) == 4)
+ test(ro[s11] == Test.MyEnum.enum1)
+ test(ro[s12] == Test.MyEnum.enum2)
+ test(ro[s22] == Test.MyEnum.enum3)
+ test(ro[s23] == Test.MyEnum.enum2)
+ self.called()
+
+ def opByteBoolDS(self, ro, do):
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0][10])
+ test(not ro[0][11])
+ test(ro[0][101])
+ test(len(ro[1]) == 2)
+ test(ro[1][10])
+ test(not ro[1][100])
+ test(len(do) == 3)
+ test(len(do[0]) == 2)
+ test(not do[0][100])
+ test(not do[0][101])
+ test(len(do[1]) == 2)
+ test(do[1][10])
+ test(not do[1][100])
+ test(len(do[2]) == 3)
+ test(do[2][10])
+ test(not do[2][11])
+ test(do[2][101])
+ self.called()
+
+ def opShortIntDS(self, ro, do):
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0][110] == -1)
+ test(ro[0][111] == -100)
+ test(ro[0][1101] == 0)
+ test(len(ro[1]) == 2)
+ test(ro[1][110] == -1)
+ test(ro[1][1100] == 123123)
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0][100] == -1001)
+ test(len(do[1]) == 2)
+ test(do[1][110] == -1)
+ test(do[1][1100] == 123123)
+ test(len(do[2]) == 3)
+ test(do[2][110] == -1)
+ test(do[2][111] == -100)
+ test(do[2][1101] == 0)
+ self.called()
+
+ def opLongFloatDS(self, ro, do):
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0][999999110] - -1.1 < 0.01)
+ test(ro[0][999999120] - -100.4 < 0.01)
+ test(ro[0][999999130] - 0.5 < 0.01)
+ test(len(ro[1]) == 2)
+ test(ro[1][999999110] - -1.1 < 0.01)
+ test(ro[1][999999111] - 123123.2 < 0.01)
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0][999999140] - 3.14 < 0.01)
+ test(len(do[1]) == 2)
+ test(do[1][999999110] - -1.1 < 0.01)
+ test(do[1][999999111] - 123123.2 < 0.01)
+ test(len(do[2]) == 3)
+ test(do[2][999999110] - -1.1 < 0.01)
+ test(do[2][999999120] - -100.4 < 0.01)
+ test(do[2][999999130] - 0.5 < 0.01)
+ self.called()
+
+ def opStringStringDS(self, ro, do):
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0]["foo"] == "abc -1.1")
+ test(ro[0]["FOO"] == "abc -100.4")
+ test(ro[0]["BAR"] == "abc 0.5")
+ test(len(ro[1]) == 2)
+ test(ro[1]["foo"] == "abc -1.1")
+ test(ro[1]["bar"] == "abc 123123.2")
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0]["f00"] == "ABC -3.14")
+ test(len(do[1]) == 2)
+ test(do[1]["foo"] == "abc -1.1")
+ test(do[1]["bar"] == "abc 123123.2")
+ test(len(do[2]) == 3)
+ test(do[2]["foo"] == "abc -1.1")
+ test(do[2]["FOO"] == "abc -100.4")
+ test(do[2]["BAR"] == "abc 0.5")
+ self.called()
+
+ def opStringMyEnumDS(self, ro, do):
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0]["abc"] == Test.MyEnum.enum1)
+ test(ro[0]["qwerty"] == Test.MyEnum.enum3)
+ test(ro[0]["Hello!!"] == Test.MyEnum.enum2)
+ test(len(ro[1]) == 2)
+ test(ro[1]["abc"] == Test.MyEnum.enum1)
+ test(ro[1][""] == Test.MyEnum.enum2)
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0]["Goodbye"] == Test.MyEnum.enum1)
+ test(len(do[1]) == 2)
+ test(do[1]["abc"] == Test.MyEnum.enum1)
+ test(do[1][""] == Test.MyEnum.enum2)
+ test(len(do[2]) == 3)
+ test(do[2]["abc"] == Test.MyEnum.enum1)
+ test(do[2]["qwerty"] == Test.MyEnum.enum3)
+ test(do[2]["Hello!!"] == Test.MyEnum.enum2)
+ self.called()
+
+ def opMyEnumStringDS(self, ro, do):
+ test(len(ro) == 2)
+ test(len(ro[0]) == 2)
+ test(ro[0][Test.MyEnum.enum2] == "Hello!!")
+ test(ro[0][Test.MyEnum.enum3] == "qwerty")
+ test(len(ro[1]) == 1)
+ test(ro[1][Test.MyEnum.enum1] == "abc")
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0][Test.MyEnum.enum1] == "Goodbye")
+ test(len(do[1]) == 1)
+ test(do[1][Test.MyEnum.enum1] == "abc")
+ test(len(do[2]) == 2)
+ test(do[2][Test.MyEnum.enum2] == "Hello!!")
+ test(do[2][Test.MyEnum.enum3] == "qwerty")
+ self.called()
+
+ def opMyStructMyEnumDS(self, ro, do):
+ s11 = Test.MyStruct(1, 1)
+ s12 = Test.MyStruct(1, 2)
+ s22 = Test.MyStruct(2, 2)
+ s23 = Test.MyStruct(2, 3)
+ test(len(ro) == 2)
+ test(len(ro[0]) == 3)
+ test(ro[0][s11] == Test.MyEnum.enum1)
+ test(ro[0][s22] == Test.MyEnum.enum3)
+ test(ro[0][s23] == Test.MyEnum.enum2)
+ test(len(ro[1]) == 2)
+ test(ro[1][s11] == Test.MyEnum.enum1)
+ test(ro[1][s12] == Test.MyEnum.enum2)
+ test(len(do) == 3)
+ test(len(do[0]) == 1)
+ test(do[0][s23] == Test.MyEnum.enum3)
+ test(len(do[1]) == 2)
+ test(do[1][s11] == Test.MyEnum.enum1)
+ test(do[1][s12] == Test.MyEnum.enum2)
+ test(len(do[2]) == 3)
+ test(do[2][s11] == Test.MyEnum.enum1)
+ test(do[2][s22] == Test.MyEnum.enum3)
+ test(do[2][s23] == Test.MyEnum.enum2)
+ self.called()
+
+ def opByteByteSD(self, ro, do):
+ if sys.version_info[0] == 2:
+ test(len(do) == 1)
+ test(len(do[0xf1]) == 2)
+ test(do[0xf1][0] == '\xf2')
+ test(do[0xf1][1] == '\xf3')
+ test(len(ro) == 3)
+ test(len(ro[0x01]) == 2)
+ test(ro[0x01][0] == '\x01')
+ test(ro[0x01][1] == '\x11')
+ test(len(ro[0x22]) == 1)
+ test(ro[0x22][0] == '\x12')
+ test(len(ro[0xf1]) == 2)
+ test(ro[0xf1][0] == '\xf2')
+ test(ro[0xf1][1] == '\xf3')
+ else:
+ test(len(do) == 1)
+ test(len(do[0xf1]) == 2)
+ test(do[0xf1][0] == 0xf2)
+ test(do[0xf1][1] == 0xf3)
+ test(len(ro) == 3)
+ test(len(ro[0x01]) == 2)
+ test(ro[0x01][0] == 0x01)
+ test(ro[0x01][1] == 0x11)
+ test(len(ro[0x22]) == 1)
+ test(ro[0x22][0] == 0x12)
+ test(len(ro[0xf1]) == 2)
+ test(ro[0xf1][0] == 0xf2)
+ test(ro[0xf1][1] == 0xf3)
+ self.called()
+
+ def opBoolBoolSD(self, ro, do):
+ test(len(do) == 1)
+ test(len(do[False]) == 2)
+ test(do[False][0])
+ test(not do[False][1])
+ test(len(ro) == 2)
+ test(len(ro[False]) == 2)
+ test(ro[False][0])
+ test(not ro[False][1])
+ test(len(ro[True]) == 3)
+ test(not ro[True][0])
+ test(ro[True][1])
+ test(ro[True][2])
+ self.called()
+
+ def opShortShortSD(self, ro, do):
+ test(len(do) == 1)
+ test(len(do[4]) == 2)
+ test(do[4][0] == 6)
+ test(do[4][1] == 7)
+ test(len(ro) == 3)
+ test(len(ro[1]) == 3)
+ test(ro[1][0] == 1)
+ test(ro[1][1] == 2)
+ test(ro[1][2] == 3)
+ test(len(ro[2]) == 2)
+ test(ro[2][0] == 4)
+ test(ro[2][1] == 5)
+ test(len(ro[4]) == 2)
+ test(ro[4][0] == 6)
+ test(ro[4][1] == 7)
+ self.called()
+
+ def opIntIntSD(self, ro, do):
+ test(len(do) == 1)
+ test(len(do[400]) == 2)
+ test(do[400][0] == 600)
+ test(do[400][1] == 700)
+ test(len(ro) == 3)
+ test(len(ro[100]) == 3)
+ test(ro[100][0] == 100)
+ test(ro[100][1] == 200)
+ test(ro[100][2] == 300)
+ test(len(ro[200]) == 2)
+ test(ro[200][0] == 400)
+ test(ro[200][1] == 500)
+ test(len(ro[400]) == 2)
+ test(ro[400][0] == 600)
+ test(ro[400][1] == 700)
+ self.called()
+
+ def opLongLongSD(self, ro, do):
+ test(len(do) == 1)
+ test(len(do[999999992]) == 2)
+ test(do[999999992][0] == 999999110)
+ test(do[999999992][1] == 999999120)
+ test(len(ro) == 3)
+ test(len(ro[999999990]) == 3)
+ test(ro[999999990][0] == 999999110)
+ test(ro[999999990][1] == 999999111)
+ test(ro[999999990][2] == 999999110)
+ test(len(ro[999999991]) == 2)
+ test(ro[999999991][0] == 999999120)
+ test(ro[999999991][1] == 999999130)
+ test(len(ro[999999992]) == 2)
+ test(ro[999999992][0] == 999999110)
+ test(ro[999999992][1] == 999999120)
+ self.called()
+
+ def opStringFloatSD(self, ro, do):
+ test(len(do) == 1)
+ test(len(do["aBc"]) == 2)
+ test(do["aBc"][0] - -3.14 < 0.10)
+ test(do["aBc"][1] - 3.14 < 0.10)
+ test(len(ro) == 3)
+ test(len(ro["abc"]) == 3)
+ test(ro["abc"][0] - -1.1 < 0.10)
+ test(ro["abc"][1] - 123123.2 < 0.10)
+ test(ro["abc"][2] - 100.0 < 0.10)
+ test(len(ro["ABC"]) == 2)
+ test(ro["ABC"][0] - 42.24 < 0.10)
+ test(ro["ABC"][1] - -1.61 < 0.10)
+ test(len(ro["aBc"]) == 2)
+ test(ro["aBc"][0] - -3.14 < 0.10)
+ test(ro["aBc"][1] - 3.14 < 0.10)
+ self.called()
+
+ def opStringDoubleSD(self, ro, do):
+ test(len(do) == 1)
+ test(len(do[""]) == 2)
+ test(do[""][0] == 1.6E10)
+ test(do[""][1] == 1.7E10)
+ test(len(ro) == 3)
+ test(len(ro["Hello!!"]) == 3)
+ test(ro["Hello!!"][0] == 1.1E10)
+ test(ro["Hello!!"][1] == 1.2E10)
+ test(ro["Hello!!"][2] == 1.3E10)
+ test(len(ro["Goodbye"]) == 2)
+ test(ro["Goodbye"][0] == 1.4E10)
+ test(ro["Goodbye"][1] == 1.5E10)
+ test(len(ro[""]) == 2)
+ test(ro[""][0] == 1.6E10)
+ test(ro[""][1] == 1.7E10)
+ self.called()
+
+ def opStringStringSD(self, ro, do):
+ test(len(do) == 1)
+ test(len(do["ghi"]) == 2)
+ test(do["ghi"][0] == "and")
+ test(do["ghi"][1] == "xor")
+ test(len(ro) == 3)
+ test(len(ro["abc"]) == 3)
+ test(ro["abc"][0] == "abc")
+ test(ro["abc"][1] == "de")
+ test(ro["abc"][2] == "fghi")
+ test(len(ro["def"]) == 2)
+ test(ro["def"][0] == "xyz")
+ test(ro["def"][1] == "or")
+ test(len(ro["ghi"]) == 2)
+ test(ro["ghi"][0] == "and")
+ test(ro["ghi"][1] == "xor")
+ self.called()
+
+ def opMyEnumMyEnumSD(self, ro, do):
+ test(len(do) == 1)
+ test(len(do[Test.MyEnum.enum1]) == 2)
+ test(do[Test.MyEnum.enum1][0] == Test.MyEnum.enum3)
+ test(do[Test.MyEnum.enum1][1] == Test.MyEnum.enum3)
+ test(len(ro) == 3)
+ test(len(ro[Test.MyEnum.enum3]) == 3)
+ test(ro[Test.MyEnum.enum3][0] == Test.MyEnum.enum1)
+ test(ro[Test.MyEnum.enum3][1] == Test.MyEnum.enum1)
+ test(ro[Test.MyEnum.enum3][2] == Test.MyEnum.enum2)
+ test(len(ro[Test.MyEnum.enum2]) == 2)
+ test(ro[Test.MyEnum.enum2][0] == Test.MyEnum.enum1)
+ test(ro[Test.MyEnum.enum2][1] == Test.MyEnum.enum2)
+ test(len(ro[Test.MyEnum.enum1]) == 2)
+ test(ro[Test.MyEnum.enum1][0] == Test.MyEnum.enum3)
+ test(ro[Test.MyEnum.enum1][1] == Test.MyEnum.enum3)
+ self.called()
+
+ def opIntS(self, r):
+ for j in range(0, len(r)):
+ test(r[j] == -j)
+ self.called()
+
+ def opIdempotent(self):
+ self.called()
+
+ def opNonmutating(self):
+ self.called()
+
+ def opDerived(self):
+ self.called()
+
+ def exCB(self, ex):
+ test(False)
+
+def twowaysAMI(communicator, p):
+ cb = Callback()
+ p.begin_ice_ping(cb.ping, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_ice_isA(Test.MyClass.ice_staticId(), cb.isA, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_ice_id(cb.id, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_ice_ids(cb.ids, cb.exCB)
+ cb.check()
+
+ r = p.begin_opVoid()
+ p.end_opVoid(r)
+
+ cb = Callback()
+ p.begin_opVoid(cb.opVoid, cb.exCB)
+ cb.check()
+
+ r = p.begin_opByte(0xff, 0x0f)
+ (ret, p3) = p.end_opByte(r)
+ test(p3 == 0xf0)
+ test(ret == 0xff)
+
+ cb = Callback()
+ p.begin_opByte(0xff, 0x0f, cb.opByte, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opBool(True, False, cb.opBool, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opShortIntLong(10, 11, 12, cb.opShortIntLong, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opFloatDouble(3.14, 1.1E10, cb.opFloatDouble, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opString("hello", "world", cb.opString, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opMyEnum(Test.MyEnum.enum2, cb.opMyEnum, cb.exCB)
+ cb.check()
+
+ cb = Callback(communicator)
+ p.begin_opMyClass(p, cb.opMyClass, cb.exCB)
+ cb.check()
+
+ si1 = Test.Structure()
+ si1.p = p
+ si1.e = Test.MyEnum.enum3
+ si1.s = Test.AnotherStruct()
+ si1.s.s = "abc"
+ si2 = Test.Structure()
+ si2.p = None
+ si2.e = Test.MyEnum.enum2
+ si2.s = Test.AnotherStruct()
+ si2.s.s = "def"
+
+ cb = Callback(communicator)
+ p.begin_opStruct(si1, si2, cb.opStruct, cb.exCB)
+ cb.check()
+
+ bsi1 = (0x01, 0x11, 0x12, 0x22)
+ bsi2 = (0xf1, 0xf2, 0xf3, 0xf4)
+
+ cb = Callback()
+ p.begin_opByteS(bsi1, bsi2, cb.opByteS, cb.exCB)
+ cb.check()
+
+ bsi1 = (True, True, False)
+ bsi2 = (False,)
+
+ cb = Callback()
+ p.begin_opBoolS(bsi1, bsi2, cb.opBoolS, cb.exCB)
+ cb.check()
+
+ ssi = (1, 2, 3)
+ isi = (5, 6, 7, 8)
+ lsi = (10, 30, 20)
+
+ cb = Callback()
+ p.begin_opShortIntLongS(ssi, isi, lsi, cb.opShortIntLongS, cb.exCB)
+ cb.check()
+
+ fsi = (3.14, 1.11)
+ dsi = (1.1E10, 1.2E10, 1.3E10)
+
+ cb = Callback()
+ p.begin_opFloatDoubleS(fsi, dsi, cb.opFloatDoubleS, cb.exCB)
+ cb.check()
+
+ ssi1 = ('abc', 'de', 'fghi')
+ ssi2 = ('xyz',)
+
+ cb = Callback()
+ p.begin_opStringS(ssi1, ssi2, cb.opStringS, cb.exCB)
+ cb.check()
+
+ bsi1 = ((0x01, 0x11, 0x12), (0xff,))
+ bsi2 = ((0x0e,), (0xf2, 0xf1))
+
+ cb = Callback()
+ p.begin_opByteSS(bsi1, bsi2, cb.opByteSS, cb.exCB)
+ cb.check()
+
+ bsi1 = ((True,), (False,), (True, True),)
+ bsi2 = ((False, False, True),)
+
+ cb = Callback()
+ p.begin_opBoolSS(bsi1, bsi2, cb.opBoolSS, cb.exCB)
+ cb.check();
+
+ ssi = ((1,2,5), (13,), ())
+ isi = ((24, 98), (42,))
+ lsi = ((496, 1729),)
+
+ cb = Callback()
+ p.begin_opShortIntLongSS(ssi, isi, lsi, cb.opShortIntLongSS, cb.exCB)
+ cb.check()
+
+ fsi = ((3.14,), (1.11,), ())
+ dsi = ((1.1E10, 1.2E10, 1.3E10),)
+
+ cb = Callback()
+ p.begin_opFloatDoubleSS(fsi, dsi, cb.opFloatDoubleSS, cb.exCB)
+ cb.check()
+
+ ssi1 = (('abc',), ('de', 'fghi'))
+ ssi2 = ((), (), ('xyz',))
+
+ cb = Callback()
+ p.begin_opStringSS(ssi1, ssi2, cb.opStringSS, cb.exCB)
+ cb.check()
+
+ di1 = {10: True, 100: False}
+ di2 = {10: True, 11: False, 101: True}
+
+ cb = Callback()
+ p.begin_opByteBoolD(di1, di2, cb.opByteBoolD, cb.exCB)
+ cb.check()
+
+ di1 = {110: -1, 1100: 123123}
+ di2 = {110: -1, 111: -100, 1101: 0}
+
+ cb = Callback()
+ p.begin_opShortIntD(di1, di2, cb.opShortIntD, cb.exCB)
+ cb.check()
+
+ di1 = {999999110: -1.1, 999999111: 123123.2}
+ di2 = {999999110: -1.1, 999999120: -100.4, 999999130: 0.5}
+
+ cb = Callback()
+ p.begin_opLongFloatD(di1, di2, cb.opLongFloatD, cb.exCB)
+ cb.check()
+
+ di1 = {'foo': 'abc -1.1', 'bar': 'abc 123123.2'}
+ di2 = {'foo': 'abc -1.1', 'FOO': 'abc -100.4', 'BAR': 'abc 0.5'}
+
+ cb = Callback()
+ p.begin_opStringStringD(di1, di2, cb.opStringStringD, cb.exCB)
+ cb.check()
+
+ di1 = {'abc': Test.MyEnum.enum1, '': Test.MyEnum.enum2}
+ di2 = {'abc': Test.MyEnum.enum1, 'qwerty': Test.MyEnum.enum3, 'Hello!!': Test.MyEnum.enum2}
+
+ cb = Callback()
+ p.begin_opStringMyEnumD(di1, di2, cb.opStringMyEnumD, cb.exCB)
+ cb.check()
+
+ di1 = {Test.MyEnum.enum1: 'abc'}
+ di2 = {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}
+
+ cb = Callback()
+ p.begin_opMyEnumStringD(di1, di2, cb.opMyEnumStringD, cb.exCB)
+ cb.check()
+
+ s11 = Test.MyStruct()
+ s11.i = 1
+ s11.j = 1
+ s12 = Test.MyStruct()
+ s12.i = 1
+ s12.j = 2
+ s22 = Test.MyStruct()
+ s22.i = 2
+ s22.j = 2
+ s23 = Test.MyStruct()
+ s23.i = 2
+ s23.j = 3
+ di1 = {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2}
+ di2 = {s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2}
+
+ cb = Callback()
+ p.begin_opMyStructMyEnumD(di1, di2, cb.opMyStructMyEnumD, cb.exCB)
+ cb.check()
+
+ dsi1 = ({ 10: True, 100: False }, { 10: True, 11: False, 101: True })
+ dsi2 = ({ 100: False, 101: False },)
+
+ cb = Callback()
+ p.begin_opByteBoolDS(dsi1, dsi2, cb.opByteBoolDS, cb.exCB)
+ cb.check()
+
+ dsi1 = ({ 110: -1, 1100: 123123 }, { 110: -1, 111: -100, 1101: 0 })
+ dsi2 = ({ 100: -1001 },)
+
+ cb = Callback()
+ p.begin_opShortIntDS(dsi1, dsi2, cb.opShortIntDS, cb.exCB)
+ cb.called()
+
+ dsi1 = ({ 999999110: -1.1, 999999111: 123123.2 }, { 999999110: -1.1, 999999120: -100.4, 999999130: 0.5 })
+ dsi2 = ({ 999999140: 3.14 },)
+
+ cb = Callback()
+ p.begin_opLongFloatDS(dsi1, dsi2, cb.opLongFloatDS, cb.exCB)
+ cb.called()
+
+ dsi1 = ({ "foo": "abc -1.1", "bar": "abc 123123.2" }, { "foo": "abc -1.1", "FOO": "abc -100.4", "BAR": "abc 0.5" })
+ dsi2 = ({ "f00": "ABC -3.14" },)
+
+ cb = Callback()
+ p.begin_opStringStringDS(dsi1, dsi2, cb.opStringStringDS, cb.exCB)
+ cb.called()
+
+ dsi1 = (
+ { "abc": Test.MyEnum.enum1, "": Test.MyEnum.enum2 },
+ { "abc": Test.MyEnum.enum1, "qwerty": Test.MyEnum.enum3, "Hello!!": Test.MyEnum.enum2 }
+ )
+
+ dsi2 = ({ "Goodbye": Test.MyEnum.enum1 },)
+
+ cb = Callback()
+ p.begin_opStringMyEnumDS(dsi1, dsi2, cb.opStringMyEnumDS, cb.exCB)
+ cb.called()
+
+ dsi1 = ({ Test.MyEnum.enum1: 'abc' }, { Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'})
+ dsi2 = ({ Test.MyEnum.enum1: 'Goodbye' },)
+
+ cb = Callback()
+ p.begin_opMyEnumStringDS(dsi1, dsi2, cb.opMyEnumStringDS, cb.exCB)
+ cb.called()
+
+ s11 = Test.MyStruct(1, 1)
+ s12 = Test.MyStruct(1, 2)
+
+ s22 = Test.MyStruct(2, 2)
+ s23 = Test.MyStruct(2, 3)
+
+ dsi1 = (
+ { s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2 },
+ { s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2 }
+ )
+ dsi2 = ({ s23: Test.MyEnum.enum3 },)
+
+ cb = Callback()
+ p.begin_opMyStructMyEnumDS(dsi1, dsi2, cb.opMyStructMyEnumDS, cb.exCB)
+ cb.called()
+
+ sdi1 = { 0x01: (0x01, 0x11), 0x22: (0x12,) }
+ sdi2 = { 0xf1: (0xf2, 0xf3) }
+
+ cb = Callback()
+ p.begin_opByteByteSD(sdi1, sdi2, cb.opByteByteSD, cb.exCB)
+ cb.called()
+
+ sdi1 = { False: (True, False), True: (False, True, True) }
+ sdi2 = { False: (True, False) }
+
+ cb = Callback()
+ p.begin_opBoolBoolSD(sdi1, sdi2, cb.opBoolBoolSD, cb.exCB)
+ cb.called()
+
+ sdi1 = { 1: (1, 2, 3), 2: (4, 5) }
+ sdi2 = { 4: (6, 7) }
+
+ cb = Callback()
+ p.begin_opShortShortSD(sdi1, sdi2, cb.opShortShortSD, cb.exCB)
+ cb.called()
+
+ sdi1 = { 100: (100, 200, 300), 200: (400, 500) }
+ sdi2 = { 400: (600, 700) }
+
+ cb = Callback()
+ p.begin_opIntIntSD(sdi1, sdi2, cb.opIntIntSD, cb.exCB)
+ cb.called()
+
+ sdi1 = { 999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130) }
+ sdi2 = { 999999992: (999999110, 999999120) }
+
+ cb = Callback()
+ p.begin_opLongLongSD(sdi1, sdi2, cb.opLongLongSD, cb.exCB)
+ cb.called()
+
+ sdi1 = { "abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61) }
+ sdi2 = { "aBc": (-3.14, 3.14) }
+
+ cb = Callback()
+ p.begin_opStringFloatSD(sdi1, sdi2, cb.opStringFloatSD, cb.exCB)
+ cb.called()
+
+ sdi1 = { "Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10) }
+ sdi2 = { "": (1.6E10, 1.7E10) }
+
+ cb = Callback()
+ p.begin_opStringDoubleSD(sdi1, sdi2, cb.opStringDoubleSD, cb.exCB);
+ cb.called()
+
+ sdi1 = { "abc": ("abc", "de", "fghi") , "def": ("xyz", "or") }
+ sdi2 = { "ghi": ("and", "xor") }
+
+ cb = Callback()
+ p.begin_opStringStringSD(sdi1, sdi2, cb.opStringStringSD, cb.exCB)
+ cb.called()
+
+ sdi1 = {
+ Test.MyEnum.enum3: (Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2),
+ Test.MyEnum.enum2: (Test.MyEnum.enum1, Test.MyEnum.enum2)
+ }
+ sdi2 = { Test.MyEnum.enum1: (Test.MyEnum.enum3, Test.MyEnum.enum3) }
+
+ cb = Callback()
+ p.begin_opMyEnumMyEnumSD(sdi1, sdi2, cb.opMyEnumMyEnumSD, cb.exCB)
+ cb.called()
+
+ lengths = ( 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 )
+ for l in lengths:
+ s = []
+ for i in range(l):
+ s.append(i)
+ cb = Callback(l)
+ p.begin_opIntS(s, cb.opIntS, cb.exCB)
+ cb.check()
+
+ ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}
+
+ test(len(p.ice_getContext()) == 0)
+ r = p.begin_opContext()
+ c = p.end_opContext(r)
+ test(c != ctx)
+
+ test(len(p.ice_getContext()) == 0)
+ r = p.begin_opContext(_ctx=ctx)
+ c = p.end_opContext(r)
+ test(c == ctx)
+
+ p2 = Test.MyClassPrx.checkedCast(p.ice_context(ctx))
+ test(p2.ice_getContext() == ctx)
+ r = p2.begin_opContext()
+ c = p2.end_opContext(r)
+ test(c == ctx)
+
+ r = p2.begin_opContext(_ctx=ctx)
+ c = p2.end_opContext(r)
+ test(c == ctx)
+
+ #
+ # Test implicit context propagation
+ #
+ if p.ice_getConnection():
+ impls = ( 'Shared', 'PerThread' )
+ for i in impls:
+ initData = Ice.InitializationData()
+ initData.properties = communicator.getProperties().clone()
+ initData.properties.setProperty('Ice.ImplicitContext', i)
+ ic = Ice.initialize(data=initData)
+
+ ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}
+
+ p3 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:default -p 12010"))
+
+ ic.getImplicitContext().setContext(ctx)
+ test(ic.getImplicitContext().getContext() == ctx)
+ r = p3.begin_opContext()
+ c = p3.end_opContext(r)
+ test(c == ctx)
+
+ ic.getImplicitContext().put('zero', 'ZERO')
+
+ ctx = ic.getImplicitContext().getContext()
+ r = p3.begin_opContext()
+ c = p3.end_opContext(r)
+ test(c == ctx)
+
+ prxContext = {'one': 'UN', 'four': 'QUATRE'}
+
+ combined = {}
+ combined.update(ctx)
+ combined.update(prxContext)
+ test(combined['one'] == 'UN')
+
+ p3 = Test.MyClassPrx.uncheckedCast(p3.ice_context(prxContext))
+ ic.getImplicitContext().setContext({})
+ r = p3.begin_opContext()
+ c = p3.end_opContext(r)
+ test(c == prxContext)
+
+ ic.getImplicitContext().setContext(ctx)
+ r = p3.begin_opContext()
+ c = p3.end_opContext(r)
+ test(c == combined)
+
+ ic.destroy()
+
+ cb = Callback()
+ p.begin_opIdempotent(cb.opIdempotent, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opNonmutating(cb.opNonmutating, cb.exCB)
+ cb.check()
+
+ derived = Test.MyDerivedClassPrx.checkedCast(p)
+ test(derived)
+ cb = Callback()
+ derived.begin_opDerived(cb.opDerived, cb.exCB)
+ cb.check()
+
+
+ r = p.begin_opByte1(0xFF)
+ test(p.end_opByte1(r) == 0xFF)
+
+ r = p.begin_opShort1(0x7FFF)
+ test(p.end_opShort1(r) == 0x7FFF)
+
+ r = p.begin_opInt1(0x7FFFFFFF)
+ test(p.end_opInt1(r) == 0x7FFFFFFF)
+
+ r = p.begin_opLong1(0x7FFFFFFFFFFFFFFF)
+ test(p.end_opLong1(r) == 0x7FFFFFFFFFFFFFFF)
+
+ r = p.begin_opFloat1(1.0)
+ test(p.end_opFloat1(r) == 1.0)
+
+ r = p.begin_opDouble1(1.0)
+ test(p.end_opDouble1(r) == 1.0)
+
+ r = p.begin_opString1("opString1")
+ test(p.end_opString1(r) == "opString1")
+
+ r = p.begin_opStringS1(None)
+ test(len(p.end_opStringS1(r)) == 0)
+
+ r = p.begin_opByteBoolD1(None)
+ test(len(p.end_opByteBoolD1(r)) == 0)
+
+ r = p.begin_opStringS2(None)
+ test(len(p.end_opStringS2(r)) == 0)
+
+ r = p.begin_opByteBoolD2(None)
+ test(len(p.end_opByteBoolD2(r)) == 0)
diff --git a/python/test/Ice/operations/run.py b/python/test/Ice/operations/run.py
new file mode 100755
index 00000000000..767b20c0a2c
--- /dev/null
+++ b/python/test/Ice/operations/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("tests with regular server.")
+TestUtil.clientServerTest()
+print("tests with AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py")
+print("tests with collocated server.")
+TestUtil.collocatedTest(" --Ice.ThreadPool.Client.SizeMax=2 --Ice.ThreadPool.Client.SizeWarn=0")
diff --git a/python/test/Ice/optional/AllTests.py b/python/test/Ice/optional/AllTests.py
new file mode 100644
index 00000000000..051e415e9f4
--- /dev/null
+++ b/python/test/Ice/optional/AllTests.py
@@ -0,0 +1,774 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ ref = "initial:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ initial = Test.InitialPrx.checkedCast(base)
+ test(initial)
+ test(initial == base)
+ print("ok")
+
+ sys.stdout.write("testing optional data members... ")
+ sys.stdout.flush()
+
+ oo1 = Test.OneOptional()
+ test(oo1.a is Ice.Unset)
+ oo1.a = 15
+
+ oo2 = Test.OneOptional(16)
+ test(oo2.a == 16)
+
+ mo1 = Test.MultiOptional()
+ test(mo1.a is Ice.Unset)
+ test(mo1.b is Ice.Unset)
+ test(mo1.c is Ice.Unset)
+ test(mo1.d is Ice.Unset)
+ test(mo1.e is Ice.Unset)
+ test(mo1.f is Ice.Unset)
+ test(mo1.g is Ice.Unset)
+ test(mo1.h is Ice.Unset)
+ test(mo1.i is Ice.Unset)
+ test(mo1.j is Ice.Unset)
+ test(mo1.k is Ice.Unset)
+ test(mo1.bs is Ice.Unset)
+ test(mo1.ss is Ice.Unset)
+ test(mo1.iid is Ice.Unset)
+ test(mo1.sid is Ice.Unset)
+ test(mo1.fs is Ice.Unset)
+ test(mo1.vs is Ice.Unset)
+
+ test(mo1.shs is Ice.Unset)
+ test(mo1.es is Ice.Unset)
+ test(mo1.fss is Ice.Unset)
+ test(mo1.vss is Ice.Unset)
+ test(mo1.oos is Ice.Unset)
+ test(mo1.oops is Ice.Unset)
+
+ test(mo1.ied is Ice.Unset)
+ test(mo1.ifsd is Ice.Unset)
+ test(mo1.ivsd is Ice.Unset)
+ test(mo1.iood is Ice.Unset)
+ test(mo1.ioopd is Ice.Unset)
+
+ test(mo1.bos is Ice.Unset)
+
+ fs = Test.FixedStruct(78)
+ vs = Test.VarStruct("hello")
+ mo1 = Test.MultiOptional(15, True, 19, 78, 99, 5.5, 1.0, "test", Test.MyEnum.MyEnumMember, \
+ Test.MultiOptionalPrx.uncheckedCast(communicator.stringToProxy("test")), \
+ None, [5], ["test", "test2"], {4:3}, {"test":10}, fs, vs, [1], \
+ [Test.MyEnum.MyEnumMember, Test.MyEnum.MyEnumMember], \
+ [ fs ], [ vs ], [ oo1 ], \
+ [ Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")) ], \
+ {4:Test.MyEnum.MyEnumMember}, {4:fs}, {5:vs}, {5:Test.OneOptional(15)}, \
+ {5:Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))}, \
+ [False, True, False])
+
+ test(mo1.a == 15)
+ test(mo1.b == True)
+ test(mo1.c == 19)
+ test(mo1.d == 78)
+ test(mo1.e == 99)
+ test(mo1.f == 5.5)
+ test(mo1.g == 1.0)
+ test(mo1.h == "test")
+ test(mo1.i == Test.MyEnum.MyEnumMember)
+ test(mo1.j == Test.MultiOptionalPrx.uncheckedCast(communicator.stringToProxy("test")))
+ test(mo1.k == None)
+ test(mo1.bs == [5])
+ test(mo1.ss == ["test", "test2"])
+ test(mo1.iid[4] == 3)
+ test(mo1.sid["test"] == 10)
+ test(mo1.fs == Test.FixedStruct(78))
+ test(mo1.vs == Test.VarStruct("hello"))
+
+ test(mo1.shs[0] == 1)
+ test(mo1.es[0] == Test.MyEnum.MyEnumMember and mo1.es[1] == Test.MyEnum.MyEnumMember)
+ test(mo1.fss[0] == Test.FixedStruct(78))
+ test(mo1.vss[0] == Test.VarStruct("hello"))
+ test(mo1.oos[0] == oo1)
+ test(mo1.oops[0] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")))
+
+ test(mo1.ied[4] == Test.MyEnum.MyEnumMember)
+ test(mo1.ifsd[4] == Test.FixedStruct(78))
+ test(mo1.ivsd[5] == Test.VarStruct("hello"))
+ test(mo1.iood[5].a == 15)
+ test(mo1.ioopd[5] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")))
+
+ test(mo1.bos == [False, True, False])
+
+ print("ok")
+
+ sys.stdout.write("testing marshaling... ")
+ sys.stdout.flush()
+
+ oo4 = initial.pingPong(Test.OneOptional())
+ test(oo4.a is Ice.Unset)
+
+ oo5 = initial.pingPong(oo1)
+ test(oo1.a == oo5.a)
+
+ mo4 = initial.pingPong(Test.MultiOptional())
+ test(mo4.a is Ice.Unset)
+ test(mo4.b is Ice.Unset)
+ test(mo4.c is Ice.Unset)
+ test(mo4.d is Ice.Unset)
+ test(mo4.e is Ice.Unset)
+ test(mo4.f is Ice.Unset)
+ test(mo4.g is Ice.Unset)
+ test(mo4.h is Ice.Unset)
+ test(mo4.i is Ice.Unset)
+ test(mo4.j is Ice.Unset)
+ test(mo4.k is Ice.Unset)
+ test(mo4.bs is Ice.Unset)
+ test(mo4.ss is Ice.Unset)
+ test(mo4.iid is Ice.Unset)
+ test(mo4.sid is Ice.Unset)
+ test(mo4.fs is Ice.Unset)
+ test(mo4.vs is Ice.Unset)
+
+ test(mo4.shs is Ice.Unset)
+ test(mo4.es is Ice.Unset)
+ test(mo4.fss is Ice.Unset)
+ test(mo4.vss is Ice.Unset)
+ test(mo4.oos is Ice.Unset)
+ test(mo4.oops is Ice.Unset)
+
+ test(mo4.ied is Ice.Unset)
+ test(mo4.ifsd is Ice.Unset)
+ test(mo4.ivsd is Ice.Unset)
+ test(mo4.iood is Ice.Unset)
+ test(mo4.ioopd is Ice.Unset)
+
+ test(mo4.bos is Ice.Unset)
+
+ mo5 = initial.pingPong(mo1)
+ test(mo5.a == mo1.a)
+ test(mo5.b == mo1.b)
+ test(mo5.c == mo1.c)
+ test(mo5.d == mo1.d)
+ test(mo5.e == mo1.e)
+ test(mo5.f == mo1.f)
+ test(mo5.g == mo1.g)
+ test(mo5.h == mo1.h)
+ test(mo5.i == mo1.i)
+ test(mo5.j == mo1.j)
+ test(mo5.k == None)
+ if sys.version_info[0] == 2:
+ test(mo5.bs == "\x05")
+ else:
+ test(mo5.bs[0] == 5)
+ test(mo5.ss == mo1.ss)
+ test(mo5.iid[4] == 3)
+ test(mo5.sid["test"] == 10)
+ test(mo5.fs == mo1.fs)
+ test(mo5.vs == mo1.vs)
+ test(mo5.shs == mo1.shs)
+ test(mo5.es[0] == Test.MyEnum.MyEnumMember and mo1.es[1] == Test.MyEnum.MyEnumMember)
+ test(mo5.fss[0] == Test.FixedStruct(78))
+ test(mo5.vss[0] == Test.VarStruct("hello"))
+ test(mo5.oos[0].a == 15)
+ test(mo5.oops[0] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")))
+
+ test(mo5.ied[4] == Test.MyEnum.MyEnumMember)
+ test(mo5.ifsd[4] == Test.FixedStruct(78))
+ test(mo5.ivsd[5] == Test.VarStruct("hello"))
+ test(mo5.iood[5].a == 15)
+ test(mo5.ioopd[5] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")))
+
+ test(mo5.bos == mo1.bos)
+
+ # Clear the first half of the optional members
+ mo6 = Test.MultiOptional()
+ mo6.b = mo5.b
+ mo6.d = mo5.d
+ mo6.f = mo5.f
+ mo6.h = mo5.h
+ mo6.j = mo5.j
+ mo6.bs = mo5.bs
+ mo6.iid = mo5.iid
+ mo6.fs = mo5.fs
+ mo6.shs = mo5.shs
+ mo6.fss = mo5.fss
+ mo6.oos = mo5.oos
+ mo6.ifsd = mo5.ifsd
+ mo6.iood = mo5.iood
+ mo6.bos = mo5.bos
+
+ mo7 = initial.pingPong(mo6)
+ test(mo7.a is Ice.Unset)
+ test(mo7.b == mo1.b)
+ test(mo7.c is Ice.Unset)
+ test(mo7.d == mo1.d)
+ test(mo7.e is Ice.Unset)
+ test(mo7.f == mo1.f)
+ test(mo7.g is Ice.Unset)
+ test(mo7.h == mo1.h)
+ test(mo7.i is Ice.Unset)
+ test(mo7.j == mo1.j)
+ test(mo7.k is Ice.Unset)
+ if sys.version_info[0] == 2:
+ test(mo7.bs == "\x05")
+ else:
+ test(mo7.bs[0] == 5)
+ test(mo7.ss is Ice.Unset)
+ test(mo7.iid[4] == 3)
+ test(mo7.sid is Ice.Unset)
+ test(mo7.fs == mo1.fs)
+ test(mo7.vs is Ice.Unset)
+
+ test(mo7.shs == mo1.shs)
+ test(mo7.es is Ice.Unset)
+ test(mo7.fss[0] == Test.FixedStruct(78))
+ test(mo7.vss is Ice.Unset)
+ test(mo7.oos[0].a == 15)
+ test(mo7.oops is Ice.Unset)
+
+ test(mo7.ied is Ice.Unset)
+ test(mo7.ifsd[4] == Test.FixedStruct(78))
+ test(mo7.ivsd is Ice.Unset)
+ test(mo7.iood[5].a == 15)
+ test(mo7.ioopd is Ice.Unset)
+
+ test(mo7.bos == [False, True, False])
+
+ # Clear the second half of the optional members
+ mo8 = Test.MultiOptional()
+ mo8.a = mo5.a
+ mo8.c = mo5.c
+ mo8.e = mo5.e
+ mo8.g = mo5.g
+ mo8.i = mo5.i
+ mo8.k = mo8
+ mo8.ss = mo5.ss
+ mo8.sid = mo5.sid
+ mo8.vs = mo5.vs
+
+ mo8.es = mo5.es
+ mo8.vss = mo5.vss
+ mo8.oops = mo5.oops
+
+ mo8.ied = mo5.ied
+ mo8.ivsd = mo5.ivsd
+ mo8.ioopd = mo5.ioopd
+
+ mo9 = initial.pingPong(mo8)
+ test(mo9.a == mo1.a)
+ test(mo9.b is Ice.Unset)
+ test(mo9.c == mo1.c)
+ test(mo9.d is Ice.Unset)
+ test(mo9.e == mo1.e)
+ test(mo9.f is Ice.Unset)
+ test(mo9.g == mo1.g)
+ test(mo9.h is Ice.Unset)
+ test(mo9.i == mo1.i)
+ test(mo9.j is Ice.Unset)
+ test(mo9.k == mo9)
+ test(mo9.bs is Ice.Unset)
+ test(mo9.ss == mo1.ss)
+ test(mo9.iid is Ice.Unset)
+ test(mo9.sid["test"] == 10)
+ test(mo9.fs is Ice.Unset)
+ test(mo9.vs == mo1.vs)
+
+ test(mo9.shs is Ice.Unset)
+ test(mo9.es[0] == Test.MyEnum.MyEnumMember and mo1.es[1] == Test.MyEnum.MyEnumMember)
+ test(mo9.fss is Ice.Unset)
+ test(mo9.vss[0] == Test.VarStruct("hello"))
+ test(mo9.oos is Ice.Unset)
+ test(mo9.oops[0] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")))
+
+ test(mo9.ied[4] == Test.MyEnum.MyEnumMember)
+ test(mo9.ifsd is Ice.Unset)
+ test(mo9.ivsd[5] == Test.VarStruct("hello"))
+ test(mo9.iood is Ice.Unset)
+ test(mo9.ioopd[5] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")))
+
+ test(mo9.bos is Ice.Unset)
+
+ #
+ # Use the 1.0 encoding with operations whose only class parameters are optional.
+ #
+ initial.sendOptionalClass(True, Test.OneOptional(53))
+ initial.ice_encodingVersion(Ice.Encoding_1_0).sendOptionalClass(True, Test.OneOptional(53))
+
+ r = initial.returnOptionalClass(True)
+ test(r != Ice.Unset)
+ r = initial.ice_encodingVersion(Ice.Encoding_1_0).returnOptionalClass(True)
+ test(r is Ice.Unset)
+
+ recursive1 = [ Test.Recursive() ]
+ recursive2 = [ Test.Recursive() ]
+ recursive1[0].value = recursive2;
+
+ outer = Test.Recursive()
+ outer.value = recursive1
+ initial.pingPong(outer)
+
+ print("ok")
+
+ sys.stdout.write("testing marshaling of large containers with fixed size elements... ")
+ sys.stdout.flush()
+
+ mc = Test.MultiOptional()
+
+ mc.bs = []
+ for i in range(1000):
+ mc.bs.append(0)
+ mc.shs = []
+ for i in range(300):
+ mc.shs.append(0)
+
+ mc.fss = []
+ for i in range(300):
+ mc.fss.append(Test.FixedStruct())
+
+ mc.ifsd = {}
+ for i in range(300):
+ mc.ifsd[i] = Test.FixedStruct()
+
+ mc = initial.pingPong(mc)
+ test(len(mc.bs) == 1000)
+ test(len(mc.shs) == 300)
+ test(len(mc.fss) == 300)
+ test(len(mc.ifsd) == 300)
+
+ print("ok")
+
+ sys.stdout.write("testing tag marshaling... ")
+ sys.stdout.flush()
+
+ b = Test.B()
+ b2 = initial.pingPong(b)
+ test(b2.ma is Ice.Unset)
+ test(b2.mb is Ice.Unset)
+ test(b2.mc is Ice.Unset)
+
+ b.ma = 10
+ b.mb = 11
+ b.mc = 12
+ b.md = 13
+
+ b2 = initial.pingPong(b)
+ test(b2.ma == 10)
+ test(b2.mb == 11)
+ test(b2.mc == 12)
+ test(b2.md == 13)
+
+ print("ok")
+
+ sys.stdout.write("testing marshalling of objects with optional objects...")
+ sys.stdout.flush()
+
+ f = Test.F()
+
+ f.af = Test.A()
+ f.ae = f.af
+
+ rf = initial.pingPong(f)
+ test(rf.ae == rf.af)
+
+ print("ok")
+
+ sys.stdout.write("testing optional with default values... ")
+ sys.stdout.flush()
+
+ wd = initial.pingPong(Test.WD())
+ test(wd.a == 5)
+ test(wd.s == "test")
+ wd.a = Ice.Unset
+ wd.s = Ice.Unset
+ wd = initial.pingPong(wd)
+ test(wd.a is Ice.Unset)
+ test(wd.s is Ice.Unset)
+
+ print("ok")
+
+ if communicator.getProperties().getPropertyAsInt("Ice.Default.SlicedFormat") > 0:
+ sys.stdout.write("testing marshaling with unknown class slices... ")
+ sys.stdout.flush()
+
+ c = Test.C()
+ c.ss = "test"
+ c.ms = "testms"
+ c = initial.pingPong(c)
+ test(c.ma is Ice.Unset)
+ test(c.mb is Ice.Unset)
+ test(c.mc is Ice.Unset)
+ test(c.md is Ice.Unset)
+ test(c.ss == "test")
+ test(c.ms == "testms")
+
+ print("ok")
+
+ sys.stdout.write("testing optionals with unknown classes... ")
+ sys.stdout.flush()
+
+ initial2 = Test.Initial2Prx.uncheckedCast(base)
+ d = Test.D()
+ d.ds = "test"
+ d.seq = ["test1", "test2", "test3", "test4"]
+ d.ao = Test.A(18)
+ d.requiredB = 14;
+ d.requiredA = 14;
+ initial2.opClassAndUnknownOptional(Test.A(), d)
+
+ print("ok")
+
+ sys.stdout.write("testing optional parameters... ")
+ sys.stdout.flush()
+
+ (p2, p3) = initial.opByte(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opByte(56)
+ test(p2 == 56 and p3 == 56)
+ r = initial.begin_opByte(56)
+ (p2, p3) = initial.end_opByte(r)
+ test(p2 == 56 and p3 == 56)
+
+ (p2, p3) = initial.opBool(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opBool(True)
+ test(p2 == True and p3 == True)
+ r = initial.begin_opBool(True)
+ (p2, p3) = initial.end_opBool(r)
+ test(p2 == True and p3 == True)
+
+ (p2, p3) = initial.opShort(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opShort(56)
+ test(p2 == 56 and p3 == 56)
+ r = initial.begin_opShort(56)
+ (p2, p3) = initial.end_opShort(r)
+ test(p2 == 56 and p3 == 56)
+
+ (p2, p3) = initial.opInt(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opInt(56)
+ test(p2 == 56 and p3 == 56)
+ r = initial.begin_opInt(56)
+ (p2, p3) = initial.end_opInt(r)
+ test(p2 == 56 and p3 == 56)
+
+ (p2, p3) = initial.opLong(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opLong(56)
+ test(p2 == 56 and p3 == 56)
+ r = initial.begin_opLong(56)
+ (p2, p3) = initial.end_opLong(r)
+ test(p2 == 56 and p3 == 56)
+
+ (p2, p3) = initial.opFloat(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opFloat(1.0)
+ test(p2 == 1.0 and p3 == 1.0)
+ r = initial.begin_opFloat(1.0)
+ (p2, p3) = initial.end_opFloat(r)
+ test(p2 == 1.0 and p3 == 1.0)
+
+ (p2, p3) = initial.opDouble(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opDouble(1.0)
+ test(p2 == 1.0 and p3 == 1.0)
+ r = initial.begin_opDouble(1.0)
+ (p2, p3) = initial.end_opDouble(r)
+ test(p2 == 1.0 and p3 == 1.0)
+
+ (p2, p3) = initial.opString(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opString("test")
+ test(p2 == "test" and p3 == "test")
+ r = initial.begin_opString("test")
+ (p2, p3) = initial.end_opString(r)
+ test(p2 == "test" and p3 == "test")
+
+ (p2, p3) = initial.opMyEnum(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ (p2, p3) = initial.opMyEnum(Test.MyEnum.MyEnumMember)
+ test(p2 == Test.MyEnum.MyEnumMember and p3 == Test.MyEnum.MyEnumMember)
+ r = initial.begin_opMyEnum(Test.MyEnum.MyEnumMember)
+ (p2, p3) = initial.end_opMyEnum(r)
+ test(p2 == Test.MyEnum.MyEnumMember and p3 == Test.MyEnum.MyEnumMember)
+
+ (p2, p3) = initial.opSmallStruct(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = Test.SmallStruct(56)
+ (p2, p3) = initial.opSmallStruct(p1)
+ test(p2 == p1 and p3 == p1)
+ (p2, p3) = initial.opSmallStruct(None) # Test null struct
+ test(p2.m == 0 and p3.m == 0)
+ r = initial.begin_opSmallStruct(p1)
+ (p2, p3) = initial.end_opSmallStruct(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opFixedStruct(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = Test.FixedStruct(56)
+ (p2, p3) = initial.opFixedStruct(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opFixedStruct(p1)
+ (p2, p3) = initial.end_opFixedStruct(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opVarStruct(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = Test.VarStruct("test")
+ (p2, p3) = initial.opVarStruct(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opVarStruct(p1)
+ (p2, p3) = initial.end_opVarStruct(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opOneOptional(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = Test.OneOptional(58)
+ (p2, p3) = initial.opOneOptional(p1)
+ test(p2.a == p1.a and p3.a == p1.a)
+ r = initial.begin_opOneOptional(p1)
+ (p2, p3) = initial.end_opOneOptional(r)
+ test(p2.a == p1.a and p3.a == p1.a)
+
+ (p2, p3) = initial.opOneOptionalProxy(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))
+ (p2, p3) = initial.opOneOptionalProxy(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opOneOptionalProxy(p1)
+ (p2, p3) = initial.end_opOneOptionalProxy(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opByteSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [56 for x in range(100)]
+ (p2, p3) = initial.opByteSeq(p1)
+ test(len(p2) == len(p1) and len(p3) == len(p1))
+ if sys.version_info[0] == 2:
+ test(p2[0] == '\x38')
+ test(p3[0] == '\x38')
+ else:
+ test(p2[0] == 0x38)
+ test(p3[0] == 0x38)
+ r = initial.begin_opByteSeq(p1)
+ (p2, p3) = initial.end_opByteSeq(r)
+ test(len(p2) == len(p1) and len(p3) == len(p1))
+ if sys.version_info[0] == 2:
+ test(p2[0] == '\x38')
+ test(p3[0] == '\x38')
+ else:
+ test(p2[0] == 0x38)
+ test(p3[0] == 0x38)
+
+ (p2, p3) = initial.opBoolSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [True for x in range(100)]
+ (p2, p3) = initial.opBoolSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opBoolSeq(p1)
+ (p2, p3) = initial.end_opBoolSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opShortSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [56 for x in range(100)]
+ (p2, p3) = initial.opShortSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opShortSeq(p1)
+ (p2, p3) = initial.end_opShortSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opIntSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [56 for x in range(100)]
+ (p2, p3) = initial.opIntSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opIntSeq(p1)
+ (p2, p3) = initial.end_opIntSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opLongSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [56 for x in range(100)]
+ (p2, p3) = initial.opLongSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opLongSeq(p1)
+ (p2, p3) = initial.end_opLongSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opFloatSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [1.0 for x in range(100)]
+ (p2, p3) = initial.opFloatSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opFloatSeq(p1)
+ (p2, p3) = initial.end_opFloatSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opDoubleSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [1.0 for x in range(100)]
+ (p2, p3) = initial.opDoubleSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opDoubleSeq(p1)
+ (p2, p3) = initial.end_opDoubleSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opStringSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = ["test1" for x in range(100)]
+ (p2, p3) = initial.opStringSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opStringSeq(p1)
+ (p2, p3) = initial.end_opStringSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opSmallStructSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [Test.SmallStruct(1) for x in range(10)]
+ (p2, p3) = initial.opSmallStructSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opSmallStructSeq(p1)
+ (p2, p3) = initial.end_opSmallStructSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opSmallStructList(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = tuple([Test.SmallStruct(1) for x in range(10)])
+ (p2, p3) = initial.opSmallStructList(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opSmallStructList(p1)
+ (p2, p3) = initial.end_opSmallStructList(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opFixedStructSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [Test.FixedStruct(1) for x in range(10)]
+ (p2, p3) = initial.opFixedStructSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opFixedStructSeq(p1)
+ (p2, p3) = initial.end_opFixedStructSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opFixedStructList(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = tuple([Test.FixedStruct(1) for x in range(10)])
+ (p2, p3) = initial.opFixedStructList(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opFixedStructList(p1)
+ (p2, p3) = initial.end_opFixedStructList(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opVarStructSeq(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = [Test.VarStruct("test") for x in range(10)]
+ (p2, p3) = initial.opVarStructSeq(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opVarStructSeq(p1)
+ (p2, p3) = initial.end_opVarStructSeq(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opIntIntDict(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = {1:2, 2:3}
+ (p2, p3) = initial.opIntIntDict(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opIntIntDict(p1)
+ (p2, p3) = initial.end_opIntIntDict(r)
+ test(p2 == p1 and p3 == p1)
+
+ (p2, p3) = initial.opStringIntDict(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = {"1":2, "2":3}
+ (p2, p3) = initial.opStringIntDict(p1)
+ test(p2 == p1 and p3 == p1)
+ r = initial.begin_opStringIntDict(p1)
+ (p2, p3) = initial.end_opStringIntDict(r)
+ test(p2 == p1 and p3 == p1)
+
+ print("ok")
+
+ sys.stdout.write("testing exception optionals... ")
+ sys.stdout.flush()
+
+ try:
+ initial.opOptionalException(Ice.Unset, Ice.Unset, Ice.Unset)
+ except Test.OptionalException as ex:
+ test(ex.a is Ice.Unset)
+ test(ex.b is Ice.Unset)
+ test(ex.o is Ice.Unset)
+
+ try:
+ initial.opOptionalException(30, "test", Test.OneOptional(53))
+ except Test.OptionalException as ex:
+ test(ex.a == 30)
+ test(ex.b == "test")
+ test(ex.o.a == 53)
+
+ try:
+ #
+ # Use the 1.0 encoding with an exception whose only class members are optional.
+ #
+ initial.ice_encodingVersion(Ice.Encoding_1_0).opOptionalException(30, "test", Test.OneOptional(53))
+ except Test.OptionalException as ex:
+ test(ex.a is Ice.Unset)
+ test(ex.b is Ice.Unset)
+ test(ex.o is Ice.Unset)
+
+ try:
+ initial.opDerivedException(Ice.Unset, Ice.Unset, Ice.Unset)
+ except Test.DerivedException as ex:
+ test(ex.a is Ice.Unset)
+ test(ex.b is Ice.Unset)
+ test(ex.o is Ice.Unset)
+ test(ex.ss is Ice.Unset)
+ test(ex.o2 is Ice.Unset)
+
+ try:
+ initial.opDerivedException(30, "test2", Test.OneOptional(53))
+ except Test.DerivedException as ex:
+ test(ex.a == 30)
+ test(ex.b == "test2")
+ test(ex.o.a == 53)
+ test(ex.ss == "test2")
+ test(ex.o2 == ex.o)
+
+ try:
+ initial.opRequiredException(Ice.Unset, Ice.Unset, Ice.Unset)
+ except Test.RequiredException as ex:
+ test(ex.a is Ice.Unset)
+ test(ex.b is Ice.Unset)
+ test(ex.o is Ice.Unset)
+ test(ex.ss == "test")
+ test(ex.o2 == None)
+
+ try:
+ initial.opRequiredException(30, "test2", Test.OneOptional(53))
+ except Test.RequiredException as ex:
+ test(ex.a == 30)
+ test(ex.b == "test2")
+ test(ex.o.a == 53)
+ test(ex.ss == "test2")
+ test(ex.o2 == ex.o)
+
+ print("ok")
+
+ return initial
diff --git a/python/test/Ice/optional/Client.py b/python/test/Ice/optional/Client.py
new file mode 100755
index 00000000000..98b5a22d66f
--- /dev/null
+++ b/python/test/Ice/optional/Client.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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('--all -I. ClientPrivate.ice')
+import AllTests
+
+def run(args, communicator):
+ initial = AllTests.allTests(communicator)
+ initial.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/optional/ClientPrivate.ice b/python/test/Ice/optional/ClientPrivate.ice
new file mode 100644
index 00000000000..c7211442401
--- /dev/null
+++ b/python/test/Ice/optional/ClientPrivate.ice
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Test.ice>
+
+module Test
+{
+
+//
+// The server doesn't know this class.
+//
+class D extends B
+{
+ string ds;
+ optional(990) StringSeq seq;
+ optional(1000) A ao;
+};
+
+//
+// This class is a hack that allows us to invoke the opClassAndUnknownOptional operation
+// on the server and pass an optional argument. This isn't necessary in other language
+// mappings where the public stream API is available.
+//
+class Initial2
+{
+ void opClassAndUnknownOptional(A p, optional(1) Object o);
+};
+
+};
diff --git a/python/test/Ice/optional/Server.py b/python/test/Ice/optional/Server.py
new file mode 100755
index 00000000000..1533bd38b70
--- /dev/null
+++ b/python/test/Ice/optional/Server.py
@@ -0,0 +1,174 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 InitialI(Test.Initial):
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def pingPong(self, o, current=None):
+ return o
+
+ def opOptionalException(self, a, b, o, current=None):
+ raise Test.OptionalException(False, a, b, o)
+
+ def opDerivedException(self, a, b, o, current=None):
+ raise Test.DerivedException(False, a, b, o, b, o)
+
+ def opRequiredException(self, a, b, o, current=None):
+ e = Test.RequiredException()
+ e.a = a
+ e.b = b
+ e.o = o
+ if b is not Ice.Unset:
+ e.ss = b
+ if o is not Ice.Unset:
+ e.o2 = o
+ raise e
+
+ def opByte(self, p1, current=None):
+ return (p1, p1)
+
+ def opBool(self, p1, current=None):
+ return (p1, p1)
+
+ def opShort(self, p1, current=None):
+ return (p1, p1)
+
+ def opInt(self, p1, current=None):
+ return (p1, p1)
+
+ def opLong(self, p1, current=None):
+ return (p1, p1)
+
+ def opFloat(self, p1, current=None):
+ return (p1, p1)
+
+ def opDouble(self, p1, current=None):
+ return (p1, p1)
+
+ def opString(self, p1, current=None):
+ return (p1, p1)
+
+ def opMyEnum(self, p1, current=None):
+ return (p1, p1)
+
+ def opSmallStruct(self, p1, current=None):
+ return (p1, p1)
+
+ def opFixedStruct(self, p1, current=None):
+ return (p1, p1)
+
+ def opVarStruct(self, p1, current=None):
+ return (p1, p1)
+
+ def opOneOptional(self, p1, current=None):
+ return (p1, p1)
+
+ def opOneOptionalProxy(self, p1, current=None):
+ return (p1, p1)
+
+ def opByteSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opBoolSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opShortSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opIntSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opLongSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opFloatSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opDoubleSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opStringSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opSmallStructSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opSmallStructList(self, p1, current=None):
+ return (p1, p1)
+
+ def opFixedStructSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opFixedStructList(self, p1, current=None):
+ return (p1, p1)
+
+ def opVarStructSeq(self, p1, current=None):
+ return (p1, p1)
+
+ def opSerializable(self, p1, current=None):
+ return (p1, p1)
+
+ def opIntIntDict(self, p1, current=None):
+ return (p1, p1)
+
+ def opStringIntDict(self, p1, current=None):
+ return (p1, p1)
+
+ def opClassAndUnknownOptional(self, p, current=None):
+ pass
+
+ def sendOptionalClass(self, req, o, current=None):
+ pass
+
+ def returnOptionalClass(self, req, current=None):
+ return Test.OneOptional(5)
+
+ def supportsRequiredParams(self, current=None):
+ return False
+
+ def supportsJavaSerializable(self, current=None):
+ return True
+
+ def supportsCsharpSerializable(self, current=None):
+ return True
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ initial = InitialI()
+ adapter.add(initial, communicator.stringToIdentity("initial"))
+ adapter.activate()
+
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/optional/ServerAMD.py b/python/test/Ice/optional/ServerAMD.py
new file mode 100755
index 00000000000..edf6701cb0e
--- /dev/null
+++ b/python/test/Ice/optional/ServerAMD.py
@@ -0,0 +1,175 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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('TestAMD.ice')
+import Test
+
+class InitialI(Test.Initial):
+
+ def shutdown_async(self, cb, current=None):
+ current.adapter.getCommunicator().shutdown()
+ cb.ice_response()
+
+ def pingPong_async(self, cb, o, current=None):
+ cb.ice_response(o)
+
+ def opOptionalException_async(self, cb, a, b, o, current=None):
+ cb.ice_exception(Test.OptionalException(False, a, b, o))
+
+ def opDerivedException_async(self, cb, a, b, o, current=None):
+ cb.ice_exception(Test.DerivedException(False, a, b, o, b, o))
+
+ def opRequiredException_async(self, cb, a, b, o, current=None):
+ e = Test.RequiredException()
+ e.a = a
+ e.b = b
+ e.o = o
+ if b is not Ice.Unset:
+ e.ss = b
+ if o is not Ice.Unset:
+ e.o2 = o
+ cb.ice_exception(e)
+
+ def opByte_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opBool_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opShort_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opInt_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opLong_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opFloat_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opDouble_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opString_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opMyEnum_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opSmallStruct_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opFixedStruct_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opVarStruct_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opOneOptional_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opOneOptionalProxy_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opByteSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opBoolSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opShortSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opIntSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opLongSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opFloatSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opDoubleSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opStringSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opSmallStructSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opSmallStructList_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opFixedStructSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opFixedStructList_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opVarStructSeq_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opSerializable(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opIntIntDict_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opStringIntDict_async(self, cb, p1, current=None):
+ cb.ice_response(p1, p1)
+
+ def opClassAndUnknownOptional_async(self, cb, p, current=None):
+ cb.ice_response()
+
+ def sendOptionalClass_async(self, cb, req, o, current=None):
+ cb.ice_response()
+
+ def returnOptionalClass_async(self, cb, req, current=None):
+ cb.ice_response(Test.OneOptional(5))
+
+ def supportsRequiredParams_async(self, cb, current=None):
+ cb.ice_response(False)
+
+ def supportsJavaSerializable(self, cb, current=None):
+ cb.ice_response(True)
+
+ def supportsCsharpSerializable(self, cb, current=None):
+ cb.ice_response(True)
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ initial = InitialI()
+ adapter.add(initial, communicator.stringToIdentity("initial"))
+ adapter.activate()
+
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/optional/Test.ice b/python/test/Ice/optional/Test.ice
new file mode 100644
index 00000000000..2a3d25720b6
--- /dev/null
+++ b/python/test/Ice/optional/Test.ice
@@ -0,0 +1,269 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+class OneOptional
+{
+ optional(1) int a;
+};
+
+enum MyEnum
+{
+ MyEnumMember
+};
+
+struct SmallStruct
+{
+ byte m;
+};
+
+struct FixedStruct
+{
+ int m;
+};
+
+struct VarStruct
+{
+ string m;
+};
+
+struct ClassVarStruct
+{
+ int a;
+};
+
+sequence<byte> ByteSeq;
+sequence<bool> BoolSeq;
+sequence<short> ShortSeq;
+sequence<int> IntSeq;
+sequence<long> LongSeq;
+sequence<float> FloatSeq;
+sequence<double> DoubleSeq;
+sequence<string> StringSeq;
+sequence<MyEnum> MyEnumSeq;
+sequence<SmallStruct> SmallStructSeq;
+["python:seq:tuple"] sequence<SmallStruct> SmallStructList;
+sequence<FixedStruct> FixedStructSeq;
+["python:seq:tuple"] sequence<FixedStruct> FixedStructList;
+sequence<VarStruct> VarStructSeq;
+sequence<OneOptional> OneOptionalSeq;
+sequence<OneOptional*> OneOptionalPrxSeq;
+
+sequence<byte> Serializable;
+
+dictionary<int, int> IntIntDict;
+dictionary<string, int> StringIntDict;
+dictionary<int, MyEnum> IntEnumDict;
+dictionary<int, FixedStruct> IntFixedStructDict;
+dictionary<int, VarStruct> IntVarStructDict;
+dictionary<int, OneOptional> IntOneOptionalDict;
+dictionary<int, OneOptional*> IntOneOptionalPrxDict;
+
+class MultiOptional
+{
+ optional(1) byte a;
+ optional(2) bool b;
+ optional(3) short c;
+ optional(4) int d;
+ optional(5) long e;
+ optional(6) float f;
+ optional(7) double g;
+ optional(8) string h;
+ optional(9) MyEnum i;
+ optional(10) MultiOptional* j;
+ optional(11) MultiOptional k;
+ optional(12) ByteSeq bs;
+ optional(13) StringSeq ss;
+ optional(14) IntIntDict iid;
+ optional(15) StringIntDict sid;
+ optional(16) FixedStruct fs;
+ optional(17) VarStruct vs;
+
+ optional(18) ShortSeq shs;
+ optional(19) MyEnumSeq es;
+ optional(20) FixedStructSeq fss;
+ optional(21) VarStructSeq vss;
+ optional(22) OneOptionalSeq oos;
+ optional(23) OneOptionalPrxSeq oops;
+
+ optional(24) IntEnumDict ied;
+ optional(25) IntFixedStructDict ifsd;
+ optional(26) IntVarStructDict ivsd;
+ optional(27) IntOneOptionalDict iood;
+ optional(28) IntOneOptionalPrxDict ioopd;
+
+ optional(29) BoolSeq bos;
+
+ optional(30) Serializable ser;
+};
+
+class A
+{
+ int requiredA;
+ optional(1) int ma;
+ optional(50) int mb;
+ optional(500) int mc;
+};
+
+["preserve-slice"]
+class B extends A
+{
+ int requiredB;
+ optional(10) int md;
+};
+
+class C extends B
+{
+ string ss;
+ optional(890) string ms;
+};
+
+class WD
+{
+ optional(1) int a = 5;
+ optional(2) string s = "test";
+};
+
+exception OptionalException
+{
+ bool req = false;
+ optional(1) int a = 5;
+ optional(2) string b;
+ optional(50) OneOptional o;
+};
+
+exception DerivedException extends OptionalException
+{
+ optional(600) string ss = "test";
+ optional(601) OneOptional o2;
+};
+
+exception RequiredException extends OptionalException
+{
+ string ss = "test";
+ OneOptional o2;
+};
+
+class OptionalWithCustom
+{
+ optional(1) SmallStructList l;
+ ["protected"] optional(2) SmallStructList lp;
+ optional(3) ClassVarStruct s;
+};
+
+class E
+{
+ A ae;
+};
+
+class F extends E
+{
+ optional(1) A af;
+};
+
+class Recursive;
+sequence<Recursive> RecursiveSeq;
+
+class Recursive {
+ optional(0) RecursiveSeq value;
+};
+
+class Initial
+{
+ void shutdown();
+
+ Object pingPong(Object o);
+
+ void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
+ throws OptionalException;
+
+ void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
+ throws OptionalException;
+
+ void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
+ throws OptionalException;
+
+ optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3);
+
+ optional(1) bool opBool(optional(2) bool p1, out optional(3) bool p3);
+
+ optional(1) short opShort(optional(2) short p1, out optional(3) short p3);
+
+ optional(1) int opInt(optional(2) int p1, out optional(3) int p3);
+
+ optional(3) long opLong(optional(1) long p1, out optional(2) long p3);
+
+ optional(1) float opFloat(optional(2) float p1, out optional(3) float p3);
+
+ optional(1) double opDouble(optional(2) double p1, out optional(3) double p3);
+
+ optional(1) string opString(optional(2) string p1, out optional(3) string p3);
+
+ optional(1) MyEnum opMyEnum(optional(2) MyEnum p1, out optional(3) MyEnum p3);
+
+ optional(1) SmallStruct opSmallStruct(optional(2) SmallStruct p1, out optional(3) SmallStruct p3);
+
+ optional(1) FixedStruct opFixedStruct(optional(2) FixedStruct p1, out optional(3) FixedStruct p3);
+
+ optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3);
+
+ optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3);
+
+ optional(1) OneOptional* opOneOptionalProxy(optional(2) OneOptional* p1, out optional(3) OneOptional* p3);
+
+ optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3);
+
+ optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3);
+
+ optional(1) ShortSeq opShortSeq(optional(2) ShortSeq p1, out optional(3) ShortSeq p3);
+
+ optional(1) IntSeq opIntSeq(optional(2) IntSeq p1, out optional(3) IntSeq p3);
+
+ optional(1) LongSeq opLongSeq(optional(2) LongSeq p1, out optional(3) LongSeq p3);
+
+ optional(1) FloatSeq opFloatSeq(optional(2) FloatSeq p1, out optional(3) FloatSeq p3);
+
+ optional(1) DoubleSeq opDoubleSeq(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3);
+
+ optional(1) StringSeq opStringSeq(optional(2) StringSeq p1, out optional(3) StringSeq p3);
+
+ optional(1) SmallStructSeq opSmallStructSeq(optional(2) SmallStructSeq p1, out optional(3) SmallStructSeq p3);
+
+ optional(1) SmallStructList opSmallStructList(optional(2) SmallStructList p1, out optional(3) SmallStructList p3);
+
+ optional(1) FixedStructSeq opFixedStructSeq(optional(2) FixedStructSeq p1, out optional(3) FixedStructSeq p3);
+
+ optional(1) FixedStructList opFixedStructList(optional(2) FixedStructList p1, out optional(3) FixedStructList p3);
+
+ optional(1) VarStructSeq opVarStructSeq(optional(2) VarStructSeq p1, out optional(3) VarStructSeq p3);
+
+ optional(1) Serializable opSerializable(optional(2) Serializable p1, out optional(3) Serializable p3);
+
+ optional(1) IntIntDict opIntIntDict(optional(2) IntIntDict p1, out optional(3) IntIntDict p3);
+
+ optional(1) StringIntDict opStringIntDict(optional(2) StringIntDict p1, out optional(3) StringIntDict p3);
+
+ void opClassAndUnknownOptional(A p);
+
+ void sendOptionalClass(bool req, optional(1) OneOptional o);
+
+ void returnOptionalClass(bool req, out optional(1) OneOptional o);
+
+ bool supportsRequiredParams();
+
+ bool supportsJavaSerializable();
+
+ bool supportsCsharpSerializable();
+};
+
+};
diff --git a/python/test/Ice/optional/TestAMD.ice b/python/test/Ice/optional/TestAMD.ice
new file mode 100644
index 00000000000..cf6c62ee7f1
--- /dev/null
+++ b/python/test/Ice/optional/TestAMD.ice
@@ -0,0 +1,270 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+class OneOptional
+{
+ optional(1) int a;
+};
+
+enum MyEnum
+{
+ MyEnumMember
+};
+
+struct SmallStruct
+{
+ byte m;
+};
+
+struct FixedStruct
+{
+ int m;
+};
+
+struct VarStruct
+{
+ string m;
+};
+
+struct ClassVarStruct
+{
+ int a;
+};
+
+sequence<byte> ByteSeq;
+sequence<bool> BoolSeq;
+sequence<short> ShortSeq;
+sequence<int> IntSeq;
+sequence<long> LongSeq;
+sequence<float> FloatSeq;
+sequence<double> DoubleSeq;
+sequence<string> StringSeq;
+sequence<MyEnum> MyEnumSeq;
+sequence<SmallStruct> SmallStructSeq;
+["python:seq:tuple"] sequence<SmallStruct> SmallStructList;
+sequence<FixedStruct> FixedStructSeq;
+["python:seq:tuple"] sequence<FixedStruct> FixedStructList;
+sequence<VarStruct> VarStructSeq;
+sequence<OneOptional> OneOptionalSeq;
+sequence<OneOptional*> OneOptionalPrxSeq;
+
+sequence<byte> Serializable;
+
+dictionary<int, int> IntIntDict;
+dictionary<string, int> StringIntDict;
+dictionary<int, MyEnum> IntEnumDict;
+dictionary<int, FixedStruct> IntFixedStructDict;
+dictionary<int, VarStruct> IntVarStructDict;
+dictionary<int, OneOptional> IntOneOptionalDict;
+dictionary<int, OneOptional*> IntOneOptionalPrxDict;
+
+class MultiOptional
+{
+ optional(1) byte a;
+ optional(2) bool b;
+ optional(3) short c;
+ optional(4) int d;
+ optional(5) long e;
+ optional(6) float f;
+ optional(7) double g;
+ optional(8) string h;
+ optional(9) MyEnum i;
+ optional(10) MultiOptional* j;
+ optional(11) MultiOptional k;
+ optional(12) ByteSeq bs;
+ optional(13) StringSeq ss;
+ optional(14) IntIntDict iid;
+ optional(15) StringIntDict sid;
+ optional(16) FixedStruct fs;
+ optional(17) VarStruct vs;
+
+ optional(18) ShortSeq shs;
+ optional(19) MyEnumSeq es;
+ optional(20) FixedStructSeq fss;
+ optional(21) VarStructSeq vss;
+ optional(22) OneOptionalSeq oos;
+ optional(23) OneOptionalPrxSeq oops;
+
+ optional(24) IntEnumDict ied;
+ optional(25) IntFixedStructDict ifsd;
+ optional(26) IntVarStructDict ivsd;
+ optional(27) IntOneOptionalDict iood;
+ optional(28) IntOneOptionalPrxDict ioopd;
+
+ optional(29) BoolSeq bos;
+
+ optional(30) Serializable ser;
+};
+
+class A
+{
+ int requiredA;
+ optional(1) int ma;
+ optional(50) int mb;
+ optional(500) int mc;
+};
+
+["preserve-slice"]
+class B extends A
+{
+ int requiredB;
+ optional(10) int md;
+};
+
+class C extends B
+{
+ string ss;
+ optional(890) string ms;
+};
+
+class WD
+{
+ optional(1) int a = 5;
+ optional(2) string s = "test";
+};
+
+exception OptionalException
+{
+ bool req = false;
+ optional(1) int a = 5;
+ optional(2) string b;
+ optional(50) OneOptional o;
+};
+
+exception DerivedException extends OptionalException
+{
+ optional(600) string ss = "test";
+ optional(601) OneOptional o2;
+};
+
+exception RequiredException extends OptionalException
+{
+ string ss = "test";
+ OneOptional o2;
+};
+
+class OptionalWithCustom
+{
+ optional(1) SmallStructList l;
+ ["protected"] optional(2) SmallStructList lp;
+ optional(3) ClassVarStruct s;
+};
+
+class E
+{
+ A ae;
+};
+
+class F extends E
+{
+ optional(1) A af;
+};
+
+class Recursive;
+sequence<Recursive> RecursiveSeq;
+
+class Recursive {
+ optional(0) RecursiveSeq value;
+};
+
+["amd"]
+class Initial
+{
+ void shutdown();
+
+ Object pingPong(Object o);
+
+ void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
+ throws OptionalException;
+
+ void opDerivedException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
+ throws OptionalException;
+
+ void opRequiredException(optional(1) int a, optional(2) string b, optional(3) OneOptional o)
+ throws OptionalException;
+
+ optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3);
+
+ optional(1) bool opBool(optional(2) bool p1, out optional(3) bool p3);
+
+ optional(1) short opShort(optional(2) short p1, out optional(3) short p3);
+
+ optional(1) int opInt(optional(2) int p1, out optional(3) int p3);
+
+ optional(3) long opLong(optional(1) long p1, out optional(2) long p3);
+
+ optional(1) float opFloat(optional(2) float p1, out optional(3) float p3);
+
+ optional(1) double opDouble(optional(2) double p1, out optional(3) double p3);
+
+ optional(1) string opString(optional(2) string p1, out optional(3) string p3);
+
+ optional(1) MyEnum opMyEnum(optional(2) MyEnum p1, out optional(3) MyEnum p3);
+
+ optional(1) SmallStruct opSmallStruct(optional(2) SmallStruct p1, out optional(3) SmallStruct p3);
+
+ optional(1) FixedStruct opFixedStruct(optional(2) FixedStruct p1, out optional(3) FixedStruct p3);
+
+ optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3);
+
+ optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3);
+
+ optional(1) OneOptional* opOneOptionalProxy(optional(2) OneOptional* p1, out optional(3) OneOptional* p3);
+
+ optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3);
+
+ optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3);
+
+ optional(1) ShortSeq opShortSeq(optional(2) ShortSeq p1, out optional(3) ShortSeq p3);
+
+ optional(1) IntSeq opIntSeq(optional(2) IntSeq p1, out optional(3) IntSeq p3);
+
+ optional(1) LongSeq opLongSeq(optional(2) LongSeq p1, out optional(3) LongSeq p3);
+
+ optional(1) FloatSeq opFloatSeq(optional(2) FloatSeq p1, out optional(3) FloatSeq p3);
+
+ optional(1) DoubleSeq opDoubleSeq(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3);
+
+ optional(1) StringSeq opStringSeq(optional(2) StringSeq p1, out optional(3) StringSeq p3);
+
+ optional(1) SmallStructSeq opSmallStructSeq(optional(2) SmallStructSeq p1, out optional(3) SmallStructSeq p3);
+
+ optional(1) SmallStructList opSmallStructList(optional(2) SmallStructList p1, out optional(3) SmallStructList p3);
+
+ optional(1) FixedStructSeq opFixedStructSeq(optional(2) FixedStructSeq p1, out optional(3) FixedStructSeq p3);
+
+ optional(1) FixedStructList opFixedStructList(optional(2) FixedStructList p1, out optional(3) FixedStructList p3);
+
+ optional(1) VarStructSeq opVarStructSeq(optional(2) VarStructSeq p1, out optional(3) VarStructSeq p3);
+
+ optional(1) Serializable opSerializable(optional(2) Serializable p1, out optional(3) Serializable p3);
+
+ optional(1) IntIntDict opIntIntDict(optional(2) IntIntDict p1, out optional(3) IntIntDict p3);
+
+ optional(1) StringIntDict opStringIntDict(optional(2) StringIntDict p1, out optional(3) StringIntDict p3);
+
+ void opClassAndUnknownOptional(A p);
+
+ void sendOptionalClass(bool req, optional(1) OneOptional o);
+
+ void returnOptionalClass(bool req, out optional(1) OneOptional o);
+
+ bool supportsRequiredParams();
+
+ bool supportsJavaSerializable();
+
+ bool supportsCsharpSerializable();
+};
+
+};
diff --git a/python/test/Ice/optional/run.py b/python/test/Ice/optional/run.py
new file mode 100755
index 00000000000..1a3f97ec2e2
--- /dev/null
+++ b/python/test/Ice/optional/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("Running test with compact (default) format.")
+TestUtil.clientServerTest()
+print("Running test with sliced format.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.SlicedFormat", additionalServerOptions="--Ice.Default.SlicedFormat")
+print("Running test with AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py")
diff --git a/python/test/Ice/properties/Client.py b/python/test/Ice/properties/Client.py
new file mode 100644
index 00000000000..e771da6903e
--- /dev/null
+++ b/python/test/Ice/properties/Client.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class Client(Ice.Application):
+ def run(self, args):
+ properties = self.communicator().getProperties()
+ test(properties.getProperty("Ice.Trace.Network") == "1")
+ test(properties.getProperty("Ice.Trace.Protocol") == "1")
+ test(properties.getProperty("Config.Path") == "./config/中国_client.config")
+ test(properties.getProperty("Ice.ProgramName") == "PropertiesClient")
+ test(self.appName() == properties.getProperty("Ice.ProgramName"))
+
+
+sys.stdout.write("testing load properties from UTF-8 path... ")
+sys.stdout.flush()
+properties = Ice.createProperties()
+properties.load("./config/中国_client.config")
+test(properties.getProperty("Ice.Trace.Network") == "1")
+test(properties.getProperty("Ice.Trace.Protocol") == "1")
+test(properties.getProperty("Config.Path") == "./config/中国_client.config")
+test(properties.getProperty("Ice.ProgramName") == "PropertiesClient")
+print("ok")
+sys.stdout.write("testing load properties from UTF-8 path using Ice::Application... ")
+sys.stdout.flush()
+c = Client()
+c.main(sys.argv, "./config/中国_client.config")
+print("ok")
+
+sys.stdout.write("testing using Ice.Config with multiple config files... ")
+sys.stdout.flush()
+properties = Ice.createProperties(["--Ice.Config=config/config.1, config/config.2, config/config.3"])
+test(properties.getProperty("Config1") == "Config1")
+test(properties.getProperty("Config2") == "Config2")
+test(properties.getProperty("Config3") == "Config3")
+print("ok")
+
+sys.stdout.write("testing configuration file escapes... ")
+sys.stdout.flush()
+properties = Ice.createProperties(["--Ice.Config=config/escapes.cfg"])
+
+props = { "Foo\tBar":"3",
+ "Foo\\tBar":"4",
+ "Escape\\ Space":"2",
+ "Prop1":"1",
+ "Prop2":"2",
+ "Prop3":"3",
+ "My Prop1":"1",
+ "My Prop2":"2",
+ "My.Prop1":"a property",
+ "My.Prop2":"a property",
+ "My.Prop3":" a property ",
+ "My.Prop4":" a property ",
+ "My.Prop5":"a \\ property",
+ "foo=bar":"1",
+ "foo#bar":"2",
+ "foo bar":"3",
+ "A":"1",
+ "B":"2 3 4",
+ "C":"5=#6",
+ "AServer":"\\\\server\\dir",
+ "BServer":"\\server\\dir"};
+
+for k in props.keys():
+ test(properties.getProperty(k) == props[k])
+
+print("ok")
+
+sys.exit(0)
diff --git a/python/test/Ice/properties/config/.gitignore b/python/test/Ice/properties/config/.gitignore
new file mode 100644
index 00000000000..143c64680f3
--- /dev/null
+++ b/python/test/Ice/properties/config/.gitignore
@@ -0,0 +1 @@
+*.config
diff --git a/python/test/Ice/properties/config/config.1 b/python/test/Ice/properties/config/config.1
new file mode 100644
index 00000000000..2a20653e4c5
--- /dev/null
+++ b/python/test/Ice/properties/config/config.1
@@ -0,0 +1 @@
+Config1=Config1 \ No newline at end of file
diff --git a/python/test/Ice/properties/config/config.2 b/python/test/Ice/properties/config/config.2
new file mode 100644
index 00000000000..be276df6602
--- /dev/null
+++ b/python/test/Ice/properties/config/config.2
@@ -0,0 +1 @@
+Config2=Config2 \ No newline at end of file
diff --git a/python/test/Ice/properties/config/config.3 b/python/test/Ice/properties/config/config.3
new file mode 100644
index 00000000000..55c1e1123f6
--- /dev/null
+++ b/python/test/Ice/properties/config/config.3
@@ -0,0 +1 @@
+Config3=Config3 \ No newline at end of file
diff --git a/python/test/Ice/properties/config/escapes.cfg b/python/test/Ice/properties/config/escapes.cfg
new file mode 100644
index 00000000000..f438d2b59c8
--- /dev/null
+++ b/python/test/Ice/properties/config/escapes.cfg
@@ -0,0 +1,35 @@
+Foo Bar=3 #tab
+Foo\tBar=4 # embedded\t
+Escape\\ Space=2
+
+#
+# From Ice manual:
+#
+
+Prop1 = 1 # Key is "Prop1"
+ Prop2 = 2 # Key is "Prop2"
+\ Prop3 \ = 3 # Key is "Prop3"
+My Prop1 = 1 # Key is "My Prop1"
+My\ Prop2 = 2 # Key is "My Prop2"
+
+My.Prop1 = a property # Value is "a property"
+My.Prop2 = a property # Value is "a property"
+My.Prop3 = \ \ a property\ \ # Value is " a property "
+My.Prop4 = \ \ a \ \ property\ \ # Value is " a property "
+My.Prop5 = a \\ property # Value is "a \ property"
+
+foo\=bar=1 # Name is "foo=bar", value is "1"
+foo\#bar = 2 # Name is "foo#bar", value is "2"
+foo bar =3 # Name is "foo bar", value is "3"
+
+
+A=1 # Name is "A", value is "1"
+B= 2 3 4 # Name is "B", value is "2 3 4"
+C=5=\#6 # 7 # Name is "C", value is "5=#6"
+
+AServer=\\\\server\dir # Value is "\\server\dir"
+BServer=\\server\\dir # Value is "\server\dir"
+
+
+
+
diff --git a/python/test/Ice/properties/run.py b/python/test/Ice/properties/run.py
new file mode 100755
index 00000000000..c6ce2b8cfad
--- /dev/null
+++ b/python/test/Ice/properties/run.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+#
+# Write config
+#
+if sys.version_info[0] == 2:
+ configPath = "./config/\xe4\xb8\xad\xe5\x9b\xbd_client.config"
+else:
+ configPath = "./config/\u4e2d\u56fd_client.config"
+
+TestUtil.createConfig(configPath,
+ ["# Automatically generated by Ice test driver.",
+ "Ice.Trace.Protocol=1",
+ "Ice.Trace.Network=1",
+ "Ice.ProgramName=PropertiesClient",
+ "Config.Path=" + configPath],
+ "utf-8")
+
+TestUtil.simpleTest()
+
+if os.path.exists(configPath):
+ os.remove(configPath)
diff --git a/python/test/Ice/proxy/AllTests.py b/python/test/Ice/proxy/AllTests.py
new file mode 100644
index 00000000000..fb606824b30
--- /dev/null
+++ b/python/test/Ice/proxy/AllTests.py
@@ -0,0 +1,785 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, threading
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator, collocated):
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+
+ #
+ # Test nil proxies.
+ #
+ p = communicator.stringToProxy('')
+ test(p == None)
+ p = communicator.propertyToProxy('bogus')
+ test(p == None)
+
+ ref = "test:default -p 12010"
+ base = communicator.stringToProxy(ref)
+ test(base)
+
+ b1 = communicator.stringToProxy("test")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getAdapterId()) == 0 and len(b1.ice_getFacet()) == 0)
+ b1 = communicator.stringToProxy("test ")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getFacet()) == 0)
+ b1 = communicator.stringToProxy(" test ")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getFacet()) == 0)
+ b1 = communicator.stringToProxy(" test")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getFacet()) == 0)
+ b1 = communicator.stringToProxy("'test -f facet'")
+ test(b1.ice_getIdentity().name == "test -f facet" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getFacet()) == 0)
+ try:
+ b1 = communicator.stringToProxy("\"test -f facet'")
+ test(False)
+ except Ice.ProxyParseException:
+ pass
+ b1 = communicator.stringToProxy("\"test -f facet\"")
+ test(b1.ice_getIdentity().name == "test -f facet" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getFacet()) == 0)
+ b1 = communicator.stringToProxy("\"test -f facet@test\"")
+ test(b1.ice_getIdentity().name == "test -f facet@test" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getFacet()) == 0)
+ b1 = communicator.stringToProxy("\"test -f facet@test @test\"")
+ test(b1.ice_getIdentity().name == "test -f facet@test @test" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getFacet()) == 0)
+ try:
+ b1 = communicator.stringToProxy("test test")
+ test(False)
+ except Ice.ProxyParseException:
+ pass
+ b1 = communicator.stringToProxy("test\\040test")
+ test(b1.ice_getIdentity().name == "test test" and len(b1.ice_getIdentity().category) == 0)
+ try:
+ b1 = communicator.stringToProxy("test\\777")
+ test(False)
+ except Ice.IdentityParseException:
+ pass
+ b1 = communicator.stringToProxy("test\\40test")
+ test(b1.ice_getIdentity().name == "test test")
+
+ # Test some octal and hex corner cases.
+ b1 = communicator.stringToProxy("test\\4test")
+ test(b1.ice_getIdentity().name == "test\4test")
+ b1 = communicator.stringToProxy("test\\04test")
+ test(b1.ice_getIdentity().name == "test\4test")
+ b1 = communicator.stringToProxy("test\\004test")
+ test(b1.ice_getIdentity().name == "test\4test")
+ b1 = communicator.stringToProxy("test\\1114test")
+ test(b1.ice_getIdentity().name == "test\1114test")
+
+ b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test")
+ test(b1.ice_getIdentity().name == "test\b\f\n\r\t\'\"\\test" and len(b1.ice_getIdentity().category) == 0)
+
+ b1 = communicator.stringToProxy("category/test")
+ test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \
+ len(b1.ice_getAdapterId()) == 0)
+
+ b1 = communicator.stringToProxy("test@adapter")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getAdapterId() == "adapter")
+ try:
+ b1 = communicator.stringToProxy("id@adapter test")
+ test(False)
+ except Ice.ProxyParseException:
+ pass
+ b1 = communicator.stringToProxy("category/test@adapter")
+ test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \
+ b1.ice_getAdapterId() == "adapter")
+ b1 = communicator.stringToProxy("category/test@adapter:tcp")
+ test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \
+ b1.ice_getAdapterId() == "adapter:tcp")
+ b1 = communicator.stringToProxy("'category 1/test'@adapter")
+ test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category 1" and \
+ b1.ice_getAdapterId() == "adapter")
+ b1 = communicator.stringToProxy("'category/test 1'@adapter")
+ test(b1.ice_getIdentity().name == "test 1" and b1.ice_getIdentity().category == "category" and \
+ b1.ice_getAdapterId() == "adapter")
+ b1 = communicator.stringToProxy("'category/test'@'adapter 1'")
+ test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category" and \
+ b1.ice_getAdapterId() == "adapter 1")
+ b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@adapter")
+ test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category /test@foo" and \
+ b1.ice_getAdapterId() == "adapter")
+ b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\"")
+ test(b1.ice_getIdentity().name == "test" and b1.ice_getIdentity().category == "category /test@foo" and \
+ b1.ice_getAdapterId() == "adapter:tcp")
+
+ b1 = communicator.stringToProxy("id -f facet")
+ test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getFacet() == "facet")
+ b1 = communicator.stringToProxy("id -f 'facet x'")
+ test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getFacet() == "facet x")
+ b1 = communicator.stringToProxy("id -f \"facet x\"")
+ test(b1.ice_getIdentity().name == "id" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getFacet() == "facet x")
+ try:
+ b1 = communicator.stringToProxy("id -f \"facet x")
+ test(False)
+ except Ice.ProxyParseException:
+ pass
+ try:
+ b1 = communicator.stringToProxy("id -f \'facet x")
+ test(False)
+ except Ice.ProxyParseException:
+ pass
+ b1 = communicator.stringToProxy("test -f facet:tcp")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getFacet() == "facet" and len(b1.ice_getAdapterId()) == 0)
+ b1 = communicator.stringToProxy("test -f \"facet:tcp\"")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getFacet() == "facet:tcp" and len(b1.ice_getAdapterId()) == 0)
+ b1 = communicator.stringToProxy("test -f facet@test")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getFacet() == "facet" and b1.ice_getAdapterId() == "test")
+ b1 = communicator.stringToProxy("test -f 'facet@test'")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getFacet() == "facet@test" and len(b1.ice_getAdapterId()) == 0)
+ b1 = communicator.stringToProxy("test -f 'facet@test'@test")
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ b1.ice_getFacet() == "facet@test" and b1.ice_getAdapterId() == "test")
+ try:
+ b1 = communicator.stringToProxy("test -f facet@test @test")
+ test(False)
+ except Ice.ProxyParseException:
+ pass
+ b1 = communicator.stringToProxy("test")
+ test(b1.ice_isTwoway())
+ b1 = communicator.stringToProxy("test -t")
+ test(b1.ice_isTwoway())
+ b1 = communicator.stringToProxy("test -o")
+ test(b1.ice_isOneway())
+ b1 = communicator.stringToProxy("test -O")
+ test(b1.ice_isBatchOneway())
+ b1 = communicator.stringToProxy("test -d")
+ test(b1.ice_isDatagram())
+ b1 = communicator.stringToProxy("test -D")
+ test(b1.ice_isBatchDatagram())
+ b1 = communicator.stringToProxy("test")
+ test(not b1.ice_isSecure())
+ b1 = communicator.stringToProxy("test -s")
+ test(b1.ice_isSecure())
+
+ try:
+ b1 = communicator.stringToProxy("test:tcp@adapterId")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+ # This is an unknown endpoint warning, not a parse exception.
+ #
+ #try:
+ # b1 = communicator.stringToProxy("test -f the:facet:tcp")
+ # test(False)
+ #except Ice.EndpointParseException:
+ # pass
+ try:
+ b1 = communicator.stringToProxy("test::tcp")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+ print("ok")
+
+ sys.stdout.write("testing propertyToProxy... ")
+ sys.stdout.flush()
+ prop = communicator.getProperties()
+ propertyPrefix = "Foo.Proxy"
+ prop.setProperty(propertyPrefix, "test:default -p 12010")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_getIdentity().name == "test" and len(b1.ice_getIdentity().category) == 0 and \
+ len(b1.ice_getAdapterId()) == 0 and len(b1.ice_getFacet()) == 0)
+
+ property = propertyPrefix + ".Locator"
+ test(not b1.ice_getLocator())
+ prop.setProperty(property, "locator:default -p 10000")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_getLocator() and b1.ice_getLocator().ice_getIdentity().name == "locator")
+ prop.setProperty(property, "")
+
+ property = propertyPrefix + ".LocatorCacheTimeout"
+ test(b1.ice_getLocatorCacheTimeout() == -1)
+ prop.setProperty(property, "1")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_getLocatorCacheTimeout() == 1)
+ prop.setProperty(property, "")
+
+ # Now retest with an indirect proxy.
+ prop.setProperty(propertyPrefix, "test")
+ property = propertyPrefix + ".Locator"
+ prop.setProperty(property, "locator:default -p 10000")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_getLocator() and b1.ice_getLocator().ice_getIdentity().name == "locator")
+ prop.setProperty(property, "")
+
+ property = propertyPrefix + ".LocatorCacheTimeout"
+ test(b1.ice_getLocatorCacheTimeout() == -1)
+ prop.setProperty(property, "1")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_getLocatorCacheTimeout() == 1)
+ prop.setProperty(property, "")
+
+ # This cannot be tested so easily because the property is cached
+ # on communicator initialization.
+ #
+ #prop.setProperty("Ice.Default.LocatorCacheTimeout", "60")
+ #b1 = communicator.propertyToProxy(propertyPrefix)
+ #test(b1.ice_getLocatorCacheTimeout() == 60)
+ #prop.setProperty("Ice.Default.LocatorCacheTimeout", "")
+
+ prop.setProperty(propertyPrefix, "test:default -p 12010")
+
+ property = propertyPrefix + ".Router"
+ test(not b1.ice_getRouter())
+ prop.setProperty(property, "router:default -p 10000")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_getRouter() and b1.ice_getRouter().ice_getIdentity().name == "router")
+ prop.setProperty(property, "")
+
+ property = propertyPrefix + ".PreferSecure"
+ test(not b1.ice_isPreferSecure())
+ prop.setProperty(property, "1")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_isPreferSecure())
+ prop.setProperty(property, "")
+
+ property = propertyPrefix + ".ConnectionCached"
+ test(b1.ice_isConnectionCached())
+ prop.setProperty(property, "0")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(not b1.ice_isConnectionCached())
+ prop.setProperty(property, "")
+
+ property = propertyPrefix + ".InvocationTimeout";
+ test(b1.ice_getInvocationTimeout() == -1);
+ prop.setProperty(property, "1000");
+ b1 = communicator.propertyToProxy(propertyPrefix);
+ test(b1.ice_getInvocationTimeout() == 1000);
+ prop.setProperty(property, "");
+
+ property = propertyPrefix + ".EndpointSelection"
+ test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random)
+ prop.setProperty(property, "Random")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random)
+ prop.setProperty(property, "Ordered")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered)
+ prop.setProperty(property, "")
+ property = propertyPrefix + ".CollocationOptimized"
+ test(b1.ice_isCollocationOptimized())
+ prop.setProperty(property, "0")
+ b1 = communicator.propertyToProxy(propertyPrefix)
+ test(not b1.ice_isCollocationOptimized())
+ prop.setProperty(property, "")
+
+ print("ok")
+
+ sys.stdout.write("testing proxyToProperty... ")
+ sys.stdout.flush()
+
+ b1 = communicator.stringToProxy("test")
+ b1 = b1.ice_collocationOptimized(True)
+ b1 = b1.ice_connectionCached(True)
+ b1 = b1.ice_preferSecure(False)
+ b1 = b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)
+ b1 = b1.ice_locatorCacheTimeout(100)
+ b1 = b1.ice_invocationTimeout(1234);
+ b1 = b1.ice_encodingVersion(Ice.EncodingVersion(1, 0))
+
+ router = communicator.stringToProxy("router")
+ router = router.ice_collocationOptimized(False)
+ router = router.ice_connectionCached(True)
+ router = router.ice_preferSecure(True)
+ router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random)
+ router = router.ice_locatorCacheTimeout(200)
+ router = router.ice_invocationTimeout(1500);
+
+ locator = communicator.stringToProxy("locator")
+ locator = locator.ice_collocationOptimized(True)
+ locator = locator.ice_connectionCached(False)
+ locator = locator.ice_preferSecure(True)
+ locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random)
+ locator = locator.ice_locatorCacheTimeout(300)
+ locator = locator.ice_invocationTimeout(1500);
+
+ locator = locator.ice_router(Ice.RouterPrx.uncheckedCast(router))
+ b1 = b1.ice_locator(Ice.LocatorPrx.uncheckedCast(locator))
+
+ proxyProps = communicator.proxyToProperty(b1, "Test")
+ test(len(proxyProps) == 21)
+
+ test(proxyProps["Test"] == "test -t -e 1.0")
+ test(proxyProps["Test.CollocationOptimized"] == "1")
+ test(proxyProps["Test.ConnectionCached"] == "1")
+ test(proxyProps["Test.PreferSecure"] == "0")
+ test(proxyProps["Test.EndpointSelection"] == "Ordered")
+ test(proxyProps["Test.LocatorCacheTimeout"] == "100")
+ test(proxyProps["Test.InvocationTimeout"] == "1234");
+
+ test(proxyProps["Test.Locator"] == "locator -t -e " + Ice.encodingVersionToString(Ice.currentEncoding()))
+ test(proxyProps["Test.Locator.CollocationOptimized"] == "1")
+ test(proxyProps["Test.Locator.ConnectionCached"] == "0")
+ test(proxyProps["Test.Locator.PreferSecure"] == "1")
+ test(proxyProps["Test.Locator.EndpointSelection"] == "Random")
+ test(proxyProps["Test.Locator.LocatorCacheTimeout"] == "300")
+ test(proxyProps["Test.Locator.InvocationTimeout"] == "1500");
+
+ test(proxyProps["Test.Locator.Router"] == "router -t -e " + Ice.encodingVersionToString(Ice.currentEncoding()))
+ test(proxyProps["Test.Locator.Router.CollocationOptimized"] == "0")
+ test(proxyProps["Test.Locator.Router.ConnectionCached"] == "1")
+ test(proxyProps["Test.Locator.Router.PreferSecure"] == "1")
+ test(proxyProps["Test.Locator.Router.EndpointSelection"] == "Random")
+ test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"] == "200")
+ test(proxyProps["Test.Locator.Router.InvocationTimeout"] == "1500");
+
+ print("ok")
+
+ sys.stdout.write("testing ice_getCommunicator... ")
+ sys.stdout.flush()
+
+ test(base.ice_getCommunicator() == communicator)
+
+ print("ok")
+
+ sys.stdout.write("testing proxy methods... ")
+ sys.stdout.flush()
+ test(communicator.identityToString(base.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()) \
+ == "other")
+ test(base.ice_facet("facet").ice_getFacet() == "facet")
+ test(base.ice_adapterId("id").ice_getAdapterId() == "id")
+ test(base.ice_twoway().ice_isTwoway())
+ test(base.ice_oneway().ice_isOneway())
+ test(base.ice_batchOneway().ice_isBatchOneway())
+ test(base.ice_datagram().ice_isDatagram())
+ test(base.ice_batchDatagram().ice_isBatchDatagram())
+ test(base.ice_secure(True).ice_isSecure())
+ test(not base.ice_secure(False).ice_isSecure())
+ test(base.ice_collocationOptimized(True).ice_isCollocationOptimized())
+ test(not base.ice_collocationOptimized(False).ice_isCollocationOptimized())
+ test(base.ice_preferSecure(True).ice_isPreferSecure())
+ test(not base.ice_preferSecure(False).ice_isPreferSecure())
+ test(base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion() == Ice.Encoding_1_0)
+ test(base.ice_encodingVersion(Ice.Encoding_1_1).ice_getEncodingVersion() == Ice.Encoding_1_1)
+ test(base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion() != Ice.Encoding_1_1)
+
+ try:
+ base.ice_timeout(0)
+ test(False)
+ except RuntimeError:
+ pass
+
+ try:
+ base.ice_timeout(-1)
+ except RuntimeError:
+ test(False)
+
+ try:
+ base.ice_timeout(-2)
+ test(False)
+ except RuntimeError:
+ pass
+
+ try:
+ base.ice_invocationTimeout(0)
+ test(False)
+ except RuntimeError:
+ pass
+
+ try:
+ base.ice_invocationTimeout(-1)
+ except RuntimeError:
+ test(False)
+
+ try:
+ base.ice_invocationTimeout(-2)
+ test(False)
+ except RuntimeError:
+ pass
+
+ try:
+ base.ice_locatorCacheTimeout(0)
+ except RuntimeError:
+ test(False)
+
+ try:
+ base.ice_locatorCacheTimeout(-1)
+ except RuntimeError:
+ test(False)
+
+ try:
+ base.ice_locatorCacheTimeout(-2)
+ test(False)
+ except RuntimeError:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing proxy comparison... ")
+ sys.stdout.flush()
+
+ test(communicator.stringToProxy("foo") == communicator.stringToProxy("foo"))
+ test(communicator.stringToProxy("foo") != communicator.stringToProxy("foo2"))
+ test(communicator.stringToProxy("foo") < communicator.stringToProxy("foo2"))
+ test(not (communicator.stringToProxy("foo2") < communicator.stringToProxy("foo")))
+
+ compObj = communicator.stringToProxy("foo")
+
+ test(compObj.ice_facet("facet") == compObj.ice_facet("facet"))
+ test(compObj.ice_facet("facet") != compObj.ice_facet("facet1"))
+ test(compObj.ice_facet("facet") < compObj.ice_facet("facet1"))
+ test(not (compObj.ice_facet("facet") < compObj.ice_facet("facet")))
+
+ test(compObj.ice_oneway() == compObj.ice_oneway())
+ test(compObj.ice_oneway() != compObj.ice_twoway())
+ test(compObj.ice_twoway() < compObj.ice_oneway())
+ test(not (compObj.ice_oneway() < compObj.ice_twoway()))
+
+ test(compObj.ice_secure(True) == compObj.ice_secure(True))
+ test(compObj.ice_secure(False) != compObj.ice_secure(True))
+ test(compObj.ice_secure(False) < compObj.ice_secure(True))
+ test(not (compObj.ice_secure(True) < compObj.ice_secure(False)))
+
+ test(compObj.ice_collocationOptimized(True) == compObj.ice_collocationOptimized(True))
+ test(compObj.ice_collocationOptimized(False) != compObj.ice_collocationOptimized(True))
+ test(compObj.ice_collocationOptimized(False) < compObj.ice_collocationOptimized(True))
+ test(not (compObj.ice_collocationOptimized(True) < compObj.ice_collocationOptimized(False)))
+
+ test(compObj.ice_connectionCached(True) == compObj.ice_connectionCached(True))
+ test(compObj.ice_connectionCached(False) != compObj.ice_connectionCached(True))
+ test(compObj.ice_connectionCached(False) < compObj.ice_connectionCached(True))
+ test(not (compObj.ice_connectionCached(True) < compObj.ice_connectionCached(False)))
+
+ test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) == \
+ compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random))
+ test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) != \
+ compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))
+ test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random) < \
+ compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))
+ test(not (compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered) < \
+ compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random)))
+
+ test(compObj.ice_connectionId("id2") == compObj.ice_connectionId("id2"))
+ test(compObj.ice_connectionId("id1") != compObj.ice_connectionId("id2"))
+ test(compObj.ice_connectionId("id1") < compObj.ice_connectionId("id2"))
+ test(not (compObj.ice_connectionId("id2") < compObj.ice_connectionId("id1")))
+ test(compObj.ice_connectionId("id1").ice_getConnectionId() == "id1")
+ test(compObj.ice_connectionId("id2").ice_getConnectionId() == "id2")
+
+ test(compObj.ice_compress(True) == compObj.ice_compress(True))
+ test(compObj.ice_compress(False) != compObj.ice_compress(True))
+ test(compObj.ice_compress(False) < compObj.ice_compress(True))
+ test(not (compObj.ice_compress(True) < compObj.ice_compress(False)))
+
+ test(compObj.ice_timeout(20) == compObj.ice_timeout(20))
+ test(compObj.ice_timeout(10) != compObj.ice_timeout(20))
+ test(compObj.ice_timeout(10) < compObj.ice_timeout(20))
+ test(not (compObj.ice_timeout(20) < compObj.ice_timeout(10)))
+
+ loc1 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000"))
+ loc2 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc2:default -p 10000"))
+ test(compObj.ice_locator(None) == compObj.ice_locator(None))
+ test(compObj.ice_locator(loc1) == compObj.ice_locator(loc1))
+ test(compObj.ice_locator(loc1) != compObj.ice_locator(None))
+ test(compObj.ice_locator(None) != compObj.ice_locator(loc2))
+ test(compObj.ice_locator(loc1) != compObj.ice_locator(loc2))
+ test(compObj.ice_locator(None) < compObj.ice_locator(loc1))
+ test(not (compObj.ice_locator(loc1) < compObj.ice_locator(None)))
+ test(compObj.ice_locator(loc1) < compObj.ice_locator(loc2))
+ test(not (compObj.ice_locator(loc2) < compObj.ice_locator(loc1)))
+
+ rtr1 = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("rtr1:default -p 10000"))
+ rtr2 = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("rtr2:default -p 10000"))
+ test(compObj.ice_router(None) == compObj.ice_router(None))
+ test(compObj.ice_router(rtr1) == compObj.ice_router(rtr1))
+ test(compObj.ice_router(rtr1) != compObj.ice_router(None))
+ test(compObj.ice_router(None) != compObj.ice_router(rtr2))
+ test(compObj.ice_router(rtr1) != compObj.ice_router(rtr2))
+ test(compObj.ice_router(None) < compObj.ice_router(rtr1))
+ test(not (compObj.ice_router(rtr1) < compObj.ice_router(None)))
+ test(compObj.ice_router(rtr1) < compObj.ice_router(rtr2))
+ test(not (compObj.ice_router(rtr2) < compObj.ice_router(rtr1)))
+
+ ctx1 = { }
+ ctx1["ctx1"] = "v1"
+ ctx2 = { }
+ ctx2["ctx2"] = "v2"
+ test(compObj.ice_context({ }) == compObj.ice_context({ }))
+ test(compObj.ice_context(ctx1) == compObj.ice_context(ctx1))
+ test(compObj.ice_context(ctx1) != compObj.ice_context({ }))
+ test(compObj.ice_context({ }) != compObj.ice_context(ctx2))
+ test(compObj.ice_context(ctx1) != compObj.ice_context(ctx2))
+ test(compObj.ice_context(ctx1) < compObj.ice_context(ctx2))
+ test(not (compObj.ice_context(ctx2) < compObj.ice_context(ctx1)))
+
+ test(compObj.ice_preferSecure(True) == compObj.ice_preferSecure(True))
+ test(compObj.ice_preferSecure(True) != compObj.ice_preferSecure(False))
+ test(compObj.ice_preferSecure(False) < compObj.ice_preferSecure(True))
+ test(not (compObj.ice_preferSecure(True) < compObj.ice_preferSecure(False)))
+
+ compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000")
+ compObj2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001")
+ test(compObj1 != compObj2)
+ test(compObj1 < compObj2)
+ test(not (compObj2 < compObj1))
+
+ compObj1 = communicator.stringToProxy("foo@MyAdapter1")
+ compObj2 = communicator.stringToProxy("foo@MyAdapter2")
+ test(compObj1 != compObj2)
+ test(compObj1 < compObj2)
+ test(not (compObj2 < compObj1))
+
+ test(compObj1.ice_locatorCacheTimeout(20) == compObj1.ice_locatorCacheTimeout(20))
+ test(compObj1.ice_locatorCacheTimeout(10) != compObj1.ice_locatorCacheTimeout(20))
+ test(compObj1.ice_locatorCacheTimeout(10) < compObj1.ice_locatorCacheTimeout(20))
+ test(not (compObj1.ice_locatorCacheTimeout(20) < compObj1.ice_locatorCacheTimeout(10)))
+
+ test(compObj1.ice_invocationTimeout(20) == compObj1.ice_invocationTimeout(20));
+ test(compObj1.ice_invocationTimeout(10) != compObj1.ice_invocationTimeout(20));
+ test(compObj1.ice_invocationTimeout(10) < compObj1.ice_invocationTimeout(20));
+ test(not (compObj1.ice_invocationTimeout(20) < compObj1.ice_invocationTimeout(10)));
+
+ compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 1000")
+ compObj2 = communicator.stringToProxy("foo@MyAdapter1")
+ test(compObj1 != compObj2)
+ test(compObj1 < compObj2)
+ test(not (compObj2 < compObj1))
+
+ endpts1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints()
+ endpts2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001").ice_getEndpoints()
+ test(endpts1 != endpts2)
+ test(endpts1 < endpts2)
+ test(not (endpts2 < endpts1))
+ test(endpts1 == communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints())
+
+ test(compObj1.ice_encodingVersion(Ice.Encoding_1_0) == compObj1.ice_encodingVersion(Ice.Encoding_1_0))
+ test(compObj1.ice_encodingVersion(Ice.Encoding_1_0) != compObj1.ice_encodingVersion(Ice.Encoding_1_1))
+ test(compObj.ice_encodingVersion(Ice.Encoding_1_0) < compObj.ice_encodingVersion(Ice.Encoding_1_1))
+ test(not (compObj.ice_encodingVersion(Ice.Encoding_1_1) < compObj.ice_encodingVersion(Ice.Encoding_1_0)))
+
+ #
+ # TODO: Ideally we should also test comparison of fixed proxies.
+ #
+
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ cl = Test.MyClassPrx.checkedCast(base)
+ test(cl)
+
+ derived = Test.MyDerivedClassPrx.checkedCast(cl)
+ test(derived)
+ test(cl == base)
+ test(derived == base)
+ test(cl == derived)
+
+ loc = Ice.LocatorPrx.checkedCast(base)
+ test(loc == None)
+
+ #
+ # Upcasting
+ #
+ cl2 = Test.MyClassPrx.checkedCast(derived)
+ obj = Ice.ObjectPrx.checkedCast(derived)
+ test(cl2)
+ test(obj)
+ test(cl2 == obj)
+ test(cl2 == derived)
+
+ print("ok")
+
+ sys.stdout.write("testing checked cast with context... ")
+ sys.stdout.flush()
+ tccp = Test.MyClassPrx.checkedCast(base)
+ c = tccp.getContext()
+ test(c == None or len(c) == 0)
+
+ c = { }
+ c["one"] = "hello"
+ c["two"] = "world"
+ tccp = Test.MyClassPrx.checkedCast(base, c)
+ c2 = tccp.getContext()
+ test(c == c2)
+ print("ok")
+
+ sys.stdout.write("testing encoding versioning... ")
+ sys.stdout.flush()
+ ref20 = "test -e 2.0:default -p 12010";
+ cl20 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref20));
+ try:
+ cl20.ice_ping();
+ test(false);
+ except Ice.UnsupportedEncodingException:
+ # Server 2.0 endpoint doesn't support 1.1 version.
+ pass
+
+ ref10 = "test -e 1.0:default -p 12010"
+ cl10 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref10))
+ cl10.ice_ping()
+ cl10.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()
+ cl.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()
+
+ # 1.3 isn't supported but since a 1.3 proxy supports 1.1, the
+ # call will use the 1.1 encoding
+ ref13 = "test -e 1.3:default -p 12010"
+ cl13 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref13))
+ cl13.ice_ping()
+
+ print("ok")
+
+ sys.stdout.write("testing opaque endpoints... ")
+ sys.stdout.flush()
+
+ try:
+ # Invalid -x option
+ p = communicator.stringToProxy("id:opaque -t 99 -v abc -x abc")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Missing -t and -v
+ p = communicator.stringToProxy("id:opaque")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Repeated -t
+ p = communicator.stringToProxy("id:opaque -t 1 -t 1 -v abc")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Repeated -v
+ p = communicator.stringToProxy("id:opaque -t 1 -v abc -v abc")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Missing -t
+ p = communicator.stringToProxy("id:opaque -v abc")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Missing -v
+ p = communicator.stringToProxy("id:opaque -t 1")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Missing arg for -t
+ p = communicator.stringToProxy("id:opaque -t -v abc")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Missing arg for -v
+ p = communicator.stringToProxy("id:opaque -t 1 -v")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Not a number for -t
+ p = communicator.stringToProxy("id:opaque -t x -v abc")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # < 0 for -t
+ p = communicator.stringToProxy("id:opaque -t -1 -v abc")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ try:
+ # Invalid char for -v
+ p = communicator.stringToProxy("id:opaque -t 99 -v x?c")
+ test(False)
+ except Ice.EndpointParseException:
+ pass
+
+ # Legal TCP endpoint expressed as opaque endpoint
+ p1 = communicator.stringToProxy("test -e 1.1:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA==")
+ pstr = communicator.proxyToString(p1)
+ test(pstr == "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")
+
+ # Opaque endpoint encoded with 1.1 encoding.
+ p2 = communicator.stringToProxy("test -e 1.1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==")
+ test(communicator.proxyToString(p2) == "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")
+
+ if communicator.getProperties().getPropertyAsInt("Ice.IPv6") == 0:
+ # Working?
+ ssl = communicator.getProperties().getProperty("Ice.Default.Protocol") == "ssl"
+ tcp = communicator.getProperties().getProperty("Ice.Default.Protocol") == "tcp"
+ if tcp:
+ p1.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()
+
+ # Two legal TCP endpoints expressed as opaque endpoints
+ p1 = communicator.stringToProxy("test -e 1.0:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMusuAAAQJwAAAA==")
+ pstr = communicator.proxyToString(p1)
+ test(pstr == "test -t -e 1.0:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000")
+
+ #
+ # Test that an SSL endpoint and a nonsense endpoint get written
+ # back out as an opaque endpoint.
+ #
+ p1 = communicator.stringToProxy("test -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch")
+ pstr = communicator.proxyToString(p1)
+ if ssl:
+ test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch")
+ elif tcp:
+ test(pstr == "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch")
+
+ #
+ # Try to invoke on the SSL endpoint to verify that we get a
+ # NoEndpointException (or ConnectionRefusedException when
+ # running with SSL).
+ #
+ try:
+ p1.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()
+ test(False)
+ except Ice.NoEndpointException:
+ test(not ssl)
+ except Ice.ConnectFailedException:
+ test(not tcp)
+
+ #
+ # Test that the proxy with an SSL endpoint and a nonsense
+ # endpoint (which the server doesn't understand either) can be
+ # sent over the wire and returned by the server without losing
+ # the opaque endpoints.
+ #
+ p2 = derived.echo(p1)
+ pstr = communicator.proxyToString(p2)
+ if ssl:
+ test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch")
+ elif tcp:
+ test(pstr == "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch")
+
+ print("ok")
+
+ return cl
diff --git a/python/test/Ice/proxy/Client.py b/python/test/Ice/proxy/Client.py
new file mode 100755
index 00000000000..442bd795711
--- /dev/null
+++ b/python/test/Ice/proxy/Client.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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 AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ myClass = AllTests.allTests(communicator, False)
+ myClass.shutdown()
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/proxy/Collocated.py b/python/test/Ice/proxy/Collocated.py
new file mode 100755
index 00000000000..a66580d803a
--- /dev/null
+++ b/python/test/Ice/proxy/Collocated.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI, AllTests
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(TestI.MyDerivedClassI(), communicator.stringToIdentity("test"))
+ #adapter.activate() // Don't activate OA to ensure collocation is used.
+
+ AllTests.allTests(communicator, True)
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/proxy/Server.py b/python/test/Ice/proxy/Server.py
new file mode 100755
index 00000000000..cf5e7289225
--- /dev/null
+++ b/python/test/Ice/proxy/Server.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(TestI.MyDerivedClassI(), communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/proxy/ServerAMD.py b/python/test/Ice/proxy/ServerAMD.py
new file mode 100755
index 00000000000..f94496bbcb7
--- /dev/null
+++ b/python/test/Ice/proxy/ServerAMD.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, 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 + "' TestAMD.ice")
+import Test
+
+class MyDerivedClassI(Test.MyDerivedClass):
+ def __init__(self):
+ self.ctx = None
+
+ def shutdown_async(self, cb, current=None):
+ current.adapter.getCommunicator().shutdown()
+ cb.ice_response()
+
+ def getContext_async(self, cb, current):
+ return cb.ice_response(self.ctx)
+
+ def echo_async(self, cb, obj, current):
+ return cb.ice_response(obj)
+
+ def ice_isA(self, s, current):
+ self.ctx = current.ctx
+ return Test.MyDerivedClass.ice_isA(self, s, current)
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(MyDerivedClassI(), communicator.stringToIdentity("test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/proxy/Test.ice b/python/test/Ice/proxy/Test.ice
new file mode 100644
index 00000000000..7f3701e81e2
--- /dev/null
+++ b/python/test/Ice/proxy/Test.ice
@@ -0,0 +1,29 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/Current.ice>
+
+module Test
+{
+
+class MyClass
+{
+ void shutdown();
+
+ Ice::Context getContext();
+};
+
+class MyDerivedClass extends MyClass
+{
+ Object* echo(Object* obj);
+};
+
+};
diff --git a/python/test/Ice/proxy/TestAMD.ice b/python/test/Ice/proxy/TestAMD.ice
new file mode 100644
index 00000000000..f69fb3a10b6
--- /dev/null
+++ b/python/test/Ice/proxy/TestAMD.ice
@@ -0,0 +1,29 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/Current.ice>
+
+module Test
+{
+
+["amd"] class MyClass
+{
+ void shutdown();
+
+ Ice::Context getContext();
+};
+
+["amd"] class MyDerivedClass extends MyClass
+{
+ Object* echo(Object* obj);
+};
+
+};
diff --git a/python/test/Ice/proxy/TestI.py b/python/test/Ice/proxy/TestI.py
new file mode 100644
index 00000000000..72464f6d2ca
--- /dev/null
+++ b/python/test/Ice/proxy/TestI.py
@@ -0,0 +1,28 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+import time
+
+class MyDerivedClassI(Test.MyDerivedClass):
+ def __init__(self):
+ self.ctx = None
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def getContext(self, current):
+ return self.ctx
+
+ def echo(self, obj, current):
+ return obj
+
+ def ice_isA(self, s, current):
+ self.ctx = current.ctx
+ return Test.MyDerivedClass.ice_isA(self, s, current)
diff --git a/python/test/Ice/proxy/run.py b/python/test/Ice/proxy/run.py
new file mode 100755
index 00000000000..767b20c0a2c
--- /dev/null
+++ b/python/test/Ice/proxy/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("tests with regular server.")
+TestUtil.clientServerTest()
+print("tests with AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py")
+print("tests with collocated server.")
+TestUtil.collocatedTest(" --Ice.ThreadPool.Client.SizeMax=2 --Ice.ThreadPool.Client.SizeWarn=0")
diff --git a/python/test/Ice/servantLocator/AllTests.py b/python/test/Ice/servantLocator/AllTests.py
new file mode 100644
index 00000000000..debe76df441
--- /dev/null
+++ b/python/test/Ice/servantLocator/AllTests.py
@@ -0,0 +1,226 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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 sys, Ice, Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def testExceptions(obj, collocated):
+
+ try:
+ obj.requestFailedException()
+ test(False)
+ except Ice.ObjectNotExistException as ex:
+ test(ex.id == obj.ice_getIdentity())
+ test(ex.facet == obj.ice_getFacet())
+ test(ex.operation == "requestFailedException")
+ except:
+ test(False)
+
+ try:
+ obj.unknownUserException()
+ test(False)
+ except Ice.UnknownUserException as ex:
+ test(ex.unknown == "reason")
+ except:
+ test(False)
+
+ try:
+ obj.unknownLocalException()
+ test(False)
+ except Ice.UnknownLocalException as ex:
+ test(ex.unknown == "reason")
+ except:
+ test(False)
+
+ try:
+ obj.unknownException()
+ test(False)
+ except Ice.UnknownException as ex:
+ test(ex.unknown == "reason")
+ pass
+
+ try:
+ obj.userException()
+ test(False)
+ except Ice.UnknownUserException as ex:
+ test(ex.unknown.find("Test::TestIntfUserException") >= 0)
+ except Ice.OperationNotExistException:
+ pass
+ except AttributeError:
+ pass
+ except:
+ test(False)
+
+ try:
+ obj.localException()
+ test(False)
+ except Ice.UnknownLocalException as ex:
+ test(not collocated)
+ test(ex.unknown.find("Ice.SocketException") >= 0 or ex.unknown.find("Ice::SocketException") >= 0)
+ except SocketException:
+ test(collocated)
+ except:
+ test(False)
+
+ try:
+ obj.pythonException()
+ test(False)
+ except Ice.UnknownException as ex:
+ test(ex.unknown.find("RuntimeError: message") >= 0)
+ except Ice.OperationNotExistException:
+ pass
+ except AttributeError:
+ pass
+ except:
+ test(False)
+
+ try:
+ obj.unknownExceptionWithServantException()
+ test(False)
+ except Ice.UnknownException as ex:
+ test(ex.unknown == "reason")
+ except:
+ test(False)
+
+ try:
+ obj.impossibleException(False)
+ test(False)
+ except Ice.UnknownUserException:
+ # Operation doesn't throw, but locate() and finished() throw TestIntfUserException.
+ pass
+ except:
+ test(False)
+
+ try:
+ obj.impossibleException(True)
+ test(False)
+ except Ice.UnknownUserException:
+ # Operation doesn't throw, but locate() and finished() throw TestIntfUserException.
+ pass
+ except:
+ test(False)
+
+ try:
+ obj.intfUserException(False)
+ test(False)
+ except Test.TestImpossibleException:
+ # Operation doesn't throw, but locate() and finished() throw TestImpossibleException.
+ pass
+ except:
+ test(False)
+
+ try:
+ obj.intfUserException(True)
+ test(False)
+ except Test.TestImpossibleException:
+ # Operation throws TestIntfUserException, but locate() and finished() throw TestImpossibleException.
+ pass
+ except:
+ test(False)
+
+def allTests(communicator, collocated):
+ sys.stdout.write("testing stringToProxy... ")
+ sys.stdout.flush()
+ base = communicator.stringToProxy("asm:default -p 12010")
+ test(base)
+ print("ok")
+
+ sys.stdout.write("testing checked cast... ")
+ sys.stdout.flush()
+ obj = Test.TestIntfPrx.checkedCast(base)
+ test(obj)
+ test(obj == base)
+ print("ok")
+
+ sys.stdout.write("testing ice_ids... ")
+ sys.stdout.flush()
+ try:
+ obj = communicator.stringToProxy("category/locate:default -p 12010")
+ obj.ice_ids()
+ test(False)
+ except Ice.UnknownUserException as ex:
+ test(ex.unknown == "Test::TestIntfUserException")
+ except:
+ test(False)
+
+ try:
+ obj = communicator.stringToProxy("category/finished:default -p 12010")
+ obj.ice_ids()
+ test(False)
+ except Ice.UnknownUserException as ex:
+ test(ex.unknown == "Test::TestIntfUserException")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("testing servant locator... ")
+ sys.stdout.flush()
+ base = communicator.stringToProxy("category/locate:default -p 12010")
+ obj = Test.TestIntfPrx.checkedCast(base)
+ try:
+ Test.TestIntfPrx.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010"))
+ except Ice.ObjectNotExistException:
+ pass
+ print("ok")
+
+ sys.stdout.write("testing default servant locator... ")
+ sys.stdout.flush()
+ base = communicator.stringToProxy("anothercat/locate:default -p 12010")
+ obj = Test.TestIntfPrx.checkedCast(base)
+ base = communicator.stringToProxy("locate:default -p 12010")
+ obj = Test.TestIntfPrx.checkedCast(base)
+ try:
+ Test.TestIntfPrx.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010"))
+ except Ice.ObjectNotExistException:
+ pass
+ try:
+ Test.TestIntfPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010"))
+ except Ice.ObjectNotExistException:
+ pass
+ print("ok")
+
+ sys.stdout.write("testing locate exceptions... ")
+ sys.stdout.flush()
+ base = communicator.stringToProxy("category/locate:default -p 12010")
+ obj = Test.TestIntfPrx.checkedCast(base)
+ testExceptions(obj, collocated)
+ print("ok")
+
+ sys.stdout.write("testing finished exceptions... ")
+ sys.stdout.flush()
+ base = communicator.stringToProxy("category/finished:default -p 12010")
+ obj = Test.TestIntfPrx.checkedCast(base)
+ testExceptions(obj, collocated)
+ print("ok")
+
+ sys.stdout.write("testing servant locator removal... ")
+ sys.stdout.flush()
+ base = communicator.stringToProxy("test/activation:default -p 12010")
+ activation = Test.TestActivationPrx.checkedCast(base)
+ activation.activateServantLocator(False)
+ try:
+ obj.ice_ping()
+ test(False)
+ except Ice.ObjectNotExistException:
+ pass
+ print("ok")
+
+ sys.stdout.write("testing servant locator addition... ")
+ sys.stdout.flush()
+ activation.activateServantLocator(True)
+ try:
+ obj.ice_ping()
+ except:
+ test(False)
+ print("ok")
+
+ return obj
diff --git a/python/test/Ice/servantLocator/Client.py b/python/test/Ice/servantLocator/Client.py
new file mode 100755
index 00000000000..99ec03e78c3
--- /dev/null
+++ b/python/test/Ice/servantLocator/Client.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+import Ice
+Ice.loadSlice('Test.ice')
+import Test, AllTests
+
+class TestClient(Ice.Application):
+ def run(self, args):
+ obj = AllTests.allTests(self.communicator(), False)
+ obj.shutdown()
+ return 0
+
+app = TestClient()
+sys.exit(app.main(sys.argv))
diff --git a/python/test/Ice/servantLocator/Collocated.py b/python/test/Ice/servantLocator/Collocated.py
new file mode 100755
index 00000000000..ae176ff0320
--- /dev/null
+++ b/python/test/Ice/servantLocator/Collocated.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+
+import Ice
+Ice.loadSlice('Test.ice')
+import Test, TestI, AllTests, TestActivationI
+
+class TestServer(Ice.Application):
+ def run(self, args):
+ self.communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ self.communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0")
+
+ adapter = self.communicator().createObjectAdapter("TestAdapter")
+ #adapter.activate() // Don't activate OA to ensure collocation is used.
+ adapter.addServantLocator(TestI.ServantLocatorI("category"), "category")
+ adapter.addServantLocator(TestI.ServantLocatorI(""), "")
+ adapter.add(TestI.TestI(), self.communicator().stringToIdentity("asm"))
+ adapter.add(TestActivationI.TestActivationI(), self.communicator().stringToIdentity("test/activation"))
+
+ AllTests.allTests(self.communicator(), False)
+
+ adapter.deactivate()
+ adapter.waitForDeactivate()
+ return 0
+
+app = TestServer()
+sys.exit(app.main(sys.argv))
diff --git a/python/test/Ice/servantLocator/Server.py b/python/test/Ice/servantLocator/Server.py
new file mode 100755
index 00000000000..567f1e1791b
--- /dev/null
+++ b/python/test/Ice/servantLocator/Server.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+
+import Ice
+Ice.loadSlice('Test.ice')
+import Test, TestI, TestActivationI
+
+class TestServer(Ice.Application):
+ def run(self, args):
+ self.communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ self.communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0")
+
+ adapter = self.communicator().createObjectAdapter("TestAdapter")
+ adapter.addServantLocator(TestI.ServantLocatorI("category"), "category")
+ adapter.addServantLocator(TestI.ServantLocatorI(""), "")
+ adapter.add(TestI.TestI(), self.communicator().stringToIdentity("asm"))
+ adapter.add(TestActivationI.TestActivationI(), self.communicator().stringToIdentity("test/activation"))
+
+ adapter.activate()
+ adapter.waitForDeactivate()
+ return 0
+
+app = TestServer()
+sys.exit(app.main(sys.argv))
diff --git a/python/test/Ice/servantLocator/ServerAMD.py b/python/test/Ice/servantLocator/ServerAMD.py
new file mode 100755
index 00000000000..cd233e5c039
--- /dev/null
+++ b/python/test/Ice/servantLocator/ServerAMD.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+
+import Ice
+Ice.loadSlice('TestAMD.ice')
+import Test, TestAMDI, TestActivationAMDI
+
+class TestServer(Ice.Application):
+ def run(self, args):
+ self.communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ self.communicator().getProperties().setProperty("Ice.Warn.Dispatch", "0")
+
+ adapter = self.communicator().createObjectAdapter("TestAdapter")
+ adapter.addServantLocator(TestAMDI.ServantLocatorI("category"), "category")
+ adapter.addServantLocator(TestAMDI.ServantLocatorI(""), "")
+ adapter.add(TestAMDI.TestI(), self.communicator().stringToIdentity("asm"))
+ adapter.add(TestActivationAMDI.TestActivationAMDI(), self.communicator().stringToIdentity("test/activation"))
+
+ adapter.activate()
+ adapter.waitForDeactivate()
+ return 0
+
+app = TestServer()
+sys.exit(app.main(sys.argv))
diff --git a/python/test/Ice/servantLocator/Test.ice b/python/test/Ice/servantLocator/Test.ice
new file mode 100644
index 00000000000..52681603e36
--- /dev/null
+++ b/python/test/Ice/servantLocator/Test.ice
@@ -0,0 +1,54 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+exception TestIntfUserException
+{
+};
+
+exception TestImpossibleException
+{
+};
+
+interface TestIntf
+{
+ void requestFailedException();
+ void unknownUserException();
+ void unknownLocalException();
+ void unknownException();
+ void localException();
+ void userException();
+ void pythonException();
+
+ void unknownExceptionWithServantException();
+
+ string impossibleException(bool throw) throws TestImpossibleException;
+ string intfUserException(bool throw) throws TestIntfUserException, TestImpossibleException;
+
+ void asyncResponse() throws TestIntfUserException, TestImpossibleException;
+ void asyncException() throws TestIntfUserException, TestImpossibleException;
+
+ void shutdown();
+};
+
+interface TestActivation
+{
+ void activateServantLocator(bool activate);
+};
+
+local class Cookie
+{
+ ["cpp:const"] string message();
+};
+
+};
diff --git a/python/test/Ice/servantLocator/TestAMD.ice b/python/test/Ice/servantLocator/TestAMD.ice
new file mode 100644
index 00000000000..83512649026
--- /dev/null
+++ b/python/test/Ice/servantLocator/TestAMD.ice
@@ -0,0 +1,54 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+exception TestIntfUserException
+{
+};
+
+exception TestImpossibleException
+{
+};
+
+["amd"] interface TestIntf
+{
+ void requestFailedException();
+ void unknownUserException();
+ void unknownLocalException();
+ void unknownException();
+ void localException();
+ void userException();
+ void pythonException();
+
+ void unknownExceptionWithServantException();
+
+ string impossibleException(bool throw) throws TestImpossibleException;
+ string intfUserException(bool throw) throws TestIntfUserException, TestImpossibleException;
+
+ void asyncResponse() throws TestIntfUserException, TestImpossibleException;
+ void asyncException() throws TestIntfUserException, TestImpossibleException;
+
+ void shutdown();
+};
+
+interface TestActivation
+{
+ void activateServantLocator(bool activate);
+};
+
+local class Cookie
+{
+ ["cpp:const"] string message();
+};
+
+};
diff --git a/python/test/Ice/servantLocator/TestAMDI.py b/python/test/Ice/servantLocator/TestAMDI.py
new file mode 100644
index 00000000000..4ba7ca4f72f
--- /dev/null
+++ b/python/test/Ice/servantLocator/TestAMDI.py
@@ -0,0 +1,157 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+import Ice, Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class TestI(Test.TestIntf):
+
+ def requestFailedException_async(self, cb, current=None):
+ cb.ice_response()
+
+ def unknownUserException_async(self, cb, current=None):
+ cb.ice_response()
+
+ def unknownLocalException_async(self, cb, current=None):
+ cb.ice_response()
+
+ def unknownException_async(self, cb, current=None):
+ cb.ice_response()
+
+ def localException_async(self, cb, current=None):
+ cb.ice_response()
+
+ def userException_async(self, cb, current=None):
+ cb.ice_response()
+
+ def pythonException_async(self, cb, current=None):
+ cb.ice_response()
+
+ def unknownExceptionWithServantException_async(self, cb, current=None):
+ cb.ice_exception(Ice.ObjectNotExistException())
+
+ def impossibleException_async(self, cb, throw, current=None):
+ if throw:
+ cb.ice_exception(Test.TestImpossibleException())
+ else:
+ #
+ # Return a value so we can be sure that the stream position
+ # is reset correctly if finished() throws.
+ #
+ cb.ice_response("Hello")
+
+ def intfUserException_async(self, cb, throw, current=None):
+ if throw:
+ cb.ice_exception(Test.TestIntfUserException())
+ else:
+ #
+ # Return a value so we can be sure that the stream position
+ # is reset correctly if finished() throws.
+ #
+ cb.ice_response("Hello")
+
+ def asyncResponse_async(self, cb, current=None):
+ cb.ice_response()
+ raise Ice.ObjectNotExistException()
+
+ def asyncException_async(self, cb, current=None):
+ cb.ice_exception(Test.TestIntfUserException())
+ raise Ice.ObjectNotExistException()
+
+ def shutdown_async(self, cb, current=None):
+ current.adapter.deactivate()
+ cb.ice_response()
+
+class CookieI(Test.Cookie):
+ def message(self):
+ return 'blahblah'
+
+class ServantLocatorI(Ice.ServantLocator):
+ def __init__(self, category):
+ self._deactivated = False
+ self._category = category
+ self._requestId = -1
+
+ def __del__(self):
+ test(self._deactivated)
+
+ def locate(self, current):
+ test(not self._deactivated)
+
+ test(current.id.category == self._category or self._category == "")
+
+ if current.id.name == "unknown":
+ return None
+
+ test(current.id.name == "locate" or current.id.name == "finished")
+ if current.id.name == "locate":
+ self.exception(current)
+
+ #
+ # Ensure locate() is only called once per request.
+ #
+ test(self._requestId == -1)
+ self._requestId = current.requestId
+
+ return (TestI(), CookieI())
+
+ def finished(self, current, servant, cookie):
+ test(not self._deactivated)
+
+ #
+ # Ensure finished() is only called once per request.
+ #
+ test(self._requestId == current.requestId)
+ self._requestId = -1
+
+ test(current.id.category == self._category or self._category == "")
+ test(current.id.name == "locate" or current.id.name == "finished")
+
+ if current.id.name == "finished":
+ self.exception(current)
+
+ test(isinstance(cookie, Test.Cookie))
+ test(cookie.message() == 'blahblah')
+
+ def deactivate(self, category):
+ test(not self._deactivated)
+
+ self._deactivated = True
+
+ def exception(self, current):
+ if current.operation == "ice_ids":
+ raise Test.TestIntfUserException()
+ elif current.operation == "requestFailedException":
+ raise Ice.ObjectNotExistException()
+ elif current.operation == "unknownUserException":
+ raise Ice.UnknownUserException("reason")
+ elif current.operation == "unknownLocalException":
+ raise Ice.UnknownLocalException("reason")
+ elif current.operation == "unknownException":
+ raise Ice.UnknownException("reason")
+ elif current.operation == "userException":
+ raise Test.TestIntfUserException()
+ elif current.operation == "localException":
+ raise Ice.SocketException(0)
+ elif current.operation == "pythonException":
+ raise RuntimeError("message")
+ elif current.operation == "unknownExceptionWithServantException":
+ raise Ice.UnknownException("reason")
+ elif current.operation == "impossibleException":
+ raise Test.TestIntfUserException() # Yes, it really is meant to be TestIntfUserException.
+ elif current.operation == "intfUserException":
+ raise Test.TestImpossibleException() # Yes, it really is meant to be TestImpossibleException.
+ elif current.operation == "asyncResponse":
+ raise Test.TestImpossibleException()
+ elif current.operation == "asyncException":
+ raise Test.TestImpossibleException()
diff --git a/python/test/Ice/servantLocator/TestActivationAMDI.py b/python/test/Ice/servantLocator/TestActivationAMDI.py
new file mode 100644
index 00000000000..ade3027cb85
--- /dev/null
+++ b/python/test/Ice/servantLocator/TestActivationAMDI.py
@@ -0,0 +1,25 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+import Ice, Test, TestAMDI
+
+
+class TestActivationAMDI(Test.TestActivation):
+
+ def activateServantLocator(self, activate, current=None):
+ if(activate):
+ current.adapter.addServantLocator(TestAMDI.ServantLocatorI(""), "")
+ current.adapter.addServantLocator(TestAMDI.ServantLocatorI("category"), "category")
+ else:
+ locator = current.adapter.removeServantLocator("")
+ locator.deactivate("")
+ locator = current.adapter.removeServantLocator("category")
+ locator.deactivate("category")
+
diff --git a/python/test/Ice/servantLocator/TestActivationI.py b/python/test/Ice/servantLocator/TestActivationI.py
new file mode 100644
index 00000000000..026ec36af41
--- /dev/null
+++ b/python/test/Ice/servantLocator/TestActivationI.py
@@ -0,0 +1,25 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+import Ice, Test, TestI
+
+
+class TestActivationI(Test.TestActivation):
+
+ def activateServantLocator(self, activate, current=None):
+ if activate:
+ current.adapter.addServantLocator(TestI.ServantLocatorI(""), "")
+ current.adapter.addServantLocator(TestI.ServantLocatorI("category"), "category")
+ else:
+ locator = current.adapter.removeServantLocator("")
+ locator.deactivate("")
+ locator = current.adapter.removeServantLocator("category")
+ locator.deactivate("category")
+
diff --git a/python/test/Ice/servantLocator/TestI.py b/python/test/Ice/servantLocator/TestI.py
new file mode 100644
index 00000000000..19e724fd5d0
--- /dev/null
+++ b/python/test/Ice/servantLocator/TestI.py
@@ -0,0 +1,158 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time
+import Ice, Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class TestI(Test.TestIntf):
+
+ def requestFailedException(self, current=None):
+ pass
+
+ def unknownUserException(self, current=None):
+ pass
+
+ def unknownLocalException(self, current=None):
+ pass
+
+ def unknownException(self, current=None):
+ pass
+
+ def localException(self, current=None):
+ pass
+
+ def userException(self, current=None):
+ pass
+
+ def pythonException(self, current=None):
+ pass
+
+ def unknownExceptionWithServantException(self, current=None):
+ raise Ice.ObjectNotExistException()
+
+ def impossibleException(self, throw, current=None):
+ if throw:
+ raise Test.TestImpossibleException()
+ #
+ # Return a value so we can be sure that the stream position
+ # is reset correctly if finished() throws.
+ #
+ return "Hello"
+
+ def intfUserException(self, throw, current=None):
+ if throw:
+ raise Test.TestIntfUserException()
+ #
+ # Return a value so we can be sure that the stream position
+ # is reset correctly if finished() throws.
+ #
+ return "Hello"
+
+ def asyncResponse(self, current=None):
+ #
+ # Only relevant for AMD.
+ #
+ pass
+
+ def asyncException(self, current=None):
+ #
+ # Only relevant for AMD.
+ #
+ pass
+
+ def shutdown(self, current=None):
+ current.adapter.deactivate()
+
+class CookieI(Test.Cookie):
+ def message(self):
+ return 'blahblah'
+
+class ServantLocatorI(Ice.ServantLocator):
+ def __init__(self, category):
+ self._deactivated = False
+ self._category = category
+ self._requestId = -1
+
+ def __del__(self):
+ test(self._deactivated)
+
+ def locate(self, current):
+ test(not self._deactivated)
+
+ test(current.id.category == self._category or self._category == "")
+
+ if current.id.name == "unknown":
+ return None
+
+ test(current.id.name == "locate" or current.id.name == "finished")
+ if current.id.name == "locate":
+ self.exception(current)
+
+ #
+ # Ensure locate() is only called once per request.
+ #
+ test(self._requestId == -1)
+ self._requestId = current.requestId
+
+ return (TestI(), CookieI())
+
+ def finished(self, current, servant, cookie):
+ test(not self._deactivated)
+
+ #
+ # Ensure finished() is only called once per request.
+ #
+ test(self._requestId == current.requestId)
+ self._requestId = -1
+
+ test(current.id.category == self._category or self._category == "")
+ test(current.id.name == "locate" or current.id.name == "finished")
+
+ if current.id.name == "finished":
+ self.exception(current)
+
+ test(isinstance(cookie, Test.Cookie))
+ test(cookie.message() == 'blahblah')
+
+ def deactivate(self, category):
+ test(not self._deactivated)
+
+ self._deactivated = True
+
+ def exception(self, current):
+ if current.operation == "ice_ids":
+ raise Test.TestIntfUserException()
+ elif current.operation == "requestFailedException":
+ raise Ice.ObjectNotExistException()
+ elif current.operation == "unknownUserException":
+ raise Ice.UnknownUserException("reason")
+ elif current.operation == "unknownLocalException":
+ raise Ice.UnknownLocalException("reason")
+ elif current.operation == "unknownException":
+ raise Ice.UnknownException("reason")
+ elif current.operation == "userException":
+ raise Test.TestIntfUserException()
+ elif current.operation == "localException":
+ raise Ice.SocketException(0)
+ elif current.operation == "pythonException":
+ raise RuntimeError("message")
+ elif current.operation == "unknownExceptionWithServantException":
+ raise Ice.UnknownException("reason")
+ elif current.operation == "impossibleException":
+ raise Test.TestIntfUserException() # Yes, it really is meant to be TestIntfUserException.
+ elif current.operation == "intfUserException":
+ raise Test.TestImpossibleException() # Yes, it really is meant to be TestImpossibleException.
+ elif current.operation == "asyncResponse":
+ raise Test.TestImpossibleException()
+ elif current.operation == "asyncException":
+ raise Test.TestImpossibleException()
diff --git a/python/test/Ice/servantLocator/run.py b/python/test/Ice/servantLocator/run.py
new file mode 100755
index 00000000000..767b20c0a2c
--- /dev/null
+++ b/python/test/Ice/servantLocator/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("tests with regular server.")
+TestUtil.clientServerTest()
+print("tests with AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py")
+print("tests with collocated server.")
+TestUtil.collocatedTest(" --Ice.ThreadPool.Client.SizeMax=2 --Ice.ThreadPool.Client.SizeWarn=0")
diff --git a/python/test/Ice/slicing/exceptions/AllTests.py b/python/test/Ice/slicing/exceptions/AllTests.py
new file mode 100644
index 00000000000..07f860aeb1b
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/AllTests.py
@@ -0,0 +1,589 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, threading, sys
+
+Ice.loadSlice('-I. --all ClientPrivate.ice')
+import Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class CallbackBase:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def check(self):
+ self._cond.acquire()
+ try:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ finally:
+ self._cond.release()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+class Callback(CallbackBase):
+ def response(self):
+ test(False)
+
+ def exception_baseAsBase(self, exc):
+ try:
+ raise exc
+ except Test.Base as b:
+ test(b.b == "Base.b")
+ test(b.ice_name() =="Test::Base")
+ except:
+ test(False)
+ self.called()
+
+ def exception_unknownDerivedAsBase(self, exc):
+ try:
+ raise exc
+ except Test.Base as b:
+ test(b.b == "UnknownDerived.b")
+ test(b.ice_name() =="Test::Base")
+ except:
+ test(False)
+ self.called()
+
+ def exception_knownDerivedAsBase(self, exc):
+ try:
+ raise exc
+ except Test.KnownDerived as k:
+ test(k.b == "KnownDerived.b")
+ test(k.kd == "KnownDerived.kd")
+ test(k.ice_name() =="Test::KnownDerived")
+ except:
+ test(False)
+ self.called()
+
+ def exception_knownDerivedAsKnownDerived(self, exc):
+ try:
+ raise exc
+ except Test.KnownDerived as k:
+ test(k.b == "KnownDerived.b")
+ test(k.kd == "KnownDerived.kd")
+ test(k.ice_name() =="Test::KnownDerived")
+ except:
+ test(False)
+ self.called()
+
+ def exception_unknownIntermediateAsBase(self, exc):
+ try:
+ raise exc
+ except Test.Base as b:
+ test(b.b == "UnknownIntermediate.b")
+ test(b.ice_name() =="Test::Base")
+ except:
+ test(False)
+ self.called()
+
+ def exception_knownIntermediateAsBase(self, exc):
+ try:
+ raise exc
+ except Test.KnownIntermediate as ki:
+ test(ki.b == "KnownIntermediate.b")
+ test(ki.ki == "KnownIntermediate.ki")
+ test(ki.ice_name() =="Test::KnownIntermediate")
+ except:
+ test(False)
+ self.called()
+
+ def exception_knownMostDerivedAsBase(self, exc):
+ try:
+ raise exc
+ except Test.KnownMostDerived as kmd:
+ test(kmd.b == "KnownMostDerived.b")
+ test(kmd.ki == "KnownMostDerived.ki")
+ test(kmd.kmd == "KnownMostDerived.kmd")
+ test(kmd.ice_name() =="Test::KnownMostDerived")
+ except:
+ test(False)
+ self.called()
+
+ def exception_knownIntermediateAsKnownIntermediate(self, exc):
+ try:
+ raise exc
+ except Test.KnownIntermediate as ki:
+ test(ki.b == "KnownIntermediate.b")
+ test(ki.ki == "KnownIntermediate.ki")
+ test(ki.ice_name() =="Test::KnownIntermediate")
+ except:
+ test(False)
+ self.called()
+
+ def exception_knownMostDerivedAsKnownMostDerived(self, exc):
+ try:
+ raise exc
+ except Test.KnownMostDerived as kmd:
+ test(kmd.b == "KnownMostDerived.b")
+ test(kmd.ki == "KnownMostDerived.ki")
+ test(kmd.kmd == "KnownMostDerived.kmd")
+ test(kmd.ice_name() =="Test::KnownMostDerived")
+ except:
+ test(False)
+ self.called()
+
+ def exception_knownMostDerivedAsKnownIntermediate(self, exc):
+ try:
+ raise exc
+ except Test.KnownMostDerived as kmd:
+ test(kmd.b == "KnownMostDerived.b")
+ test(kmd.ki == "KnownMostDerived.ki")
+ test(kmd.kmd == "KnownMostDerived.kmd")
+ test(kmd.ice_name() =="Test::KnownMostDerived")
+ except:
+ test(False)
+ self.called()
+
+ def exception_unknownMostDerived1AsBase(self, exc):
+ try:
+ raise exc
+ except Test.KnownIntermediate as ki:
+ test(ki.b == "UnknownMostDerived1.b")
+ test(ki.ki == "UnknownMostDerived1.ki")
+ test(ki.ice_name() =="Test::KnownIntermediate")
+ except:
+ test(False)
+ self.called()
+
+ def exception_unknownMostDerived1AsKnownIntermediate(self, exc):
+ try:
+ raise exc
+ except Test.KnownIntermediate as ki:
+ test(ki.b == "UnknownMostDerived1.b")
+ test(ki.ki == "UnknownMostDerived1.ki")
+ test(ki.ice_name() =="Test::KnownIntermediate")
+ except:
+ test(False)
+ self.called()
+
+ def exception_unknownMostDerived2AsBase(self, exc):
+ try:
+ raise exc
+ except Test.Base as b:
+ test(b.b == "UnknownMostDerived2.b")
+ test(b.ice_name() =="Test::Base")
+ except:
+ test(False)
+ self.called()
+
+class RelayI(Test.Relay):
+ def knownPreservedAsBase(self, current=None):
+ ex = Test.KnownPreservedDerived()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ raise ex
+
+ def knownPreservedAsKnownPreserved(self, current=None):
+ ex = Test.KnownPreservedDerived()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ raise ex
+
+ def unknownPreservedAsBase(self, current=None):
+ ex = Test.Preserved2()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ ex.p1 = Test.PreservedClass("bc", "pc")
+ ex.p2 = ex.p1
+ raise ex
+
+ def unknownPreservedAsKnownPreserved(self, current=None):
+ ex = Test.Preserved2()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ ex.p1 = Test.PreservedClass("bc", "pc")
+ ex.p2 = ex.p1
+ raise ex
+
+def allTests(communicator):
+ obj = communicator.stringToProxy("Test:default -p 12010")
+ t = Test.TestIntfPrx.checkedCast(obj)
+
+ sys.stdout.write("base... ")
+ sys.stdout.flush()
+ try:
+ t.baseAsBase()
+ test(false)
+ except Test.Base as b:
+ test(b.b == "Base.b")
+ test(b.ice_name() == "Test::Base")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_baseAsBase(cb.response, cb.exception_baseAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("slicing of unknown derived... ")
+ sys.stdout.flush()
+ try:
+ t.unknownDerivedAsBase()
+ test(false)
+ except Test.Base as b:
+ test(b.b == "UnknownDerived.b")
+ test(b.ice_name() == "Test::Base")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("slicing of unknown derived (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_unknownDerivedAsBase(cb.response, cb.exception_unknownDerivedAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("non-slicing of known derived as base... ")
+ sys.stdout.flush()
+ try:
+ t.knownDerivedAsBase()
+ test(false)
+ except Test.KnownDerived as k:
+ test(k.b == "KnownDerived.b")
+ test(k.kd == "KnownDerived.kd")
+ test(k.ice_name() == "Test::KnownDerived")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("non-slicing of known derived as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_knownDerivedAsBase(cb.response, cb.exception_knownDerivedAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("non-slicing of known derived as derived... ")
+ sys.stdout.flush()
+ try:
+ t.knownDerivedAsKnownDerived()
+ test(false)
+ except Test.KnownDerived as k:
+ test(k.b == "KnownDerived.b")
+ test(k.kd == "KnownDerived.kd")
+ test(k.ice_name() == "Test::KnownDerived")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("non-slicing of known derived as derived (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_knownDerivedAsKnownDerived(cb.response, cb.exception_knownDerivedAsKnownDerived)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("slicing of unknown intermediate as base... ")
+ sys.stdout.flush()
+ try:
+ t.unknownIntermediateAsBase()
+ test(false)
+ except Test.Base as b:
+ test(b.b == "UnknownIntermediate.b")
+ test(b.ice_name() == "Test::Base")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("slicing of unknown intermediate as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_unknownIntermediateAsBase(cb.response, cb.exception_unknownIntermediateAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("slicing of known intermediate as base... ")
+ sys.stdout.flush()
+ try:
+ t.knownIntermediateAsBase()
+ test(false)
+ except Test.KnownIntermediate as ki:
+ test(ki.b == "KnownIntermediate.b")
+ test(ki.ki == "KnownIntermediate.ki")
+ test(ki.ice_name() == "Test::KnownIntermediate")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("slicing of known intermediate as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_knownIntermediateAsBase(cb.response, cb.exception_knownIntermediateAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("slicing of known most derived as base... ")
+ sys.stdout.flush()
+ try:
+ t.knownMostDerivedAsBase()
+ test(false)
+ except Test.KnownMostDerived as kmd:
+ test(kmd.b == "KnownMostDerived.b")
+ test(kmd.ki == "KnownMostDerived.ki")
+ test(kmd.kmd == "KnownMostDerived.kmd")
+ test(kmd.ice_name() == "Test::KnownMostDerived")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("slicing of known most derived as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_knownMostDerivedAsBase(cb.response, cb.exception_knownMostDerivedAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("non-slicing of known intermediate as intermediate... ")
+ sys.stdout.flush()
+ try:
+ t.knownIntermediateAsKnownIntermediate()
+ test(false)
+ except Test.KnownIntermediate as ki:
+ test(ki.b == "KnownIntermediate.b")
+ test(ki.ki == "KnownIntermediate.ki")
+ test(ki.ice_name() == "Test::KnownIntermediate")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("non-slicing of known intermediate as intermediate (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_knownIntermediateAsKnownIntermediate(cb.response, cb.exception_knownIntermediateAsKnownIntermediate)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("non-slicing of known most derived exception as intermediate... ")
+ sys.stdout.flush()
+ try:
+ t.knownMostDerivedAsKnownIntermediate()
+ test(false)
+ except Test.KnownMostDerived as kmd:
+ test(kmd.b == "KnownMostDerived.b")
+ test(kmd.ki == "KnownMostDerived.ki")
+ test(kmd.kmd == "KnownMostDerived.kmd")
+ test(kmd.ice_name() == "Test::KnownMostDerived")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("non-slicing of known most derived as intermediate (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_knownMostDerivedAsKnownIntermediate(cb.response, cb.exception_knownMostDerivedAsKnownIntermediate)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("non-slicing of known most derived as most derived... ")
+ sys.stdout.flush()
+ try:
+ t.knownMostDerivedAsKnownMostDerived()
+ test(false)
+ except Test.KnownMostDerived as kmd:
+ test(kmd.b == "KnownMostDerived.b")
+ test(kmd.ki == "KnownMostDerived.ki")
+ test(kmd.kmd == "KnownMostDerived.kmd")
+ test(kmd.ice_name() == "Test::KnownMostDerived")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("non-slicing of known most derived as most derived (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_knownMostDerivedAsKnownMostDerived(cb.response, cb.exception_knownMostDerivedAsKnownMostDerived)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("slicing of unknown most derived, known intermediate as base... ")
+ sys.stdout.flush()
+ try:
+ t.unknownMostDerived1AsBase()
+ test(false)
+ except Test.KnownIntermediate as ki:
+ test(ki.b == "UnknownMostDerived1.b")
+ test(ki.ki == "UnknownMostDerived1.ki")
+ test(ki.ice_name() == "Test::KnownIntermediate")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("slicing of unknown most derived, known intermediate as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_unknownMostDerived1AsBase(cb.response, cb.exception_unknownMostDerived1AsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("slicing of unknown most derived, known intermediate as intermediate... ")
+ sys.stdout.flush()
+ try:
+ t.unknownMostDerived1AsKnownIntermediate()
+ test(false)
+ except Test.KnownIntermediate as ki:
+ test(ki.b == "UnknownMostDerived1.b")
+ test(ki.ki == "UnknownMostDerived1.ki")
+ test(ki.ice_name() == "Test::KnownIntermediate")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("slicing of unknown most derived, known intermediate as intermediate (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_unknownMostDerived1AsKnownIntermediate(cb.response, cb.exception_unknownMostDerived1AsKnownIntermediate)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("slicing of unknown most derived, unknown intermediate as base... ")
+ sys.stdout.flush()
+ try:
+ t.unknownMostDerived2AsBase()
+ test(false)
+ except Test.Base as b:
+ test(b.b == "UnknownMostDerived2.b")
+ test(b.ice_name() == "Test::Base")
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("slicing of unknown most derived, unknown intermediate as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_unknownMostDerived2AsBase(cb.response, cb.exception_unknownMostDerived2AsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("unknown most derived in compact format... ")
+ sys.stdout.flush()
+ try:
+ t.unknownMostDerived2AsBaseCompact()
+ test(False)
+ except Test.Base:
+ #
+ # For the 1.0 encoding, the unknown exception is sliced to Base.
+ #
+ test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
+ except Ice.UnknownUserException:
+ #
+ # An UnkownUserException is raised for the compact format because the
+ # most-derived type is unknown and the exception cannot be sliced.
+ #
+ test(t.ice_getEncodingVersion() != Ice.Encoding_1_0)
+ except Ice.OperationNotExistException:
+ pass
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("preserved exceptions... ")
+ sys.stdout.flush()
+ adapter = communicator.createObjectAdapterWithEndpoints("Relay", "default")
+ relay = Test.RelayPrx.uncheckedCast(adapter.addWithUUID(RelayI()))
+ adapter.activate()
+
+ try:
+ t.relayKnownPreservedAsBase(relay)
+ test(False)
+ except Test.KnownPreservedDerived as ex:
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ test(ex.kpd == "derived")
+ except Ice.OperationNotExistException:
+ pass
+ except:
+ test(False)
+
+ try:
+ t.relayKnownPreservedAsKnownPreserved(relay)
+ test(False)
+ except Test.KnownPreservedDerived as ex:
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ test(ex.kpd == "derived")
+ except Ice.OperationNotExistException:
+ pass
+ except:
+ test(False)
+
+ try:
+ t.relayUnknownPreservedAsBase(relay)
+ test(False)
+ except Test.Preserved2 as ex:
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ test(ex.kpd == "derived")
+ test(ex.p1.ice_id() == Test.PreservedClass.ice_staticId())
+ pc = ex.p1
+ test(isinstance(pc, Test.PreservedClass))
+ test(pc.bc == "bc")
+ test(pc.pc == "pc")
+ test(ex.p2 == ex.p1)
+ except Test.KnownPreservedDerived as ex:
+ #
+ # For the 1.0 encoding, the unknown exception is sliced to KnownPreserved.
+ #
+ test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ test(ex.kpd == "derived")
+ except Ice.OperationNotExistException:
+ pass
+ except:
+ test(False)
+
+ try:
+ t.relayUnknownPreservedAsKnownPreserved(relay)
+ test(False)
+ except Test.Preserved2 as ex:
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ test(ex.kpd == "derived")
+ test(ex.p1.ice_id() == Test.PreservedClass.ice_staticId())
+ pc = ex.p1
+ test(isinstance(pc, Test.PreservedClass))
+ test(pc.bc == "bc")
+ test(pc.pc == "pc")
+ test(ex.p2 == ex.p1)
+ except Test.KnownPreservedDerived as ex:
+ #
+ # For the 1.0 encoding, the unknown exception is sliced to KnownPreserved.
+ #
+ test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ test(ex.kpd == "derived")
+ except Ice.OperationNotExistException:
+ pass
+ except:
+ test(False)
+
+ adapter.destroy()
+ print("ok")
+
+ return t
diff --git a/python/test/Ice/slicing/exceptions/Client.py b/python/test/Ice/slicing/exceptions/Client.py
new file mode 100755
index 00000000000..2044a2d5b27
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/Client.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, AllTests
+
+def run(args, communicator):
+ Test = AllTests.allTests(communicator)
+ Test.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/slicing/exceptions/ClientPrivate.ice b/python/test/Ice/slicing/exceptions/ClientPrivate.ice
new file mode 100644
index 00000000000..d7d016e5b65
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/ClientPrivate.ice
@@ -0,0 +1,32 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Test.ice>
+
+module Test
+{
+
+class PreservedClass extends BaseClass
+{
+ string pc;
+};
+
+exception Preserved1 extends KnownPreservedDerived
+{
+ BaseClass p1;
+};
+
+exception Preserved2 extends Preserved1
+{
+ BaseClass p2;
+};
+
+};
diff --git a/python/test/Ice/slicing/exceptions/Server.py b/python/test/Ice/slicing/exceptions/Server.py
new file mode 100755
index 00000000000..833c79bfcec
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/Server.py
@@ -0,0 +1,179 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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('-I. --all ServerPrivate.ice')
+import Test
+
+class TestI(Test.TestIntf):
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+ def baseAsBase(self, current=None):
+ b = Test.Base()
+ b.b = "Base.b"
+ raise b
+
+ def unknownDerivedAsBase(self, current=None):
+ d = Test.UnknownDerived()
+ d.b = "UnknownDerived.b"
+ d.ud = "UnknownDerived.ud"
+ raise d
+
+ def knownDerivedAsBase(self, current=None):
+ d = Test.KnownDerived()
+ d.b = "KnownDerived.b"
+ d.kd = "KnownDerived.kd"
+ raise d
+
+ def knownDerivedAsKnownDerived(self, current=None):
+ d = Test.KnownDerived()
+ d.b = "KnownDerived.b"
+ d.kd = "KnownDerived.kd"
+ raise d
+
+ def unknownIntermediateAsBase(self, current=None):
+ ui = Test.UnknownIntermediate()
+ ui.b = "UnknownIntermediate.b"
+ ui.ui = "UnknownIntermediate.ui"
+ raise ui
+
+ def knownIntermediateAsBase(self, current=None):
+ ki = Test.KnownIntermediate()
+ ki.b = "KnownIntermediate.b"
+ ki.ki = "KnownIntermediate.ki"
+ raise ki
+
+ def knownMostDerivedAsBase(self, current=None):
+ kmd = Test.KnownMostDerived()
+ kmd.b = "KnownMostDerived.b"
+ kmd.ki = "KnownMostDerived.ki"
+ kmd.kmd = "KnownMostDerived.kmd"
+ raise kmd
+
+ def knownIntermediateAsKnownIntermediate(self, current=None):
+ ki = Test.KnownIntermediate()
+ ki.b = "KnownIntermediate.b"
+ ki.ki = "KnownIntermediate.ki"
+ raise ki
+
+ def knownMostDerivedAsKnownIntermediate(self, current=None):
+ kmd = Test.KnownMostDerived()
+ kmd.b = "KnownMostDerived.b"
+ kmd.ki = "KnownMostDerived.ki"
+ kmd.kmd = "KnownMostDerived.kmd"
+ raise kmd
+
+ def knownMostDerivedAsKnownMostDerived(self, current=None):
+ kmd = Test.KnownMostDerived()
+ kmd.b = "KnownMostDerived.b"
+ kmd.ki = "KnownMostDerived.ki"
+ kmd.kmd = "KnownMostDerived.kmd"
+ raise kmd
+
+ def unknownMostDerived1AsBase(self, current=None):
+ umd1 = Test.UnknownMostDerived1()
+ umd1.b = "UnknownMostDerived1.b"
+ umd1.ki = "UnknownMostDerived1.ki"
+ umd1.umd1 = "UnknownMostDerived1.umd1"
+ raise umd1
+
+ def unknownMostDerived1AsKnownIntermediate(self, current=None):
+ umd1 = Test.UnknownMostDerived1()
+ umd1.b = "UnknownMostDerived1.b"
+ umd1.ki = "UnknownMostDerived1.ki"
+ umd1.umd1 = "UnknownMostDerived1.umd1"
+ raise umd1
+
+ def unknownMostDerived2AsBase(self, current=None):
+ umd2 = Test.UnknownMostDerived2()
+ umd2.b = "UnknownMostDerived2.b"
+ umd2.ui = "UnknownMostDerived2.ui"
+ umd2.umd2 = "UnknownMostDerived2.umd2"
+ raise umd2
+
+ def unknownMostDerived2AsBaseCompact(self, current=None):
+ umd2 = Test.UnknownMostDerived2()
+ umd2.b = "UnknownMostDerived2.b"
+ umd2.ui = "UnknownMostDerived2.ui"
+ umd2.umd2 = "UnknownMostDerived2.umd2"
+ raise umd2
+
+ def knownPreservedAsBase(self, current=None):
+ ex = Test.KnownPreservedDerived()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ raise ex
+
+ def knownPreservedAsKnownPreserved(self, current=None):
+ ex = Test.KnownPreservedDerived()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ raise ex
+
+ def relayKnownPreservedAsBase(self, r, current=None):
+ r.knownPreservedAsBase()
+
+ def relayKnownPreservedAsKnownPreserved(self, r, current=None):
+ r.knownPreservedAsKnownPreserved()
+
+ def unknownPreservedAsBase(self, current=None):
+ ex = Test.SPreserved2()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ ex.p1 = Test.SPreservedClass("bc", "spc")
+ ex.p2 = ex.p1
+ raise ex
+
+ def unknownPreservedAsKnownPreserved(self, current=None):
+ ex = Test.SPreserved2()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ ex.p1 = Test.SPreservedClass("bc", "spc")
+ ex.p2 = ex.p1
+ raise ex
+
+ def relayUnknownPreservedAsBase(self, r, current=None):
+ r.unknownPreservedAsBase()
+
+ def relayUnknownPreservedAsKnownPreserved(self, r, current=None):
+ r.unknownPreservedAsKnownPreserved()
+
+def run(args, communicator):
+ properties = communicator.getProperties()
+ properties.setProperty("Ice.Warn.Dispatch", "0")
+ properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ object = TestI()
+ adapter.add(object, communicator.stringToIdentity("Test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/slicing/exceptions/ServerAMD.py b/python/test/Ice/slicing/exceptions/ServerAMD.py
new file mode 100755
index 00000000000..9a82839d7e9
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/ServerAMD.py
@@ -0,0 +1,197 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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('-I. --all ServerPrivateAMD.ice')
+import Test
+
+class TestI(Test.TestIntf):
+ def shutdown_async(self, cb, current=None):
+ current.adapter.getCommunicator().shutdown()
+ cb.ice_response()
+
+ def baseAsBase_async(self, cb, current=None):
+ b = Test.Base()
+ b.b = "Base.b"
+ cb.ice_exception(b)
+
+ def unknownDerivedAsBase_async(self, cb, current=None):
+ d = Test.UnknownDerived()
+ d.b = "UnknownDerived.b"
+ d.ud = "UnknownDerived.ud"
+ cb.ice_exception(d)
+
+ def knownDerivedAsBase_async(self, cb, current=None):
+ d = Test.KnownDerived()
+ d.b = "KnownDerived.b"
+ d.kd = "KnownDerived.kd"
+ cb.ice_exception(d)
+
+ def knownDerivedAsKnownDerived_async(self, cb, current=None):
+ d = Test.KnownDerived()
+ d.b = "KnownDerived.b"
+ d.kd = "KnownDerived.kd"
+ cb.ice_exception(d)
+
+ def unknownIntermediateAsBase_async(self, cb, current=None):
+ ui = Test.UnknownIntermediate()
+ ui.b = "UnknownIntermediate.b"
+ ui.ui = "UnknownIntermediate.ui"
+ cb.ice_exception(ui)
+
+ def knownIntermediateAsBase_async(self, cb, current=None):
+ ki = Test.KnownIntermediate()
+ ki.b = "KnownIntermediate.b"
+ ki.ki = "KnownIntermediate.ki"
+ cb.ice_exception(ki)
+
+ def knownMostDerivedAsBase_async(self, cb, current=None):
+ kmd = Test.KnownMostDerived()
+ kmd.b = "KnownMostDerived.b"
+ kmd.ki = "KnownMostDerived.ki"
+ kmd.kmd = "KnownMostDerived.kmd"
+ cb.ice_exception(kmd)
+
+ def knownIntermediateAsKnownIntermediate_async(self, cb, current=None):
+ ki = Test.KnownIntermediate()
+ ki.b = "KnownIntermediate.b"
+ ki.ki = "KnownIntermediate.ki"
+ cb.ice_exception(ki)
+
+ def knownMostDerivedAsKnownIntermediate_async(self, cb, current=None):
+ kmd = Test.KnownMostDerived()
+ kmd.b = "KnownMostDerived.b"
+ kmd.ki = "KnownMostDerived.ki"
+ kmd.kmd = "KnownMostDerived.kmd"
+ cb.ice_exception(kmd)
+
+ def knownMostDerivedAsKnownMostDerived_async(self, cb, current=None):
+ kmd = Test.KnownMostDerived()
+ kmd.b = "KnownMostDerived.b"
+ kmd.ki = "KnownMostDerived.ki"
+ kmd.kmd = "KnownMostDerived.kmd"
+ cb.ice_exception(kmd)
+
+ def unknownMostDerived1AsBase_async(self, cb, current=None):
+ umd1 = Test.UnknownMostDerived1()
+ umd1.b = "UnknownMostDerived1.b"
+ umd1.ki = "UnknownMostDerived1.ki"
+ umd1.umd1 = "UnknownMostDerived1.umd1"
+ cb.ice_exception(umd1)
+
+ def unknownMostDerived1AsKnownIntermediate_async(self, cb, current=None):
+ umd1 = Test.UnknownMostDerived1()
+ umd1.b = "UnknownMostDerived1.b"
+ umd1.ki = "UnknownMostDerived1.ki"
+ umd1.umd1 = "UnknownMostDerived1.umd1"
+ cb.ice_exception(umd1)
+
+ def unknownMostDerived2AsBase_async(self, cb, current=None):
+ umd2 = Test.UnknownMostDerived2()
+ umd2.b = "UnknownMostDerived2.b"
+ umd2.ui = "UnknownMostDerived2.ui"
+ umd2.umd2 = "UnknownMostDerived2.umd2"
+ cb.ice_exception(umd2)
+
+ def unknownMostDerived2AsBaseCompact_async(self, cb, current=None):
+ umd2 = Test.UnknownMostDerived2()
+ umd2.b = "UnknownMostDerived2.b"
+ umd2.ui = "UnknownMostDerived2.ui"
+ umd2.umd2 = "UnknownMostDerived2.umd2"
+ cb.ice_exception(umd2)
+
+ def knownPreservedAsBase_async(self, cb, r, current=None):
+ ex = Test.KnownPreservedDerived()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ cb.ice_exception(ex)
+
+ def knownPreservedAsKnownPreserved_async(self, cb, r, current=None):
+ ex = Test.KnownPreservedDerived()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ cb.ice_exception(ex)
+
+ def relayKnownPreservedAsBase_async(self, cb, r, current=None):
+ try:
+ r.knownPreservedAsBase()
+ test(False)
+ except Ice.Exception as ex:
+ cb.ice_exception(ex)
+
+ def relayKnownPreservedAsKnownPreserved_async(self, cb, r, current=None):
+ try:
+ r.knownPreservedAsKnownPreserved()
+ test(False)
+ except Ice.Exception as ex:
+ cb.ice_exception(ex)
+
+ def unknownPreservedAsBase_async(self, cb, r, current=None):
+ ex = Test.SPreserved2()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ ex.p1 = Test.SPreservedClass("bc", "spc")
+ ex.p2 = ex.p1
+ cb.ice_exception(ex)
+
+ def unknownPreservedAsKnownPreserved_async(self, cb, r, current=None):
+ ex = Test.SPreserved2()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.kpd = "derived"
+ ex.p1 = Test.SPreservedClass("bc", "spc")
+ ex.p2 = ex.p1
+ cb.ice_exception(ex)
+
+ def relayUnknownPreservedAsBase_async(self, cb, r, current=None):
+ try:
+ r.unknownPreservedAsBase()
+ test(False)
+ except Ice.Exception as ex:
+ cb.ice_exception(ex)
+
+ def relayUnknownPreservedAsKnownPreserved_async(self, cb, r, current=None):
+ try:
+ r.unknownPreservedAsKnownPreserved()
+ test(False)
+ except Ice.Exception as ex:
+ cb.ice_exception(ex)
+
+def run(args, communicator):
+ properties = communicator.getProperties()
+ properties.setProperty("Ice.Warn.Dispatch", "0")
+ properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ object = TestI()
+ adapter.add(object, communicator.stringToIdentity("Test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/slicing/exceptions/ServerPrivate.ice b/python/test/Ice/slicing/exceptions/ServerPrivate.ice
new file mode 100644
index 00000000000..23284dcda1a
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/ServerPrivate.ice
@@ -0,0 +1,52 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Test.ice>
+
+module Test
+{
+
+exception UnknownDerived extends Base
+{
+ string ud;
+};
+
+exception UnknownIntermediate extends Base
+{
+ string ui;
+};
+
+exception UnknownMostDerived1 extends KnownIntermediate
+{
+ string umd1;
+};
+
+exception UnknownMostDerived2 extends UnknownIntermediate
+{
+ string umd2;
+};
+
+class SPreservedClass extends BaseClass
+{
+ string spc;
+};
+
+exception SPreserved1 extends KnownPreservedDerived
+{
+ BaseClass p1;
+};
+
+exception SPreserved2 extends SPreserved1
+{
+ BaseClass p2;
+};
+
+};
diff --git a/python/test/Ice/slicing/exceptions/ServerPrivateAMD.ice b/python/test/Ice/slicing/exceptions/ServerPrivateAMD.ice
new file mode 100644
index 00000000000..6f9a3259c09
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/ServerPrivateAMD.ice
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <TestAMD.ice>
+
+module Test
+{
+
+exception UnknownDerived extends Base
+{
+ string ud;
+};
+
+exception UnknownIntermediate extends Base
+{
+ string ui;
+};
+
+exception UnknownMostDerived1 extends KnownIntermediate
+{
+ string umd1;
+};
+
+exception UnknownMostDerived2 extends UnknownIntermediate
+{
+ string umd2;
+};
+
+};
diff --git a/python/test/Ice/slicing/exceptions/Test.ice b/python/test/Ice/slicing/exceptions/Test.ice
new file mode 100644
index 00000000000..e81c34580f6
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/Test.ice
@@ -0,0 +1,98 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+exception Base
+{
+ string b;
+};
+
+exception KnownDerived extends Base
+{
+ string kd;
+};
+
+exception KnownIntermediate extends Base
+{
+ string ki;
+};
+
+exception KnownMostDerived extends KnownIntermediate
+{
+ string kmd;
+};
+
+["preserve-slice"]
+exception KnownPreserved extends Base
+{
+ string kp;
+};
+
+exception KnownPreservedDerived extends KnownPreserved
+{
+ string kpd;
+};
+
+["preserve-slice"]
+class BaseClass
+{
+ string bc;
+};
+
+["format:sliced"]
+interface Relay
+{
+ void knownPreservedAsBase() throws Base;
+ void knownPreservedAsKnownPreserved() throws KnownPreserved;
+
+ void unknownPreservedAsBase() throws Base;
+ void unknownPreservedAsKnownPreserved() throws KnownPreserved;
+};
+
+["format:sliced"]
+interface TestIntf
+{
+ void baseAsBase() throws Base;
+ void unknownDerivedAsBase() throws Base;
+ void knownDerivedAsBase() throws Base;
+ void knownDerivedAsKnownDerived() throws KnownDerived;
+
+ void unknownIntermediateAsBase() throws Base;
+ void knownIntermediateAsBase() throws Base;
+ void knownMostDerivedAsBase() throws Base;
+ void knownIntermediateAsKnownIntermediate() throws KnownIntermediate;
+ void knownMostDerivedAsKnownIntermediate() throws KnownIntermediate;
+ void knownMostDerivedAsKnownMostDerived() throws KnownMostDerived;
+
+ void unknownMostDerived1AsBase() throws Base;
+ void unknownMostDerived1AsKnownIntermediate() throws KnownIntermediate;
+ void unknownMostDerived2AsBase() throws Base;
+
+ ["format:compact"] void unknownMostDerived2AsBaseCompact() throws Base;
+
+ void knownPreservedAsBase() throws Base;
+ void knownPreservedAsKnownPreserved() throws KnownPreserved;
+
+ void relayKnownPreservedAsBase(Relay* r) throws Base;
+ void relayKnownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved;
+
+ void unknownPreservedAsBase() throws Base;
+ void unknownPreservedAsKnownPreserved() throws KnownPreserved;
+
+ void relayUnknownPreservedAsBase(Relay* r) throws Base;
+ void relayUnknownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved;
+
+ void shutdown();
+};
+
+};
diff --git a/python/test/Ice/slicing/exceptions/TestAMD.ice b/python/test/Ice/slicing/exceptions/TestAMD.ice
new file mode 100644
index 00000000000..4a564781d4a
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/TestAMD.ice
@@ -0,0 +1,98 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+exception Base
+{
+ string b;
+};
+
+exception KnownDerived extends Base
+{
+ string kd;
+};
+
+exception KnownIntermediate extends Base
+{
+ string ki;
+};
+
+exception KnownMostDerived extends KnownIntermediate
+{
+ string kmd;
+};
+
+["preserve-slice"]
+exception KnownPreserved extends Base
+{
+ string kp;
+};
+
+exception KnownPreservedDerived extends KnownPreserved
+{
+ string kpd;
+};
+
+["preserve-slice"]
+class BaseClass
+{
+ string bc;
+};
+
+["format:sliced"]
+interface Relay
+{
+ void knownPreservedAsBase() throws Base;
+ void knownPreservedAsKnownPreserved() throws KnownPreserved;
+
+ void unknownPreservedAsBase() throws Base;
+ void unknownPreservedAsKnownPreserved() throws KnownPreserved;
+};
+
+["amd", "format:sliced"]
+interface TestIntf
+{
+ void baseAsBase() throws Base;
+ void unknownDerivedAsBase() throws Base;
+ void knownDerivedAsBase() throws Base;
+ void knownDerivedAsKnownDerived() throws KnownDerived;
+
+ void unknownIntermediateAsBase() throws Base;
+ void knownIntermediateAsBase() throws Base;
+ void knownMostDerivedAsBase() throws Base;
+ void knownIntermediateAsKnownIntermediate() throws KnownIntermediate;
+ void knownMostDerivedAsKnownIntermediate() throws KnownIntermediate;
+ void knownMostDerivedAsKnownMostDerived() throws KnownMostDerived;
+
+ void unknownMostDerived1AsBase() throws Base;
+ void unknownMostDerived1AsKnownIntermediate() throws KnownIntermediate;
+ void unknownMostDerived2AsBase() throws Base;
+
+ ["format:compact"] void unknownMostDerived2AsBaseCompact() throws Base;
+
+ void knownPreservedAsBase() throws Base;
+ void knownPreservedAsKnownPreserved() throws KnownPreserved;
+
+ void relayKnownPreservedAsBase(Relay* r) throws Base;
+ void relayKnownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved;
+
+ void unknownPreservedAsBase() throws Base;
+ void unknownPreservedAsKnownPreserved() throws KnownPreserved;
+
+ void relayUnknownPreservedAsBase(Relay* r) throws Base;
+ void relayUnknownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved;
+
+ void shutdown();
+};
+
+};
diff --git a/python/test/Ice/slicing/exceptions/run.py b/python/test/Ice/slicing/exceptions/run.py
new file mode 100755
index 00000000000..95757ae246f
--- /dev/null
+++ b/python/test/Ice/slicing/exceptions/run.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../..", "../../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("Running test with sliced format.")
+TestUtil.clientServerTest()
+
+print("Running test with 1.0 encoding.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
+
+print("Running test with sliced format and AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py")
+
+print("Running test with 1.0 encoding and AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py",
+ additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
diff --git a/python/test/Ice/slicing/objects/AllTests.py b/python/test/Ice/slicing/objects/AllTests.py
new file mode 100644
index 00000000000..c73a8df0b01
--- /dev/null
+++ b/python/test/Ice/slicing/objects/AllTests.py
@@ -0,0 +1,1833 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, gc, sys, threading
+
+Ice.loadSlice('-I. --all Forward.ice ClientPrivate.ice')
+import Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class CallbackBase:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def check(self):
+ self._cond.acquire()
+ try:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ finally:
+ self._cond.release()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+class Callback(CallbackBase):
+ def response_SBaseAsObject(self, o):
+ test(o)
+ test(o.ice_id() == "::Test::SBase")
+ sb = o
+ test(isinstance(sb, Test.SBase))
+ test(sb.sb == "SBase.sb")
+ self.called()
+
+ def response_SBaseAsSBase(self, sb):
+ test(sb.sb == "SBase.sb")
+ self.called()
+
+ def response_SBSKnownDerivedAsSBase(self, sb):
+ sbskd = sb
+ test(isinstance(sbskd, Test.SBSKnownDerived))
+ test(sbskd.sbskd == "SBSKnownDerived.sbskd")
+ self.called()
+
+ def response_SBSKnownDerivedAsSBSKnownDerived(self, sbskd):
+ test(sbskd.sbskd == "SBSKnownDerived.sbskd")
+ self.called()
+
+ def response_SBSUnknownDerivedAsSBase(self, sb):
+ test(sb.sb == "SBSUnknownDerived.sb")
+ self.called()
+
+ def response_SBSUnknownDerivedAsSBaseCompact(self, sb):
+ test(False)
+
+ def exception_SBSUnknownDerivedAsSBaseCompact(self, ex):
+ test(isinstance(ex, Ice.NoObjectFactoryException))
+ self.called()
+
+ def response_SUnknownAsObject10(self, o):
+ test(False)
+
+ def exception_SUnknownAsObject10(self, exc):
+ test(exc.ice_name() == "Ice::NoObjectFactoryException")
+ self.called()
+
+ def response_SUnknownAsObject11(self, o):
+ test(isinstance(o, Ice.UnknownSlicedObject))
+ test(o.unknownTypeId == "::Test::SUnknown")
+ self.called()
+
+ def exception_SUnknownAsObject11(self, exc):
+ test(False)
+
+ def response_oneElementCycle(self, b):
+ test(b)
+ test(b.ice_id() == "::Test::B")
+ test(b.sb == "B1.sb")
+ test(b.pb == b)
+ self.called()
+
+ def response_twoElementCycle(self, b1):
+ test(b1)
+ test(b1.ice_id() == "::Test::B")
+ test(b1.sb == "B1.sb")
+
+ b2 = b1.pb
+ test(b2)
+ test(b2.ice_id() == "::Test::B")
+ test(b2.sb == "B2.sb")
+ test(b2.pb == b1)
+ self.called()
+
+ def response_D1AsB(self, b1):
+ test(b1)
+ test(b1.ice_id() == "::Test::D1")
+ test(b1.sb == "D1.sb")
+ test(b1.pb)
+ test(b1.pb != b1)
+ d1 = b1
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == "D1.sd1")
+ test(d1.pd1)
+ test(d1.pd1 != b1)
+ test(b1.pb == d1.pd1)
+
+ b2 = b1.pb
+ test(b2)
+ test(b2.pb == b1)
+ test(b2.sb == "D2.sb")
+ test(b2.ice_id() == "::Test::B")
+ self.called()
+
+ def response_D1AsD1(self, d1):
+ test(d1)
+ test(d1.ice_id() == "::Test::D1")
+ test(d1.sb == "D1.sb")
+ test(d1.pb)
+ test(d1.pb != d1)
+
+ b2 = d1.pb
+ test(b2)
+ test(b2.ice_id() == "::Test::B")
+ test(b2.sb == "D2.sb")
+ test(b2.pb == d1)
+ self.called()
+
+ def response_D2AsB(self, b2):
+ test(b2)
+ test(b2.ice_id() == "::Test::B")
+ test(b2.sb == "D2.sb")
+ test(b2.pb)
+ test(b2.pb != b2)
+
+ b1 = b2.pb
+ test(b1)
+ test(b1.ice_id() == "::Test::D1")
+ test(b1.sb == "D1.sb")
+ test(b1.pb == b2)
+ d1 = b1
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == "D1.sd1")
+ test(d1.pd1 == b2)
+ self.called()
+
+ def response_paramTest1(self, b1, b2):
+ test(b1)
+ test(b1.ice_id() == "::Test::D1")
+ test(b1.sb == "D1.sb")
+ test(b1.pb == b2)
+ d1 = b1
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == "D1.sd1")
+ test(d1.pd1 == b2)
+
+ test(b2)
+ test(b2.ice_id() == "::Test::B") # No factory, must be sliced
+ test(b2.sb == "D2.sb")
+ test(b2.pb == b1)
+ self.called()
+
+ def response_returnTest1(self, r, p1, p2):
+ test(r == p1)
+ self.called()
+
+ def response_returnTest2(self, r, p1, p2):
+ test(r == p1)
+ self.called()
+
+ def response_returnTest3(self, b):
+ self.r = b
+ self.called()
+
+ def response_paramTest3(self, ret, p1, p2):
+ test(p1)
+ test(p1.sb == "D2.sb (p1 1)")
+ test(p1.pb == None)
+ test(p1.ice_id() == "::Test::B")
+
+ test(p2)
+ test(p2.sb == "D2.sb (p2 1)")
+ test(p2.pb == None)
+ test(p2.ice_id() == "::Test::B")
+
+ test(ret)
+ test(ret.sb == "D1.sb (p2 2)")
+ test(ret.pb == None)
+ test(ret.ice_id() == "::Test::D1")
+ self.called()
+
+ def response_paramTest4(self, ret, b):
+ test(b)
+ test(b.sb == "D4.sb (1)")
+ test(b.pb == None)
+ test(b.ice_id() == "::Test::B")
+
+ test(ret)
+ test(ret.sb == "B.sb (2)")
+ test(ret.pb == None)
+ test(ret.ice_id() == "::Test::B")
+ self.called()
+
+ def response_sequenceTest(self, ss):
+ self.r = ss
+ self.called()
+
+ def response_dictionaryTest(self, r, bout):
+ self.r = r
+ self.bout = bout
+ self.called()
+
+ def exception_throwBaseAsBase(self, ex):
+ test(ex.ice_name() == "Test::BaseException")
+ e = ex
+ test(isinstance(e, Test.BaseException))
+ test(e.sbe == "sbe")
+ test(e.pb)
+ test(e.pb.sb == "sb")
+ test(e.pb.pb == e.pb)
+ self.called()
+
+ def exception_throwDerivedAsBase(self, ex):
+ test(ex.ice_name() == "Test::DerivedException")
+ e = ex
+ test(isinstance(e, Test.DerivedException))
+ test(e.sbe == "sbe")
+ test(e.pb)
+ test(e.pb.sb == "sb1")
+ test(e.pb.pb == e.pb)
+ test(e.sde == "sde1")
+ test(e.pd1)
+ test(e.pd1.sb == "sb2")
+ test(e.pd1.pb == e.pd1)
+ test(e.pd1.sd1 == "sd2")
+ test(e.pd1.pd1 == e.pd1)
+ self.called()
+
+ def exception_throwDerivedAsDerived(self, ex):
+ test(ex.ice_name() == "Test::DerivedException")
+ e = ex
+ test(isinstance(e, Test.DerivedException))
+ test(e.sbe == "sbe")
+ test(e.pb)
+ test(e.pb.sb == "sb1")
+ test(e.pb.pb == e.pb)
+ test(e.sde == "sde1")
+ test(e.pd1)
+ test(e.pd1.sb == "sb2")
+ test(e.pd1.pb == e.pd1)
+ test(e.pd1.sd1 == "sd2")
+ test(e.pd1.pd1 == e.pd1)
+ self.called()
+
+ def exception_throwUnknownDerivedAsBase(self, ex):
+ test(ex.ice_name() == "Test::BaseException")
+ e = ex
+ test(isinstance(e, Test.BaseException))
+ test(e.sbe == "sbe")
+ test(e.pb)
+ test(e.pb.sb == "sb d2")
+ test(e.pb.pb == e.pb)
+ self.called()
+
+ def response_useForward(self, f):
+ test(f)
+ self.called()
+
+ def response_preserved1(self, r):
+ test(r)
+ test(isinstance(r, Test.PDerived))
+ test(r.pi == 3)
+ test(r.ps == "preserved")
+ test(r.pb == r)
+ self.called()
+
+ def response_preserved2(self, r):
+ test(r)
+ test(not isinstance(r, Test.PCUnknown))
+ test(r.pi == 3)
+ self.called()
+
+ def response_preserved3(self, r):
+ #
+ # Encoding 1.0
+ #
+ test(not isinstance(r, Test.PCDerived))
+ test(r.pi == 3)
+ self.called()
+
+ def response_preserved4(self, r):
+ #
+ # Encoding > 1.0
+ #
+ test(isinstance(r, Test.PCDerived))
+ test(r.pi == 3)
+ test(r.pbs[0] == r)
+ self.called()
+
+ def response_preserved5(self, r):
+ test(isinstance(r, Test.PCDerived3))
+ test(r.pi == 3)
+ for i in range(0, 300):
+ p2 = r.pbs[i]
+ test(isinstance(p2, Test.PCDerived2))
+ test(p2.pi == i)
+ test(len(p2.pbs) == 1)
+ test(not p2.pbs[0])
+ test(p2.pcd2 == i)
+ test(r.pcd2 == r.pi)
+ test(r.pcd3 == r.pbs[10])
+ self.called()
+
+ def response_compactPreserved1(self, r):
+ #
+ # Encoding 1.0
+ #
+ test(not isinstance(r, Test.CompactPCDerived))
+ test(r.pi == 3)
+ self.called()
+
+ def response_compactPreserved2(self, r):
+ #
+ # Encoding > 1.0
+ #
+ test(isinstance(r, Test.CompactPCDerived))
+ test(r.pi == 3)
+ test(r.pbs[0] == r)
+ self.called()
+
+ def response(self):
+ test(False)
+
+ def exception(self, exc):
+ if(isinstance(exc, Ice.OperationNotExistException)):
+ self.called()
+ return
+ test(False)
+
+class PNodeI(Test.PNode):
+ counter = 0
+
+ def __init__(self):
+ PNodeI.counter = PNodeI.counter + 1
+
+ def __del__(self):
+ PNodeI.counter = PNodeI.counter - 1
+
+class NodeFactoryI(Ice.ObjectFactory):
+ def create(self, id):
+ if id == Test.PNode.ice_staticId():
+ return PNodeI()
+ return None
+
+ def destroy(self):
+ pass
+
+class PreservedI(Test.Preserved):
+ counter = 0
+
+ def __init__(self):
+ PreservedI.counter = PreservedI.counter + 1
+
+ def __del__(self):
+ PreservedI.counter = PreservedI.counter - 1
+
+class PreservedFactoryI(Ice.ObjectFactory):
+ def create(self, id):
+ if id == Test.Preserved.ice_staticId():
+ return PreservedI()
+ return None
+
+ def destroy(self):
+ pass
+
+def allTests(communicator):
+ obj = communicator.stringToProxy("Test:default -p 12010")
+ t = Test.TestIntfPrx.checkedCast(obj)
+
+ sys.stdout.write("base as Object... ")
+ sys.stdout.flush()
+ o = None
+ try:
+ o = t.SBaseAsObject()
+ test(o)
+ test(o.ice_id() == "::Test::SBase")
+ except Ice.Exception:
+ test(False)
+ sb = o
+ test(isinstance(sb, Test.SBase))
+ test(sb)
+ test(sb.sb == "SBase.sb")
+ print("ok")
+
+ sys.stdout.write("base as Object (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_SBaseAsObject(cb.response_SBaseAsObject, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("base as base... ")
+ sys.stdout.flush()
+ try:
+ sb = t.SBaseAsSBase()
+ test(sb.sb == "SBase.sb")
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("base as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_SBaseAsSBase(cb.response_SBaseAsSBase, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("base with known derived as base... ")
+ sys.stdout.flush()
+ try:
+ sb = t.SBSKnownDerivedAsSBase()
+ test(sb.sb == "SBSKnownDerived.sb")
+ except Ice.Exception:
+ test(False)
+ sbskd = sb
+ test(isinstance(sbskd, Test.SBSKnownDerived))
+ test(sbskd)
+ test(sbskd.sbskd == "SBSKnownDerived.sbskd")
+ print("ok")
+
+ sys.stdout.write("base with known derived as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_SBSKnownDerivedAsSBase(cb.response_SBSKnownDerivedAsSBase, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("base with known derived as known derived... ")
+ sys.stdout.flush()
+ try:
+ sbskd = t.SBSKnownDerivedAsSBSKnownDerived()
+ test(sbskd.sbskd == "SBSKnownDerived.sbskd")
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("base with known derived as known derived (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_SBSKnownDerivedAsSBSKnownDerived(cb.response_SBSKnownDerivedAsSBSKnownDerived, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("base with unknown derived as base... ")
+ sys.stdout.flush()
+ try:
+ sb = t.SBSUnknownDerivedAsSBase()
+ test(sb.sb == "SBSUnknownDerived.sb")
+ except Ice.Exception:
+ test(False)
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ try:
+ #
+ # This test succeeds for the 1.0 encoding.
+ #
+ sb = t.SBSUnknownDerivedAsSBaseCompact()
+ test(sb.sb == "SBSUnknownDerived.sb")
+ except Ice.OperationNotExistException:
+ pass
+ except:
+ test(False)
+ else:
+ try:
+ #
+ # This test fails when using the compact format because the instance cannot
+ # be sliced to a known type.
+ #
+ sb = t.SBSUnknownDerivedAsSBaseCompact()
+ test(False)
+ except Ice.OperationNotExistException:
+ pass
+ except Ice.NoObjectFactoryException:
+ # Expected.
+ pass
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("base with unknown derived as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_SBSUnknownDerivedAsSBase(cb.response_SBSUnknownDerivedAsSBase, cb.exception)
+ cb.check()
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ #
+ # This test succeeds for the 1.0 encoding.
+ #
+ cb = Callback()
+ t.begin_SBSUnknownDerivedAsSBaseCompact(cb.response_SBSUnknownDerivedAsSBase, cb.exception)
+ cb.check()
+ else:
+ #
+ # This test fails when using the compact format because the instance cannot
+ # be sliced to a known type.
+ #
+ cb = Callback()
+ t.begin_SBSUnknownDerivedAsSBaseCompact(cb.response_SBSUnknownDerivedAsSBaseCompact,
+ cb.exception_SBSUnknownDerivedAsSBaseCompact)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("unknown with Object as Object... ")
+ sys.stdout.flush()
+ try:
+ o = t.SUnknownAsObject()
+ test(t.ice_getEncodingVersion() != Ice.Encoding_1_0)
+ test(isinstance(o, Ice.UnknownSlicedObject))
+ test(o.unknownTypeId == "::Test::SUnknown")
+ t.checkSUnknown(o)
+ except Ice.NoObjectFactoryException:
+ test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("unknown with Object as Object (AMI)... ")
+ sys.stdout.flush()
+ try:
+ cb = Callback()
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ t.begin_SUnknownAsObject(cb.response_SUnknownAsObject10, cb.exception_SUnknownAsObject10)
+ else:
+ t.begin_SUnknownAsObject(cb.response_SUnknownAsObject11, cb.exception_SUnknownAsObject11)
+ cb.check()
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("one-element cycle... ")
+ sys.stdout.flush()
+ try:
+ b = t.oneElementCycle()
+ test(b)
+ test(b.ice_id() == "::Test::B")
+ test(b.sb == "B1.sb")
+ test(b.pb == b)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("one-element cycle (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_oneElementCycle(cb.response_oneElementCycle, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("two-element cycle... ")
+ sys.stdout.flush()
+ try:
+ b1 = t.twoElementCycle()
+ test(b1)
+ test(b1.ice_id() == "::Test::B")
+ test(b1.sb == "B1.sb")
+
+ b2 = b1.pb
+ test(b2)
+ test(b2.ice_id() == "::Test::B")
+ test(b2.sb == "B2.sb")
+ test(b2.pb == b1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("two-element cycle (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_twoElementCycle(cb.response_twoElementCycle, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("known derived pointer slicing as base... ")
+ sys.stdout.flush()
+ try:
+ b1 = t.D1AsB()
+ test(b1)
+ test(b1.ice_id() == "::Test::D1")
+ test(b1.sb == "D1.sb")
+ test(b1.pb)
+ test(b1.pb != b1)
+ d1 = b1
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == "D1.sd1")
+ test(d1.pd1)
+ test(d1.pd1 != b1)
+ test(b1.pb == d1.pd1)
+
+ b2 = b1.pb
+ test(b2)
+ test(b2.pb == b1)
+ test(b2.sb == "D2.sb")
+ test(b2.ice_id() == "::Test::B")
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("known derived pointer slicing as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_D1AsB(cb.response_D1AsB, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("known derived pointer slicing as derived... ")
+ sys.stdout.flush()
+ try:
+ d1 = t.D1AsD1()
+ test(d1)
+ test(d1.ice_id() == "::Test::D1")
+ test(d1.sb == "D1.sb")
+ test(d1.pb)
+ test(d1.pb != d1)
+
+ b2 = d1.pb
+ test(b2)
+ test(b2.ice_id() == "::Test::B")
+ test(b2.sb == "D2.sb")
+ test(b2.pb == d1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("known derived pointer slicing as derived (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_D1AsD1(cb.response_D1AsD1, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("unknown derived pointer slicing as base... ")
+ sys.stdout.flush()
+ try:
+ b2 = t.D2AsB()
+ test(b2)
+ test(b2.ice_id() == "::Test::B")
+ test(b2.sb == "D2.sb")
+ test(b2.pb)
+ test(b2.pb != b2)
+
+ b1 = b2.pb
+ test(b1)
+ test(b1.ice_id() == "::Test::D1")
+ test(b1.sb == "D1.sb")
+ test(b1.pb == b2)
+ d1 = b1
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == "D1.sd1")
+ test(d1.pd1 == b2)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("unknown derived pointer slicing as base (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_D2AsB(cb.response_D2AsB, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("param ptr slicing with known first... ")
+ sys.stdout.flush()
+ try:
+ b1, b2 = t.paramTest1()
+
+ test(b1)
+ test(b1.ice_id() == "::Test::D1")
+ test(b1.sb == "D1.sb")
+ test(b1.pb == b2)
+ d1 = b1
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == "D1.sd1")
+ test(d1.pd1 == b2)
+
+ test(b2)
+ test(b2.ice_id() == "::Test::B") # No factory, must be sliced
+ test(b2.sb == "D2.sb")
+ test(b2.pb == b1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("param ptr slicing with known first (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_paramTest1(cb.response_paramTest1, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("param ptr slicing with unknown first... ")
+ sys.stdout.flush()
+ try:
+ b2, b1 = t.paramTest2()
+
+ test(b1)
+ test(b1.ice_id() == "::Test::D1")
+ test(b1.sb == "D1.sb")
+ test(b1.pb == b2)
+ d1 = b1
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == "D1.sd1")
+ test(d1.pd1 == b2)
+
+ test(b2)
+ test(b2.ice_id() == "::Test::B") # No factory, must be sliced
+ test(b2.sb == "D2.sb")
+ test(b2.pb == b1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("return value identity with known first... ")
+ sys.stdout.flush()
+ try:
+ r, p1, p2 = t.returnTest1()
+ test(r == p1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("return value identity with known first (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_returnTest1(cb.response_returnTest1, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("return value identity with unknown first... ")
+ sys.stdout.flush()
+ try:
+ r, p1, p2 = t.returnTest2()
+ test(r == p1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("return value identity with unknown first (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_returnTest2(cb.response_returnTest2, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("return value identity for input params known first... ")
+ sys.stdout.flush()
+ try:
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d3 = Test.D3()
+ d3.pb = d1
+ d3.sb = "D3.sb"
+ d3.sd3 = "D3.sd3"
+ d3.pd3 = d1
+ d1.pb = d3
+ d1.pd1 = d3
+
+ b1 = t.returnTest3(d1, d3)
+
+ test(b1)
+ test(b1.sb == "D1.sb")
+ test(b1.ice_id() == "::Test::D1")
+ p1 = b1
+ test(isinstance(p1, Test.D1))
+ test(p1.sd1 == "D1.sd1")
+ test(p1.pd1 == b1.pb)
+
+ b2 = b1.pb
+ test(b2)
+ test(b2.sb == "D3.sb")
+ test(b2.ice_id() == "::Test::B") # Sliced by server
+ test(b2.pb == b1)
+ p3 = b2
+ test(not isinstance(p3, Test.D3))
+
+ test(b1 != d1)
+ test(b1 != d3)
+ test(b2 != d1)
+ test(b2 != d3)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("return value identity for input params known first (AMI)... ")
+ sys.stdout.flush()
+ try:
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d3 = Test.D3()
+ d3.pb = d1
+ d3.sb = "D3.sb"
+ d3.sd3 = "D3.sd3"
+ d3.pd3 = d1
+ d1.pb = d3
+ d1.pd1 = d3
+
+ cb = Callback()
+ t.begin_returnTest3(d1, d3, cb.response_returnTest3, cb.exception)
+ cb.check()
+ b1 = cb.r
+
+ test(b1)
+ test(b1.sb == "D1.sb")
+ test(b1.ice_id() == "::Test::D1")
+ p1 = b1
+ test(isinstance(p1, Test.D1))
+ test(p1.sd1 == "D1.sd1")
+ test(p1.pd1 == b1.pb)
+
+ b2 = b1.pb
+ test(b2)
+ test(b2.sb == "D3.sb")
+ test(b2.ice_id() == "::Test::B") # Sliced by server
+ test(b2.pb == b1)
+ p3 = b2
+ test(not isinstance(p3, Test.D3))
+
+ test(b1 != d1)
+ test(b1 != d3)
+ test(b2 != d1)
+ test(b2 != d3)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("return value identity for input params unknown first... ")
+ sys.stdout.flush()
+ try:
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d3 = Test.D3()
+ d3.pb = d1
+ d3.sb = "D3.sb"
+ d3.sd3 = "D3.sd3"
+ d3.pd3 = d1
+ d1.pb = d3
+ d1.pd1 = d3
+
+ b1 = t.returnTest3(d3, d1)
+
+ test(b1)
+ test(b1.sb == "D3.sb")
+ test(b1.ice_id() == "::Test::B") # Sliced by server
+ p1 = b1
+ test(not isinstance(p1, Test.D3))
+
+ b2 = b1.pb
+ test(b2)
+ test(b2.sb == "D1.sb")
+ test(b2.ice_id() == "::Test::D1")
+ test(b2.pb == b1)
+ p3 = b2
+ test(isinstance(p3, Test.D1))
+ test(p3.sd1 == "D1.sd1")
+ test(p3.pd1 == b1)
+
+ test(b1 != d1)
+ test(b1 != d3)
+ test(b2 != d1)
+ test(b2 != d3)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("return value identity for input params unknown first (AMI)... ")
+ sys.stdout.flush()
+ try:
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d3 = Test.D3()
+ d3.pb = d1
+ d3.sb = "D3.sb"
+ d3.sd3 = "D3.sd3"
+ d3.pd3 = d1
+ d1.pb = d3
+ d1.pd1 = d3
+
+ cb = Callback()
+ t.begin_returnTest3(d3, d1, cb.response_returnTest3, cb.exception)
+ cb.check()
+ b1 = cb.r
+
+ test(b1)
+ test(b1.sb == "D3.sb")
+ test(b1.ice_id() == "::Test::B") # Sliced by server
+ p1 = b1
+ test(not isinstance(p1, Test.D3))
+
+ b2 = b1.pb
+ test(b2)
+ test(b2.sb == "D1.sb")
+ test(b2.ice_id() == "::Test::D1")
+ test(b2.pb == b1)
+ p3 = b2
+ test(isinstance(p3, Test.D1))
+ test(p3.sd1 == "D1.sd1")
+ test(p3.pd1 == b1)
+
+ test(b1 != d1)
+ test(b1 != d3)
+ test(b2 != d1)
+ test(b2 != d3)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("remainder unmarshaling (3 instances)... ")
+ sys.stdout.flush()
+ try:
+ ret, p1, p2 = t.paramTest3()
+
+ test(p1)
+ test(p1.sb == "D2.sb (p1 1)")
+ test(p1.pb == None)
+ test(p1.ice_id() == "::Test::B")
+
+ test(p2)
+ test(p2.sb == "D2.sb (p2 1)")
+ test(p2.pb == None)
+ test(p2.ice_id() == "::Test::B")
+
+ test(ret)
+ test(ret.sb == "D1.sb (p2 2)")
+ test(ret.pb == None)
+ test(ret.ice_id() == "::Test::D1")
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("remainder unmarshaling (3 instances) (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_paramTest3(cb.response_paramTest3, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("remainder unmarshaling (4 instances)... ")
+ sys.stdout.flush()
+ try:
+ ret, b = t.paramTest4()
+
+ test(b)
+ test(b.sb == "D4.sb (1)")
+ test(b.pb == None)
+ test(b.ice_id() == "::Test::B")
+
+ test(ret)
+ test(ret.sb == "B.sb (2)")
+ test(ret.pb == None)
+ test(ret.ice_id() == "::Test::B")
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("remainder unmarshaling (4 instances) (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_paramTest4(cb.response_paramTest4, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as base... ")
+ sys.stdout.flush()
+ try:
+ b1 = Test.B()
+ b1.sb = "B.sb(1)"
+ b1.pb = b1
+
+ d3 = Test.D3()
+ d3.sb = "D3.sb"
+ d3.pb = d3
+ d3.sd3 = "D3.sd3"
+ d3.pd3 = b1
+
+ b2 = Test.B()
+ b2.sb = "B.sb(2)"
+ b2.pb = b1
+
+ r = t.returnTest3(d3, b2)
+
+ test(r)
+ test(r.ice_id() == "::Test::B")
+ test(r.sb == "D3.sb")
+ test(r.pb == r)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as base (AMI)... ")
+ sys.stdout.flush()
+ try:
+ b1 = Test.B()
+ b1.sb = "B.sb(1)"
+ b1.pb = b1
+
+ d3 = Test.D3()
+ d3.sb = "D3.sb"
+ d3.pb = d3
+ d3.sd3 = "D3.sd3"
+ d3.pd3 = b1
+
+ b2 = Test.B()
+ b2.sb = "B.sb(2)"
+ b2.pb = b1
+
+ cb = Callback()
+ t.begin_returnTest3(d3, b2, cb.response_returnTest3, cb.exception)
+ cb.check()
+ r = cb.r
+
+ test(r)
+ test(r.ice_id() == "::Test::B")
+ test(r.sb == "D3.sb")
+ test(r.pb == r)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as derived... ")
+ sys.stdout.flush()
+ try:
+ d11 = Test.D1()
+ d11.sb = "D1.sb(1)"
+ d11.pb = d11
+ d11.sd1 = "D1.sd1(1)"
+ d11.pd1 = None
+
+ d3 = Test.D3()
+ d3.sb = "D3.sb"
+ d3.pb = d3
+ d3.sd3 = "D3.sd3"
+ d3.pd3 = d11
+
+ d12 = Test.D1()
+ d12.sb = "D1.sb(2)"
+ d12.pb = d12
+ d12.sd1 = "D1.sd1(2)"
+ d12.pd1 = d11
+
+ r = t.returnTest3(d3, d12)
+ test(r)
+ test(r.ice_id() == "::Test::B")
+ test(r.sb == "D3.sb")
+ test(r.pb == r)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as derived (AMI)... ")
+ sys.stdout.flush()
+ try:
+ d11 = Test.D1()
+ d11.sb = "D1.sb(1)"
+ d11.pb = d11
+ d11.sd1 = "D1.sd1(1)"
+ d11.pd1 = None
+
+ d3 = Test.D3()
+ d3.sb = "D3.sb"
+ d3.pb = d3
+ d3.sd3 = "D3.sd3"
+ d3.pd3 = d11
+
+ d12 = Test.D1()
+ d12.sb = "D1.sb(2)"
+ d12.pb = d12
+ d12.sd1 = "D1.sd1(2)"
+ d12.pd1 = d11
+
+ cb = Callback()
+ t.begin_returnTest3(d3, d12, cb.response_returnTest3, cb.exception)
+ cb.check()
+ r = cb.r
+
+ test(r)
+ test(r.ice_id() == "::Test::B")
+ test(r.sb == "D3.sb")
+ test(r.pb == r)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("sequence slicing... ")
+ sys.stdout.flush()
+ try:
+ ss = Test.SS3()
+ ss1b = Test.B()
+ ss1b.sb = "B.sb"
+ ss1b.pb = ss1b
+
+ ss1d1 = Test.D1()
+ ss1d1.sb = "D1.sb"
+ ss1d1.sd1 = "D1.sd1"
+ ss1d1.pb = ss1b
+
+ ss1d3 = Test.D3()
+ ss1d3.sb = "D3.sb"
+ ss1d3.sd3 = "D3.sd3"
+ ss1d3.pb = ss1b
+
+ ss2b = Test.B()
+ ss2b.sb = "B.sb"
+ ss2b.pb = ss1b
+
+ ss2d1 = Test.D1()
+ ss2d1.sb = "D1.sb"
+ ss2d1.sd1 = "D1.sd1"
+ ss2d1.pb = ss2b
+
+ ss2d3 = Test.D3()
+ ss2d3.sb = "D3.sb"
+ ss2d3.sd3 = "D3.sd3"
+ ss2d3.pb = ss2b
+
+ ss1d1.pd1 = ss2b
+ ss1d3.pd3 = ss2d1
+
+ ss2d1.pd1 = ss1d3
+ ss2d3.pd3 = ss1d1
+
+ ss1 = Test.SS1()
+ ss1.s = (ss1b, ss1d1, ss1d3)
+
+ ss2 = Test.SS2()
+ ss2.s = (ss2b, ss2d1, ss2d3)
+
+ ss = t.sequenceTest(ss1, ss2)
+
+ test(ss.c1)
+ ss1b = ss.c1.s[0]
+ ss1d1 = ss.c1.s[1]
+ test(ss.c2)
+ ss1d3 = ss.c1.s[2]
+
+ test(ss.c2)
+ ss2b = ss.c2.s[0]
+ ss2d1 = ss.c2.s[1]
+ ss2d3 = ss.c2.s[2]
+
+ test(ss1b.pb == ss1b)
+ test(ss1d1.pb == ss1b)
+ test(ss1d3.pb == ss1b)
+
+ test(ss2b.pb == ss1b)
+ test(ss2d1.pb == ss2b)
+ test(ss2d3.pb == ss2b)
+
+ test(ss1b.ice_id() == "::Test::B")
+ test(ss1d1.ice_id() == "::Test::D1")
+ test(ss1d3.ice_id() == "::Test::B")
+
+ test(ss2b.ice_id() == "::Test::B")
+ test(ss2d1.ice_id() == "::Test::D1")
+ test(ss2d3.ice_id() == "::Test::B")
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("sequence slicing (AMI)... ")
+ sys.stdout.flush()
+ try:
+ ss = Test.SS3()
+ ss1b = Test.B()
+ ss1b.sb = "B.sb"
+ ss1b.pb = ss1b
+
+ ss1d1 = Test.D1()
+ ss1d1.sb = "D1.sb"
+ ss1d1.sd1 = "D1.sd1"
+ ss1d1.pb = ss1b
+
+ ss1d3 = Test.D3()
+ ss1d3.sb = "D3.sb"
+ ss1d3.sd3 = "D3.sd3"
+ ss1d3.pb = ss1b
+
+ ss2b = Test.B()
+ ss2b.sb = "B.sb"
+ ss2b.pb = ss1b
+
+ ss2d1 = Test.D1()
+ ss2d1.sb = "D1.sb"
+ ss2d1.sd1 = "D1.sd1"
+ ss2d1.pb = ss2b
+
+ ss2d3 = Test.D3()
+ ss2d3.sb = "D3.sb"
+ ss2d3.sd3 = "D3.sd3"
+ ss2d3.pb = ss2b
+
+ ss1d1.pd1 = ss2b
+ ss1d3.pd3 = ss2d1
+
+ ss2d1.pd1 = ss1d3
+ ss2d3.pd3 = ss1d1
+
+ ss1 = Test.SS1()
+ ss1.s = (ss1b, ss1d1, ss1d3)
+
+ ss2 = Test.SS2()
+ ss2.s = (ss2b, ss2d1, ss2d3)
+
+ cb = Callback()
+ t.begin_sequenceTest(ss1, ss2, cb.response_sequenceTest, cb.exception)
+ cb.check()
+ ss = cb.r
+
+ test(ss.c1)
+ ss1b = ss.c1.s[0]
+ ss1d1 = ss.c1.s[1]
+ test(ss.c2)
+ ss1d3 = ss.c1.s[2]
+
+ test(ss.c2)
+ ss2b = ss.c2.s[0]
+ ss2d1 = ss.c2.s[1]
+ ss2d3 = ss.c2.s[2]
+
+ test(ss1b.pb == ss1b)
+ test(ss1d1.pb == ss1b)
+ test(ss1d3.pb == ss1b)
+
+ test(ss2b.pb == ss1b)
+ test(ss2d1.pb == ss2b)
+ test(ss2d3.pb == ss2b)
+
+ test(ss1b.ice_id() == "::Test::B")
+ test(ss1d1.ice_id() == "::Test::D1")
+ test(ss1d3.ice_id() == "::Test::B")
+
+ test(ss2b.ice_id() == "::Test::B")
+ test(ss2d1.ice_id() == "::Test::D1")
+ test(ss2d3.ice_id() == "::Test::B")
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("dictionary slicing... ")
+ sys.stdout.flush()
+ try:
+ bin = {}
+ for i in range(0, 10):
+ d1 = Test.D1()
+ s = "D1." + str(i)
+ d1.sb = s
+ d1.pb = d1
+ d1.sd1 = s
+ d1.pd1 = None
+ bin[i] = d1
+
+ r, bout = t.dictionaryTest(bin)
+
+ test(len(bout) == 10)
+ for i in range(0, 10):
+ b = bout[i * 10]
+ test(b)
+ s = "D1." + str(i)
+ test(b.sb == s)
+ test(b.pb)
+ test(b.pb != b)
+ test(b.pb.sb == s)
+ test(b.pb.pb == b.pb)
+
+ test(len(r) == 10)
+ for i in range(0, 10):
+ b = r[i * 20]
+ test(b)
+ s = "D1." + str(i * 20)
+ test(b.sb == s)
+ if i == 0:
+ test(b.pb == None)
+ else:
+ test(b.pb == r[(i - 1) * 20])
+ d1 = b
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == s)
+ test(d1.pd1 == d1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("dictionary slicing (AMI)... ")
+ sys.stdout.flush()
+ try:
+ bin = {}
+ for i in range(0, 10):
+ d1 = Test.D1()
+ s = "D1." + str(i)
+ d1.sb = s
+ d1.pb = d1
+ d1.sd1 = s
+ d1.pd1 = None
+ bin[i] = d1
+
+ cb = Callback()
+ t.begin_dictionaryTest(bin, cb.response_dictionaryTest, cb.exception)
+ cb.check()
+ bout = cb.bout
+ r = cb.r
+
+ test(len(bout) == 10)
+ for i in range(0, 10):
+ b = bout[i * 10]
+ test(b)
+ s = "D1." + str(i)
+ test(b.sb == s)
+ test(b.pb)
+ test(b.pb != b)
+ test(b.pb.sb == s)
+ test(b.pb.pb == b.pb)
+
+ test(len(r) == 10)
+ for i in range(0, 10):
+ b = r[i * 20]
+ test(b)
+ s = "D1." + str(i * 20)
+ test(b.sb == s)
+ if i == 0:
+ test(b.pb == None)
+ else:
+ test(b.pb == r[(i - 1) * 20])
+ d1 = b
+ test(isinstance(d1, Test.D1))
+ test(d1.sd1 == s)
+ test(d1.pd1 == d1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("base exception thrown as base exception... ")
+ sys.stdout.flush()
+ try:
+ t.throwBaseAsBase()
+ test(False)
+ except Test.BaseException as e:
+ test(e.ice_name() == "Test::BaseException")
+ test(e.sbe == "sbe")
+ test(e.pb)
+ test(e.pb.sb == "sb")
+ test(e.pb.pb == e.pb)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("base exception thrown as base exception (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_throwBaseAsBase(cb.response, cb.exception_throwBaseAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("derived exception thrown as base exception... ")
+ sys.stdout.flush()
+ try:
+ t.throwDerivedAsBase()
+ test(False)
+ except Test.DerivedException as e:
+ test(e.ice_name() == "Test::DerivedException")
+ test(e.sbe == "sbe")
+ test(e.pb)
+ test(e.pb.sb == "sb1")
+ test(e.pb.pb == e.pb)
+ test(e.sde == "sde1")
+ test(e.pd1)
+ test(e.pd1.sb == "sb2")
+ test(e.pd1.pb == e.pd1)
+ test(e.pd1.sd1 == "sd2")
+ test(e.pd1.pd1 == e.pd1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("derived exception thrown as base exception (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_throwDerivedAsBase(cb.response, cb.exception_throwDerivedAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("derived exception thrown as derived exception... ")
+ sys.stdout.flush()
+ try:
+ t.throwDerivedAsDerived()
+ test(False)
+ except Test.DerivedException as e:
+ test(e.ice_name() == "Test::DerivedException")
+ test(e.sbe == "sbe")
+ test(e.pb)
+ test(e.pb.sb == "sb1")
+ test(e.pb.pb == e.pb)
+ test(e.sde == "sde1")
+ test(e.pd1)
+ test(e.pd1.sb == "sb2")
+ test(e.pd1.pb == e.pd1)
+ test(e.pd1.sd1 == "sd2")
+ test(e.pd1.pd1 == e.pd1)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("derived exception thrown as derived exception (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_throwDerivedAsDerived(cb.response, cb.exception_throwDerivedAsDerived)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("unknown derived exception thrown as base exception... ")
+ sys.stdout.flush()
+ try:
+ t.throwUnknownDerivedAsBase()
+ test(False)
+ except Test.BaseException as e:
+ test(e.ice_name() == "Test::BaseException")
+ test(e.sbe == "sbe")
+ test(e.pb)
+ test(e.pb.sb == "sb d2")
+ test(e.pb.pb == e.pb)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("unknown derived exception thrown as base exception (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_throwUnknownDerivedAsBase(cb.response, cb.exception_throwUnknownDerivedAsBase)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("forward-declared class... ")
+ sys.stdout.flush()
+ try:
+ f = t.useForward()
+ test(f)
+ except Ice.Exception:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("forward-declared class (AMI)... ")
+ sys.stdout.flush()
+ cb = Callback()
+ t.begin_useForward(cb.response_useForward, cb.exception)
+ cb.check()
+ print("ok")
+
+ sys.stdout.write("preserved classes... ")
+ sys.stdout.flush()
+
+ try:
+ #
+ # Server knows the most-derived class PDerived.
+ #
+ pd = Test.PDerived()
+ pd.pi = 3
+ pd.ps = "preserved"
+ pd.pb = pd
+
+ r = t.exchangePBase(pd)
+ test(isinstance(r, Test.PDerived))
+ test(r.pi == 3)
+ test(r.ps == "preserved")
+ test(r.pb == r)
+
+ #
+ # Server only knows the base (non-preserved) type, so the object is sliced.
+ #
+ pu = Test.PCUnknown()
+ pu.pi = 3
+ pu.pu = "preserved"
+
+ r = t.exchangePBase(pu)
+ test(not isinstance(r, Test.PCUnknown))
+ test(r.pi == 3)
+
+ #
+ # Server only knows the intermediate type Preserved. The object will be sliced to
+ # Preserved for the 1.0 encoding; otherwise it should be returned intact.
+ #
+ pcd = Test.PCDerived()
+ pcd.pi = 3
+ pcd.pbs = [ pcd ]
+
+ r = t.exchangePBase(pcd)
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ test(not isinstance(r, Test.PCDerived))
+ test(r.pi == 3)
+ else:
+ test(isinstance(r, Test.PCDerived))
+ test(r.pi == 3)
+ test(r.pbs[0] == r)
+
+ #
+ # Server only knows the intermediate type CompactPDerived. The object will be sliced to
+ # CompactPDerived for the 1.0 encoding; otherwise it should be returned intact.
+ #
+ pcd = Test.CompactPCDerived()
+ pcd.pi = 3
+ pcd.pbs = [ pcd ]
+
+ r = t.exchangePBase(pcd)
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ test(not isinstance(r, Test.CompactPCDerived))
+ test(r.pi == 3)
+ else:
+ test(isinstance(r, Test.CompactPCDerived))
+ test(r.pi == 3)
+ test(r.pbs[0] == r)
+
+ #
+ # Send an object that will have multiple preserved slices in the server.
+ # The object will be sliced to Preserved for the 1.0 encoding.
+ #
+ pcd = Test.PCDerived3()
+ pcd.pi = 3
+ #
+ # Sending more than 254 objects exercises the encoding for object ids.
+ #
+ pcd.pbs = []
+ for i in range(0, 300):
+ p2 = Test.PCDerived2()
+ p2.pi = i
+ p2.pbs = [ None ] # Nil reference. This slice should not have an indirection table.
+ p2.pcd2 = i
+ pcd.pbs.append(p2)
+ pcd.pcd2 = pcd.pi
+ pcd.pcd3 = pcd.pbs[10]
+
+ r = t.exchangePBase(pcd)
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ test(not isinstance(r, Test.PCDerived3))
+ test(isinstance(r, Test.Preserved))
+ test(r.pi == 3)
+ else:
+ test(isinstance(r, Test.PCDerived3))
+ test(r.pi == 3)
+ for i in range(0, 300):
+ p2 = r.pbs[i]
+ test(isinstance(p2, Test.PCDerived2))
+ test(p2.pi == i)
+ test(len(p2.pbs) == 1)
+ test(not p2.pbs[0])
+ test(p2.pcd2 == i)
+ test(r.pcd2 == r.pi)
+ test(r.pcd3 == r.pbs[10])
+
+ #
+ # Obtain an object with preserved slices and send it back to the server.
+ # The preserved slices should be excluded for the 1.0 encoding, otherwise
+ # they should be included.
+ #
+ p = t.PBSUnknownAsPreserved()
+ t.checkPBSUnknown(p)
+ if t.ice_getEncodingVersion() != Ice.Encoding_1_0:
+ t.ice_encodingVersion(Ice.Encoding_1_0).checkPBSUnknown(p)
+ except Ice.OperationNotExistException:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("preserved classes (AMI)... ")
+ sys.stdout.flush()
+
+ #
+ # Server knows the most-derived class PDerived.
+ #
+ pd = Test.PDerived()
+ pd.pi = 3
+ pd.ps = "preserved"
+ pd.pb = pd
+
+ cb = Callback()
+ t.begin_exchangePBase(pd, cb.response_preserved1, cb.exception)
+ cb.check()
+
+ #
+ # Server only knows the base (non-preserved) type, so the object is sliced.
+ #
+ pu = Test.PCUnknown()
+ pu.pi = 3
+ pu.pu = "preserved"
+
+ cb = Callback()
+ t.begin_exchangePBase(pu, cb.response_preserved2, cb.exception)
+ cb.check()
+
+ #
+ # Server only knows the intermediate type Preserved. The object will be sliced to
+ # Preserved for the 1.0 encoding; otherwise it should be returned intact.
+ #
+ pcd = Test.PCDerived()
+ pcd.pi = 3
+ pcd.pbs = [ pcd ]
+
+ cb = Callback()
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ t.begin_exchangePBase(pcd, cb.response_preserved3, cb.exception)
+ else:
+ t.begin_exchangePBase(pcd, cb.response_preserved4, cb.exception)
+ cb.check()
+
+ #
+ # Server only knows the intermediate type CompactPDerived. The object will be sliced to
+ # CompactPDerived for the 1.0 encoding; otherwise it should be returned intact.
+ #
+ pcd = Test.CompactPCDerived()
+ pcd.pi = 3
+ pcd.pbs = [ pcd ]
+
+ cb = Callback()
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ t.begin_exchangePBase(pcd, cb.response_compactPreserved1, cb.exception)
+ else:
+ t.begin_exchangePBase(pcd, cb.response_compactPreserved2, cb.exception)
+ cb.check()
+
+ #
+ # Send an object that will have multiple preserved slices in the server.
+ # The object will be sliced to Preserved for the 1.0 encoding.
+ #
+ pcd = Test.PCDerived3()
+ pcd.pi = 3
+ #
+ # Sending more than 254 objects exercises the encoding for object ids.
+ #
+ pcd.pbs = []
+ for i in range(0, 300):
+ p2 = Test.PCDerived2()
+ p2.pi = i
+ p2.pbs = [ None ] # Nil reference. This slice should not have an indirection table.
+ p2.pcd2 = i
+ pcd.pbs.append(p2)
+ pcd.pcd2 = pcd.pi
+ pcd.pcd3 = pcd.pbs[10]
+
+ cb = Callback()
+ if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
+ t.begin_exchangePBase(pcd, cb.response_preserved3, cb.exception)
+ else:
+ t.begin_exchangePBase(pcd, cb.response_preserved5, cb.exception)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("garbage collection of preserved classes... ")
+ sys.stdout.flush()
+ try:
+ #
+ # Register a factory in order to substitute our own subclass of
+ # UCNode. This provides an easy way to determine how many
+ # unmarshaled instances currently exist.
+ #
+ communicator.addObjectFactory(NodeFactoryI(), Test.PNode.ice_staticId())
+
+ #
+ # Relay a graph through the server. This test uses a preserved class
+ # with a class member.
+ #
+ c = Test.PNode()
+ c.next = Test.PNode()
+ c.next.next = Test.PNode()
+ c.next.next.next = c # Create a cyclic graph.
+
+ test(PNodeI.counter == 0)
+ n = t.exchangePNode(c)
+ test(PNodeI.counter == 3)
+ test(n.next != None)
+ test(n.next != n.next.next)
+ test(n.next.next != n.next.next.next)
+ test(n.next.next.next == n)
+ n = None # Release reference.
+ if sys.version_info[0] == 3 and sys.version_info[1] >= 4:
+ #
+ # In Python 3.4, objects with a __del__ method can still be collected.
+ #
+ gc.collect()
+ test(PNodeI.counter == 0)
+ else:
+ #
+ # The PNodeI class declares a __del__ method, which means the Python
+ # garbage collector will NOT collect a cycle of PNodeI objects.
+ #
+ gc.collect() # No effect.
+ test(PNodeI.counter == 3)
+ #
+ # The uncollectable objects are stored in gc.garbage. We have to
+ # manually break the cycle and then remove the objects from the
+ # gc.garbage list.
+ #
+ test(len(gc.garbage) > 0)
+ for o in gc.garbage:
+ if isinstance(o, PNodeI):
+ o.next = None
+ o = None # Remove last reference.
+ del gc.garbage[:]
+ test(PNodeI.counter == 0)
+
+ #
+ # Obtain a preserved object from the server where the most-derived
+ # type is unknown. The preserved slice refers to a graph of PNode
+ # objects.
+ #
+ test(PNodeI.counter == 0)
+ p = t.PBSUnknownAsPreservedWithGraph()
+ test(p)
+ test(PNodeI.counter == 3)
+ t.checkPBSUnknownWithGraph(p)
+ p = None # Release reference.
+ if sys.version_info[0] == 3 and sys.version_info[1] >= 4:
+ #
+ # In Python 3.4, objects with a __del__ method can still be collected.
+ #
+ gc.collect()
+ test(PNodeI.counter == 0)
+ else:
+ #
+ # The PNodeI class declares a __del__ method, which means the Python
+ # garbage collector will NOT collect a cycle of PNodeI objects.
+ #
+ gc.collect() # No effect.
+ test(PNodeI.counter == 3)
+ #
+ # The uncollectable objects are stored in gc.garbage. We have to
+ # manually break the cycle and then remove the objects from the
+ # gc.garbage list.
+ #
+ test(len(gc.garbage) > 0)
+ for o in gc.garbage:
+ if isinstance(o, PNodeI):
+ o.next = None
+ o = None # Remove last reference.
+ del gc.garbage[:]
+ test(PNodeI.counter == 0)
+
+ #
+ # Register a factory in order to substitute our own subclass of
+ # Preserved. This provides an easy way to determine how many
+ # unmarshaled instances currently exist.
+ #
+ communicator.addObjectFactory(PreservedFactoryI(), Test.Preserved.ice_staticId())
+
+ #
+ # Obtain a preserved object from the server where the most-derived
+ # type is unknown. A data member in the preserved slice refers to the
+ # outer object, so the chain of references looks like this:
+ #
+ # outer->slicedData->outer
+ #
+ test(PreservedI.counter == 0)
+ p = t.PBSUnknown2AsPreservedWithGraph()
+ test(p != None)
+ test(PreservedI.counter == 1)
+ t.checkPBSUnknown2WithGraph(p)
+ p._ice_slicedData = None # Break the cycle.
+ p = None # Release reference.
+ test(PreservedI.counter == 0)
+
+ #
+ # Throw a preserved exception where the most-derived type is unknown.
+ # The preserved exception slice contains a class data member. This
+ # object is also preserved, and its most-derived type is also unknown.
+ # The preserved slice of the object contains a class data member that
+ # refers to itself.
+ #
+ # The chain of references looks like this:
+ #
+ # ex->slicedData->obj->slicedData->obj
+ #
+ try:
+ test(PreservedI.counter == 0)
+
+ try:
+ t.throwPreservedException()
+ except Test.PreservedException as ex:
+ #
+ # The class instance is only retained when the encoding is > 1.0.
+ #
+ if t.ice_getEncodingVersion() != Ice.Encoding_1_0:
+ test(PreservedI.counter == 1)
+ gc.collect() # No effect.
+ test(PreservedI.counter == 1)
+ ex._ice_slicedData = None # Break the cycle.
+
+ #
+ # Exception has gone out of scope.
+ #
+ if t.ice_getEncodingVersion() != Ice.Encoding_1_0:
+ gc.collect()
+ if sys.version_info[0] == 3 and sys.version_info[1] >= 4:
+ #
+ # In Python 3.4, objects with a __del__ method can still be collected.
+ #
+ test(len(gc.garbage) == 0)
+ else:
+ test(len(gc.garbage) > 0)
+ for o in gc.garbage:
+ if isinstance(o, PreservedI):
+ o._ice_slicedData = None
+ o = None # Remove last reference.
+ del gc.garbage[:]
+ test(PreservedI.counter == 0)
+ except Ice.Exception:
+ test(False)
+ except Ice.OperationNotExistException:
+ pass
+
+ print("ok")
+
+ return t
diff --git a/python/test/Ice/slicing/objects/Client.py b/python/test/Ice/slicing/objects/Client.py
new file mode 100755
index 00000000000..2044a2d5b27
--- /dev/null
+++ b/python/test/Ice/slicing/objects/Client.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, AllTests
+
+def run(args, communicator):
+ Test = AllTests.allTests(communicator)
+ Test.shutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/slicing/objects/ClientPrivate.ice b/python/test/Ice/slicing/objects/ClientPrivate.ice
new file mode 100644
index 00000000000..3880bd583ab
--- /dev/null
+++ b/python/test/Ice/slicing/objects/ClientPrivate.ice
@@ -0,0 +1,49 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Test.ice>
+
+module Test
+{
+
+class D3 extends B
+{
+ string sd3;
+ B pd3;
+};
+
+["preserve-slice"]
+class PCUnknown extends PBase
+{
+ string pu;
+};
+
+class PCDerived extends PDerived
+{
+ PBaseSeq pbs;
+};
+
+class PCDerived2 extends PCDerived
+{
+ int pcd2;
+};
+
+class PCDerived3 extends PCDerived2
+{
+ Object pcd3;
+};
+
+class CompactPCDerived(57) extends CompactPDerived
+{
+ PBaseSeq pbs;
+};
+
+};
diff --git a/python/test/Ice/slicing/objects/Forward.ice b/python/test/Ice/slicing/objects/Forward.ice
new file mode 100644
index 00000000000..89486e226cc
--- /dev/null
+++ b/python/test/Ice/slicing/objects/Forward.ice
@@ -0,0 +1,27 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+class Forward;
+
+class Hidden
+{
+ Forward f;
+};
+
+class Forward
+{
+ Hidden h;
+};
+
+};
diff --git a/python/test/Ice/slicing/objects/Server.py b/python/test/Ice/slicing/objects/Server.py
new file mode 100755
index 00000000000..e5b7465d7af
--- /dev/null
+++ b/python/test/Ice/slicing/objects/Server.py
@@ -0,0 +1,390 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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('-I. --all ServerPrivate.ice Forward.ice')
+import Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class TestI(Test.TestIntf):
+ def SBaseAsObject(self, current=None):
+ sb = Test.SBase()
+ sb.sb = "SBase.sb"
+ return sb
+
+ def SBaseAsSBase(self, current=None):
+ sb = Test.SBase()
+ sb.sb = "SBase.sb"
+ return sb
+
+ def SBSKnownDerivedAsSBase(self, current=None):
+ sbskd = Test.SBSKnownDerived()
+ sbskd.sb = "SBSKnownDerived.sb"
+ sbskd.sbskd = "SBSKnownDerived.sbskd"
+ return sbskd
+
+ def SBSKnownDerivedAsSBSKnownDerived(self, current=None):
+ sbskd = Test.SBSKnownDerived()
+ sbskd.sb = "SBSKnownDerived.sb"
+ sbskd.sbskd = "SBSKnownDerived.sbskd"
+ return sbskd
+
+ def SBSUnknownDerivedAsSBase(self, current=None):
+ sbsud = Test.SBSUnknownDerived()
+ sbsud.sb = "SBSUnknownDerived.sb"
+ sbsud.sbsud = "SBSUnknownDerived.sbsud"
+ return sbsud
+
+ def SBSUnknownDerivedAsSBaseCompact(self, current=None):
+ sbsud = Test.SBSUnknownDerived()
+ sbsud.sb = "SBSUnknownDerived.sb"
+ sbsud.sbsud = "SBSUnknownDerived.sbsud"
+ return sbsud
+
+ def SUnknownAsObject(self, current=None):
+ su = Test.SUnknown()
+ su.su = "SUnknown.su"
+ return su
+
+ def checkSUnknown(self, obj, current=None):
+ if current.encoding == Ice.Encoding_1_0:
+ test(not isinstance(obj, Test.SUnknown))
+ else:
+ test(isinstance(obj, Test.SUnknown))
+ test(obj.su == "SUnknown.su")
+
+ def oneElementCycle(self, current=None):
+ b = Test.B()
+ b.sb = "B1.sb"
+ b.pb = b
+ return b
+
+ def twoElementCycle(self, current=None):
+ b1 = Test.B()
+ b1.sb = "B1.sb"
+ b2 = Test.B()
+ b2.sb = "B2.sb"
+ b2.pb = b1
+ b1.pb = b2
+ return b1
+
+ def D1AsB(self, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ return d1
+
+ def D1AsD1(self, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ return d1
+
+ def D2AsB(self, current=None):
+ d2 = Test.D2()
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d1 = Test.D1()
+ d1.pb = d2
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d1.pd1 = d2
+ d2.pb = d1
+ d2.pd2 = d1
+ return d2
+
+ def paramTest1(self, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ return (d1, d2)
+
+ def paramTest2(self, current=None):
+ c = Ice.Current()
+ p1, p2 = self.paramTest1(c)
+ return (p2, p1)
+
+ def paramTest3(self, current=None):
+ d2 = Test.D2()
+ d2.sb = "D2.sb (p1 1)"
+ d2.pb = None
+ d2.sd2 = "D2.sd2 (p1 1)"
+
+ d1 = Test.D1()
+ d1.sb = "D1.sb (p1 2)"
+ d1.pb = None
+ d1.sd1 = "D1.sd2 (p1 2)"
+ d1.pd1 = None
+ d2.pd2 = d1
+
+ d4 = Test.D2()
+ d4.sb = "D2.sb (p2 1)"
+ d4.pb = None
+ d4.sd2 = "D2.sd2 (p2 1)"
+
+ d3 = Test.D1()
+ d3.sb = "D1.sb (p2 2)"
+ d3.pb = None
+ d3.sd1 = "D1.sd2 (p2 2)"
+ d3.pd1 = None
+ d4.pd2 = d3
+
+ return (d3, d2, d4)
+
+ def paramTest4(self, current=None):
+ d4 = Test.D4()
+ d4.sb = "D4.sb (1)"
+ d4.pb = None
+ d4.p1 = Test.B()
+ d4.p1.sb = "B.sb (1)"
+ d4.p1.pb = None
+ d4.p2 = Test.B()
+ d4.p2.sb = "B.sb (2)"
+ d4.p2.pb = None
+ return (d4.p2, d4)
+
+ def returnTest1(self, current=None):
+ c = Ice.Current()
+ p1, p2 = self.paramTest1(c)
+ return (p1, p1, p2)
+
+ def returnTest2(self, current=None):
+ c = Ice.Current()
+ p2, p1 = self.paramTest1(c)
+ return (p1, p1, p2)
+
+ def returnTest3(self, p1, p2, current=None):
+ return p1
+
+ def sequenceTest(self, p1, p2, current=None):
+ ss = Test.SS3()
+ ss.c1 = p1
+ ss.c2 = p2
+ return ss
+
+ def dictionaryTest(self, bin, current=None):
+ bout = {}
+ for i in range(0, 10):
+ b = bin[i]
+ d2 = Test.D2()
+ d2.sb = b.sb
+ d2.pb = b.pb
+ d2.sd2 = "D2"
+ d2.pd2 = d2
+ bout[i * 10] = d2
+
+ r = {}
+ for i in range(0, 10):
+ s = "D1." + str(i * 20)
+ d1 = Test.D1()
+ d1.sb = s
+ if i == 0:
+ d1.pb = None
+ else:
+ d1.pb = r[(i - 1) * 20]
+ d1.sd1 = s
+ d1.pd1 = d1
+ r[i * 20] = d1
+
+ return (r, bout)
+
+ def exchangePBase(self, pb, current=None):
+ return pb
+
+ def PBSUnknownAsPreserved(self, current=None):
+ r = Test.PSUnknown()
+ r.pi = 5
+ r.ps = "preserved"
+ r.psu = "unknown"
+ r.graph = None
+ return r
+
+ def checkPBSUnknown(self, p, current=None):
+ if current.encoding == Ice.Encoding_1_0:
+ test(not isinstance(p, Test.PSUnknown))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ else:
+ test(isinstance(p, Test.PSUnknown))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ test(p.psu == "unknown")
+ test(not p.graph)
+
+ def PBSUnknownAsPreservedWithGraph_async(self, cb, current=None):
+ r = Test.PSUnknown()
+ r.pi = 5
+ r.ps = "preserved"
+ r.psu = "unknown"
+ r.graph = Test.PNode()
+ r.graph.next = Test.PNode()
+ r.graph.next.next = Test.PNode()
+ r.graph.next.next.next = r.graph
+ cb.ice_response(r)
+ r.graph.next.next.next = None # Break the cycle.
+
+ def checkPBSUnknownWithGraph(self, p, current=None):
+ if current.encoding == Ice.Encoding_1_0:
+ test(not isinstance(p, Test.PSUnknown))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ else:
+ test(isinstance(p, Test.PSUnknown))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ test(p.psu == "unknown")
+ test(p.graph != p.graph.next)
+ test(p.graph.next != p.graph.next.next)
+ test(p.graph.next.next.next == p.graph)
+ p.graph.next.next.next = None # Break the cycle.
+
+ def PBSUnknown2AsPreservedWithGraph_async(self, cb, current=None):
+ r = Test.PSUnknown2()
+ r.pi = 5
+ r.ps = "preserved"
+ r.pb = r
+ cb.ice_response(r)
+ r.pb = None # Break the cycle.
+
+ def checkPBSUnknown2WithGraph(self, p, current=None):
+ if current.encoding == Ice.Encoding_1_0:
+ test(not isinstance(p, Test.PSUnknown2))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ else:
+ test(isinstance(p, Test.PSUnknown2))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ test(p.pb == p)
+ p.pb = None # Break the cycle.
+
+ def exchangePNode(self, pn, current=None):
+ return pn
+
+ def throwBaseAsBase(self, current=None):
+ be = Test.BaseException()
+ be.sbe = "sbe"
+ be.pb = Test.B()
+ be.pb.sb = "sb"
+ be.pb.pb = be.pb
+ raise be
+
+ def throwDerivedAsBase(self, current=None):
+ de = Test.DerivedException()
+ de.sbe = "sbe"
+ de.pb = Test.B()
+ de.pb.sb = "sb1"
+ de.pb.pb = de.pb
+ de.sde = "sde1"
+ de.pd1 = Test.D1()
+ de.pd1.sb = "sb2"
+ de.pd1.pb = de.pd1
+ de.pd1.sd1 = "sd2"
+ de.pd1.pd1 = de.pd1
+ raise de
+
+ def throwDerivedAsDerived(self, current=None):
+ de = Test.DerivedException()
+ de.sbe = "sbe"
+ de.pb = Test.B()
+ de.pb.sb = "sb1"
+ de.pb.pb = de.pb
+ de.sde = "sde1"
+ de.pd1 = Test.D1()
+ de.pd1.sb = "sb2"
+ de.pd1.pb = de.pd1
+ de.pd1.sd1 = "sd2"
+ de.pd1.pd1 = de.pd1
+ raise de
+
+ def throwUnknownDerivedAsBase(self, current=None):
+ d2 = Test.D2()
+ d2.sb = "sb d2"
+ d2.pb = d2
+ d2.sd2 = "sd2 d2"
+ d2.pd2 = d2
+
+ ude = Test.UnknownDerivedException()
+ ude.sbe = "sbe"
+ ude.pb = d2
+ ude.sude = "sude"
+ ude.pd2 = d2
+ raise ude
+
+ def throwPreservedException_async(self, cb, current=None):
+ ue = Test.PSUnknownException()
+ ue.p = Test.PSUnknown2()
+ ue.p.pi = 5
+ ue.p.ps = "preserved"
+ ue.p.pb = ue.p
+ cb.ice_exception(ue)
+ ue.p.pb = None # Break the cycle.
+
+ def useForward(self, current=None):
+ f = Test.Forward()
+ f.h = Test.Hidden()
+ f.h.f = f
+ return f
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+def run(args, communicator):
+ properties = communicator.getProperties()
+ properties.setProperty("Ice.Warn.Dispatch", "0")
+ properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ object = TestI()
+ adapter.add(object, communicator.stringToIdentity("Test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/slicing/objects/ServerAMD.py b/python/test/Ice/slicing/objects/ServerAMD.py
new file mode 100755
index 00000000000..9020ff30a5f
--- /dev/null
+++ b/python/test/Ice/slicing/objects/ServerAMD.py
@@ -0,0 +1,419 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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('-I. --all ServerPrivateAMD.ice Forward.ice')
+import Test
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class TestI(Test.TestIntf):
+ def SBaseAsObject_async(self, cb, current=None):
+ sb = Test.SBase()
+ sb.sb = "SBase.sb"
+ cb.ice_response(sb)
+
+ def SBaseAsSBase_async(self, cb, current=None):
+ sb = Test.SBase()
+ sb.sb = "SBase.sb"
+ cb.ice_response(sb)
+
+ def SBSKnownDerivedAsSBase_async(self, cb, current=None):
+ sbskd = Test.SBSKnownDerived()
+ sbskd.sb = "SBSKnownDerived.sb"
+ sbskd.sbskd = "SBSKnownDerived.sbskd"
+ cb.ice_response(sbskd)
+
+ def SBSKnownDerivedAsSBSKnownDerived_async(self, cb, current=None):
+ sbskd = Test.SBSKnownDerived()
+ sbskd.sb = "SBSKnownDerived.sb"
+ sbskd.sbskd = "SBSKnownDerived.sbskd"
+ cb.ice_response(sbskd)
+
+ def SBSUnknownDerivedAsSBase_async(self, cb, current=None):
+ sbsud = Test.SBSUnknownDerived()
+ sbsud.sb = "SBSUnknownDerived.sb"
+ sbsud.sbsud = "SBSUnknownDerived.sbsud"
+ cb.ice_response(sbsud)
+
+ def SBSUnknownDerivedAsSBaseCompact_async(self, cb, current=None):
+ sbsud = Test.SBSUnknownDerived()
+ sbsud.sb = "SBSUnknownDerived.sb"
+ sbsud.sbsud = "SBSUnknownDerived.sbsud"
+ cb.ice_response(sbsud)
+
+ def SUnknownAsObject_async(self, cb, current=None):
+ su = Test.SUnknown()
+ su.su = "SUnknown.su"
+ cb.ice_response(su)
+
+ def checkSUnknown_async(self, cb, obj, current=None):
+ if current.encoding == Ice.Encoding_1_0:
+ test(not isinstance(obj, Test.SUnknown))
+ else:
+ test(isinstance(obj, Test.SUnknown))
+ test(obj.su == "SUnknown.su")
+ cb.ice_response()
+
+ def oneElementCycle_async(self, cb, current=None):
+ b = Test.B()
+ b.sb = "B1.sb"
+ b.pb = b
+ cb.ice_response(b)
+
+ def twoElementCycle_async(self, cb, current=None):
+ b1 = Test.B()
+ b1.sb = "B1.sb"
+ b2 = Test.B()
+ b2.sb = "B2.sb"
+ b2.pb = b1
+ b1.pb = b2
+ cb.ice_response(b1)
+
+ def D1AsB_async(self, cb, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ cb.ice_response(d1)
+
+ def D1AsD1_async(self, cb, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ cb.ice_response(d1)
+
+ def D2AsB_async(self, cb, current=None):
+ d2 = Test.D2()
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d1 = Test.D1()
+ d1.pb = d2
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d1.pd1 = d2
+ d2.pb = d1
+ d2.pd2 = d1
+ cb.ice_response(d2)
+
+ def paramTest1_async(self, cb, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ cb.ice_response(d1, d2)
+
+ def paramTest2_async(self, cb, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ cb.ice_response(d2, d1)
+
+ def paramTest3_async(self, cb, current=None):
+ d2 = Test.D2()
+ d2.sb = "D2.sb (p1 1)"
+ d2.pb = None
+ d2.sd2 = "D2.sd2 (p1 1)"
+
+ d1 = Test.D1()
+ d1.sb = "D1.sb (p1 2)"
+ d1.pb = None
+ d1.sd1 = "D1.sd2 (p1 2)"
+ d1.pd1 = None
+ d2.pd2 = d1
+
+ d4 = Test.D2()
+ d4.sb = "D2.sb (p2 1)"
+ d4.pb = None
+ d4.sd2 = "D2.sd2 (p2 1)"
+
+ d3 = Test.D1()
+ d3.sb = "D1.sb (p2 2)"
+ d3.pb = None
+ d3.sd1 = "D1.sd2 (p2 2)"
+ d3.pd1 = None
+ d4.pd2 = d3
+
+ cb.ice_response(d3, d2, d4)
+
+ def paramTest4_async(self, cb, current=None):
+ d4 = Test.D4()
+ d4.sb = "D4.sb (1)"
+ d4.pb = None
+ d4.p1 = Test.B()
+ d4.p1.sb = "B.sb (1)"
+ d4.p1.pb = None
+ d4.p2 = Test.B()
+ d4.p2.sb = "B.sb (2)"
+ d4.p2.pb = None
+ cb.ice_response(d4.p2, d4)
+
+ def returnTest1_async(self, cb, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ cb.ice_response(d2, d2, d1)
+
+ def returnTest2_async(self, cb, current=None):
+ d1 = Test.D1()
+ d1.sb = "D1.sb"
+ d1.sd1 = "D1.sd1"
+ d2 = Test.D2()
+ d2.pb = d1
+ d2.sb = "D2.sb"
+ d2.sd2 = "D2.sd2"
+ d2.pd2 = d1
+ d1.pb = d2
+ d1.pd1 = d2
+ cb.ice_response(d1, d1, d2)
+
+ def returnTest3_async(self, cb, p1, p2, current=None):
+ cb.ice_response(p1)
+
+ def sequenceTest_async(self, cb, p1, p2, current=None):
+ ss = Test.SS3()
+ ss.c1 = p1
+ ss.c2 = p2
+ cb.ice_response(ss)
+
+ def dictionaryTest_async(self, cb, bin, current=None):
+ bout = {}
+ for i in range(0, 10):
+ b = bin[i]
+ d2 = Test.D2()
+ d2.sb = b.sb
+ d2.pb = b.pb
+ d2.sd2 = "D2"
+ d2.pd2 = d2
+ bout[i * 10] = d2
+
+ r = {}
+ for i in range(0, 10):
+ s = "D1." + str(i * 20)
+ d1 = Test.D1()
+ d1.sb = s
+ if i == 0:
+ d1.pb = None
+ else:
+ d1.pb = r[(i - 1) * 20]
+ d1.sd1 = s
+ d1.pd1 = d1
+ r[i * 20] = d1
+
+ cb.ice_response(r, bout)
+
+ def exchangePBase_async(self, cb, pb, current=None):
+ cb.ice_response(pb)
+
+ def PBSUnknownAsPreserved_async(self, cb, current=None):
+ r = Test.PSUnknown()
+ r.pi = 5
+ r.ps = "preserved"
+ r.psu = "unknown"
+ r.graph = None
+ cb.ice_response(r)
+
+ def checkPBSUnknown_async(self, cb, p, current=None):
+ if current.encoding == Ice.Encoding_1_0:
+ test(not isinstance(p, Test.PSUnknown))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ else:
+ test(isinstance(p, Test.PSUnknown))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ test(p.psu == "unknown")
+ test(not p.graph)
+ cb.ice_response()
+
+ def PBSUnknownAsPreservedWithGraph_async(self, cb, current=None):
+ r = Test.PSUnknown()
+ r.pi = 5
+ r.ps = "preserved"
+ r.psu = "unknown"
+ r.graph = Test.PNode()
+ r.graph.next = Test.PNode()
+ r.graph.next.next = Test.PNode()
+ r.graph.next.next.next = r.graph
+ cb.ice_response(r)
+ r.graph.next.next.next = None # Break the cycle.
+
+ def checkPBSUnknownWithGraph_async(self, cb, p, current=None):
+ if current.encoding == Ice.Encoding_1_0:
+ test(not isinstance(p, Test.PSUnknown))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ else:
+ test(isinstance(p, Test.PSUnknown))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ test(p.psu == "unknown")
+ test(p.graph != p.graph.next)
+ test(p.graph.next != p.graph.next.next)
+ test(p.graph.next.next.next == p.graph)
+ p.graph.next.next.next = None # Break the cycle.
+ cb.ice_response()
+
+ def PBSUnknown2AsPreservedWithGraph_async(self, cb, current=None):
+ r = Test.PSUnknown2()
+ r.pi = 5
+ r.ps = "preserved"
+ r.pb = r
+ cb.ice_response(r)
+ r.pb = None # Break the cycle.
+
+ def checkPBSUnknown2WithGraph_async(self, cb, p, current=None):
+ if current.encoding == Ice.Encoding_1_0:
+ test(not isinstance(p, Test.PSUnknown2))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ else:
+ test(isinstance(p, Test.PSUnknown2))
+ test(p.pi == 5)
+ test(p.ps == "preserved")
+ test(p.pb == p)
+ p.pb = None # Break the cycle.
+ cb.ice_response()
+
+ def exchangePNode_async(self, cb, pn, current=None):
+ cb.ice_response(pn)
+
+ def throwBaseAsBase_async(self, cb, current=None):
+ be = Test.BaseException()
+ be.sbe = "sbe"
+ be.pb = Test.B()
+ be.pb.sb = "sb"
+ be.pb.pb = be.pb
+ cb.ice_exception(be)
+
+ def throwDerivedAsBase_async(self, cb, current=None):
+ de = Test.DerivedException()
+ de.sbe = "sbe"
+ de.pb = Test.B()
+ de.pb.sb = "sb1"
+ de.pb.pb = de.pb
+ de.sde = "sde1"
+ de.pd1 = Test.D1()
+ de.pd1.sb = "sb2"
+ de.pd1.pb = de.pd1
+ de.pd1.sd1 = "sd2"
+ de.pd1.pd1 = de.pd1
+ cb.ice_exception(de)
+
+ def throwDerivedAsDerived_async(self, cb, current=None):
+ de = Test.DerivedException()
+ de.sbe = "sbe"
+ de.pb = Test.B()
+ de.pb.sb = "sb1"
+ de.pb.pb = de.pb
+ de.sde = "sde1"
+ de.pd1 = Test.D1()
+ de.pd1.sb = "sb2"
+ de.pd1.pb = de.pd1
+ de.pd1.sd1 = "sd2"
+ de.pd1.pd1 = de.pd1
+ cb.ice_exception(de)
+
+ def throwUnknownDerivedAsBase_async(self, cb, current=None):
+ d2 = Test.D2()
+ d2.sb = "sb d2"
+ d2.pb = d2
+ d2.sd2 = "sd2 d2"
+ d2.pd2 = d2
+
+ ude = Test.UnknownDerivedException()
+ ude.sbe = "sbe"
+ ude.pb = d2
+ ude.sude = "sude"
+ ude.pd2 = d2
+ cb.ice_exception(ude)
+
+ def throwPreservedException_async(self, cb, current=None):
+ ue = Test.PSUnknownException()
+ ue.p = Test.PSUnknown2()
+ ue.p.pi = 5
+ ue.p.ps = "preserved"
+ ue.p.pb = ue.p
+ cb.ice_exception(ue)
+ ue.p.pb = None # Break the cycle.
+
+ def useForward_async(self, cb, current=None):
+ f = Test.Forward()
+ f.h = Test.Hidden()
+ f.h.f = f
+ cb.ice_response(f)
+
+ def shutdown_async(self, cb, current=None):
+ current.adapter.getCommunicator().shutdown()
+ cb.ice_response()
+
+def run(args, communicator):
+ properties = communicator.getProperties()
+ properties.setProperty("Ice.Warn.Dispatch", "0")
+ properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ object = TestI()
+ adapter.add(object, communicator.stringToIdentity("Test"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ communicator = Ice.initialize(sys.argv)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/slicing/objects/ServerPrivate.ice b/python/test/Ice/slicing/objects/ServerPrivate.ice
new file mode 100644
index 00000000000..f4eb9552f0f
--- /dev/null
+++ b/python/test/Ice/slicing/objects/ServerPrivate.ice
@@ -0,0 +1,67 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Test.ice>
+
+module Test
+{
+
+class SBSUnknownDerived extends SBase
+{
+ string sbsud;
+};
+
+class SUnknown
+{
+ string su;
+};
+
+class D2 extends B
+{
+ string sd2;
+ B pd2;
+};
+
+class D4 extends B
+{
+ B p1;
+ B p2;
+};
+
+exception UnknownDerivedException extends BaseException
+{
+ string sude;
+ D2 pd2;
+};
+
+class MyClass
+{
+ int i;
+};
+
+class PSUnknown extends Preserved
+{
+ string psu;
+ PNode graph;
+ MyClass cl;
+};
+
+class PSUnknown2 extends Preserved
+{
+ PBase pb;
+};
+
+exception PSUnknownException extends PreservedException
+{
+ PSUnknown2 p;
+};
+
+};
diff --git a/python/test/Ice/slicing/objects/ServerPrivateAMD.ice b/python/test/Ice/slicing/objects/ServerPrivateAMD.ice
new file mode 100644
index 00000000000..51746909b3f
--- /dev/null
+++ b/python/test/Ice/slicing/objects/ServerPrivateAMD.ice
@@ -0,0 +1,67 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <TestAMD.ice>
+
+module Test
+{
+
+class SBSUnknownDerived extends SBase
+{
+ string sbsud;
+};
+
+class SUnknown
+{
+ string su;
+};
+
+class D2 extends B
+{
+ string sd2;
+ B pd2;
+};
+
+class D4 extends B
+{
+ B p1;
+ B p2;
+};
+
+exception UnknownDerivedException extends BaseException
+{
+ string sude;
+ D2 pd2;
+};
+
+class MyClass
+{
+ int i;
+};
+
+class PSUnknown extends Preserved
+{
+ string psu;
+ PNode graph;
+ MyClass cl;
+};
+
+class PSUnknown2 extends Preserved
+{
+ PBase pb;
+};
+
+exception PSUnknownException extends PreservedException
+{
+ PSUnknown2 p;
+};
+
+};
diff --git a/python/test/Ice/slicing/objects/Test.ice b/python/test/Ice/slicing/objects/Test.ice
new file mode 100644
index 00000000000..3b1d13db6bd
--- /dev/null
+++ b/python/test/Ice/slicing/objects/Test.ice
@@ -0,0 +1,164 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+class SBase
+{
+ string sb;
+};
+
+class SBSKnownDerived extends SBase
+{
+ string sbskd;
+};
+
+class B
+{
+ string sb;
+ B pb;
+};
+
+class D1 extends B
+{
+ string sd1;
+ B pd1;
+};
+
+sequence<B> BSeq;
+
+class SS1
+{
+ BSeq s;
+};
+
+class SS2
+{
+ BSeq s;
+};
+
+struct SS3
+{
+ SS1 c1;
+ SS2 c2;
+};
+
+dictionary<int, B> BDict;
+
+exception BaseException
+{
+ string sbe;
+ B pb;
+};
+
+exception DerivedException extends BaseException
+{
+ string sde;
+ D1 pd1;
+};
+
+class Forward; /* Forward-declared class defined in another compilation unit */
+
+class PBase
+{
+ int pi;
+};
+
+sequence<PBase> PBaseSeq;
+
+["preserve-slice"]
+class Preserved extends PBase
+{
+ string ps;
+};
+
+class PDerived extends Preserved
+{
+ PBase pb;
+};
+
+class CompactPDerived(56) extends Preserved
+{
+ PBase pb;
+};
+
+["preserve-slice"]
+class PNode
+{
+ PNode next;
+};
+
+["preserve-slice"]
+exception PreservedException
+{
+};
+
+["format:sliced"]
+interface TestIntf
+{
+ Object SBaseAsObject();
+ SBase SBaseAsSBase();
+ SBase SBSKnownDerivedAsSBase();
+ SBSKnownDerived SBSKnownDerivedAsSBSKnownDerived();
+
+ SBase SBSUnknownDerivedAsSBase();
+
+ ["format:compact"] SBase SBSUnknownDerivedAsSBaseCompact();
+
+ Object SUnknownAsObject();
+ void checkSUnknown(Object o);
+
+ B oneElementCycle();
+ B twoElementCycle();
+ B D1AsB();
+ D1 D1AsD1();
+ B D2AsB();
+
+ void paramTest1(out B p1, out B p2);
+ void paramTest2(out B p2, out B p1);
+ B paramTest3(out B p1, out B p2);
+ B paramTest4(out B p);
+
+ B returnTest1(out B p1, out B p2);
+ B returnTest2(out B p2, out B p1);
+ B returnTest3(B p1, B p2);
+
+ SS3 sequenceTest(SS1 p1, SS2 p2);
+
+ BDict dictionaryTest(BDict bin, out BDict bout);
+
+ PBase exchangePBase(PBase pb);
+
+ Preserved PBSUnknownAsPreserved();
+ void checkPBSUnknown(Preserved p);
+
+ ["amd"] Preserved PBSUnknownAsPreservedWithGraph();
+ void checkPBSUnknownWithGraph(Preserved p);
+
+ ["amd"] Preserved PBSUnknown2AsPreservedWithGraph();
+ void checkPBSUnknown2WithGraph(Preserved p);
+
+ PNode exchangePNode(PNode pn);
+
+ void throwBaseAsBase() throws BaseException;
+ void throwDerivedAsBase() throws BaseException;
+ void throwDerivedAsDerived() throws DerivedException;
+ void throwUnknownDerivedAsBase() throws BaseException;
+ ["amd"] void throwPreservedException() throws PreservedException;
+
+ void useForward(out Forward f); /* Use of forward-declared class to verify that code is generated correctly. */
+
+ void shutdown();
+};
+
+};
+
diff --git a/python/test/Ice/slicing/objects/TestAMD.ice b/python/test/Ice/slicing/objects/TestAMD.ice
new file mode 100644
index 00000000000..0d6f7eefb78
--- /dev/null
+++ b/python/test/Ice/slicing/objects/TestAMD.ice
@@ -0,0 +1,158 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+class SBase
+{
+ string sb;
+};
+
+class SBSKnownDerived extends SBase
+{
+ string sbskd;
+};
+
+class B
+{
+ string sb;
+ B pb;
+};
+
+class D1 extends B
+{
+ string sd1;
+ B pd1;
+};
+
+sequence<B> BSeq;
+
+class SS1
+{
+ BSeq s;
+};
+
+class SS2
+{
+ BSeq s;
+};
+
+struct SS3
+{
+ SS1 c1;
+ SS2 c2;
+};
+
+dictionary<int, B> BDict;
+
+exception BaseException
+{
+ string sbe;
+ B pb;
+};
+
+exception DerivedException extends BaseException
+{
+ string sde;
+ D1 pd1;
+};
+
+class Forward; // Forward-declared class defined in another compilation unit
+
+class PBase
+{
+ int pi;
+};
+
+sequence<PBase> PBaseSeq;
+
+["preserve-slice"]
+class Preserved extends PBase
+{
+ string ps;
+};
+
+class PDerived extends Preserved
+{
+ PBase pb;
+};
+
+["preserve-slice"]
+class PNode
+{
+ PNode next;
+};
+
+["preserve-slice"]
+exception PreservedException
+{
+};
+
+["amd", "format:sliced"]
+interface TestIntf
+{
+ Object SBaseAsObject();
+ SBase SBaseAsSBase();
+ SBase SBSKnownDerivedAsSBase();
+ SBSKnownDerived SBSKnownDerivedAsSBSKnownDerived();
+
+ SBase SBSUnknownDerivedAsSBase();
+
+ ["format:compact"] SBase SBSUnknownDerivedAsSBaseCompact();
+
+ Object SUnknownAsObject();
+ void checkSUnknown(Object o);
+
+ B oneElementCycle();
+ B twoElementCycle();
+ B D1AsB();
+ D1 D1AsD1();
+ B D2AsB();
+
+ void paramTest1(out B p1, out B p2);
+ void paramTest2(out B p2, out B p1);
+ B paramTest3(out B p1, out B p2);
+ B paramTest4(out B p);
+
+ B returnTest1(out B p1, out B p2);
+ B returnTest2(out B p2, out B p1);
+ B returnTest3(B p1, B p2);
+
+ SS3 sequenceTest(SS1 p1, SS2 p2);
+
+ BDict dictionaryTest(BDict bin, out BDict bout);
+
+ PBase exchangePBase(PBase pb);
+
+ Preserved PBSUnknownAsPreserved();
+ void checkPBSUnknown(Preserved p);
+
+ Preserved PBSUnknownAsPreservedWithGraph();
+ void checkPBSUnknownWithGraph(Preserved p);
+
+ Preserved PBSUnknown2AsPreservedWithGraph();
+ void checkPBSUnknown2WithGraph(Preserved p);
+
+ PNode exchangePNode(PNode pn);
+
+ void throwBaseAsBase() throws BaseException;
+ void throwDerivedAsBase() throws BaseException;
+ void throwDerivedAsDerived() throws DerivedException;
+ void throwUnknownDerivedAsBase() throws BaseException;
+ void throwPreservedException() throws PreservedException;
+
+ void useForward(out Forward f); /* Use of forward-declared class to verify that code is generated correctly. */
+
+ void shutdown();
+};
+
+};
diff --git a/python/test/Ice/slicing/objects/run.py b/python/test/Ice/slicing/objects/run.py
new file mode 100755
index 00000000000..a2cb1c4544e
--- /dev/null
+++ b/python/test/Ice/slicing/objects/run.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../..", "../../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+print("Running test with sliced format.")
+TestUtil.clientServerTest()
+
+print("Running test with 1.0 encoding.")
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
+
+print("Running test with sliced format and AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py")
+
+print("Running test with 1.0 encoding and AMD server.")
+TestUtil.clientServerTest(server="ServerAMD.py",
+ additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
diff --git a/python/test/Ice/timeout/AllTests.py b/python/test/Ice/timeout/AllTests.py
new file mode 100644
index 00000000000..d9db6f705b1
--- /dev/null
+++ b/python/test/Ice/timeout/AllTests.py
@@ -0,0 +1,259 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, sys, threading, time
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class CallbackBase:
+ def __init__(self):
+ self._called = False
+ self._cond = threading.Condition()
+
+ def called(self):
+ self._cond.acquire()
+ self._called = True
+ self._cond.notify()
+ self._cond.release()
+
+ def check(self):
+ self._cond.acquire()
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ return True
+
+class Callback(CallbackBase):
+ def response(self):
+ self.called()
+
+ def exception(self, ex):
+ test(False)
+
+ def responseEx(self):
+ test(False)
+
+ def exceptionEx(self, ex):
+ test(isinstance(ex, Ice.TimeoutException))
+ self.called()
+
+def allTests(communicator):
+ sref = "timeout:default -p 12010"
+ obj = communicator.stringToProxy(sref)
+ test(obj != None)
+
+ timeout = Test.TimeoutPrx.checkedCast(obj)
+ test(timeout != None)
+
+ sys.stdout.write("testing connect timeout... ")
+ sys.stdout.flush()
+ #
+ # Expect ConnectTimeoutException.
+ #
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(100))
+ timeout.holdAdapter(500)
+ try:
+ to.op()
+ test(False)
+ except Ice.ConnectTimeoutException:
+ pass # Expected.
+ #
+ # Expect success.
+ #
+ timeout.op() # Ensure adapter is active.
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(1000))
+ timeout.holdAdapter(500)
+ try:
+ to.op()
+ except Ice.ConnectTimeoutException:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("testing connection timeout... ")
+ sys.stdout.flush()
+ #
+ # Expect TimeoutException.
+ #
+ if sys.version_info[0] == 2:
+ seq = []
+ seq[0:10000000] = range(0, 10000000) # add 10,000,000 entries.
+ seq = ['\x00' for x in seq] # set them all to \x00
+ seq = ''.join(seq) # make into a byte array
+ else:
+ seq = bytes([0 for x in range(0, 10000000)])
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(100))
+ timeout.holdAdapter(500)
+ try:
+ to.sendData(seq)
+ test(False)
+ except Ice.TimeoutException:
+ pass # Expected.
+ #
+ # Expect success.
+ #
+ timeout.op() # Ensure adapter is active.
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(1000))
+ timeout.holdAdapter(500)
+ try:
+ if sys.version_info[0] == 2:
+ seq2 = []
+ seq2[0:1000000] = range(0, 1000000) # add 1,000,000 entries.
+ seq2 = ['\x00' for x in seq2] # set them all to \x00
+ seq2 = ''.join(seq2) # make into a byte array
+ else:
+ seq2 = bytes([0 for x in range(0, 1000000)])
+ to.sendData(seq2)
+ except Ice.TimeoutException:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("testing invocation timeout... ")
+ sys.stdout.flush()
+ connection = obj.ice_getConnection();
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100));
+ test(connection == to.ice_getConnection());
+ try:
+ to.sleep(750);
+ test(False);
+ except Ice.InvocationTimeoutException:
+ pass
+ obj.ice_ping();
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500));
+ test(connection == to.ice_getConnection());
+ try:
+ to.sleep(250);
+ except Ice.InvocationTimeoutException:
+ test(False);
+ test(connection == to.ice_getConnection());
+
+ # #
+ # # Expect InvocationTimeoutException.
+ # #
+ # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(250));
+ # cb = new Callback();
+ # to.begin_sleep(750, newCallback_Timeout_sleep(cb, &Callback.responseEx, &Callback.exceptionEx));
+ # cb.check();
+
+ # #
+ # # Expect success.
+ # #
+ # to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500));
+ # cb = new Callback();
+ # to.begin_sleep(250, newCallback_Timeout_sleep(cb, &Callback.response, &Callback.exception));
+ # cb.check();
+ print("ok")
+
+ sys.stdout.write("testing close timeout... ")
+ sys.stdout.flush()
+ to = Test.TimeoutPrx.checkedCast(obj.ice_timeout(100));
+ connection = to.ice_getConnection();
+ timeout.holdAdapter(500);
+ connection.close(False);
+ try:
+ connection.getInfo(); # getInfo() doesn't throw in the closing state.
+ except Ice.LocalException:
+ test(False);
+ time.sleep(0.5);
+ try:
+ connection.getInfo();
+ test(False);
+ except Ice.CloseConnectionException:
+ # Expected.
+ pass
+ timeout.op(); # Ensure adapter is active.
+ print("ok")
+
+ sys.stdout.write("testing timeout overrides... ")
+ sys.stdout.flush()
+
+ #
+ # Test Ice.Override.Timeout. This property overrides all
+ # endpoint timeouts.
+ #
+ initData = Ice.InitializationData()
+ initData.properties = communicator.getProperties().clone()
+ initData.properties.setProperty("Ice.Override.Timeout", "100")
+ comm = Ice.initialize(initData)
+ to = Test.TimeoutPrx.checkedCast(comm.stringToProxy(sref))
+ timeout.holdAdapter(500)
+ try:
+ to.sendData(seq)
+ test(False)
+ except Ice.TimeoutException:
+ pass # Expected.
+ #
+ # Calling ice_timeout() should have no effect.
+ #
+ timeout.op() # Ensure adapter is active.
+ to = Test.TimeoutPrx.checkedCast(to.ice_timeout(1000))
+ timeout.holdAdapter(500);
+ try:
+ to.sendData(seq)
+ test(False)
+ except Ice.TimeoutException:
+ pass # Expected.
+ comm.destroy()
+ #
+ # Test Ice.Override.ConnectTimeout.
+ #
+ initData = Ice.InitializationData()
+ initData.properties = communicator.getProperties().clone()
+ initData.properties.setProperty("Ice.Override.ConnectTimeout", "250")
+ comm = Ice.initialize(initData)
+ timeout.holdAdapter(750)
+ to = Test.TimeoutPrx.uncheckedCast(comm.stringToProxy(sref))
+ try:
+ to.op()
+ test(False)
+ except Ice.ConnectTimeoutException:
+ pass # Expected.
+ #
+ # Calling ice_timeout() should have no effect on the connect timeout.
+ #
+ timeout.op() # Ensure adapter is active.
+ timeout.holdAdapter(750)
+ to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(1000))
+ try:
+ to.op()
+ test(False)
+ except Ice.ConnectTimeoutException:
+ pass # Expected.
+ #
+ # Verify that timeout set via ice_timeout() is still used for requests.
+ #
+ timeout.op() # Ensure adapter is active.
+ to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(100));
+ to.ice_getConnection(); # Establish connection
+ timeout.holdAdapter(750);
+ try:
+ to.sendData(seq)
+ test(False)
+ except Ice.TimeoutException:
+ pass # Expected.
+ comm.destroy()
+
+ #
+ # Test Ice.Override.CloseTimeout.
+ #
+ initData = Ice.InitializationData()
+ initData.properties = communicator.getProperties().clone()
+ initData.properties.setProperty("Ice.Override.CloseTimeout", "100")
+ comm = Ice.initialize(initData)
+ connection = comm.stringToProxy(sref).ice_getConnection();
+ timeout.holdAdapter(500);
+ now = time.clock();
+ comm.destroy();
+ test((time.clock() - now) < 0.4);
+
+ print("ok")
+
+
+ return timeout
diff --git a/python/test/Ice/timeout/Client.py b/python/test/Ice/timeout/Client.py
new file mode 100755
index 00000000000..0cee6a61c9e
--- /dev/null
+++ b/python/test/Ice/timeout/Client.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+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 AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ timeout = AllTests.allTests(communicator)
+ timeout.shutdown()
+
+ return True
+
+try:
+ #
+ # In this test, we need at least two threads in the
+ # client side thread pool for nested AMI.
+ #
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+
+ #
+ # We need to send messages large enough to cause the transport
+ # buffers to fill up.
+ #
+ initData.properties.setProperty("Ice.MessageSizeMax", "10000");
+
+ #
+ # For this test, we want to disable retries.
+ #
+ initData.properties.setProperty("Ice.RetryIntervals", "-1");
+
+ #
+ # This test kills connections, so we don't want warnings.
+ #
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+
+ #
+ # Limit the send buffer size, this test relies on the socket
+ # send() blocking after sending a given amount of data.
+ #
+ initData.properties.setProperty("Ice.TCP.SndSize", "50000");
+
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/timeout/Server.py b/python/test/Ice/timeout/Server.py
new file mode 100755
index 00000000000..058491d9011
--- /dev/null
+++ b/python/test/Ice/timeout/Server.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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, time, threading
+
+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)
+ self._adapter = adapter
+ self._timeout = timeout
+
+ def run(self):
+ time.sleep(self._timeout / 1000.0)
+ self._adapter.activate()
+
+class TimeoutI(Test.Timeout):
+ def op(self, current=None):
+ pass
+
+ def sendData(self, data, current=None):
+ pass
+
+ def sleep(self, timeout, current=None):
+ if timeout != 0:
+ time.sleep(timeout / 1000.0)
+
+ def holdAdapter(self, to, current=None):
+ current.adapter.hold()
+ t = ActivateAdapterThread(current.adapter, to)
+ t.start()
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(TimeoutI(), communicator.stringToIdentity("timeout"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+ #
+ # 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");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/timeout/Test.ice b/python/test/Ice/timeout/Test.ice
new file mode 100644
index 00000000000..dc54d71c16c
--- /dev/null
+++ b/python/test/Ice/timeout/Test.ice
@@ -0,0 +1,28 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+sequence<byte> ByteSeq;
+
+interface Timeout
+{
+ void op();
+ void sendData(ByteSeq seq);
+ void sleep(int to);
+
+ void holdAdapter(int to);
+
+ void shutdown();
+};
+
+};
diff --git a/python/test/Ice/timeout/run.py b/python/test/Ice/timeout/run.py
new file mode 100755
index 00000000000..74d2e5d1724
--- /dev/null
+++ b/python/test/Ice/timeout/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/python/test/Makefile b/python/test/Makefile
new file mode 100644
index 00000000000..23caa0e5bda
--- /dev/null
+++ b/python/test/Makefile
@@ -0,0 +1,21 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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.
+#
+# **********************************************************************
+
+top_srcdir = ..
+
+include $(top_srcdir)/config/Make.rules
+
+SUBDIRS = Slice
+
+$(EVERYTHING)::
+ @for subdir in $(SUBDIRS); \
+ do \
+ echo "making $@ in $$subdir"; \
+ ( cd $$subdir && $(MAKE) $@ ) || exit 1; \
+ done
diff --git a/python/test/Makefile.mak b/python/test/Makefile.mak
new file mode 100644
index 00000000000..9830e50eb83
--- /dev/null
+++ b/python/test/Makefile.mak
@@ -0,0 +1,19 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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.
+#
+# **********************************************************************
+
+top_srcdir = ..
+
+!include $(top_srcdir)\config\Make.rules.mak
+
+SUBDIRS = Slice
+
+$(EVERYTHING)::
+ @for %i in ( $(SUBDIRS) ) do \
+ @echo "making $@ in %i" && \
+ cmd /c "cd %i && $(MAKE) -nologo -f Makefile.mak $@" || exit 1
diff --git a/python/test/Slice/Makefile b/python/test/Slice/Makefile
new file mode 100644
index 00000000000..19f18553195
--- /dev/null
+++ b/python/test/Slice/Makefile
@@ -0,0 +1,21 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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.
+#
+# **********************************************************************
+
+top_srcdir = ../..
+
+include $(top_srcdir)/config/Make.rules
+
+SUBDIRS = import
+
+$(EVERYTHING)::
+ @for subdir in $(SUBDIRS); \
+ do \
+ echo "making $@ in $$subdir"; \
+ ( cd $$subdir && $(MAKE) $@ ) || exit 1; \
+ done
diff --git a/python/test/Slice/Makefile.mak b/python/test/Slice/Makefile.mak
new file mode 100644
index 00000000000..2646dddc07c
--- /dev/null
+++ b/python/test/Slice/Makefile.mak
@@ -0,0 +1,19 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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.
+#
+# **********************************************************************
+
+top_srcdir = ..\..
+
+!include $(top_srcdir)\config\Make.rules.mak
+
+SUBDIRS = import
+
+$(EVERYTHING)::
+ @for %i in ( $(SUBDIRS) ) do \
+ @echo "making $@ in %i" && \
+ cmd /c "cd %i && $(MAKE) -nologo -f Makefile.mak $@" || exit 1
diff --git a/python/test/Slice/import/.depend.mak b/python/test/Slice/import/.depend.mak
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/python/test/Slice/import/.depend.mak
diff --git a/python/test/Slice/import/.gitignore b/python/test/Slice/import/.gitignore
new file mode 100644
index 00000000000..88325c99134
--- /dev/null
+++ b/python/test/Slice/import/.gitignore
@@ -0,0 +1,3 @@
+Test1_ice.py
+Test2_ice.py
+Test
diff --git a/python/test/Slice/import/Client.py b/python/test/Slice/import/Client.py
new file mode 100755
index 00000000000..a8f9a1956b0
--- /dev/null
+++ b/python/test/Slice/import/Client.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
+ toplevel = os.path.normpath(toplevel)
+ if os.path.exists(os.path.join(toplevel, "python", "Ice.py")):
+ break
+else:
+ raise RuntimeError("can't find toplevel directory!")
+
+import Test
+
+status = True
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+try:
+ sys.stdout.write("testing imports... ")
+ sys.stdout.flush()
+
+ test(Test.SubA.SubSubA1.Value1 == 10)
+ test(Test.SubA.SubSubA1.Value2 == 11)
+ test(Test.SubA.SubSubA2.Value1 == 30)
+ test(Test.SubB.SubSubB1.Value1 == 20)
+ test(Test.SubB.SubSubB1.Value2 == 21)
+
+ print("ok")
+except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Slice/import/Makefile b/python/test/Slice/import/Makefile
new file mode 100644
index 00000000000..91581b604f5
--- /dev/null
+++ b/python/test/Slice/import/Makefile
@@ -0,0 +1,32 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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.
+#
+# **********************************************************************
+
+top_srcdir = ../../..
+
+include $(top_srcdir)/config/Make.rules
+
+#
+# Parallel builds are not supported because multiple executions of slice2py could
+# attempt to modify the __init__.py file simultaneously.
+#
+.NOTPARALLEL:
+
+SRCS = Test1_ice.py \
+ Test2_ice.py
+
+all:: $(SRCS)
+
+Test1_ice.py: Test1.ice $(SLICE2PY) $(SLICEPARSERLIB)
+ $(SLICE2PY) $(SLICE2PYFLAGS) $<
+
+Test2_ice.py: Test2.ice $(SLICE2PY) $(SLICEPARSERLIB)
+ $(SLICE2PY) $(SLICE2PYFLAGS) $<
+
+clean::
+ rm -rf $(SRCS) Test
diff --git a/python/test/Slice/import/Makefile.mak b/python/test/Slice/import/Makefile.mak
new file mode 100644
index 00000000000..f56fb6a3d87
--- /dev/null
+++ b/python/test/Slice/import/Makefile.mak
@@ -0,0 +1,29 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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.
+#
+# **********************************************************************
+
+top_srcdir = ..\..\..
+
+!include $(top_srcdir)\config\Make.rules.mak
+
+SRCS = Test1_ice.py \
+ Test2_ice.py
+
+all:: $(SRCS)
+
+Test1_ice.py: "Test1.ice" "$(SLICE2PY)" "$(SLICEPARSERLIB)"
+ "$(SLICE2PY)" $(SLICE2PYFLAGS) "Test1.ice"
+
+Test2_ice.py: "Test2.ice" "$(SLICE2PY)" "$(SLICEPARSERLIB)"
+ "$(SLICE2PY)" $(SLICE2PYFLAGS) "Test2.ice"
+
+clean::
+ -rmdir /s /q Test
+ del /q $(SRCS)
+
+include .depend.mak
diff --git a/python/test/Slice/import/Test1.ice b/python/test/Slice/import/Test1.ice
new file mode 100644
index 00000000000..48f6af92c8e
--- /dev/null
+++ b/python/test/Slice/import/Test1.ice
@@ -0,0 +1,27 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+module Test
+{
+ module SubA
+ {
+ module SubSubA1
+ {
+ const int Value1 = 10;
+ };
+ };
+
+ module SubB
+ {
+ module SubSubB1
+ {
+ const int Value1 = 20;
+ };
+ };
+};
diff --git a/python/test/Slice/import/Test2.ice b/python/test/Slice/import/Test2.ice
new file mode 100644
index 00000000000..4cd0913081c
--- /dev/null
+++ b/python/test/Slice/import/Test2.ice
@@ -0,0 +1,31 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+module Test
+{
+ module SubA
+ {
+ module SubSubA1
+ {
+ const int Value2 = 11;
+ };
+ module SubSubA2
+ {
+ const int Value1 = 30;
+ };
+ };
+
+ module SubB
+ {
+ module SubSubB1
+ {
+ const int Value2 = 21;
+ };
+ };
+};
diff --git a/python/test/Slice/import/run.py b/python/test/Slice/import/run.py
new file mode 100755
index 00000000000..2054bdd7692
--- /dev/null
+++ b/python/test/Slice/import/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+sys.stdout.write("starting client... ")
+sys.stdout.flush()
+clientProc = TestUtil.startClient("Client.py", "--Ice.Default.Host=127.0.0.1", startReader = False)
+print("ok")
+clientProc.startReader()
+clientProc.waitTestSuccess()
diff --git a/python/test/Slice/keyword/Client.py b/python/test/Slice/keyword/Client.py
new file mode 100755
index 00000000000..82560627c27
--- /dev/null
+++ b/python/test/Slice/keyword/Client.py
@@ -0,0 +1,118 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
+ toplevel = os.path.normpath(toplevel)
+ if os.path.exists(os.path.join(toplevel, "python", "Ice.py")):
+ break
+else:
+ raise RuntimeError("can't find toplevel directory!")
+
+import Ice
+
+Ice.loadSlice('Key.ice')
+import _and
+
+class delI(_and._del):
+ def _elif_async(self, _cb, _else, current=None):
+ pass
+
+class execI(_and._exec):
+ def _finally(self, current=None):
+ assert current.operation == "finally"
+
+class forI(_and._for):
+ def foo(self, _from, current=None):
+ pass
+
+class ifI(_and._if):
+ def _elif_async(self, _cb, _else, current=None):
+ pass
+ def _finally(self, current=None):
+ pass
+ def foo(self, _from, current=None):
+ pass
+
+class printI(_and._print):
+ def _raise(self, _else, _return, _try, _while, _yield, _lambda, _or, _global):
+ pass
+
+def testtypes():
+ sys.stdout.write("Testing generated type names... ")
+ sys.stdout.flush()
+ a = _and._assert._break
+ b = _and._continue
+ b._def = 0
+ c = _and.delPrx.uncheckedCast(None)
+ assert "_elif" in dir(_and.delPrx)
+ c1 = delI()
+ d = _and.execPrx.uncheckedCast(None)
+ assert "_finally" in dir(_and.execPrx)
+ d1 = execI()
+
+ e1 = forI()
+ f = _and.ifPrx.uncheckedCast(None)
+
+ assert "_finally" in dir(_and.ifPrx)
+ assert "_elif" in dir(_and.ifPrx)
+ f1 = ifI()
+ g = _and._is()
+ g._lamba = 0
+ h = _and._not()
+ h._lamba = 0
+ h._or = 1
+ h._pass = 2
+ i = printI()
+ j = _and._lambda;
+ en = _and.EnumNone._None
+ print("ok")
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(execI(), communicator.stringToIdentity("test"))
+ adapter.activate()
+
+ sys.stdout.write("Testing operation name... ")
+ sys.stdout.flush()
+ p = _and.execPrx.uncheckedCast(
+ adapter.createProxy(communicator.stringToIdentity("test")));
+ p._finally();
+ print("ok")
+
+ testtypes()
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ #
+ # Its possible to have batch oneway requests dispatched after the
+ # adapter is deactivated due to thread scheduling so we supress
+ # this warning.
+ #
+ initData.properties.setProperty("Ice.Warn.Dispatch", "0");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Slice/keyword/Key.ice b/python/test/Slice/keyword/Key.ice
new file mode 100644
index 00000000000..6e46ad0748c
--- /dev/null
+++ b/python/test/Slice/keyword/Key.ice
@@ -0,0 +1,67 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+module and
+{
+ enum assert
+ {
+ break
+ };
+
+ struct continue
+ {
+ int def;
+ };
+
+ interface del
+ {
+ ["amd"] void elif(int else, out int except);
+ };
+
+ interface exec
+ {
+ void finally();
+ };
+
+ class for
+ {
+ int lambda;
+ void foo(exec* from, out int global);
+ };
+
+ class if extends for implements exec, del
+ {
+ };
+
+ sequence<assert> import;
+ dictionary<string,assert> in;
+
+ exception is
+ {
+ int lambda;
+ };
+ exception not extends is
+ {
+ int or;
+ int pass;
+ };
+
+ local interface print
+ {
+ assert raise(continue else, for return, if try, del* while, exec* yield,
+ for* lambda, if* or, int global)
+ throws is;
+ };
+
+ const int lambda = 0;
+
+ enum EnumNone {
+ None
+ };
+};
diff --git a/python/test/Slice/keyword/run.py b/python/test/Slice/keyword/run.py
new file mode 100755
index 00000000000..2054bdd7692
--- /dev/null
+++ b/python/test/Slice/keyword/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+sys.stdout.write("starting client... ")
+sys.stdout.flush()
+clientProc = TestUtil.startClient("Client.py", "--Ice.Default.Host=127.0.0.1", startReader = False)
+print("ok")
+clientProc.startReader()
+clientProc.waitTestSuccess()
diff --git a/python/test/Slice/macros/Client.py b/python/test/Slice/macros/Client.py
new file mode 100755
index 00000000000..a64d7faf9b0
--- /dev/null
+++ b/python/test/Slice/macros/Client.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
+ toplevel = os.path.normpath(toplevel)
+ if os.path.exists(os.path.join(toplevel, "python", "Ice.py")):
+ break
+else:
+ raise RuntimeError("can't find toplevel directory!")
+
+import Ice
+
+Ice.loadSlice('Test.ice')
+import Test, copy
+
+status = True
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+try:
+ sys.stdout.write("testing Slice predefined macros... ")
+ sys.stdout.flush()
+
+ d = Test.Default()
+ test(d.x == 10)
+ test(d.y == 10)
+
+ nd = Test.NoDefault()
+ test(nd.x != 10)
+ test(nd.y != 10)
+
+ c = Test.PythonOnly()
+ test(c.lang == "python")
+ test(c.version == Ice.intVersion())
+ print("ok")
+except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Slice/macros/Test.ice b/python/test/Slice/macros/Test.ice
new file mode 100644
index 00000000000..825c641fffa
--- /dev/null
+++ b/python/test/Slice/macros/Test.ice
@@ -0,0 +1,54 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+//
+// This macro sets the default value only when compiling with slice2py.
+//
+#ifdef __SLICE2PY__
+# define DEFAULT(X) = X
+#else
+# define DEFAULT(X) /**/
+#endif
+
+//
+// This macro sets the default value only when not compiling with slice2py.
+//
+#ifndef __SLICE2PY__
+# define NODEFAULT(X) = X
+#else
+# define NODEFAULT(X) /**/
+#endif
+
+module Test
+{
+
+class Default
+{
+ int x DEFAULT(10);
+ int y DEFAULT(10);
+};
+
+class NoDefault
+{
+ int x NODEFAULT(10);
+ int y NODEFAULT(10);
+};
+
+//
+// This class is only defined when compiling with slice2py.
+//
+#ifdef __SLICE2PY__
+class PythonOnly
+{
+ string lang DEFAULT("python");
+ int version DEFAULT(ICE_VERSION);
+};
+#endif
+
+};
diff --git a/python/test/Slice/macros/run.py b/python/test/Slice/macros/run.py
new file mode 100755
index 00000000000..2054bdd7692
--- /dev/null
+++ b/python/test/Slice/macros/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+sys.stdout.write("starting client... ")
+sys.stdout.flush()
+clientProc = TestUtil.startClient("Client.py", "--Ice.Default.Host=127.0.0.1", startReader = False)
+print("ok")
+clientProc.startReader()
+clientProc.waitTestSuccess()
diff --git a/python/test/Slice/structure/Client.py b/python/test/Slice/structure/Client.py
new file mode 100755
index 00000000000..036ce2121d1
--- /dev/null
+++ b/python/test/Slice/structure/Client.py
@@ -0,0 +1,211 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
+ toplevel = os.path.normpath(toplevel)
+ if os.path.exists(os.path.join(toplevel, "python", "Ice.py")):
+ break
+else:
+ raise RuntimeError("can't find toplevel directory!")
+
+import Ice
+
+Ice.loadSlice('Test.ice')
+import Test, copy
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def allTests(communicator):
+ sys.stdout.write("testing equals() for Slice structures... ")
+ sys.stdout.flush()
+
+ #
+ # Define some default values.
+ #
+ def_s2 = Test.S2(True, 98, 99, 100, 101, "string", (1, 2, 3), Test.S1("name"))
+
+ #
+ # Compare default-constructed structures.
+ #
+ test(Test.S2() == Test.S2())
+
+ #
+ # Change one member at a time.
+ #
+ v = copy.copy(def_s2)
+ test(v == def_s2)
+
+ v = copy.copy(def_s2)
+ v.bo = False
+ test(v != def_s2)
+
+ v = copy.copy(def_s2)
+ v.by = v.by - 1
+ test(v != def_s2)
+
+ v = copy.copy(def_s2)
+ v.sh = v.sh - 1
+ test(v != def_s2)
+
+ v = copy.copy(def_s2)
+ v.i = v.i - 1
+ test(v != def_s2)
+
+ v = copy.copy(def_s2)
+ v.l = v.l - 1
+ test(v != def_s2)
+
+ v = copy.copy(def_s2)
+ v.str = ""
+ test(v != def_s2)
+
+ #
+ # String member
+ #
+ v1 = copy.copy(def_s2)
+ v1.str = "string"
+ test(v1 == def_s2)
+
+ v1 = copy.copy(def_s2)
+ v2 = copy.copy(def_s2)
+ v1.str = None
+ test(v1 != v2)
+
+ v1 = copy.copy(def_s2)
+ v2 = copy.copy(def_s2)
+ v2.str = None
+ test(v1 != v2)
+
+ v1 = copy.copy(def_s2)
+ v2 = copy.copy(def_s2)
+ v1.str = None
+ v2.str = None
+ test(v1 == v2)
+
+ #
+ # Sequence member
+ #
+ v1 = copy.copy(def_s2)
+ v1.seq = copy.copy(def_s2.seq)
+ test(v1 == def_s2)
+
+ v1 = copy.copy(def_s2)
+ v1.seq = ()
+ test(v1 != def_s2)
+
+ v1 = copy.copy(def_s2)
+ v1.seq = (1, 2, 3)
+ test(v1 == def_s2)
+
+ v1 = copy.copy(def_s2)
+ v2 = copy.copy(def_s2)
+ v1.seq = None
+ test(v1 != v2)
+
+ v1 = copy.copy(def_s2)
+ v2 = copy.copy(def_s2)
+ v2.seq = None
+ test(v1 != v2)
+
+ #
+ # Struct member
+ #
+ v1 = copy.copy(def_s2)
+ v1.s = copy.copy(def_s2.s)
+ test(v1 == def_s2)
+
+ v1 = copy.copy(def_s2)
+ v1.s = Test.S1("name")
+ test(v1 == def_s2)
+
+ v1 = copy.copy(def_s2)
+ v1.s = Test.S1("noname")
+ test(v1 != def_s2)
+
+ v1 = copy.copy(def_s2)
+ v2 = copy.copy(def_s2)
+ v1.s = None
+ test(v1 != v2)
+
+ v1 = copy.copy(def_s2)
+ v2 = copy.copy(def_s2)
+ v2.s = None
+ test(v1 != v2)
+
+ #
+ # Define some default values.
+ #
+ def_s3 = Test.S3(Test.C("name"), {"1":"2"}, communicator.stringToProxy("test"))
+
+ #
+ # Compare default-constructed structures.
+ #
+ test(Test.S3() == Test.S3())
+
+ #
+ # Change one member at a time.
+ #
+ v1 = copy.copy(def_s3)
+ test(v1 == def_s3)
+
+ v1.obj = None
+ test(v1 != def_s3)
+
+ v1.obj = Test.C("name")
+ test(v1 != def_s3)
+
+ v1 = copy.copy(def_s3)
+ v1.sd = copy.copy(def_s3.sd)
+ test(v1 == def_s3)
+
+ v1.sd = None
+ test(v1 != def_s3)
+
+ v1.sd = {"1":"3"}
+ test(v1 != def_s3)
+
+ v1 = copy.copy(def_s3)
+ v1.prx = None
+ test(v1 != def_s3)
+
+ v1.prx = communicator.stringToProxy("test")
+ test(v1 == def_s3)
+
+ v1.prx = communicator.stringToProxy("test2")
+ test(v1 != def_s3)
+
+ print("ok")
+
+def run(args, communicator):
+ allTests(communicator)
+
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Slice/structure/Test.ice b/python/test/Slice/structure/Test.ice
new file mode 100644
index 00000000000..973a80ad921
--- /dev/null
+++ b/python/test/Slice/structure/Test.ice
@@ -0,0 +1,47 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+[["cpp:include:list"]]
+
+module Test
+{
+
+sequence<int> IntSeq;
+dictionary<string, string> StringDict;
+
+struct S1
+{
+ string name;
+};
+
+struct S2
+{
+ bool bo;
+ byte by;
+ short sh;
+ int i;
+ long l;
+ string str;
+ IntSeq seq;
+ S1 s;
+};
+
+class C
+{
+ string name;
+};
+
+struct S3
+{
+ C obj;
+ StringDict sd;
+ Object* prx;
+};
+
+};
diff --git a/python/test/Slice/structure/run.py b/python/test/Slice/structure/run.py
new file mode 100755
index 00000000000..2054bdd7692
--- /dev/null
+++ b/python/test/Slice/structure/run.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+sys.stdout.write("starting client... ")
+sys.stdout.flush()
+clientProc = TestUtil.startClient("Client.py", "--Ice.Default.Host=127.0.0.1", startReader = False)
+print("ok")
+clientProc.startReader()
+clientProc.waitTestSuccess()