-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New makeProxy factory function in Swift #2275
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,10 @@ func allTests(_ helper: TestHelper, collocated: Bool = false) throws { | |
let output = helper.getWriter() | ||
|
||
var sref = "test:\(helper.getTestEndpoint(num: 0))" | ||
var obj = try communicator.stringToProxy(sref)! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer need this intermediary ObjectPrx. |
||
var p = try makeProxy(communicator: communicator, proxyString: sref, type: TestIntfPrx.self) | ||
|
||
var p = uncheckedCast(prx: obj, type: TestIntfPrx.self) | ||
sref = "testController:\(helper.getTestEndpoint(num: 1))" | ||
obj = try communicator.stringToProxy(sref)! | ||
|
||
let testController = uncheckedCast(prx: obj, type: TestIntfControllerPrx.self) | ||
let testController = try makeProxy(communicator: communicator, proxyString: sref, type: TestIntfControllerPrx.self) | ||
|
||
output.write("testing async invocation...") | ||
do { | ||
|
@@ -61,7 +58,7 @@ func allTests(_ helper: TestHelper, collocated: Bool = false) throws { | |
|
||
output.write("testing local exceptions... ") | ||
do { | ||
let indirect = uncheckedCast(prx: p.ice_adapterId("dummy"), type: TestIntfPrx.self) | ||
let indirect = p.ice_adapterId("dummy") | ||
try indirect.opAsync().wait() | ||
} catch is Ice.NoEndpointException {} | ||
|
||
|
@@ -77,8 +74,8 @@ func allTests(_ helper: TestHelper, collocated: Bool = false) throws { | |
var initData = Ice.InitializationData() | ||
initData.properties = communicator.getProperties().clone() | ||
let ic = try helper.initialize(initData) | ||
let o = try ic.stringToProxy(p.ice_toString())! | ||
let p2 = try checkedCast(prx: o, type: TestIntfPrx.self)! | ||
let p2 = try makeProxy(communicator: ic, proxyString: p.ice_toString(), type: TestIntfPrx.self) | ||
try p2.ice_pingAsync().wait() | ||
ic.destroy() | ||
do { | ||
try p2.opAsync().wait() | ||
|
@@ -89,7 +86,7 @@ func allTests(_ helper: TestHelper, collocated: Bool = false) throws { | |
|
||
output.write("testing exception callback... ") | ||
do { | ||
let i = uncheckedCast(prx: p.ice_adapterId("dummy"), type: TestIntfPrx.self) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The various ice_ factory method already returned a proxy with the same type. |
||
let i = p.ice_adapterId("dummy") | ||
|
||
do { | ||
_ = try i.ice_isAAsync(id: "::Test::TestIntf").wait() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,9 @@ func allTests(_ helper: TestHelper) throws { | |
let communicator = helper.communicator() | ||
let output = helper.getWriter() | ||
|
||
let com = try uncheckedCast( | ||
prx: communicator.stringToProxy("communicator:\(helper.getTestEndpoint(num: 0))")!, | ||
let com = try makeProxy( | ||
communicator: communicator, | ||
proxyString: "communicator:\(helper.getTestEndpoint(num: 0))", | ||
type: RemoteCommunicatorPrx.self) | ||
|
||
output.write("testing binding with single endpoint... ") | ||
|
@@ -48,12 +49,8 @@ func allTests(_ helper: TestHelper) throws { | |
|
||
try com.deactivateObjectAdapter(adapter) | ||
|
||
let test3 = uncheckedCast(prx: test1, type: TestIntfPrx.self) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code made no sense. uncheckedCast here just returns test1. |
||
try test(test3.ice_getConnection() === test1.ice_getConnection()) | ||
try test(test3.ice_getConnection() === test2.ice_getConnection()) | ||
|
||
do { | ||
try test3.ice_ping() | ||
try test1.ice_ping() | ||
try test(false) | ||
} catch is Ice.ConnectFailedException { | ||
// expected | ||
|
@@ -318,7 +315,7 @@ func allTests(_ helper: TestHelper) throws { | |
try obj.ice_getConnection()!.close(.GracefullyWithWait) | ||
} | ||
|
||
obj = uncheckedCast(prx: obj.ice_endpointSelection(.Random), type: TestIntfPrx.self) | ||
obj = obj.ice_endpointSelection(.Random) | ||
try test(obj.ice_getEndpointSelection() == .Random) | ||
|
||
names.append("Adapter21") | ||
|
@@ -344,7 +341,7 @@ func allTests(_ helper: TestHelper) throws { | |
] | ||
|
||
var obj = try createTestIntfPrx(adapters) | ||
obj = uncheckedCast(prx: obj.ice_endpointSelection(.Ordered), type: TestIntfPrx.self) | ||
obj = obj.ice_endpointSelection(.Ordered) | ||
try test(obj.ice_getEndpointSelection() == .Ordered) | ||
let nRetry = 3 | ||
|
||
|
@@ -423,12 +420,8 @@ func allTests(_ helper: TestHelper) throws { | |
do { | ||
let adapter = try com.createObjectAdapter(name: "Adapter41", endpoints: "default")! | ||
|
||
let test1 = try uncheckedCast( | ||
prx: adapter.getTestIntf()!.ice_connectionCached(false), | ||
type: TestIntfPrx.self) | ||
let test2 = try uncheckedCast( | ||
prx: adapter.getTestIntf()!.ice_connectionCached(false), | ||
type: TestIntfPrx.self) | ||
let test1 = try adapter.getTestIntf()!.ice_connectionCached(false) | ||
let test2 = try adapter.getTestIntf()!.ice_connectionCached(false) | ||
try test(!test1.ice_isConnectionCached()) | ||
try test(!test2.ice_isConnectionCached()) | ||
try test(test1.ice_getConnection() != nil && test2.ice_getConnection() != nil) | ||
|
@@ -438,9 +431,8 @@ func allTests(_ helper: TestHelper) throws { | |
|
||
try com.deactivateObjectAdapter(adapter) | ||
|
||
let test3 = uncheckedCast(prx: test1, type: TestIntfPrx.self) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This returns test1. |
||
do { | ||
try test(test3.ice_getConnection() === test1.ice_getConnection()) | ||
_ = try test1.ice_getConnection() | ||
try test(false) | ||
} catch is Ice.ConnectFailedException { | ||
// expected | ||
|
@@ -458,9 +450,7 @@ func allTests(_ helper: TestHelper) throws { | |
com.createObjectAdapter(name: "Adapter53", endpoints: "default")!, | ||
] | ||
|
||
let obj = try uncheckedCast( | ||
prx: createTestIntfPrx(adapters).ice_connectionCached(false), | ||
type: TestIntfPrx.self) | ||
let obj = try createTestIntfPrx(adapters).ice_connectionCached(false) | ||
try test(!obj.ice_isConnectionCached()) | ||
|
||
var names = ["Adapter51", "Adapter52", "Adapter53"] | ||
|
@@ -494,9 +484,7 @@ func allTests(_ helper: TestHelper) throws { | |
com.createObjectAdapter(name: "AdapterAMI53", endpoints: "default")!, | ||
] | ||
|
||
let obj = try uncheckedCast( | ||
prx: createTestIntfPrx(adapters).ice_connectionCached(false), | ||
type: TestIntfPrx.self) | ||
let obj = try createTestIntfPrx(adapters).ice_connectionCached(false) | ||
try test(!obj.ice_isConnectionCached()) | ||
|
||
var names = ["AdapterAMI51", "AdapterAMI52", "AdapterAMI53"] | ||
|
@@ -531,16 +519,14 @@ func allTests(_ helper: TestHelper) throws { | |
] | ||
|
||
var obj = try createTestIntfPrx(adapters) | ||
obj = uncheckedCast( | ||
prx: obj.ice_endpointSelection(.Ordered), | ||
type: TestIntfPrx.self) | ||
obj = obj.ice_endpointSelection(.Ordered) | ||
try test(obj.ice_getEndpointSelection() == .Ordered) | ||
obj = uncheckedCast(prx: obj.ice_connectionCached(false), type: TestIntfPrx.self) | ||
obj = obj.ice_connectionCached(false) | ||
try test(!obj.ice_isConnectionCached()) | ||
let nRetry = 3 | ||
var i = 0 | ||
// | ||
// Ensure that endpoints are tried in order by deactiving the adapters | ||
bernardnormier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Ensure that endpoints are tried in order by deactivating the adapters | ||
// one after the other. | ||
// | ||
while try i < nRetry && obj.getAdapterName() == "Adapter61" { | ||
|
@@ -616,16 +602,16 @@ func allTests(_ helper: TestHelper) throws { | |
] | ||
|
||
var obj = try createTestIntfPrx(adapters) | ||
obj = uncheckedCast(prx: obj.ice_endpointSelection(.Ordered), type: TestIntfPrx.self) | ||
obj = obj.ice_endpointSelection(.Ordered) | ||
try test(obj.ice_getEndpointSelection() == .Ordered) | ||
obj = uncheckedCast(prx: obj.ice_connectionCached(false), type: TestIntfPrx.self) | ||
obj = obj.ice_connectionCached(false) | ||
try test(!obj.ice_isConnectionCached()) | ||
|
||
let nRetry = 3 | ||
var i = 0 | ||
|
||
// | ||
// Ensure that endpoints are tried in order by deactiving the adapters | ||
// Ensure that endpoints are tried in order by deactivating the adapters | ||
// one after the other. | ||
// | ||
while try i < nRetry && obj.getAdapterNameAsync().wait() == "AdapterAMI61" { | ||
|
@@ -701,7 +687,7 @@ func allTests(_ helper: TestHelper) throws { | |
let obj = try createTestIntfPrx(adapters) | ||
try test(obj.getAdapterName() == "Adapter71") | ||
|
||
let testUDP = uncheckedCast(prx: obj.ice_datagram(), type: TestIntfPrx.self) | ||
let testUDP = obj.ice_datagram() | ||
try test(obj.ice_getConnection() !== testUDP.ice_getConnection()) | ||
do { | ||
_ = try testUDP.getAdapterName() | ||
|
@@ -723,11 +709,11 @@ func allTests(_ helper: TestHelper) throws { | |
try obj.ice_getConnection()!.close(.GracefullyWithWait) | ||
} | ||
|
||
var testSecure = uncheckedCast(prx: obj.ice_secure(true), type: TestIntfPrx.self) | ||
var testSecure = obj.ice_secure(true) | ||
try test(testSecure.ice_isSecure()) | ||
testSecure = uncheckedCast(prx: obj.ice_secure(false), type: TestIntfPrx.self) | ||
testSecure = obj.ice_secure(false) | ||
try test(!testSecure.ice_isSecure()) | ||
testSecure = uncheckedCast(prx: obj.ice_secure(true), type: TestIntfPrx.self) | ||
testSecure = obj.ice_secure(true) | ||
try test(testSecure.ice_isSecure()) | ||
try test(obj.ice_getConnection() !== testSecure.ice_getConnection()) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also remove this sref variables, and write the string directly as the "proxyString:" parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in this test.