diff options
-rw-r--r-- | cpp/test/Ice/Makefile | 4 | ||||
-rw-r--r-- | cpp/test/Ice/timeout/AllTests.cpp | 96 | ||||
-rw-r--r-- | cpp/test/Ice/timeout/Client.cpp | 4 | ||||
-rw-r--r-- | cpp/test/Ice/timeout/Server.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Ice/timeout/TestI.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Ice/udp/AllTests.cpp | 25 | ||||
-rw-r--r-- | cpp/test/Ice/udp/Client.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Ice/udp/Server.cpp | 6 | ||||
-rw-r--r-- | cpp/test/Ice/udp/TestI.cpp | 10 | ||||
-rw-r--r-- | cpp/test/Ice/udp/TestI.h | 4 |
10 files changed, 105 insertions, 50 deletions
diff --git a/cpp/test/Ice/Makefile b/cpp/test/Ice/Makefile index 7a020073067..e700b59127d 100644 --- a/cpp/test/Ice/Makefile +++ b/cpp/test/Ice/Makefile @@ -22,7 +22,9 @@ SUBDIRS = proxy \ objects \ properties \ admin \ - enums + enums \ + timeout \ + udp else SUBDIRS = proxy \ operations \ diff --git a/cpp/test/Ice/timeout/AllTests.cpp b/cpp/test/Ice/timeout/AllTests.cpp index e10ac8258c5..3d46840742d 100644 --- a/cpp/test/Ice/timeout/AllTests.cpp +++ b/cpp/test/Ice/timeout/AllTests.cpp @@ -80,14 +80,14 @@ public: }; typedef IceUtil::Handle<Callback> CallbackPtr; -TimeoutPrx +TimeoutPrxPtr allTests(const Ice::CommunicatorPtr& communicator) { string sref = "timeout:default -p 12010"; - Ice::ObjectPrx obj = communicator->stringToProxy(sref); + Ice::ObjectPrxPtr obj = communicator->stringToProxy(sref); test(obj); - TimeoutPrx timeout = TimeoutPrx::checkedCast(obj); + TimeoutPrxPtr timeout = ICE_CHECKED_CAST(TimeoutPrx, obj); test(timeout); cout << "testing connect timeout... " << flush; @@ -95,7 +95,7 @@ allTests(const Ice::CommunicatorPtr& communicator) // // Expect ConnectTimeoutException. // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(100)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_timeout(100)); timeout->holdAdapter(500); try { @@ -112,7 +112,7 @@ allTests(const Ice::CommunicatorPtr& communicator) // Expect success. // timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_timeout(1000)); timeout->holdAdapter(500); try { @@ -133,7 +133,7 @@ allTests(const Ice::CommunicatorPtr& communicator) // // Expect TimeoutException. // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(100)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_timeout(100)); timeout->holdAdapter(500); try { @@ -150,7 +150,7 @@ allTests(const Ice::CommunicatorPtr& communicator) // Expect success. // timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_timeout(1000)); timeout->holdAdapter(500); try { @@ -167,7 +167,7 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing invocation timeout... " << flush; { Ice::ConnectionPtr connection = obj->ice_getConnection(); - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_invocationTimeout(100)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_invocationTimeout(100)); test(connection == to->ice_getConnection()); try { @@ -178,7 +178,7 @@ allTests(const Ice::CommunicatorPtr& communicator) { } obj->ice_ping(); - to = TimeoutPrx::checkedCast(obj->ice_invocationTimeout(500)); + to = ICE_CHECKED_CAST(TimeoutPrx, obj->ice_invocationTimeout(500)); test(connection == to->ice_getConnection()); try { @@ -194,26 +194,55 @@ allTests(const Ice::CommunicatorPtr& communicator) // // Expect InvocationTimeoutException. // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_invocationTimeout(100)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_invocationTimeout(100)); + +#ifdef ICE_CPP11_MAPPING + auto f = to->sleep_async(750); + try + { + f.get(); + test(false); + } + catch(const Ice::InvocationTimeoutException&) + { + } + catch(...) + { + test(false); + } +#else CallbackPtr cb = new Callback(); to->begin_sleep(750, newCallback_Timeout_sleep(cb, &Callback::responseEx, &Callback::exceptionEx)); cb->check(); +#endif obj->ice_ping(); } { // // Expect success. // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_invocationTimeout(500)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_invocationTimeout(500)); +#ifdef ICE_CPP11_MAPPING + auto f = to->sleep_async(250); + try + { + f.get(); + } + catch(...) + { + test(false); + } +#else CallbackPtr cb = new Callback(); to->begin_sleep(250, newCallback_Timeout_sleep(cb, &Callback::response, &Callback::exception)); cb->check(); +#endif } { // // Backward compatible connection timeouts // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_invocationTimeout(-2)->ice_timeout(250)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, obj->ice_invocationTimeout(-2)->ice_timeout(250)); Ice::ConnectionPtr con; try { @@ -234,11 +263,14 @@ allTests(const Ice::CommunicatorPtr& communicator) } } obj->ice_ping(); - try { con = to->ice_getConnection(); +#ifdef ICE_CPP11_MAPPING + to->sleep_async(750).get(); +#else to->end_sleep(to->begin_sleep(750)); +#endif test(false); } catch(const Ice::TimeoutException&) @@ -259,7 +291,7 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing close timeout... " << flush; { - TimeoutPrx to = TimeoutPrx::checkedCast(obj->ice_timeout(250)); + TimeoutPrxPtr to = ICE_CHECKED_CAST(TimeoutPrx, obj->ice_timeout(250)); Ice::ConnectionPtr connection = to->ice_getConnection(); timeout->holdAdapter(600); connection->close(false); @@ -295,7 +327,7 @@ allTests(const Ice::CommunicatorPtr& communicator) initData.properties = communicator->getProperties()->clone(); initData.properties->setProperty("Ice.Override.Timeout", "250"); Ice::CommunicatorPtr comm = Ice::initialize(initData); - TimeoutPrx to = TimeoutPrx::checkedCast(comm->stringToProxy(sref)); + TimeoutPrxPtr to = ICE_CHECKED_CAST(TimeoutPrx, comm->stringToProxy(sref)); timeout->holdAdapter(700); try { @@ -311,7 +343,7 @@ allTests(const Ice::CommunicatorPtr& communicator) // Calling ice_timeout() should have no effect. // timeout->op(); // Ensure adapter is active. - to = TimeoutPrx::checkedCast(to->ice_timeout(1000)); + to = ICE_CHECKED_CAST(TimeoutPrx, to->ice_timeout(1000)); timeout->holdAdapter(500); try { @@ -333,7 +365,7 @@ allTests(const Ice::CommunicatorPtr& communicator) initData.properties->setProperty("Ice.Override.ConnectTimeout", "250"); Ice::CommunicatorPtr comm = Ice::initialize(initData); timeout->holdAdapter(750); - TimeoutPrx to = TimeoutPrx::uncheckedCast(comm->stringToProxy(sref)); + TimeoutPrxPtr to = ICE_UNCHECKED_CAST(TimeoutPrx, comm->stringToProxy(sref)); try { to->op(); @@ -348,7 +380,7 @@ allTests(const Ice::CommunicatorPtr& communicator) // timeout->op(); // Ensure adapter is active. timeout->holdAdapter(750); - to = TimeoutPrx::uncheckedCast(to->ice_timeout(1000)); + to = ICE_UNCHECKED_CAST(TimeoutPrx, to->ice_timeout(1000)); try { to->op(); @@ -362,7 +394,7 @@ allTests(const Ice::CommunicatorPtr& communicator) // Verify that timeout set via ice_timeout() is still used for requests. // timeout->op(); // Ensure adapter is active. - to = TimeoutPrx::uncheckedCast(to->ice_timeout(250)); + to = ICE_UNCHECKED_CAST(TimeoutPrx, to->ice_timeout(250)); to->ice_getConnection(); // Establish connection timeout->holdAdapter(750); try @@ -399,7 +431,7 @@ allTests(const Ice::CommunicatorPtr& communicator) Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TimeoutCollocated"); adapter->activate(); - TimeoutPrx timeout = TimeoutPrx::uncheckedCast(adapter->addWithUUID(new TimeoutI())); + TimeoutPrxPtr timeout = ICE_UNCHECKED_CAST(TimeoutPrx, adapter->addWithUUID(ICE_MAKE_SHARED(TimeoutI))); timeout = timeout->ice_invocationTimeout(100); try { @@ -412,19 +444,28 @@ allTests(const Ice::CommunicatorPtr& communicator) try { +#ifdef ICE_CPP11_MAPPING + timeout->sleep_async(300).get(); +#else timeout->end_sleep(timeout->begin_sleep(300)); +#endif test(false); } catch(const Ice::InvocationTimeoutException&) { } - TimeoutPrx batchTimeout = timeout->ice_batchOneway(); + TimeoutPrxPtr batchTimeout = timeout->ice_batchOneway(); batchTimeout->ice_ping(); batchTimeout->ice_ping(); batchTimeout->ice_ping(); - timeout->ice_invocationTimeout(-1)->begin_sleep(300); // Keep the server thread pool busy. + // Keep the server thread pool busy. +#ifdef ICE_CPP11_MAPPING + timeout->ice_invocationTimeout(-1)->sleep_async(300); +#else + timeout->ice_invocationTimeout(-1)->begin_sleep(300); +#endif try { batchTimeout->ice_flushBatchRequests(); @@ -438,10 +479,19 @@ allTests(const Ice::CommunicatorPtr& communicator) batchTimeout->ice_ping(); batchTimeout->ice_ping(); - timeout->ice_invocationTimeout(-1)->begin_sleep(300); // Keep the server thread pool busy. + // Keep the server thread pool busy. +#ifdef ICE_CPP11_MAPPING + timeout->ice_invocationTimeout(-1)->sleep_async(300); +#else + timeout->ice_invocationTimeout(-1)->begin_sleep(300); +#endif try { +#ifdef ICE_CPP11_MAPPING + batchTimeout->ice_flushBatchRequests_async().get(); +#else batchTimeout->end_ice_flushBatchRequests(batchTimeout->begin_ice_flushBatchRequests()); +#endif test(false); } catch(const Ice::InvocationTimeoutException&) diff --git a/cpp/test/Ice/timeout/Client.cpp b/cpp/test/Ice/timeout/Client.cpp index 16821374682..beebbe4e0c2 100644 --- a/cpp/test/Ice/timeout/Client.cpp +++ b/cpp/test/Ice/timeout/Client.cpp @@ -19,8 +19,8 @@ using namespace Test; int run(int, char**, const Ice::CommunicatorPtr& communicator) { - TimeoutPrx allTests(const Ice::CommunicatorPtr&); - TimeoutPrx timeout = allTests(communicator); + TimeoutPrxPtr allTests(const Ice::CommunicatorPtr&); + TimeoutPrxPtr timeout = allTests(communicator); timeout->shutdown(); return EXIT_SUCCESS; } diff --git a/cpp/test/Ice/timeout/Server.cpp b/cpp/test/Ice/timeout/Server.cpp index 61104b01a04..a11671b3c7a 100644 --- a/cpp/test/Ice/timeout/Server.cpp +++ b/cpp/test/Ice/timeout/Server.cpp @@ -20,7 +20,7 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); - Ice::ObjectPtr object = new TimeoutI; + Ice::ObjectPtr object = ICE_MAKE_SHARED(TimeoutI); adapter->add(object, communicator->stringToIdentity("timeout")); adapter->activate(); TEST_READY diff --git a/cpp/test/Ice/timeout/TestI.cpp b/cpp/test/Ice/timeout/TestI.cpp index 273985f9a1c..ba41c405bf0 100644 --- a/cpp/test/Ice/timeout/TestI.cpp +++ b/cpp/test/Ice/timeout/TestI.cpp @@ -47,7 +47,7 @@ TimeoutI::sendData(const Test::ByteSeq&, const Ice::Current&) } void -TimeoutI::sleep(Ice::Int to, const Ice::Current&) +TimeoutI::sleep(Ice::Int to, const Ice::Current& c) { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(to)); } diff --git a/cpp/test/Ice/udp/AllTests.cpp b/cpp/test/Ice/udp/AllTests.cpp index b741719eef8..04920cdbd08 100644 --- a/cpp/test/Ice/udp/AllTests.cpp +++ b/cpp/test/Ice/udp/AllTests.cpp @@ -57,21 +57,20 @@ private: int _replies; }; - -typedef IceUtil::Handle<PingReplyI> PingReplyIPtr; +ICE_DEFINE_PTR(PingReplyIPtr, PingReplyI); void allTests(const CommunicatorPtr& communicator) { communicator->getProperties()->setProperty("ReplyAdapter.Endpoints", "udp -p 12030"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("ReplyAdapter"); - PingReplyIPtr replyI = new PingReplyI; - PingReplyPrx reply = PingReplyPrx::uncheckedCast(adapter->addWithUUID(replyI))->ice_datagram(); + PingReplyIPtr replyI = ICE_MAKE_SHARED(PingReplyI); + PingReplyPrxPtr reply = ICE_UNCHECKED_CAST(PingReplyPrx, adapter->addWithUUID(replyI))->ice_datagram(); adapter->activate(); cout << "testing udp... " << flush; - ObjectPrx base = communicator->stringToProxy("test -d:udp -p 12010"); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(base); + ObjectPrxPtr base = communicator->stringToProxy("test -d:udp -p 12010"); + TestIntfPrxPtr obj = ICE_UNCHECKED_CAST(TestIntfPrx, base); int nRetry = 5; bool ret; @@ -89,8 +88,8 @@ allTests(const CommunicatorPtr& communicator) // If the 3 datagrams were not received within the 2 seconds, we try again to // receive 3 new datagrams using a new object. We give up after 5 retries. - replyI = new PingReplyI; - reply = PingReplyPrx::uncheckedCast(adapter->addWithUUID(replyI))->ice_datagram(); + replyI = ICE_MAKE_SHARED(PingReplyI); + reply = ICE_UNCHECKED_CAST(PingReplyPrx, adapter->addWithUUID(replyI))->ice_datagram(); } test(ret); @@ -149,7 +148,7 @@ allTests(const CommunicatorPtr& communicator) endpoint = "udp -h 239.255.1.1 -p 12020"; } base = communicator->stringToProxy("test -d:" + endpoint); - TestIntfPrx objMcast = TestIntfPrx::uncheckedCast(base); + TestIntfPrxPtr objMcast = ICE_UNCHECKED_CAST(TestIntfPrx, base); #if !defined(ICE_OS_WINRT) && (!defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE)) cout << "testing udp multicast... " << flush; @@ -163,8 +162,8 @@ allTests(const CommunicatorPtr& communicator) { break; // Success } - replyI = new PingReplyI; - reply = PingReplyPrx::uncheckedCast(adapter->addWithUUID(replyI))->ice_datagram(); + replyI = ICE_MAKE_SHARED(PingReplyI); + reply = ICE_UNCHECKED_CAST(PingReplyPrx, adapter->addWithUUID(replyI))->ice_datagram(); } if(!ret) { @@ -194,8 +193,8 @@ allTests(const CommunicatorPtr& communicator) // If the 3 datagrams were not received within the 2 seconds, we try again to // receive 3 new datagrams using a new object. We give up after 5 retries. - replyI = new PingReplyI; - reply = PingReplyPrx::uncheckedCast(adapter->addWithUUID(replyI))->ice_datagram(); + replyI = ICE_MAKE_SHARED(PingReplyI); + reply = ICE_UNCHECKED_CAST(PingReplyPrx, adapter->addWithUUID(replyI))->ice_datagram(); } test(ret); cout << "ok" << endl; diff --git a/cpp/test/Ice/udp/Client.cpp b/cpp/test/Ice/udp/Client.cpp index ac60fdf9093..a9e2a0071bf 100644 --- a/cpp/test/Ice/udp/Client.cpp +++ b/cpp/test/Ice/udp/Client.cpp @@ -27,7 +27,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { ostringstream os; os << "control:tcp -p " << (12010 + i); - TestIntfPrx::uncheckedCast(communicator->stringToProxy(os.str()))->shutdown(); + ICE_UNCHECKED_CAST(TestIntfPrx, communicator->stringToProxy(os.str()))->shutdown(); } return EXIT_SUCCESS; } diff --git a/cpp/test/Ice/udp/Server.cpp b/cpp/test/Ice/udp/Server.cpp index 654f1e65dc4..3409e10327a 100644 --- a/cpp/test/Ice/udp/Server.cpp +++ b/cpp/test/Ice/udp/Server.cpp @@ -26,14 +26,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) os << "tcp -p " << (12010 + num); properties->setProperty("ControlAdapter.Endpoints", os.str()); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("ControlAdapter"); - adapter->add(new TestIntfI, communicator->stringToIdentity("control")); + adapter->add(ICE_MAKE_SHARED(TestIntfI), communicator->stringToIdentity("control")); adapter->activate(); if(num == 0) { properties->setProperty("TestAdapter.Endpoints", "udp -p 12010"); Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("TestAdapter"); - adapter2->add(new TestIntfI, communicator->stringToIdentity("test")); + adapter2->add(ICE_MAKE_SHARED(TestIntfI), communicator->stringToIdentity("test")); adapter2->activate(); } @@ -52,7 +52,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } properties->setProperty("McastTestAdapter.Endpoints", endpoint); Ice::ObjectAdapterPtr mcastAdapter = communicator->createObjectAdapter("McastTestAdapter"); - mcastAdapter->add(new TestIntfI, communicator->stringToIdentity("test")); + mcastAdapter->add(ICE_MAKE_SHARED(TestIntfI), communicator->stringToIdentity("test")); mcastAdapter->activate(); TEST_READY diff --git a/cpp/test/Ice/udp/TestI.cpp b/cpp/test/Ice/udp/TestI.cpp index 46b30ba20c9..468dba622d0 100644 --- a/cpp/test/Ice/udp/TestI.cpp +++ b/cpp/test/Ice/udp/TestI.cpp @@ -15,7 +15,7 @@ using namespace std; using namespace Ice; void -TestIntfI::ping(const Test::PingReplyPrx& reply, const Current&) +TestIntfI::ping(const Test::PingReplyPrxPtr& reply, const Current&) { try { @@ -28,7 +28,7 @@ TestIntfI::ping(const Test::PingReplyPrx& reply, const Current&) } void -TestIntfI::sendByteSeq(const Test::ByteSeq&, const Test::PingReplyPrx& reply, const Current&) +TestIntfI::sendByteSeq(const Test::ByteSeq&, const Test::PingReplyPrxPtr& reply, const Current&) { try { @@ -53,7 +53,7 @@ TestIntfI::pingBiDir(const Ice::Identity& id, const Ice::Current& current) { Test::ByteSeq seq; seq.resize(32 * 1024); - Test::TestIntfPrx::uncheckedCast(current.con->createProxy(id))->sendByteSeq(seq, 0); + ICE_UNCHECKED_CAST(Test::TestIntfPrx, current.con->createProxy(id))->sendByteSeq(seq, 0); } catch(const DatagramLimitException&) { @@ -63,7 +63,11 @@ TestIntfI::pingBiDir(const Ice::Identity& id, const Ice::Current& current) // // Send the reply through the incoming connection. // +#ifdef ICE_CPP11_MAPPING + Ice::uncheckedCast<Test::PingReplyPrx>(current.con->createProxy(id))->reply_async(); +#else Test::PingReplyPrx::uncheckedCast(current.con->createProxy(id))->begin_reply(); +#endif } catch(const Ice::Exception& ex) { diff --git a/cpp/test/Ice/udp/TestI.h b/cpp/test/Ice/udp/TestI.h index 5d17f261936..b0f738c98c5 100644 --- a/cpp/test/Ice/udp/TestI.h +++ b/cpp/test/Ice/udp/TestI.h @@ -16,8 +16,8 @@ class TestIntfI : public Test::TestIntf { public: - virtual void ping(const Test::PingReplyPrx&, const Ice::Current&); - virtual void sendByteSeq(const Test::ByteSeq&, const Test::PingReplyPrx&, const Ice::Current&); + virtual void ping(const Test::PingReplyPrxPtr&, const Ice::Current&); + virtual void sendByteSeq(const Test::ByteSeq&, const Test::PingReplyPrxPtr&, const Ice::Current&); virtual void pingBiDir(const Ice::Identity&, const Ice::Current&); virtual void shutdown(const Ice::Current&); }; |