summaryrefslogtreecommitdiff
path: root/py/test/Ice/slicing/exceptions/AllTests.py
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2012-05-10 16:45:22 -0700
committerMark Spruiell <mes@zeroc.com>2012-05-10 16:45:22 -0700
commit485691562a75595eda00af35f5235f6fc22fa36c (patch)
tree4eaf48ac7512239a47d97e533cd3da1a75084f29 /py/test/Ice/slicing/exceptions/AllTests.py
parent* C++ implementation for compact/sliced formats (diff)
downloadice-485691562a75595eda00af35f5235f6fc22fa36c.tar.bz2
ice-485691562a75595eda00af35f5235f6fc22fa36c.tar.xz
ice-485691562a75595eda00af35f5235f6fc22fa36c.zip
C++ bug fixes; adding more Python tests
Diffstat (limited to 'py/test/Ice/slicing/exceptions/AllTests.py')
-rw-r--r--py/test/Ice/slicing/exceptions/AllTests.py122
1 files changed, 121 insertions, 1 deletions
diff --git a/py/test/Ice/slicing/exceptions/AllTests.py b/py/test/Ice/slicing/exceptions/AllTests.py
index 320cd195404..079212fe755 100644
--- a/py/test/Ice/slicing/exceptions/AllTests.py
+++ b/py/test/Ice/slicing/exceptions/AllTests.py
@@ -10,7 +10,7 @@
import Ice, threading, sys
-Ice.loadSlice('Test.ice')
+Ice.loadSlice('-I. --all ClientPrivate.ice')
import Test
def test(b):
@@ -183,6 +183,35 @@ class Callback(CallbackBase):
test(False)
self.called()
+class RelayI(Test.Relay):
+ def knownPreservedAsBase(self, current=None):
+ ex = Test.KnownPreserved()
+ ex.b = "base"
+ ex.kp = "preserved"
+ raise ex
+
+ def knownPreservedAsKnownPreserved(self, current=None):
+ ex = Test.KnownPreserved()
+ ex.b = "base"
+ ex.kp = "preserved"
+ raise ex
+
+ def unknownPreservedAsBase(self, current=None):
+ ex = Test.Preserved2()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.p1 = Test.PreservedClass("bc", "pc")
+ ex.p2 = ex.p1
+ raise ex
+
+ def unknownPreservedAsKnownPreserved(self, current=None):
+ ex = Test.Preserved2()
+ ex.b = "base"
+ ex.kp = "preserved"
+ ex.p1 = Test.PreservedClass("bc", "pc")
+ ex.p2 = ex.p1
+ raise ex
+
def allTests(communicator):
obj = communicator.stringToProxy("Test:default -p 12010")
t = Test.TestIntfPrx.checkedCast(obj)
@@ -446,4 +475,95 @@ def allTests(communicator):
cb.check()
print("ok")
+ sys.stdout.write("unknown most derived in compact format... ")
+ sys.stdout.flush()
+ try:
+ t.unknownMostDerived2AsBaseCompact()
+ test(False)
+ except Test.Base:
+ #
+ # For the 1.0 encoding, the unknown exception is sliced to Base.
+ #
+ test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
+ except Ice.MarshalException:
+ #
+ # A MarshalException is raised for the compact format because the
+ # most-derived type is unknown and the exception cannot be sliced.
+ #
+ test(t.ice_getEncodingVersion() != Ice.Encoding_1_0)
+ except:
+ test(False)
+ print("ok")
+
+ sys.stdout.write("preserved exceptions... ")
+ sys.stdout.flush()
+ adapter = communicator.createObjectAdapterWithEndpoints("Relay", "default")
+ relay = Test.RelayPrx.uncheckedCast(adapter.addWithUUID(RelayI()))
+ adapter.activate()
+
+ try:
+ t.relayKnownPreservedAsBase(relay)
+ test(False)
+ except Test.KnownPreserved as ex:
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ except:
+ test(False)
+
+ try:
+ t.relayKnownPreservedAsKnownPreserved(relay)
+ test(False)
+ except Test.KnownPreserved as ex:
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ except:
+ test(False)
+
+ try:
+ t.relayUnknownPreservedAsBase(relay)
+ test(False)
+ except Test.Preserved2 as ex:
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ test(ex.p1.ice_id() == Test.PreservedClass.ice_staticId())
+ pc = ex.p1
+ test(isinstance(pc, Test.PreservedClass))
+ test(pc.bc == "bc")
+ test(pc.pc == "pc")
+ test(ex.p2 == ex.p1)
+ except Test.KnownPreserved as ex:
+ #
+ # For the 1.0 encoding, the unknown exception is sliced to KnownPreserved.
+ #
+ test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ except:
+ test(False)
+
+ try:
+ t.relayUnknownPreservedAsKnownPreserved(relay)
+ test(False)
+ except Test.Preserved2 as ex:
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ test(ex.p1.ice_id() == Test.PreservedClass.ice_staticId())
+ pc = ex.p1
+ test(isinstance(pc, Test.PreservedClass))
+ test(pc.bc == "bc")
+ test(pc.pc == "pc")
+ test(ex.p2 == ex.p1)
+ except Test.KnownPreserved as ex:
+ #
+ # For the 1.0 encoding, the unknown exception is sliced to KnownPreserved.
+ #
+ test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
+ test(ex.b == "base")
+ test(ex.kp == "preserved")
+ except:
+ test(False)
+
+ adapter.destroy()
+ print("ok")
+
return t