diff options
author | Mark Spruiell <mes@zeroc.com> | 2012-05-16 16:05:50 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2012-05-16 16:05:50 -0700 |
commit | 3b6fbd2cb1ab0e9f6dbdfd4cbda02eb16fd85569 (patch) | |
tree | edfa533e67fb4ee003d1afbb2e1ba8a9b03ef3f3 /py/test | |
parent | porting ami test changes to python (diff) | |
download | ice-3b6fbd2cb1ab0e9f6dbdfd4cbda02eb16fd85569.tar.bz2 ice-3b6fbd2cb1ab0e9f6dbdfd4cbda02eb16fd85569.tar.xz ice-3b6fbd2cb1ab0e9f6dbdfd4cbda02eb16fd85569.zip |
* Ruby port of sliced/compact/preserved
* Python clean up
* More changes to exceptions test
Diffstat (limited to 'py/test')
-rw-r--r-- | py/test/Ice/proxy/AllTests.py | 60 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/AllTests.py | 22 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/ClientPrivate.ice | 2 | ||||
-rwxr-xr-x | py/test/Ice/slicing/exceptions/Server.py | 32 | ||||
-rwxr-xr-x | py/test/Ice/slicing/exceptions/ServerAMD.py | 32 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/ServerPrivate.ice | 15 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/Test.ice | 11 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/TestAMD.ice | 11 | ||||
-rw-r--r-- | py/test/Ice/slicing/objects/AllTests.py | 4 |
9 files changed, 150 insertions, 39 deletions
diff --git a/py/test/Ice/proxy/AllTests.py b/py/test/Ice/proxy/AllTests.py index da1db1f2324..6cb4507bf6c 100644 --- a/py/test/Ice/proxy/AllTests.py +++ b/py/test/Ice/proxy/AllTests.py @@ -293,14 +293,14 @@ def allTests(communicator, collocated): prop.setProperty(property, "6.5") try: communicator.propertyToProxy(propertyPrefix) - test(false) + test(False) except Ice.UnsupportedEncodingException: pass prop.setProperty(property, "1.2") - try : + try: communicator.propertyToProxy(propertyPrefix) - test(false) + test(False) except Ice.UnsupportedEncodingException: pass prop.setProperty(property, "") @@ -311,7 +311,7 @@ def allTests(communicator, collocated): sys.stdout.flush() b1 = communicator.stringToProxy("test") - #b1 = b1.ice_collocationOptimized(true) + #b1 = b1.ice_collocationOptimized(True) b1 = b1.ice_connectionCached(True) b1 = b1.ice_preferSecure(False) b1 = b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered) @@ -319,14 +319,14 @@ def allTests(communicator, collocated): b1 = b1.ice_encodingVersion(Ice.EncodingVersion(1, 0)) router = communicator.stringToProxy("router") - #router = router.ice_collocationOptimized(false) + #router = router.ice_collocationOptimized(False) router = router.ice_connectionCached(True) router = router.ice_preferSecure(True) router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random) router = router.ice_locatorCacheTimeout(200) locator = communicator.stringToProxy("locator") - #locator = locator.ice_collocationOptimized(true) + #locator = locator.ice_collocationOptimized(True) locator = locator.ice_connectionCached(False) locator = locator.ice_preferSecure(True) locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random) @@ -340,7 +340,7 @@ def allTests(communicator, collocated): test(proxyProps["Test"] == "test -t") #test(proxyProps["Test.CollocationOptimized"] == "1") - test(proxyProps["Test.EncodingVersion"] == "1.0"); + test(proxyProps["Test.EncodingVersion"] == "1.0") test(proxyProps["Test.ConnectionCached"] == "1") test(proxyProps["Test.PreferSecure"] == "0") test(proxyProps["Test.EndpointSelection"] == "Ordered") @@ -348,14 +348,14 @@ def allTests(communicator, collocated): test(proxyProps["Test.Locator"] == "locator -t") #test(proxyProps["Test.Locator.CollocationOptimized"] == "1") - test(proxyProps["Test.Locator.EncodingVersion"] == Ice.encodingVersionToString(Ice.currentEncoding())); + test(proxyProps["Test.Locator.EncodingVersion"] == Ice.encodingVersionToString(Ice.currentEncoding())) test(proxyProps["Test.Locator.ConnectionCached"] == "0") test(proxyProps["Test.Locator.PreferSecure"] == "1") test(proxyProps["Test.Locator.EndpointSelection"] == "Random") test(proxyProps["Test.Locator.LocatorCacheTimeout"] == "300") test(proxyProps["Test.Locator.Router"] == "router -t") - test(proxyProps["Test.Locator.Router.EncodingVersion"] == Ice.encodingVersionToString(Ice.currentEncoding())); + test(proxyProps["Test.Locator.Router.EncodingVersion"] == Ice.encodingVersionToString(Ice.currentEncoding())) #test(proxyProps["Test.Locator.Router.CollocationOptimized"] == "0") test(proxyProps["Test.Locator.Router.ConnectionCached"] == "1") test(proxyProps["Test.Locator.Router.PreferSecure"] == "1") @@ -363,8 +363,8 @@ def allTests(communicator, collocated): test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"] == "200") try: - b1.ice_encodingVersion(Ice.EncodingVersion(3, 4)); - test(false); + b1.ice_encodingVersion(Ice.EncodingVersion(3, 4)) + test(False) except Ice.UnsupportedEncodingException: pass @@ -390,13 +390,13 @@ def allTests(communicator, collocated): test(base.ice_batchDatagram().ice_isBatchDatagram()) test(base.ice_secure(True).ice_isSecure()) test(not base.ice_secure(False).ice_isSecure()) - #test(base.ice_collocationOptimized(true)->ice_isCollocationOptimized()) - #test(!base.ice_collocationOptimized(false)->ice_isCollocationOptimized()) + #test(base.ice_collocationOptimized(True)->ice_isCollocationOptimized()) + #test(!base.ice_collocationOptimized(False)->ice_isCollocationOptimized()) test(base.ice_preferSecure(True).ice_isPreferSecure()) test(not base.ice_preferSecure(False).ice_isPreferSecure()) - test(base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion() == Ice.Encoding_1_0); - test(base.ice_encodingVersion(Ice.Encoding_1_1).ice_getEncodingVersion() == Ice.Encoding_1_1); - test(base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion() != Ice.Encoding_1_1); + test(base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion() == Ice.Encoding_1_0) + test(base.ice_encodingVersion(Ice.Encoding_1_1).ice_getEncodingVersion() == Ice.Encoding_1_1) + test(base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion() != Ice.Encoding_1_1) print("ok") sys.stdout.write("testing proxy comparison... ") @@ -471,7 +471,7 @@ def allTests(communicator, collocated): test(not (compObj.ice_locator(loc1) < compObj.ice_locator(None))) test(compObj.ice_locator(loc1) < compObj.ice_locator(loc2)) test(not (compObj.ice_locator(loc2) < compObj.ice_locator(loc1))) - + rtr1 = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("rtr1:default -p 10000")) rtr2 = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("rtr2:default -p 10000")) test(compObj.ice_router(None) == compObj.ice_router(None)) @@ -495,12 +495,12 @@ def allTests(communicator, collocated): test(compObj.ice_context(ctx1) != compObj.ice_context(ctx2)) test(compObj.ice_context(ctx1) < compObj.ice_context(ctx2)) test(not (compObj.ice_context(ctx2) < compObj.ice_context(ctx1))) - + test(compObj.ice_preferSecure(True) == compObj.ice_preferSecure(True)) test(compObj.ice_preferSecure(True) != compObj.ice_preferSecure(False)) test(compObj.ice_preferSecure(False) < compObj.ice_preferSecure(True)) test(not (compObj.ice_preferSecure(True) < compObj.ice_preferSecure(False))) - + compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000") compObj2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001") test(compObj1 != compObj2) @@ -531,10 +531,10 @@ def allTests(communicator, collocated): test(not (endpts2 < endpts1)) test(endpts1 == communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints()) - test(compObj1.ice_encodingVersion(Ice.Encoding_1_0) == compObj1.ice_encodingVersion(Ice.Encoding_1_0)); - test(compObj1.ice_encodingVersion(Ice.Encoding_1_0) != compObj1.ice_encodingVersion(Ice.Encoding_1_1)); - test(compObj.ice_encodingVersion(Ice.Encoding_1_0) < compObj.ice_encodingVersion(Ice.Encoding_1_1)); - test(not (compObj.ice_encodingVersion(Ice.Encoding_1_1) < compObj.ice_encodingVersion(Ice.Encoding_1_0))); + test(compObj1.ice_encodingVersion(Ice.Encoding_1_0) == compObj1.ice_encodingVersion(Ice.Encoding_1_0)) + test(compObj1.ice_encodingVersion(Ice.Encoding_1_0) != compObj1.ice_encodingVersion(Ice.Encoding_1_1)) + test(compObj.ice_encodingVersion(Ice.Encoding_1_0) < compObj.ice_encodingVersion(Ice.Encoding_1_1)) + test(not (compObj.ice_encodingVersion(Ice.Encoding_1_1) < compObj.ice_encodingVersion(Ice.Encoding_1_0))) # # TODO: Ideally we should also test comparison of fixed proxies. @@ -666,15 +666,15 @@ def allTests(communicator, collocated): p1 = communicator.stringToProxy("test:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA==") pstr = communicator.proxyToString(p1) test(pstr == "test -t:tcp -h 127.0.0.1 -p 12010 -t 10000") - + # 1.1 TCP endpoint encoded with 1.1 encoding. - p2 = communicator.stringToProxy("test:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAAEAAQE="); - test(communicator.proxyToString(p2) == "test -t:tcp -e 1.1 -h 127.0.0.1 -p 12010 -t 10000"); - + p2 = communicator.stringToProxy("test:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAAEAAQE=") + test(communicator.proxyToString(p2) == "test -t:tcp -e 1.1 -h 127.0.0.1 -p 12010 -t 10000") + # 1.0 TCP endpoint encoded with 1.1 encoding. - p2 = communicator.stringToProxy("test: opaque -t 1 -e 1.1 -v CTEyNy4wLjAuMeouAAAQJwAAAAEAAQA="); - test(communicator.proxyToString(p2) == "test -t:tcp -h 127.0.0.1 -p 12010 -t 10000"); - + p2 = communicator.stringToProxy("test: opaque -t 1 -e 1.1 -v CTEyNy4wLjAuMeouAAAQJwAAAAEAAQA=") + test(communicator.proxyToString(p2) == "test -t:tcp -h 127.0.0.1 -p 12010 -t 10000") + if communicator.getProperties().getPropertyAsInt("Ice.IPv6") == 0: # Working? ssl = communicator.getProperties().getProperty("Ice.Default.Protocol") == "ssl" diff --git a/py/test/Ice/slicing/exceptions/AllTests.py b/py/test/Ice/slicing/exceptions/AllTests.py index 079212fe755..aa77f42e009 100644 --- a/py/test/Ice/slicing/exceptions/AllTests.py +++ b/py/test/Ice/slicing/exceptions/AllTests.py @@ -185,21 +185,24 @@ class Callback(CallbackBase): class RelayI(Test.Relay): def knownPreservedAsBase(self, current=None): - ex = Test.KnownPreserved() + ex = Test.KnownPreservedDerived() ex.b = "base" ex.kp = "preserved" + ex.kpd = "derived" raise ex def knownPreservedAsKnownPreserved(self, current=None): - ex = Test.KnownPreserved() + ex = Test.KnownPreservedDerived() ex.b = "base" ex.kp = "preserved" + ex.kpd = "derived" raise ex def unknownPreservedAsBase(self, current=None): ex = Test.Preserved2() ex.b = "base" ex.kp = "preserved" + ex.kpd = "derived" ex.p1 = Test.PreservedClass("bc", "pc") ex.p2 = ex.p1 raise ex @@ -208,6 +211,7 @@ class RelayI(Test.Relay): ex = Test.Preserved2() ex.b = "base" ex.kp = "preserved" + ex.kpd = "derived" ex.p1 = Test.PreservedClass("bc", "pc") ex.p2 = ex.p1 raise ex @@ -504,18 +508,20 @@ def allTests(communicator): try: t.relayKnownPreservedAsBase(relay) test(False) - except Test.KnownPreserved as ex: + except Test.KnownPreservedDerived as ex: test(ex.b == "base") test(ex.kp == "preserved") + test(ex.kpd == "derived") except: test(False) try: t.relayKnownPreservedAsKnownPreserved(relay) test(False) - except Test.KnownPreserved as ex: + except Test.KnownPreservedDerived as ex: test(ex.b == "base") test(ex.kp == "preserved") + test(ex.kpd == "derived") except: test(False) @@ -525,19 +531,21 @@ def allTests(communicator): except Test.Preserved2 as ex: test(ex.b == "base") test(ex.kp == "preserved") + test(ex.kpd == "derived") test(ex.p1.ice_id() == Test.PreservedClass.ice_staticId()) pc = ex.p1 test(isinstance(pc, Test.PreservedClass)) test(pc.bc == "bc") test(pc.pc == "pc") test(ex.p2 == ex.p1) - except Test.KnownPreserved as ex: + except Test.KnownPreservedDerived as ex: # # For the 1.0 encoding, the unknown exception is sliced to KnownPreserved. # test(t.ice_getEncodingVersion() == Ice.Encoding_1_0) test(ex.b == "base") test(ex.kp == "preserved") + test(ex.kpd == "derived") except: test(False) @@ -547,19 +555,21 @@ def allTests(communicator): except Test.Preserved2 as ex: test(ex.b == "base") test(ex.kp == "preserved") + test(ex.kpd == "derived") test(ex.p1.ice_id() == Test.PreservedClass.ice_staticId()) pc = ex.p1 test(isinstance(pc, Test.PreservedClass)) test(pc.bc == "bc") test(pc.pc == "pc") test(ex.p2 == ex.p1) - except Test.KnownPreserved as ex: + except Test.KnownPreservedDerived as ex: # # For the 1.0 encoding, the unknown exception is sliced to KnownPreserved. # test(t.ice_getEncodingVersion() == Ice.Encoding_1_0) test(ex.b == "base") test(ex.kp == "preserved") + test(ex.kpd == "derived") except: test(False) diff --git a/py/test/Ice/slicing/exceptions/ClientPrivate.ice b/py/test/Ice/slicing/exceptions/ClientPrivate.ice index 9b2e381798a..029e6d5d37e 100644 --- a/py/test/Ice/slicing/exceptions/ClientPrivate.ice +++ b/py/test/Ice/slicing/exceptions/ClientPrivate.ice @@ -19,7 +19,7 @@ class PreservedClass extends BaseClass string pc; }; -exception Preserved1 extends KnownPreserved +exception Preserved1 extends KnownPreservedDerived { BaseClass p1; }; diff --git a/py/test/Ice/slicing/exceptions/Server.py b/py/test/Ice/slicing/exceptions/Server.py index eb0c585a9b6..a880f12b335 100755 --- a/py/test/Ice/slicing/exceptions/Server.py +++ b/py/test/Ice/slicing/exceptions/Server.py @@ -107,12 +107,44 @@ class TestI(Test.TestIntf): umd2.umd2 = "UnknownMostDerived2.umd2" raise umd2 + def knownPreservedAsBase(self, current=None): + ex = Test.KnownPreservedDerived() + ex.b = "base" + ex.kp = "preserved" + ex.kpd = "derived" + raise ex + + def knownPreservedAsKnownPreserved(self, current=None): + ex = Test.KnownPreservedDerived() + ex.b = "base" + ex.kp = "preserved" + ex.kpd = "derived" + raise ex + def relayKnownPreservedAsBase(self, r, current=None): r.knownPreservedAsBase() def relayKnownPreservedAsKnownPreserved(self, r, current=None): r.knownPreservedAsKnownPreserved() + def unknownPreservedAsBase(self, current=None): + ex = Test.SPreserved2() + ex.b = "base" + ex.kp = "preserved" + ex.kpd = "derived" + ex.p1 = Test.SPreservedClass("bc", "spc") + ex.p2 = ex.p1 + raise ex + + def unknownPreservedAsKnownPreserved(self, current=None): + ex = Test.SPreserved2() + ex.b = "base" + ex.kp = "preserved" + ex.kpd = "derived" + ex.p1 = Test.SPreservedClass("bc", "spc") + ex.p2 = ex.p1 + raise ex + def relayUnknownPreservedAsBase(self, r, current=None): r.unknownPreservedAsBase() diff --git a/py/test/Ice/slicing/exceptions/ServerAMD.py b/py/test/Ice/slicing/exceptions/ServerAMD.py index 426550025dd..7bc152bbd90 100755 --- a/py/test/Ice/slicing/exceptions/ServerAMD.py +++ b/py/test/Ice/slicing/exceptions/ServerAMD.py @@ -109,6 +109,20 @@ class TestI(Test.TestIntf): umd2.umd2 = "UnknownMostDerived2.umd2" cb.ice_exception(umd2) + def knownPreservedAsBase_async(self, cb, r, current=None): + ex = Test.KnownPreservedDerived() + ex.b = "base" + ex.kp = "preserved" + ex.kpd = "derived" + cb.ice_exception(ex) + + def knownPreservedAsKnownPreserved_async(self, cb, r, current=None): + ex = Test.KnownPreservedDerived() + ex.b = "base" + ex.kp = "preserved" + ex.kpd = "derived" + cb.ice_exception(ex) + def relayKnownPreservedAsBase_async(self, cb, r, current=None): try: r.knownPreservedAsBase() @@ -123,6 +137,24 @@ class TestI(Test.TestIntf): except Ice.Exception as ex: cb.ice_exception(ex) + def unknownPreservedAsBase_async(self, cb, r, current=None): + ex = Test.SPreserved2() + ex.b = "base" + ex.kp = "preserved" + ex.kpd = "derived" + ex.p1 = Test.SPreservedClass("bc", "spc") + ex.p2 = ex.p1 + cb.ice_exception(ex) + + def unknownPreservedAsKnownPreserved_async(self, cb, r, current=None): + ex = Test.SPreserved2() + ex.b = "base" + ex.kp = "preserved" + ex.kpd = "derived" + ex.p1 = Test.SPreservedClass("bc", "spc") + ex.p2 = ex.p1 + cb.ice_exception(ex) + def relayUnknownPreservedAsBase_async(self, cb, r, current=None): try: r.unknownPreservedAsBase() diff --git a/py/test/Ice/slicing/exceptions/ServerPrivate.ice b/py/test/Ice/slicing/exceptions/ServerPrivate.ice index df89aa2efea..e03994a4641 100644 --- a/py/test/Ice/slicing/exceptions/ServerPrivate.ice +++ b/py/test/Ice/slicing/exceptions/ServerPrivate.ice @@ -34,4 +34,19 @@ exception UnknownMostDerived2 extends UnknownIntermediate string umd2; }; +class SPreservedClass extends BaseClass +{ + string spc; +}; + +exception SPreserved1 extends KnownPreservedDerived +{ + BaseClass p1; +}; + +exception SPreserved2 extends SPreserved1 +{ + BaseClass p2; +}; + }; diff --git a/py/test/Ice/slicing/exceptions/Test.ice b/py/test/Ice/slicing/exceptions/Test.ice index be67cb391e6..e558935d440 100644 --- a/py/test/Ice/slicing/exceptions/Test.ice +++ b/py/test/Ice/slicing/exceptions/Test.ice @@ -38,6 +38,11 @@ exception KnownPreserved extends Base string kp; }; +exception KnownPreservedDerived extends KnownPreserved +{ + string kpd; +}; + ["preserve-slice"] class BaseClass { @@ -75,9 +80,15 @@ interface TestIntf ["format:compact"] void unknownMostDerived2AsBaseCompact() throws Base; + void knownPreservedAsBase() throws Base; + void knownPreservedAsKnownPreserved() throws KnownPreserved; + void relayKnownPreservedAsBase(Relay* r) throws Base; void relayKnownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved; + void unknownPreservedAsBase() throws Base; + void unknownPreservedAsKnownPreserved() throws KnownPreserved; + void relayUnknownPreservedAsBase(Relay* r) throws Base; void relayUnknownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved; diff --git a/py/test/Ice/slicing/exceptions/TestAMD.ice b/py/test/Ice/slicing/exceptions/TestAMD.ice index fbf94f29a56..259a297fd63 100644 --- a/py/test/Ice/slicing/exceptions/TestAMD.ice +++ b/py/test/Ice/slicing/exceptions/TestAMD.ice @@ -38,6 +38,11 @@ exception KnownPreserved extends Base string kp; }; +exception KnownPreservedDerived extends KnownPreserved +{ + string kpd; +}; + ["preserve-slice"] class BaseClass { @@ -75,9 +80,15 @@ interface TestIntf ["format:compact"] void unknownMostDerived2AsBaseCompact() throws Base; + void knownPreservedAsBase() throws Base; + void knownPreservedAsKnownPreserved() throws KnownPreserved; + void relayKnownPreservedAsBase(Relay* r) throws Base; void relayKnownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved; + void unknownPreservedAsBase() throws Base; + void unknownPreservedAsKnownPreserved() throws KnownPreserved; + void relayUnknownPreservedAsBase(Relay* r) throws Base; void relayUnknownPreservedAsKnownPreserved(Relay* r) throws KnownPreserved; diff --git a/py/test/Ice/slicing/objects/AllTests.py b/py/test/Ice/slicing/objects/AllTests.py index f13cd7c6d8f..0ae2726c152 100644 --- a/py/test/Ice/slicing/objects/AllTests.py +++ b/py/test/Ice/slicing/objects/AllTests.py @@ -1482,7 +1482,7 @@ def allTests(communicator): # The object will be sliced to Preserved for the 1.0 encoding. # pcd = Test.PCDerived3() - pcd.pi = 3; + pcd.pi = 3 # # Sending more than 254 objects exercises the encoding for object ids. # @@ -1572,7 +1572,7 @@ def allTests(communicator): # The object will be sliced to Preserved for the 1.0 encoding. # pcd = Test.PCDerived3() - pcd.pi = 3; + pcd.pi = 3 # # Sending more than 254 objects exercises the encoding for object ids. # |