diff options
author | Bernard Normier <bernard@zeroc.com> | 2019-04-12 17:09:41 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2019-04-12 17:16:24 -0400 |
commit | 7ef0d2af9c2a1f031cf46f9dbb0092295fc7cffe (patch) | |
tree | e631373222d873ad4dec401bb41da22fdfd8a923 | |
parent | Regenerate test projects (diff) | |
download | ice-7ef0d2af9c2a1f031cf46f9dbb0092295fc7cffe.tar.bz2 ice-7ef0d2af9c2a1f031cf46f9dbb0092295fc7cffe.tar.xz ice-7ef0d2af9c2a1f031cf46f9dbb0092295fc7cffe.zip |
Removed throws from some proxy methods
-rw-r--r-- | cpp/include/Ice/Proxy.h | 12 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 6 | ||||
-rw-r--r-- | swift/src/Ice/Proxy.swift | 192 | ||||
-rw-r--r-- | swift/src/IceObjc/IceObjcObjectPrx.h | 1 | ||||
-rw-r--r-- | swift/src/IceObjc/ObjectPrx.mm | 5 | ||||
-rw-r--r-- | swift/test/Ice/adapterDeactivation/AllTests.swift | 2 | ||||
-rw-r--r-- | swift/test/Ice/exceptions/Client.swift | 6 | ||||
-rw-r--r-- | swift/test/Ice/operations/BatchOneways.swift | 4 | ||||
-rw-r--r-- | swift/test/Ice/operations/BatchOnewaysAMI.swift | 2 | ||||
-rw-r--r-- | swift/test/Ice/proxy/AllTests.swift | 136 |
10 files changed, 213 insertions, 153 deletions
diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index c52ca6a59cb..4056f04a515 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -993,6 +993,12 @@ public: ::std::shared_ptr<::Ice::ObjectPrx> ice_fixed(const ::std::shared_ptr<::Ice::Connection>& connection) const; /** + * Determines whether this proxy is a fixed proxy. + * @return True if this proxy is a fixed proxy, false otherwise. + */ + bool ice_isFixed() const; + + /** * Obtains the Connection for this proxy. If the proxy does not yet have an established connection, * it first attempts to create a connection. * @return The connection for this proxy. @@ -2659,6 +2665,12 @@ public: ::Ice::ObjectPrx ice_fixed(const ::Ice::ConnectionPtr& connection) const; /** + * Determines whether this proxy is a fixed proxy. + * @return True if this proxy is a fixed proxy, false otherwise. + */ + bool ice_isFixed() const; + + /** * Obtains the Connection for this proxy. If the proxy does not yet have an established connection, * it first attempts to create a connection. * @return The connection for this proxy. diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index f2b6e188ceb..76b03fa86ff 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -1287,6 +1287,12 @@ ICE_OBJECT_PRX::ice_fixed(const ::Ice::ConnectionPtr& connection) const } } +bool +ICE_OBJECT_PRX::ice_isFixed() const +{ + return FixedReferencePtr::dynamicCast(_reference); +} + ConnectionPtr ICE_OBJECT_PRX::ice_getCachedConnection() const { diff --git a/swift/src/Ice/Proxy.swift b/swift/src/Ice/Proxy.swift index 783e46dd659..ca2b2c816c8 100644 --- a/swift/src/Ice/Proxy.swift +++ b/swift/src/Ice/Proxy.swift @@ -13,35 +13,35 @@ import PromiseKit public protocol ObjectPrx: CustomStringConvertible, AnyObject { func ice_getCommunicator() -> Communicator func ice_getIdentity() -> Identity - func ice_identity(_ id: Identity) throws -> Self + func ice_identity(_ id: Identity) -> ObjectPrx func ice_getContext() -> Context func ice_context(_ context: Context) -> Self func ice_getFacet() -> String func ice_facet(_ facet: String) -> ObjectPrx func ice_getAdapterId() -> String - func ice_adapterId(_ id: String) throws -> Self + func ice_adapterId(_ id: String) -> Self func ice_getEndpoints() -> EndpointSeq - func ice_endpoints(_ endpoints: EndpointSeq) throws -> Self + func ice_endpoints(_ endpoints: EndpointSeq) -> Self func ice_getLocatorCacheTimeout() -> Int32 - func ice_locatorCacheTimeout(_ timeout: Int32) throws -> Self + func ice_locatorCacheTimeout(_ timeout: Int32) -> Self func ice_getInvocationTimeout() -> Int32 - func ice_invocationTimeout(_ timeout: Int32) throws -> Self + func ice_invocationTimeout(_ timeout: Int32) -> Self func ice_getConnectionId() -> String - func ice_connectionId(_ id: String) throws -> Self + func ice_connectionId(_ id: String) -> Self func ice_isConnectionCached() -> Bool - func ice_connectionCached(_ cached: Bool) throws -> Self + func ice_connectionCached(_ cached: Bool) -> Self func ice_getEndpointSelection() -> EndpointSelectionType - func ice_endpointSelection(_ type: EndpointSelectionType) throws -> Self + func ice_endpointSelection(_ type: EndpointSelectionType) -> Self func ice_getEncodingVersion() -> EncodingVersion func ice_encodingVersion(_ encoding: EncodingVersion) -> Self func ice_getRouter() -> RouterPrx? - func ice_router(_ router: RouterPrx?) throws -> Self + func ice_router(_ router: RouterPrx?) -> Self func ice_getLocator() -> LocatorPrx? - func ice_locator(_ locator: LocatorPrx?) throws -> Self + func ice_locator(_ locator: LocatorPrx?) -> Self func ice_isSecure() -> Bool func ice_secure(_ secure: Bool) -> Self func ice_isPreferSecure() -> Bool - func ice_preferSecure(_ preferSecure: Bool) throws -> Self + func ice_preferSecure(_ preferSecure: Bool) -> Self func ice_isTwoway() -> Bool func ice_twoway() -> Self func ice_isOneway() -> Bool @@ -55,8 +55,9 @@ public protocol ObjectPrx: CustomStringConvertible, AnyObject { func ice_getCompress() -> Bool? func ice_compress(_ compress: Bool) -> Self func ice_getTimeout() -> Int32? - func ice_timeout(_ timeout: Int32) throws -> Self - func ice_fixed(_ connection: Connection) throws -> Self? + func ice_timeout(_ timeout: Int32) -> Self + func ice_fixed(_ connection: Connection) -> Self + func ice_isFixed() -> Bool func ice_getConnection() throws -> Connection? func ice_getCachedConnection() -> Connection? func ice_flushBatchRequests() throws @@ -65,7 +66,7 @@ public protocol ObjectPrx: CustomStringConvertible, AnyObject { sentFlags: DispatchWorkItemFlags?) -> Promise<Void> func ice_toString() -> String func ice_isCollocationOptimized() -> Bool - func ice_collocationOptimized(_ collocated: Bool) throws -> Self? + func ice_collocationOptimized(_ collocated: Bool) -> Self func ice_invoke(operation: String, mode: OperationMode, @@ -273,9 +274,14 @@ open class _ObjectPrxI: ObjectPrx { return Identity(name: name as String, category: category as String) } - public func ice_identity(_ id: Identity) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_identity(id.name, category: id.category)) + public func ice_identity(_ id: Identity) -> ObjectPrx { + precondition(!id.name.isEmpty, "Identity name cannot be empty") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_identity(id.name, category: id.category)) as _ObjectPrxI + } + } catch { + fatalError("\(error)") } } @@ -299,9 +305,14 @@ open class _ObjectPrxI: ObjectPrx { return _handle.ice_getAdapterId() } - public func ice_adapterId(_ id: String) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_adapterId(id)) + public func ice_adapterId(_ id: String) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with an adapterId") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_adapterId(id)) + } + } catch { + fatalError("\(error)") } } @@ -309,9 +320,14 @@ open class _ObjectPrxI: ObjectPrx { return _handle.ice_getEndpoints().fromObjc() } - public func ice_endpoints(_ endpoints: EndpointSeq) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_endpoints(endpoints.toObjc())) + public func ice_endpoints(_ endpoints: EndpointSeq) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with endpoints") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_endpoints(endpoints.toObjc())) + } + } catch { + fatalError("\(error)") } } @@ -319,9 +335,15 @@ open class _ObjectPrxI: ObjectPrx { return _handle.ice_getLocatorCacheTimeout() } - public func ice_locatorCacheTimeout(_ timeout: Int32) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_locatorCacheTimeout(timeout)) + public func ice_locatorCacheTimeout(_ timeout: Int32) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with a locatorCacheTimeout") + precondition(timeout >= -1, "Invalid locator cache timeout value") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_locatorCacheTimeout(timeout)) + } + } catch { + fatalError("\(error)") } } @@ -329,9 +351,14 @@ open class _ObjectPrxI: ObjectPrx { return _handle.ice_getInvocationTimeout() } - public func ice_invocationTimeout(_ timeout: Int32) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_invocationTimeout(timeout)) + public func ice_invocationTimeout(_ timeout: Int32) -> Self { + precondition(timeout >= 1 || timeout == -1 || timeout == -2, "Invalid invocation timeout value") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_invocationTimeout(timeout)) + } + } catch { + fatalError("\(error)") } } @@ -339,9 +366,14 @@ open class _ObjectPrxI: ObjectPrx { return _handle.ice_getConnectionId() } - public func ice_connectionId(_ id: String) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_connectionId(id)) + public func ice_connectionId(_ id: String) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with a connectionId") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_connectionId(id)) + } + } catch { + fatalError("\(error)") } } @@ -349,9 +381,14 @@ open class _ObjectPrxI: ObjectPrx { return _handle.ice_isConnectionCached() } - public func ice_connectionCached(_ cached: Bool) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_connectionCached(cached)) + public func ice_connectionCached(_ cached: Bool) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with a cached connection") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_connectionCached(cached)) + } + } catch { + fatalError("\(error)") } } @@ -359,9 +396,14 @@ open class _ObjectPrxI: ObjectPrx { return EndpointSelectionType(rawValue: _handle.ice_getEndpointSelection())! } - public func ice_endpointSelection(_ type: EndpointSelectionType) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_endpointSelection(type.rawValue)) + public func ice_endpointSelection(_ type: EndpointSelectionType) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with an endpointSelectionType") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_endpointSelection(type.rawValue)) + } + } catch { + fatalError("\(error)") } } @@ -380,10 +422,15 @@ open class _ObjectPrxI: ObjectPrx { return fromICEObjectPrx(routerHandle) as _RouterPrxI } - public func ice_router(_ router: RouterPrx?) throws -> Self { - return try autoreleasepool { - let r = router as? _RouterPrxI - return try fromICEObjectPrx(_handle.ice_router(r?._handle ?? nil)) + public func ice_router(_ router: RouterPrx?) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with a router") + do { + return try autoreleasepool { + let r = router as? _RouterPrxI + return try fromICEObjectPrx(_handle.ice_router(r?._handle ?? nil)) + } + } catch { + fatalError("\(error)") } } @@ -394,10 +441,15 @@ open class _ObjectPrxI: ObjectPrx { return fromICEObjectPrx(locatorHandle) as _LocatorPrxI } - public func ice_locator(_ locator: LocatorPrx?) throws -> Self { - return try autoreleasepool { - let l = locator as? _LocatorPrxI - return try fromICEObjectPrx(_handle.ice_locator(l?._handle ?? nil)) + public func ice_locator(_ locator: LocatorPrx?) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with a locator") + do { + return try autoreleasepool { + let l = locator as? _LocatorPrxI + return try fromICEObjectPrx(_handle.ice_locator(l?._handle ?? nil)) + } + } catch { + fatalError("\(error)") } } @@ -413,9 +465,14 @@ open class _ObjectPrxI: ObjectPrx { return _handle.ice_isPreferSecure() } - public func ice_preferSecure(_ preferSecure: Bool) throws -> Self { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_preferSecure(preferSecure)) + public func ice_preferSecure(_ preferSecure: Bool) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with preferSecure") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_preferSecure(preferSecure)) + } + } catch { + fatalError("\(error)") } } @@ -477,16 +534,32 @@ open class _ObjectPrxI: ObjectPrx { return timeout } - public func ice_timeout(_ timeout: Int32) throws -> Self { - return try fromICEObjectPrx(_handle.ice_timeout(timeout)) + public func ice_timeout(_ timeout: Int32) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with a connection timeout") + precondition(timeout > 0 || timeout == -1, "Invalid connection timeout value") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_timeout(timeout)) + } + } catch { + fatalError("\(error)") + } } - public func ice_fixed(_ connection: Connection) throws -> Self? { - return try autoreleasepool { - try fromICEObjectPrx(_handle.ice_fixed((connection as! ConnectionI)._handle)) + public func ice_fixed(_ connection: Connection) -> Self { + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_fixed((connection as! ConnectionI)._handle)) + } + } catch { + fatalError("\(error)") } } + public func ice_isFixed() -> Bool { + return _handle.ice_isFixed() + } + public func ice_getConnection() throws -> Connection? { return try autoreleasepool { // @@ -524,8 +597,15 @@ open class _ObjectPrxI: ObjectPrx { return _handle.ice_isCollocationOptimized() } - public func ice_collocationOptimized(_ collocated: Bool) throws -> Self? { - return try fromICEObjectPrx(_handle.ice_collocationOptimized(collocated)) + public func ice_collocationOptimized(_ collocated: Bool) -> Self { + precondition(!ice_isFixed(), "Cannot create a fixed proxy with collocation optimization") + do { + return try autoreleasepool { + try fromICEObjectPrx(_handle.ice_collocationOptimized(collocated)) + } + } catch { + fatalError("\(error)") + } } public static func ice_read(from istr: InputStream) throws -> Self? { diff --git a/swift/src/IceObjc/IceObjcObjectPrx.h b/swift/src/IceObjc/IceObjcObjectPrx.h index 49e93dce332..bf07be73486 100644 --- a/swift/src/IceObjc/IceObjcObjectPrx.h +++ b/swift/src/IceObjc/IceObjcObjectPrx.h @@ -75,6 +75,7 @@ NS_ASSUME_NONNULL_BEGIN -(nullable id) ice_getTimeout; -(nullable instancetype) ice_timeout:(int32_t)timeout error:(NSError* _Nullable * _Nullable)error; -(nullable instancetype) ice_fixed:(ICEConnection*)connection error:(NSError* _Nullable * _Nullable)error; +-(bool) ice_isFixed; -(nullable id) ice_getConnection:(NSError* _Nullable * _Nullable)error; //Either NSNull or ICEConnection -(nullable ICEConnection*) ice_getCachedConnection; -(BOOL) ice_flushBatchRequests:(NSError* _Nullable * _Nullable)error; diff --git a/swift/src/IceObjc/ObjectPrx.mm b/swift/src/IceObjc/ObjectPrx.mm index 011340f8a7e..d0d19a031c2 100644 --- a/swift/src/IceObjc/ObjectPrx.mm +++ b/swift/src/IceObjc/ObjectPrx.mm @@ -434,6 +434,11 @@ } } +-(bool) ice_isFixed +{ + return _prx->ice_isFixed(); +} + -(id)ice_getConnection:(NSError**)error { try diff --git a/swift/test/Ice/adapterDeactivation/AllTests.swift b/swift/test/Ice/adapterDeactivation/AllTests.swift index 907f468c42a..5e0cf5d0fd6 100644 --- a/swift/test/Ice/adapterDeactivation/AllTests.swift +++ b/swift/test/Ice/adapterDeactivation/AllTests.swift @@ -120,7 +120,7 @@ func allTests(_ helper: TestHelper) throws { do { routerId.name = "test" - router = try uncheckedCast(prx: base.ice_identity(routerId), type: Ice.RouterPrx.self) + router = uncheckedCast(prx: base.ice_identity(routerId), type: Ice.RouterPrx.self) _ = try communicator.createObjectAdapterWithRouter(name: "", rtr: router) try test(false) } catch is Ice.OperationNotExistException { diff --git a/swift/test/Ice/exceptions/Client.swift b/swift/test/Ice/exceptions/Client.swift index eb20351591a..4e411f52aaa 100644 --- a/swift/test/Ice/exceptions/Client.swift +++ b/swift/test/Ice/exceptions/Client.swift @@ -315,7 +315,7 @@ public class Client: TestHelperI { do { let id = try Ice.stringToIdentity("does not exist") do { - let thrower2 = try uncheckedCast(prx: thrower.ice_identity(id), type: ThrowerPrx.self) + let thrower2 = uncheckedCast(prx: thrower.ice_identity(id), type: ThrowerPrx.self) try thrower2.ice_ping() try test(false) } catch let ex as Ice.ObjectNotExistException { @@ -598,7 +598,7 @@ public class Client: TestHelperI { output.write("catching object not exist exception with new AMI mapping... ") try Promise<Void> { seal in let id = try Ice.stringToIdentity("does not exist") - let thrower2 = try uncheckedCast(prx: thrower.ice_identity(id), type: ThrowerPrx.self) + let thrower2 = uncheckedCast(prx: thrower.ice_identity(id), type: ThrowerPrx.self) firstly { thrower2.throwAasAAsync(1) }.done { @@ -763,7 +763,7 @@ public class Client: TestHelperI { output.write("catching object not exist exception with new AMI mapping... ") try Promise<Void> { seal in let id = try Ice.stringToIdentity("does not exist") - let thrower2 = try uncheckedCast(prx: thrower.ice_identity(id), type: ThrowerPrx.self) + let thrower2 = uncheckedCast(prx: thrower.ice_identity(id), type: ThrowerPrx.self) firstly { thrower2.throwAasAAsync(1) }.done { diff --git a/swift/test/Ice/operations/BatchOneways.swift b/swift/test/Ice/operations/BatchOneways.swift index abe72e5364a..09943978486 100644 --- a/swift/test/Ice/operations/BatchOneways.swift +++ b/swift/test/Ice/operations/BatchOneways.swift @@ -55,7 +55,7 @@ func batchOneways(_ helper: TestHelper, _ p: MyClassPrx) throws { var identity = Ice.Identity() identity.name = "invalid" - let batch3 = try batch.ice_identity(identity) + let batch3 = batch.ice_identity(identity) try batch3.ice_ping() try batch3.ice_flushBatchRequests() @@ -81,7 +81,7 @@ func batchOneways(_ helper: TestHelper, _ p: MyClassPrx) throws { let batchC1 = uncheckedCast(prx: prx.ice_compress(false), type: MyClassPrx.self) let batchC2 = uncheckedCast(prx: prx.ice_compress(true), type: MyClassPrx.self) - let batchC3 = uncheckedCast(prx: try prx.ice_identity(identity), type: MyClassPrx.self) + let batchC3 = uncheckedCast(prx: prx.ice_identity(identity), type: MyClassPrx.self) try batchC1.opByteSOneway(bs1) try batchC1.opByteSOneway(bs1) diff --git a/swift/test/Ice/operations/BatchOnewaysAMI.swift b/swift/test/Ice/operations/BatchOnewaysAMI.swift index 9f2a3329f39..8a43741d797 100644 --- a/swift/test/Ice/operations/BatchOnewaysAMI.swift +++ b/swift/test/Ice/operations/BatchOnewaysAMI.swift @@ -52,7 +52,7 @@ func batchOnewaysAMI(_ helper: TestHelper, _ p: MyClassPrx) throws { _ = batch2.ice_pingAsync() } - let batch3 = try batch.ice_identity(Ice.Identity(name: "invalid", category: "")) + let batch3 = batch.ice_identity(Ice.Identity(name: "invalid", category: "")) _ = batch3.ice_pingAsync() try batch3.ice_flushBatchRequestsAsync().wait() diff --git a/swift/test/Ice/proxy/AllTests.swift b/swift/test/Ice/proxy/AllTests.swift index 95a896872a5..f22fabdb8c7 100644 --- a/swift/test/Ice/proxy/AllTests.swift +++ b/swift/test/Ice/proxy/AllTests.swift @@ -347,7 +347,7 @@ public func allTests(helper: TestHelper) throws -> MyClassPrx { b2 = try b1.ice_getConnection()!.createProxy(Ice.stringToIdentity("fixed"))! let str = try communicator.proxyToString(b2) try test(b2.ice_toString() == str) - let str2 = try b1.ice_identity(b2.ice_getIdentity()).ice_secure(b2.ice_isSecure()).ice_toString() + let str2 = b1.ice_identity(b2.ice_getIdentity()).ice_secure(b2.ice_isSecure()).ice_toString() // Verify that the stringified fixed proxy is the same as a regular stringified proxy // but without endpoints try test(str2.hasPrefix("\(str):")) @@ -472,32 +472,32 @@ public func allTests(helper: TestHelper) throws -> MyClassPrx { writer.write("testing proxyToProperty... ") b1 = try communicator.stringToProxy("test")! - b1 = try b1.ice_collocationOptimized(true)! - b1 = try b1.ice_connectionCached(true) - b1 = try b1.ice_preferSecure(false) - b1 = try b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered) - b1 = try b1.ice_locatorCacheTimeout(100) - b1 = try b1.ice_invocationTimeout(1234) + b1 = b1.ice_collocationOptimized(true) + b1 = b1.ice_connectionCached(true) + b1 = b1.ice_preferSecure(false) + b1 = b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered) + b1 = b1.ice_locatorCacheTimeout(100) + b1 = b1.ice_invocationTimeout(1234) b1 = b1.ice_encodingVersion(Ice.EncodingVersion(major: 1, minor: 0)) var router = try communicator.stringToProxy("router")! - router = try router.ice_collocationOptimized(false)! - router = try router.ice_connectionCached(true) - router = try router.ice_preferSecure(true) - router = try router.ice_endpointSelection(Ice.EndpointSelectionType.Random) - router = try router.ice_locatorCacheTimeout(200) - router = try router.ice_invocationTimeout(1500) + router = router.ice_collocationOptimized(false) + router = router.ice_connectionCached(true) + router = router.ice_preferSecure(true) + router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random) + router = router.ice_locatorCacheTimeout(200) + router = router.ice_invocationTimeout(1500) var locator = try communicator.stringToProxy("locator")! - locator = try locator.ice_collocationOptimized(true)! - locator = try locator.ice_connectionCached(false) - locator = try locator.ice_preferSecure(true) - locator = try locator.ice_endpointSelection(Ice.EndpointSelectionType.Random) - locator = try locator.ice_locatorCacheTimeout(300) - locator = try locator.ice_invocationTimeout(1500) + locator = locator.ice_collocationOptimized(true) + locator = locator.ice_connectionCached(false) + locator = locator.ice_preferSecure(true) + locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random) + locator = locator.ice_locatorCacheTimeout(300) + locator = locator.ice_invocationTimeout(1500) - locator = try locator.ice_router(uncheckedCast(prx: router, type: Ice.RouterPrx.self)) - b1 = try b1.ice_locator(uncheckedCast(prx: locator, type: Ice.LocatorPrx.self)) + locator = locator.ice_router(uncheckedCast(prx: router, type: Ice.RouterPrx.self)) + b1 = b1.ice_locator(uncheckedCast(prx: locator, type: Ice.LocatorPrx.self)) let proxyProps = try communicator.proxyToProperty(proxy: b1, property: "Test") try test(proxyProps.count == 21) @@ -545,61 +545,17 @@ public func allTests(helper: TestHelper) throws -> MyClassPrx { try test(baseProxy.ice_batchDatagram().ice_isBatchDatagram()) try test(baseProxy.ice_secure(true).ice_isSecure()) try test(!baseProxy.ice_secure(false).ice_isSecure()) - try test(baseProxy.ice_collocationOptimized(true)!.ice_isCollocationOptimized()) - try test(!baseProxy.ice_collocationOptimized(false)!.ice_isCollocationOptimized()) + try test(baseProxy.ice_collocationOptimized(true).ice_isCollocationOptimized()) + try test(!baseProxy.ice_collocationOptimized(false).ice_isCollocationOptimized()) try test(baseProxy.ice_preferSecure(true).ice_isPreferSecure()) try test(!baseProxy.ice_preferSecure(false).ice_isPreferSecure()) - do { - _ = try baseProxy.ice_timeout(0) - try test(false) - } catch is Ice.RuntimeError {} - - do { - _ = try baseProxy.ice_timeout(-1) - } catch { - try test(false) - } - - do { - _ = try baseProxy.ice_timeout(-2) - try test(false) - } catch is Ice.RuntimeError {} - - do { - _ = try baseProxy.ice_invocationTimeout(0) - try test(false) - } catch is Ice.RuntimeError {} - - do { - _ = try baseProxy.ice_invocationTimeout(-1) - _ = try baseProxy.ice_invocationTimeout(-2) - } catch { - try test(false) - } - - do { - _ = try baseProxy.ice_invocationTimeout(-3) - try test(false) - } catch is Ice.RuntimeError {} - - do { - _ = try baseProxy.ice_locatorCacheTimeout(0) - } catch { - try test(false) - } - - do { - _ = try baseProxy.ice_locatorCacheTimeout(-1) - } catch { - try test(false) - } - - do { - _ = try baseProxy.ice_locatorCacheTimeout(-2) - try test(false) - } catch is Ice.RuntimeError {} - + try test(baseProxy.ice_timeout(-1).ice_getTimeout() == -1) + try test(baseProxy.ice_invocationTimeout(-1).ice_getInvocationTimeout() == -1) + try test(baseProxy.ice_invocationTimeout(-2).ice_getInvocationTimeout() == -2) + try test(baseProxy.ice_locatorCacheTimeout(0).ice_getLocatorCacheTimeout() == 0) + try test(baseProxy.ice_locatorCacheTimeout(-1).ice_getLocatorCacheTimeout() == -1) + writer.writeLine("ok") writer.write("testing proxy comparison... ") @@ -709,8 +665,8 @@ public func allTests(helper: TestHelper) throws -> MyClassPrx { let baseConnection = try baseProxy.ice_getConnection() if baseConnection != nil { let baseConnection2 = try baseProxy.ice_connectionId("base2").ice_getConnection() - compObj1 = try compObj1!.ice_fixed(baseConnection!) - compObj2 = try compObj2!.ice_fixed(baseConnection2!) + compObj1 = compObj1!.ice_fixed(baseConnection!) + compObj2 = compObj2!.ice_fixed(baseConnection2!) try test(compObj1 != compObj2) } writer.writeLine("ok") @@ -736,29 +692,29 @@ public func allTests(helper: TestHelper) throws -> MyClassPrx { do { let connection = try cl.ice_getConnection() if connection != nil { - let prx = try cl.ice_fixed(connection!)! + let prx = cl.ice_fixed(connection!) try prx.ice_ping() - try test(cl.ice_secure(true).ice_fixed(connection!)!.ice_isSecure()) - try test(cl.ice_facet("facet").ice_fixed(connection!)!.ice_getFacet() == "facet") - try test(cl.ice_oneway().ice_fixed(connection!)!.ice_isOneway()) + try test(cl.ice_secure(true).ice_fixed(connection!).ice_isSecure()) + try test(cl.ice_facet("facet").ice_fixed(connection!).ice_getFacet() == "facet") + try test(cl.ice_oneway().ice_fixed(connection!).ice_isOneway()) let ctx = ["one": "hello", "two": "world"] - try test(cl.ice_fixed(connection!)!.ice_getContext().isEmpty) - try test(cl.ice_context(ctx).ice_fixed(connection!)!.ice_getContext().count == 2) - try test(cl.ice_fixed(connection!)!.ice_getInvocationTimeout() == -1) - try test(cl.ice_invocationTimeout(10).ice_fixed(connection!)!.ice_getInvocationTimeout() == 10) - try test(cl.ice_fixed(connection!)!.ice_getConnection() === connection) - try test(cl.ice_fixed(connection!)!.ice_fixed(connection!)!.ice_getConnection() === connection) - try test(cl.ice_fixed(connection!)!.ice_getTimeout() == nil) - try test(cl.ice_compress(true).ice_fixed(connection!)!.ice_getCompress()!) + try test(cl.ice_fixed(connection!).ice_getContext().isEmpty) + try test(cl.ice_context(ctx).ice_fixed(connection!).ice_getContext().count == 2) + try test(cl.ice_fixed(connection!).ice_getInvocationTimeout() == -1) + try test(cl.ice_invocationTimeout(10).ice_fixed(connection!).ice_getInvocationTimeout() == 10) + try test(cl.ice_fixed(connection!).ice_getConnection() === connection) + try test(cl.ice_fixed(connection!).ice_fixed(connection!).ice_getConnection() === connection) + try test(cl.ice_fixed(connection!).ice_getTimeout() == nil) + try test(cl.ice_compress(true).ice_fixed(connection!).ice_getCompress()!) let fixedConnection = try cl.ice_connectionId("ice_fixed").ice_getConnection() - try test(cl.ice_fixed(connection!)!.ice_fixed(fixedConnection!)!.ice_getConnection() === + try test(cl.ice_fixed(connection!).ice_fixed(fixedConnection!).ice_getConnection() === fixedConnection) do { - try cl.ice_secure(!connection!.getEndpoint().getInfo()!.secure()).ice_fixed(connection!)!.ice_ping() + try cl.ice_secure(!connection!.getEndpoint().getInfo()!.secure()).ice_fixed(connection!).ice_ping() } catch is Ice.NoEndpointException {} do { - try cl.ice_datagram().ice_fixed(connection!)!.ice_ping() + try cl.ice_datagram().ice_fixed(connection!).ice_ping() } catch is Ice.NoEndpointException {} } } |