summaryrefslogtreecommitdiff
path: root/python/test
diff options
context:
space:
mode:
Diffstat (limited to 'python/test')
-rw-r--r--python/test/Ice/acm/AllTests.py119
-rwxr-xr-xpython/test/Ice/acm/Client.py11
-rwxr-xr-xpython/test/Ice/acm/Server.py13
-rw-r--r--python/test/Ice/acm/Test.ice3
-rw-r--r--python/test/Ice/acm/TestI.py74
-rwxr-xr-xpython/test/Ice/acm/run.py23
-rw-r--r--python/test/Ice/adapterDeactivation/AllTests.py4
-rw-r--r--python/test/Ice/adapterDeactivation/TestI.py2
-rwxr-xr-xpython/test/Ice/adapterDeactivation/run.py24
-rw-r--r--python/test/Ice/admin/AllTests.py2
-rw-r--r--python/test/Ice/admin/Client.py11
-rw-r--r--python/test/Ice/admin/Server.py13
-rw-r--r--python/test/Ice/admin/TestI.py16
-rwxr-xr-xpython/test/Ice/admin/run.py23
-rw-r--r--python/test/Ice/ami/AllTests.py840
-rwxr-xr-xpython/test/Ice/ami/Client.py13
-rwxr-xr-xpython/test/Ice/ami/Collocated.py17
-rwxr-xr-xpython/test/Ice/ami/Server.py19
-rw-r--r--python/test/Ice/ami/Test.ice15
-rw-r--r--python/test/Ice/ami/TestI.py50
-rwxr-xr-xpython/test/Ice/ami/run.py26
-rw-r--r--python/test/Ice/application/test.py10
-rw-r--r--python/test/Ice/binding/AllTests.py83
-rwxr-xr-xpython/test/Ice/binding/Client.py11
-rwxr-xr-xpython/test/Ice/binding/Server.py13
-rw-r--r--python/test/Ice/binding/TestI.py8
-rwxr-xr-xpython/test/Ice/binding/run.py23
-rwxr-xr-xpython/test/Ice/blobject/Client.py42
-rw-r--r--python/test/Ice/blobject/RouterI.py95
-rwxr-xr-xpython/test/Ice/blobject/Server.py15
-rwxr-xr-xpython/test/Ice/blobject/run.py23
-rw-r--r--python/test/Ice/checksum/AllTests.py1
-rw-r--r--python/test/Ice/checksum/CTypes.ice68
-rwxr-xr-xpython/test/Ice/checksum/Client.py11
-rw-r--r--python/test/Ice/checksum/STypes.ice66
-rwxr-xr-xpython/test/Ice/checksum/Server.py15
-rwxr-xr-xpython/test/Ice/checksum/run.py23
-rwxr-xr-xpython/test/Ice/custom/Client.py11
-rwxr-xr-xpython/test/Ice/custom/Server.py15
-rwxr-xr-xpython/test/Ice/custom/run.py23
-rwxr-xr-xpython/test/Ice/defaultServant/Client.py11
-rw-r--r--python/test/Ice/defaultServant/MyObjectI.py2
-rwxr-xr-xpython/test/Ice/defaultServant/run.py29
-rw-r--r--python/test/Ice/defaultValue/Test.ice20
-rwxr-xr-xpython/test/Ice/defaultValue/run.py29
-rwxr-xr-xpython/test/Ice/enums/Client.py11
-rwxr-xr-xpython/test/Ice/enums/Server.py15
-rwxr-xr-xpython/test/Ice/enums/run.py28
-rw-r--r--python/test/Ice/exceptions/AllTests.py271
-rwxr-xr-xpython/test/Ice/exceptions/Client.py11
-rwxr-xr-xpython/test/Ice/exceptions/Collocated.py13
-rwxr-xr-xpython/test/Ice/exceptions/Server.py17
-rwxr-xr-xpython/test/Ice/exceptions/ServerAMD.py130
-rw-r--r--python/test/Ice/exceptions/TestI.py2
-rwxr-xr-xpython/test/Ice/exceptions/run.py48
-rw-r--r--python/test/Ice/facets/AllTests.py28
-rwxr-xr-xpython/test/Ice/facets/Client.py11
-rwxr-xr-xpython/test/Ice/facets/Collocated.py19
-rwxr-xr-xpython/test/Ice/facets/Server.py19
-rw-r--r--python/test/Ice/facets/TestI.py16
-rwxr-xr-xpython/test/Ice/facets/run.py24
-rw-r--r--python/test/Ice/faultTolerance/AllTests.py43
-rwxr-xr-xpython/test/Ice/faultTolerance/Client.py15
-rwxr-xr-xpython/test/Ice/faultTolerance/Server.py17
-rwxr-xr-xpython/test/Ice/faultTolerance/run.py47
-rw-r--r--python/test/Ice/info/AllTests.py106
-rwxr-xr-xpython/test/Ice/info/Client.py11
-rwxr-xr-xpython/test/Ice/info/Server.py13
-rw-r--r--python/test/Ice/info/TestI.py27
-rwxr-xr-xpython/test/Ice/info/run.py23
-rwxr-xr-xpython/test/Ice/inheritance/Client.py11
-rwxr-xr-xpython/test/Ice/inheritance/Collocated.py13
-rwxr-xr-xpython/test/Ice/inheritance/Server.py13
-rw-r--r--python/test/Ice/inheritance/Test.ice2
-rw-r--r--python/test/Ice/inheritance/TestI.py18
-rwxr-xr-xpython/test/Ice/inheritance/run.py24
-rw-r--r--python/test/Ice/location/AllTests.py92
-rwxr-xr-xpython/test/Ice/location/Client.py11
-rwxr-xr-xpython/test/Ice/location/Server.py65
-rwxr-xr-xpython/test/Ice/location/run.py23
-rw-r--r--python/test/Ice/objects/AllTests.py115
-rwxr-xr-xpython/test/Ice/objects/Client.py11
-rwxr-xr-xpython/test/Ice/objects/Collocated.py15
-rwxr-xr-xpython/test/Ice/objects/Server.py43
-rw-r--r--python/test/Ice/objects/Test.ice15
-rw-r--r--python/test/Ice/objects/TestI.py41
-rwxr-xr-xpython/test/Ice/objects/run.py35
-rw-r--r--python/test/Ice/operations/AllTests.py28
-rw-r--r--python/test/Ice/operations/BatchOneways.py7
-rw-r--r--python/test/Ice/operations/BatchOnewaysAMI.py16
-rw-r--r--python/test/Ice/operations/BatchOnewaysFuture.py88
-rwxr-xr-xpython/test/Ice/operations/Client.py16
-rwxr-xr-xpython/test/Ice/operations/Collocated.py13
-rw-r--r--python/test/Ice/operations/OnewaysAMI.py14
-rw-r--r--python/test/Ice/operations/OnewaysFuture.py54
-rwxr-xr-xpython/test/Ice/operations/Server.py13
-rwxr-xr-xpython/test/Ice/operations/ServerAMD.py407
-rw-r--r--python/test/Ice/operations/Test.ice21
-rw-r--r--python/test/Ice/operations/TestAMD.ice21
-rw-r--r--python/test/Ice/operations/TestI.py66
-rw-r--r--python/test/Ice/operations/Twoways.py42
-rw-r--r--python/test/Ice/operations/TwowaysAMI.py24
-rw-r--r--python/test/Ice/operations/TwowaysFuture.py1354
-rwxr-xr-xpython/test/Ice/operations/run.py28
-rw-r--r--python/test/Ice/optional/AllTests.py185
-rwxr-xr-xpython/test/Ice/optional/Client.py11
-rw-r--r--python/test/Ice/optional/ClientPrivate.ice2
-rwxr-xr-xpython/test/Ice/optional/Server.py45
-rwxr-xr-xpython/test/Ice/optional/ServerAMD.py226
-rw-r--r--python/test/Ice/optional/Test.ice22
-rw-r--r--python/test/Ice/optional/TestAMD.ice25
-rwxr-xr-xpython/test/Ice/optional/run.py28
-rwxr-xr-xpython/test/Ice/properties/run.py45
-rw-r--r--python/test/Ice/proxy/AllTests.py30
-rwxr-xr-xpython/test/Ice/proxy/Client.py11
-rwxr-xr-xpython/test/Ice/proxy/Collocated.py13
-rwxr-xr-xpython/test/Ice/proxy/Server.py13
-rwxr-xr-xpython/test/Ice/proxy/ServerAMD.py28
-rw-r--r--python/test/Ice/proxy/Test.ice4
-rw-r--r--python/test/Ice/proxy/TestAMD.ice4
-rw-r--r--python/test/Ice/proxy/TestI.py4
-rwxr-xr-xpython/test/Ice/proxy/run.py28
-rw-r--r--python/test/Ice/servantLocator/AllTests.py6
-rwxr-xr-xpython/test/Ice/servantLocator/Collocated.py4
-rwxr-xr-xpython/test/Ice/servantLocator/Server.py4
-rwxr-xr-xpython/test/Ice/servantLocator/ServerAMD.py4
-rw-r--r--python/test/Ice/servantLocator/TestAMDI.py71
-rw-r--r--python/test/Ice/servantLocator/TestActivationAMDI.py2
-rw-r--r--python/test/Ice/servantLocator/TestActivationI.py2
-rw-r--r--python/test/Ice/servantLocator/TestI.py2
-rwxr-xr-xpython/test/Ice/servantLocator/run.py28
-rw-r--r--python/test/Ice/slicing/exceptions/AllTests.py161
-rwxr-xr-xpython/test/Ice/slicing/exceptions/Client.py11
-rwxr-xr-xpython/test/Ice/slicing/exceptions/Server.py15
-rwxr-xr-xpython/test/Ice/slicing/exceptions/ServerAMD.py150
-rwxr-xr-xpython/test/Ice/slicing/exceptions/run.py36
-rw-r--r--python/test/Ice/slicing/objects/AllTests.py271
-rwxr-xr-xpython/test/Ice/slicing/objects/Client.py11
-rw-r--r--python/test/Ice/slicing/objects/Forward.ice27
-rwxr-xr-xpython/test/Ice/slicing/objects/Server.py37
-rwxr-xr-xpython/test/Ice/slicing/objects/ServerAMD.py190
-rw-r--r--python/test/Ice/slicing/objects/Test.ice12
-rw-r--r--python/test/Ice/slicing/objects/TestAMD.ice12
-rwxr-xr-xpython/test/Ice/slicing/objects/run.py36
-rw-r--r--python/test/Ice/timeout/AllTests.py97
-rwxr-xr-xpython/test/Ice/timeout/Client.py11
-rwxr-xr-xpython/test/Ice/timeout/Server.py15
-rwxr-xr-xpython/test/Ice/timeout/run.py23
-rw-r--r--python/test/Slice/escape/Clash.ice69
-rwxr-xr-xpython/test/Slice/escape/Client.py (renamed from python/test/Slice/keyword/Client.py)35
-rw-r--r--python/test/Slice/escape/Key.ice (renamed from python/test/Slice/keyword/Key.ice)17
-rw-r--r--python/test/Slice/import/.depend.mak0
-rwxr-xr-xpython/test/Slice/import/run.py59
-rw-r--r--python/test/Slice/import/test.py26
-rwxr-xr-xpython/test/Slice/keyword/run.py28
-rwxr-xr-xpython/test/Slice/macros/run.py28
-rwxr-xr-xpython/test/Slice/structure/Client.py11
-rwxr-xr-xpython/test/Slice/structure/run.py28
-rw-r--r--python/test/Slice/unicodePaths/run.py82
159 files changed, 4756 insertions, 3278 deletions
diff --git a/python/test/Ice/acm/AllTests.py b/python/test/Ice/acm/AllTests.py
index 5dcb67f9c32..365a0daa26f 100644
--- a/python/test/Ice/acm/AllTests.py
+++ b/python/test/Ice/acm/AllTests.py
@@ -20,48 +20,33 @@ class LoggerI(Ice.Logger):
self.m = threading.Lock()
def start(self):
- self.m.acquire()
- try:
+ with self.m:
self._started = True
self.dump()
- finally:
- self.m.release()
def _print(self, msg):
- self.m.acquire()
- try:
+ with self.m:
self._messages.append(msg)
if self._started:
self.dump()
- finally:
- self.m.release()
def trace(self, category, msg):
- self.m.acquire()
- try:
+ with self.m:
self._messages.append("[" + category + "] " + msg)
if self._started:
self.dump()
- finally:
- self.m.release()
def warning(self, msg):
- self.m.acquire()
- try:
+ with self.m:
self._messages.append("warning: " + msg)
if self._started:
self.dump()
- finally:
- self.m.release()
def error(self, msg):
- self.m.acquire()
- try:
+ with self.m:
self._messages.append("error: " + msg)
if self._started:
self.dump()
- finally:
- self.m.release()
def getPrefix(self):
return ""
@@ -74,7 +59,7 @@ class LoggerI(Ice.Logger):
print(p)
self._messages = []
-class TestCase(threading.Thread, Ice.ConnectionCallback):
+class TestCase(threading.Thread):
def __init__(self, name, com):
threading.Thread.__init__(self)
self._name = name
@@ -128,24 +113,20 @@ class TestCase(threading.Thread, Ice.ConnectionCallback):
proxy = Test.TestIntfPrx.uncheckedCast(self._communicator.stringToProxy(
self._adapter.getTestIntf().ice_toString()))
try:
- proxy.ice_getConnection().setCallback(self)
+ proxy.ice_getConnection().setCloseCallback(lambda conn: self.closed(conn))
+ proxy.ice_getConnection().setHeartbeatCallback(lambda conn: self.heartbeat(conn))
+
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:
+ with self.m:
self._heartbeat = self._heartbeat + 1
- finally:
- self.m.release()
def closed(self, con):
- self.m.acquire()
- try:
+ with self.m:
self._closed = True
- finally:
- self.m.release()
def runTestCase(self, adapter, proxy):
test(False)
@@ -173,11 +154,8 @@ def allTests(communicator):
def runTestCase(self, adapter, proxy):
proxy.sleep(2)
- self.m.acquire()
- try:
+ with self.m:
test(self._heartbeat >= 2)
- finally:
- self.m.release()
class InvocationHeartbeatOnHoldTest(TestCase):
def __init__(self, com):
@@ -195,11 +173,8 @@ def allTests(communicator):
adapter.activate()
proxy.interruptSleep()
- self.m.acquire()
- try:
+ with self.m:
test(self._closed)
- finally:
- self.m.release()
class InvocationNoHeartbeatTest(TestCase):
def __init__(self, com):
@@ -216,12 +191,9 @@ def allTests(communicator):
except Ice.ConnectionTimeoutException:
proxy.interruptSleep()
- self.m.acquire()
- try:
+ with self.m:
test(self._heartbeat == 0)
test(self._closed)
- finally:
- self.m.release()
class InvocationHeartbeatCloseOnIdleTest(TestCase):
def __init__(self, com):
@@ -233,12 +205,9 @@ def allTests(communicator):
# No close on invocation, the call should succeed this time.
proxy.sleep(2)
- self.m.acquire()
- try:
+ with self.m:
test(self._heartbeat == 0)
test(not self._closed)
- finally:
- self.m.release()
class CloseOnIdleTest(TestCase):
def __init__(self, com):
@@ -248,12 +217,9 @@ def allTests(communicator):
def runTestCase(self, adapter, proxy):
time.sleep(1.6) # Idle for 1.6 seconds
- self.m.acquire()
- try:
+ with self.m:
test(self._heartbeat == 0)
test(self._closed)
- finally:
- self.m.release()
class CloseOnInvocationTest(TestCase):
def __init__(self, com):
@@ -263,12 +229,9 @@ def allTests(communicator):
def runTestCase(self, adapter, proxy):
time.sleep(1.5) # Idle for 1.5 seconds
- self.m.acquire()
- try:
+ with self.m:
test(self._heartbeat == 0)
test(not self._closed)
- finally:
- self.m.release()
class CloseOnIdleAndInvocationTest(TestCase):
def __init__(self, com):
@@ -284,21 +247,15 @@ def allTests(communicator):
adapter.hold()
time.sleep(1.6) # Idle for 1.6 seconds
- self.m.acquire()
- try:
+ with self.m:
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:
+ with self.m:
test(self._closed) # Connection should be closed this time.
- finally:
- self.m.release()
class ForcefulCloseOnIdleAndInvocationTest(TestCase):
def __init__(self, com):
@@ -309,12 +266,9 @@ def allTests(communicator):
adapter.hold()
time.sleep(1.6) # Idle for 1.6 seconds
- self.m.acquire()
- try:
+ with self.m:
test(self._heartbeat == 0)
test(self._closed) # Connection closed forcefully by ACM.
- finally:
- self.m.release()
class HeartbeatOnIdleTest(TestCase):
def __init__(self, com):
@@ -324,11 +278,8 @@ def allTests(communicator):
def runTestCase(self, adapter, proxy):
time.sleep(2)
- self.m.acquire()
- try:
+ with self.m:
test(self._heartbeat >= 3)
- finally:
- self.m.release()
class HeartbeatAlwaysTest(TestCase):
def __init__(self, com):
@@ -340,11 +291,27 @@ def allTests(communicator):
proxy.ice_ping()
time.sleep(0.1)
- self.m.acquire()
- try:
+ with self.m:
test(self._heartbeat >= 3)
- finally:
- self.m.release()
+
+ class HeartbeatManualTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "manual heartbeats", com)
+ #
+ # Disable heartbeats.
+ #
+ self.setClientACM(10, -1, 0)
+ self.setServerACM(10, -1, 0)
+
+ def runTestCase(self, adapter, proxy):
+ proxy.startHeartbeatCount()
+ con = proxy.ice_getConnection()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ con.heartbeat()
+ proxy.waitForHeartbeatCount(5)
class SetACMTest(TestCase):
def __init__(self, com):
@@ -370,7 +337,8 @@ def allTests(communicator):
test(acm.close == Ice.ACMClose.CloseOnInvocationAndIdle)
test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways)
- proxy.waitForHeartbeat(2)
+ proxy.startHeartbeatCount()
+ proxy.waitForHeartbeatCount(2)
tests.append(InvocationHeartbeatTest(com))
tests.append(InvocationHeartbeatOnHoldTest(com))
@@ -384,6 +352,7 @@ def allTests(communicator):
tests.append(HeartbeatOnIdleTest(com))
tests.append(HeartbeatAlwaysTest(com))
+ tests.append(HeartbeatManualTest(com))
tests.append(SetACMTest(com))
for p in tests:
diff --git a/python/test/Ice/acm/Client.py b/python/test/Ice/acm/Client.py
index 0c81ffe7cc5..aa46258a512 100755
--- a/python/test/Ice/acm/Client.py
+++ b/python/test/Ice/acm/Client.py
@@ -32,17 +32,10 @@ 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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 5a9b3b82667..d00888764cb 100755
--- a/python/test/Ice/acm/Server.py
+++ b/python/test/Ice/acm/Server.py
@@ -22,7 +22,7 @@ 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")
+ id = Ice.stringToIdentity("communicator")
adapter.add(TestI.RemoteCommunicatorI(), id)
adapter.activate()
@@ -37,17 +37,10 @@ try:
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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index cd9867f820e..7018c9df821 100644
--- a/python/test/Ice/acm/Test.ice
+++ b/python/test/Ice/acm/Test.ice
@@ -17,7 +17,8 @@ interface TestIntf
void sleep(int seconds);
void sleepAndHold(int seconds);
void interruptSleep();
- void waitForHeartbeat(int count);
+ void startHeartbeatCount();
+ void waitForHeartbeatCount(int count);
};
interface RemoteObjectAdapter
diff --git a/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py
index 21ab6444384..53158e42a28 100644
--- a/python/test/Ice/acm/TestI.py
+++ b/python/test/Ice/acm/TestI.py
@@ -9,7 +9,22 @@
import Ice, Test, threading
-class RemoteCommunicatorI(Test.RemoteCommunicator):
+class ConnectionCallbackI():
+ def __init__(self):
+ self.m = threading.Condition()
+ self.count = 0
+
+ def heartbeat(self, con):
+ with self.m:
+ self.count += 1
+ self.m.notifyAll()
+
+ def waitForCount(self, count):
+ with self.m:
+ while self.count < count:
+ self.m.wait()
+
+class RemoteCommunicatorI(Test._RemoteCommunicatorDisp):
def createObjectAdapter(self, timeout, close, heartbeat, current=None):
com = current.adapter.getCommunicator()
properties = com.getProperties()
@@ -29,11 +44,11 @@ class RemoteCommunicatorI(Test.RemoteCommunicator):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
-class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
+class RemoteObjectAdapterI(Test._RemoteObjectAdapterDisp):
def __init__(self, adapter):
self._adapter = adapter
self._testIntf = Test.TestIntfPrx.uncheckedCast(adapter.add(TestIntfI(),
- adapter.getCommunicator().stringToIdentity("test")))
+ Ice.stringToIdentity("test")))
adapter.activate()
def getTestIntf(self, current=None):
@@ -51,61 +66,26 @@ class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
except Ice.ObjectAdapterDeactivatedException:
pass
-class TestIntfI(Test.TestIntf):
+class TestIntfI(Test._TestIntfDisp):
def __init__(self):
self.m = threading.Condition()
def sleep(self, delay, current=None):
- self.m.acquire()
- try:
+ with self.m:
self.m.wait(delay)
- finally:
- self.m.release()
def sleepAndHold(self, delay, current=None):
- self.m.acquire()
- try:
+ with self.m:
current.adapter.hold()
self.m.wait(delay)
- finally:
- self.m.release()
def interruptSleep(self, delay, current=None):
- self.m.acquire()
- try:
+ with self.m:
self.m.notifyAll()
- finally:
- self.m.release()
-
- def waitForHeartbeat(self, count, current=None):
-
- class ConnectionCallbackI(Ice.ConnectionCallback):
-
- def __init__(self):
- self.m = threading.Condition()
- self.count = 0
-
- def heartbeat(self, con):
- self.m.acquire()
- try:
- self.count -= 1
- self.m.notifyAll()
- finally:
- self.m.release()
-
- def closed(self, con):
- pass
-
- def waitForCount(self, count):
- self.m.acquire()
- self.count = count
- try:
- while self.count > 0:
- self.m.wait()
- finally:
- self.m.release()
- callback = ConnectionCallbackI()
- current.con.setCallback(callback)
- callback.waitForCount(2)
+ def startHeartbeatCount(self, current=None):
+ self.callback = ConnectionCallbackI()
+ current.con.setHeartbeatCallback(lambda con: self.callback.heartbeat(con))
+ def waitForHeartbeatCount(self, count, current=None):
+ self.callback.waitForCount(2)
diff --git a/python/test/Ice/acm/run.py b/python/test/Ice/acm/run.py
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/acm/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index e690c8ff5a3..3adb8987a4b 100644
--- a/python/test/Ice/adapterDeactivation/AllTests.py
+++ b/python/test/Ice/adapterDeactivation/AllTests.py
@@ -57,14 +57,14 @@ def allTests(communicator):
initData = Ice.InitializationData();
initData.properties = communicator.getProperties().clone();
comm = Ice.initialize(initData);
- comm.stringToProxy("test:default -p 12010").begin_ice_ping();
+ comm.stringToProxy("test:default -p 12010").ice_pingAsync();
comm.destroy();
print("ok");
sys.stdout.write("testing whether server is gone... ")
sys.stdout.flush()
try:
- obj.ice_ping()
+ obj.ice_timeout(100).ice_ping() # Use timeout to speed up testing on Windows
test(False)
except Ice.LocalException:
print("ok")
diff --git a/python/test/Ice/adapterDeactivation/TestI.py b/python/test/Ice/adapterDeactivation/TestI.py
index 03e44ce4911..aeb4f60e98b 100644
--- a/python/test/Ice/adapterDeactivation/TestI.py
+++ b/python/test/Ice/adapterDeactivation/TestI.py
@@ -14,7 +14,7 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class TestI(Test.TestIntf):
+class TestI(Test._TestIntfDisp):
def transient(self, current=None):
communicator = current.adapter.getCommunicator()
adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9999")
diff --git a/python/test/Ice/adapterDeactivation/run.py b/python/test/Ice/adapterDeactivation/run.py
deleted file mode 100755
index e3c2c280892..00000000000
--- a/python/test/Ice/adapterDeactivation/run.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index b42e293f8c6..749dd1bc7eb 100644
--- a/python/test/Ice/admin/AllTests.py
+++ b/python/test/Ice/admin/AllTests.py
@@ -116,7 +116,7 @@ def allTests(communicator):
init.properties.setProperty("Ice.Admin.Enabled", "1")
com = Ice.initialize(init)
test(com.getAdmin() == None)
- identity = com.stringToIdentity("test-admin")
+ identity = Ice.stringToIdentity("test-admin")
try:
com.createAdmin(None, identity)
test(False)
diff --git a/python/test/Ice/admin/Client.py b/python/test/Ice/admin/Client.py
index 54186aa5583..65174adc68a 100644
--- a/python/test/Ice/admin/Client.py
+++ b/python/test/Ice/admin/Client.py
@@ -28,17 +28,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 81ea14d8029..adc448c6396 100644
--- a/python/test/Ice/admin/Server.py
+++ b/python/test/Ice/admin/Server.py
@@ -22,7 +22,7 @@ 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");
+ ident = Ice.stringToIdentity("factory");
adapter.add(TestI.RemoteCommunicatorFactoryI(), ident);
adapter.activate();
@@ -30,17 +30,10 @@ def run(args, communicator):
return True;
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/TestI.py b/python/test/Ice/admin/TestI.py
index 89fcb9360d1..9172a2da65d 100644
--- a/python/test/Ice/admin/TestI.py
+++ b/python/test/Ice/admin/TestI.py
@@ -13,11 +13,11 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class TestFacetI(Test.TestFacet):
+class TestFacetI(Test._TestFacetDisp):
def op(self, current = None):
return
-class RemoteCommunicatorI(Test.RemoteCommunicator, Ice.PropertiesAdminUpdateCallback):
+class RemoteCommunicatorI(Test._RemoteCommunicatorDisp, Ice.PropertiesAdminUpdateCallback):
def __init__(self, communicator):
self.communicator = communicator
self.called = False
@@ -27,8 +27,7 @@ class RemoteCommunicatorI(Test.RemoteCommunicator, Ice.PropertiesAdminUpdateCall
return self.communicator.getAdmin()
def getChanges(self, current = None):
- self.m.acquire()
- try:
+ with self.m:
#
# The client calls PropertiesAdmin::setProperties() and then invokes
# this operation. Since setProperties() is implemented using AMD, the
@@ -42,8 +41,6 @@ class RemoteCommunicatorI(Test.RemoteCommunicator, Ice.PropertiesAdminUpdateCall
self.called = False
return self.changes
- finally:
- self.m.release()
def shutdown(self, current = None):
self.communicator.shutdown()
@@ -59,15 +56,12 @@ class RemoteCommunicatorI(Test.RemoteCommunicator, Ice.PropertiesAdminUpdateCall
self.communicator.destroy()
def updated(self, changes):
- self.m.acquire()
- try:
+ with self.m:
self.changes = changes
self.called = True
self.m.notify()
- finally:
- self.m.release()
-class RemoteCommunicatorFactoryI(Test.RemoteCommunicatorFactory):
+class RemoteCommunicatorFactoryI(Test._RemoteCommunicatorFactoryDisp):
def createCommunicator(self, props, current = None):
#
diff --git a/python/test/Ice/admin/run.py b/python/test/Ice/admin/run.py
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/admin/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 1b49e269a30..b7dd106aadb 100644
--- a/python/test/Ice/ami/AllTests.py
+++ b/python/test/Ice/ami/AllTests.py
@@ -19,19 +19,15 @@ class CallbackBase:
self._cond = threading.Condition()
def check(self):
- self._cond.acquire()
- try:
+ with self._cond:
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()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
def exception(self, ex):
test(False)
@@ -241,6 +237,86 @@ class FlushExCallback(CallbackBase):
def sentWC(self, sentSynchronously, cookie):
test(False)
+class FutureDoneCallback(CallbackBase):
+ def isA(self, f):
+ test(f.result())
+ self.called()
+
+ def ping(self, f):
+ self.called()
+
+ def id(self, f):
+ test(f.result() == "::Test::TestIntf")
+ self.called()
+
+ def ids(self, f):
+ test(len(f.result()) == 2)
+ self.called()
+
+ def connection(self, f):
+ test(f.result() != None)
+ self.called()
+
+ def op(self, f):
+ self.called()
+
+ def opWithResult(self, f):
+ test(f.result() == 15)
+ self.called()
+
+ def opWithUE(self, f):
+ try:
+ f.result()
+ test(False)
+ except Test.TestIntfException:
+ self.called()
+ except:
+ test(False)
+
+class FutureExceptionCallback(CallbackBase):
+ def opWithUE(self, f):
+ test(isinstance(f.exception(), Test.TestIntfException))
+ self.called()
+
+ def ex(self, f):
+ test(isinstance(f.exception(), Ice.NoEndpointException))
+ self.called()
+
+ def noEx(self, f):
+ test(f.exception() is None)
+
+class FutureSentCallback(CallbackBase):
+ def __init__(self):
+ CallbackBase.__init__(self)
+ self._thread = threading.currentThread()
+
+ def sent(self, f, sentSynchronously):
+ test((sentSynchronously and self._thread == threading.currentThread()) or \
+ (not sentSynchronously and self._thread != threading.currentThread()))
+ self.called()
+
+class FutureFlushCallback(CallbackBase):
+ def __init__(self, cookie=None):
+ CallbackBase.__init__(self)
+ self._thread = threading.currentThread()
+ self._cookie = cookie
+
+ def sent(self, f, sentSynchronously):
+ test((sentSynchronously and self._thread == threading.currentThread()) or \
+ (not sentSynchronously and self._thread != threading.currentThread()))
+ self.called()
+
+class FutureFlushExCallback(CallbackBase):
+ def __init__(self, cookie=None):
+ CallbackBase.__init__(self)
+ self._cookie = cookie
+
+ def exception(self, f):
+ self.called()
+
+ def sent(self, f, sentSynchronously):
+ test(False)
+
LocalException = 0
UserException = 1
OtherException = 2
@@ -315,22 +391,22 @@ def allTests(communicator, collocated):
result = p.begin_ice_isA("::Test::TestIntf")
test(p.end_ice_isA(result))
- result = p.begin_ice_isA("::Test::TestIntf", _ctx=ctx)
+ result = p.begin_ice_isA("::Test::TestIntf", context=ctx)
test(p.end_ice_isA(result))
result = p.begin_ice_ping()
p.end_ice_ping(result)
- result = p.begin_ice_ping(_ctx=ctx)
+ result = p.begin_ice_ping(context=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)
+ result = p.begin_ice_id(context=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)
+ result = p.begin_ice_ids(context=ctx)
test(len(p.end_ice_ids(result)) == 2)
if not collocated:
@@ -339,12 +415,12 @@ def allTests(communicator, collocated):
result = p.begin_op()
p.end_op(result)
- result = p.begin_op(_ctx=ctx)
+ result = p.begin_op(context=ctx)
p.end_op(result)
result = p.begin_opWithResult()
test(p.end_opWithResult(result) == 15)
- result = p.begin_opWithResult(_ctx=ctx)
+ result = p.begin_opWithResult(context=ctx)
test(p.end_opWithResult(result) == 15)
result = p.begin_opWithUE()
@@ -353,7 +429,7 @@ def allTests(communicator, collocated):
test(False)
except Test.TestIntfException:
pass
- result = p.begin_opWithUE(_ctx=ctx)
+ result = p.begin_opWithUE(context=ctx)
try:
p.end_opWithUE(result)
test(False)
@@ -370,41 +446,41 @@ def allTests(communicator, collocated):
cookie = 5
cbWC = ResponseCallbackWC(cookie)
- p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.isA, cb.ex)
+ p.begin_ice_isA(Test._TestIntfDisp.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))
+ p.begin_ice_isA(Test._TestIntfDisp.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)
+ p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), cb.isA, cb.ex, context=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)
+ p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie),
+ context=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)
+ p.begin_ice_ping(cb.ping, cb.ex, context=ctx)
cb.check()
- p.begin_ice_ping(lambda: cbWC.ping(cookie), lambda: cbWC.ex(ex, cookie), _ctx=ctx)
+ p.begin_ice_ping(lambda: cbWC.ping(cookie), lambda: cbWC.ex(ex, cookie), context=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)
+ p.begin_ice_id(cb.id, cb.ex, context=ctx)
cb.check()
- p.begin_ice_id(lambda id: cbWC.id(id, cookie), lambda ex: cbWC.ex(ex, cookie), _ctx=ctx)
+ p.begin_ice_id(lambda id: cbWC.id(id, cookie), lambda ex: cbWC.ex(ex, cookie), context=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)
+ p.begin_ice_ids(cb.ids, cb.ex, context=ctx)
cb.check()
- p.begin_ice_ids(lambda ids: cbWC.ids(ids, cookie), lambda ex: cbWC.ex(ex, cookie), _ctx=ctx)
+ p.begin_ice_ids(lambda ids: cbWC.ids(ids, cookie), lambda ex: cbWC.ex(ex, cookie), context=ctx)
cbWC.check()
if not collocated:
@@ -417,27 +493,27 @@ def allTests(communicator, collocated):
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)
+ p.begin_op(cb.op, cb.ex, context=ctx)
cb.check()
- p.begin_op(lambda: cbWC.op(cookie), lambda ex: cbWC.ex(ex, cookie), _ctx=ctx)
+ p.begin_op(lambda: cbWC.op(cookie), lambda ex: cbWC.ex(ex, cookie), context=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)
+ p.begin_opWithResult(cb.opWithResult, cb.ex, context=ctx)
cb.check()
- p.begin_opWithResult(lambda r: cbWC.opWithResult(r, cookie), lambda ex: cbWC.ex(ex, cookie), _ctx=ctx)
+ p.begin_opWithResult(lambda r: cbWC.opWithResult(r, cookie), lambda ex: cbWC.ex(ex, cookie), context=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)
+ p.begin_opWithUE(cb.op, cb.opWithUE, context=ctx)
cb.check()
- p.begin_opWithUE(lambda: cbWC.op(cookie), lambda ex: cbWC.opWithUE(ex, cookie), _ctx=ctx)
+ p.begin_opWithUE(lambda: cbWC.op(cookie), lambda ex: cbWC.opWithUE(ex, cookie), context=ctx)
cbWC.check()
print("ok")
@@ -487,9 +563,9 @@ def allTests(communicator, collocated):
cookie = 5
cbWC = ExceptionCallbackWC(cookie)
- i.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.response, cb.ex)
+ i.begin_ice_isA(Test._TestIntfDisp.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))
+ i.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), lambda b: cbWC.response(b, cookie), lambda ex: cbWC.ex(ex, cookie))
cbWC.check()
i.begin_ice_ping(cb.response, cb.ex)
@@ -528,8 +604,8 @@ def allTests(communicator, collocated):
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),
+ p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), cb.nullResponse, cb.noEx)
+ p.begin_ice_isA(Test._TestIntfDisp.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))
@@ -693,7 +769,7 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = p.ice_batchOneway()
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
cb = FlushCallback()
r = b1.begin_ice_flushBatchRequests(cb.exception, cb.sent)
cb.check()
@@ -707,7 +783,7 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = p.ice_batchOneway()
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
cb = FlushCallback(cookie)
r = b1.begin_ice_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie), lambda ss: cb.sentWC(ss, cookie))
cb.check()
@@ -729,7 +805,7 @@ def allTests(communicator, collocated):
b1.opBatch()
b1.opBatch()
cb = FlushCallback()
- r = b1.ice_getConnection().begin_flushBatchRequests(cb.exception, cb.sent)
+ r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent)
cb.check()
test(r.isSent())
test(r.isCompleted())
@@ -743,7 +819,8 @@ def allTests(communicator, collocated):
b1.opBatch()
b1.opBatch()
cb = FlushCallback(cookie)
- r = b1.ice_getConnection().begin_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie),
+ r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy,
+ lambda ex: cb.exceptionWC(ex, cookie),
lambda ss: cb.sentWC(ss, cookie))
cb.check()
test(p.waitForBatch(2))
@@ -754,9 +831,9 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
cb = FlushExCallback()
- r = b1.ice_getConnection().begin_flushBatchRequests(cb.exception, cb.sent)
+ r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent)
cb.check()
test(not r.isSent())
test(r.isCompleted())
@@ -768,9 +845,10 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
cb = FlushExCallback(cookie)
- r = b1.ice_getConnection().begin_flushBatchRequests(lambda ex: cb.exceptionWC(ex, cookie),
+ r = b1.ice_getConnection().begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy,
+ lambda ex: cb.exceptionWC(ex, cookie),
lambda ss: cb.sentWC(ss, cookie))
cb.check()
test(p.opBatchCount() == 0)
@@ -788,7 +866,7 @@ def allTests(communicator, collocated):
b1.opBatch()
b1.opBatch()
cb = FlushCallback()
- r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent)
cb.check()
test(r.isSent())
test(r.isCompleted())
@@ -800,9 +878,9 @@ def allTests(communicator, collocated):
test(p.opBatchCount() == 0)
b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
b1.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
cb = FlushCallback()
- r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent)
cb.check()
test(r.isSent()) # Exceptions are ignored!
test(r.isCompleted())
@@ -821,7 +899,7 @@ def allTests(communicator, collocated):
b2.opBatch()
b2.opBatch()
cb = FlushCallback()
- r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent)
cb.check()
test(r.isSent())
test(r.isCompleted())
@@ -840,9 +918,9 @@ def allTests(communicator, collocated):
b2.ice_getConnection() # Ensure connection is established.
b1.opBatch()
b2.opBatch()
- b1.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
cb = FlushCallback()
- r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent)
cb.check()
test(r.isSent()) # Exceptions are ignored!
test(r.isCompleted())
@@ -860,10 +938,10 @@ def allTests(communicator, collocated):
b2.ice_getConnection() # Ensure connection is established.
b1.opBatch()
b2.opBatch()
- b1.ice_getConnection().close(False)
- b2.ice_getConnection().close(False)
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
+ b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
cb = FlushCallback()
- r = communicator.begin_flushBatchRequests(cb.exception, cb.sent)
+ r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy, cb.exception, cb.sent)
cb.check()
test(r.isSent()) # Exceptions are ignored!
test(r.isCompleted())
@@ -965,7 +1043,7 @@ def allTests(communicator, collocated):
con = p.ice_getConnection()
p2 = p.ice_batchOneway()
p2.ice_ping()
- r = con.begin_flushBatchRequests()
+ r = con.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy)
test(r.getConnection() == con)
test(r.getCommunicator() == communicator)
test(r.getProxy() == None) # Expected
@@ -976,7 +1054,7 @@ def allTests(communicator, collocated):
#
p2 = p.ice_batchOneway()
p2.ice_ping()
- r = communicator.begin_flushBatchRequests()
+ r = communicator.begin_flushBatchRequests(Ice.CompressBatch.BasedOnProxy)
test(r.getConnection() == None) # Expected
test(r.getCommunicator() == communicator)
test(r.getProxy() == None) # Expected
@@ -1043,10 +1121,26 @@ def allTests(communicator, collocated):
print("ok")
- if p.ice_getConnection():
- sys.stdout.write("testing close connection with sending queue... ")
+ if p.ice_getConnection() and p.supportsAMD():
+
+ sys.stdout.write("testing graceful close connection with wait... ")
sys.stdout.flush()
+ #
+ # Local case: begin a request, close the connection gracefully, and make sure it waits
+ # for the request to complete.
+ #
+ cb = CallbackBase()
+ con = p.ice_getConnection()
+ con.setCloseCallback(lambda con: cb.called())
+ f = p.sleepAsync(100)
+ con.close(Ice.ConnectionClose.GracefullyWithWait) # Blocks until the request completes.
+ f.result() # Should complete successfully.
+ cb.check()
+
+ #
+ # Remote case.
+ #
if sys.version_info[0] == 2:
b = [chr(random.randint(0, 255)) for x in range(0, 10*1024)]
seq = ''.join(b)
@@ -1067,7 +1161,7 @@ def allTests(communicator, collocated):
results = []
for i in range(0, maxQueue):
results.append(p.begin_opWithPayload(seq))
- if not p.begin_close(False).isSent():
+ if not p.begin_close(Test.CloseMode.GracefullyWithWait).isSent():
for i in range(0, maxQueue):
r = p.begin_opWithPayload(seq)
results.append(r)
@@ -1087,4 +1181,634 @@ def allTests(communicator, collocated):
print("ok")
+ sys.stdout.write("testing graceful close connection without wait... ")
+ sys.stdout.flush()
+
+ #
+ # Local case: start an operation and then close the connection gracefully on the client side
+ # without waiting for the pending invocation to complete. There will be no retry and we expect the
+ # invocation to fail with ConnectionManuallyClosedException.
+ #
+ p = p.ice_connectionId("CloseGracefully") # Start with a new connection.
+ con = p.ice_getConnection()
+ f = p.startDispatchAsync()
+ f.sent() # Ensure the request was sent before we close the connection.
+ con.close(Ice.ConnectionClose.Gracefully)
+ try:
+ f.result()
+ test(False)
+ except Ice.ConnectionManuallyClosedException as ex:
+ test(ex.graceful)
+ p.finishDispatch()
+
+ #
+ # Remote case: the server closes the connection gracefully, which means the connection
+ # will not be closed until all pending dispatched requests have completed.
+ #
+ con = p.ice_getConnection()
+ cb = CallbackBase()
+ con.setCloseCallback(lambda c: cb.called())
+ f = p.sleepAsync(100)
+ p.close(Test.CloseMode.Gracefully) # Close is delayed until sleep completes.
+ cb.check() # Ensure connection was closed.
+ try:
+ f.result()
+ except:
+ test(false)
+
+ print("ok")
+
+ sys.stdout.write("testing forceful close connection... ")
+ sys.stdout.flush()
+
+ #
+ # Local case: start an operation and then close the connection forcefully on the client side.
+ # There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException.
+ #
+ p.ice_ping()
+ con = p.ice_getConnection()
+ f = p.startDispatchAsync()
+ f.sent() # Ensure the request was sent before we close the connection.
+ con.close(Ice.ConnectionClose.Forcefully)
+ try:
+ f.result()
+ test(False)
+ except Ice.ConnectionManuallyClosedException as ex:
+ test(not ex.graceful)
+ p.finishDispatch()
+
+ #
+ # Remote case: the server closes the connection forcefully. This causes the request to fail
+ # with a ConnectionLostException. Since the close() operation is not idempotent, the client
+ # will not retry.
+ #
+ try:
+ p.close(Test.CloseMode.Forcefully)
+ test(False)
+ except Ice.ConnectionLostException:
+ # Expected.
+ pass
+
+ print("ok")
+
+def allTestsFuture(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 future invocations... ")
+ sys.stdout.flush()
+ ctx = {}
+
+ test(p.ice_isAAsync("::Test::TestIntf").result())
+ test(p.ice_isAAsync("::Test::TestIntf", ctx).result())
+
+ p.ice_pingAsync().result()
+ p.ice_pingAsync(ctx).result()
+
+ test(p.ice_idAsync().result() == "::Test::TestIntf")
+ test(p.ice_idAsync(ctx).result() == "::Test::TestIntf")
+
+ test(len(p.ice_idsAsync().result()) == 2)
+ test(len(p.ice_idsAsync(ctx).result()) == 2)
+
+ if not collocated:
+ test(p.ice_getConnectionAsync().result() != None)
+
+ p.opAsync().result()
+ p.opAsync(ctx).result()
+
+ test(p.opWithResultAsync().result() == 15)
+ test(p.opWithResultAsync(ctx).result() == 15)
+
+ try:
+ p.opWithUEAsync().result()
+ test(False)
+ except Test.TestIntfException:
+ pass
+ try:
+ p.opWithUEAsync(ctx).result()
+ test(False)
+ except Test.TestIntfException:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing done callback... ")
+ sys.stdout.flush()
+
+ ctx = {}
+ cb = FutureDoneCallback()
+
+ p.ice_isAAsync(Test._TestIntfDisp.ice_staticId()).add_done_callback(cb.isA)
+ cb.check()
+ p.ice_isAAsync(Test._TestIntfDisp.ice_staticId(), ctx).add_done_callback(cb.isA)
+ cb.check()
+
+ p.ice_pingAsync().add_done_callback(cb.ping)
+ cb.check()
+ p.ice_pingAsync(ctx).add_done_callback(cb.ping)
+ cb.check()
+
+ p.ice_idAsync().add_done_callback(cb.id)
+ cb.check()
+ p.ice_idAsync(ctx).add_done_callback(cb.id)
+ cb.check()
+
+ p.ice_idsAsync().add_done_callback(cb.ids)
+ cb.check()
+ p.ice_idsAsync(ctx).add_done_callback(cb.ids)
+ cb.check()
+
+ if not collocated:
+ p.ice_getConnectionAsync().add_done_callback(cb.connection)
+ cb.check()
+
+ p.opAsync().add_done_callback(cb.op)
+ cb.check()
+ p.opAsync(ctx).add_done_callback(cb.op)
+ cb.check()
+
+ p.opWithResultAsync().add_done_callback(cb.opWithResult)
+ cb.check()
+ p.opWithResultAsync(ctx).add_done_callback(cb.opWithResult)
+ cb.check()
+
+ p.opWithUEAsync().add_done_callback(cb.opWithUE)
+ cb.check()
+ p.opWithUEAsync(ctx).add_done_callback(cb.opWithUE)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("testing local exceptions... ")
+ sys.stdout.flush()
+
+ indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy"))
+
+ try:
+ indirect.opAsync().result()
+ test(False)
+ except Ice.NoEndpointException:
+ pass
+
+ try:
+ p.ice_oneway().opWithResultAsync().result()
+ 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.opAsync()
+ test(False)
+ except Ice.CommunicatorDestroyedException:
+ pass
+
+ print("ok")
+
+ sys.stdout.write("testing local exceptions with done callback... ")
+ sys.stdout.flush()
+
+ i = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy"))
+ cb = FutureExceptionCallback()
+
+ i.ice_isAAsync(Test._TestIntfDisp.ice_staticId()).add_done_callback(cb.ex)
+ cb.check()
+
+ i.ice_pingAsync().add_done_callback(cb.ex)
+ cb.check()
+
+ i.ice_idAsync().add_done_callback(cb.ex)
+ cb.check()
+
+ i.ice_idsAsync().add_done_callback(cb.ex)
+ cb.check()
+
+ if not collocated:
+ i.ice_getConnectionAsync().add_done_callback(cb.ex)
+ cb.check()
+
+ i.opAsync().add_done_callback(cb.ex)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("testing exceptions with done callback... ")
+ sys.stdout.flush()
+
+ cb = FutureExceptionCallback()
+
+ # Ensures no exception is set when response is received.
+ p.ice_isAAsync(Test._TestIntfDisp.ice_staticId()).add_done_callback(cb.noEx)
+ p.opAsync().add_done_callback(cb.noEx)
+
+ # If response is a user exception, it should be received.
+ p.opWithUEAsync().add_done_callback(cb.opWithUE)
+ cb.check()
+
+ print("ok")
+
+ sys.stdout.write("testing sent callback... ")
+ sys.stdout.flush()
+
+ cb = FutureSentCallback()
+
+ p.ice_isAAsync("").add_sent_callback(cb.sent)
+ cb.check()
+
+ p.ice_pingAsync().add_sent_callback(cb.sent)
+ cb.check()
+
+ p.ice_idAsync().add_sent_callback(cb.sent)
+ cb.check()
+
+ p.ice_idsAsync().add_sent_callback(cb.sent)
+ cb.check()
+
+ p.opAsync().add_sent_callback(cb.sent)
+ cb.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 = FutureSentCallback()
+ while True:
+ f = p.opWithPayloadAsync(seq)
+ f.add_sent_callback(cb.sent)
+ cbs.append(cb)
+ if not f.is_sent_synchronously():
+ break
+ cb = FutureSentCallback()
+ except Exception as ex:
+ testController.resumeAdapter()
+ raise ex
+ testController.resumeAdapter()
+ for r in cbs:
+ r.check()
+
+ print("ok")
+
+ sys.stdout.write("testing batch requests with proxy... ")
+ sys.stdout.flush()
+
+ test(p.opBatchCount() == 0)
+ b1 = p.ice_batchOneway()
+ b1.opBatch()
+ b1.opBatch()
+ cb = FutureFlushCallback()
+ f = b1.ice_flushBatchRequestsAsync()
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ test(f.is_sent())
+ test(f.done())
+ test(p.waitForBatch(2))
+
+ if p.ice_getConnection(): # No collocation optimization
+ test(p.opBatchCount() == 0)
+ b1 = p.ice_batchOneway()
+ b1.opBatch()
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
+ cb = FutureFlushCallback()
+ f = b1.ice_flushBatchRequestsAsync()
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ f.result() # Wait until finished.
+ test(f.is_sent())
+ test(f.done())
+ test(p.waitForBatch(1))
+
+ print("ok")
+
+ if p.ice_getConnection(): # No collocation optimization
+ sys.stdout.write("testing batch requests with connection... ")
+ sys.stdout.flush()
+
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b1.opBatch()
+ b1.opBatch()
+ cb = FutureFlushCallback()
+ f = b1.ice_getConnection().flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ f.result() # Wait until finished.
+ test(f.is_sent())
+ test(f.done())
+ test(p.waitForBatch(2))
+
+ test(p.opBatchCount() == 0)
+ b1 = Test.TestIntfPrx.uncheckedCast(p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway())
+ b1.opBatch()
+ b1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
+ cb = FutureFlushExCallback()
+ f = b1.ice_getConnection().flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ f.add_done_callback(cb.exception)
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ test(not f.is_sent())
+ test(f.done())
+ 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 = FutureFlushCallback()
+ f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ f.result() # Wait until finished.
+ test(f.is_sent())
+ test(f.done())
+ 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(Ice.ConnectionClose.GracefullyWithWait)
+ cb = FutureFlushCallback()
+ f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ f.result() # Wait until finished.
+ test(f.is_sent()) # Exceptions are ignored!
+ test(f.done())
+ 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 = FutureFlushCallback()
+ f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ f.result() # Wait until finished.
+ test(f.is_sent())
+ test(f.done())
+ 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(Ice.ConnectionClose.GracefullyWithWait)
+ cb = FutureFlushCallback()
+ f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ f.result() # Wait until finished.
+ test(f.is_sent()) # Exceptions are ignored!
+ test(f.done())
+ 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(Ice.ConnectionClose.GracefullyWithWait)
+ b2.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
+ cb = FutureFlushCallback()
+ f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ f.add_sent_callback(cb.sent)
+ cb.check()
+ f.result() # Wait until finished.
+ test(f.is_sent()) # Exceptions are ignored!
+ test(f.done())
+ test(p.opBatchCount() == 0)
+
+ print("ok")
+
+ sys.stdout.write("testing future operations... ")
+ sys.stdout.flush()
+
+ indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy"))
+ f = indirect.opAsync()
+ try:
+ f.result()
+ test(False)
+ except Ice.NoEndpointException:
+ pass
+
+ testController.holdAdapter()
+ f1 = None
+ f2 = None
+ try:
+ f1 = p.opAsync()
+ 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):
+ f2 = p.opWithPayloadAsync(seq)
+ if not f2.is_sent_synchronously():
+ break
+
+ test(f1 == f1)
+ test(f1 != f2)
+
+ if p.ice_getConnection():
+ test((f1.is_sent_synchronously() and f1.is_sent() and not f1.done()) or
+ (not f1.is_sent_synchronously() and not f1.done()))
+
+ test(not f2.is_sent_synchronously() and not f2.done())
+ except Exception as ex:
+ testController.resumeAdapter()
+ raise ex
+ testController.resumeAdapter()
+
+ f1.sent()
+ test(f1.is_sent())
+
+ f2.sent()
+ test(f2.is_sent())
+
+ f1.result()
+ test(f1.done())
+
+ f2.result()
+ test(f2.done())
+
+ test(f1.operation() == "op")
+ test(f2.operation() == "opWithPayload")
+
+ #
+ # Twoway
+ #
+ f = p.ice_pingAsync()
+ test(f.operation() == "ice_ping")
+ test(f.connection() == None) # Expected
+ test(f.communicator() == communicator)
+ test(f.proxy() == p)
+ f.result()
+
+ #
+ # Oneway
+ #
+ p2 = p.ice_oneway()
+ f = p2.ice_pingAsync()
+ test(f.operation() == "ice_ping")
+ test(f.connection() == None) # Expected
+ test(f.communicator() == communicator)
+ test(f.proxy() == p2)
+
+ #
+ # Batch request via proxy
+ #
+ p2 = p.ice_batchOneway()
+ p2.ice_ping()
+ f = p2.ice_flushBatchRequestsAsync()
+ test(f.connection() == None) # Expected
+ test(f.communicator() == communicator)
+ test(f.proxy() == p2)
+ f.result()
+
+ if p.ice_getConnection():
+ #
+ # Batch request via connection
+ #
+ con = p.ice_getConnection()
+ p2 = p.ice_batchOneway()
+ p2.ice_ping()
+ f = con.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ test(f.connection() == con)
+ test(f.communicator() == communicator)
+ test(f.proxy() == None) # Expected
+ f.result()
+
+ #
+ # Batch request via communicator
+ #
+ p2 = p.ice_batchOneway()
+ p2.ice_ping()
+ f = communicator.flushBatchRequestsAsync(Ice.CompressBatch.BasedOnProxy)
+ test(f.connection() == None) # Expected
+ test(f.communicator() == communicator)
+ test(f.proxy() == None) # Expected
+ f.result()
+
+ if(p.ice_getConnection()):
+ f1 = None
+ f2 = 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
+ f = p.opWithPayloadAsync(seq)
+
+ test(not f.is_sent())
+
+ f1 = p.ice_pingAsync()
+ f2 = p.ice_idAsync()
+ f1.cancel()
+ f2.cancel()
+ try:
+ f1.result()
+ test(false)
+ except(Ice.InvocationCanceledException):
+ pass
+
+ try:
+ f2.result()
+ test(false)
+ except(Ice.InvocationCanceledException):
+ pass
+
+ testController.resumeAdapter()
+ p.ice_ping()
+ test(not f1.is_sent() and f1.done())
+ test(not f2.is_sent() and f2.done())
+
+ testController.holdAdapter()
+
+ f1 = p.opAsync()
+ f2 = p.ice_idAsync()
+ f1.sent()
+ f2.sent()
+ f1.cancel()
+ f2.cancel()
+ try:
+ f1.result()
+ test(false)
+ except:
+ pass
+ try:
+ f2.result()
+ test(false)
+ except:
+ pass
+ testController.resumeAdapter()
+
+ print("ok")
+
p.shutdown()
diff --git a/python/test/Ice/ami/Client.py b/python/test/Ice/ami/Client.py
index 70efcce696f..ecd21b9bb85 100755
--- a/python/test/Ice/ami/Client.py
+++ b/python/test/Ice/ami/Client.py
@@ -26,12 +26,14 @@ def test(b):
def run(args, communicator):
AllTests.allTests(communicator, False)
+ AllTests.allTestsFuture(communicator, False)
return True
try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
initData.properties.setProperty('Ice.Warn.AMICallback', '0')
+ initData.properties.setProperty('Ice.Warn.Connections', '0')
#
# Limit the send buffer size, this test relies on the socket
@@ -39,17 +41,10 @@ try:
#
initData.properties.setProperty("Ice.TCP.SndSize", "50000");
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 767ebee3d5c..d349e62c1d5 100755
--- a/python/test/Ice/ami/Collocated.py
+++ b/python/test/Ice/ami/Collocated.py
@@ -29,10 +29,10 @@ def run(args, communicator):
testController = TestI.TestIntfControllerI(adapter)
- adapter.add(TestI.TestIntfI(), communicator.stringToIdentity("test"))
+ adapter.add(TestI.TestIntfI(), Ice.stringToIdentity("test"))
#adapter.activate() # Collocated test doesn't need to active the OA
-
- adapter2.add(testController, communicator.stringToIdentity("testController"))
+
+ adapter2.add(testController, Ice.stringToIdentity("testController"))
#adapter2.activate() # Collocated test doesn't need to active the OA
AllTests.allTests(communicator, True)
@@ -50,17 +50,10 @@ try:
#
initData.properties.setProperty("Ice.Warn.Connections", "0");
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 51242e16a3e..c60a21bbb06 100755
--- a/python/test/Ice/ami/Server.py
+++ b/python/test/Ice/ami/Server.py
@@ -28,10 +28,10 @@ def run(args, communicator):
testController = TestI.TestIntfControllerI(adapter)
- adapter.add(TestI.TestIntfI(), communicator.stringToIdentity("test"))
+ adapter.add(TestI.TestIntfI(), Ice.stringToIdentity("test"))
adapter.activate()
- adapter2.add(testController, communicator.stringToIdentity("testController"))
+ adapter2.add(testController, Ice.stringToIdentity("testController"))
adapter2.activate()
communicator.waitForShutdown()
@@ -44,25 +44,18 @@ try:
#
# This test kills connections, so we don't want warnings.
#
- initData.properties.setProperty("Ice.Warn.Connections", "0");
+ 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");
+ initData.properties.setProperty("Ice.TCP.RcvSize", "50000")
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index fa0affce73a..88cd7c71841 100644
--- a/python/test/Ice/ami/Test.ice
+++ b/python/test/Ice/ami/Test.ice
@@ -10,7 +10,6 @@
#pragma once
#include <Ice/BuiltinSequences.ice>
-#include <Ice/Endpoint.ice>
module Test
{
@@ -19,6 +18,13 @@ exception TestIntfException
{
};
+enum CloseMode
+{
+ Forcefully,
+ Gracefully,
+ GracefullyWithWait
+};
+
interface TestIntf
{
void op();
@@ -29,9 +35,13 @@ interface TestIntf
void opBatch();
int opBatchCount();
bool waitForBatch(int count);
- void close(bool force);
+ void close(CloseMode mode);
+ void sleep(int ms);
+ ["amd"] void startDispatch();
+ void finishDispatch();
void shutdown();
+ bool supportsAMD();
bool supportsFunctionalTests();
};
@@ -42,4 +52,3 @@ interface TestIntfController
};
};
-
diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py
index 2950c206f70..d969b10fd72 100644
--- a/python/test/Ice/ami/TestI.py
+++ b/python/test/Ice/ami/TestI.py
@@ -7,12 +7,13 @@
#
# **********************************************************************
-import Ice, Test, threading
+import Ice, Test, threading, time
-class TestIntfI(Test.TestIntf):
+class TestIntfI(Test._TestIntfDisp):
def __init__(self):
self._cond = threading.Condition()
self._batchCount = 0
+ self._pending = []
def op(self, current=None):
pass
@@ -27,41 +28,56 @@ class TestIntfI(Test.TestIntf):
pass
def opBatch(self, current=None):
- self._cond.acquire()
- try:
+ with self._cond:
self._batchCount += 1
self._cond.notify()
- finally:
- self._cond.release()
def opBatchCount(self, current=None):
- self._cond.acquire()
- try:
+ with self._cond:
return self._batchCount
- finally:
- self._cond.release()
def waitForBatch(self, count, current=None):
- self._cond.acquire()
- try:
+ with self._cond:
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 close(self, mode, current=None):
+ current.con.close(Ice.ConnectionClose.valueOf(mode.value))
+
+ def sleep(self, ms, current=None):
+ time.sleep(ms / 1000.0)
+
+ def startDispatch(self, current=None):
+ f = Ice.Future()
+ with self._cond:
+ self._pending.append(f)
+ return f
+
+ def finishDispatch(self, current=None):
+ with self._cond:
+ for f in self._pending:
+ f.set_result(None)
+ self._pending = []
def shutdown(self, current=None):
+ #
+ # Just in case a request arrived late.
+ #
+ with self._cond:
+ for f in self._pending:
+ f.set_result(None)
current.adapter.getCommunicator().shutdown()
+ def supportsAMD(self, current=None):
+ return True
+
def supportsFunctionalTests(self, current=None):
return False
-class TestIntfControllerI(Test.TestIntfController):
+class TestIntfControllerI(Test._TestIntfControllerDisp):
def __init__(self, adapter):
self._adapter = adapter
diff --git a/python/test/Ice/ami/run.py b/python/test/Ice/ami/run.py
deleted file mode 100755
index 13c9c5d76d2..00000000000
--- a/python/test/Ice/ami/run.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/test.py b/python/test/Ice/application/test.py
new file mode 100644
index 00000000000..6dda05ec6ec
--- /dev/null
+++ b/python/test/Ice/application/test.py
@@ -0,0 +1,10 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2016 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.
+#
+# **********************************************************************
+
+# Dummy file to not run this test which is only ran manually. \ No newline at end of file
diff --git a/python/test/Ice/binding/AllTests.py b/python/test/Ice/binding/AllTests.py
index 83fce934f57..c028d92c6d3 100644
--- a/python/test/Ice/binding/AllTests.py
+++ b/python/test/Ice/binding/AllTests.py
@@ -18,32 +18,25 @@ class GetAdapterNameCB:
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 response(self, f):
+ with self._cond:
+ self._name = f.result()
+ self._cond.notify()
def getResult(self):
- self._cond.acquire()
- try:
+ with self._cond:
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)
+ proxy.getAdapterNameAsync().add_done_callback(cb.response)
return cb.getResult()
-
+
def createTestIntfPrx(adapters):
endpoints = []
test = None
@@ -72,9 +65,9 @@ def allTests(communicator):
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())
@@ -84,6 +77,8 @@ def allTests(communicator):
test(False)
except Ice.ConnectionRefusedException:
pass
+ except Ice.ConnectTimeoutException:
+ pass
print("ok")
@@ -115,7 +110,7 @@ def allTests(communicator):
name = test1.getAdapterName()
if names.count(name) > 0:
names.remove(name)
- test1.ice_getConnection().close(False)
+ test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
#
# Ensure that the proxy correctly caches the connection (we
@@ -131,10 +126,10 @@ def allTests(communicator):
while i < nRetry and t.getAdapterName() == name:
i = i + 1
test(i == nRetry)
-
+
for a in adapters:
- a.getTestIntf().ice_getConnection().close(False)
-
+ a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
+
#
# Deactivate an adapter and ensure that we can still
# establish the connection to the remaining adapters.
@@ -157,13 +152,13 @@ def allTests(communicator):
name = test1.getAdapterName()
if names.count(name) > 0:
names.remove(name)
- test1.ice_getConnection().close(False)
+ test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
#
# Deactivate an adapter and ensure that we can still
# establish the connection to the remaining adapters.
#
- com.deactivateObjectAdapter(adapters[2])
+ com.deactivateObjectAdapter(adapters[2])
t = createTestIntfPrx(adapters)
test(t.getAdapterName() == "Adapter12")
@@ -199,7 +194,7 @@ def allTests(communicator):
name = getAdapterNameWithAMI(test1)
if names.count(name) > 0:
names.remove(name)
- test1.ice_getConnection().close(False)
+ test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
#
# Ensure that the proxy correctly caches the connection (we
@@ -215,10 +210,10 @@ def allTests(communicator):
while i < nRetry and getAdapterNameWithAMI(t) == name:
i = i + 1
test(i == nRetry)
-
+
for a in adapters:
- a.getTestIntf().ice_getConnection().close(False)
-
+ a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
+
#
# Deactivate an adapter and ensure that we can still
# establish the connection to the remaining adapters.
@@ -241,13 +236,13 @@ def allTests(communicator):
name = getAdapterNameWithAMI(test1)
if names.count(name) > 0:
names.remove(name)
- test1.ice_getConnection().close(False)
+ test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
#
# Deactivate an adapter and ensure that we can still
# establish the connection to the remaining adapters.
#
- com.deactivateObjectAdapter(adapters[2])
+ com.deactivateObjectAdapter(adapters[2])
t = createTestIntfPrx(adapters)
test(getAdapterNameWithAMI(t) == "AdapterAMI12")
@@ -271,7 +266,7 @@ def allTests(communicator):
name = t.getAdapterName()
if names.count(name) > 0:
names.remove(name)
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
t = Test.TestIntfPrx.uncheckedCast(t.ice_endpointSelection(Ice.EndpointSelectionType.Random))
test(t.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random)
@@ -283,7 +278,7 @@ def allTests(communicator):
name = t.getAdapterName()
if names.count(name) > 0:
names.remove(name)
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
deactivate(com, adapters)
@@ -326,6 +321,8 @@ def allTests(communicator):
t.getAdapterName()
except Ice.ConnectionRefusedException:
pass
+ except Ice.ConnectTimeoutException:
+ pass
endpoints = t.ice_getEndpoints()
@@ -334,19 +331,19 @@ def allTests(communicator):
#
# 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)
+ t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
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)
+ t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
adapters.append(com.createObjectAdapter("Adapter34", endpoints[0].toString()))
i = 0
while i < nRetry and t.getAdapterName() == "Adapter34":
@@ -378,6 +375,8 @@ def allTests(communicator):
test(False)
except Ice.ConnectionRefusedException:
pass
+ except Ice.ConnectTimeoutException:
+ pass
print("ok")
@@ -488,6 +487,8 @@ def allTests(communicator):
t.getAdapterName()
except Ice.ConnectionRefusedException:
pass
+ except Ice.ConnectTimeoutException:
+ pass
endpoints = t.ice_getEndpoints()
@@ -496,7 +497,7 @@ def allTests(communicator):
#
# 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":
@@ -556,6 +557,8 @@ def allTests(communicator):
t.getAdapterName()
except Ice.ConnectionRefusedException:
pass
+ except Ice.ConnectTimeoutException:
+ pass
endpoints = t.ice_getEndpoints()
@@ -564,7 +567,7 @@ def allTests(communicator):
#
# 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":
@@ -611,11 +614,11 @@ def allTests(communicator):
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)
+ t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
testSecure = Test.TestIntfPrx.uncheckedCast(t.ice_secure(True))
test(testSecure.ice_isSecure())
@@ -629,13 +632,13 @@ def allTests(communicator):
for i in range(0, 5):
test(t.getAdapterName() == "Adapter81")
- t.ice_getConnection().close(False)
+ t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
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)
+ t.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
com.deactivateObjectAdapter(adapters[0])
try:
@@ -643,6 +646,8 @@ def allTests(communicator):
test(False)
except Ice.ConnectionRefusedException:
pass
+ except Ice.ConnectTimeoutException:
+ pass
deactivate(com, adapters)
diff --git a/python/test/Ice/binding/Client.py b/python/test/Ice/binding/Client.py
index bb3ba837f48..e68dfb5a518 100755
--- a/python/test/Ice/binding/Client.py
+++ b/python/test/Ice/binding/Client.py
@@ -20,17 +20,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index e4ba5333d5f..ace8c09fbd5 100755
--- a/python/test/Ice/binding/Server.py
+++ b/python/test/Ice/binding/Server.py
@@ -17,7 +17,7 @@ import Test, TestI
def run(args, communicator):
communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
adapter = communicator.createObjectAdapter("TestAdapter")
- id = communicator.stringToIdentity("communicator")
+ id = Ice.stringToIdentity("communicator")
adapter.add(TestI.RemoteCommunicatorI(), id)
adapter.activate()
@@ -25,17 +25,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/TestI.py b/python/test/Ice/binding/TestI.py
index 94030aa5774..1cf751840bc 100644
--- a/python/test/Ice/binding/TestI.py
+++ b/python/test/Ice/binding/TestI.py
@@ -9,7 +9,7 @@
import Ice, Test
-class RemoteCommunicatorI(Test.RemoteCommunicator):
+class RemoteCommunicatorI(Test._RemoteCommunicatorDisp):
def __init__(self):
self._nextPort = 10001
@@ -32,10 +32,10 @@ class RemoteCommunicatorI(Test.RemoteCommunicator):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
-class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
+class RemoteObjectAdapterI(Test._RemoteObjectAdapterDisp):
def __init__(self, adapter):
self._adapter = adapter
- self._testIntf = Test.TestIntfPrx.uncheckedCast(self._adapter.add(TestI(), adapter.getCommunicator().stringToIdentity("test")))
+ self._testIntf = Test.TestIntfPrx.uncheckedCast(self._adapter.add(TestI(), Ice.stringToIdentity("test")))
self._adapter.activate()
def getTestIntf(self, current=None):
@@ -47,6 +47,6 @@ class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
except Ice.ObjectAdapterDeactivatedException:
pass
-class TestI(Test.TestIntf):
+class TestI(Test._TestIntfDisp):
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
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/binding/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index d61d5430c6a..3b7cb0821cf 100755
--- a/python/test/Ice/blobject/Client.py
+++ b/python/test/Ice/blobject/Client.py
@@ -52,45 +52,31 @@ 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()
+ with Ice.initialize(argv, initData) as communicator:
+ 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()
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index bccca264b04..34928c48f89 100644
--- a/python/test/Ice/blobject/RouterI.py
+++ b/python/test/Ice/blobject/RouterI.py
@@ -17,43 +17,29 @@ class CallQueue(threading.Thread):
self._destroy = False
def add(self, call):
- self._condVar.acquire()
- self._queue.append(call)
- self._condVar.notify()
- self._condVar.release()
+ with self._condVar:
+ self._queue.append(call)
+ self._condVar.notify()
def destroy(self):
- self._condVar.acquire()
- self._destroy = True
- self._condVar.notify()
- self._condVar.release()
+ with self._condVar:
+ self._destroy = True
+ self._condVar.notify()
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()
+ with self._condVar:
+ while len(self._queue) == 0 and not self._destroy:
+ self._condVar.wait()
+ if self._destroy:
+ break
+ call = self._queue.pop()
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):
+ def __init__(self, proxy, future, inParams, curr):
self._proxy = proxy
- self._amdCallback = amdCallback
+ self._future = future
self._inParams = inParams
self._curr = curr
@@ -66,13 +52,19 @@ class BlobjectCall(object):
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)
+ self._future.set_result((ok, out))
except Ice.Exception as e:
- self._amdCallback.ice_exception(e)
+ self._future.set_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)
+ f = proxy.ice_invokeAsync(self._curr.operation, self._curr.mode, self._inParams, self._curr.ctx)
+ f.add_done_callback(self.done)
+
+ def done(self, future):
+ try:
+ (ok, bytes) = future.result()
+ self._future.set_result((ok, bytes))
+ except Exception as ex:
+ self._future.set_exception(ex)
class BlobjectAsyncI(Ice.BlobjectAsync):
def __init__(self):
@@ -81,23 +73,22 @@ class BlobjectAsyncI(Ice.BlobjectAsync):
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 ice_invoke(self, inParams, curr):
+ f = Ice.Future()
+ with self._lock:
+ proxy = self._objects[curr.id]
+ assert proxy
+ self._queue.add(BlobjectCall(proxy, f, inParams, curr))
+ return f
def add(self, proxy):
- self._lock.acquire()
- self._objects[proxy.ice_getIdentity()] = proxy.ice_facet("").ice_twoway().ice_router(None)
- self._lock.release()
+ with self._lock:
+ self._objects[proxy.ice_getIdentity()] = proxy.ice_facet("").ice_twoway().ice_router(None)
def destroy(self):
- self._lock.acquire()
- self._queue.destroy()
- self._queue.join()
- self._lock.release()
+ with self._lock:
+ self._queue.destroy()
+ self._queue.join()
class BlobjectI(Ice.Blobject):
def __init__(self):
@@ -105,9 +96,8 @@ class BlobjectI(Ice.Blobject):
self._lock = threading.Lock()
def ice_invoke(self, inParams, curr):
- self._lock.acquire()
- proxy = self._objects[curr.id]
- self._lock.release()
+ with self._lock:
+ proxy = self._objects[curr.id]
if len(curr.facet) > 0:
proxy = proxy.ice_facet(curr.facet)
@@ -122,9 +112,8 @@ class BlobjectI(Ice.Blobject):
raise
def add(self, proxy):
- self._lock.acquire()
- self._objects[proxy.ice_getIdentity()] = proxy.ice_facet("").ice_twoway().ice_router(None)
- self._lock.release()
+ with self._lock:
+ self._objects[proxy.ice_getIdentity()] = proxy.ice_facet("").ice_twoway().ice_router(None)
def destroy(self):
pass
@@ -142,7 +131,7 @@ class ServantLocatorI(Ice.ServantLocator):
def deactivate(self, s):
pass
-class RouterI(Ice.Router):
+class RouterI(Ice._RouterDisp):
def __init__(self, communicator, sync):
self._adapter = communicator.createObjectAdapterWithEndpoints("forward", "default -h 127.0.0.1")
if sync:
diff --git a/python/test/Ice/blobject/Server.py b/python/test/Ice/blobject/Server.py
index 19db1d77c83..9cd56f0de08 100755
--- a/python/test/Ice/blobject/Server.py
+++ b/python/test/Ice/blobject/Server.py
@@ -15,7 +15,7 @@ import Ice
Ice.loadSlice('Test.ice')
import Test
-class TestI(Test.Hello):
+class TestI(Test._HelloDisp):
def sayHello(self, delay, current=None):
if delay != 0:
time.sleep(delay / 1000.0)
@@ -33,7 +33,7 @@ class TestI(Test.Hello):
def run(args, communicator):
communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
adapter = communicator.createObjectAdapter("TestAdapter")
- adapter.add(TestI(), communicator.stringToIdentity("test"))
+ adapter.add(TestI(), Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
@@ -47,17 +47,10 @@ try:
# this warning.
#
initData.properties.setProperty("Ice.Warn.Dispatch", "0");
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/run.py b/python/test/Ice/blobject/run.py
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/blobject/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 4a91a943fd8..77683b92770 100644
--- a/python/test/Ice/checksum/AllTests.py
+++ b/python/test/Ice/checksum/AllTests.py
@@ -46,7 +46,6 @@ def allTests(communicator):
m = patt.search(i)
if m:
n = int(i[m.start():])
-
test(i in Ice.sliceChecksums)
if n <= 1:
diff --git a/python/test/Ice/checksum/CTypes.ice b/python/test/Ice/checksum/CTypes.ice
index f4d3198b613..c15d5c94633 100644
--- a/python/test/Ice/checksum/CTypes.ice
+++ b/python/test/Ice/checksum/CTypes.ice
@@ -378,7 +378,7 @@ exception OptionalEx4
//
// TEST: Same
//
-class BaseClass1
+interface BaseInterface1
{
void baseOp1();
void baseOp2(int i, out string s) throws Exception1;
@@ -387,7 +387,7 @@ class BaseClass1
//
// TEST: Change return type
//
-class BaseClass2
+interface BaseInterface2
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -396,7 +396,7 @@ class BaseClass2
//
// TEST: Add parameter
//
-class BaseClass3
+interface BaseInterface3
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -405,7 +405,7 @@ class BaseClass3
//
// TEST: Add exception
//
-class BaseClass4
+interface BaseInterface4
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -414,7 +414,7 @@ class BaseClass4
//
// TEST: Change out parameter to in parameter
//
-class BaseClass5
+interface BaseInterface5
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -423,7 +423,7 @@ class BaseClass5
//
// TEST: Remove parameter
//
-class BaseClass6
+interface BaseInterface6
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -432,7 +432,7 @@ class BaseClass6
//
// TEST: Remove exception
//
-class BaseClass7
+interface BaseInterface7
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -441,34 +441,16 @@ class BaseClass7
//
// TEST: Remove operation
//
-class BaseClass8
+interface BaseInterface8
{
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
+// TEST: Add base interface
//
-class BaseClass11
+interface BaseInterface9
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -479,8 +461,7 @@ class BaseClass11
//
class Compact1(1)
{
- void baseOp();
- void baseOp2(int i, out string s) throws Exception1;
+ int id;
};
//
@@ -495,8 +476,7 @@ class Derived1 extends Compact1
//
class Compact2(2)
{
- void baseOp();
- void baseOp2(int i, out string s) throws Exception1;
+ int id;
};
//
@@ -550,53 +530,53 @@ class Optional4
};
//
-// TEST: Class with optional parameters.
+// TEST: Interface with optional parameters.
//
-class OptionalParameters0
+interface OptionalParameters0
{
void op1(string firstName, optional(1) string secondName,
optional(2) string emailAddress);
};
//
-// TEST: Class with optional parameters, different order.
+// TEST: Interface with optional parameters, different order.
//
-class OptionalParameters1
+interface OptionalParameters1
{
void op1(string firstName, optional(1) string secondName,
optional(2) string emailAddress);
};
//
-// TEST: Class with optional parameters, different tags.
+// TEST: Interface with optional parameters, different tags.
//
-class OptionalParameters2
+interface OptionalParameters2
{
void op1(string firstName, optional(1) string emailAddress,
optional(2) string secondName);
};
//
-// TEST: Class with different optional parameters.
+// TEST: Interface with different optional parameters.
//
-class OptionalParameters3
+interface OptionalParameters3
{
void op1(string firstName, optional(1) string emailAddress,
string secondName);
};
//
-// TEST: Class with optional return type.
+// TEST: Interface with optional return type.
//
-class OptionalReturn0
+interface OptionalReturn0
{
optional(1) int op();
};
//
-// TEST: Class that changes optional return type.
+// TEST: Interface that changes optional return type.
//
-class OptionalReturn2
+interface OptionalReturn2
{
optional(1) int op();
};
diff --git a/python/test/Ice/checksum/Client.py b/python/test/Ice/checksum/Client.py
index cf30cc1c55e..0cc81d37861 100755
--- a/python/test/Ice/checksum/Client.py
+++ b/python/test/Ice/checksum/Client.py
@@ -25,17 +25,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 991c6316d42..98c5e37f143 100644
--- a/python/test/Ice/checksum/STypes.ice
+++ b/python/test/Ice/checksum/STypes.ice
@@ -375,7 +375,7 @@ exception OptionalEx4
//
// TEST: Same
//
-class BaseClass1
+interface BaseInterface1
{
void baseOp1();
void baseOp2(int i, out string s) throws Exception1;
@@ -384,7 +384,7 @@ class BaseClass1
//
// TEST: Change return type
//
-class BaseClass2
+interface BaseInterface2
{
int baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -393,7 +393,7 @@ class BaseClass2
//
// TEST: Add parameter
//
-class BaseClass3
+interface BaseInterface3
{
void baseOp(Object o);
void baseOp2(int i, out string s) throws Exception1;
@@ -402,7 +402,7 @@ class BaseClass3
//
// TEST: Add exception
//
-class BaseClass4
+interface BaseInterface4
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1, Exception2;
@@ -411,7 +411,7 @@ class BaseClass4
//
// TEST: Change out parameter to in parameter
//
-class BaseClass5
+interface BaseInterface5
{
void baseOp();
void baseOp2(int i, string s) throws Exception1;
@@ -420,7 +420,7 @@ class BaseClass5
//
// TEST: Remove parameter
//
-class BaseClass6
+interface BaseInterface6
{
void baseOp();
void baseOp2(out string s) throws Exception1;
@@ -429,7 +429,7 @@ class BaseClass6
//
// TEST: Remove exception
//
-class BaseClass7
+interface BaseInterface7
{
void baseOp();
void baseOp2(int i, out string s);
@@ -438,7 +438,7 @@ class BaseClass7
//
// TEST: Remove operation
//
-class BaseClass8
+interface BaseInterface8
{
void baseOp2(int i, out string s) throws Exception1;
};
@@ -446,25 +446,7 @@ class BaseClass8
//
// 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
+interface BaseInterface9 extends Interface1
{
void baseOp();
void baseOp2(int i, out string s) throws Exception1;
@@ -475,8 +457,7 @@ class BaseClass11 extends EmptyClass1 implements Interface1
//
class Compact1(1)
{
- void baseOp();
- void baseOp2(int i, out string s) throws Exception1;
+ int id;
};
//
@@ -491,8 +472,7 @@ class Derived1 extends Compact1
//
class Compact2(3)
{
- void baseOp();
- void baseOp2(int i, out string s) throws Exception1;
+ int id;
};
//
@@ -547,53 +527,53 @@ class Optional4
};
//
-// TEST: Class with optional parameters.
+// TEST: Interface with optional parameters.
//
-class OptionalParameters0
+interface OptionalParameters0
{
void op1(string firstName, optional(1) string secondName,
optional(2) string emailAddress);
};
//
-// TEST: Class with optional parameters, different order.
+// TEST: Interface with optional parameters, different order.
//
-class OptionalParameters1
+interface OptionalParameters1
{
void op1(string firstName, optional(2) string emailAddress,
optional(1) string secondName);
};
//
-// TEST: Class with optional parameters, different tags.
+// TEST: Interface with optional parameters, different tags.
//
-class OptionalParameters2
+interface OptionalParameters2
{
void op1(string firstName, optional(2) string emailAddress,
optional(1) string secondName);
};
//
-// TEST: Class with different optional parameters.
+// TEST: Interface with different optional parameters.
//
-class OptionalParameters3
+interface OptionalParameters3
{
void op1(string firstName, string emailAddress,
optional(1) string secondName);
};
//
-// TEST: Class with optional return type.
+// TEST: Interface with optional return type.
//
-class OptionalReturn0
+interface OptionalReturn0
{
optional(1) int op();
};
//
-// TEST: Class that changes optional return type.
+// TEST: Interface that changes optional return type.
//
-class OptionalReturn2
+interface OptionalReturn2
{
int op();
};
diff --git a/python/test/Ice/checksum/Server.py b/python/test/Ice/checksum/Server.py
index 0005e80051d..54028534eb7 100755
--- a/python/test/Ice/checksum/Server.py
+++ b/python/test/Ice/checksum/Server.py
@@ -19,7 +19,7 @@ if not slice_dir:
Ice.loadSlice("'-I" + slice_dir + "' --checksum Test.ice STypes.ice")
import Test
-class ChecksumI(Test.Checksum):
+class ChecksumI(Test._ChecksumDisp):
def getSliceChecksums(self, current=None):
return Ice.sliceChecksums
@@ -30,23 +30,16 @@ 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.add(object, Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/run.py b/python/test/Ice/checksum/run.py
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/checksum/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/Client.py b/python/test/Ice/custom/Client.py
index 83e845dc8d8..ccffc2b1508 100755
--- a/python/test/Ice/custom/Client.py
+++ b/python/test/Ice/custom/Client.py
@@ -20,17 +20,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index cb5680ecdd3..ad132e98526 100755
--- a/python/test/Ice/custom/Server.py
+++ b/python/test/Ice/custom/Server.py
@@ -18,7 +18,7 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class CustomI(Test.Custom):
+class CustomI(Test._CustomDisp):
def opByteString1(self, b1, current=None):
if sys.version_info[0] == 2:
test(isinstance(b1, str))
@@ -93,23 +93,16 @@ 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.add(object, Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/run.py b/python/test/Ice/custom/run.py
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/custom/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/Client.py b/python/test/Ice/defaultServant/Client.py
index bb3ba837f48..e68dfb5a518 100755
--- a/python/test/Ice/defaultServant/Client.py
+++ b/python/test/Ice/defaultServant/Client.py
@@ -20,17 +20,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 5ff29e8bc28..13eaf576f83 100644
--- a/python/test/Ice/defaultServant/MyObjectI.py
+++ b/python/test/Ice/defaultServant/MyObjectI.py
@@ -9,7 +9,7 @@
import Ice, Test
-class MyObjectI(Test.MyObject):
+class MyObjectI(Test._MyObjectDisp):
def ice_ping(self, current=None):
name = current.id.name
diff --git a/python/test/Ice/defaultServant/run.py b/python/test/Ice/defaultServant/run.py
deleted file mode 100755
index 3082ed4e986..00000000000
--- a/python/test/Ice/defaultServant/run.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/Test.ice b/python/test/Ice/defaultValue/Test.ice
index e4bb79e50e0..c29b88c956c 100644
--- a/python/test/Ice/defaultValue/Test.ice
+++ b/python/test/Ice/defaultValue/Test.ice
@@ -9,6 +9,8 @@
#pragma once
+[["suppress-warning:deprecated"]] // For enumerator references
+
module Test
{
@@ -33,12 +35,12 @@ struct Struct1
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 c1 = ::Test::Color::red;
Color c2 = Test::green;
Color c3 = blue;
- Nested::Color nc1 = ::Test::Nested::red;
+ Nested::Color nc1 = Test::Nested::Color::red;
Nested::Color nc2 = Nested::green;
- Nested::Color nc3 = Nested::blue;
+ Nested::Color nc3 = blue;
string noDefault;
int zeroI = 0;
long zeroL = 0;
@@ -56,12 +58,12 @@ 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 ConstColor1 = ::Test::Color::red;
const Color ConstColor2 = Test::green;
const Color ConstColor3 = blue;
-const Nested::Color ConstNestedColor1 = ::Test::Nested::red;
+const Nested::Color ConstNestedColor1 = Test::Nested::Color::red;
const Nested::Color ConstNestedColor2 = Test::Nested::green;
-const Nested::Color ConstNestedColor3 = Nested::blue;
+const Nested::Color ConstNestedColor3 = blue;
const int ConstZeroI = 0;
const long ConstZeroL = 0;
const float ConstZeroF = 0;
@@ -115,12 +117,12 @@ class Base
class Derived extends Base
{
- Color c1 = ::Test::red;
+ Color c1 = ::Test::Color::red;
Color c2 = Test::green;
Color c3 = blue;
- Nested::Color nc1 = ::Test::Nested::red;
+ Nested::Color nc1 = ::Test::Nested::Color::red;
Nested::Color nc2 = Nested::green;
- Nested::Color nc3 = Nested::blue;
+ Nested::Color nc3 = blue;
};
exception BaseEx
diff --git a/python/test/Ice/defaultValue/run.py b/python/test/Ice/defaultValue/run.py
deleted file mode 100755
index 3082ed4e986..00000000000
--- a/python/test/Ice/defaultValue/run.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/Client.py b/python/test/Ice/enums/Client.py
index 9e3b20d38ef..ae42eead6ac 100755
--- a/python/test/Ice/enums/Client.py
+++ b/python/test/Ice/enums/Client.py
@@ -20,17 +20,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 8f9559a83bc..93f27f861c0 100755
--- a/python/test/Ice/enums/Server.py
+++ b/python/test/Ice/enums/Server.py
@@ -18,7 +18,7 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class TestIntfI(Test.TestIntf):
+class TestIntfI(Test._TestIntfDisp):
def opByte(self, b1, current=None):
return (b1, b1)
@@ -50,23 +50,16 @@ 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.add(object, Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/run.py b/python/test/Ice/enums/run.py
deleted file mode 100755
index eb0e326db74..00000000000
--- a/python/test/Ice/enums/run.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 9dae9af06e2..88d948324b2 100644
--- a/python/test/Ice/exceptions/AllTests.py
+++ b/python/test/Ice/exceptions/AllTests.py
@@ -13,7 +13,7 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class EmptyI(Test.Empty):
+class EmptyI(Test._EmptyDisp):
pass
class ServantLocatorI(Ice.ServantLocator):
@@ -26,12 +26,8 @@ class ServantLocatorI(Ice.ServantLocator):
def deactivate(self, category):
pass
-class ObjectFactoryI(Ice.ObjectFactory):
- def create(id):
- return None
-
- def destroy():
- pass
+def ValueFactory(type):
+ return None
class CallbackBase:
def __init__(self):
@@ -39,19 +35,15 @@ class CallbackBase:
self._cond = threading.Condition()
def check(self):
- self._cond.acquire()
- try:
+ with self._cond:
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()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
class Callback(CallbackBase):
def __init__(self, communicator=None):
@@ -176,7 +168,7 @@ class Callback(CallbackBase):
try:
raise ex
except Ice.ObjectNotExistException as ex:
- id = self._communicator.stringToIdentity("does not exist")
+ id = Ice.stringToIdentity("does not exist")
test(ex.id == id)
except:
test(False)
@@ -226,29 +218,29 @@ def allTests(communicator):
communicator.getProperties().setProperty("TestAdapter1.Endpoints", "default")
adapter = communicator.createObjectAdapter("TestAdapter1")
obj = EmptyI()
- adapter.add(obj, communicator.stringToIdentity("x"))
+ adapter.add(obj, Ice.stringToIdentity("x"))
try:
- adapter.add(obj, communicator.stringToIdentity("x"))
+ adapter.add(obj, Ice.stringToIdentity("x"))
test(false)
except Ice.AlreadyRegisteredException:
pass
try:
- adapter.add(obj, communicator.stringToIdentity(""))
+ adapter.add(obj, Ice.stringToIdentity(""))
test(false)
except Ice.IllegalIdentityException as ex:
test(ex.id.name == "")
try:
- adapter.add(None, communicator.stringToIdentity("x"))
+ adapter.add(None, Ice.stringToIdentity("x"))
test(false)
except Ice.IllegalServantException:
pass
- adapter.remove(communicator.stringToIdentity("x"))
+ adapter.remove(Ice.stringToIdentity("x"))
try:
- adapter.remove(communicator.stringToIdentity("x"))
+ adapter.remove(Ice.stringToIdentity("x"))
test(false)
except Ice.NotRegisteredException:
pass
@@ -273,10 +265,10 @@ def allTests(communicator):
sys.stdout.write("testing object factory registration exception... ")
sys.stdout.flush()
- of = ObjectFactoryI()
- communicator.addObjectFactory(of, "x")
+
+ communicator.getValueFactoryManager().add(ValueFactory, "x")
try:
- communicator.addObjectFactory(of, "x")
+ communicator.getValueFactoryManager().add(ValueFactory, "x")
test(false)
except Ice.AlreadyRegisteredException:
pass
@@ -499,7 +491,7 @@ def allTests(communicator):
sys.stdout.write("catching object not exist exception... ")
sys.stdout.flush()
- id = communicator.stringToIdentity("does not exist")
+ id = Ice.stringToIdentity("does not exist")
try:
thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id))
thrower2.throwAasA(1)
@@ -593,6 +585,7 @@ def allTests(communicator):
try:
thrower.throwAfterException()
+ test(False)
except Test.A:
pass
except:
@@ -601,6 +594,230 @@ def allTests(communicator):
print("ok")
+ sys.stdout.write("catching exact types with futures... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwAasAAsync(1).result()
+ test(False)
+ except Test.A as ex:
+ test(ex.aMem == 1)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwAorDasAorDAsync(1).result()
+ test(False)
+ except Test.A as ex:
+ test(ex.aMem == 1)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwAorDasAorDAsync(-1).result()
+ test(False)
+ except Test.D as ex:
+ test(ex.dMem == -1)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwBasBAsync(1, 2).result()
+ test(False)
+ except Test.B as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwCasCAsync(1, 2, 3).result()
+ 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.throwModAAsync(1, 2).result()
+ 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 derived types with futures... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwBasAAsync(1, 2).result()
+ test(False)
+ except Test.B as ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwCasAAsync(1, 2, 3).result()
+ 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.throwCasBAsync(1, 2, 3).result()
+ 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 with futures... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwUndeclaredAAsync(1).result()
+ test(False)
+ except Ice.UnknownUserException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwUndeclaredBAsync(1, 2).result()
+ test(False)
+ except Ice.UnknownUserException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ try:
+ thrower.throwUndeclaredCAsync(1, 2, 3).result()
+ test(False)
+ except Ice.UnknownUserException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
+ sys.stdout.write("catching object not exist exception with futures... ")
+ sys.stdout.flush()
+
+ id = Ice.stringToIdentity("does not exist")
+ try:
+ thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id))
+ thrower2.throwAasAAsync(1).result()
+# 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 with futures... ")
+ sys.stdout.flush()
+
+ try:
+ thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet")
+ try:
+ thrower2.ice_pingAsync().result()
+ 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 with futures... ")
+ sys.stdout.flush()
+
+ try:
+ thrower2 = Test.WrongOperationPrx.uncheckedCast(thrower)
+ thrower2.noSuchOperationAsync().result()
+ 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 with futures... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwLocalExceptionAsync().result()
+ test(False)
+ except Ice.UnknownLocalException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+ try:
+ thrower.throwLocalExceptionIdempotentAsync().result()
+ 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 with futures... ")
+ sys.stdout.flush()
+
+ try:
+ thrower.throwNonIceExceptionAsync().result()
+ test(False)
+ except Ice.UnknownException:
+ pass
+ except:
+ print(sys.exc_info())
+ test(False)
+
+ print("ok")
+
sys.stdout.write("catching exact types with AMI mapping... ")
sys.stdout.flush()
@@ -668,7 +885,7 @@ def allTests(communicator):
sys.stdout.write("catching object not exist exception with AMI mapping... ")
sys.stdout.flush()
- id = communicator.stringToIdentity("does not exist")
+ id = Ice.stringToIdentity("does not exist")
thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id))
cb = Callback(communicator)
thrower2.begin_throwAasA(1, cb.response, cb.exception_AasAObjectNotExist)
diff --git a/python/test/Ice/exceptions/Client.py b/python/test/Ice/exceptions/Client.py
index 61ab651cb11..7016fac1441 100755
--- a/python/test/Ice/exceptions/Client.py
+++ b/python/test/Ice/exceptions/Client.py
@@ -29,17 +29,10 @@ try:
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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 510584ddb0f..1f5ee529e14 100755
--- a/python/test/Ice/exceptions/Collocated.py
+++ b/python/test/Ice/exceptions/Collocated.py
@@ -25,7 +25,7 @@ def run(args, communicator):
properties.setProperty("TestAdapter.Endpoints", "default -p 12010")
adapter = communicator.createObjectAdapter("TestAdapter")
object = TestI.ThrowerI()
- adapter.add(object, communicator.stringToIdentity("thrower"))
+ adapter.add(object, Ice.stringToIdentity("thrower"))
#adapter.activate() // Don't activate OA to ensure collocation is used.
thrower = AllTests.allTests(communicator)
@@ -36,17 +36,10 @@ 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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 51c2978d2b3..2afc4e427f5 100755
--- a/python/test/Ice/exceptions/Server.py
+++ b/python/test/Ice/exceptions/Server.py
@@ -24,9 +24,9 @@ def run(args, communicator):
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.add(object, Ice.stringToIdentity("thrower"))
+ adapter2.add(object, Ice.stringToIdentity("thrower"))
+ adapter3.add(object, Ice.stringToIdentity("thrower"))
adapter.activate()
adapter2.activate()
adapter3.activate()
@@ -44,17 +44,10 @@ try:
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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 07b323fa947..7e3d005ecc1 100755
--- a/python/test/Ice/exceptions/ServerAMD.py
+++ b/python/test/Ice/exceptions/ServerAMD.py
@@ -23,130 +23,141 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class ThrowerI(Test.Thrower):
- def shutdown_async(self, cb, current=None):
+class ThrowerI(Test._ThrowerDisp):
+ def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
- cb.ice_response()
- def supportsUndeclaredExceptions_async(self, cb, current=None):
- cb.ice_response(True)
+ def supportsUndeclaredExceptions(self, current=None):
+ return True
- def supportsAssertException_async(self, cb, current=None):
- cb.ice_response(False)
+ def supportsAssertException(self, current=None):
+ return False
- def throwAasA_async(self, cb, a, current=None):
+ def throwAasA(self, a, current=None):
ex = Test.A()
ex.aMem = a
- cb.ice_exception(ex)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def throwAorDasAorD_async(self, cb, a, current=None):
+ def throwAorDasAorD(self, a, current=None):
+ f = Ice.Future()
if a > 0:
ex = Test.A()
ex.aMem = a
- cb.ice_exception(ex)
+ f.set_exception(ex)
else:
ex = Test.D()
ex.dMem = a
- cb.ice_exception(ex)
+ f.set_exception(ex)
+ return f
- def throwBasA_async(self, cb, a, b, current=None):
+ def throwBasA(self, 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):
+ def throwCasA(self, a, b, c, current=None):
ex = Test.C()
ex.aMem = a
ex.bMem = b
ex.cMem = c
- cb.ice_exception(ex)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def throwBasB_async(self, cb, a, b, current=None):
+ def throwBasB(self, 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):
+ def throwCasB(self, a, b, c, current=None):
ex = Test.C()
ex.aMem = a
ex.bMem = b
ex.cMem = c
- cb.ice_exception(ex)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def throwCasC_async(self, cb, a, b, c, current=None):
+ def throwCasC(self, a, b, c, current=None):
ex = Test.C()
ex.aMem = a
ex.bMem = b
ex.cMem = c
- cb.ice_exception(ex)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def throwModA_async(self, cb, a, a2, current=None):
+ def throwModA(self, a, a2, current=None):
ex = Test.Mod.A()
ex.aMem = a
ex.a2Mem = a2
raise ex
- def throwUndeclaredA_async(self, cb, a, current=None):
+ def throwUndeclaredA(self, a, current=None):
ex = Test.A()
ex.aMem = a
- cb.ice_exception(ex)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def throwUndeclaredB_async(self, cb, a, b, current=None):
+ def throwUndeclaredB(self, 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):
+ def throwUndeclaredC(self, a, b, c, current=None):
ex = Test.C()
ex.aMem = a
ex.bMem = b
ex.cMem = c
- cb.ice_exception(ex)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def throwLocalException_async(self, cb, current=None):
- cb.ice_exception(Ice.TimeoutException())
+ def throwLocalException(self, current=None):
+ f = Ice.Future()
+ f.set_exception(Ice.TimeoutException())
+ return f
- 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
+ def throwNonIceException(self, current=None):
+ f = Ice.Future()
+ f.set_exception(RuntimeError("12345"))
+ return f
- cb.ice_exception(RuntimeError("12345"))
-
- def throwAssertException_async(self, cb, current=None):
+ def throwAssertException(self, current=None):
raise RuntimeError("operation `throwAssertException' not supported")
- def throwMemoryLimitException_async(self, cb, seq, current=None):
- cb.ice_response(bytearray(20 * 1024))
+ def throwMemoryLimitException(self, seq, current=None):
+ return Ice.Future.completed(bytearray(20 * 1024))
- def throwLocalExceptionIdempotent_async(self, cb, current=None):
- cb.ice_exception(Ice.TimeoutException())
+ def throwLocalExceptionIdempotent(self, current=None):
+ f = Ice.Future()
+ f.set_exception(Ice.TimeoutException())
+ return f
- def throwAfterResponse_async(self, cb, current=None):
- cb.ice_response()
- raise RuntimeError("12345")
+ def throwAfterResponse(self, current=None):
+ # Cannot be implemented with Futures
+ return None
- def throwAfterException_async(self, cb, current=None):
- cb.ice_exception(Test.A())
- raise RuntimeError("12345")
+ def throwAfterException(self, current=None):
+ # Cannot be implemented with Futures
+ f = Ice.Future()
+ f.set_exception(Test.A())
+ return f
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.add(object, Ice.stringToIdentity("thrower"))
+ adapter2.add(object, Ice.stringToIdentity("thrower"))
+ adapter3.add(object, Ice.stringToIdentity("thrower"))
adapter.activate()
adapter2.activate()
adapter3.activate()
@@ -164,17 +175,10 @@ try:
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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/TestI.py b/python/test/Ice/exceptions/TestI.py
index 2f994f3422c..ac4e3ab99f2 100644
--- a/python/test/Ice/exceptions/TestI.py
+++ b/python/test/Ice/exceptions/TestI.py
@@ -9,7 +9,7 @@
import Ice, Test, array, sys
-class ThrowerI(Test.Thrower):
+class ThrowerI(Test._ThrowerDisp):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
diff --git a/python/test/Ice/exceptions/run.py b/python/test/Ice/exceptions/run.py
deleted file mode 100755
index 96a9752d793..00000000000
--- a/python/test/Ice/exceptions/run.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 5a553700407..b9fcba386dd 100644
--- a/python/test/Ice/facets/AllTests.py
+++ b/python/test/Ice/facets/AllTests.py
@@ -13,7 +13,7 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class EmptyI(Test.Empty):
+class EmptyI(Test._EmptyDisp):
pass
def allTests(communicator):
@@ -45,16 +45,16 @@ def allTests(communicator):
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")
+ adapter.add(obj, Ice.stringToIdentity("d"))
+ adapter.addFacet(obj, Ice.stringToIdentity("d"), "facetABCD")
try:
- adapter.addFacet(obj, communicator.stringToIdentity("d"), "facetABCD")
+ adapter.addFacet(obj, Ice.stringToIdentity("d"), "facetABCD")
test(false)
except Ice.AlreadyRegisteredException:
pass
- adapter.removeFacet(communicator.stringToIdentity("d"), "facetABCD")
+ adapter.removeFacet(Ice.stringToIdentity("d"), "facetABCD")
try:
- adapter.removeFacet(communicator.stringToIdentity("d"), "facetABCD")
+ adapter.removeFacet(Ice.stringToIdentity("d"), "facetABCD")
test(false)
except Ice.NotRegisteredException:
pass
@@ -64,22 +64,22 @@ def allTests(communicator):
sys.stdout.flush()
obj1 = EmptyI()
obj2 = EmptyI()
- adapter.addFacet(obj1, communicator.stringToIdentity("id1"), "f1")
- adapter.addFacet(obj2, communicator.stringToIdentity("id1"), "f2")
+ adapter.addFacet(obj1, Ice.stringToIdentity("id1"), "f1")
+ adapter.addFacet(obj2, Ice.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"))
+ adapter.addFacet(obj1, Ice.stringToIdentity("id2"), "f1")
+ adapter.addFacet(obj2, Ice.stringToIdentity("id2"), "f2")
+ adapter.addFacet(obj3, Ice.stringToIdentity("id2"), "")
+ fm = adapter.removeAllFacets(Ice.stringToIdentity("id1"))
test(len(fm) == 2)
test(fm["f1"] == obj1)
test(fm["f2"] == obj2)
try:
- adapter.removeAllFacets(communicator.stringToIdentity("id1"))
+ adapter.removeAllFacets(Ice.stringToIdentity("id1"))
test(false)
except Ice.NotRegisteredException:
pass
- fm = adapter.removeAllFacets(communicator.stringToIdentity("id2"))
+ fm = adapter.removeAllFacets(Ice.stringToIdentity("id2"))
test(len(fm) == 3)
test(fm["f1"] == obj1)
test(fm["f2"] == obj2)
diff --git a/python/test/Ice/facets/Client.py b/python/test/Ice/facets/Client.py
index 2339436a44c..86807cecb5d 100755
--- a/python/test/Ice/facets/Client.py
+++ b/python/test/Ice/facets/Client.py
@@ -21,17 +21,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 5760df42994..f336384b0ea 100755
--- a/python/test/Ice/facets/Collocated.py
+++ b/python/test/Ice/facets/Collocated.py
@@ -18,12 +18,12 @@ 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")
+ adapter.add(d, Ice.stringToIdentity("d"))
+ adapter.addFacet(d, Ice.stringToIdentity("d"), "facetABCD")
f = TestI.FI()
- adapter.addFacet(f, communicator.stringToIdentity("d"), "facetEF")
+ adapter.addFacet(f, Ice.stringToIdentity("d"), "facetEF")
h = TestI.HI(communicator)
- adapter.addFacet(h, communicator.stringToIdentity("d"), "facetGH")
+ adapter.addFacet(h, Ice.stringToIdentity("d"), "facetGH")
#adapter.activate() // Don't activate OA to ensure collocation is used.
@@ -32,17 +32,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index f89933d33a1..846e724f4a2 100755
--- a/python/test/Ice/facets/Server.py
+++ b/python/test/Ice/facets/Server.py
@@ -18,12 +18,12 @@ 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")
+ adapter.add(d, Ice.stringToIdentity("d"))
+ adapter.addFacet(d, Ice.stringToIdentity("d"), "facetABCD")
f = TestI.FI()
- adapter.addFacet(f, communicator.stringToIdentity("d"), "facetEF")
+ adapter.addFacet(f, Ice.stringToIdentity("d"), "facetEF")
h = TestI.HI(communicator)
- adapter.addFacet(h, communicator.stringToIdentity("d"), "facetGH")
+ adapter.addFacet(h, Ice.stringToIdentity("d"), "facetGH")
adapter.activate()
communicator.waitForShutdown()
@@ -31,17 +31,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/TestI.py b/python/test/Ice/facets/TestI.py
index 4f977b74c32..c3bcfe20042 100644
--- a/python/test/Ice/facets/TestI.py
+++ b/python/test/Ice/facets/TestI.py
@@ -9,31 +9,31 @@
import Test
-class AI(Test.A):
+class AI(Test._ADisp):
def callA(self, current=None):
return "A"
-class BI(Test.B, AI):
+class BI(Test._BDisp, AI):
def callB(self, current=None):
return "B"
-class CI(Test.C, AI):
+class CI(Test._CDisp, AI):
def callC(self, current=None):
return "C"
-class DI(Test.D, BI, CI):
+class DI(Test._DDisp, BI, CI):
def callD(self, current=None):
return "D"
-class EI(Test.E):
+class EI(Test._EDisp):
def callE(self, current=None):
return "E"
-class FI(Test.F, EI):
+class FI(Test._FDisp, EI):
def callF(self, current=None):
return "F"
-class GI(Test.G):
+class GI(Test._GDisp):
def __init__(self, communicator):
self._communicator = communicator
@@ -43,7 +43,7 @@ class GI(Test.G):
def callG(self, current=None):
return "G"
-class HI(Test.H, GI):
+class HI(Test._HDisp, GI):
def __init__(self, communicator):
GI.__init__(self, communicator)
diff --git a/python/test/Ice/facets/run.py b/python/test/Ice/facets/run.py
deleted file mode 100755
index e3c2c280892..00000000000
--- a/python/test/Ice/facets/run.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 8445c159321..dda42cfd74a 100644
--- a/python/test/Ice/faultTolerance/AllTests.py
+++ b/python/test/Ice/faultTolerance/AllTests.py
@@ -22,37 +22,32 @@ class CallbackBase:
self._cond = threading.Condition()
def check(self):
- self._cond.acquire()
- try:
+ with self._cond:
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()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
class Callback(CallbackBase):
- def response(self):
- test(False)
-
- def exception(self, ex):
- test(False)
-
- def opPidI(self, pid):
- self._pid = pid
- self.called()
+ def opPidI(self, f):
+ try:
+ self._pid = f.result()
+ self.called()
+ except:
+ test(False)
- def opShutdownI(self):
+ def opShutdownI(self, f):
+ test(f.exception() is None)
self.called()
- def exceptAbortI(self, ex):
+ def exceptAbortI(self, f):
+ test(f.exception() is not None)
try:
- raise ex
+ f.result()
except Ice.ConnectionLostException:
pass
except Ice.ConnectFailedException:
@@ -102,7 +97,7 @@ def allTests(communicator, ports):
sys.stdout.write("testing server #%d with AMI... " % i)
sys.stdout.flush()
cb = Callback()
- obj.begin_pid(cb.opPidI, cb.exception)
+ obj.pidAsync().add_done_callback(cb.opPidI)
cb.check()
pid = cb.pid()
test(pid != oldPid)
@@ -119,7 +114,7 @@ def allTests(communicator, ports):
sys.stdout.write("shutting down server #%d with AMI... " % i)
sys.stdout.flush()
cb = Callback()
- obj.begin_shutdown(cb.opShutdownI, cb.exception)
+ obj.shutdownAsync().add_done_callback(cb.opShutdownI)
cb.check()
print("ok")
elif j == 1 or i + 1 > len(ports):
@@ -137,7 +132,7 @@ def allTests(communicator, ports):
sys.stdout.write("aborting server #%d with AMI... " % i)
sys.stdout.flush()
cb = Callback()
- obj.begin_abort(cb.response, cb.exceptAbortI)
+ obj.abortAsync().add_done_callback(cb.exceptAbortI)
cb.check()
print("ok")
elif j == 2 or j == 3:
@@ -155,7 +150,7 @@ def allTests(communicator, ports):
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)
+ obj.idempotentAbortAsync().add_done_callback(cb.exceptAbortI)
cb.check()
print("ok")
diff --git a/python/test/Ice/faultTolerance/Client.py b/python/test/Ice/faultTolerance/Client.py
index ef78b617521..eb87436670c 100755
--- a/python/test/Ice/faultTolerance/Client.py
+++ b/python/test/Ice/faultTolerance/Client.py
@@ -27,7 +27,7 @@ def run(args, communicator):
usage(args[0])
return False
- ports.append(int(arg))
+ ports.append(12010 + int(arg))
if len(ports) == 0:
sys.stderr.write(args[0] + ": no ports specified\n")
@@ -45,23 +45,16 @@ def run(args, communicator):
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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 8f6fcddf314..c6c96c99744 100755
--- a/python/test/Ice/faultTolerance/Server.py
+++ b/python/test/Ice/faultTolerance/Server.py
@@ -17,7 +17,7 @@ import Test
def usage(n):
sys.stderr.write("Usage: " + n + " port\n")
-class TestI(Test.TestIntf):
+class TestI(Test._TestIntfDisp):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
@@ -43,7 +43,7 @@ def run(args, communicator):
usage(args[0])
return False
- port = int(arg)
+ port = 12010 + int(arg)
if port <= 0:
sys.stderr.write(args[0] + ": no port specified\n")
@@ -54,7 +54,7 @@ def run(args, communicator):
communicator.getProperties().setProperty("TestAdapter.Endpoints", endpts)
adapter = communicator.createObjectAdapter("TestAdapter")
object = TestI()
- adapter.add(object, communicator.stringToIdentity("test"))
+ adapter.add(object, Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
@@ -69,17 +69,10 @@ try:
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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/run.py b/python/test/Ice/faultTolerance/run.py
deleted file mode 100755
index fae644649f7..00000000000
--- a/python/test/Ice/faultTolerance/run.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index d94b78edfce..43f9d24dc1d 100644
--- a/python/test/Ice/info/AllTests.py
+++ b/python/test/Ice/info/AllTests.py
@@ -13,6 +13,18 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
+def getTCPEndpointInfo(info):
+ while(info):
+ if isinstance(info, Ice.TCPEndpointInfo):
+ return info
+ info = info.underlying
+
+def getTCPConnectionInfo(info):
+ while(info):
+ if isinstance(info, Ice.TCPConnectionInfo):
+ return info
+ info = info.underlying
+
def allTests(communicator):
sys.stdout.write("testing proxy endpoint information... ")
sys.stdout.flush()
@@ -23,22 +35,23 @@ def allTests(communicator):
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 and isinstance(ipEndpoint, Ice.SSLEndpointInfo)) or
- (ipEndpoint.type() == Ice.WSEndpointType and isinstance(ipEndpoint, Ice.WSEndpointInfo)) or
- (ipEndpoint.type() == Ice.WSSEndpointType and isinstance(ipEndpoint, Ice.WSSEndpointInfo)))
+ endpoint = endps[0].getInfo()
+ tcpEndpoint = getTCPEndpointInfo(endpoint)
+ test(isinstance(tcpEndpoint, Ice.TCPEndpointInfo))
+ test(tcpEndpoint.host == "tcphost")
+ test(tcpEndpoint.port == 10000)
+ test(tcpEndpoint.sourceAddress == "10.10.10.10")
+ test(tcpEndpoint.timeout == 1200)
+ test(tcpEndpoint.compress)
+ test(not tcpEndpoint.datagram())
+ test((tcpEndpoint.type() == Ice.TCPEndpointType and not tcpEndpoint.secure()) or
+ (tcpEndpoint.type() == Ice.SSLEndpointType and tcpEndpoint.secure()) or # SSL
+ (tcpEndpoint.type() == Ice.WSEndpointType and not tcpEndpoint.secure()) or # WS
+ (tcpEndpoint.type() == Ice.WSSEndpointType and tcpEndpoint.secure())) # WS
+ test((tcpEndpoint.type() == Ice.TCPEndpointType and isinstance(endpoint, Ice.TCPEndpointInfo)) or
+ (tcpEndpoint.type() == Ice.SSLEndpointType and isinstance(endpoint, Ice.SSLEndpointInfo)) or
+ (tcpEndpoint.type() == Ice.WSEndpointType and isinstance(endpoint, Ice.WSEndpointInfo)) or
+ (tcpEndpoint.type() == Ice.WSSEndpointType and isinstance(endpoint, Ice.WSEndpointInfo)))
udpEndpoint = endps[1].getInfo()
test(isinstance(udpEndpoint, Ice.UDPEndpointInfo))
@@ -71,18 +84,24 @@ def allTests(communicator):
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)
+ tcpEndpoint = getTCPEndpointInfo(endpoints[0].getInfo())
+ test(tcpEndpoint.type() == Ice.TCPEndpointType or tcpEndpoint.type() == 2 or tcpEndpoint.type() == 4 or
+ tcpEndpoint.type() == 5)
+ test(tcpEndpoint.host == defaultHost)
+ test(tcpEndpoint.port > 0)
+ test(tcpEndpoint.timeout == 15000)
udpEndpoint = endpoints[1].getInfo()
test(udpEndpoint.host == defaultHost)
test(udpEndpoint.datagram())
test(udpEndpoint.port > 0)
+ endpoints = (endpoints[0], )
+ test(len(endpoints) == 1)
+ adapter.setPublishedEndpoints(endpoints)
+ publishedEndpoints = adapter.getPublishedEndpoints()
+ test(endpoints == publishedEndpoints)
+
adapter.destroy()
communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -h * -p 12020")
@@ -92,15 +111,16 @@ def allTests(communicator):
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)
+ tcpEndpoint = getTCPEndpointInfo(endpoints[i].getInfo())
+ test(tcpEndpoint.port == 12020)
- ipEndpoint = publishedEndpoints[0].getInfo()
- test(ipEndpoint.host == "127.0.0.1")
- test(ipEndpoint.port == 12020)
+ tcpEndpoint = getTCPEndpointInfo(publishedEndpoints[0].getInfo())
+ test(tcpEndpoint.host == "127.0.0.1")
+ test(tcpEndpoint.port == 12020)
adapter.destroy()
@@ -112,13 +132,13 @@ def allTests(communicator):
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)
+ tcpinfo = getTCPEndpointInfo(base.ice_getConnection().getEndpoint().getInfo())
+ test(tcpinfo.port == 12010)
+ test(not tcpinfo.compress)
+ test(tcpinfo.host == defaultHost)
ctx = testIntf.getEndpointInfoAsContext()
- test(ctx["host"] == ipinfo.host)
+ test(ctx["host"] == tcpinfo.host)
test(ctx["compress"] == "false")
port = int(ctx["port"])
test(port > 0)
@@ -136,26 +156,26 @@ def allTests(communicator):
connection.setBufferSize(1024, 2048)
info = connection.getInfo()
+ tcpinfo = getTCPConnectionInfo(info)
test(not info.incoming)
test(len(info.adapterName) == 0)
- test(info.remotePort == 12010)
+ test(tcpinfo.remotePort == 12010)
if defaultHost == '127.0.0.1':
- test(info.remoteAddress == defaultHost)
- test(info.localAddress == defaultHost)
- test(info.rcvSize >= 1024)
- test(info.sndSize >= 2048)
+ test(tcpinfo.remoteAddress == defaultHost)
+ test(tcpinfo.localAddress == defaultHost)
+ test(tcpinfo.rcvSize >= 1024)
+ test(tcpinfo.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))
+ test(ctx["remoteAddress"] == tcpinfo.localAddress)
+ test(ctx["localAddress"] == tcpinfo.remoteAddress)
+ test(ctx["remotePort"] == str(tcpinfo.localPort))
+ test(ctx["localPort"] == str(tcpinfo.remotePort))
if(base.ice_getConnection().type() == "ws" or base.ice_getConnection().type() == "wss"):
- test((base.ice_getConnection().type() == "ws" and isinstance(info, Ice.WSConnectionInfo)) or
- (base.ice_getConnection().type() == "wss" and isinstance(info, Ice.WSSConnectionInfo)))
+ test(isinstance(info, Ice.WSConnectionInfo))
test(info.headers["Upgrade"] == "websocket")
test(info.headers["Connection"] == "Upgrade")
diff --git a/python/test/Ice/info/Client.py b/python/test/Ice/info/Client.py
index 299cde74e86..49db5dbee46 100755
--- a/python/test/Ice/info/Client.py
+++ b/python/test/Ice/info/Client.py
@@ -30,17 +30,10 @@ def run(args, communicator):
try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 0ae75f959f5..371e544e042 100755
--- a/python/test/Ice/info/Server.py
+++ b/python/test/Ice/info/Server.py
@@ -22,7 +22,7 @@ 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.add(TestI.MyDerivedClassI(), Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
@@ -30,17 +30,10 @@ def run(args, communicator):
try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/TestI.py b/python/test/Ice/info/TestI.py
index 7fc0e5abd92..563e9e8180b 100644
--- a/python/test/Ice/info/TestI.py
+++ b/python/test/Ice/info/TestI.py
@@ -10,7 +10,19 @@
import Ice, Test
import time
-class MyDerivedClassI(Test.TestIntf):
+def getIPEndpointInfo(info):
+ while(info):
+ if isinstance(info, Ice.IPEndpointInfo):
+ return info
+ info = info.underlying
+
+def getIPConnectionInfo(info):
+ while(info):
+ if isinstance(info, Ice.IPConnectionInfo):
+ return info
+ info = info.underlying
+
+class MyDerivedClassI(Test._TestIntfDisp):
def __init__(self):
self.ctx = None
@@ -19,7 +31,7 @@ class MyDerivedClassI(Test.TestIntf):
def getEndpointInfoAsContext(self, current):
ctx = {}
- info = current.con.getEndpoint().getInfo()
+ info = getIPEndpointInfo(current.con.getEndpoint().getInfo())
ctx["timeout"] = str(info.timeout)
if info.compress:
ctx["compress"] = "true"
@@ -51,18 +63,19 @@ class MyDerivedClassI(Test.TestIntf):
def getConnectionInfoAsContext(self, current):
ctx = {}
info = current.con.getInfo()
+ ipinfo = getIPConnectionInfo(info)
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)
+ ctx["localAddress"] = ipinfo.localAddress
+ ctx["localPort"] = str(ipinfo.localPort)
+ ctx["remoteAddress"] = ipinfo.remoteAddress
+ ctx["remotePort"] = str(ipinfo.remotePort)
- if isinstance(info, Ice.WSConnectionInfo) or isinstance(info, Ice.WSSConnectionInfo):
+ if isinstance(info, Ice.WSConnectionInfo):
for key, value in info.headers.items():
ctx["ws." + key] = value
diff --git a/python/test/Ice/info/run.py b/python/test/Ice/info/run.py
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/info/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/Client.py b/python/test/Ice/inheritance/Client.py
index 842cef5c4be..256854795fe 100755
--- a/python/test/Ice/inheritance/Client.py
+++ b/python/test/Ice/inheritance/Client.py
@@ -20,17 +20,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 479f94dd558..d8fc1925da5 100755
--- a/python/test/Ice/inheritance/Collocated.py
+++ b/python/test/Ice/inheritance/Collocated.py
@@ -18,7 +18,7 @@ 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.add(object, Ice.stringToIdentity("initial"))
#adapter.activate() // Don't activate OA to ensure collocation is used.
AllTests.allTests(communicator)
@@ -26,17 +26,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index a445f89f0db..c08e4f6b29d 100755
--- a/python/test/Ice/inheritance/Server.py
+++ b/python/test/Ice/inheritance/Server.py
@@ -18,23 +18,16 @@ 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.add(object, Ice.stringToIdentity("initial"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 84af3da3fd6..372dbcc414a 100644
--- a/python/test/Ice/inheritance/Test.ice
+++ b/python/test/Ice/inheritance/Test.ice
@@ -9,6 +9,8 @@
#pragma once
+[["suppress-warning:deprecated"]] // For classes with operations
+
module Test
{
diff --git a/python/test/Ice/inheritance/TestI.py b/python/test/Ice/inheritance/TestI.py
index 9b06a39c8cb..f4d98732334 100644
--- a/python/test/Ice/inheritance/TestI.py
+++ b/python/test/Ice/inheritance/TestI.py
@@ -9,39 +9,39 @@
import Ice, Test
-class CAI(Test.MA.CA):
+class CAI(Test.MA._CADisp):
def caop(self, p, current=None):
return p
-class CBI(Test.MB.CB, CAI):
+class CBI(Test.MB._CBDisp, CAI):
def cbop(self, p, current=None):
return p
-class CCI(Test.MA.CC, CBI):
+class CCI(Test.MA._CCDisp, CBI):
def ccop(self, p, current=None):
return p
-class IAI(Test.MA.IA):
+class IAI(Test.MA._IADisp):
def iaop(self, p, current=None):
return p
-class IB1I(Test.MB.IB1, IAI):
+class IB1I(Test.MB._IB1Disp, IAI):
def ib1op(self, p, current=None):
return p
-class IB2I(Test.MB.IB2, IAI):
+class IB2I(Test.MB._IB2Disp, IAI):
def ib2op(self, p, current=None):
return p
-class ICI(Test.MA.IC, IB1I, IB2I):
+class ICI(Test.MA._ICDisp, IB1I, IB2I):
def icop(self, p, current=None):
return p
-class CDI(Test.MA.CD, CCI, IB1I, IB2I):
+class CDI(Test.MA._CDDisp, CCI, IB1I, IB2I):
def cdop(self, p, current=None):
return p
-class InitialI(Test.Initial):
+class InitialI(Test._InitialDisp):
def __init__(self, adapter):
self._ca = Test.MA.CAPrx.uncheckedCast(adapter.addWithUUID(CAI()))
self._cb = Test.MB.CBPrx.uncheckedCast(adapter.addWithUUID(CBI()))
diff --git a/python/test/Ice/inheritance/run.py b/python/test/Ice/inheritance/run.py
deleted file mode 100755
index e3c2c280892..00000000000
--- a/python/test/Ice/inheritance/run.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index fb4113238ba..4fddaac9ec6 100644
--- a/python/test/Ice/location/AllTests.py
+++ b/python/test/Ice/location/AllTests.py
@@ -9,7 +9,7 @@
import Ice, Test, sys
-class HelloI(Test.Hello):
+class HelloI(Test._HelloDisp):
def sayHello(self, current=None):
pass
@@ -22,8 +22,8 @@ def allTests(communicator, ref):
locator = communicator.getDefaultLocator()
test(manager)
- registry = Test.TestLocatorRegistryPrx.checkedCast(locator.getRegistry());
- test(registry);
+ registry = Test.TestLocatorRegistryPrx.checkedCast(locator.getRegistry())
+ test(registry)
sys.stdout.write("testing stringToProxy... ")
sys.stdout.flush()
@@ -36,34 +36,34 @@ def allTests(communicator, ref):
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()));
-
+ 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());
+ 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... ")
@@ -106,24 +106,28 @@ def allTests(communicator, ref):
try:
obj3 = Test.TestIntfPrx.checkedCast(base3)
obj3.ice_ping()
- except Ice.LocalException:
+ except Ice.LocalException as ex:
+ print(ex)
test(False)
try:
obj2 = Test.TestIntfPrx.checkedCast(base2)
obj2.ice_ping()
- except Ice.LocalException:
+ except Ice.LocalException as ex:
+ print(ex)
test(False)
obj.shutdown()
manager.startServer()
try:
obj2 = Test.TestIntfPrx.checkedCast(base2)
obj2.ice_ping()
- except Ice.LocalException:
+ except Ice.LocalException as ex:
+ print(ex)
test(False)
try:
obj3 = Test.TestIntfPrx.checkedCast(base3)
obj3.ice_ping()
- except Ice.LocalException:
+ except Ice.LocalException as ex:
+ print(ex)
test(False)
obj.shutdown()
manager.startServer()
@@ -196,7 +200,7 @@ def allTests(communicator, ref):
sys.stdout.flush()
hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("hello"))
obj.migrateHello()
- hello.ice_getConnection().close(False);
+ hello.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
hello.sayHello()
obj.migrateHello()
hello.sayHello()
@@ -233,21 +237,21 @@ def allTests(communicator, ref):
#
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);
+ 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());
+ id = Ice.Identity()
+ id.name = Ice.generateUUID()
+ registry.addObject(adapter.add(HelloI(), id))
+ adapter.activate()
+
+ helloPrx = Test.HelloPrx.checkedCast(communicator.stringToProxy(Ice.identityToString(id)))
+ test(not helloPrx.ice_getConnection())
- adapter.deactivate();
+ adapter.deactivate()
print("ok")
sys.stdout.write("shutdown server manager... ")
diff --git a/python/test/Ice/location/Client.py b/python/test/Ice/location/Client.py
index 00f224ad1f9..ddb9601b7d8 100755
--- a/python/test/Ice/location/Client.py
+++ b/python/test/Ice/location/Client.py
@@ -31,17 +31,10 @@ 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)
+ with Ice.initialize(sys.argv, data) as communicator:
+ 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
index e354926119c..ecb351b820d 100755
--- a/python/test/Ice/location/Server.py
+++ b/python/test/Ice/location/Server.py
@@ -19,29 +19,29 @@ if not slice_dir:
Ice.loadSlice("'-I" + slice_dir + "' Test.ice")
import Test
-class ServerLocatorRegistry(Test.TestLocatorRegistry):
+class ServerLocatorRegistry(Test._TestLocatorRegistryDisp):
def __init__(self):
self._adapters = {}
self._objects = {}
- def setAdapterDirectProxy_async(self, cb, adapter, obj, current=None):
+ def setAdapterDirectProxy(self, adapter, obj, current=None):
if obj:
self._adapters[adapter] = obj
else:
self._adapters.pop(adapter)
- cb.ice_response()
+ return None
- def setReplicatedAdapterDirectProxy_async(self, cb, adapter, replica, obj, current=None):
+ def setReplicatedAdapterDirectProxy(self, 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()
+ return None
- def setServerProcessProxy_async(self, id, proxy, current=None):
- cb.ice_response()
+ def setServerProcessProxy(self, id, proxy, current=None):
+ return None
def addObject(self, obj, current=None):
self._objects[obj.ice_getIdentity()] = obj
@@ -56,20 +56,20 @@ class ServerLocatorRegistry(Test.TestLocatorRegistry):
raise Ice.ObjectNotFoundException()
return self._objects[id]
-class ServerLocator(Test.TestLocator):
+class ServerLocator(Test._TestLocatorDisp):
def __init__(self, registry, registryPrx):
self._registry = registry
self._registryPrx = registryPrx
self._requestCount = 0
- def findObjectById_async(self, response, id, current=None):
+ def findObjectById(self, id, current=None):
self._requestCount += 1
- response.ice_response(self._registry.getObject(id))
+ return Ice.Future.completed(self._registry.getObject(id))
- def findAdapterById_async(self, response, id, current=None):
+ def findAdapterById(self, id, current=None):
self._requestCount += 1
- response.ice_response(self._registry.getAdapter(id))
+ return Ice.Future.completed(self._registry.getAdapter(id))
def getRegistry(self, current=None):
return self._registryPrx
@@ -77,7 +77,7 @@ class ServerLocator(Test.TestLocator):
def getRequestCount(self, current=None):
return self._requestCount
-class ServerManagerI(Test.ServerManager):
+class ServerManagerI(Test._ServerManagerDisp):
def __init__(self, registry, initData):
self._registry = registry
self._communicators = []
@@ -89,7 +89,7 @@ class ServerManagerI(Test.ServerManager):
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
@@ -109,9 +109,9 @@ class ServerManagerI(Test.ServerManager):
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"))
+ self._registry.addObject(adapter.add(object, Ice.stringToIdentity("test")))
+ self._registry.addObject(adapter.add(object, Ice.stringToIdentity("test2")))
+ adapter.add(object, Ice.stringToIdentity("test3"))
adapter.activate()
adapter2.activate()
@@ -121,28 +121,28 @@ class ServerManagerI(Test.ServerManager):
i.destroy()
current.adapter.getCommunicator().shutdown()
-class HelloI(Test.Hello):
+class HelloI(Test._HelloDisp):
def sayHello(self, current=None):
pass
-class TestI(Test.TestIntf):
+class TestI(Test._TestIntfDisp):
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")))
+ self._registry.addObject(self._adapter1.add(HelloI(), Ice.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")))
+ return Test.HelloPrx.uncheckedCast(self._adapter1.createIndirectProxy(Ice.stringToIdentity("hello")))
def getReplicatedHello(self, current=None):
- return Test.HelloPrx.uncheckedCast(self._adapter1.createProxy(communicator.stringToIdentity("hello")))
+ return Test.HelloPrx.uncheckedCast(self._adapter1.createProxy(Ice.stringToIdentity("hello")))
def migrateHello(self, current=None):
- id = communicator.stringToIdentity("hello")
+ id = Ice.stringToIdentity("hello")
try:
self._registry.addObject(self._adapter2.add(self._adapter1.remove(id), id))
except Ice.NotRegisteredException:
@@ -166,14 +166,14 @@ def run(args, communicator, initData):
# 'servers' created with the server manager interface.
#
registry = ServerLocatorRegistry()
- registry.addObject(adapter.createProxy(communicator.stringToIdentity("ServerManager")))
+ registry.addObject(adapter.createProxy(Ice.stringToIdentity("ServerManager")))
object = ServerManagerI(registry, initData)
- adapter.add(object, communicator.stringToIdentity("ServerManager"))
+ adapter.add(object, Ice.stringToIdentity("ServerManager"))
- registryPrx = Ice.LocatorRegistryPrx.uncheckedCast(adapter.add(registry, communicator.stringToIdentity("registry")))
+ registryPrx = Ice.LocatorRegistryPrx.uncheckedCast(adapter.add(registry, Ice.stringToIdentity("registry")))
locator = ServerLocator(registry, registryPrx)
- adapter.add(locator, communicator.stringToIdentity("locator"))
+ adapter.add(locator, Ice.stringToIdentity("locator"))
adapter.activate()
communicator.waitForShutdown()
@@ -183,17 +183,10 @@ def run(args, communicator, initData):
try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator, initData)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/run.py b/python/test/Ice/location/run.py
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/location/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index bc7fceab2e9..7578f850ecf 100644
--- a/python/test/Ice/objects/AllTests.py
+++ b/python/test/Ice/objects/AllTests.py
@@ -9,28 +9,30 @@
import Ice, Test, TestI, sys
+def MyValueFactory(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
+
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
+ return None
+
+ def destroy():
pass
def test(b):
@@ -38,15 +40,16 @@ def test(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')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::B')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::C')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::D')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::E')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::F')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::I')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::J')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::H')
+
+ communicator.addObjectFactory(MyObjectFactory(), "TestOF")
sys.stdout.write("testing stringToProxy... ")
sys.stdout.flush()
@@ -67,19 +70,19 @@ def allTests(communicator):
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()
@@ -97,26 +100,26 @@ def allTests(communicator):
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))
+ test(isinstance(j, TestI.JI))
h = initial.getH()
test(isinstance(h, Test.H))
print("ok")
-
+
sys.stdout.write("getting D1... ")
sys.stdout.flush()
- d1 = initial.getD1(Test.D1(Test.A1("a1"), Test.A1("a2"), Test.A1("a3"), Test.A1("a4")));
+ d1 = initial.getD1(Test.D1(Test.A1("a1"), Test.A1("a2"), Test.A1("a3"), Test.A1("a4")))
test(d1.a1.name == "a1")
test(d1.a2.name == "a2")
test(d1.a3.name == "a3")
test(d1.a4.name == "a4")
print("ok")
-
+
sys.stdout.write("throw EDerived... ")
sys.stdout.flush()
try:
@@ -135,7 +138,7 @@ def allTests(communicator):
initial.setI(TestI.JI())
initial.setI(TestI.HI())
print("ok")
-
+
sys.stdout.write("checking consistency... ")
sys.stdout.flush()
test(b1 != b2)
@@ -152,11 +155,11 @@ def allTests(communicator):
test(b1.theA.theC)
test(b1.theA.theC.theB == b1.theA)
test(b1.preMarshalInvoked)
- test(b1.postUnmarshalInvoked())
+ test(b1.postUnmarshalInvoked)
test(b1.theA.preMarshalInvoked)
- test(b1.theA.postUnmarshalInvoked())
+ test(b1.theA.postUnmarshalInvoked)
test(b1.theA.theC.preMarshalInvoked)
- test(b1.theA.theC.postUnmarshalInvoked())
+ 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)
@@ -170,7 +173,7 @@ def allTests(communicator):
test(c)
test(d)
print("ok")
-
+
sys.stdout.write("checking consistency... ")
sys.stdout.flush()
test(b1 != b2)
@@ -190,13 +193,13 @@ def allTests(communicator):
test(d.theB == b2)
test(d.theC == None)
test(d.preMarshalInvoked)
- test(d.postUnmarshalInvoked())
+ test(d.postUnmarshalInvoked)
test(d.theA.preMarshalInvoked)
- test(d.theA.postUnmarshalInvoked())
+ test(d.theA.postUnmarshalInvoked)
test(d.theB.preMarshalInvoked)
- test(d.theB.postUnmarshalInvoked())
+ test(d.theB.postUnmarshalInvoked)
test(d.theB.theC.preMarshalInvoked)
- test(d.theB.theC.postUnmarshalInvoked())
+ test(d.theB.theC.postUnmarshalInvoked)
print("ok")
sys.stdout.write("testing sequences... ")
@@ -219,8 +222,16 @@ def allTests(communicator):
pass
print("ok")
+ sys.stdout.write("testing marshaled results...")
+ sys.stdout.flush()
+ b1 = initial.getMB()
+ test(b1 != None and b1.theB == b1)
+ b1 = initial.getAMDMBAsync().result()
+ test(b1 != None and b1.theB == b1)
+ 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
+ # 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... ")
@@ -244,4 +255,14 @@ def allTests(communicator):
test(False)
print("ok")
+ sys.stdout.write("testing getting ObjectFactory... ")
+ sys.stdout.flush()
+ test(communicator.findObjectFactory("TestOF") != None)
+ print("ok")
+
+ sys.stdout.write("testing getting ObjectFactory as ValueFactory... ")
+ sys.stdout.flush()
+ test(communicator.getValueFactoryManager().find("TestOF") != None)
+ print("ok")
+
return initial
diff --git a/python/test/Ice/objects/Client.py b/python/test/Ice/objects/Client.py
index a27a4771580..eb34e04fc41 100755
--- a/python/test/Ice/objects/Client.py
+++ b/python/test/Ice/objects/Client.py
@@ -21,17 +21,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/Collocated.py b/python/test/Ice/objects/Collocated.py
index a44a1c9a48f..845d56c4cea 100755
--- a/python/test/Ice/objects/Collocated.py
+++ b/python/test/Ice/objects/Collocated.py
@@ -19,9 +19,9 @@ 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"))
+ adapter.add(initial, Ice.stringToIdentity("initial"))
uoet = TestI.UnexpectedObjectExceptionTestI()
- adapter.add(uoet, communicator.stringToIdentity("uoet"))
+ adapter.add(uoet, Ice.stringToIdentity("uoet"))
#adapter.activate() // Don't activate OA to ensure collocation is used.
AllTests.allTests(communicator)
@@ -32,17 +32,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index b23f646405d..b4352d82b5d 100755
--- a/python/test/Ice/objects/Server.py
+++ b/python/test/Ice/objects/Server.py
@@ -15,48 +15,35 @@ 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 MyValueFactory(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 run(args, communicator):
- factory = MyObjectFactory()
- communicator.addObjectFactory(factory, '::Test::I')
- communicator.addObjectFactory(factory, '::Test::J')
- communicator.addObjectFactory(factory, '::Test::H')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::I')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::J')
+ communicator.getValueFactoryManager().add(MyValueFactory, '::Test::H')
communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
adapter = communicator.createObjectAdapter("TestAdapter")
initial = TestI.InitialI(adapter)
- adapter.add(initial, communicator.stringToIdentity("initial"))
+ adapter.add(initial, Ice.stringToIdentity("initial"))
uoet = TestI.UnexpectedObjectExceptionTestI()
- adapter.add(uoet, communicator.stringToIdentity("uoet"))
+ adapter.add(uoet, Ice.stringToIdentity("uoet"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/Test.ice b/python/test/Ice/objects/Test.ice
index 9517a5b050f..8ddd5e1d4cc 100644
--- a/python/test/Ice/objects/Test.ice
+++ b/python/test/Ice/objects/Test.ice
@@ -9,6 +9,8 @@
#pragma once
+[["suppress-warning:deprecated"]] // For classes with operations
+
module Test
{
@@ -37,7 +39,7 @@ class A
C theC;
bool preMarshalInvoked;
- bool postUnmarshalInvoked();
+ bool postUnmarshalInvoked;
};
class B extends A
@@ -50,7 +52,7 @@ class C
B theB;
bool preMarshalInvoked;
- bool postUnmarshalInvoked();
+ bool postUnmarshalInvoked;
};
class D
@@ -60,23 +62,19 @@ class D
C theC;
bool preMarshalInvoked;
- bool postUnmarshalInvoked();
+ bool postUnmarshalInvoked;
};
["protected"] class E
{
int i;
string s;
-
- bool checkValues();
};
class F
{
["protected"] E e1;
E e2;
-
- bool checkValues();
};
interface I
@@ -174,6 +172,9 @@ class Initial
E getE();
F getF();
+ ["marshaled-result"] B getMB();
+ ["amd", "marshaled-result"] B getAMDMB();
+
void getAll(out B b1, out B b2, out C theC, out D theD);
I getI();
diff --git a/python/test/Ice/objects/TestI.py b/python/test/Ice/objects/TestI.py
index 03c4e4db06d..f711157a741 100644
--- a/python/test/Ice/objects/TestI.py
+++ b/python/test/Ice/objects/TestI.py
@@ -12,44 +12,35 @@ import Ice, Test
class BI(Test.B):
def __init__(self):
self.preMarshalInvoked = False
- self._postUnmarshalInvoked = False
-
- def postUnmarshalInvoked(self, current=None):
- return self._postUnmarshalInvoked
+ self.postUnmarshalInvoked = False
def ice_preMarshal(self):
self.preMarshalInvoked = True
def ice_postUnmarshal(self):
- self._postUnmarshalInvoked = True
+ self.postUnmarshalInvoked = True
class CI(Test.C):
def __init__(self):
self.preMarshalInvoked = False
- self._postUnmarshalInvoked = False
-
- def postUnmarshalInvoked(self, current=None):
- return self._postUnmarshalInvoked
+ self.postUnmarshalInvoked = False
def ice_preMarshal(self):
self.preMarshalInvoked = True
def ice_postUnmarshal(self):
- self._postUnmarshalInvoked = True
+ self.postUnmarshalInvoked = True
class DI(Test.D):
def __init__(self):
self.preMarshalInvoked = False
- self._postUnmarshalInvoked = False
-
- def postUnmarshalInvoked(self, current=None):
- return self._postUnmarshalInvoked
+ self.postUnmarshalInvoked = False
def ice_preMarshal(self):
self.preMarshalInvoked = True
def ice_postUnmarshal(self):
- self._postUnmarshalInvoked = True
+ self.postUnmarshalInvoked = True
class EI(Test.E):
def __init__(self):
@@ -65,16 +56,18 @@ class FI(Test.F):
def checkValues(self, current=None):
return self._e1 != None and self._e1 == self.e2
-class II(Test.I):
- pass
+class II(Ice.InterfaceByValue):
+ def __init__(self):
+ Ice.InterfaceByValue.__init__(self, "::Test::I")
-class JI(Test.J):
- pass
+class JI(Ice.InterfaceByValue):
+ def __init__(self):
+ Ice.InterfaceByValue.__init__(self, "::Test::J")
class HI(Test.H):
pass
-class InitialI(Test.Initial):
+class InitialI(Test._InitialDisp):
def __init__(self, adapter):
self._adapter = adapter
self._b1 = BI()
@@ -132,6 +125,12 @@ class InitialI(Test.Initial):
def getF(self, current=None):
return self._f
+ def getMB(self, current):
+ return self._b1
+
+ def getAMDMB(self, current):
+ return Ice.Future.completed(self._b1)
+
def getAll(self, current=None):
self._b1.preMarshalInvoked = False
self._b2.preMarshalInvoked = False
@@ -175,6 +174,6 @@ class InitialI(Test.Initial):
def throwInnerSubEx(self, current=None):
raise Test.Inner.Sub.Ex("Inner::Sub::Ex")
-class UnexpectedObjectExceptionTestI(Test.UnexpectedObjectExceptionTest):
+class UnexpectedObjectExceptionTestI(Test._UnexpectedObjectExceptionTestDisp):
def op(self, current=None):
return Test.AlsoEmpty()
diff --git a/python/test/Ice/objects/run.py b/python/test/Ice/objects/run.py
deleted file mode 100755
index 670da8fecb4..00000000000
--- a/python/test/Ice/objects/run.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 802e595037b..d306b75ec87 100644
--- a/python/test/Ice/operations/AllTests.py
+++ b/python/test/Ice/operations/AllTests.py
@@ -7,8 +7,8 @@
#
# **********************************************************************
-import Ice, Test, Twoways, TwowaysAMI, Oneways, OnewaysAMI, BatchOneways, sys
-import BatchOnewaysAMI
+import Ice, Test, Twoways, TwowaysFuture, TwowaysAMI, Oneways, OnewaysFuture, OnewaysAMI, BatchOneways, sys
+import BatchOnewaysAMI, BatchOnewaysFuture
def test(b):
if not b:
@@ -32,23 +32,39 @@ def allTests(communicator):
Oneways.oneways(communicator, cl)
print("ok")
+ sys.stdout.write("testing twoway operations with futures... ")
+ sys.stdout.flush()
+ TwowaysFuture.twowaysFuture(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 futures... ")
+ sys.stdout.flush()
+ OnewaysFuture.onewaysFuture(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.write("testing batch oneway operations with futures... ")
+ sys.stdout.flush()
+ BatchOnewaysFuture.batchOneways(cl)
+ BatchOnewaysFuture.batchOneways(derived)
+ print("ok")
+
+ sys.stdout.write("testing batch oneway operations with AMI... ")
sys.stdout.flush()
BatchOnewaysAMI.batchOneways(cl)
BatchOnewaysAMI.batchOneways(derived)
diff --git a/python/test/Ice/operations/BatchOneways.py b/python/test/Ice/operations/BatchOneways.py
index fdef04bf70c..4cbe23276a6 100644
--- a/python/test/Ice/operations/BatchOneways.py
+++ b/python/test/Ice/operations/BatchOneways.py
@@ -64,6 +64,9 @@ def batchOneways(p):
batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway())
batch.ice_flushBatchRequests() # Empty flush
+ if batch.ice_getConnection():
+ batch.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy)
+ batch.ice_getCommunicator().flushBatchRequests(Ice.CompressBatch.BasedOnProxy)
p.opByteSOnewayCallCount() # Reset the call count
@@ -82,7 +85,7 @@ def batchOneways(p):
batch1.ice_ping()
batch2.ice_ping()
batch1.ice_flushBatchRequests()
- batch1.ice_getConnection().close(False)
+ batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
batch1.ice_ping()
batch2.ice_ping()
@@ -90,7 +93,7 @@ def batchOneways(p):
batch2.ice_getConnection()
batch1.ice_ping()
- batch1.ice_getConnection().close(False)
+ batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
batch1.ice_ping()
batch2.ice_ping()
diff --git a/python/test/Ice/operations/BatchOnewaysAMI.py b/python/test/Ice/operations/BatchOnewaysAMI.py
index 28e1b47149c..7629d7d1627 100644
--- a/python/test/Ice/operations/BatchOnewaysAMI.py
+++ b/python/test/Ice/operations/BatchOnewaysAMI.py
@@ -19,19 +19,15 @@ class Callback:
self._cond = threading.Condition()
def check(self):
- self._cond.acquire()
- try:
+ with self._cond:
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()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
def batchOneways(p):
@@ -65,14 +61,14 @@ def batchOneways(p):
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.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
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.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
batch1.end_ice_ping(batch1.begin_ice_ping())
batch2.end_ice_ping(batch2.begin_ice_ping())
diff --git a/python/test/Ice/operations/BatchOnewaysFuture.py b/python/test/Ice/operations/BatchOnewaysFuture.py
new file mode 100644
index 00000000000..7f2b89cfc81
--- /dev/null
+++ b/python/test/Ice/operations/BatchOnewaysFuture.py
@@ -0,0 +1,88 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2016 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):
+ with self._cond:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+
+ def called(self):
+ with self._cond:
+ self._called = True
+ self._cond.notify()
+
+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())
+
+ f = batch.ice_flushBatchRequestsAsync() # Empty flush
+ f.result()
+
+ test(batch.ice_flushBatchRequestsAsync().is_sent()) # Empty flush
+ test(batch.ice_flushBatchRequestsAsync().done()) # Empty flush
+ test(batch.ice_flushBatchRequestsAsync().is_sent_synchronously()) # Empty flush
+
+ for i in range(30):
+ batch.opByteSOnewayAsync(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_pingAsync()
+ batch2.ice_pingAsync()
+ batch1.ice_flushBatchRequestsAsync().result()
+ batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
+ batch1.ice_pingAsync()
+ batch2.ice_pingAsync()
+
+ batch1.ice_getConnection()
+ batch2.ice_getConnection()
+
+ batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait)
+
+ test(not batch1.ice_pingAsync().done())
+ test(not batch2.ice_pingAsync().done())
+
+ identity = Ice.Identity()
+ identity.name = "invalid";
+ batch3 = batch.ice_identity(identity)
+ batch3.ice_ping()
+ batch3.ice_flushBatchRequestsAsync().result()
+
+ # Make sure that a bogus batch request doesn't cause troubles to other ones.
+ batch3.ice_ping()
+ batch.ice_ping()
+ batch.ice_flushBatchRequestsAsync().result()
+ batch.ice_ping()
diff --git a/python/test/Ice/operations/Client.py b/python/test/Ice/operations/Client.py
index e5c66401c07..51da4c466b3 100755
--- a/python/test/Ice/operations/Client.py
+++ b/python/test/Ice/operations/Client.py
@@ -31,7 +31,7 @@ def run(args, communicator):
sys.stdout.flush()
myClass.shutdown()
try:
- myClass.opVoid()
+ myClass.ice_timeout(100).ice_ping(); # Use timeout to speed up testing on Windows
test(False)
except Ice.LocalException:
print("ok")
@@ -49,17 +49,13 @@ try:
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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ status = run(sys.argv, communicator)
+ # Test multiple destroy calls
+ communicator.destroy()
+ communicator.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/operations/Collocated.py b/python/test/Ice/operations/Collocated.py
index 36b09e12f11..8148b7af298 100755
--- a/python/test/Ice/operations/Collocated.py
+++ b/python/test/Ice/operations/Collocated.py
@@ -22,7 +22,7 @@ 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"))
+ prx = adapter.add(TestI.MyDerivedClassI(), Ice.stringToIdentity("test"))
#adapter.activate() // Don't activate OA to ensure collocation is used.
if prx.ice_getConnection():
@@ -38,17 +38,10 @@ try:
initData.properties.setProperty("Ice.BatchAutoFlushSize", "100")
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/OnewaysAMI.py b/python/test/Ice/operations/OnewaysAMI.py
index a2dc299933c..79b31c73eb3 100644
--- a/python/test/Ice/operations/OnewaysAMI.py
+++ b/python/test/Ice/operations/OnewaysAMI.py
@@ -19,19 +19,15 @@ class CallbackBase:
self._cond = threading.Condition()
def check(self):
- self._cond.acquire()
- try:
+ with self._cond:
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()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
class Callback(CallbackBase):
def sent(self, sentSynchronously):
@@ -49,7 +45,7 @@ def onewaysAMI(communicator, proxy):
cb.check()
try:
- p.begin_ice_isA(Test.MyClass.ice_staticId())
+ p.begin_ice_isA(Test._MyClassDisp.ice_staticId())
test(False)
except RuntimeError:
pass
diff --git a/python/test/Ice/operations/OnewaysFuture.py b/python/test/Ice/operations/OnewaysFuture.py
new file mode 100644
index 00000000000..741425a0ef4
--- /dev/null
+++ b/python/test/Ice/operations/OnewaysFuture.py
@@ -0,0 +1,54 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2016 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
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def onewaysFuture(communicator, proxy):
+
+ p = Test.MyClassPrx.uncheckedCast(proxy.ice_oneway())
+
+ f = p.ice_pingAsync()
+ f.sent()
+
+ try:
+ p.ice_isAAsync(Test._MyClassDisp.ice_staticId())
+ test(False)
+ except RuntimeError:
+ pass
+
+ try:
+ p.ice_idAsync()
+ test(False)
+ except RuntimeError:
+ pass
+
+ try:
+ p.ice_idsAsync()
+ test(False)
+ except RuntimeError:
+ pass
+
+ f = p.opVoidAsync()
+ f.sent()
+
+ f = p.opIdempotentAsync()
+ f.sent()
+
+ f = p.opNonmutatingAsync()
+ f.sent()
+
+ try:
+ p.opByteAsync(0xff, 0x0f)
+ test(False)
+ except RuntimeError:
+ pass
diff --git a/python/test/Ice/operations/Server.py b/python/test/Ice/operations/Server.py
index 9b19906eafe..5ec8816dc25 100755
--- a/python/test/Ice/operations/Server.py
+++ b/python/test/Ice/operations/Server.py
@@ -21,7 +21,7 @@ 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.add(TestI.MyDerivedClassI(), Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
@@ -35,17 +35,10 @@ try:
# this warning.
#
initData.properties.setProperty("Ice.Warn.Dispatch", "0");
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index f3dd86e001b..0b727f42970 100755
--- a/python/test/Ice/operations/ServerAMD.py
+++ b/python/test/Ice/operations/ServerAMD.py
@@ -8,7 +8,11 @@
#
# **********************************************************************
-import os, sys, traceback, threading
+import os, sys, traceback, threading, time
+
+haveConcurrentFuture = sys.version_info.major > 3 or (sys.version_info.major == 3 and sys.version_info.minor >= 5)
+if haveConcurrentFuture:
+ import concurrent.futures
import Ice
slice_dir = Ice.getSliceDir()
@@ -23,87 +27,96 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class Thread_opVoid(threading.Thread):
- def __init__(self, cb):
+class FutureThread(threading.Thread):
+ def __init__(self, f, r):
threading.Thread.__init__(self)
- self.cb = cb
+ self.future = f
+ self.result = r
def run(self):
- self.cb.ice_response()
+ time.sleep(0.01)
+ self.future.set_result(self.result)
-class MyDerivedClassI(Test.MyDerivedClass):
+class MyDerivedClassI(Test._MyDerivedClassDisp):
def __init__(self):
- self.opVoidThread = None
- self.opVoidThreadLock = threading.Lock()
+ self.threads = []
+ self.threadLock = 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)
+ return Test._MyDerivedClassDisp.ice_isA(self, id, current)
def ice_ping(self, current=None):
test(current.mode == Ice.OperationMode.Nonmutating)
- Test.MyDerivedClass.ice_ping(self, current)
+ Test._MyDerivedClassDisp.ice_ping(self, current)
def ice_ids(self, current=None):
test(current.mode == Ice.OperationMode.Nonmutating)
- return Test.MyDerivedClass.ice_ids(self, current)
+ return Test._MyDerivedClassDisp.ice_ids(self, current)
def ice_id(self, current=None):
test(current.mode == Ice.OperationMode.Nonmutating)
- return Test.MyDerivedClass.ice_id(self, current)
+ return Test._MyDerivedClassDisp.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()
+ def shutdown(self, current=None):
+ with self.threadLock:
+ for thread in self.threads:
+ thread.join()
+ self.threads = []
current.adapter.getCommunicator().shutdown()
- cb.ice_response()
- def opVoid_async(self, cb, current=None):
+ def opVoid(self, current=None):
test(current.mode == Ice.OperationMode.Normal)
- self.opVoidThreadLock.acquire()
- if self.opVoidThread:
- self.opVoidThread.join()
- self.opVoidThread = None
+ f = Ice.Future()
+
+ with self.threadLock:
+ thread = FutureThread(f, None)
+ self.threads.append(thread)
+ thread.start()
- self.opVoidThread = Thread_opVoid(cb)
- self.opVoidThread.start()
- self.opVoidThreadLock.release()
+ return f
- def opByte_async(self, cb, p1, p2, current=None):
- cb.ice_response(p1, p1 ^ p2)
+ def opByte(self, p1, p2, current=None):
+ # Test the ability to use another Future type
+ if haveConcurrentFuture:
+ f = concurrent.futures.Future()
+ with self.threadLock:
+ thread = FutureThread(f, (p1, p1 ^ p2))
+ self.threads.append(thread)
+ thread.start()
+ else:
+ f = Ice.Future.completed((p1, p1 ^ p2))
+ return f
- def opBool_async(self, cb, p1, p2, current=None):
- cb.ice_response(p2, p1)
+ def opBool(self, p1, p2, current=None):
+ return Ice.Future.completed((p2, p1))
- def opShortIntLong_async(self, cb, p1, p2, p3, current=None):
- cb.ice_response(p3, p1, p2, p3)
+ def opShortIntLong(self, p1, p2, p3, current=None):
+ return Ice.Future.completed((p3, p1, p2, p3))
- def opFloatDouble_async(self, cb, p1, p2, current=None):
- cb.ice_response(p2, p1, p2)
+ def opFloatDouble(self, p1, p2, current=None):
+ return Ice.Future.completed((p2, p1, p2))
- def opString_async(self, cb, p1, p2, current=None):
- cb.ice_response(p1 + " " + p2, p2 + " " + p1)
+ def opString(self, p1, p2, current=None):
+ return Ice.Future.completed((p1 + " " + p2, p2 + " " + p1))
- def opMyEnum_async(self, cb, p1, current=None):
- cb.ice_response(Test.MyEnum.enum3, p1)
+ def opMyEnum(self, p1, current=None):
+ return Ice.Future.completed((Test.MyEnum.enum3, p1))
- def opMyClass_async(self, cb, p1, current=None):
+ def opMyClass(self, 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)
+ p3 = Test.MyClassPrx.uncheckedCast(current.adapter.createProxy(Ice.stringToIdentity("noSuchIdentity")))
+ return Ice.Future.completed((Test.MyClassPrx.uncheckedCast(current.adapter.createProxy(current.id)), p2, p3))
- def opStruct_async(self, cb, p1, p2, current=None):
+ def opStruct(self, p1, p2, current=None):
p1.s.s = "a new string"
- cb.ice_response(p2, p1)
+ return Ice.Future.completed((p2, p1))
- def opByteS_async(self, cb, p1, p2, current=None):
+ 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)
@@ -113,310 +126,327 @@ class MyDerivedClassI(Test.MyDerivedClass):
else:
p3 = bytes(reversed(p1))
r = p1 + p2
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opBoolS_async(self, cb, p1, p2, current=None):
+ def opBoolS(self, p1, p2, current=None):
p3 = p1[0:]
p3.extend(p2)
r = p1[0:]
r.reverse();
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opShortIntLongS_async(self, cb, p1, p2, p3, current=None):
+ def opShortIntLongS(self, 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)
+ return Ice.Future.completed((p3, p4, p5, p6))
- def opFloatDoubleS_async(self, cb, p1, p2, current=None):
+ def opFloatDoubleS(self, p1, p2, current=None):
p3 = p1[0:]
p4 = p2[0:]
p4.reverse()
r = p2[0:]
r.extend(p1)
- cb.ice_response(r, p3, p4)
+ return Ice.Future.completed((r, p3, p4))
- def opStringS_async(self, cb, p1, p2, current=None):
+ def opStringS(self, p1, p2, current=None):
p3 = p1[0:]
p3.extend(p2)
r = p1[0:]
r.reverse()
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opByteSS_async(self, cb, p1, p2, current=None):
+ def opByteSS(self, p1, p2, current=None):
p3 = p1[0:]
p3.reverse()
r = p1[0:]
r.extend(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opBoolSS_async(self, cb, p1, p2, current=None):
+ def opBoolSS(self, p1, p2, current=None):
p3 = p1[0:]
p3.extend(p2)
r = p1[0:]
r.reverse()
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opShortIntLongSS_async(self, cb, p1, p2, p3, current=None):
+ def opShortIntLongSS(self, 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)
+ return Ice.Future.completed((p3, p4, p5, p6))
- def opFloatDoubleSS_async(self, cb, p1, p2, current=None):
+ def opFloatDoubleSS(self, p1, p2, current=None):
p3 = p1[0:]
p4 = p2[0:]
p4.reverse()
r = p2[0:]
r.extend(p2)
- cb.ice_response(r, p3, p4)
+ return Ice.Future.completed((r, p3, p4))
- def opStringSS_async(self, cb, p1, p2, current=None):
+ def opStringSS(self, p1, p2, current=None):
p3 = p1[0:]
p3.extend(p2)
r = p2[0:]
r.reverse()
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opStringSSS_async(self, cb, p1, p2, current=None):
+ def opStringSSS(self, p1, p2, current=None):
p3 = p1[0:]
p3.extend(p2)
r = p2[0:]
r.reverse()
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opByteBoolD_async(self, cb, p1, p2, current=None):
+ def opByteBoolD(self, p1, p2, current=None):
p3 = p1.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opShortIntD_async(self, cb, p1, p2, current=None):
+ def opShortIntD(self, p1, p2, current=None):
p3 = p1.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opLongFloatD_async(self, cb, p1, p2, current=None):
+ def opLongFloatD(self, p1, p2, current=None):
p3 = p1.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opStringStringD_async(self, cb, p1, p2, current=None):
+ def opStringStringD(self, p1, p2, current=None):
p3 = p1.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opStringMyEnumD_async(self, cb, p1, p2, current=None):
+ def opStringMyEnumD(self, p1, p2, current=None):
p3 = p1.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opMyEnumStringD_async(self, cb, p1, p2, current=None):
+ def opMyEnumStringD(self, p1, p2, current=None):
p3 = p1.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opMyStructMyEnumD_async(self, cb, p1, p2, current=None):
+ def opMyStructMyEnumD(self, p1, p2, current=None):
p3 = p1.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opByteBoolDS_async(self, cb, p1, p2, current=None):
+ def opByteBoolDS(self, p1, p2, current=None):
p3 = p2[0:]
p3.extend(p1)
r = p1[::-1]
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opShortIntDS_async(self, cb, p1, p2, current=None):
+ def opShortIntDS(self, p1, p2, current=None):
p3 = p2[0:]
p3.extend(p1)
r = p1[::-1]
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opLongFloatDS_async(self, cb, p1, p2, current=None):
+ def opLongFloatDS(self, p1, p2, current=None):
p3 = p2[0:]
p3.extend(p1)
r = p1[::-1]
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opStringStringDS_async(self, cb, p1, p2, current=None):
+ def opStringStringDS(self, p1, p2, current=None):
p3 = p2[0:]
p3.extend(p1)
r = p1[::-1]
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opStringMyEnumDS_async(self, cb, p1, p2, current=None):
+ def opStringMyEnumDS(self, p1, p2, current=None):
p3 = p2[0:]
p3.extend(p1)
r = p1[::-1]
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opMyEnumStringDS_async(self, cb, p1, p2, current=None):
+ def opMyEnumStringDS(self, p1, p2, current=None):
p3 = p2[0:]
p3.extend(p1)
r = p1[::-1]
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opMyStructMyEnumDS_async(self, cb, p1, p2, current=None):
+ def opMyStructMyEnumDS(self, p1, p2, current=None):
p3 = p2[0:]
p3.extend(p1)
r = p1[::-1]
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opByteByteSD_async(self, cb, p1, p2, current=None):
+ def opByteByteSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opBoolBoolSD_async(self, cb, p1, p2, current=None):
+ def opBoolBoolSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opShortShortSD_async(self, cb, p1, p2, current=None):
+ def opShortShortSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opIntIntSD_async(self, cb, p1, p2, current=None):
+ def opIntIntSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opLongLongSD_async(self, cb, p1, p2, current=None):
+ def opLongLongSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opStringFloatSD_async(self, cb, p1, p2, current=None):
+ def opStringFloatSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opStringDoubleSD_async(self, cb, p1, p2, current=None):
+ def opStringDoubleSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opStringStringSD_async(self, cb, p1, p2, current=None):
+ def opStringStringSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opMyEnumMyEnumSD_async(self, cb, p1, p2, current=None):
+ def opMyEnumMyEnumSD(self, p1, p2, current=None):
p3 = p2.copy()
r = p1.copy()
r.update(p2)
- cb.ice_response(r, p3)
+ return Ice.Future.completed((r, p3))
- def opIntS_async(self, cb, s, current=None):
- cb.ice_response([-x for x in s])
+ def opIntS(self, s, current=None):
+ return Ice.Future.completed([-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 opByteSOneway(self, s, current=None):
+ with self.lock:
+ self.opByteSOnewayCount += 1
+ return Ice.Future.completed(None)
- def opByteSOnewayCallCount_async(self, cb, current=None):
- self.lock.acquire()
- count = self.opByteSOnewayCount
- self.opByteSOnewayCount = 0
- self.lock.release()
- cb.ice_response(count)
+ def opByteSOnewayCallCount(self, current=None):
+ with self.lock:
+ count = self.opByteSOnewayCount
+ self.opByteSOnewayCount = 0
+ return Ice.Future.completed(count)
- def opDoubleMarshaling_async(self, cb, p1, p2, current=None):
+ def opDoubleMarshaling(self, p1, p2, current=None):
d = 1278312346.0 / 13.0;
test(p1 == d)
for i in p2:
test(i == d)
- cb.ice_response()
+ return Ice.Future.completed(None)
- def opContext_async(self, cb, current=None):
- cb.ice_response(current.ctx)
+ def opContext(self, current=None):
+ return Ice.Future.completed(current.ctx)
- def opIdempotent_async(self, cb, current=None):
+ def opIdempotent(self, current=None):
test(current.mode == Ice.OperationMode.Idempotent)
- cb.ice_response()
+ return Ice.Future.completed(None)
- def opNonmutating_async(self, cb, current=None):
+ def opNonmutating(self, 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 opStringLiterals_async(self, cb, current=None):
- return cb.ice_response([
+ return Ice.Future.completed(None)
+
+ def opDerived(self, current=None):
+ return Ice.Future.completed(None)
+
+ def opByte1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opShort1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opInt1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opLong1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opFloat1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opDouble1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opString1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opStringS1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opByteBoolD1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opStringS2(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opByteBoolD2(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opMyClass1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opMyStruct1(self, value, current=None):
+ return Ice.Future.completed(value)
+
+ def opStringLiterals(self, current=None):
+ return Ice.Future.completed([
Test.s0, Test.s1, Test.s2, Test.s3, Test.s4, Test.s5, Test.s6, Test.s7, Test.s8, Test.s9, Test.s10,
- Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9, Test.sw10,
+ Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9,
+ Test.sw10,
Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5,
Test.su0, Test.su1, Test.su2])
-
- def opWStringLiterals_async(self, cb, current=None):
- return self.opStringLiterals_async(cb, current)
+
+ def opWStringLiterals(self, current=None):
+ return self.opStringLiterals(current)
+
+ def opMStruct1(self, current):
+ return Ice.Future.completed(Test.Structure())
+
+ def opMStruct2(self, p1, current):
+ return Ice.Future.completed((p1, p1))
+
+ def opMSeq1(self, current):
+ return Ice.Future.completed([])
+
+ def opMSeq2(self, p1, current):
+ return Ice.Future.completed((p1, p1))
+
+ def opMDict1(self, current):
+ return Ice.Future.completed({})
+
+ def opMDict2(self, p1, current):
+ return Ice.Future.completed((p1, p1))
def run(args, communicator):
communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
adapter = communicator.createObjectAdapter("TestAdapter")
- adapter.add(MyDerivedClassI(), communicator.stringToIdentity("test"))
+ adapter.add(MyDerivedClassI(), Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
@@ -425,17 +455,10 @@ 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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 82e7cba1dfc..dfb978df5d3 100644
--- a/python/test/Ice/operations/Test.ice
+++ b/python/test/Ice/operations/Test.ice
@@ -21,7 +21,7 @@ enum MyEnum
enum3
};
-class MyClass;
+interface MyClass;
struct AnotherStruct
{
@@ -91,7 +91,7 @@ dictionary<string, DoubleS> StringDoubleSD;
dictionary<string, StringS> StringStringSD;
dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD;
-class MyClass
+interface MyClass
{
void shutdown();
@@ -249,6 +249,15 @@ class MyClass
StringS opStringLiterals();
StringS opWStringLiterals();
+
+ ["marshaled-result"] Structure opMStruct1();
+ ["marshaled-result"] Structure opMStruct2(Structure p1, out Structure p2);
+
+ ["marshaled-result"] StringS opMSeq1();
+ ["marshaled-result"] StringS opMSeq2(StringS p1, out StringS p2);
+
+ ["marshaled-result"] StringStringD opMDict1();
+ ["marshaled-result"] StringStringD opMDict2(StringStringD p1, out StringStringD p2);
};
struct MyStruct1
@@ -265,7 +274,7 @@ class MyClass1
string myClass1; // Same name as the enclosing class
};
-class MyDerivedClass extends MyClass
+interface MyDerivedClass extends MyClass
{
void opDerived();
MyClass1 opMyClass1(MyClass1 opMyClass1);
@@ -314,9 +323,9 @@ const string sw10 = "\U00000DA7"; // Sinhala Letter Alpapraa
\v vertical tab byte 0x0b in ASCII encoding
**/
-const string ss0 = "\'\"\?\\\a\b\f\n\r\t\v";
-const string ss1 = "\u0027\u0022\u003f\u005c\u0007\u0008\u000c\u000a\u000d\u0009\u000b";
-const string ss2 = "\U00000027\U00000022\U0000003f\U0000005c\U00000007\U00000008\U0000000c\U0000000a\U0000000d\U00000009\U0000000b";
+const string ss0 = "\'\"\?\\\a\b\f\n\r\t\v\6";
+const string ss1 = "\u0027\u0022\u003f\u005c\u0007\u0008\u000c\u000a\u000d\u0009\u000b\u0006";
+const string ss2 = "\U00000027\U00000022\U0000003f\U0000005c\U00000007\U00000008\U0000000c\U0000000a\U0000000d\U00000009\U0000000b\U00000006";
const string ss3 = "\\\\U\\u\\"; /* \\U\u\ */
const string ss4 = "\\\u0041\\"; /* \A\ */
diff --git a/python/test/Ice/operations/TestAMD.ice b/python/test/Ice/operations/TestAMD.ice
index 6be5c0d6f5d..078fd362409 100644
--- a/python/test/Ice/operations/TestAMD.ice
+++ b/python/test/Ice/operations/TestAMD.ice
@@ -19,7 +19,7 @@ enum MyEnum
enum3
};
-class MyClass;
+interface MyClass;
struct AnotherStruct
{
@@ -89,7 +89,7 @@ dictionary<string, DoubleS> StringDoubleSD;
dictionary<string, StringS> StringStringSD;
dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD;
-["amd"] class MyClass
+["amd"] interface MyClass
{
void shutdown();
@@ -247,6 +247,15 @@ dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD;
StringS opStringLiterals();
StringS opWStringLiterals();
+
+ ["marshaled-result"] Structure opMStruct1();
+ ["marshaled-result"] Structure opMStruct2(Structure p1, out Structure p2);
+
+ ["marshaled-result"] StringS opMSeq1();
+ ["marshaled-result"] StringS opMSeq2(StringS p1, out StringS p2);
+
+ ["marshaled-result"] StringStringD opMDict1();
+ ["marshaled-result"] StringStringD opMDict2(StringStringD p1, out StringStringD p2);
};
struct MyStruct1
@@ -263,7 +272,7 @@ class MyClass1
string myClass1; // Same name as the enclosing class
};
-["amd"] class MyDerivedClass extends MyClass
+["amd"] interface MyDerivedClass extends MyClass
{
void opDerived();
MyClass1 opMyClass1(MyClass1 opMyClass1);
@@ -312,9 +321,9 @@ const string sw10 = "\U00000DA7"; // Sinhala Letter Alpapraa
\v vertical tab byte 0x0b in ASCII encoding
**/
-const string ss0 = "\'\"\?\\\a\b\f\n\r\t\v";
-const string ss1 = "\u0027\u0022\u003f\u005c\u0007\u0008\u000c\u000a\u000d\u0009\u000b";
-const string ss2 = "\U00000027\U00000022\U0000003f\U0000005c\U00000007\U00000008\U0000000c\U0000000a\U0000000d\U00000009\U0000000b";
+const string ss0 = "\'\"\?\\\a\b\f\n\r\t\v\6";
+const string ss1 = "\u0027\u0022\u003f\u005c\u0007\u0008\u000c\u000a\u000d\u0009\u000b\u0006";
+const string ss2 = "\U00000027\U00000022\U0000003f\U0000005c\U00000007\U00000008\U0000000c\U0000000a\U0000000d\U00000009\U0000000b\U00000006";
const string ss3 = "\\\\U\\u\\"; /* \\U\u\ */
const string ss4 = "\\\u0041\\"; /* \A\ */
diff --git a/python/test/Ice/operations/TestI.py b/python/test/Ice/operations/TestI.py
index 789add7eb15..0a3b39966ff 100644
--- a/python/test/Ice/operations/TestI.py
+++ b/python/test/Ice/operations/TestI.py
@@ -13,26 +13,26 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class MyDerivedClassI(Test.MyDerivedClass):
+class MyDerivedClassI(Test._MyDerivedClassDisp):
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)
+ return Test._MyDerivedClassDisp.ice_isA(self, id, current)
def ice_ping(self, current=None):
test(current.mode == Ice.OperationMode.Nonmutating)
- Test.MyDerivedClass.ice_ping(self, current)
+ Test._MyDerivedClassDisp.ice_ping(self, current)
def ice_ids(self, current=None):
test(current.mode == Ice.OperationMode.Nonmutating)
- return Test.MyDerivedClass.ice_ids(self, current)
+ return Test._MyDerivedClassDisp.ice_ids(self, current)
def ice_id(self, current=None):
test(current.mode == Ice.OperationMode.Nonmutating)
- return Test.MyDerivedClass.ice_id(self, current)
+ return Test._MyDerivedClassDisp.ice_id(self, current)
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
@@ -60,7 +60,7 @@ class MyDerivedClassI(Test.MyDerivedClass):
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"))))
+ Test.MyClassPrx.uncheckedCast(current.adapter.createProxy(Ice.stringToIdentity("noSuchIdentity"))))
def opStruct(self, p1, p2, current=None):
p1.s.s = "a new string"
@@ -294,15 +294,13 @@ class MyDerivedClassI(Test.MyDerivedClass):
return [-x for x in s]
def opByteSOneway(self, s, current=None):
- self.lock.acquire()
- self.opByteSOnewayCount += 1
- self.lock.release()
+ with self.lock:
+ self.opByteSOnewayCount += 1
def opByteSOnewayCallCount(self, current=None):
- self.lock.acquire()
- count = self.opByteSOnewayCount
- self.opByteSOnewayCount = 0
- self.lock.release()
+ with self.lock:
+ count = self.opByteSOnewayCount
+ self.opByteSOnewayCount = 0
return count
def opContext(self, current=None):
@@ -328,47 +326,63 @@ class MyDerivedClassI(Test.MyDerivedClass):
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
-
+
def opStringLiterals(self, current=None):
return [Test.s0, Test.s1, Test.s2, Test.s3, Test.s4, Test.s5, Test.s6, Test.s7, Test.s8, Test.s9, Test.s10,
Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9, Test.sw10,
Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5,
Test.su0, Test.su1, Test.su2]
-
+
def opWStringLiterals(self, current=None):
return self.opStringLiterals(current)
- \ No newline at end of file
+ def opMStruct1(self, current):
+ return Test.Structure();
+
+ def opMStruct2(self, p1, current):
+ return (p1, p1);
+
+ def opMSeq1(self, current):
+ return ()
+
+ def opMSeq2(self, p1, current):
+ return (p1, p1);
+
+ def opMDict1(self, current):
+ return {};
+
+ def opMDict2(self, p1, current):
+ return (p1, p1);
diff --git a/python/test/Ice/operations/Twoways.py b/python/test/Ice/operations/Twoways.py
index ebaa50ae011..1e473884823 100644
--- a/python/test/Ice/operations/Twoways.py
+++ b/python/test/Ice/operations/Twoways.py
@@ -15,9 +15,9 @@ def test(b):
raise RuntimeError('test assertion failed')
def twoways(communicator, p):
-
+
literals = p.opStringLiterals();
-
+
test(Test.s0 == "\\")
test(Test.s0 == Test.sw0)
test(Test.s0 == literals[0])
@@ -32,7 +32,7 @@ def twoways(communicator, p):
test(Test.s2 == Test.sw2)
test(Test.s2 == literals[2])
test(Test.s2 == literals[13])
-
+
test(Test.s3 == "A21")
test(Test.s3 == Test.sw3)
test(Test.s3 == literals[3])
@@ -62,7 +62,7 @@ def twoways(communicator, p):
test(Test.s8 == Test.sw8)
test(Test.s8 == literals[8])
test(Test.s8 == literals[19])
-
+
test(Test.s9 == "\xf0\x9f\x8d\x8c" if version_info[0] < 3 else b"\xf0\x9f\x8d\x8c".decode("utf-8"))
test(Test.s9 == Test.sw9)
test(Test.s9 == literals[9])
@@ -73,13 +73,13 @@ def twoways(communicator, p):
test(Test.s10 == literals[10])
test(Test.s10 == literals[21])
- test(Test.ss0 == "\'\"\x3f\\\a\b\f\n\r\t\v")
+ test(Test.ss0 == "\'\"\x3f\\\a\b\f\n\r\t\v\x06")
test(Test.ss0 == Test.ss1)
test(Test.ss0 == Test.ss2)
test(Test.ss0 == literals[22])
test(Test.ss0 == literals[23])
test(Test.ss0 == literals[24])
-
+
test(Test.ss3 == "\\\\U\\u\\")
test(Test.ss3 == literals[25])
@@ -103,7 +103,7 @@ def twoways(communicator, p):
#
# ice_isA
#
- test(p.ice_isA(Test.MyClass.ice_staticId()))
+ test(p.ice_isA(Test._MyClassDisp.ice_staticId()))
#
# ice_ids
@@ -117,13 +117,13 @@ def twoways(communicator, p):
#
# ice_id
#
- test(p.ice_id() == Test.MyDerivedClass.ice_staticId())
+ test(p.ice_id() == Test._MyDerivedClassDisp.ice_staticId())
#
# Prx ice_staticId
#
- test(Test.MyClassPrx.ice_staticId() == Test.MyClass.ice_staticId())
- test(Test.MyDerivedClassPrx.ice_staticId() == Test.MyDerivedClass.ice_staticId())
+ test(Test.MyClassPrx.ice_staticId() == Test._MyClassDisp.ice_staticId())
+ test(Test.MyDerivedClassPrx.ice_staticId() == Test._MyDerivedClassDisp.ice_staticId())
test(Ice.ObjectPrx.ice_staticId() == Ice.Object.ice_staticId())
#
@@ -266,9 +266,9 @@ def twoways(communicator, 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"))
+ test(c1.ice_getIdentity() == Ice.stringToIdentity("test"))
+ test(c2.ice_getIdentity() == Ice.stringToIdentity("noSuchIdentity"))
+ test(r.ice_getIdentity() == Ice.stringToIdentity("test"))
r.opVoid()
c1.opVoid()
try:
@@ -1420,3 +1420,19 @@ def twoways(communicator, p):
test(c.tesT == "Test.MyClass1.testT")
test(c.myClass == None)
test(c.myClass1 == "Test.MyClass1.myClass1")
+
+ p1 = p.opMStruct1()
+ p1.e = Test.MyEnum.enum3
+ (p3, p2) = p.opMStruct2(p1)
+ test(p2 == p1 and p3 == p1)
+
+ p.opMSeq1();
+ p1 = ["test"]
+ (p3, p2) = p.opMSeq2(p1)
+ test(p2[0] == "test" and p3[0] == "test");
+
+ p.opMDict1();
+
+ p1 = { "test": "test" }
+ (p3, p2) = p.opMDict2(p1)
+ test(p3["test"] == "test" and p2["test"] == "test")
diff --git a/python/test/Ice/operations/TwowaysAMI.py b/python/test/Ice/operations/TwowaysAMI.py
index c8aee9df604..5f7cc1445c0 100644
--- a/python/test/Ice/operations/TwowaysAMI.py
+++ b/python/test/Ice/operations/TwowaysAMI.py
@@ -19,19 +19,15 @@ class CallbackBase:
self._cond = threading.Condition()
def check(self):
- self._cond.acquire()
- try:
+ with self._cond:
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()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
class Callback(CallbackBase):
def __init__(self, communicator=None):
@@ -90,9 +86,9 @@ class Callback(CallbackBase):
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"))
+ test(c1.ice_getIdentity() == Ice.stringToIdentity("test"))
+ test(c2.ice_getIdentity() == Ice.stringToIdentity("noSuchIdentity"))
+ test(r.ice_getIdentity() == Ice.stringToIdentity("test"))
# We can't do the callbacks below in serialize mode
if self._communicator.getProperties().getPropertyAsInt("Ice.Client.ThreadPool.Serialize") == 0:
r.opVoid()
@@ -761,7 +757,7 @@ def twowaysAMI(communicator, p):
cb.check()
cb = Callback()
- p.begin_ice_isA(Test.MyClass.ice_staticId(), cb.isA, cb.exCB)
+ p.begin_ice_isA(Test._MyClassDisp.ice_staticId(), cb.isA, cb.exCB)
cb.check()
cb = Callback()
@@ -1105,7 +1101,7 @@ def twowaysAMI(communicator, p):
test(c != ctx)
test(len(p.ice_getContext()) == 0)
- r = p.begin_opContext(_ctx=ctx)
+ r = p.begin_opContext(context=ctx)
c = p.end_opContext(r)
test(c == ctx)
@@ -1115,7 +1111,7 @@ def twowaysAMI(communicator, p):
c = p2.end_opContext(r)
test(c == ctx)
- r = p2.begin_opContext(_ctx=ctx)
+ r = p2.begin_opContext(context=ctx)
c = p2.end_opContext(r)
test(c == ctx)
diff --git a/python/test/Ice/operations/TwowaysFuture.py b/python/test/Ice/operations/TwowaysFuture.py
new file mode 100644
index 00000000000..19b0bdaab6c
--- /dev/null
+++ b/python/test/Ice/operations/TwowaysFuture.py
@@ -0,0 +1,1354 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2016 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):
+ with self._cond:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+
+ def called(self):
+ with self._cond:
+ self._called = True
+ self._cond.notify()
+
+class Callback(CallbackBase):
+ def __init__(self, communicator=None):
+ CallbackBase.__init__(self)
+ self._communicator = communicator
+
+ def opByte(self, f):
+ try:
+ (r, b) = f.result()
+ test(b == 0xf0)
+ test(r == 0xff)
+ self.called()
+ except:
+ test(False)
+
+ def opBool(self, f):
+ try:
+ (r, b) = f.result()
+ test(b)
+ test(not r)
+ self.called()
+ except:
+ test(False)
+
+ def opShortIntLong(self, f):
+ try:
+ (r, s, i, l) = f.result()
+ test(s == 10)
+ test(i == 11)
+ test(l == 12)
+ test(r == 12)
+ self.called()
+ except:
+ test(False)
+
+ def opFloatDouble(self, fut):
+ try:
+ (r, f, d) = fut.result()
+ test(f - 3.14 < 0.001)
+ test(d == 1.1E10)
+ test(r == 1.1E10)
+ self.called()
+ except:
+ test(False)
+
+ def opString(self, f):
+ try:
+ (r, s) = f.result()
+ test(s == "world hello")
+ test(r == "hello world")
+ self.called()
+ except:
+ test(False)
+
+ def opMyEnum(self, f):
+ try:
+ (r, e) = f.result()
+ test(e == Test.MyEnum.enum2)
+ test(r == Test.MyEnum.enum3)
+ self.called()
+ except:
+ test(False)
+
+ def opMyClass(self, f):
+ try:
+ (r, c1, c2) = f.result()
+ test(c1.ice_getIdentity() == Ice.stringToIdentity("test"))
+ test(c2.ice_getIdentity() == Ice.stringToIdentity("noSuchIdentity"))
+ test(r.ice_getIdentity() == Ice.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()
+ except:
+ test(False)
+
+ def opStruct(self, f):
+ try:
+ (rso, so) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opByteS(self, f):
+ try:
+ (rso, bso) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opBoolS(self, f):
+ try:
+ (rso, bso) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opShortIntLongS(self, f):
+ try:
+ (rso, sso, iso, lso) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opFloatDoubleS(self, f):
+ try:
+ (rso, fso, dso) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringS(self, f):
+ try:
+ (rso, sso) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opByteSS(self, f):
+ try:
+ (rso, bso) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opBoolSS(self, f):
+ try:
+ (rso, bso) = f.result()
+ 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();
+ except:
+ test(False)
+
+ def opShortIntLongSS(self, f):
+ try:
+ (rso, sso, iso, lso) = f.result()
+ 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();
+ except:
+ test(False)
+
+ def opFloatDoubleSS(self, f):
+ try:
+ (rso, fso, dso) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringSS(self, f):
+ try:
+ (rso, sso) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opByteBoolD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opShortIntD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opLongFloatD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringStringD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringMyEnumD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opMyEnumStringD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opMyStructMyEnumD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opByteBoolDS(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opShortIntDS(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opLongFloatDS(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringStringDS(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringMyEnumDS(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opMyEnumStringDS(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opMyStructMyEnumDS(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opByteByteSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opBoolBoolSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opShortShortSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opIntIntSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opLongLongSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringFloatSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringDoubleSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opStringStringSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opMyEnumMyEnumSD(self, f):
+ try:
+ (ro, do) = f.result()
+ 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()
+ except:
+ test(False)
+
+ def opIntS(self, f):
+ try:
+ r = f.result()
+ for j in range(0, len(r)):
+ test(r[j] == -j)
+ self.called()
+ except:
+ test(False)
+
+ def opIdempotent(self, f):
+ self.called()
+
+ def opNonmutating(self, f):
+ self.called()
+
+ def opDerived(self, f):
+ self.called()
+
+def twowaysFuture(communicator, p):
+ f = p.ice_pingAsync()
+ test(f.result() is None)
+
+ f = p.ice_isAAsync(Test._MyClassDisp.ice_staticId())
+ test(f.result())
+
+ f = p.ice_idAsync()
+ test(f.result() == "::Test::MyDerivedClass")
+
+ f = p.ice_idsAsync()
+ test(len(f.result()) == 3)
+
+ f = p.opVoidAsync()
+ test(f.result() is None)
+
+ cb = Callback()
+ p.opVoidAsync().add_done_callback(lambda f: cb.called())
+ cb.check()
+
+ f = p.opByteAsync(0xff, 0x0f)
+ (ret, p3) = f.result()
+ test(p3 == 0xf0)
+ test(ret == 0xff)
+
+ cb = Callback()
+ p.opByteAsync(0xff, 0x0f).add_done_callback(cb.opByte)
+ cb.check()
+
+ cb = Callback()
+ p.opBoolAsync(True, False).add_done_callback(cb.opBool)
+ cb.check()
+
+ cb = Callback()
+ p.opShortIntLongAsync(10, 11, 12).add_done_callback(cb.opShortIntLong)
+ cb.check()
+
+ cb = Callback()
+ p.opFloatDoubleAsync(3.14, 1.1E10).add_done_callback(cb.opFloatDouble)
+ cb.check()
+
+ cb = Callback()
+ p.opStringAsync("hello", "world").add_done_callback(cb.opString)
+ cb.check()
+
+ cb = Callback()
+ p.opMyEnumAsync(Test.MyEnum.enum2).add_done_callback(cb.opMyEnum)
+ cb.check()
+
+ cb = Callback(communicator)
+ p.opMyClassAsync(p).add_done_callback(cb.opMyClass)
+ 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.opStructAsync(si1, si2).add_done_callback(cb.opStruct)
+ cb.check()
+
+ bsi1 = (0x01, 0x11, 0x12, 0x22)
+ bsi2 = (0xf1, 0xf2, 0xf3, 0xf4)
+
+ cb = Callback()
+ p.opByteSAsync(bsi1, bsi2).add_done_callback(cb.opByteS)
+ cb.check()
+
+ bsi1 = (True, True, False)
+ bsi2 = (False,)
+
+ cb = Callback()
+ p.opBoolSAsync(bsi1, bsi2).add_done_callback(cb.opBoolS)
+ cb.check()
+
+ ssi = (1, 2, 3)
+ isi = (5, 6, 7, 8)
+ lsi = (10, 30, 20)
+
+ cb = Callback()
+ p.opShortIntLongSAsync(ssi, isi, lsi).add_done_callback(cb.opShortIntLongS)
+ cb.check()
+
+ fsi = (3.14, 1.11)
+ dsi = (1.1E10, 1.2E10, 1.3E10)
+
+ cb = Callback()
+ p.opFloatDoubleSAsync(fsi, dsi).add_done_callback(cb.opFloatDoubleS)
+ cb.check()
+
+ ssi1 = ('abc', 'de', 'fghi')
+ ssi2 = ('xyz',)
+
+ cb = Callback()
+ p.opStringSAsync(ssi1, ssi2).add_done_callback(cb.opStringS)
+ cb.check()
+
+ bsi1 = ((0x01, 0x11, 0x12), (0xff,))
+ bsi2 = ((0x0e,), (0xf2, 0xf1))
+
+ cb = Callback()
+ p.opByteSSAsync(bsi1, bsi2).add_done_callback(cb.opByteSS)
+ cb.check()
+
+ bsi1 = ((True,), (False,), (True, True),)
+ bsi2 = ((False, False, True),)
+
+ cb = Callback()
+ p.opBoolSSAsync(bsi1, bsi2).add_done_callback(cb.opBoolSS)
+ cb.check();
+
+ ssi = ((1,2,5), (13,), ())
+ isi = ((24, 98), (42,))
+ lsi = ((496, 1729),)
+
+ cb = Callback()
+ p.opShortIntLongSSAsync(ssi, isi, lsi).add_done_callback(cb.opShortIntLongSS)
+ cb.check()
+
+ fsi = ((3.14,), (1.11,), ())
+ dsi = ((1.1E10, 1.2E10, 1.3E10),)
+
+ cb = Callback()
+ p.opFloatDoubleSSAsync(fsi, dsi).add_done_callback(cb.opFloatDoubleSS)
+ cb.check()
+
+ ssi1 = (('abc',), ('de', 'fghi'))
+ ssi2 = ((), (), ('xyz',))
+
+ cb = Callback()
+ p.opStringSSAsync(ssi1, ssi2).add_done_callback(cb.opStringSS)
+ cb.check()
+
+ di1 = {10: True, 100: False}
+ di2 = {10: True, 11: False, 101: True}
+
+ cb = Callback()
+ p.opByteBoolDAsync(di1, di2).add_done_callback(cb.opByteBoolD)
+ cb.check()
+
+ di1 = {110: -1, 1100: 123123}
+ di2 = {110: -1, 111: -100, 1101: 0}
+
+ cb = Callback()
+ p.opShortIntDAsync(di1, di2).add_done_callback(cb.opShortIntD)
+ cb.check()
+
+ di1 = {999999110: -1.1, 999999111: 123123.2}
+ di2 = {999999110: -1.1, 999999120: -100.4, 999999130: 0.5}
+
+ cb = Callback()
+ p.opLongFloatDAsync(di1, di2).add_done_callback(cb.opLongFloatD)
+ 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.opStringStringDAsync(di1, di2).add_done_callback(cb.opStringStringD)
+ 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.opStringMyEnumDAsync(di1, di2).add_done_callback(cb.opStringMyEnumD)
+ cb.check()
+
+ di1 = {Test.MyEnum.enum1: 'abc'}
+ di2 = {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}
+
+ cb = Callback()
+ p.opMyEnumStringDAsync(di1, di2).add_done_callback(cb.opMyEnumStringD)
+ 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.opMyStructMyEnumDAsync(di1, di2).add_done_callback(cb.opMyStructMyEnumD)
+ cb.check()
+
+ dsi1 = ({ 10: True, 100: False }, { 10: True, 11: False, 101: True })
+ dsi2 = ({ 100: False, 101: False },)
+
+ cb = Callback()
+ p.opByteBoolDSAsync(dsi1, dsi2).add_done_callback(cb.opByteBoolDS)
+ cb.check()
+
+ dsi1 = ({ 110: -1, 1100: 123123 }, { 110: -1, 111: -100, 1101: 0 })
+ dsi2 = ({ 100: -1001 },)
+
+ cb = Callback()
+ p.opShortIntDSAsync(dsi1, dsi2).add_done_callback(cb.opShortIntDS)
+ 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.opLongFloatDSAsync(dsi1, dsi2).add_done_callback(cb.opLongFloatDS)
+ 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.opStringStringDSAsync(dsi1, dsi2).add_done_callback(cb.opStringStringDS)
+ 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.opStringMyEnumDSAsync(dsi1, dsi2).add_done_callback(cb.opStringMyEnumDS)
+ cb.called()
+
+ dsi1 = ({ Test.MyEnum.enum1: 'abc' }, { Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'})
+ dsi2 = ({ Test.MyEnum.enum1: 'Goodbye' },)
+
+ cb = Callback()
+ p.opMyEnumStringDSAsync(dsi1, dsi2).add_done_callback(cb.opMyEnumStringDS)
+ 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.opMyStructMyEnumDSAsync(dsi1, dsi2).add_done_callback(cb.opMyStructMyEnumDS)
+ cb.called()
+
+ sdi1 = { 0x01: (0x01, 0x11), 0x22: (0x12,) }
+ sdi2 = { 0xf1: (0xf2, 0xf3) }
+
+ cb = Callback()
+ p.opByteByteSDAsync(sdi1, sdi2).add_done_callback(cb.opByteByteSD)
+ cb.called()
+
+ sdi1 = { False: (True, False), True: (False, True, True) }
+ sdi2 = { False: (True, False) }
+
+ cb = Callback()
+ p.opBoolBoolSDAsync(sdi1, sdi2).add_done_callback(cb.opBoolBoolSD)
+ cb.called()
+
+ sdi1 = { 1: (1, 2, 3), 2: (4, 5) }
+ sdi2 = { 4: (6, 7) }
+
+ cb = Callback()
+ p.opShortShortSDAsync(sdi1, sdi2).add_done_callback(cb.opShortShortSD)
+ cb.called()
+
+ sdi1 = { 100: (100, 200, 300), 200: (400, 500) }
+ sdi2 = { 400: (600, 700) }
+
+ cb = Callback()
+ p.opIntIntSDAsync(sdi1, sdi2).add_done_callback(cb.opIntIntSD)
+ cb.called()
+
+ sdi1 = { 999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130) }
+ sdi2 = { 999999992: (999999110, 999999120) }
+
+ cb = Callback()
+ p.opLongLongSDAsync(sdi1, sdi2).add_done_callback(cb.opLongLongSD)
+ cb.called()
+
+ sdi1 = { "abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61) }
+ sdi2 = { "aBc": (-3.14, 3.14) }
+
+ cb = Callback()
+ p.opStringFloatSDAsync(sdi1, sdi2).add_done_callback(cb.opStringFloatSD)
+ cb.called()
+
+ sdi1 = { "Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10) }
+ sdi2 = { "": (1.6E10, 1.7E10) }
+
+ cb = Callback()
+ p.opStringDoubleSDAsync(sdi1, sdi2).add_done_callback(cb.opStringDoubleSD)
+ cb.called()
+
+ sdi1 = { "abc": ("abc", "de", "fghi") , "def": ("xyz", "or") }
+ sdi2 = { "ghi": ("and", "xor") }
+
+ cb = Callback()
+ p.opStringStringSDAsync(sdi1, sdi2).add_done_callback(cb.opStringStringSD)
+ 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.opMyEnumMyEnumSDAsync(sdi1, sdi2).add_done_callback(cb.opMyEnumMyEnumSD)
+ 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.opIntSAsync(s).add_done_callback(cb.opIntS)
+ cb.check()
+
+ ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}
+
+ test(len(p.ice_getContext()) == 0)
+ f = p.opContextAsync()
+ c = f.result()
+ test(c != ctx)
+
+ test(len(p.ice_getContext()) == 0)
+ f = p.opContextAsync(context=ctx)
+ c = f.result()
+ test(c == ctx)
+
+ p2 = Test.MyClassPrx.checkedCast(p.ice_context(ctx))
+ test(p2.ice_getContext() == ctx)
+ f = p2.opContextAsync()
+ c = f.result()
+ test(c == ctx)
+
+ f = p2.opContextAsync(context=ctx)
+ c = f.result()
+ 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)
+ f = p3.opContextAsync()
+ c = f.result()
+ test(c == ctx)
+
+ ic.getImplicitContext().put('zero', 'ZERO')
+
+ ctx = ic.getImplicitContext().getContext()
+ f = p3.opContextAsync()
+ c = f.result()
+ 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({})
+ f = p3.opContextAsync()
+ c = f.result()
+ test(c == prxContext)
+
+ ic.getImplicitContext().setContext(ctx)
+ f = p3.opContextAsync()
+ c = f.result()
+ test(c == combined)
+
+ ic.destroy()
+
+ cb = Callback()
+ p.opIdempotentAsync().add_done_callback(cb.opIdempotent)
+ cb.check()
+
+ cb = Callback()
+ p.opNonmutatingAsync().add_done_callback(cb.opNonmutating)
+ cb.check()
+
+ derived = Test.MyDerivedClassPrx.checkedCast(p)
+ test(derived)
+ cb = Callback()
+ derived.opDerivedAsync().add_done_callback(cb.opDerived)
+ cb.check()
+
+ f = p.opByte1Async(0xFF)
+ test(f.result() == 0xFF)
+
+ f = p.opShort1Async(0x7FFF)
+ test(f.result() == 0x7FFF)
+
+ f = p.opInt1Async(0x7FFFFFFF)
+ test(f.result() == 0x7FFFFFFF)
+
+ f = p.opLong1Async(0x7FFFFFFFFFFFFFFF)
+ test(f.result() == 0x7FFFFFFFFFFFFFFF)
+
+ f = p.opFloat1Async(1.0)
+ test(f.result() == 1.0)
+
+ f = p.opDouble1Async(1.0)
+ test(f.result() == 1.0)
+
+ f = p.opString1Async("opString1")
+ test(f.result() == "opString1")
+
+ f = p.opStringS1Async(None)
+ test(len(f.result()) == 0)
+
+ f = p.opByteBoolD1Async(None)
+ test(len(f.result()) == 0)
+
+ f = p.opStringS2Async(None)
+ test(len(f.result()) == 0)
+
+ f = p.opByteBoolD2Async(None)
+ test(len(f.result()) == 0)
diff --git a/python/test/Ice/operations/run.py b/python/test/Ice/operations/run.py
deleted file mode 100755
index 63b57c4f797..00000000000
--- a/python/test/Ice/operations/run.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index f798be8f20e..ee5565db1b4 100644
--- a/python/test/Ice/optional/AllTests.py
+++ b/python/test/Ice/optional/AllTests.py
@@ -76,13 +76,13 @@ def allTests(communicator):
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")), \
+ 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")) ], \
+ [ communicator.stringToProxy("test") ], \
{4:Test.MyEnum.MyEnumMember}, {4:fs}, {5:vs}, {5:Test.OneOptional(15)}, \
- {5:Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))}, \
+ {5:communicator.stringToProxy("test")}, \
[False, True, False])
test(mo1.a == 15)
@@ -94,7 +94,7 @@ def allTests(communicator):
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.j == communicator.stringToProxy("test"))
test(mo1.k == None)
test(mo1.bs == [5])
test(mo1.ss == ["test", "test2"])
@@ -108,13 +108,13 @@ def allTests(communicator):
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.oops[0] == 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.ioopd[5] == communicator.stringToProxy("test"))
test(mo1.bos == [False, True, False])
@@ -197,13 +197,13 @@ def allTests(communicator):
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.oops[0] == 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.ioopd[5] == communicator.stringToProxy("test"))
test(mo5.bos == mo1.bos)
@@ -305,13 +305,13 @@ def allTests(communicator):
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.oops[0] == 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.ioopd[5] == communicator.stringToProxy("test"))
test(mo9.bos is Ice.Unset)
@@ -465,72 +465,72 @@ def allTests(communicator):
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)
+ f = initial.opByteAsync(56)
+ (p2, p3) = f.result()
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)
+ f = initial.opBoolAsync(True)
+ (p2, p3) = f.result()
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)
+ f = initial.opShortAsync(56)
+ (p2, p3) = f.result()
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)
+ f = initial.opIntAsync(56)
+ (p2, p3) = f.result()
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)
+ f = initial.opLongAsync(56)
+ (p2, p3) = f.result()
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)
+ f = initial.opFloatAsync(1.0)
+ (p2, p3) = f.result()
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)
+ f = initial.opDoubleAsync(1.0)
+ (p2, p3) = f.result()
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)
+ f = initial.opStringAsync("test")
+ (p2, p3) = f.result()
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)
+ f = initial.opMyEnumAsync(Test.MyEnum.MyEnumMember)
+ (p2, p3) = f.result()
test(p2 == Test.MyEnum.MyEnumMember and p3 == Test.MyEnum.MyEnumMember)
(p2, p3) = initial.opSmallStruct(Ice.Unset)
@@ -540,8 +540,8 @@ def allTests(communicator):
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)
+ f = initial.opSmallStructAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opFixedStruct(Ice.Unset)
@@ -549,8 +549,8 @@ def allTests(communicator):
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)
+ f = initial.opFixedStructAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opVarStruct(Ice.Unset)
@@ -558,8 +558,8 @@ def allTests(communicator):
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)
+ f = initial.opVarStructAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opOneOptional(Ice.Unset)
@@ -567,17 +567,17 @@ def allTests(communicator):
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)
+ f = initial.opOneOptionalAsync(p1)
+ (p2, p3) = f.result()
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"))
+ p1 = 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)
+ f = initial.opOneOptionalProxyAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opByteSeq(Ice.Unset)
@@ -591,8 +591,8 @@ def allTests(communicator):
else:
test(p2[0] == 0x38)
test(p3[0] == 0x38)
- r = initial.begin_opByteSeq(p1)
- (p2, p3) = initial.end_opByteSeq(r)
+ f = initial.opByteSeqAsync(p1)
+ (p2, p3) = f.result()
test(len(p2) == len(p1) and len(p3) == len(p1))
if sys.version_info[0] == 2:
test(p2[0] == '\x38')
@@ -606,8 +606,8 @@ def allTests(communicator):
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)
+ f = initial.opBoolSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opShortSeq(Ice.Unset)
@@ -615,8 +615,8 @@ def allTests(communicator):
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)
+ f = initial.opShortSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opIntSeq(Ice.Unset)
@@ -624,8 +624,8 @@ def allTests(communicator):
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)
+ f = initial.opIntSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opLongSeq(Ice.Unset)
@@ -633,8 +633,8 @@ def allTests(communicator):
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)
+ f = initial.opLongSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opFloatSeq(Ice.Unset)
@@ -642,8 +642,8 @@ def allTests(communicator):
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)
+ f = initial.opFloatSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opDoubleSeq(Ice.Unset)
@@ -651,8 +651,8 @@ def allTests(communicator):
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)
+ f = initial.opDoubleSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opStringSeq(Ice.Unset)
@@ -660,8 +660,8 @@ def allTests(communicator):
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)
+ f = initial.opStringSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opSmallStructSeq(Ice.Unset)
@@ -669,8 +669,8 @@ def allTests(communicator):
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)
+ f = initial.opSmallStructSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opSmallStructList(Ice.Unset)
@@ -678,8 +678,8 @@ def allTests(communicator):
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)
+ f = initial.opSmallStructListAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opFixedStructSeq(Ice.Unset)
@@ -687,8 +687,8 @@ def allTests(communicator):
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)
+ f = initial.opFixedStructSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opFixedStructList(Ice.Unset)
@@ -696,8 +696,8 @@ def allTests(communicator):
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)
+ f = initial.opFixedStructListAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opVarStructSeq(Ice.Unset)
@@ -705,8 +705,8 @@ def allTests(communicator):
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)
+ f = initial.opVarStructSeqAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opIntIntDict(Ice.Unset)
@@ -714,8 +714,8 @@ def allTests(communicator):
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)
+ f = initial.opIntIntDictAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
(p2, p3) = initial.opStringIntDict(Ice.Unset)
@@ -723,10 +723,19 @@ def allTests(communicator):
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)
+ f = initial.opStringIntDictAsync(p1)
+ (p2, p3) = f.result()
test(p2 == p1 and p3 == p1)
+ (p2, p3) = initial.opIntOneOptionalDict(Ice.Unset)
+ test(p2 is Ice.Unset and p3 is Ice.Unset)
+ p1 = {1:Test.OneOptional(58), 2:Test.OneOptional(59)}
+ (p2, p3) = initial.opIntOneOptionalDict(p1)
+ test(p2[1].a == 58 and p3[1].a == 58);
+ f = initial.opIntOneOptionalDictAsync(p1)
+ (p2, p3) = f.result()
+ test(p2[1].a == 58 and p3[1].a == 58);
+
print("ok")
sys.stdout.write("testing exception optionals... ")
@@ -794,4 +803,42 @@ def allTests(communicator):
print("ok")
+ sys.stdout.write("testing optionals with marshaled results... ")
+ sys.stdout.flush()
+
+ test(initial.opMStruct1() != Ice.Unset);
+ test(initial.opMDict1() != Ice.Unset);
+ test(initial.opMSeq1() != Ice.Unset);
+ test(initial.opMG1() != Ice.Unset);
+
+ (p3, p2) = initial.opMStruct2(Ice.Unset);
+ test(p2 == Ice.Unset and p3 == Ice.Unset);
+
+ p1 = Test.SmallStruct();
+ (p3, p2) = initial.opMStruct2(p1)
+ test(p2 == p1 and p3 == p1)
+
+ (p3, p2) = initial.opMSeq2(Ice.Unset)
+ test(p2 == Ice.Unset and p3 == Ice.Unset)
+
+ p1 = ["hello"]
+ (p3, p2) = initial.opMSeq2(p1);
+ test(p2[0] == "hello" and p3[0] == "hello")
+
+ (p3, p2) = initial.opMDict2(Ice.Unset)
+ test(p2 == Ice.Unset and p3 == Ice.Unset)
+
+ p1 = {"test" : 54}
+ (p3, p2) = initial.opMDict2(p1)
+ test(p2["test"] == 54 and p3["test"] == 54)
+
+ (p3, p2) = initial.opMG2(Ice.Unset)
+ test(p2 == Ice.Unset and p3 == Ice.Unset)
+
+ p1 = Test.G();
+ (p3, p2) = initial.opMG2(p1);
+ test(p2 != Ice.Unset and p3 != Ice.Unset and p3 == p2);
+
+ print("ok")
+
return initial
diff --git a/python/test/Ice/optional/Client.py b/python/test/Ice/optional/Client.py
index c0dd750ba76..4af2bbcbe37 100755
--- a/python/test/Ice/optional/Client.py
+++ b/python/test/Ice/optional/Client.py
@@ -20,17 +20,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 866fabc1905..ddb03cd4aa5 100644
--- a/python/test/Ice/optional/ClientPrivate.ice
+++ b/python/test/Ice/optional/ClientPrivate.ice
@@ -29,7 +29,7 @@ class D extends B
// 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
+interface 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
index 6fdb9ad6ab4..46cd0fbebf2 100755
--- a/python/test/Ice/optional/Server.py
+++ b/python/test/Ice/optional/Server.py
@@ -14,7 +14,7 @@ import Ice
Ice.loadSlice('Test.ice')
import Test
-class InitialI(Test.Initial):
+class InitialI(Test._InitialDisp):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
@@ -129,6 +129,9 @@ class InitialI(Test.Initial):
def opStringIntDict(self, p1, current=None):
return (p1, p1)
+ def opIntOneOptionalDict(self, p1, current=None):
+ return (p1, p1)
+
def opClassAndUnknownOptional(self, p, current=None):
pass
@@ -144,6 +147,30 @@ class InitialI(Test.Initial):
def opVoid(self, current=None):
pass
+ def opMStruct1(self, current):
+ return Test.SmallStruct()
+
+ def opMStruct2(self, p1, current):
+ return (p1, p1)
+
+ def opMSeq1(self, current):
+ return []
+
+ def opMSeq2(self, p1, current):
+ return (p1, p1)
+
+ def opMDict1(self, current):
+ return {}
+
+ def opMDict2(self, p1, current):
+ return (p1, p1)
+
+ def opMG1(self, current):
+ return Test.G()
+
+ def opMG2(self, p1, current):
+ return (p1, p1)
+
def supportsRequiredParams(self, current=None):
return False
@@ -156,28 +183,24 @@ class InitialI(Test.Initial):
def supportsCppStringView(self, current=None):
return False
+ def supportsNullOptional(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.add(initial, Ice.stringToIdentity("initial"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index c69ad90f864..c2cbe60ceec 100755
--- a/python/test/Ice/optional/ServerAMD.py
+++ b/python/test/Ice/optional/ServerAMD.py
@@ -14,22 +14,25 @@ import Ice
Ice.loadSlice('TestAMD.ice')
import Test
-class InitialI(Test.Initial):
+class InitialI(Test._InitialDisp):
- def shutdown_async(self, cb, current=None):
+ def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
- cb.ice_response()
- def pingPong_async(self, cb, o, current=None):
- cb.ice_response(o)
+ def pingPong(self, o, current=None):
+ return Ice.Future.completed(o)
- def opOptionalException_async(self, cb, a, b, o, current=None):
- cb.ice_exception(Test.OptionalException(False, a, b, o))
+ def opOptionalException(self, a, b, o, current=None):
+ f = Ice.Future()
+ f.set_exception(Test.OptionalException(False, a, b, o))
+ return f
- def opDerivedException_async(self, cb, a, b, o, current=None):
- cb.ice_exception(Test.DerivedException(False, a, b, o, b, o))
+ def opDerivedException(self, a, b, o, current=None):
+ f = Ice.Future()
+ f.set_exception(Test.DerivedException(False, a, b, o, b, o))
+ return f
- def opRequiredException_async(self, cb, a, b, o, current=None):
+ def opRequiredException(self, a, b, o, current=None):
e = Test.RequiredException()
e.a = a
e.b = b
@@ -38,147 +41,172 @@ class InitialI(Test.Initial):
e.ss = b
if o is not Ice.Unset:
e.o2 = o
- cb.ice_exception(e)
+ f = Ice.Future()
+ f.set_exception(e)
+ return f
- def opByte_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opByte(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opBool_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opBool(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opShort_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opShort(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opInt_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opInt(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opLong_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opLong(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opFloat_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opFloat(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opDouble_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opDouble(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opString_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opString(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opMyEnum_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opMyEnum(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opSmallStruct_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opSmallStruct(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opFixedStruct_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opFixedStruct(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opVarStruct_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opVarStruct(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opOneOptional_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opOneOptional(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opOneOptionalProxy_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opOneOptionalProxy(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opByteSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opByteSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opBoolSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opBoolSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opShortSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opShortSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opIntSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opIntSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opLongSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opLongSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opFloatSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opFloatSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opDoubleSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opDoubleSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opStringSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opStringSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opSmallStructSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opSmallStructSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opSmallStructList_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opSmallStructList(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opFixedStructSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opFixedStructSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opFixedStructList_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opFixedStructList(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opVarStructSeq_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opVarStructSeq(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opSerializable_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opSerializable(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opIntIntDict_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opIntIntDict(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opStringIntDict_async(self, cb, p1, current=None):
- cb.ice_response(p1, p1)
+ def opStringIntDict(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def opClassAndUnknownOptional_async(self, cb, p, current=None):
- cb.ice_response()
+ def opIntOneOptionalDict(self, p1, current=None):
+ return Ice.Future.completed((p1, p1))
- def sendOptionalClass_async(self, cb, req, o, current=None):
- cb.ice_response()
+ def opClassAndUnknownOptional(self, p, current=None):
+ return Ice.Future.completed(None)
- def returnOptionalClass_async(self, cb, req, current=None):
- cb.ice_response(Test.OneOptional(53))
+ def sendOptionalClass(self, req, o, current=None):
+ return Ice.Future.completed(None)
- def opG_async(self, cb, g, current=None):
- cb.ice_response(g)
+ def returnOptionalClass(self, req, current=None):
+ return Ice.Future.completed(Test.OneOptional(53))
- def opVoid_async(self, cb, current=None):
- cb.ice_response()
+ def opG(self, g, current=None):
+ return Ice.Future.completed(g)
- def supportsRequiredParams_async(self, cb, current=None):
- cb.ice_response(False)
+ def opVoid(self, current=None):
+ return Ice.Future.completed(None)
- def supportsJavaSerializable_async(self, cb, current=None):
- cb.ice_response(True)
+ def opMStruct1(self, current):
+ return Ice.Future.completed(Test.SmallStruct())
- def supportsCsharpSerializable_async(self, cb, current=None):
- cb.ice_response(False)
+ def opMStruct2(self, p1, current):
+ return Ice.Future.completed((p1, p1))
- def supportsCppStringView_async(self, cb, current=None):
- cb.ice_response(False)
+ def opMSeq1(self, current):
+ return Ice.Future.completed([])
+
+ def opMSeq2(self, p1, current):
+ return Ice.Future.completed((p1, p1))
+
+ def opMDict1(self, current):
+ return Ice.Future.completed({})
+
+ def opMDict2(self, p1, current):
+ return Ice.Future.completed((p1, p1))
+
+ def opMG1(self, current):
+ return Ice.Future.completed(Test.G())
+
+ def opMG2(self, p1, current):
+ return Ice.Future.completed((p1, p1))
+
+ def supportsRequiredParams(self, current=None):
+ return Ice.Future.completed(False)
+
+ def supportsJavaSerializable(self, current=None):
+ return Ice.Future.completed(True)
+
+ def supportsCsharpSerializable(self, current=None):
+ return Ice.Future.completed(False)
+
+ def supportsCppStringView(self, current=None):
+ return Ice.Future.completed(False)
+
+ def supportsNullOptional(self, current=None):
+ return Ice.Future.completed(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.add(initial, Ice.stringToIdentity("initial"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index b28ba7add93..b95de842d06 100644
--- a/python/test/Ice/optional/Test.ice
+++ b/python/test/Ice/optional/Test.ice
@@ -196,7 +196,7 @@ class Recursive {
optional(0) RecursiveSeq value;
};
-class Initial
+interface Initial
{
void shutdown();
@@ -271,6 +271,9 @@ class Initial
optional(1) StringIntDict opStringIntDict(optional(2) StringIntDict p1, out optional(3) StringIntDict p3);
+ optional(1) IntOneOptionalDict opIntOneOptionalDict(optional(2) IntOneOptionalDict p1,
+ out optional(3) IntOneOptionalDict p3);
+
void opClassAndUnknownOptional(A p);
void sendOptionalClass(bool req, optional(1) OneOptional o);
@@ -281,6 +284,21 @@ class Initial
void opVoid();
+ ["marshaled-result"] optional(1) SmallStruct opMStruct1();
+ ["marshaled-result"] optional(1) SmallStruct opMStruct2(optional(2) SmallStruct p1,
+ out optional(3)SmallStruct p2);
+
+ ["marshaled-result"] optional(1) StringSeq opMSeq1();
+ ["marshaled-result"] optional(1) StringSeq opMSeq2(optional(2) StringSeq p1,
+ out optional(3) StringSeq p2);
+
+ ["marshaled-result"] optional(1) StringIntDict opMDict1();
+ ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1,
+ out optional(3) StringIntDict p2);
+
+ ["marshaled-result"] optional(1) G opMG1();
+ ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2);
+
bool supportsRequiredParams();
bool supportsJavaSerializable();
@@ -288,6 +306,8 @@ class Initial
bool supportsCsharpSerializable();
bool supportsCppStringView();
+
+ bool supportsNullOptional();
};
};
diff --git a/python/test/Ice/optional/TestAMD.ice b/python/test/Ice/optional/TestAMD.ice
index d44c0ca159d..1562414e1c2 100644
--- a/python/test/Ice/optional/TestAMD.ice
+++ b/python/test/Ice/optional/TestAMD.ice
@@ -192,12 +192,13 @@ class G
class Recursive;
sequence<Recursive> RecursiveSeq;
-class Recursive {
+class Recursive
+{
optional(0) RecursiveSeq value;
};
["amd"]
-class Initial
+interface Initial
{
void shutdown();
@@ -272,6 +273,9 @@ class Initial
optional(1) StringIntDict opStringIntDict(optional(2) StringIntDict p1, out optional(3) StringIntDict p3);
+ optional(1) IntOneOptionalDict opIntOneOptionalDict(optional(2) IntOneOptionalDict p1,
+ out optional(3) IntOneOptionalDict p3);
+
void opClassAndUnknownOptional(A p);
void sendOptionalClass(bool req, optional(1) OneOptional o);
@@ -282,6 +286,21 @@ class Initial
void opVoid();
+ ["marshaled-result"] optional(1) SmallStruct opMStruct1();
+ ["marshaled-result"] optional(1) SmallStruct opMStruct2(optional(2) SmallStruct p1,
+ out optional(3)SmallStruct p2);
+
+ ["marshaled-result"] optional(1) StringSeq opMSeq1();
+ ["marshaled-result"] optional(1) StringSeq opMSeq2(optional(2) StringSeq p1,
+ out optional(3) StringSeq p2);
+
+ ["marshaled-result"] optional(1) StringIntDict opMDict1();
+ ["marshaled-result"] optional(1) StringIntDict opMDict2(optional(2) StringIntDict p1,
+ out optional(3) StringIntDict p2);
+
+ ["marshaled-result"] optional(1) G opMG1();
+ ["marshaled-result"] optional(1) G opMG2(optional(2) G p1, out optional(3) G p2);
+
bool supportsRequiredParams();
bool supportsJavaSerializable();
@@ -289,6 +308,8 @@ class Initial
bool supportsCsharpSerializable();
bool supportsCppStringView();
+
+ bool supportsNullOptional();
};
};
diff --git a/python/test/Ice/optional/run.py b/python/test/Ice/optional/run.py
deleted file mode 100755
index 1f5ee28b14f..00000000000
--- a/python/test/Ice/optional/run.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/run.py b/python/test/Ice/properties/run.py
deleted file mode 100755
index 7e3f28eddab..00000000000
--- a/python/test/Ice/properties/run.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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"
- decodedPath = configPath.decode("utf-8")
-else:
- configPath = "./config/\u4e2d\u56fd_client.config"
- decodedPath = configPath # No need to decode with Python3, strings are already Unicode
-
-TestUtil.createFile(decodedPath,
- ["# 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(decodedPath):
- os.remove(decodedPath)
diff --git a/python/test/Ice/proxy/AllTests.py b/python/test/Ice/proxy/AllTests.py
index 5ab14dd3d73..8c34f28cc29 100644
--- a/python/test/Ice/proxy/AllTests.py
+++ b/python/test/Ice/proxy/AllTests.py
@@ -358,10 +358,36 @@ def allTests(communicator, collocated):
sys.stdout.write("testing proxy methods... ")
sys.stdout.flush()
+
+
test(communicator.identityToString(base.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()) \
== "other")
- test(Ice.identityToString(base.ice_identity(Ice.stringToIdentity("other")).ice_getIdentity()) == "other")
-
+
+ #
+ # Verify that ToStringMode is passed correctly
+ #
+ euroStr = "\xE2\x82\xAC" if sys.version_info[0] < 3 else "\u20ac"
+ ident = Ice.Identity("test", "\x7F{}".format(euroStr))
+
+ idStr = Ice.identityToString(ident, Ice.ToStringMode.Unicode)
+ test(idStr == "\\u007f{}/test".format(euroStr))
+ ident2 = Ice.stringToIdentity(idStr)
+ test(ident == ident2)
+ test(Ice.identityToString(ident) == idStr)
+
+ idStr = Ice.identityToString(ident, Ice.ToStringMode.ASCII)
+ test(idStr == "\\u007f\\u20ac/test")
+ ident2 = Ice.stringToIdentity(idStr)
+ test(ident == ident2)
+
+ idStr = Ice.identityToString(ident, Ice.ToStringMode.Compat)
+ test(idStr == "\\177\\342\\202\\254/test")
+ ident2 = Ice.stringToIdentity(idStr)
+ test(ident == ident2)
+
+ ident2 = Ice.stringToIdentity(communicator.identityToString(ident))
+ test(ident == ident2)
+
test(base.ice_facet("facet").ice_getFacet() == "facet")
test(base.ice_adapterId("id").ice_getAdapterId() == "id")
test(base.ice_twoway().ice_isTwoway())
diff --git a/python/test/Ice/proxy/Client.py b/python/test/Ice/proxy/Client.py
index 5139f0e248a..5d83b846460 100755
--- a/python/test/Ice/proxy/Client.py
+++ b/python/test/Ice/proxy/Client.py
@@ -32,17 +32,10 @@ def run(args, communicator):
try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 4f4adcc66ed..2d12b55c431 100755
--- a/python/test/Ice/proxy/Collocated.py
+++ b/python/test/Ice/proxy/Collocated.py
@@ -22,7 +22,7 @@ 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.add(TestI.MyDerivedClassI(), Ice.stringToIdentity("test"))
#adapter.activate() // Don't activate OA to ensure collocation is used.
AllTests.allTests(communicator, True)
@@ -32,17 +32,10 @@ def run(args, communicator):
try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index 66e359e170f..2c6d3ee8c2f 100755
--- a/python/test/Ice/proxy/Server.py
+++ b/python/test/Ice/proxy/Server.py
@@ -23,7 +23,7 @@ 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.add(TestI.MyDerivedClassI(), Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
@@ -32,17 +32,10 @@ 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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index c767ac44efb..6a310161383 100755
--- a/python/test/Ice/proxy/ServerAMD.py
+++ b/python/test/Ice/proxy/ServerAMD.py
@@ -19,28 +19,27 @@ if not slice_dir:
Ice.loadSlice("'-I" + slice_dir + "' TestAMD.ice")
import Test
-class MyDerivedClassI(Test.MyDerivedClass):
+class MyDerivedClassI(Test._MyDerivedClassDisp):
def __init__(self):
self.ctx = None
- def shutdown_async(self, cb, current=None):
+ def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
- cb.ice_response()
- def getContext_async(self, cb, current):
- return cb.ice_response(self.ctx)
+ def getContext(self, current):
+ return Ice.Future.completed(self.ctx)
- def echo_async(self, cb, obj, current):
- return cb.ice_response(obj)
+ def echo(self, obj, current):
+ return Ice.Future.completed(obj)
def ice_isA(self, s, current):
self.ctx = current.ctx
- return Test.MyDerivedClass.ice_isA(self, s, current)
+ return Test._MyDerivedClassDisp.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.add(MyDerivedClassI(), Ice.stringToIdentity("test"))
adapter.activate()
communicator.waitForShutdown()
return True
@@ -50,17 +49,10 @@ try:
initData.properties = Ice.createProperties(sys.argv)
initData.properties.setProperty("Ice.Warn.Connections", "0")
initData.properties.setProperty("Ice.Warn.Dispatch", "0")
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index b96eced15dc..f98d7dbcb3d 100644
--- a/python/test/Ice/proxy/Test.ice
+++ b/python/test/Ice/proxy/Test.ice
@@ -14,14 +14,14 @@
module Test
{
-class MyClass
+interface MyClass
{
void shutdown();
Ice::Context getContext();
};
-class MyDerivedClass extends MyClass
+interface MyDerivedClass extends MyClass
{
Object* echo(Object* obj);
};
diff --git a/python/test/Ice/proxy/TestAMD.ice b/python/test/Ice/proxy/TestAMD.ice
index beeb7692447..d0312f701b1 100644
--- a/python/test/Ice/proxy/TestAMD.ice
+++ b/python/test/Ice/proxy/TestAMD.ice
@@ -14,14 +14,14 @@
module Test
{
-["amd"] class MyClass
+["amd"] interface MyClass
{
void shutdown();
Ice::Context getContext();
};
-["amd"] class MyDerivedClass extends MyClass
+["amd"] interface MyDerivedClass extends MyClass
{
Object* echo(Object* obj);
};
diff --git a/python/test/Ice/proxy/TestI.py b/python/test/Ice/proxy/TestI.py
index 5ee763ab1ee..3c6be1cba94 100644
--- a/python/test/Ice/proxy/TestI.py
+++ b/python/test/Ice/proxy/TestI.py
@@ -10,7 +10,7 @@
import Ice, Test
import time
-class MyDerivedClassI(Test.MyDerivedClass):
+class MyDerivedClassI(Test._MyDerivedClassDisp):
def __init__(self):
self.ctx = None
@@ -25,4 +25,4 @@ class MyDerivedClassI(Test.MyDerivedClass):
def ice_isA(self, s, current):
self.ctx = current.ctx
- return Test.MyDerivedClass.ice_isA(self, s, current)
+ return Test._MyDerivedClassDisp.ice_isA(self, s, current)
diff --git a/python/test/Ice/proxy/run.py b/python/test/Ice/proxy/run.py
deleted file mode 100755
index 63b57c4f797..00000000000
--- a/python/test/Ice/proxy/run.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 2c8bcc159a3..55d77d5f43f 100644
--- a/python/test/Ice/servantLocator/AllTests.py
+++ b/python/test/Ice/servantLocator/AllTests.py
@@ -52,7 +52,7 @@ def testExceptions(obj, collocated):
obj.userException()
test(False)
except Ice.UnknownUserException as ex:
- test(ex.unknown.find("Test::TestIntfUserException") >= 0)
+ test(ex.unknown.find("::Test::TestIntfUserException") >= 0)
except Ice.OperationNotExistException:
pass
except AttributeError:
@@ -148,7 +148,7 @@ def allTests(communicator, collocated):
obj.ice_ids()
test(False)
except Ice.UnknownUserException as ex:
- test(ex.unknown == "Test::TestIntfUserException")
+ test(ex.unknown == "::Test::TestIntfUserException")
except:
test(False)
@@ -157,7 +157,7 @@ def allTests(communicator, collocated):
obj.ice_ids()
test(False)
except Ice.UnknownUserException as ex:
- test(ex.unknown == "Test::TestIntfUserException")
+ test(ex.unknown == "::Test::TestIntfUserException")
except:
test(False)
print("ok")
diff --git a/python/test/Ice/servantLocator/Collocated.py b/python/test/Ice/servantLocator/Collocated.py
index 0f90ca48ef4..41d0c8e9148 100755
--- a/python/test/Ice/servantLocator/Collocated.py
+++ b/python/test/Ice/servantLocator/Collocated.py
@@ -23,8 +23,8 @@ class TestServer(Ice.Application):
#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"))
+ adapter.add(TestI.TestI(), Ice.stringToIdentity("asm"))
+ adapter.add(TestActivationI.TestActivationI(), Ice.stringToIdentity("test/activation"))
AllTests.allTests(self.communicator(), False)
diff --git a/python/test/Ice/servantLocator/Server.py b/python/test/Ice/servantLocator/Server.py
index bada31bcabe..12f7d67d846 100755
--- a/python/test/Ice/servantLocator/Server.py
+++ b/python/test/Ice/servantLocator/Server.py
@@ -22,8 +22,8 @@ class TestServer(Ice.Application):
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.add(TestI.TestI(), Ice.stringToIdentity("asm"))
+ adapter.add(TestActivationI.TestActivationI(), Ice.stringToIdentity("test/activation"))
adapter.activate()
adapter.waitForDeactivate()
diff --git a/python/test/Ice/servantLocator/ServerAMD.py b/python/test/Ice/servantLocator/ServerAMD.py
index f36103f1f64..b29f6f5aa7d 100755
--- a/python/test/Ice/servantLocator/ServerAMD.py
+++ b/python/test/Ice/servantLocator/ServerAMD.py
@@ -22,8 +22,8 @@ class TestServer(Ice.Application):
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.add(TestAMDI.TestI(), Ice.stringToIdentity("asm"))
+ adapter.add(TestActivationAMDI.TestActivationAMDI(), Ice.stringToIdentity("test/activation"))
adapter.activate()
adapter.waitForDeactivate()
diff --git a/python/test/Ice/servantLocator/TestAMDI.py b/python/test/Ice/servantLocator/TestAMDI.py
index 83394875075..2b53c01863f 100644
--- a/python/test/Ice/servantLocator/TestAMDI.py
+++ b/python/test/Ice/servantLocator/TestAMDI.py
@@ -14,63 +14,76 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class TestI(Test.TestIntf):
+class TestI(Test._TestIntfDisp):
- def requestFailedException_async(self, cb, current=None):
- cb.ice_response()
+ def requestFailedException(self, current=None):
+ return None
- def unknownUserException_async(self, cb, current=None):
- cb.ice_response()
+ def unknownUserException(self, current=None):
+ return None
- def unknownLocalException_async(self, cb, current=None):
- cb.ice_response()
+ def unknownLocalException(self, current=None):
+ return None
- def unknownException_async(self, cb, current=None):
- cb.ice_response()
+ def unknownException(self, current=None):
+ return None
- def localException_async(self, cb, current=None):
- cb.ice_response()
+ def localException(self, current=None):
+ return None
- def userException_async(self, cb, current=None):
- cb.ice_response()
+ def userException(self, current=None):
+ return None
- def pythonException_async(self, cb, current=None):
- cb.ice_response()
+ def pythonException(self, current=None):
+ return None
- def unknownExceptionWithServantException_async(self, cb, current=None):
- cb.ice_exception(Ice.ObjectNotExistException())
+ def unknownExceptionWithServantException(self, current=None):
+ f = Ice.Future()
+ f.set_exception(Ice.ObjectNotExistException())
+ return f
- def impossibleException_async(self, cb, throw, current=None):
+ def impossibleException(self, throw, current=None):
+ f = Ice.Future()
if throw:
- cb.ice_exception(Test.TestImpossibleException())
+ f.set_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")
+ f.set_result("Hello")
+ return f
- def intfUserException_async(self, cb, throw, current=None):
+ def intfUserException(self, throw, current=None):
+ f = Ice.Future()
if throw:
- cb.ice_exception(Test.TestIntfUserException())
+ f.set_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")
+ f.set_result("Hello")
+ return f
- def asyncResponse_async(self, cb, current=None):
- cb.ice_response()
+ def asyncResponse(self, current=None):
+ #
+ # We can't do this with futures.
+ #
+ #return Ice.Future.completed(None)
raise Ice.ObjectNotExistException()
- def asyncException_async(self, cb, current=None):
- cb.ice_exception(Test.TestIntfUserException())
+ def asyncException(self, current=None):
+ #
+ # We can't do this with futures.
+ #
+ #f = Ice.Future()
+ #f.set_exception(Test.TestIntfUserException())
+ #return f
raise Ice.ObjectNotExistException()
- def shutdown_async(self, cb, current=None):
+ def shutdown(self, current=None):
current.adapter.deactivate()
- cb.ice_response()
class CookieI(Test.Cookie):
def message(self):
diff --git a/python/test/Ice/servantLocator/TestActivationAMDI.py b/python/test/Ice/servantLocator/TestActivationAMDI.py
index f5ac04384a6..af47ff448b5 100644
--- a/python/test/Ice/servantLocator/TestActivationAMDI.py
+++ b/python/test/Ice/servantLocator/TestActivationAMDI.py
@@ -11,7 +11,7 @@ import os, sys, traceback, time
import Ice, Test, TestAMDI
-class TestActivationAMDI(Test.TestActivation):
+class TestActivationAMDI(Test._TestActivationDisp):
def activateServantLocator(self, activate, current=None):
if(activate):
diff --git a/python/test/Ice/servantLocator/TestActivationI.py b/python/test/Ice/servantLocator/TestActivationI.py
index 4e795914b79..fc01f072f34 100644
--- a/python/test/Ice/servantLocator/TestActivationI.py
+++ b/python/test/Ice/servantLocator/TestActivationI.py
@@ -11,7 +11,7 @@ import os, sys, traceback, time
import Ice, Test, TestI
-class TestActivationI(Test.TestActivation):
+class TestActivationI(Test._TestActivationDisp):
def activateServantLocator(self, activate, current=None):
if activate:
diff --git a/python/test/Ice/servantLocator/TestI.py b/python/test/Ice/servantLocator/TestI.py
index 6063eb7e288..4b9eb26c0cf 100644
--- a/python/test/Ice/servantLocator/TestI.py
+++ b/python/test/Ice/servantLocator/TestI.py
@@ -14,7 +14,7 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class TestI(Test.TestIntf):
+class TestI(Test._TestIntfDisp):
def requestFailedException(self, current=None):
pass
diff --git a/python/test/Ice/servantLocator/run.py b/python/test/Ice/servantLocator/run.py
deleted file mode 100755
index 63b57c4f797..00000000000
--- a/python/test/Ice/servantLocator/run.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index fbf0828b008..6a8dc126729 100644
--- a/python/test/Ice/slicing/exceptions/AllTests.py
+++ b/python/test/Ice/slicing/exceptions/AllTests.py
@@ -23,167 +23,173 @@ class CallbackBase:
self._cond = threading.Condition()
def check(self):
- self._cond.acquire()
- try:
+ with self._cond:
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()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
class Callback(CallbackBase):
- def response(self):
- test(False)
-
- def exception_baseAsBase(self, exc):
+ def exception_baseAsBase(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.Base as b:
test(b.b == "Base.b")
- test(b.ice_name() =="Test::Base")
+ test(b.ice_id() == "::Test::Base")
except:
test(False)
self.called()
- def exception_unknownDerivedAsBase(self, exc):
+ def exception_unknownDerivedAsBase(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.Base as b:
test(b.b == "UnknownDerived.b")
- test(b.ice_name() =="Test::Base")
+ test(b.ice_id() == "::Test::Base")
except:
test(False)
self.called()
- def exception_knownDerivedAsBase(self, exc):
+ def exception_knownDerivedAsBase(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.KnownDerived as k:
test(k.b == "KnownDerived.b")
test(k.kd == "KnownDerived.kd")
- test(k.ice_name() =="Test::KnownDerived")
+ test(k.ice_id() == "::Test::KnownDerived")
except:
test(False)
self.called()
- def exception_knownDerivedAsKnownDerived(self, exc):
+ def exception_knownDerivedAsKnownDerived(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.KnownDerived as k:
test(k.b == "KnownDerived.b")
test(k.kd == "KnownDerived.kd")
- test(k.ice_name() =="Test::KnownDerived")
+ test(k.ice_id() == "::Test::KnownDerived")
except:
test(False)
self.called()
- def exception_unknownIntermediateAsBase(self, exc):
+ def exception_unknownIntermediateAsBase(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.Base as b:
test(b.b == "UnknownIntermediate.b")
- test(b.ice_name() =="Test::Base")
+ test(b.ice_id() == "::Test::Base")
except:
test(False)
self.called()
- def exception_knownIntermediateAsBase(self, exc):
+ def exception_knownIntermediateAsBase(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.KnownIntermediate as ki:
test(ki.b == "KnownIntermediate.b")
test(ki.ki == "KnownIntermediate.ki")
- test(ki.ice_name() =="Test::KnownIntermediate")
+ test(ki.ice_id() == "::Test::KnownIntermediate")
except:
test(False)
self.called()
- def exception_knownMostDerivedAsBase(self, exc):
+ def exception_knownMostDerivedAsBase(self, f):
try:
- raise exc
+ f.result()
+ 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")
+ test(kmd.ice_id() == "::Test::KnownMostDerived")
except:
test(False)
self.called()
- def exception_knownIntermediateAsKnownIntermediate(self, exc):
+ def exception_knownIntermediateAsKnownIntermediate(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.KnownIntermediate as ki:
test(ki.b == "KnownIntermediate.b")
test(ki.ki == "KnownIntermediate.ki")
- test(ki.ice_name() =="Test::KnownIntermediate")
+ test(ki.ice_id() == "::Test::KnownIntermediate")
except:
test(False)
self.called()
- def exception_knownMostDerivedAsKnownMostDerived(self, exc):
+ def exception_knownMostDerivedAsKnownMostDerived(self, f):
try:
- raise exc
+ f.result()
+ 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")
+ test(kmd.ice_id() == "::Test::KnownMostDerived")
except:
test(False)
self.called()
- def exception_knownMostDerivedAsKnownIntermediate(self, exc):
+ def exception_knownMostDerivedAsKnownIntermediate(self, f):
try:
- raise exc
+ f.result()
+ 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")
+ test(kmd.ice_id() == "::Test::KnownMostDerived")
except:
test(False)
self.called()
- def exception_unknownMostDerived1AsBase(self, exc):
+ def exception_unknownMostDerived1AsBase(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.KnownIntermediate as ki:
test(ki.b == "UnknownMostDerived1.b")
test(ki.ki == "UnknownMostDerived1.ki")
- test(ki.ice_name() =="Test::KnownIntermediate")
+ test(ki.ice_id() == "::Test::KnownIntermediate")
except:
test(False)
self.called()
- def exception_unknownMostDerived1AsKnownIntermediate(self, exc):
+ def exception_unknownMostDerived1AsKnownIntermediate(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.KnownIntermediate as ki:
test(ki.b == "UnknownMostDerived1.b")
test(ki.ki == "UnknownMostDerived1.ki")
- test(ki.ice_name() =="Test::KnownIntermediate")
+ test(ki.ice_id() == "::Test::KnownIntermediate")
except:
test(False)
self.called()
- def exception_unknownMostDerived2AsBase(self, exc):
+ def exception_unknownMostDerived2AsBase(self, f):
try:
- raise exc
+ f.result()
+ test(False)
except Test.Base as b:
test(b.b == "UnknownMostDerived2.b")
- test(b.ice_name() =="Test::Base")
+ test(b.ice_id() == "::Test::Base")
except:
test(False)
self.called()
-class RelayI(Test.Relay):
+class RelayI(Test._RelayDisp):
def knownPreservedAsBase(self, current=None):
ex = Test.KnownPreservedDerived()
ex.b = "base"
@@ -227,7 +233,7 @@ def allTests(communicator):
test(false)
except Test.Base as b:
test(b.b == "Base.b")
- test(b.ice_name() == "Test::Base")
+ test(b.ice_id() == "::Test::Base")
except:
test(False)
print("ok")
@@ -235,7 +241,7 @@ def allTests(communicator):
sys.stdout.write("base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_baseAsBase(cb.response, cb.exception_baseAsBase)
+ t.baseAsBaseAsync().add_done_callback(cb.exception_baseAsBase)
cb.check()
print("ok")
@@ -246,7 +252,7 @@ def allTests(communicator):
test(false)
except Test.Base as b:
test(b.b == "UnknownDerived.b")
- test(b.ice_name() == "Test::Base")
+ test(b.ice_id() == "::Test::Base")
except:
test(False)
print("ok")
@@ -254,7 +260,7 @@ def allTests(communicator):
sys.stdout.write("slicing of unknown derived (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_unknownDerivedAsBase(cb.response, cb.exception_unknownDerivedAsBase)
+ t.unknownDerivedAsBaseAsync().add_done_callback(cb.exception_unknownDerivedAsBase)
cb.check()
print("ok")
@@ -266,7 +272,7 @@ def allTests(communicator):
except Test.KnownDerived as k:
test(k.b == "KnownDerived.b")
test(k.kd == "KnownDerived.kd")
- test(k.ice_name() == "Test::KnownDerived")
+ test(k.ice_id() == "::Test::KnownDerived")
except:
test(False)
print("ok")
@@ -274,7 +280,7 @@ def allTests(communicator):
sys.stdout.write("non-slicing of known derived as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_knownDerivedAsBase(cb.response, cb.exception_knownDerivedAsBase)
+ t.knownDerivedAsBaseAsync().add_done_callback(cb.exception_knownDerivedAsBase)
cb.check()
print("ok")
@@ -286,7 +292,7 @@ def allTests(communicator):
except Test.KnownDerived as k:
test(k.b == "KnownDerived.b")
test(k.kd == "KnownDerived.kd")
- test(k.ice_name() == "Test::KnownDerived")
+ test(k.ice_id() == "::Test::KnownDerived")
except:
test(False)
print("ok")
@@ -294,7 +300,7 @@ def allTests(communicator):
sys.stdout.write("non-slicing of known derived as derived (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_knownDerivedAsKnownDerived(cb.response, cb.exception_knownDerivedAsKnownDerived)
+ t.knownDerivedAsKnownDerivedAsync().add_done_callback(cb.exception_knownDerivedAsKnownDerived)
cb.check()
print("ok")
@@ -305,7 +311,7 @@ def allTests(communicator):
test(false)
except Test.Base as b:
test(b.b == "UnknownIntermediate.b")
- test(b.ice_name() == "Test::Base")
+ test(b.ice_id() == "::Test::Base")
except:
test(False)
print("ok")
@@ -313,7 +319,7 @@ def allTests(communicator):
sys.stdout.write("slicing of unknown intermediate as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_unknownIntermediateAsBase(cb.response, cb.exception_unknownIntermediateAsBase)
+ t.unknownIntermediateAsBaseAsync().add_done_callback(cb.exception_unknownIntermediateAsBase)
cb.check()
print("ok")
@@ -325,7 +331,7 @@ def allTests(communicator):
except Test.KnownIntermediate as ki:
test(ki.b == "KnownIntermediate.b")
test(ki.ki == "KnownIntermediate.ki")
- test(ki.ice_name() == "Test::KnownIntermediate")
+ test(ki.ice_id() == "::Test::KnownIntermediate")
except:
test(False)
print("ok")
@@ -333,7 +339,7 @@ def allTests(communicator):
sys.stdout.write("slicing of known intermediate as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_knownIntermediateAsBase(cb.response, cb.exception_knownIntermediateAsBase)
+ t.knownIntermediateAsBaseAsync().add_done_callback(cb.exception_knownIntermediateAsBase)
cb.check()
print("ok")
@@ -346,7 +352,7 @@ def allTests(communicator):
test(kmd.b == "KnownMostDerived.b")
test(kmd.ki == "KnownMostDerived.ki")
test(kmd.kmd == "KnownMostDerived.kmd")
- test(kmd.ice_name() == "Test::KnownMostDerived")
+ test(kmd.ice_id() == "::Test::KnownMostDerived")
except:
test(False)
print("ok")
@@ -354,7 +360,7 @@ def allTests(communicator):
sys.stdout.write("slicing of known most derived as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_knownMostDerivedAsBase(cb.response, cb.exception_knownMostDerivedAsBase)
+ t.knownMostDerivedAsBaseAsync().add_done_callback(cb.exception_knownMostDerivedAsBase)
cb.check()
print("ok")
@@ -366,7 +372,7 @@ def allTests(communicator):
except Test.KnownIntermediate as ki:
test(ki.b == "KnownIntermediate.b")
test(ki.ki == "KnownIntermediate.ki")
- test(ki.ice_name() == "Test::KnownIntermediate")
+ test(ki.ice_id() == "::Test::KnownIntermediate")
except:
test(False)
print("ok")
@@ -374,7 +380,7 @@ def allTests(communicator):
sys.stdout.write("non-slicing of known intermediate as intermediate (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_knownIntermediateAsKnownIntermediate(cb.response, cb.exception_knownIntermediateAsKnownIntermediate)
+ t.knownIntermediateAsKnownIntermediateAsync().add_done_callback(cb.exception_knownIntermediateAsKnownIntermediate)
cb.check()
print("ok")
@@ -387,7 +393,7 @@ def allTests(communicator):
test(kmd.b == "KnownMostDerived.b")
test(kmd.ki == "KnownMostDerived.ki")
test(kmd.kmd == "KnownMostDerived.kmd")
- test(kmd.ice_name() == "Test::KnownMostDerived")
+ test(kmd.ice_id() == "::Test::KnownMostDerived")
except:
test(False)
print("ok")
@@ -395,7 +401,7 @@ def allTests(communicator):
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)
+ t.knownMostDerivedAsKnownIntermediateAsync().add_done_callback(cb.exception_knownMostDerivedAsKnownIntermediate)
cb.check()
print("ok")
@@ -408,7 +414,7 @@ def allTests(communicator):
test(kmd.b == "KnownMostDerived.b")
test(kmd.ki == "KnownMostDerived.ki")
test(kmd.kmd == "KnownMostDerived.kmd")
- test(kmd.ice_name() == "Test::KnownMostDerived")
+ test(kmd.ice_id() == "::Test::KnownMostDerived")
except:
test(False)
print("ok")
@@ -416,7 +422,7 @@ def allTests(communicator):
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)
+ t.knownMostDerivedAsKnownMostDerivedAsync().add_done_callback(cb.exception_knownMostDerivedAsKnownMostDerived)
cb.check()
print("ok")
@@ -428,7 +434,7 @@ def allTests(communicator):
except Test.KnownIntermediate as ki:
test(ki.b == "UnknownMostDerived1.b")
test(ki.ki == "UnknownMostDerived1.ki")
- test(ki.ice_name() == "Test::KnownIntermediate")
+ test(ki.ice_id() == "::Test::KnownIntermediate")
except:
test(False)
print("ok")
@@ -436,7 +442,7 @@ def allTests(communicator):
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)
+ t.unknownMostDerived1AsBaseAsync().add_done_callback(cb.exception_unknownMostDerived1AsBase)
cb.check()
print("ok")
@@ -448,7 +454,7 @@ def allTests(communicator):
except Test.KnownIntermediate as ki:
test(ki.b == "UnknownMostDerived1.b")
test(ki.ki == "UnknownMostDerived1.ki")
- test(ki.ice_name() == "Test::KnownIntermediate")
+ test(ki.ice_id() == "::Test::KnownIntermediate")
except:
test(False)
print("ok")
@@ -456,7 +462,8 @@ def allTests(communicator):
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)
+ t.unknownMostDerived1AsKnownIntermediateAsync().add_done_callback(
+ cb.exception_unknownMostDerived1AsKnownIntermediate)
cb.check()
print("ok")
@@ -467,7 +474,7 @@ def allTests(communicator):
test(false)
except Test.Base as b:
test(b.b == "UnknownMostDerived2.b")
- test(b.ice_name() == "Test::Base")
+ test(b.ice_id() == "::Test::Base")
except:
test(False)
print("ok")
@@ -475,7 +482,7 @@ def allTests(communicator):
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)
+ t.unknownMostDerived2AsBaseAsync().add_done_callback(cb.exception_unknownMostDerived2AsBase)
cb.check()
print("ok")
diff --git a/python/test/Ice/slicing/exceptions/Client.py b/python/test/Ice/slicing/exceptions/Client.py
index 370ed6305b8..830d6f18148 100755
--- a/python/test/Ice/slicing/exceptions/Client.py
+++ b/python/test/Ice/slicing/exceptions/Client.py
@@ -18,17 +18,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/Server.py b/python/test/Ice/slicing/exceptions/Server.py
index 383a8c6dea8..223cdb31ebd 100755
--- a/python/test/Ice/slicing/exceptions/Server.py
+++ b/python/test/Ice/slicing/exceptions/Server.py
@@ -13,7 +13,7 @@ import Ice
Ice.loadSlice('-I. --all ServerPrivate.ice')
import Test
-class TestI(Test.TestIntf):
+class TestI(Test._TestIntfDisp):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
@@ -157,23 +157,16 @@ def run(args, communicator):
properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000")
adapter = communicator.createObjectAdapter("TestAdapter")
object = TestI()
- adapter.add(object, communicator.stringToIdentity("Test"))
+ adapter.add(object, Ice.stringToIdentity("Test"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 9df80030c3f..d398e502e77 100755
--- a/python/test/Ice/slicing/exceptions/ServerAMD.py
+++ b/python/test/Ice/slicing/exceptions/ServerAMD.py
@@ -14,160 +14,203 @@ import Ice
Ice.loadSlice('-I. --all ServerPrivateAMD.ice')
import Test
-class TestI(Test.TestIntf):
- def shutdown_async(self, cb, current=None):
+class TestI(Test._TestIntfDisp):
+ def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
- cb.ice_response()
- def baseAsBase_async(self, cb, current=None):
+ def baseAsBase(self, current=None):
b = Test.Base()
b.b = "Base.b"
- cb.ice_exception(b)
+ f = Ice.Future()
+ f.set_exception(b)
+ return f
- def unknownDerivedAsBase_async(self, cb, current=None):
+ def unknownDerivedAsBase(self, current=None):
d = Test.UnknownDerived()
d.b = "UnknownDerived.b"
d.ud = "UnknownDerived.ud"
- cb.ice_exception(d)
+ f = Ice.Future()
+ f.set_exception(d)
+ return f
- def knownDerivedAsBase_async(self, cb, current=None):
+ def knownDerivedAsBase(self, current=None):
d = Test.KnownDerived()
d.b = "KnownDerived.b"
d.kd = "KnownDerived.kd"
- cb.ice_exception(d)
+ f = Ice.Future()
+ f.set_exception(d)
+ return f
- def knownDerivedAsKnownDerived_async(self, cb, current=None):
+ def knownDerivedAsKnownDerived(self, current=None):
d = Test.KnownDerived()
d.b = "KnownDerived.b"
d.kd = "KnownDerived.kd"
- cb.ice_exception(d)
+ f = Ice.Future()
+ f.set_exception(d)
+ return f
- def unknownIntermediateAsBase_async(self, cb, current=None):
+ def unknownIntermediateAsBase(self, current=None):
ui = Test.UnknownIntermediate()
ui.b = "UnknownIntermediate.b"
ui.ui = "UnknownIntermediate.ui"
- cb.ice_exception(ui)
+ f = Ice.Future()
+ f.set_exception(ui)
+ return f
- def knownIntermediateAsBase_async(self, cb, current=None):
+ def knownIntermediateAsBase(self, current=None):
ki = Test.KnownIntermediate()
ki.b = "KnownIntermediate.b"
ki.ki = "KnownIntermediate.ki"
- cb.ice_exception(ki)
+ f = Ice.Future()
+ f.set_exception(ki)
+ return f
- def knownMostDerivedAsBase_async(self, cb, current=None):
+ def knownMostDerivedAsBase(self, current=None):
kmd = Test.KnownMostDerived()
kmd.b = "KnownMostDerived.b"
kmd.ki = "KnownMostDerived.ki"
kmd.kmd = "KnownMostDerived.kmd"
- cb.ice_exception(kmd)
+ f = Ice.Future()
+ f.set_exception(kmd)
+ return f
- def knownIntermediateAsKnownIntermediate_async(self, cb, current=None):
+ def knownIntermediateAsKnownIntermediate(self, current=None):
ki = Test.KnownIntermediate()
ki.b = "KnownIntermediate.b"
ki.ki = "KnownIntermediate.ki"
- cb.ice_exception(ki)
+ f = Ice.Future()
+ f.set_exception(ki)
+ return f
- def knownMostDerivedAsKnownIntermediate_async(self, cb, current=None):
+ def knownMostDerivedAsKnownIntermediate(self, current=None):
kmd = Test.KnownMostDerived()
kmd.b = "KnownMostDerived.b"
kmd.ki = "KnownMostDerived.ki"
kmd.kmd = "KnownMostDerived.kmd"
- cb.ice_exception(kmd)
+ f = Ice.Future()
+ f.set_exception(kmd)
+ return f
- def knownMostDerivedAsKnownMostDerived_async(self, cb, current=None):
+ def knownMostDerivedAsKnownMostDerived(self, current=None):
kmd = Test.KnownMostDerived()
kmd.b = "KnownMostDerived.b"
kmd.ki = "KnownMostDerived.ki"
kmd.kmd = "KnownMostDerived.kmd"
- cb.ice_exception(kmd)
+ f = Ice.Future()
+ f.set_exception(kmd)
+ return f
- def unknownMostDerived1AsBase_async(self, cb, current=None):
+ def unknownMostDerived1AsBase(self, current=None):
umd1 = Test.UnknownMostDerived1()
umd1.b = "UnknownMostDerived1.b"
umd1.ki = "UnknownMostDerived1.ki"
umd1.umd1 = "UnknownMostDerived1.umd1"
- cb.ice_exception(umd1)
+ f = Ice.Future()
+ f.set_exception(umd1)
+ return f
- def unknownMostDerived1AsKnownIntermediate_async(self, cb, current=None):
+ def unknownMostDerived1AsKnownIntermediate(self, current=None):
umd1 = Test.UnknownMostDerived1()
umd1.b = "UnknownMostDerived1.b"
umd1.ki = "UnknownMostDerived1.ki"
umd1.umd1 = "UnknownMostDerived1.umd1"
- cb.ice_exception(umd1)
+ f = Ice.Future()
+ f.set_exception(umd1)
+ return f
- def unknownMostDerived2AsBase_async(self, cb, current=None):
+ def unknownMostDerived2AsBase(self, current=None):
umd2 = Test.UnknownMostDerived2()
umd2.b = "UnknownMostDerived2.b"
umd2.ui = "UnknownMostDerived2.ui"
umd2.umd2 = "UnknownMostDerived2.umd2"
- cb.ice_exception(umd2)
+ f = Ice.Future()
+ f.set_exception(umd2)
+ return f
- def unknownMostDerived2AsBaseCompact_async(self, cb, current=None):
+ def unknownMostDerived2AsBaseCompact(self, current=None):
umd2 = Test.UnknownMostDerived2()
umd2.b = "UnknownMostDerived2.b"
umd2.ui = "UnknownMostDerived2.ui"
umd2.umd2 = "UnknownMostDerived2.umd2"
- cb.ice_exception(umd2)
+ f = Ice.Future()
+ f.set_exception(umd2)
+ return f
- def knownPreservedAsBase_async(self, cb, r, current=None):
+ def knownPreservedAsBase(self, r, current=None):
ex = Test.KnownPreservedDerived()
ex.b = "base"
ex.kp = "preserved"
ex.kpd = "derived"
- cb.ice_exception(ex)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def knownPreservedAsKnownPreserved_async(self, cb, r, current=None):
+ def knownPreservedAsKnownPreserved(self, r, current=None):
ex = Test.KnownPreservedDerived()
ex.b = "base"
ex.kp = "preserved"
ex.kpd = "derived"
- cb.ice_exception(ex)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def relayKnownPreservedAsBase_async(self, cb, r, current=None):
+ def relayKnownPreservedAsBase(self, r, current=None):
+ f = Ice.Future()
try:
r.knownPreservedAsBase()
test(False)
except Ice.Exception as ex:
- cb.ice_exception(ex)
+ f.set_exception(ex)
+ return f
- def relayKnownPreservedAsKnownPreserved_async(self, cb, r, current=None):
+ def relayKnownPreservedAsKnownPreserved(self, r, current=None):
+ f = Ice.Future()
try:
r.knownPreservedAsKnownPreserved()
test(False)
except Ice.Exception as ex:
- cb.ice_exception(ex)
+ f.set_exception(ex)
+ return f
- def unknownPreservedAsBase_async(self, cb, r, current=None):
+ def unknownPreservedAsBase(self, 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)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def unknownPreservedAsKnownPreserved_async(self, cb, r, current=None):
+ def unknownPreservedAsKnownPreserved(self, 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)
+ f = Ice.Future()
+ f.set_exception(ex)
+ return f
- def relayUnknownPreservedAsBase_async(self, cb, r, current=None):
+ def relayUnknownPreservedAsBase(self, r, current=None):
+ f = Ice.Future()
try:
r.unknownPreservedAsBase()
test(False)
except Ice.Exception as ex:
- cb.ice_exception(ex)
+ f.set_exception(ex)
+ return f
- def relayUnknownPreservedAsKnownPreserved_async(self, cb, r, current=None):
+ def relayUnknownPreservedAsKnownPreserved(self, r, current=None):
+ f = Ice.Future()
try:
r.unknownPreservedAsKnownPreserved()
test(False)
except Ice.Exception as ex:
- cb.ice_exception(ex)
+ f.set_exception(ex)
+ return f
def run(args, communicator):
properties = communicator.getProperties()
@@ -175,23 +218,16 @@ def run(args, communicator):
properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000")
adapter = communicator.createObjectAdapter("TestAdapter")
object = TestI()
- adapter.add(object, communicator.stringToIdentity("Test"))
+ adapter.add(object, Ice.stringToIdentity("Test"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/run.py b/python/test/Ice/slicing/exceptions/run.py
deleted file mode 100755
index 358f20eb50d..00000000000
--- a/python/test/Ice/slicing/exceptions/run.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 4d4e7d424d4..10c0fd251b9 100644
--- a/python/test/Ice/slicing/objects/AllTests.py
+++ b/python/test/Ice/slicing/objects/AllTests.py
@@ -10,7 +10,7 @@
import Ice, gc, sys, threading
-Ice.loadSlice('-I. --all Forward.ice ClientPrivate.ice')
+Ice.loadSlice('-I. --all ClientPrivate.ice')
import Test
def test(b):
@@ -23,22 +23,19 @@ class CallbackBase:
self._cond = threading.Condition()
def check(self):
- self._cond.acquire()
- try:
+ with self._cond:
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()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
class Callback(CallbackBase):
- def response_SBaseAsObject(self, o):
+ def response_SBaseAsObject(self, f):
+ o = f.result()
test(o)
test(o.ice_id() == "::Test::SBase")
sb = o
@@ -46,54 +43,53 @@ class Callback(CallbackBase):
test(sb.sb == "SBase.sb")
self.called()
- def response_SBaseAsSBase(self, sb):
+ def response_SBaseAsSBase(self, f):
+ sb = f.result()
test(sb.sb == "SBase.sb")
self.called()
- def response_SBSKnownDerivedAsSBase(self, sb):
- sbskd = sb
+ def response_SBSKnownDerivedAsSBase(self, f):
+ sbskd = f.result()
test(isinstance(sbskd, Test.SBSKnownDerived))
test(sbskd.sbskd == "SBSKnownDerived.sbskd")
self.called()
- def response_SBSKnownDerivedAsSBSKnownDerived(self, sbskd):
+ def response_SBSKnownDerivedAsSBSKnownDerived(self, f):
+ sbskd = f.result()
test(sbskd.sbskd == "SBSKnownDerived.sbskd")
self.called()
- def response_SBSUnknownDerivedAsSBase(self, sb):
+ def response_SBSUnknownDerivedAsSBase(self, f):
+ sb = f.result()
test(sb.sb == "SBSUnknownDerived.sb")
self.called()
- def response_SBSUnknownDerivedAsSBaseCompact(self, sb):
- test(False)
-
- def exception_SBSUnknownDerivedAsSBaseCompact(self, ex):
- test(isinstance(ex, Ice.NoObjectFactoryException))
+ def exception_SBSUnknownDerivedAsSBaseCompact(self, f):
+ test(f.exception() is not None)
+ test(isinstance(f.exception(), Ice.NoValueFactoryException))
self.called()
- def response_SUnknownAsObject10(self, o):
- test(False)
-
- def exception_SUnknownAsObject10(self, exc):
- test(exc.ice_name() == "Ice::NoObjectFactoryException")
+ def exception_SUnknownAsObject10(self, f):
+ test(f.exception() is not None)
+ test(f.exception().ice_id() == "::Ice::NoValueFactoryException")
self.called()
- def response_SUnknownAsObject11(self, o):
- test(isinstance(o, Ice.UnknownSlicedObject))
+ def response_SUnknownAsObject11(self, f):
+ o = f.result()
+ test(isinstance(o, Ice.UnknownSlicedValue))
test(o.unknownTypeId == "::Test::SUnknown")
self.called()
- def exception_SUnknownAsObject11(self, exc):
- test(False)
-
- def response_oneElementCycle(self, b):
+ def response_oneElementCycle(self, f):
+ b = f.result()
test(b)
test(b.ice_id() == "::Test::B")
test(b.sb == "B1.sb")
test(b.pb == b)
self.called()
- def response_twoElementCycle(self, b1):
+ def response_twoElementCycle(self, f):
+ b1 = f.result()
test(b1)
test(b1.ice_id() == "::Test::B")
test(b1.sb == "B1.sb")
@@ -105,7 +101,8 @@ class Callback(CallbackBase):
test(b2.pb == b1)
self.called()
- def response_D1AsB(self, b1):
+ def response_D1AsB(self, f):
+ b1 = f.result()
test(b1)
test(b1.ice_id() == "::Test::D1")
test(b1.sb == "D1.sb")
@@ -125,7 +122,8 @@ class Callback(CallbackBase):
test(b2.ice_id() == "::Test::B")
self.called()
- def response_D1AsD1(self, d1):
+ def response_D1AsD1(self, f):
+ d1 = f.result()
test(d1)
test(d1.ice_id() == "::Test::D1")
test(d1.sb == "D1.sb")
@@ -139,7 +137,8 @@ class Callback(CallbackBase):
test(b2.pb == d1)
self.called()
- def response_D2AsB(self, b2):
+ def response_D2AsB(self, f):
+ b2 = f.result()
test(b2)
test(b2.ice_id() == "::Test::B")
test(b2.sb == "D2.sb")
@@ -157,7 +156,8 @@ class Callback(CallbackBase):
test(d1.pd1 == b2)
self.called()
- def response_paramTest1(self, b1, b2):
+ def response_paramTest1(self, f):
+ (b1, b2) = f.result()
test(b1)
test(b1.ice_id() == "::Test::D1")
test(b1.sb == "D1.sb")
@@ -173,19 +173,23 @@ class Callback(CallbackBase):
test(b2.pb == b1)
self.called()
- def response_returnTest1(self, r, p1, p2):
+ def response_returnTest1(self, f):
+ (r, p1, p2) = f.result()
test(r == p1)
self.called()
- def response_returnTest2(self, r, p1, p2):
+ def response_returnTest2(self, f):
+ (r, p1, p2) = f.result()
test(r == p1)
self.called()
- def response_returnTest3(self, b):
+ def response_returnTest3(self, f):
+ b = f.result()
self.r = b
self.called()
- def response_paramTest3(self, ret, p1, p2):
+ def response_paramTest3(self, f):
+ (ret, p1, p2) = f.result()
test(p1)
test(p1.sb == "D2.sb (p1 1)")
test(p1.pb == None)
@@ -202,7 +206,8 @@ class Callback(CallbackBase):
test(ret.ice_id() == "::Test::D1")
self.called()
- def response_paramTest4(self, ret, b):
+ def response_paramTest4(self, f):
+ (ret, b) = f.result()
test(b)
test(b.sb == "D4.sb (1)")
test(b.pb == None)
@@ -214,17 +219,21 @@ class Callback(CallbackBase):
test(ret.ice_id() == "::Test::B")
self.called()
- def response_sequenceTest(self, ss):
+ def response_sequenceTest(self, f):
+ ss = f.result()
self.r = ss
self.called()
- def response_dictionaryTest(self, r, bout):
+ def response_dictionaryTest(self, f):
+ (r, bout) = f.result()
self.r = r
self.bout = bout
self.called()
- def exception_throwBaseAsBase(self, ex):
- test(ex.ice_name() == "Test::BaseException")
+ def exception_throwBaseAsBase(self, f):
+ ex = f.exception()
+ test(ex is not None)
+ test(ex.ice_id() == "::Test::BaseException")
e = ex
test(isinstance(e, Test.BaseException))
test(e.sbe == "sbe")
@@ -233,8 +242,10 @@ class Callback(CallbackBase):
test(e.pb.pb == e.pb)
self.called()
- def exception_throwDerivedAsBase(self, ex):
- test(ex.ice_name() == "Test::DerivedException")
+ def exception_throwDerivedAsBase(self, f):
+ ex = f.exception()
+ test(ex is not None)
+ test(ex.ice_id() == "::Test::DerivedException")
e = ex
test(isinstance(e, Test.DerivedException))
test(e.sbe == "sbe")
@@ -249,8 +260,10 @@ class Callback(CallbackBase):
test(e.pd1.pd1 == e.pd1)
self.called()
- def exception_throwDerivedAsDerived(self, ex):
- test(ex.ice_name() == "Test::DerivedException")
+ def exception_throwDerivedAsDerived(self, f):
+ ex = f.exception()
+ test(ex is not None)
+ test(ex.ice_id() == "::Test::DerivedException")
e = ex
test(isinstance(e, Test.DerivedException))
test(e.sbe == "sbe")
@@ -265,8 +278,10 @@ class Callback(CallbackBase):
test(e.pd1.pd1 == e.pd1)
self.called()
- def exception_throwUnknownDerivedAsBase(self, ex):
- test(ex.ice_name() == "Test::BaseException")
+ def exception_throwUnknownDerivedAsBase(self, f):
+ ex = f.exception()
+ test(ex is not None)
+ test(ex.ice_id() == "::Test::BaseException")
e = ex
test(isinstance(e, Test.BaseException))
test(e.sbe == "sbe")
@@ -276,10 +291,12 @@ class Callback(CallbackBase):
self.called()
def response_useForward(self, f):
- test(f)
+ fwd = f.result()
+ test(fwd)
self.called()
- def response_preserved1(self, r):
+ def response_preserved1(self, f):
+ r = f.result()
test(r)
test(isinstance(r, Test.PDerived))
test(r.pi == 3)
@@ -287,30 +304,34 @@ class Callback(CallbackBase):
test(r.pb == r)
self.called()
- def response_preserved2(self, r):
+ def response_preserved2(self, f):
+ r = f.result()
test(r)
test(not isinstance(r, Test.PCUnknown))
test(r.pi == 3)
self.called()
- def response_preserved3(self, r):
+ def response_preserved3(self, f):
#
# Encoding 1.0
#
+ r = f.result()
test(not isinstance(r, Test.PCDerived))
test(r.pi == 3)
self.called()
- def response_preserved4(self, r):
+ def response_preserved4(self, f):
#
# Encoding > 1.0
#
+ r = f.result()
test(isinstance(r, Test.PCDerived))
test(r.pi == 3)
test(r.pbs[0] == r)
self.called()
- def response_preserved5(self, r):
+ def response_preserved5(self, f):
+ r = f.result()
test(isinstance(r, Test.PCDerived3))
test(r.pi == 3)
for i in range(0, 300):
@@ -324,32 +345,25 @@ class Callback(CallbackBase):
test(r.pcd3 == r.pbs[10])
self.called()
- def response_compactPreserved1(self, r):
+ def response_compactPreserved1(self, f):
#
# Encoding 1.0
#
+ r = f.result()
test(not isinstance(r, Test.CompactPCDerived))
test(r.pi == 3)
self.called()
- def response_compactPreserved2(self, r):
+ def response_compactPreserved2(self, f):
#
# Encoding > 1.0
#
+ r = f.result()
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
@@ -359,14 +373,10 @@ class PNodeI(Test.PNode):
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
+def NodeFactoryI(id):
+ if id == Test.PNode.ice_staticId():
+ return PNodeI()
+ return None
class PreservedI(Test.Preserved):
counter = 0
@@ -377,14 +387,10 @@ class PreservedI(Test.Preserved):
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 PreservedFactoryI(id):
+ if id == Test.Preserved.ice_staticId():
+ return PreservedI()
+ return None
def allTests(communicator):
obj = communicator.stringToProxy("Test:default -p 12010")
@@ -408,7 +414,7 @@ def allTests(communicator):
sys.stdout.write("base as Object (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_SBaseAsObject(cb.response_SBaseAsObject, cb.exception)
+ t.SBaseAsObjectAsync().add_done_callback(cb.response_SBaseAsObject)
cb.check()
print("ok")
@@ -424,7 +430,7 @@ def allTests(communicator):
sys.stdout.write("base as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_SBaseAsSBase(cb.response_SBaseAsSBase, cb.exception)
+ t.SBaseAsSBaseAsync().add_done_callback(cb.response_SBaseAsSBase)
cb.check()
print("ok")
@@ -444,7 +450,7 @@ def allTests(communicator):
sys.stdout.write("base with known derived as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_SBSKnownDerivedAsSBase(cb.response_SBSKnownDerivedAsSBase, cb.exception)
+ t.SBSKnownDerivedAsSBaseAsync().add_done_callback(cb.response_SBSKnownDerivedAsSBase)
cb.check()
print("ok")
@@ -460,7 +466,7 @@ def allTests(communicator):
sys.stdout.write("base with known derived as known derived (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_SBSKnownDerivedAsSBSKnownDerived(cb.response_SBSKnownDerivedAsSBSKnownDerived, cb.exception)
+ t.SBSKnownDerivedAsSBSKnownDerivedAsync().add_done_callback(cb.response_SBSKnownDerivedAsSBSKnownDerived)
cb.check()
print("ok")
@@ -492,7 +498,7 @@ def allTests(communicator):
test(False)
except Ice.OperationNotExistException:
pass
- except Ice.NoObjectFactoryException:
+ except Ice.NoValueFactoryException:
# Expected.
pass
except:
@@ -502,14 +508,14 @@ def allTests(communicator):
sys.stdout.write("base with unknown derived as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_SBSUnknownDerivedAsSBase(cb.response_SBSUnknownDerivedAsSBase, cb.exception)
+ t.SBSUnknownDerivedAsSBaseAsync().add_done_callback(cb.response_SBSUnknownDerivedAsSBase)
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)
+ t.SBSUnknownDerivedAsSBaseCompactAsync().add_done_callback(cb.response_SBSUnknownDerivedAsSBase)
cb.check()
else:
#
@@ -517,8 +523,7 @@ def allTests(communicator):
# be sliced to a known type.
#
cb = Callback()
- t.begin_SBSUnknownDerivedAsSBaseCompact(cb.response_SBSUnknownDerivedAsSBaseCompact,
- cb.exception_SBSUnknownDerivedAsSBaseCompact)
+ t.SBSUnknownDerivedAsSBaseCompactAsync().add_done_callback(cb.exception_SBSUnknownDerivedAsSBaseCompact)
cb.check()
print("ok")
@@ -527,10 +532,10 @@ def allTests(communicator):
try:
o = t.SUnknownAsObject()
test(t.ice_getEncodingVersion() != Ice.Encoding_1_0)
- test(isinstance(o, Ice.UnknownSlicedObject))
+ test(isinstance(o, Ice.UnknownSlicedValue))
test(o.unknownTypeId == "::Test::SUnknown")
t.checkSUnknown(o)
- except Ice.NoObjectFactoryException:
+ except Ice.NoValueFactoryException:
test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
except Ice.Exception:
test(False)
@@ -541,9 +546,9 @@ def allTests(communicator):
try:
cb = Callback()
if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
- t.begin_SUnknownAsObject(cb.response_SUnknownAsObject10, cb.exception_SUnknownAsObject10)
+ t.SUnknownAsObjectAsync().add_done_callback(cb.exception_SUnknownAsObject10)
else:
- t.begin_SUnknownAsObject(cb.response_SUnknownAsObject11, cb.exception_SUnknownAsObject11)
+ t.SUnknownAsObjectAsync().add_done_callback(cb.response_SUnknownAsObject11)
cb.check()
except Ice.Exception:
test(False)
@@ -564,7 +569,7 @@ def allTests(communicator):
sys.stdout.write("one-element cycle (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_oneElementCycle(cb.response_oneElementCycle, cb.exception)
+ t.oneElementCycleAsync().add_done_callback(cb.response_oneElementCycle)
cb.check()
print("ok")
@@ -588,7 +593,7 @@ def allTests(communicator):
sys.stdout.write("two-element cycle (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_twoElementCycle(cb.response_twoElementCycle, cb.exception)
+ t.twoElementCycleAsync().add_done_callback(cb.response_twoElementCycle)
cb.check()
print("ok")
@@ -620,7 +625,7 @@ def allTests(communicator):
sys.stdout.write("known derived pointer slicing as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_D1AsB(cb.response_D1AsB, cb.exception)
+ t.D1AsBAsync().add_done_callback(cb.response_D1AsB)
cb.check()
print("ok")
@@ -646,7 +651,7 @@ def allTests(communicator):
sys.stdout.write("known derived pointer slicing as derived (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_D1AsD1(cb.response_D1AsD1, cb.exception)
+ t.D1AsD1Async().add_done_callback(cb.response_D1AsD1)
cb.check()
print("ok")
@@ -676,7 +681,7 @@ def allTests(communicator):
sys.stdout.write("unknown derived pointer slicing as base (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_D2AsB(cb.response_D2AsB, cb.exception)
+ t.D2AsBAsync().add_done_callback(cb.response_D2AsB)
cb.check()
print("ok")
@@ -705,7 +710,7 @@ def allTests(communicator):
sys.stdout.write("param ptr slicing with known first (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_paramTest1(cb.response_paramTest1, cb.exception)
+ t.paramTest1Async().add_done_callback(cb.response_paramTest1)
cb.check()
print("ok")
@@ -743,7 +748,7 @@ def allTests(communicator):
sys.stdout.write("return value identity with known first (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_returnTest1(cb.response_returnTest1, cb.exception)
+ t.returnTest1Async().add_done_callback(cb.response_returnTest1)
cb.check()
print("ok")
@@ -759,7 +764,7 @@ def allTests(communicator):
sys.stdout.write("return value identity with unknown first (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_returnTest2(cb.response_returnTest2, cb.exception)
+ t.returnTest2Async().add_done_callback(cb.response_returnTest2)
cb.check()
print("ok")
@@ -818,7 +823,7 @@ def allTests(communicator):
d1.pd1 = d3
cb = Callback()
- t.begin_returnTest3(d1, d3, cb.response_returnTest3, cb.exception)
+ t.returnTest3Async(d1, d3).add_done_callback(cb.response_returnTest3)
cb.check()
b1 = cb.r
@@ -901,7 +906,7 @@ def allTests(communicator):
d1.pd1 = d3
cb = Callback()
- t.begin_returnTest3(d3, d1, cb.response_returnTest3, cb.exception)
+ t.returnTest3Async(d3, d1).add_done_callback(cb.response_returnTest3)
cb.check()
b1 = cb.r
@@ -955,7 +960,7 @@ def allTests(communicator):
sys.stdout.write("remainder unmarshaling (3 instances) (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_paramTest3(cb.response_paramTest3, cb.exception)
+ t.paramTest3Async().add_done_callback(cb.response_paramTest3)
cb.check()
print("ok")
@@ -980,7 +985,7 @@ def allTests(communicator):
sys.stdout.write("remainder unmarshaling (4 instances) (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_paramTest4(cb.response_paramTest4, cb.exception)
+ t.paramTest4Async().add_done_callback(cb.response_paramTest4)
cb.check()
print("ok")
@@ -1029,7 +1034,7 @@ def allTests(communicator):
b2.pb = b1
cb = Callback()
- t.begin_returnTest3(d3, b2, cb.response_returnTest3, cb.exception)
+ t.returnTest3Async(d3, b2).add_done_callback(cb.response_returnTest3)
cb.check()
r = cb.r
@@ -1093,7 +1098,7 @@ def allTests(communicator):
d12.pd1 = d11
cb = Callback()
- t.begin_returnTest3(d3, d12, cb.response_returnTest3, cb.exception)
+ t.returnTest3Async(d3, d12).add_done_callback(cb.response_returnTest3)
cb.check()
r = cb.r
@@ -1226,7 +1231,7 @@ def allTests(communicator):
ss2.s = (ss2b, ss2d1, ss2d3)
cb = Callback()
- t.begin_sequenceTest(ss1, ss2, cb.response_sequenceTest, cb.exception)
+ t.sequenceTestAsync(ss1, ss2).add_done_callback(cb.response_sequenceTest)
cb.check()
ss = cb.r
@@ -1318,7 +1323,7 @@ def allTests(communicator):
bin[i] = d1
cb = Callback()
- t.begin_dictionaryTest(bin, cb.response_dictionaryTest, cb.exception)
+ t.dictionaryTestAsync(bin).add_done_callback(cb.response_dictionaryTest)
cb.check()
bout = cb.bout
r = cb.r
@@ -1358,7 +1363,7 @@ def allTests(communicator):
t.throwBaseAsBase()
test(False)
except Test.BaseException as e:
- test(e.ice_name() == "Test::BaseException")
+ test(e.ice_id() == "::Test::BaseException")
test(e.sbe == "sbe")
test(e.pb)
test(e.pb.sb == "sb")
@@ -1370,7 +1375,7 @@ def allTests(communicator):
sys.stdout.write("base exception thrown as base exception (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_throwBaseAsBase(cb.response, cb.exception_throwBaseAsBase)
+ t.throwBaseAsBaseAsync().add_done_callback(cb.exception_throwBaseAsBase)
cb.check()
print("ok")
@@ -1380,7 +1385,7 @@ def allTests(communicator):
t.throwDerivedAsBase()
test(False)
except Test.DerivedException as e:
- test(e.ice_name() == "Test::DerivedException")
+ test(e.ice_id() == "::Test::DerivedException")
test(e.sbe == "sbe")
test(e.pb)
test(e.pb.sb == "sb1")
@@ -1398,7 +1403,7 @@ def allTests(communicator):
sys.stdout.write("derived exception thrown as base exception (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_throwDerivedAsBase(cb.response, cb.exception_throwDerivedAsBase)
+ t.throwDerivedAsBaseAsync().add_done_callback(cb.exception_throwDerivedAsBase)
cb.check()
print("ok")
@@ -1408,7 +1413,7 @@ def allTests(communicator):
t.throwDerivedAsDerived()
test(False)
except Test.DerivedException as e:
- test(e.ice_name() == "Test::DerivedException")
+ test(e.ice_id() == "::Test::DerivedException")
test(e.sbe == "sbe")
test(e.pb)
test(e.pb.sb == "sb1")
@@ -1426,7 +1431,7 @@ def allTests(communicator):
sys.stdout.write("derived exception thrown as derived exception (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_throwDerivedAsDerived(cb.response, cb.exception_throwDerivedAsDerived)
+ t.throwDerivedAsDerivedAsync().add_done_callback(cb.exception_throwDerivedAsDerived)
cb.check()
print("ok")
@@ -1436,7 +1441,7 @@ def allTests(communicator):
t.throwUnknownDerivedAsBase()
test(False)
except Test.BaseException as e:
- test(e.ice_name() == "Test::BaseException")
+ test(e.ice_id() == "::Test::BaseException")
test(e.sbe == "sbe")
test(e.pb)
test(e.pb.sb == "sb d2")
@@ -1448,7 +1453,7 @@ def allTests(communicator):
sys.stdout.write("unknown derived exception thrown as base exception (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_throwUnknownDerivedAsBase(cb.response, cb.exception_throwUnknownDerivedAsBase)
+ t.throwUnknownDerivedAsBaseAsync().add_done_callback(cb.exception_throwUnknownDerivedAsBase)
cb.check()
print("ok")
@@ -1464,7 +1469,7 @@ def allTests(communicator):
sys.stdout.write("forward-declared class (AMI)... ")
sys.stdout.flush()
cb = Callback()
- t.begin_useForward(cb.response_useForward, cb.exception)
+ t.useForwardAsync().add_done_callback(cb.response_useForward)
cb.check()
print("ok")
@@ -1579,7 +1584,7 @@ def allTests(communicator):
t.ice_encodingVersion(Ice.Encoding_1_0).checkPBSUnknown(p)
except Ice.OperationNotExistException:
pass
-
+
print("ok")
sys.stdout.write("preserved classes (AMI)... ")
@@ -1594,7 +1599,7 @@ def allTests(communicator):
pd.pb = pd
cb = Callback()
- t.begin_exchangePBase(pd, cb.response_preserved1, cb.exception)
+ t.exchangePBaseAsync(pd).add_done_callback(cb.response_preserved1)
cb.check()
#
@@ -1605,7 +1610,7 @@ def allTests(communicator):
pu.pu = "preserved"
cb = Callback()
- t.begin_exchangePBase(pu, cb.response_preserved2, cb.exception)
+ t.exchangePBaseAsync(pu).add_done_callback(cb.response_preserved2)
cb.check()
#
@@ -1618,9 +1623,9 @@ def allTests(communicator):
cb = Callback()
if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
- t.begin_exchangePBase(pcd, cb.response_preserved3, cb.exception)
+ t.exchangePBaseAsync(pcd).add_done_callback(cb.response_preserved3)
else:
- t.begin_exchangePBase(pcd, cb.response_preserved4, cb.exception)
+ t.exchangePBaseAsync(pcd).add_done_callback(cb.response_preserved4)
cb.check()
#
@@ -1633,9 +1638,9 @@ def allTests(communicator):
cb = Callback()
if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
- t.begin_exchangePBase(pcd, cb.response_compactPreserved1, cb.exception)
+ t.exchangePBaseAsync(pcd).add_done_callback(cb.response_compactPreserved1)
else:
- t.begin_exchangePBase(pcd, cb.response_compactPreserved2, cb.exception)
+ t.exchangePBaseAsync(pcd).add_done_callback(cb.response_compactPreserved2)
cb.check()
#
@@ -1659,9 +1664,9 @@ def allTests(communicator):
cb = Callback()
if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
- t.begin_exchangePBase(pcd, cb.response_preserved3, cb.exception)
+ t.exchangePBaseAsync(pcd).add_done_callback(cb.response_preserved3)
else:
- t.begin_exchangePBase(pcd, cb.response_preserved5, cb.exception)
+ t.exchangePBaseAsync(pcd).add_done_callback(cb.response_preserved5)
cb.check()
print("ok")
@@ -1674,7 +1679,7 @@ def allTests(communicator):
# UCNode. This provides an easy way to determine how many
# unmarshaled instances currently exist.
#
- communicator.addObjectFactory(NodeFactoryI(), Test.PNode.ice_staticId())
+ communicator.getValueFactoryManager().add(NodeFactoryI, Test.PNode.ice_staticId())
#
# Relay a graph through the server. This test uses a preserved class
@@ -1761,7 +1766,7 @@ def allTests(communicator):
# Preserved. This provides an easy way to determine how many
# unmarshaled instances currently exist.
#
- communicator.addObjectFactory(PreservedFactoryI(), Test.Preserved.ice_staticId())
+ communicator.getValueFactoryManager().add(PreservedFactoryI, Test.Preserved.ice_staticId())
#
# Obtain a preserved object from the server where the most-derived
diff --git a/python/test/Ice/slicing/objects/Client.py b/python/test/Ice/slicing/objects/Client.py
index 370ed6305b8..830d6f18148 100755
--- a/python/test/Ice/slicing/objects/Client.py
+++ b/python/test/Ice/slicing/objects/Client.py
@@ -18,17 +18,10 @@ def run(args, communicator):
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/Forward.ice b/python/test/Ice/slicing/objects/Forward.ice
deleted file mode 100644
index 1654e5f10ae..00000000000
--- a/python/test/Ice/slicing/objects/Forward.ice
+++ /dev/null
@@ -1,27 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2017 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
index 8dec2d3461e..b1780ef5881 100755
--- a/python/test/Ice/slicing/objects/Server.py
+++ b/python/test/Ice/slicing/objects/Server.py
@@ -11,14 +11,14 @@
import os, sys, traceback
import Ice
-Ice.loadSlice('-I. --all ServerPrivate.ice Forward.ice')
+Ice.loadSlice('-I. --all ServerPrivate.ice')
import Test
def test(b):
if not b:
raise RuntimeError('test assertion failed')
-class TestI(Test.TestIntf):
+class TestI(Test._TestIntfDisp):
def SBaseAsObject(self, current=None):
sb = Test.SBase()
sb.sb = "SBase.sb"
@@ -244,7 +244,7 @@ class TestI(Test.TestIntf):
test(p.psu == "unknown")
test(not p.graph)
- def PBSUnknownAsPreservedWithGraph_async(self, cb, current=None):
+ def PBSUnknownAsPreservedWithGraph(self, current=None):
r = Test.PSUnknown()
r.pi = 5
r.ps = "preserved"
@@ -253,8 +253,8 @@ class TestI(Test.TestIntf):
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.
+ return Ice.Future.completed(r)
+ #r.graph.next.next.next = None # Break the cycle.
def checkPBSUnknownWithGraph(self, p, current=None):
if current.encoding == Ice.Encoding_1_0:
@@ -271,13 +271,13 @@ class TestI(Test.TestIntf):
test(p.graph.next.next.next == p.graph)
p.graph.next.next.next = None # Break the cycle.
- def PBSUnknown2AsPreservedWithGraph_async(self, cb, current=None):
+ def PBSUnknown2AsPreservedWithGraph(self, current=None):
r = Test.PSUnknown2()
r.pi = 5
r.ps = "preserved"
r.pb = r
- cb.ice_response(r)
- r.pb = None # Break the cycle.
+ return Ice.Future.completed(r)
+ #r.pb = None # Break the cycle.
def checkPBSUnknown2WithGraph(self, p, current=None):
if current.encoding == Ice.Encoding_1_0:
@@ -344,14 +344,16 @@ class TestI(Test.TestIntf):
ude.pd2 = d2
raise ude
- def throwPreservedException_async(self, cb, current=None):
+ def throwPreservedException(self, 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.
+ f = Ice.Future()
+ f.set_exception(ue)
+ return f
+ #ue.p.pb = None # Break the cycle.
def useForward(self, current=None):
f = Test.Forward()
@@ -368,23 +370,16 @@ def run(args, communicator):
properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000")
adapter = communicator.createObjectAdapter("TestAdapter")
object = TestI()
- adapter.add(object, communicator.stringToIdentity("Test"))
+ adapter.add(object, Ice.stringToIdentity("Test"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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
index 11410253a14..f64a6f13af9 100755
--- a/python/test/Ice/slicing/objects/ServerAMD.py
+++ b/python/test/Ice/slicing/objects/ServerAMD.py
@@ -11,77 +11,77 @@
import os, sys, traceback
import Ice
-Ice.loadSlice('-I. --all ServerPrivateAMD.ice Forward.ice')
+Ice.loadSlice('-I. --all ServerPrivateAMD.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):
+class TestI(Test._TestIntfDisp):
+ def SBaseAsObject(self, current=None):
sb = Test.SBase()
sb.sb = "SBase.sb"
- cb.ice_response(sb)
+ return Ice.Future.completed(sb)
- def SBaseAsSBase_async(self, cb, current=None):
+ def SBaseAsSBase(self, current=None):
sb = Test.SBase()
sb.sb = "SBase.sb"
- cb.ice_response(sb)
+ return Ice.Future.completed(sb)
- def SBSKnownDerivedAsSBase_async(self, cb, current=None):
+ def SBSKnownDerivedAsSBase(self, current=None):
sbskd = Test.SBSKnownDerived()
sbskd.sb = "SBSKnownDerived.sb"
sbskd.sbskd = "SBSKnownDerived.sbskd"
- cb.ice_response(sbskd)
+ return Ice.Future.completed(sbskd)
- def SBSKnownDerivedAsSBSKnownDerived_async(self, cb, current=None):
+ def SBSKnownDerivedAsSBSKnownDerived(self, current=None):
sbskd = Test.SBSKnownDerived()
sbskd.sb = "SBSKnownDerived.sb"
sbskd.sbskd = "SBSKnownDerived.sbskd"
- cb.ice_response(sbskd)
+ return Ice.Future.completed(sbskd)
- def SBSUnknownDerivedAsSBase_async(self, cb, current=None):
+ def SBSUnknownDerivedAsSBase(self, current=None):
sbsud = Test.SBSUnknownDerived()
sbsud.sb = "SBSUnknownDerived.sb"
sbsud.sbsud = "SBSUnknownDerived.sbsud"
- cb.ice_response(sbsud)
+ return Ice.Future.completed(sbsud)
- def SBSUnknownDerivedAsSBaseCompact_async(self, cb, current=None):
+ def SBSUnknownDerivedAsSBaseCompact(self, current=None):
sbsud = Test.SBSUnknownDerived()
sbsud.sb = "SBSUnknownDerived.sb"
sbsud.sbsud = "SBSUnknownDerived.sbsud"
- cb.ice_response(sbsud)
+ return Ice.Future.completed(sbsud)
- def SUnknownAsObject_async(self, cb, current=None):
+ def SUnknownAsObject(self, current=None):
su = Test.SUnknown()
su.su = "SUnknown.su"
- cb.ice_response(su)
+ return Ice.Future.completed(su)
- def checkSUnknown_async(self, cb, obj, current=None):
+ 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")
- cb.ice_response()
+ return Ice.Future.completed(None)
- def oneElementCycle_async(self, cb, current=None):
+ def oneElementCycle(self, current=None):
b = Test.B()
b.sb = "B1.sb"
b.pb = b
- cb.ice_response(b)
+ return Ice.Future.completed(b)
- def twoElementCycle_async(self, cb, current=None):
+ 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
- cb.ice_response(b1)
+ return Ice.Future.completed(b1)
- def D1AsB_async(self, cb, current=None):
+ def D1AsB(self, current=None):
d1 = Test.D1()
d1.sb = "D1.sb"
d1.sd1 = "D1.sd1"
@@ -92,9 +92,9 @@ class TestI(Test.TestIntf):
d2.pd2 = d1
d1.pb = d2
d1.pd1 = d2
- cb.ice_response(d1)
+ return Ice.Future.completed(d1)
- def D1AsD1_async(self, cb, current=None):
+ def D1AsD1(self, current=None):
d1 = Test.D1()
d1.sb = "D1.sb"
d1.sd1 = "D1.sd1"
@@ -105,9 +105,9 @@ class TestI(Test.TestIntf):
d2.pd2 = d1
d1.pb = d2
d1.pd1 = d2
- cb.ice_response(d1)
+ return Ice.Future.completed(d1)
- def D2AsB_async(self, cb, current=None):
+ def D2AsB(self, current=None):
d2 = Test.D2()
d2.sb = "D2.sb"
d2.sd2 = "D2.sd2"
@@ -118,9 +118,9 @@ class TestI(Test.TestIntf):
d1.pd1 = d2
d2.pb = d1
d2.pd2 = d1
- cb.ice_response(d2)
+ return Ice.Future.completed(d2)
- def paramTest1_async(self, cb, current=None):
+ def paramTest1(self, current=None):
d1 = Test.D1()
d1.sb = "D1.sb"
d1.sd1 = "D1.sd1"
@@ -131,9 +131,9 @@ class TestI(Test.TestIntf):
d2.pd2 = d1
d1.pb = d2
d1.pd1 = d2
- cb.ice_response(d1, d2)
+ return Ice.Future.completed((d1, d2))
- def paramTest2_async(self, cb, current=None):
+ def paramTest2(self, current=None):
d1 = Test.D1()
d1.sb = "D1.sb"
d1.sd1 = "D1.sd1"
@@ -144,9 +144,9 @@ class TestI(Test.TestIntf):
d2.pd2 = d1
d1.pb = d2
d1.pd1 = d2
- cb.ice_response(d2, d1)
+ return Ice.Future.completed((d2, d1))
- def paramTest3_async(self, cb, current=None):
+ def paramTest3(self, current=None):
d2 = Test.D2()
d2.sb = "D2.sb (p1 1)"
d2.pb = None
@@ -171,9 +171,9 @@ class TestI(Test.TestIntf):
d3.pd1 = None
d4.pd2 = d3
- cb.ice_response(d3, d2, d4)
+ return Ice.Future.completed((d3, d2, d4))
- def paramTest4_async(self, cb, current=None):
+ def paramTest4(self, current=None):
d4 = Test.D4()
d4.sb = "D4.sb (1)"
d4.pb = None
@@ -183,9 +183,9 @@ class TestI(Test.TestIntf):
d4.p2 = Test.B()
d4.p2.sb = "B.sb (2)"
d4.p2.pb = None
- cb.ice_response(d4.p2, d4)
+ return Ice.Future.completed((d4.p2, d4))
- def returnTest1_async(self, cb, current=None):
+ def returnTest1(self, current=None):
d1 = Test.D1()
d1.sb = "D1.sb"
d1.sd1 = "D1.sd1"
@@ -196,9 +196,9 @@ class TestI(Test.TestIntf):
d2.pd2 = d1
d1.pb = d2
d1.pd1 = d2
- cb.ice_response(d2, d2, d1)
+ return Ice.Future.completed((d2, d2, d1))
- def returnTest2_async(self, cb, current=None):
+ def returnTest2(self, current=None):
d1 = Test.D1()
d1.sb = "D1.sb"
d1.sd1 = "D1.sd1"
@@ -209,18 +209,18 @@ class TestI(Test.TestIntf):
d2.pd2 = d1
d1.pb = d2
d1.pd1 = d2
- cb.ice_response(d1, d1, d2)
+ return Ice.Future.completed((d1, d1, d2))
- def returnTest3_async(self, cb, p1, p2, current=None):
- cb.ice_response(p1)
+ def returnTest3(self, p1, p2, current=None):
+ return Ice.Future.completed(p1)
- def sequenceTest_async(self, cb, p1, p2, current=None):
+ def sequenceTest(self, p1, p2, current=None):
ss = Test.SS3()
ss.c1 = p1
ss.c2 = p2
- cb.ice_response(ss)
+ return Ice.Future.completed(ss)
- def dictionaryTest_async(self, cb, bin, current=None):
+ def dictionaryTest(self, bin, current=None):
bout = {}
for i in range(0, 10):
b = bin[i]
@@ -244,20 +244,20 @@ class TestI(Test.TestIntf):
d1.pd1 = d1
r[i * 20] = d1
- cb.ice_response(r, bout)
+ return Ice.Future.completed((r, bout))
- def exchangePBase_async(self, cb, pb, current=None):
- cb.ice_response(pb)
+ def exchangePBase(self, pb, current=None):
+ return Ice.Future.completed(pb)
- def PBSUnknownAsPreserved_async(self, cb, current=None):
+ def PBSUnknownAsPreserved(self, current=None):
r = Test.PSUnknown()
r.pi = 5
r.ps = "preserved"
r.psu = "unknown"
r.graph = None
- cb.ice_response(r)
+ return Ice.Future.completed(r)
- def checkPBSUnknown_async(self, cb, p, current=None):
+ def checkPBSUnknown(self, p, current=None):
if current.encoding == Ice.Encoding_1_0:
test(not isinstance(p, Test.PSUnknown))
test(p.pi == 5)
@@ -268,9 +268,9 @@ class TestI(Test.TestIntf):
test(p.ps == "preserved")
test(p.psu == "unknown")
test(not p.graph)
- cb.ice_response()
+ return Ice.Future.completed(None)
- def PBSUnknownAsPreservedWithGraph_async(self, cb, current=None):
+ def PBSUnknownAsPreservedWithGraph(self, current=None):
r = Test.PSUnknown()
r.pi = 5
r.ps = "preserved"
@@ -279,10 +279,10 @@ class TestI(Test.TestIntf):
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.
+ return Ice.Future.completed(r)
+ #r.graph.next.next.next = None # Break the cycle.
- def checkPBSUnknownWithGraph_async(self, cb, p, current=None):
+ def checkPBSUnknownWithGraph(self, p, current=None):
if current.encoding == Ice.Encoding_1_0:
test(not isinstance(p, Test.PSUnknown))
test(p.pi == 5)
@@ -296,17 +296,17 @@ class TestI(Test.TestIntf):
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()
+ return Ice.Future.completed(None)
- def PBSUnknown2AsPreservedWithGraph_async(self, cb, current=None):
+ def PBSUnknown2AsPreservedWithGraph(self, current=None):
r = Test.PSUnknown2()
r.pi = 5
r.ps = "preserved"
r.pb = r
- cb.ice_response(r)
- r.pb = None # Break the cycle.
+ return Ice.Future.completed(r)
+ #r.pb = None # Break the cycle.
- def checkPBSUnknown2WithGraph_async(self, cb, p, current=None):
+ def checkPBSUnknown2WithGraph(self, p, current=None):
if current.encoding == Ice.Encoding_1_0:
test(not isinstance(p, Test.PSUnknown2))
test(p.pi == 5)
@@ -317,20 +317,22 @@ class TestI(Test.TestIntf):
test(p.ps == "preserved")
test(p.pb == p)
p.pb = None # Break the cycle.
- cb.ice_response()
+ return Ice.Future.completed(None)
- def exchangePNode_async(self, cb, pn, current=None):
- cb.ice_response(pn)
+ def exchangePNode(self, pn, current=None):
+ return Ice.Future.completed(pn)
- def throwBaseAsBase_async(self, cb, current=None):
+ def throwBaseAsBase(self, 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)
+ f = Ice.Future()
+ f.set_exception(be)
+ return f
- def throwDerivedAsBase_async(self, cb, current=None):
+ def throwDerivedAsBase(self, current=None):
de = Test.DerivedException()
de.sbe = "sbe"
de.pb = Test.B()
@@ -342,9 +344,11 @@ class TestI(Test.TestIntf):
de.pd1.pb = de.pd1
de.pd1.sd1 = "sd2"
de.pd1.pd1 = de.pd1
- cb.ice_exception(de)
+ f = Ice.Future()
+ f.set_exception(de)
+ return f
- def throwDerivedAsDerived_async(self, cb, current=None):
+ def throwDerivedAsDerived(self, current=None):
de = Test.DerivedException()
de.sbe = "sbe"
de.pb = Test.B()
@@ -356,9 +360,11 @@ class TestI(Test.TestIntf):
de.pd1.pb = de.pd1
de.pd1.sd1 = "sd2"
de.pd1.pd1 = de.pd1
- cb.ice_exception(de)
+ f = Ice.Future()
+ f.set_exception(de)
+ return f
- def throwUnknownDerivedAsBase_async(self, cb, current=None):
+ def throwUnknownDerivedAsBase(self, current=None):
d2 = Test.D2()
d2.sb = "sb d2"
d2.pb = d2
@@ -370,26 +376,29 @@ class TestI(Test.TestIntf):
ude.pb = d2
ude.sude = "sude"
ude.pd2 = d2
- cb.ice_exception(ude)
+ f = Ice.Future()
+ f.set_exception(ude)
+ return f
- def throwPreservedException_async(self, cb, current=None):
+ def throwPreservedException(self, 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):
+ f = Ice.Future()
+ f.set_exception(ue)
+ return f
+ #ue.p.pb = None # Break the cycle.
+
+ def useForward(self, current=None):
+ fwd = Test.Forward()
+ fwd.h = Test.Hidden()
+ fwd.h.f = fwd
+ return Ice.Future.completed(fwd)
+
+ def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
- cb.ice_response()
def run(args, communicator):
properties = communicator.getProperties()
@@ -397,23 +406,16 @@ def run(args, communicator):
properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000")
adapter = communicator.createObjectAdapter("TestAdapter")
object = TestI()
- adapter.add(object, communicator.stringToIdentity("Test"))
+ adapter.add(object, Ice.stringToIdentity("Test"))
adapter.activate()
communicator.waitForShutdown()
return True
try:
- communicator = Ice.initialize(sys.argv)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv) as communicator:
+ 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/Test.ice b/python/test/Ice/slicing/objects/Test.ice
index b9936669b30..89f2780c352 100644
--- a/python/test/Ice/slicing/objects/Test.ice
+++ b/python/test/Ice/slicing/objects/Test.ice
@@ -66,7 +66,7 @@ exception DerivedException extends BaseException
D1 pd1;
};
-class Forward; /* Forward-declared class defined in another compilation unit */
+class Forward;
class PBase
{
@@ -160,5 +160,15 @@ interface TestIntf
void shutdown();
};
+class Hidden
+{
+ Forward f;
+};
+
+class Forward
+{
+ Hidden h;
+};
+
};
diff --git a/python/test/Ice/slicing/objects/TestAMD.ice b/python/test/Ice/slicing/objects/TestAMD.ice
index 181e8279d94..dc034da87ab 100644
--- a/python/test/Ice/slicing/objects/TestAMD.ice
+++ b/python/test/Ice/slicing/objects/TestAMD.ice
@@ -66,7 +66,7 @@ exception DerivedException extends BaseException
D1 pd1;
};
-class Forward; // Forward-declared class defined in another compilation unit
+class Forward;
class PBase
{
@@ -155,4 +155,14 @@ interface TestIntf
void shutdown();
};
+class Hidden
+{
+ Forward f;
+};
+
+class Forward
+{
+ Hidden h;
+};
+
};
diff --git a/python/test/Ice/slicing/objects/run.py b/python/test/Ice/slicing/objects/run.py
deleted file mode 100755
index af4c5d38c06..00000000000
--- a/python/test/Ice/slicing/objects/run.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index 0d4bd320336..65d923559d4 100644
--- a/python/test/Ice/timeout/AllTests.py
+++ b/python/test/Ice/timeout/AllTests.py
@@ -19,17 +19,16 @@ class CallbackBase:
self._cond = threading.Condition()
def called(self):
- self._cond.acquire()
- self._called = True
- self._cond.notify()
- self._cond.release()
+ with self._cond:
+ self._called = True
+ self._cond.notify()
def check(self):
- self._cond.acquire()
- while not self._called:
- self._cond.wait()
- self._called = False
- return True
+ with self._cond:
+ while not self._called:
+ self._cond.wait()
+ self._called = False
+ return True
class Callback(CallbackBase):
def response(self):
@@ -117,58 +116,58 @@ def allTests(communicator):
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());
+ connection = obj.ice_getConnection()
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100))
+ test(connection == to.ice_getConnection())
try:
- to.sleep(750);
- test(False);
+ 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());
+ obj.ice_ping()
+ to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500))
+ test(connection == to.ice_getConnection())
try:
- to.sleep(250);
+ to.sleep(250)
except Ice.InvocationTimeoutException:
- test(False);
- test(connection == to.ice_getConnection());
+ 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();
+ # 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();
+ # 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);
+ to = Test.TimeoutPrx.checkedCast(obj.ice_timeout(100))
+ connection = to.ice_getConnection()
+ timeout.holdAdapter(500)
+ connection.close(Ice.ConnectionClose.GracefullyWithWait)
try:
connection.getInfo(); # getInfo() doesn't throw in the closing state.
except Ice.LocalException:
- test(False);
- time.sleep(0.5);
+ test(False)
+ time.sleep(0.5)
try:
- connection.getInfo();
- test(False);
- except Ice.CloseConnectionException:
+ connection.getInfo()
+ test(False)
+ except Ice.ConnectionManuallyClosedException as ex:
# Expected.
- pass
- timeout.op(); # Ensure adapter is active.
+ test(ex.graceful)
+ timeout.op() # Ensure adapter is active.
print("ok")
sys.stdout.write("testing timeout overrides... ")
@@ -180,10 +179,10 @@ def allTests(communicator):
#
initData = Ice.InitializationData()
initData.properties = communicator.getProperties().clone()
- initData.properties.setProperty("Ice.Override.Timeout", "100")
+ initData.properties.setProperty("Ice.Override.Timeout", "250")
comm = Ice.initialize(initData)
to = Test.TimeoutPrx.checkedCast(comm.stringToProxy(sref))
- timeout.holdAdapter(500)
+ timeout.holdAdapter(700)
try:
to.sendData(seq)
test(False)
@@ -194,7 +193,7 @@ def allTests(communicator):
#
timeout.op() # Ensure adapter is active.
to = Test.TimeoutPrx.checkedCast(to.ice_timeout(1000))
- timeout.holdAdapter(500);
+ timeout.holdAdapter(500)
try:
to.sendData(seq)
test(False)
@@ -230,9 +229,9 @@ def allTests(communicator):
# 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(250));
+ to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(250))
to.ice_getConnection(); # Establish connection
- timeout.holdAdapter(750);
+ timeout.holdAdapter(750)
try:
to.sendData(seq)
test(False)
@@ -247,11 +246,11 @@ def allTests(communicator):
initData.properties = communicator.getProperties().clone()
initData.properties.setProperty("Ice.Override.CloseTimeout", "100")
comm = Ice.initialize(initData)
- connection = comm.stringToProxy(sref).ice_getConnection();
- timeout.holdAdapter(800);
- now = time.clock();
- comm.destroy();
- test((time.clock() - now) < 0.7);
+ connection = comm.stringToProxy(sref).ice_getConnection()
+ timeout.holdAdapter(800)
+ now = time.clock()
+ comm.destroy()
+ test((time.clock() - now) < 0.7)
print("ok")
diff --git a/python/test/Ice/timeout/Client.py b/python/test/Ice/timeout/Client.py
index cf8c193ee70..2e1a5dbf3bd 100755
--- a/python/test/Ice/timeout/Client.py
+++ b/python/test/Ice/timeout/Client.py
@@ -58,17 +58,10 @@ try:
#
initData.properties.setProperty("Ice.TCP.SndSize", "50000");
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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
index bfffcd560ba..8834fe8d1ce 100755
--- a/python/test/Ice/timeout/Server.py
+++ b/python/test/Ice/timeout/Server.py
@@ -29,7 +29,7 @@ class ActivateAdapterThread(threading.Thread):
time.sleep(self._timeout / 1000.0)
self._adapter.activate()
-class TimeoutI(Test.Timeout):
+class TimeoutI(Test._TimeoutDisp):
def op(self, current=None):
pass
@@ -51,7 +51,7 @@ class TimeoutI(Test.Timeout):
def run(args, communicator):
communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
adapter = communicator.createObjectAdapter("TestAdapter")
- adapter.add(TimeoutI(), communicator.stringToIdentity("timeout"))
+ adapter.add(TimeoutI(), Ice.stringToIdentity("timeout"))
adapter.activate()
communicator.waitForShutdown()
return True
@@ -65,17 +65,10 @@ try:
# 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)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/run.py b/python/test/Ice/timeout/run.py
deleted file mode 100755
index 1a8297794cd..00000000000
--- a/python/test/Ice/timeout/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/Slice/escape/Clash.ice b/python/test/Slice/escape/Clash.ice
new file mode 100644
index 00000000000..63df89f2e7b
--- /dev/null
+++ b/python/test/Slice/escape/Clash.ice
@@ -0,0 +1,69 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2016 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.
+//
+// **********************************************************************
+
+[["underscore"]]
+
+module Clash
+{
+
+interface Intf
+{
+ void context();
+ void current();
+ void response();
+ void upCast();
+ void typeId();
+ void del();
+ void cookie();
+ void sync();
+ void inS();
+ void istr();
+
+ void op(string context, string current, string response, string ex, string sent, string cookie,
+ string sync, string result, string istr, string ostr, optional(1) string proxy);
+ void opOut(out string context, out string current, out string response, out string ex,
+ out string sent, out string cookie, out string sync, out string result, out string istr,
+ out string ostr, out optional(1) string proxy);
+};
+
+class Cls
+{
+ Intf* s;
+ string context;
+ int current;
+ short response;
+ string upCast;
+ int typeId;
+ short del;
+ optional(1) short cookie;
+ string ex;
+ int result;
+ string istr;
+ string ostr;
+ string inS;
+ string in;
+ string proxy;
+};
+
+struct St
+{
+ string v;
+ short istr;
+ int ostr;
+ int rhs;
+ string other;
+};
+
+exception Ex
+{
+ short istr;
+ int ostr;
+};
+
+};
diff --git a/python/test/Slice/keyword/Client.py b/python/test/Slice/escape/Client.py
index 710eb343f6b..1d91d29d434 100755
--- a/python/test/Slice/keyword/Client.py
+++ b/python/test/Slice/escape/Client.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# **********************************************************************
#
-# Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
+# Copyright (c) 2003-2016 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.
@@ -20,22 +20,20 @@ else:
import Ice
Ice.loadSlice('Key.ice')
+Ice.loadSlice('Clash.ice')
+
import _and
-class delI(_and._del):
- def _elif_async(self, _cb, _else, current=None):
+class delI(_and._delDisp):
+ def _elifAsync(self, _else, current=None):
pass
-class execI(_and._exec):
+class execI(_and._execDisp):
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):
+class ifI(_and._ifDisp):
+ def _elifAsync(self, _else, current=None):
pass
def _finally(self, current=None):
pass
@@ -59,7 +57,7 @@ def testtypes():
assert "_finally" in dir(_and.execPrx)
d1 = execI()
- e1 = forI()
+ e1 = _and._for()
f = _and.ifPrx.uncheckedCast(None)
assert "_finally" in dir(_and.ifPrx)
@@ -79,13 +77,13 @@ def testtypes():
def run(args, communicator):
communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
adapter = communicator.createObjectAdapter("TestAdapter")
- adapter.add(execI(), communicator.stringToIdentity("test"))
+ adapter.add(execI(), Ice.stringToIdentity("test"))
adapter.activate()
sys.stdout.write("Testing operation name... ")
sys.stdout.flush()
p = _and.execPrx.uncheckedCast(
- adapter.createProxy(communicator.stringToIdentity("test")));
+ adapter.createProxy(Ice.stringToIdentity("test")));
p._finally();
print("ok")
@@ -102,17 +100,10 @@ try:
# this warning.
#
initData.properties.setProperty("Ice.Warn.Dispatch", "0");
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/escape/Key.ice
index 39b462dd9e2..6c27b307d09 100644
--- a/python/test/Slice/keyword/Key.ice
+++ b/python/test/Slice/escape/Key.ice
@@ -1,6 +1,6 @@
// **********************************************************************
//
-// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
+// Copyright (c) 2003-2016 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.
@@ -32,10 +32,11 @@ module and
class for
{
int lambda;
- void foo(exec* from, out int global);
+ exec* from;
+ int global;
};
- class if extends for implements exec, del
+ interface if extends exec, del
{
};
@@ -46,6 +47,7 @@ module and
{
int lambda;
};
+
exception not extends is
{
int or;
@@ -54,14 +56,15 @@ module and
local interface print
{
- assert raise(continue else, for return, if try, del* while, exec* yield,
- for* lambda, if* or, int global)
- throws is;
+ 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 {
+ enum EnumNone
+ {
None
};
};
diff --git a/python/test/Slice/import/.depend.mak b/python/test/Slice/import/.depend.mak
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/python/test/Slice/import/.depend.mak
+++ /dev/null
diff --git a/python/test/Slice/import/run.py b/python/test/Slice/import/run.py
deleted file mode 100755
index cc9f8b41d2f..00000000000
--- a/python/test/Slice/import/run.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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, shutil, subprocess
-
-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
-
-testdir = os.path.dirname(os.path.abspath(__file__))
-
-if os.path.exists(os.path.join(testdir, "Test1_ice.py")):
- os.remove(os.path.join(testdir, "Test1_ice.py"))
-if os.path.exists(os.path.join(testdir, "Test2_ice.py")):
- os.remove(os.path.join(testdir, "Test2_ice.py"))
-if os.path.exists(os.path.join(testdir, "Test")):
- shutil.rmtree(os.path.join(testdir, "Test"))
-
-if os.environ.get("USE_BIN_DIST", "no") == "yes":
- if TestUtil.isDarwin():
- slice2py = sys.executable + " /usr/local/bin/slice2py"
- elif TestUtil.isWin32():
- pythonHome = os.path.dirname(sys.executable)
- slice2py = os.path.join(pythonHome, "Scripts", "slice2py.exe")
- elif os.path.isfile(os.path.join(TestUtil.getCppBinDir(), "slice2py")):
- slice2py = os.path.join(TestUtil.getCppBinDir(), "slice2py")
- else:
- import slice2py
- slice2py = sys.executable + " " + os.path.normpath(os.path.join(slice2py.__file__, "..", "..", "..", "..", "bin", "slice2py"))
-else:
- if TestUtil.isYocto():
- slice2py = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "..", "..", "cpp", "bin", "slice2py")
- else:
- slice2py = sys.executable + " " + os.path.join(path[0], "python", "config", "s2py.py")
-
-s2p = TestUtil.spawn(slice2py + " Test1.ice")
-s2p.waitTestSuccess()
-s2p = TestUtil.spawn(slice2py + " Test2.ice")
-s2p.waitTestSuccess()
-
-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/import/test.py b/python/test/Slice/import/test.py
new file mode 100644
index 00000000000..6a0343d1e4e
--- /dev/null
+++ b/python/test/Slice/import/test.py
@@ -0,0 +1,26 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2016 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.
+#
+# **********************************************************************
+
+class SliceImportTestCase(ClientTestCase):
+
+ def setupClientSide(self, current):
+
+ testdir = current.testcase.getPath()
+ if os.path.exists(os.path.join(testdir, "Test1_ice.py")):
+ os.remove(os.path.join(testdir, "Test1_ice.py"))
+ if os.path.exists(os.path.join(testdir, "Test2_ice.py")):
+ os.remove(os.path.join(testdir, "Test2_ice.py"))
+ if os.path.exists(os.path.join(testdir, "Test")):
+ shutil.rmtree(os.path.join(testdir, "Test"))
+
+ slice2py = SliceTranslator("slice2py")
+ slice2py.run(current, args=["Test1.ice"])
+ slice2py.run(current, args=["Test2.ice"])
+
+TestSuite(__name__, [ SliceImportTestCase() ]) \ No newline at end of file
diff --git a/python/test/Slice/keyword/run.py b/python/test/Slice/keyword/run.py
deleted file mode 100755
index b7fe1b9ed2c..00000000000
--- a/python/test/Slice/keyword/run.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/run.py b/python/test/Slice/macros/run.py
deleted file mode 100755
index b7fe1b9ed2c..00000000000
--- a/python/test/Slice/macros/run.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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
index b820506ec8b..2a9e23246db 100755
--- a/python/test/Slice/structure/Client.py
+++ b/python/test/Slice/structure/Client.py
@@ -195,17 +195,10 @@ def run(args, communicator):
try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
- communicator = Ice.initialize(sys.argv, initData)
- status = run(sys.argv, communicator)
+ with Ice.initialize(sys.argv, initData) as communicator:
+ 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/run.py b/python/test/Slice/structure/run.py
deleted file mode 100755
index b7fe1b9ed2c..00000000000
--- a/python/test/Slice/structure/run.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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/unicodePaths/run.py b/python/test/Slice/unicodePaths/run.py
deleted file mode 100644
index d192cc607ce..00000000000
--- a/python/test/Slice/unicodePaths/run.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# **********************************************************************
-#
-# Copyright (c) 2003-2017 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, locale, shutil
-
-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
-
-def test(b):
- if not b:
- print("failed!")
- sys.exit(1)
-
-if TestUtil.isAIX() or TestUtil.isLinux():
- encoding = locale.getdefaultlocale()[1]
- if encoding != "UTF-8":
- print("Please set LC_ALL to xx_xx.UTF-8, for example FR_FR.UTF-8")
- print("Skipping test")
- sys.exit(0)
-
-if sys.version_info[0] == 2 and TestUtil.isWin32():
- print("To run this test on Windows you need to be using Python 3.x")
- print("Python 2.x subprocess module doesn't support unicode on Windows")
- print("Skipping test")
- sys.exit(0)
-
-if os.environ.get("USE_BIN_DIST", "no") == "yes":
- if TestUtil.isDarwin():
- slice2py = sys.executable + " /usr/local/bin/slice2py"
- elif TestUtil.isWin32():
- pythonHome = os.path.dirname(sys.executable)
- slice2py = os.path.join(pythonHome, "Scripts", "slice2py.exe")
- elif os.path.isfile(os.path.join(TestUtil.getCppBinDir(), "slice2py")):
- slice2py = os.path.join(TestUtil.getCppBinDir(), "slice2py")
- else:
- import slice2py
- slice2py = sys.executable + " " + os.path.normpath(os.path.join(slice2py.__file__, "..", "..", "..", "..", "bin", "slice2py"))
-else:
- if TestUtil.isYocto():
- slice2py = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "..", "..", "cpp", "bin", "slice2py")
- else:
- slice2py = sys.executable + " " + os.path.join(path[0], "python", "config", "s2py.py")
-
-sys.stdout.write("testing Slice compiler and unicode file paths... ")
-sys.stdout.flush()
-
-#
-# Write config
-#
-if sys.version_info[0] == 2:
- srcPath = "./\xe4\xb8\xad\xe5\x9b\xbd".decode("utf-8")
-else:
- srcPath = "./\u4e2d\u56fd"
-if os.path.exists(srcPath):
- shutil.rmtree(srcPath)
-os.mkdir(srcPath)
-TestUtil.createFile("%s/Test.ice" % srcPath, ["module Test { ",
- "class Point{int x; int y; };",
- "interface Canvas{ void draw(Point p); };",
- "};"], "utf-8")
-p = TestUtil.runCommand('%s %s/Test.ice --output-dir %s' % (slice2py, srcPath, srcPath))
-test(p.wait() == 0)
-test(os.path.isfile("%s/Test_ice.py" % srcPath))
-
-if os.path.exists(srcPath):
- shutil.rmtree(srcPath)
-print("ok")