diff options
86 files changed, 2120 insertions, 2626 deletions
diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index a2c508ec1e8..0d068b2ad2b 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -12,26 +12,26 @@ particular aspect of Ice. - [General Changes](#general-changes) - [C++ Changes](#c-changes) - [Java Changes](#java-changes) - - [C# Changes](#c#-changes) + - [C# Changes](#c-changes-1) - [Python Changes](#python-changes) - [Ruby Changes](#ruby-changes) - [PHP Changes](#php-changes) - [Visual Studio Add-in Changes](#visual-studio-add-in-changes) - [Changes in 3.4.1](#changes-in-341) - [General Changes](#general-changes-1) - - [C++ Changes](#c-changes-1) + - [C++ Changes](#c-changes-2) - [Java Changes](#java-changes-1) - - [C# Changes](#c#-changes-1) + - [C# Changes](#c-changes-3) - [Python Changes](#python-changes-1) -- [Changes for 3.4.0](#changes-for-340) +- [Changes in 3.4.0](#changes-in-340) - [General Changes](#general-changes-2) - - [C++ Changes](#c-changes-2) + - [C++ Changes](#c-changes-4) - [Java Changes](#java-changes-2) - - [C# Changes](#c#-changes-2) + - [C# Changes](#c-changes-5) - [Python Changes](#python-changes-2) - [Ruby Changes](#ruby-changes-1) - [PHP Changes](#php-changes-1) - - [Visual Studio Plugin Changes](#visual-studio-plugin-changes) + - [Visual Studio Add-in Changes](#visual-studio-add-in-changes-1) # Changes in Ice 3.4.2 diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index 1a02d2e9ebf..a77c5032c02 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -608,7 +608,6 @@ generated from the section label. <section name="Glacier2"> <property name="AddConnectionContext"/> <property name="Client" class="objectadapter"/> - <property name="Client.AlwaysBatch" /> <property name="Client.Buffered" /> <property name="Client.ForwardContext" /> <property name="Client.SleepTime" /> @@ -629,7 +628,6 @@ generated from the section label. <property name="SSLPermissionsVerifier" class="proxy" /> <property name="RoutingTable.MaxSize" /> <property name="Server" class="objectadapter" /> - <property name="Server.AlwaysBatch" /> <property name="Server.Buffered" /> <property name="Server.ForwardContext" /> <property name="Server.SleepTime" /> @@ -637,7 +635,6 @@ generated from the section label. <property name="Server.Trace.Request" /> <property name="SessionManager" class="proxy" /> <property name="SSLSessionManager" class="proxy" /> - <property name="SessionTimeout" /> <property name="Trace.RoutingTable" /> <property name="Trace.Session" /> </section> diff --git a/cpp/config/Make.rules b/cpp/config/Make.rules index 2d3fa07dad1..64f2d5d577c 100644 --- a/cpp/config/Make.rules +++ b/cpp/config/Make.rules @@ -9,7 +9,7 @@ # # Supported configurations # -supported-configs = shared static cpp11-shared cpp11-static +supported-configs = cpp98-shared cpp98-static cpp11-shared cpp11-static -include $(lang_srcdir)/config/Make.rules.$(os) ifeq ($(os),Darwin) @@ -42,10 +42,7 @@ endif # that are static-only # shared_projects = % -shared_excludes = IceUtil Slice \ - icebridge \ - test/Glacier2/% \ - test/IceBridge/% +shared_excludes = IceUtil Slice # # Build only few components with the static configuration (core and stubs) @@ -55,19 +52,35 @@ static_projects = test/Common \ test/Ice/% \ test/IceSSL/% \ test/IceDiscovery/simple \ - test/Glacier2/application \ test/IceGrid/simple static_excludes = test/Ice/library test/Ice/plugin +$(eval $(call validate-config)) + # -# Components and projects which are built with C++11 +# Components and projects which are built with C++98 +# +cpp98_projects = % +cpp98_excludes = glacier2router \ + icebridge \ + iceboxadmin \ + icegridnode icegridregistry icegridadmin icegriddb \ + IceStormService icestormadmin icestormdb \ + IceXML \ + test/Glacier2/% \ + test/IceBridge/% \ + test/IceGrid/% \ + test/IceStorm/% + +# +# Components and projects which are built with C++17 # cpp11_components = $(coreandstub_components) \ glacier2router Glacier2CryptPermissionsVerifier \ - icebox icebridge \ - IceDB \ - IceXML \ + icebox iceboxadmin \ + icebridge \ + IceDB IceXML \ icegridnode icegridregistry icegridadmin icegriddb \ IceStormService icestormadmin icestormdb \ @@ -108,9 +121,10 @@ endif # cpp11_cppflags = -DICE_CPP11_MAPPING -std=c++17 cpp11_ldflags = $(cpp11_cppflags) -cpp11_targetname = $(if $(or $(filter-out $($1_target),program),$(filter $(bindir)%,$($4_targetdir))),++11) +cpp11_targetname = $(if $(or $(filter-out $($1_target),program), $(if $(filter icebox,$1), $(filter $(bindir)%,$($4_targetdir)),)),++11) cpp11_targetdir = $(if $(filter %/build,$5),cpp11) + # # $(call make-cpp-src-project,$1=project) # diff --git a/cpp/config/Make.xcodesdk.rules b/cpp/config/Make.xcodesdk.rules index d35fe59c40f..c7393365787 100644 --- a/cpp/config/Make.xcodesdk.rules +++ b/cpp/config/Make.xcodesdk.rules @@ -4,7 +4,7 @@ include $(top_srcdir)/config/Make.xcodesdk.rules -supported-configs += xcodesdk cpp11-xcodesdk +supported-configs += cpp98-xcodesdk cpp11-xcodesdk is-iostest-program = $(and $(filter-out macosx,$2),$(filter test/%,$1)) diff --git a/cpp/config/glacier2router.cfg b/cpp/config/glacier2router.cfg index 14d325fc2ff..a200a608b81 100644 --- a/cpp/config/glacier2router.cfg +++ b/cpp/config/glacier2router.cfg @@ -42,7 +42,7 @@ Glacier2.PermissionsVerifier=DemoGlacier2Router/NullPermissionsVerifier # for longer than this value, the session expires and is removed. The # unit is seconds. # -Glacier2.SessionTimeout=30 +Glacier2.Client.ACM.Timeout=30 # # Glacier2 always disables active connection management so there is no diff --git a/cpp/config/templates.xml b/cpp/config/templates.xml index aab103a9c67..f7a20322c3b 100644 --- a/cpp/config/templates.xml +++ b/cpp/config/templates.xml @@ -12,10 +12,10 @@ <server id="${instance-name}" exe="glacier2router" activation="always"> <properties> + <property name="Glacier2.Client.ACM.Timeout" value="${session-timeout}"/> <property name="Glacier2.Client.Endpoints" value="${client-endpoints}"/> - <property name="Glacier2.Server.Endpoints" value="${server-endpoints}"/> <property name="Glacier2.InstanceName" value="${instance-name}"/> - <property name="Glacier2.SessionTimeout" value="${session-timeout}"/> + <property name="Glacier2.Server.Endpoints" value="${server-endpoints}"/> </properties> </server> diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index d6e3b64678c..79b3014958f 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -1,7 +1,7 @@ // // Copyright (c) ZeroC, Inc. All rights reserved. // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Fri Jan 29 15:05:58 2021 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Wed Feb 3 10:19:18 2021 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -1168,7 +1168,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.Client.ThreadPool.ThreadIdleTime", false, 0), IceInternal::Property("Glacier2.Client.ThreadPool.ThreadPriority", false, 0), IceInternal::Property("Glacier2.Client.MessageSizeMax", false, 0), - IceInternal::Property("Glacier2.Client.AlwaysBatch", false, 0), IceInternal::Property("Glacier2.Client.Buffered", false, 0), IceInternal::Property("Glacier2.Client.ForwardContext", false, 0), IceInternal::Property("Glacier2.Client.SleepTime", false, 0), @@ -1243,7 +1242,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.Server.ThreadPool.ThreadIdleTime", false, 0), IceInternal::Property("Glacier2.Server.ThreadPool.ThreadPriority", false, 0), IceInternal::Property("Glacier2.Server.MessageSizeMax", false, 0), - IceInternal::Property("Glacier2.Server.AlwaysBatch", false, 0), IceInternal::Property("Glacier2.Server.Buffered", false, 0), IceInternal::Property("Glacier2.Server.ForwardContext", false, 0), IceInternal::Property("Glacier2.Server.SleepTime", false, 0), @@ -1269,7 +1267,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.SSLSessionManager.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.SSLSessionManager.Context.*", false, 0), IceInternal::Property("Glacier2.SSLSessionManager", false, 0), - IceInternal::Property("Glacier2.SessionTimeout", false, 0), IceInternal::Property("Glacier2.Trace.RoutingTable", false, 0), IceInternal::Property("Glacier2.Trace.Session", false, 0), }; diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index 42bf1fce9bc..71f3f64b9a1 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -1,7 +1,7 @@ // // Copyright (c) ZeroC, Inc. All rights reserved. // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Fri Jan 29 15:05:58 2021 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Wed Feb 3 10:19:18 2021 // IMPORTANT: Do not edit this file -- any edits made here will be lost! diff --git a/cpp/src/IceStorm/Subscriber.cpp b/cpp/src/IceStorm/Subscriber.cpp index a7ea42d3c13..9edfe04ea21 100644 --- a/cpp/src/IceStorm/Subscriber.cpp +++ b/cpp/src/IceStorm/Subscriber.cpp @@ -869,10 +869,10 @@ Subscriber::Subscriber(shared_ptr<Instance> instance, if(_instance->observer()) { _observer.attach(_instance->observer()->getSubscriberObserver(_instance->serviceName(), - rec.topicName, - rec.obj, - rec.theQoS, - rec.theTopic, + _rec.topicName, + _rec.obj, + _rec.theQoS, + _rec.theTopic, toSubscriberState(_state), 0)); } diff --git a/cpp/test/Glacier2/override/test.py b/cpp/test/Glacier2/override/test.py index 232283fe93c..306e11f9c5b 100644 --- a/cpp/test/Glacier2/override/test.py +++ b/cpp/test/Glacier2/override/test.py @@ -14,15 +14,15 @@ routerProps = { 'Ice.ThreadPool.Server.Serialize' : '1', 'Ice.ThreadPool.Client.Serialize' : '1', 'Glacier2.Filter.Category.Accept' : '"c"', - 'Glacier2.SessionTimeout' : '"30"', - 'Glacier2.PermissionsVerifier' : 'Glacier2/NullPermissionsVerifier', + 'Glacier2.Client.ACM.Timeout' : '"30"', + 'Glacier2.Client.Buffered=1 --Glacier2.Server.Buffered' : '1', 'Glacier2.Client.ForwardContext' : '1', + 'Glacier2.Client.SleepTime=50 --Glacier2.Server.SleepTime' : '50', 'Glacier2.Client.Trace.Override' : '0', 'Glacier2.Client.Trace.Request' : '0', + 'Glacier2.PermissionsVerifier' : 'Glacier2/NullPermissionsVerifier', 'Glacier2.Server.Trace.Override' : '0', 'Glacier2.Server.Trace.Request' : '0', - 'Glacier2.Client.Buffered=1 --Glacier2.Server.Buffered' : '1', - 'Glacier2.Client.SleepTime=50 --Glacier2.Server.SleepTime' : '50', } Glacier2TestSuite(__name__, routerProps=routerProps) diff --git a/cpp/test/Glacier2/router/Client.cpp b/cpp/test/Glacier2/router/Client.cpp index cd22432362f..ecaa171c22e 100644 --- a/cpp/test/Glacier2/router/Client.cpp +++ b/cpp/test/Glacier2/router/Client.cpp @@ -447,8 +447,9 @@ CallbackClient::run(int argc, char** argv) { cout << "getting the session timeout... " << flush; - auto timeout = router->getSessionTimeout(); - test(timeout == 30); + auto sessionTimeout = router->getSessionTimeout(); + auto acmTimeout = router->getACMTimeout(); + test(sessionTimeout == 30 && sessionTimeout == acmTimeout); cout << "ok" << endl; } diff --git a/cpp/test/IceBridge/simple/AllTests.cpp b/cpp/test/IceBridge/simple/AllTests.cpp index 0f66b77f277..16a76f21cb8 100644 --- a/cpp/test/IceBridge/simple/AllTests.cpp +++ b/cpp/test/IceBridge/simple/AllTests.cpp @@ -5,74 +5,49 @@ #include <Ice/Ice.h> #include <TestHelper.h> #include <Test.h> +#include <mutex> +#include <chrono> +#include <atomic> using namespace std; +using namespace std::chrono_literals; namespace { -class CallbackI : public Test::Callback +class CallbackI final : public Test::Callback { public: - CallbackI() : _count(0), _datagramCount(0) - { - } - - virtual void - ping(const Ice::Current&) + void + ping(const Ice::Current&) override { ++_count; } - virtual int - getCount(const Ice::Current&) + int + getCount(const Ice::Current&) override { return _count; } - virtual void - datagram(const Ice::Current& c) + void + datagram(const Ice::Current& c) override { test(c.con->getEndpoint()->getInfo()->datagram()); ++_datagramCount; } - virtual int - getDatagramCount(const Ice::Current&) + int + getDatagramCount(const Ice::Current&) override { return _datagramCount; } private: - int _count; - int _datagramCount; -}; - -class HeartbeatCallbackI : public Ice::HeartbeatCallback, private IceUtil::Mutex -{ -public: - - HeartbeatCallbackI() : _count(0) - { - } - - virtual void heartbeat(const Ice::ConnectionPtr&) - { - Lock sync(*this); - ++_count; - } - - int getCount() const - { - Lock sync(*this); - return _count; - } - -private: - - int _count; + int _count = 0; + int _datagramCount = 0; }; } @@ -80,12 +55,12 @@ private: void allTests(Test::TestHelper* helper) { - Ice::CommunicatorPtr communicator = helper->communicator(); + auto communicator = helper->communicator(); cout << "testing connection to bridge... " << flush; - Ice::ObjectPrx prx = communicator->stringToProxy("test:" + helper->getTestEndpoint(1) + ":" + - helper->getTestEndpoint(1, "udp")); + auto prx = communicator->stringToProxy("test:" + helper->getTestEndpoint(1) + ":" + + helper->getTestEndpoint(1, "udp")); test(prx); - Test::MyClassPrx cl = Ice::checkedCast<Test::MyClassPrx>(prx); + auto cl = Ice::checkedCast<Test::MyClassPrx>(prx); cl->ice_ping(); cout << "ok" << endl; @@ -98,7 +73,7 @@ allTests(Test::TestHelper* helper) int nRetry = 20; while(cl->getDatagramCount() < 10 && --nRetry > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(50)); + this_thread::sleep_for(50ms); } test(cl->getDatagramCount() >= 10); } @@ -106,7 +81,7 @@ allTests(Test::TestHelper* helper) cout << "testing connection close... " << flush; { - Test::MyClassPrx clc = + auto clc = Ice::checkedCast<Test::MyClassPrx>(cl->ice_getConnection()->createProxy(cl->ice_getIdentity())); clc->ice_ping(); clc->closeConnection(false); @@ -130,7 +105,7 @@ allTests(Test::TestHelper* helper) // of the connection close. test(ex.unknown.find("CloseConnectionException") != string::npos); } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1)); + this_thread::sleep_for(1ms); } try { @@ -149,16 +124,16 @@ allTests(Test::TestHelper* helper) int nRetry = 20; while(cl->getConnectionCount() != 2 && --nRetry > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(50)); + this_thread::sleep_for(50ms); } test(cl->getConnectionCount() == 2); test(cl->ice_connectionId("other")->getConnectionInfo() != cl->getConnectionInfo()); test(cl->getConnectionCount() == 3); - cl->ice_connectionId("other")->ice_getConnection()->close(Ice::ConnectionCloseGracefully); + cl->ice_connectionId("other")->ice_getConnection()->close(Ice::ConnectionClose::Gracefully); nRetry = 20; while(cl->getConnectionCount() != 2 && --nRetry > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(50)); + this_thread::sleep_for(50ms); } test(cl->getConnectionCount() == 2); } @@ -174,10 +149,10 @@ allTests(Test::TestHelper* helper) { ostringstream os; os << i; - Test::MyClassPrx p = cl->ice_connectionId(os.str()); + auto p = cl->ice_connectionId(os.str()); for(int j = 0; j < 20; ++j) { - p->begin_incCounter(++counter); + p->incCounterAsync(++counter, nullptr); } cl->waitCounter(counter); p->closeConnection(false); @@ -186,10 +161,10 @@ allTests(Test::TestHelper* helper) { ostringstream os; os << i; - Test::MyClassPrx p = cl->ice_connectionId(os.str())->ice_oneway(); + auto p = cl->ice_connectionId(os.str())->ice_oneway(); for(int j = 0; j < 20; ++j) { - p->begin_incCounter(++counter); + p->incCounterAsync(++counter, nullptr); } cl->waitCounter(counter); p->closeConnection(false); @@ -197,10 +172,10 @@ allTests(Test::TestHelper* helper) } cout << "ok" << endl; - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(""); + auto adapter = communicator->createObjectAdapter(""); Ice::Identity id; id.name = "callback"; - adapter->add(new CallbackI(), id); + adapter->add(make_shared<CallbackI>(), id); cout << "testing bi-dir callbacks... " << flush; { @@ -216,7 +191,7 @@ allTests(Test::TestHelper* helper) cout << "testing datagram bi-dir callbacks... " << flush; { - Test::MyClassPrx p = cl->ice_datagram(); + auto p = cl->ice_datagram(); p->ice_getConnection()->setAdapter(adapter); for(int i = 0; i < 20; i++) { @@ -225,7 +200,7 @@ allTests(Test::TestHelper* helper) int nRetry = 20; while(cl->getCallbackDatagramCount() < 10 && --nRetry > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(50)); + this_thread::sleep_for(50ms); } test(cl->getCallbackDatagramCount() >= 10); } @@ -233,11 +208,11 @@ allTests(Test::TestHelper* helper) cout << "testing router... " << flush; { - Ice::ObjectPrx base = communicator->stringToProxy("Ice/RouterFinder:" + helper->getTestEndpoint(1)); - Ice::RouterFinderPrx finder = Ice::checkedCast<Ice::RouterFinderPrx>(base); - Ice::RouterPrx router = finder->getRouter(); + auto base = communicator->stringToProxy("Ice/RouterFinder:" + helper->getTestEndpoint(1)); + auto finder = Ice::checkedCast<Ice::RouterFinderPrx>(base); + auto router = finder->getRouter(); base = communicator->stringToProxy("test")->ice_router(router); - Test::MyClassPrx p = Ice::checkedCast<Test::MyClassPrx>(base); + auto p = Ice::checkedCast<Test::MyClassPrx>(base); p->ice_ping(); } cout << "ok" << endl; @@ -246,20 +221,23 @@ allTests(Test::TestHelper* helper) { test(cl->getHeartbeatCount() == 0); // No heartbeats enabled by default - Test::MyClassPrx p = cl->ice_connectionId("heartbeat"); - p->ice_getConnection()->setACM(1, IceUtil::None, Ice::HeartbeatAlways); + auto p = cl->ice_connectionId("heartbeat"); + p->ice_getConnection()->setACM(1, Ice::nullopt, Ice::ACMHeartbeat::HeartbeatAlways); - Test::MyClassPrx p2 = cl->ice_connectionId("heartbeat2"); - HeartbeatCallbackI* heartbeat = new HeartbeatCallbackI(); - p2->ice_getConnection()->setHeartbeatCallback(heartbeat); + auto p2 = cl->ice_connectionId("heartbeat2"); + atomic_int counter = 0; + p2->ice_getConnection()->setHeartbeatCallback([&counter](const auto&) + { + counter++; + }); p2->enableHeartbeats(); int nRetry = 20; - while((p->getHeartbeatCount() < 1 || heartbeat->getCount() < 1) && --nRetry > 0) + while((p->getHeartbeatCount() < 1 || counter.load() < 1) && --nRetry > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + this_thread::sleep_for(500ms); // TODO: check sleep time } - test(p->getHeartbeatCount() > 0 && heartbeat->getCount() > 0); + test(p->getHeartbeatCount() > 0 && counter.load() > 0); } cout << "ok" << endl; @@ -268,8 +246,8 @@ allTests(Test::TestHelper* helper) cout << "ok" << endl; cout << "testing bridge shutdown... " << flush; - Ice::ObjectPrx admin = communicator->stringToProxy("IceBridge/admin:" + helper->getTestEndpoint(2, "tcp")); - Ice::ProcessPrx process = Ice::checkedCast<Ice::ProcessPrx>(admin->ice_facet("Process")); + auto admin = communicator->stringToProxy("IceBridge/admin:" + helper->getTestEndpoint(2, "tcp")); + auto process = Ice::checkedCast<Ice::ProcessPrx>(admin->ice_facet("Process")); process->shutdown(); cout << "ok" << endl; } diff --git a/cpp/test/IceBridge/simple/Client.cpp b/cpp/test/IceBridge/simple/Client.cpp index 392150634e3..3fecc885ffa 100644 --- a/cpp/test/IceBridge/simple/Client.cpp +++ b/cpp/test/IceBridge/simple/Client.cpp @@ -8,19 +8,19 @@ using namespace std; -class Client : public Test::TestHelper +class Client final : public Test::TestHelper { public: - void run(int argc, char** argv); + void run(int argc, char** argv) override; }; void Client::run(int argc, char** argv) { - Ice::PropertiesPtr properties = createTestProperties(argc, argv); + auto properties = createTestProperties(argc, argv); properties->setProperty("Ice.RetryIntervals", "-1"); - Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv, properties); void allTests(Test::TestHelper*); allTests(this); } diff --git a/cpp/test/IceBridge/simple/Server.cpp b/cpp/test/IceBridge/simple/Server.cpp index 4b51e5d132b..c75ae99363b 100644 --- a/cpp/test/IceBridge/simple/Server.cpp +++ b/cpp/test/IceBridge/simple/Server.cpp @@ -8,31 +8,31 @@ using namespace std; -class Server : public Test::TestHelper +class Server final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Server::run(int argc, char** argv) { - Ice::PropertiesPtr properties = createTestProperties(argc, argv); + auto properties = createTestProperties(argc, argv); properties->setProperty("Ice.Warn.Dispatch", "0"); // Make sure requests are serialized, this is required for the ordering test. properties->setProperty("Ice.ThreadPool.Server.Serialize", "1"); - Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); - communicator->getProperties()->setProperty("TestAdapter.Endpoints", - getTestEndpoint() + ":" + - getTestEndpoint("udp")); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); - adapter->add(ICE_MAKE_SHARED(MyClassI), Ice::stringToIdentity("test")); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv, properties); + communicatorHolder->getProperties()->setProperty("TestAdapter.Endpoints", + getTestEndpoint() + ":" + + getTestEndpoint("udp")); + auto adapter = communicatorHolder->createObjectAdapter("TestAdapter"); + adapter->add(make_shared<MyClassI>(), Ice::stringToIdentity("test")); adapter->activate(); serverReady(); - communicator->waitForShutdown(); + communicatorHolder->waitForShutdown(); } DEFINE_TEST(Server) diff --git a/cpp/test/IceBridge/simple/TestI.cpp b/cpp/test/IceBridge/simple/TestI.cpp index 23166c77a91..e4df7602f74 100644 --- a/cpp/test/IceBridge/simple/TestI.cpp +++ b/cpp/test/IceBridge/simple/TestI.cpp @@ -12,240 +12,158 @@ using namespace Test; namespace { -class CloseCallbackI : public Ice::CloseCallback -{ -public: - - CloseCallbackI(const MyClassIPtr& cl) : _cl(cl) - { - } - - void - closed(const Ice::ConnectionPtr& connection) - { - _cl->removeConnection(connection); - } - -private: - - MyClassIPtr _cl; -}; - -class HeartbeatCallbackI : public Ice::HeartbeatCallback -{ -public: - - HeartbeatCallbackI(const MyClassIPtr& cl) : _cl(cl) - { - } - - void - heartbeat(const Ice::ConnectionPtr& connection) - { - _cl->incHeartbeatCount(connection); - } - -private: - - MyClassIPtr _cl; -}; - -class CallbackI : public IceUtil::Shared -{ -public: - - CallbackI(const AMD_MyClass_callCallbackPtr& amdCB) : _amdCB(amdCB) - { - } - - void response() - { - _amdCB->ice_response(); - } - - void exception(const Ice::Exception& ex) - { - _amdCB->ice_exception(ex); - } - -private: - - const AMD_MyClass_callCallbackPtr _amdCB; -}; - -template<typename T> class GetCount : public IceUtil::Shared -{ -public: - - GetCount(const T& amdCB) : _amdCB(amdCB) - { - } - - void response(int count) - { - _amdCB->ice_response(count); - } - - void exception(const Ice::Exception& ex) - { - _amdCB->ice_exception(ex); - } - -private: - - const T _amdCB; -}; -typedef GetCount<AMD_MyClass_getCallbackCountPtr> GetCallbackCount; -typedef GetCount<AMD_MyClass_getCallbackDatagramCountPtr> GetCallbackDatagramCount; - Ice::Identity callbackId = { "callback" , "" }; } -MyClassI::MyClassI() : _datagramCount(0), _counter(0) -{ -} - void -MyClassI::callCallback_async(const AMD_MyClass_callCallbackPtr& amdCB, const Ice::Current& c) +MyClassI::callCallbackAsync(function<void()> response, + function<void(exception_ptr)> error, + const Ice::Current& current) { - checkConnection(c.con); - Callback_Callback_pingPtr cb = newCallback_Callback_ping(new CallbackI(amdCB), - &CallbackI::response, - &CallbackI::exception); - Ice::uncheckedCast<CallbackPrx>(c.con->createProxy(callbackId))->begin_ping(cb); + checkConnection(current.con); + auto prx = Ice::uncheckedCast<CallbackPrx>(current.con->createProxy(callbackId)); + + prx->pingAsync([response = move(response)](){ response(); }, + [error = move(error)](exception_ptr e){ error(e); }); } void -MyClassI::getCallbackCount_async(const AMD_MyClass_getCallbackCountPtr& amdCB, const Ice::Current& c) +MyClassI::getCallbackCountAsync(function<void(int)> response, + function<void(exception_ptr)> error, + const Ice::Current& current) { - checkConnection(c.con); - Callback_Callback_getCountPtr cb = newCallback_Callback_getCount(new GetCallbackCount(amdCB), - &GetCallbackCount::response, - &GetCallbackCount::exception); - Ice::uncheckedCast<CallbackPrx>(c.con->createProxy(callbackId))->begin_getCount(cb); + checkConnection(current.con); + auto prx = Ice::uncheckedCast<CallbackPrx>(current.con->createProxy(callbackId)); + + prx->getCountAsync([response = move(response)](int count){ response(count); }, + [error = move(error)](exception_ptr e){ error(e); }); } void -MyClassI::incCounter(int expected, const Ice::Current& c) +MyClassI::incCounter(int expected, const Ice::Current& current) { - checkConnection(c.con); + checkConnection(current.con); - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - if(_counter + 1 != expected) { - cout << _counter << " " << expected << endl; + lock_guard<mutex> lg(_mutex); + if(_counter + 1 != expected) + { + cout << _counter << " " << expected << endl; + } + test(++_counter == expected); } - test(++_counter == expected); - _monitor.notifyAll(); + _condVar.notify_all(); } void MyClassI::waitCounter(int value, const Ice::Current&) { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); + unique_lock<mutex> lock(_mutex); while(_counter != value) { - _monitor.wait(); + _condVar.wait(lock); } } int -MyClassI::getConnectionCount(const Ice::Current& c) +MyClassI::getConnectionCount(const Ice::Current& current) { - checkConnection(c.con); + checkConnection(current.con); return static_cast<int>(_connections.size()); } string -MyClassI::getConnectionInfo(const Ice::Current& c) +MyClassI::getConnectionInfo(const Ice::Current& current) { - checkConnection(c.con); - return c.con->toString(); + checkConnection(current.con); + return current.con->toString(); } void -MyClassI::closeConnection(bool forceful, const Ice::Current& c) +MyClassI::closeConnection(bool forceful, const Ice::Current& current) { - checkConnection(c.con); + checkConnection(current.con); if(forceful) { - c.con->close(Ice::ConnectionCloseForcefully); + current.con->close(Ice::ConnectionClose::Forcefully); } else { - c.con->close(Ice::ConnectionCloseGracefully); + current.con->close(Ice::ConnectionClose::Gracefully); } } void -MyClassI::datagram(const Ice::Current& c) +MyClassI::datagram(const Ice::Current& current) { - checkConnection(c.con); - test(c.con->getEndpoint()->getInfo()->datagram()); + checkConnection(current.con); + test(current.con->getEndpoint()->getInfo()->datagram()); ++_datagramCount; } int -MyClassI::getDatagramCount(const Ice::Current& c) +MyClassI::getDatagramCount(const Ice::Current& current) { - checkConnection(c.con); + checkConnection(current.con); return _datagramCount; } void -MyClassI::callDatagramCallback(const Ice::Current& c) +MyClassI::callDatagramCallback(const Ice::Current& current) { - checkConnection(c.con); - test(c.con->getEndpoint()->getInfo()->datagram()); - Ice::uncheckedCast<CallbackPrx>(c.con->createProxy(callbackId))->datagram(); + checkConnection(current.con); + test(current.con->getEndpoint()->getInfo()->datagram()); + Ice::uncheckedCast<CallbackPrx>(current.con->createProxy(callbackId))->datagram(); } void -MyClassI::getCallbackDatagramCount_async(const AMD_MyClass_getCallbackDatagramCountPtr& amdCB, const Ice::Current& c) +MyClassI::getCallbackDatagramCountAsync(function<void(int)> response, + function<void(exception_ptr)> error, + const Ice::Current& current) { - checkConnection(c.con); - Callback_Callback_getDatagramCountPtr cb = newCallback_Callback_getDatagramCount(new GetCallbackDatagramCount(amdCB), - &GetCallbackDatagramCount::response, - &GetCallbackDatagramCount::exception); - Ice::uncheckedCast<CallbackPrx>(c.con->createProxy(callbackId))->begin_getDatagramCount(cb); + checkConnection(current.con); + auto prx = Ice::uncheckedCast<CallbackPrx>(current.con->createProxy(callbackId)); + + prx->getDatagramCountAsync([response = move(response)](int count){ response(count); }, + [error = move(error)](auto e){ error(e); }); } int -MyClassI::getHeartbeatCount(const Ice::Current& c) +MyClassI::getHeartbeatCount(const Ice::Current& current) { - checkConnection(c.con); + checkConnection(current.con); - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - return _connections[c.con]; + lock_guard<mutex> lg(_mutex); + return _connections[current.con]; } void -MyClassI::enableHeartbeats(const Ice::Current& c) +MyClassI::enableHeartbeats(const Ice::Current& current) { - checkConnection(c.con); - c.con->setACM(1, IceUtil::None, Ice::HeartbeatAlways); + checkConnection(current.con); + current.con->setACM(1, Ice::nullopt, Ice::ACMHeartbeat::HeartbeatAlways); } void -MyClassI::shutdown(const Ice::Current& c) +MyClassI::shutdown(const Ice::Current& current) { - checkConnection(c.con); - c.adapter->getCommunicator()->shutdown(); + checkConnection(current.con); + current.adapter->getCommunicator()->shutdown(); } void -MyClassI::removeConnection(const Ice::ConnectionPtr& c) +MyClassI::removeConnection(const shared_ptr<Ice::Connection>& con) { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - _connections.erase(c); + lock_guard<mutex> lg(_mutex); + _connections.erase(con); } void -MyClassI::incHeartbeatCount(const Ice::ConnectionPtr& c) +MyClassI::incHeartbeatCount(const shared_ptr<Ice::Connection>& con) { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - map<Ice::ConnectionPtr, int>::iterator p = _connections.find(c); + lock_guard<mutex> lg(_mutex); + auto p = _connections.find(con); if(p == _connections.end()) { return; @@ -254,13 +172,13 @@ MyClassI::incHeartbeatCount(const Ice::ConnectionPtr& c) } void -MyClassI::checkConnection(const Ice::ConnectionPtr& c) +MyClassI::checkConnection(const shared_ptr<Ice::Connection>& con) { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - if(_connections.find(c) == _connections.end()) + lock_guard<mutex> lg(_mutex); + if(_connections.find(con) == _connections.end()) { - _connections.insert(make_pair(c, 0)); - c->setCloseCallback(new CloseCallbackI(this)); - c->setHeartbeatCallback(new HeartbeatCallbackI(this)); + _connections.insert(make_pair(con, 0)); + con->setCloseCallback([self = shared_from_this()](const auto& c){ self->removeConnection(c); }); + con->setHeartbeatCallback([self = shared_from_this()](const auto& c){ self->incHeartbeatCount(c); }); } } diff --git a/cpp/test/IceBridge/simple/TestI.h b/cpp/test/IceBridge/simple/TestI.h index 7ad0dec1b88..0bf58475223 100644 --- a/cpp/test/IceBridge/simple/TestI.h +++ b/cpp/test/IceBridge/simple/TestI.h @@ -7,45 +7,51 @@ #include <Test.h> -class MyClassI : public Test::MyClass +class MyClassI final : public Test::MyClass, public std::enable_shared_from_this<MyClassI> { public: - MyClassI(); + void callCallbackAsync(std::function<void()>, + std::function<void(std::exception_ptr)>, + const Ice::Current&) override; - virtual void callCallback_async(const Test::AMD_MyClass_callCallbackPtr&, const Ice::Current&); - virtual void getCallbackCount_async(const Test::AMD_MyClass_getCallbackCountPtr&, const Ice::Current&); + void getCallbackCountAsync(std::function<void(int)>, + std::function<void(std::exception_ptr)>, + const Ice::Current& current) override; - virtual void incCounter(int, const Ice::Current&); - virtual void waitCounter(int, const Ice::Current&); + void incCounter(int, const Ice::Current&) override; + void waitCounter(int, const Ice::Current&) override; - virtual int getConnectionCount(const Ice::Current&); - virtual std::string getConnectionInfo(const Ice::Current&); - virtual void closeConnection(bool, const Ice::Current&); + int getConnectionCount(const Ice::Current&) override; + std::string getConnectionInfo(const Ice::Current&) override; + void closeConnection(bool, const Ice::Current&) override; - virtual void datagram(const Ice::Current&); - virtual int getDatagramCount(const Ice::Current&); + void datagram(const Ice::Current&) override; + int getDatagramCount(const Ice::Current&) override; - virtual void callDatagramCallback(const Ice::Current&); - virtual void getCallbackDatagramCount_async(const Test::AMD_MyClass_getCallbackDatagramCountPtr&, const Ice::Current&); + void callDatagramCallback(const Ice::Current&) override; - virtual int getHeartbeatCount(const Ice::Current&); - virtual void enableHeartbeats(const Ice::Current&); + void getCallbackDatagramCountAsync(std::function<void(int)>, + std::function<void(std::exception_ptr)>, + const Ice::Current&) override; - virtual void shutdown(const Ice::Current&); + int getHeartbeatCount(const Ice::Current&) override; + void enableHeartbeats(const Ice::Current&) override; - void removeConnection(const Ice::ConnectionPtr&); - void incHeartbeatCount(const Ice::ConnectionPtr&); + void shutdown(const Ice::Current&) override; + + void removeConnection(const std::shared_ptr<Ice::Connection>&); + void incHeartbeatCount(const std::shared_ptr<Ice::Connection>&); private: - void checkConnection(const Ice::ConnectionPtr&); + void checkConnection(const std::shared_ptr<Ice::Connection>&); - IceUtil::Monitor<IceUtil::Mutex> _monitor; - int _datagramCount; - std::map<Ice::ConnectionPtr, int> _connections; - int _counter; + std::mutex _mutex; + std::condition_variable _condVar; + int _datagramCount = 0; + std::map<std::shared_ptr<Ice::Connection>, int> _connections; + int _counter = 0; }; -typedef IceUtil::Handle<MyClassI> MyClassIPtr; #endif diff --git a/cpp/test/IceGrid/activation/AllTests.cpp b/cpp/test/IceGrid/activation/AllTests.cpp index fbeda45eb40..9b477cf5659 100644 --- a/cpp/test/IceGrid/activation/AllTests.cpp +++ b/cpp/test/IceGrid/activation/AllTests.cpp @@ -4,7 +4,6 @@ #include <Ice/Ice.h> #include <IceGrid/IceGrid.h> -#include <IceUtil/Thread.h> #include <TestHelper.h> #include <Test.h> @@ -12,92 +11,63 @@ using namespace std; using namespace Test; void -waitForServerState(const IceGrid::AdminPrx& admin, const std::string& server, IceGrid::ServerState state) +waitForServerState(const shared_ptr<IceGrid::AdminPrx>& admin, const std::string& server, IceGrid::ServerState state) { int nRetry = 0; while(admin->getServerState(server) != state && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + this_thread::sleep_for(500ms); ++nRetry; } if(admin->getServerState(server) != state) { cerr << "server state change timed out:" << endl; cerr << "server: " << server << endl; - cerr << "state: " << state << endl; + cerr << "state: " << static_cast<int>(state) << endl; } } -class PingThread : public IceUtil::Thread, IceUtil::Monitor<IceUtil::Mutex> +exception_ptr +ping(const shared_ptr<Ice::ObjectPrx>& proxy, int nRepetitions) { -public: - - PingThread(const Ice::ObjectPrx& proxy, int nRepetitions) : - _proxy(proxy), _finished(false), _nRepetitions(nRepetitions) - { - } - - virtual void run() + exception_ptr exception = nullptr; + for(int i = 0; i < nRepetitions; ++i) { - for(int i = 0; i < _nRepetitions; ++i) + try { - try - { - _proxy->ice_ping(); - } - catch(const Ice::LocalException& ex) - { - _exception.reset(ex.ice_clone()); - } - catch(...) - { - assert(false); - } + proxy->ice_ping(); } - - Lock sync(*this); - _finished = true; - notifyAll(); - } - - Ice::LocalException* - waitUntilFinished() - { - Lock sync(*this); - while(!_finished) + catch(const Ice::LocalException&) { - wait(); + exception = std::current_exception(); + } + catch(...) + { + assert(false); } - return _exception.release(); } -private: - - Ice::ObjectPrx _proxy; - IceInternal::UniquePtr<Ice::LocalException> _exception; - bool _finished; - int _nRepetitions; -}; -typedef IceUtil::Handle<PingThread> PingThreadPtr; + return exception; +} void allTests(Test::TestHelper* helper) { - Ice::CommunicatorPtr communicator = helper->communicator(); - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( + auto communicator = helper->communicator(); + auto registry = Ice::checkedCast<IceGrid::RegistryPrx>( communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast( + auto query = Ice::checkedCast<IceGrid::QueryPrx>( communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Query")); - IceGrid::AdminSessionPrx adminSession = registry->createAdminSession("foo", "bar"); + auto adminSession = registry->createAdminSession("foo", "bar"); adminSession->ice_getConnection()->setACM(registry->getACMTimeout(), - IceUtil::None, - Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + Ice::nullopt, + Ice::ACMHeartbeat::HeartbeatAlways); - IceGrid::AdminPrx admin = adminSession->getAdmin(); + auto admin = adminSession->getAdmin(); test(admin); admin->startServer("node-1"); @@ -106,31 +76,31 @@ allTests(Test::TestHelper* helper) int nRetry = 0; while(!admin->pingNode("node-1") && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); ++nRetry; } nRetry = 0; while(!admin->pingNode("node-2") && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); ++nRetry; } cout << "testing on-demand activation... " << flush; try { - test(admin->getServerState("server") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server")); - waitForServerState(admin, "server", IceGrid::Active); + test(admin->getServerState("server") == IceGrid::ServerState::Inactive); + auto obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server")); + waitForServerState(admin, "server", IceGrid::ServerState::Active); obj->shutdown(); - waitForServerState(admin, "server", IceGrid::Inactive); + waitForServerState(admin, "server", IceGrid::ServerState::Inactive); nRetry = 4; while(--nRetry > 0) { obj->shutdown(); } - waitForServerState(admin, "server", IceGrid::Inactive); + waitForServerState(admin, "server", IceGrid::ServerState::Inactive); } catch(const Ice::LocalException& ex) { @@ -142,23 +112,23 @@ allTests(Test::TestHelper* helper) cout << "testing manual activation... " << flush; try { - test(admin->getServerState("server-manual") == IceGrid::Inactive); - TestIntfPrx obj; + test(admin->getServerState("server-manual") == IceGrid::ServerState::Inactive); + shared_ptr<TestIntfPrx> obj; try { - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); + obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server-manual")); test(false); } catch(const Ice::NoEndpointException&) { } - test(admin->getServerState("server-manual") == IceGrid::Inactive); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Inactive); admin->startServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); - test(admin->getServerState("server-manual") == IceGrid::Active); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Active); + obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server-manual")); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Active); obj->shutdown(); - waitForServerState(admin, "server-manual", IceGrid::Inactive); + waitForServerState(admin, "server-manual", IceGrid::ServerState::Inactive); } catch(const Ice::LocalException& ex) { @@ -170,18 +140,18 @@ allTests(Test::TestHelper* helper) cout << "testing always activation... " << flush; try { - waitForServerState(admin, "server-always", IceGrid::Active); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-always")); + waitForServerState(admin, "server-always", IceGrid::ServerState::Active); + auto obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server-always")); admin->stopServer("server-always"); - waitForServerState(admin, "server-always", IceGrid::Active); + waitForServerState(admin, "server-always", IceGrid::ServerState::Active); obj->shutdown(); - waitForServerState(admin, "server-always", IceGrid::Active); + waitForServerState(admin, "server-always", IceGrid::ServerState::Active); nRetry = 4; while(--nRetry > 0) { obj->shutdown(); } - waitForServerState(admin, "server-always", IceGrid::Active); + waitForServerState(admin, "server-always", IceGrid::ServerState::Active); } catch(const Ice::LocalException& ex) { @@ -193,10 +163,10 @@ allTests(Test::TestHelper* helper) cout << "testing session activation... " << flush; try { - IceGrid::SessionPrx session = registry->createSession("test", ""); + auto session = registry->createSession("test", ""); - test(admin->getServerState("server-session") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-session")); + test(admin->getServerState("server-session") == IceGrid::ServerState::Inactive); + auto obj = Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("server-session")); try { obj->ice_ping(); @@ -207,18 +177,18 @@ allTests(Test::TestHelper* helper) } session->allocateObjectById(obj->ice_getIdentity()); obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); + waitForServerState(admin, "server-session", IceGrid::ServerState::Active); obj->shutdown(); - waitForServerState(admin, "server-session", IceGrid::Inactive); + waitForServerState(admin, "server-session", IceGrid::ServerState::Inactive); obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); + waitForServerState(admin, "server-session", IceGrid::ServerState::Active); nRetry = 4; while(--nRetry > 0) { obj->shutdown(); } obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); + waitForServerState(admin, "server-session", IceGrid::ServerState::Active); session->releaseObject(obj->ice_getIdentity()); try { @@ -228,11 +198,11 @@ allTests(Test::TestHelper* helper) catch(const Ice::NoEndpointException&) { } - waitForServerState(admin, "server-session", IceGrid::Inactive); + waitForServerState(admin, "server-session", IceGrid::ServerState::Inactive); session->allocateObjectById(obj->ice_getIdentity()); obj->ice_ping(); - waitForServerState(admin, "server-session", IceGrid::Active); + waitForServerState(admin, "server-session", IceGrid::ServerState::Active); session->destroy(); try { @@ -242,7 +212,7 @@ allTests(Test::TestHelper* helper) catch(const Ice::NoEndpointException&) { } - waitForServerState(admin, "server-session", IceGrid::Inactive); + waitForServerState(admin, "server-session", IceGrid::ServerState::Inactive); } catch(const Ice::LocalException& ex) { @@ -256,7 +226,7 @@ allTests(Test::TestHelper* helper) { size_t count = query->findAllObjectsByType("Test").size(); - test(admin->getServerState("server") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::ServerState::Inactive); admin->enableServer("server", false); try { @@ -271,7 +241,7 @@ allTests(Test::TestHelper* helper) { // The notification of the server being disabled is asynchronous and might // not be visible to the Query interface immediately. - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + this_thread::sleep_for(100ms); } try @@ -282,9 +252,9 @@ allTests(Test::TestHelper* helper) catch(const IceGrid::ServerStartException&) { } - test(admin->getServerState("server") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::ServerState::Inactive); - test(admin->getServerState("server-manual") == IceGrid::Inactive); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Inactive); admin->enableServer("server-manual", false); try { @@ -302,18 +272,18 @@ allTests(Test::TestHelper* helper) catch(const IceGrid::ServerStartException&) { } - test(admin->getServerState("server-manual") == IceGrid::Inactive); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Inactive); while(query->findAllObjectsByType("Test").size() != count - 2) { // The notification of the server being disabled is asynchronous and might // not be visible to the Query interface immediately. - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + this_thread::sleep_for(100ms); } - test(admin->getServerState("server-always") == IceGrid::Active); + test(admin->getServerState("server-always") == IceGrid::ServerState::Active); admin->enableServer("server-always", false); admin->stopServer("server-always"); - test(admin->getServerState("server-always") == IceGrid::Inactive); + test(admin->getServerState("server-always") == IceGrid::ServerState::Inactive); try { communicator->stringToProxy("server-always")->ice_ping(); @@ -330,20 +300,20 @@ allTests(Test::TestHelper* helper) catch(const IceGrid::ServerStartException&) { } - test(admin->getServerState("server-always") == IceGrid::Inactive); + test(admin->getServerState("server-always") == IceGrid::ServerState::Inactive); while(query->findAllObjectsByType("Test").size() != count - 3) { // The notification of the server being disabled is asynchronous and might // not be visible to the Query interface immediately. - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + this_thread::sleep_for(100ms); } - test(admin->getServerState("server") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::ServerState::Inactive); admin->enableServer("server", true); communicator->stringToProxy("server")->ice_locatorCacheTimeout(0)->ice_ping(); int pid = admin->getServerPid("server"); admin->enableServer("server", false); - test(admin->getServerState("server") == IceGrid::Active); + test(admin->getServerState("server") == IceGrid::ServerState::Active); try { communicator->stringToProxy("server")->ice_locatorCacheTimeout(0)->ice_ping(); @@ -356,13 +326,13 @@ allTests(Test::TestHelper* helper) communicator->stringToProxy("server")->ice_locatorCacheTimeout(0)->ice_ping(); test(admin->getServerPid("server") == pid); admin->stopServer("server"); - test(admin->getServerState("server") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::ServerState::Inactive); while(query->findAllObjectsByType("Test").size() != count - 2) { // The notification of the server being disabled is asynchronous and might // not be visible to the Query interface immediately. - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + this_thread::sleep_for(100ms); } } catch(const Ice::LocalException& ex) @@ -375,17 +345,17 @@ allTests(Test::TestHelper* helper) cout << "testing server enable... " << flush; try { - test(admin->getServerState("server") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::ServerState::Inactive); admin->enableServer("server", true); communicator->stringToProxy("server")->ice_ping(); admin->stopServer("server"); - test(admin->getServerState("server") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::ServerState::Inactive); admin->startServer("server"); - test(admin->getServerState("server") == IceGrid::Active); + test(admin->getServerState("server") == IceGrid::ServerState::Active); admin->stopServer("server"); - test(admin->getServerState("server") == IceGrid::Inactive); + test(admin->getServerState("server") == IceGrid::ServerState::Inactive); - test(admin->getServerState("server-manual") == IceGrid::Inactive); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Inactive); admin->enableServer("server-manual", true); try { @@ -395,25 +365,19 @@ allTests(Test::TestHelper* helper) catch(const Ice::NoEndpointException&) { } - test(admin->getServerState("server-manual") == IceGrid::Inactive); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Inactive); admin->startServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Active); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Active); admin->stopServer("server-manual"); - test(admin->getServerState("server-manual") == IceGrid::Inactive); + test(admin->getServerState("server-manual") == IceGrid::ServerState::Inactive); - test(admin->getServerState("server-always") == IceGrid::Inactive); + test(admin->getServerState("server-always") == IceGrid::ServerState::Inactive); admin->enableServer("server-always", true); - waitForServerState(admin, "server-always", IceGrid::Active); + waitForServerState(admin, "server-always", IceGrid::ServerState::Active); admin->stopServer("server-always"); - try - { - admin->startServer("server-always"); -// test(false); - } - catch(const IceGrid::ServerStartException&) - { - } - test(admin->getServerState("server-always") == IceGrid::Active); + + admin->startServer("server-always"); + test(admin->getServerState("server-always") == IceGrid::ServerState::Active); } catch(const Ice::LocalException& ex) { @@ -425,71 +389,76 @@ allTests(Test::TestHelper* helper) cout << "testing activation failure... " << flush; try { - int i; + auto invalid = communicator->stringToProxy("invalid-exe"); + + future<exception_ptr> futures[3] = {}; const int nThreads = 3; - Ice::ObjectPrx invalid = communicator->stringToProxy("invalid-exe"); - vector<PingThreadPtr> threads; - threads.reserve(nThreads); - vector<PingThreadPtr>::const_iterator p; - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 10)); - } - for(p = threads.begin(); p != threads.end(); ++p) + for(int i = 0; i < nThreads; i++) { - (*p)->start(); + futures[i] = async(launch::async, [&invalid] { return ping(invalid, 10); }); } - for(p = threads.begin(); p != threads.end(); ++p) + for(int i = 0; i < nThreads; i++) { - IceInternal::UniquePtr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->getThreadControl().join(); + try + { + auto exception = futures[i].get(); + test(exception); + rethrow_exception(exception); + } + catch(const Ice::NoEndpointException&) + { + } + catch(...) + { + test(false); + } } - threads.resize(0); invalid = communicator->stringToProxy("invalid-pwd"); - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 10)); - } - for(p = threads.begin(); p != threads.end(); ++p) + for(int i = 0; i < nThreads; i++) { - (*p)->start(); + futures[i] = async(launch::async, [&invalid] { return ping(invalid, 10); }); } - for(p = threads.begin(); p != threads.end(); ++p) + for(int i = 0; i < nThreads; i++) { - IceInternal::UniquePtr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->getThreadControl().join(); + try + { + auto exception = futures[i].get(); + test(exception); + rethrow_exception(exception); + } + catch(const Ice::NoEndpointException&) + { + } + catch(...) + { + test(false); + } } - threads.resize(0); invalid = communicator->stringToProxy("fail-on-startup"); - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(invalid, 5)); - } - for(p = threads.begin(); p != threads.end(); ++p) + for(int i = 0; i < nThreads; i++) { - (*p)->start(); + futures[i] = async(launch::async, [&invalid] { return ping(invalid, 5); }); } - for(p = threads.begin(); p != threads.end(); ++p) + for(int i = 0; i < nThreads; i++) { - IceInternal::UniquePtr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->getThreadControl().join(); + + try + { + auto exception = futures[i].get(); + test(exception); + rethrow_exception(exception); + } + catch(const Ice::NoEndpointException&) + { + } + catch(...) + { + test(false); + } } - threads.resize(0); try { @@ -521,29 +490,30 @@ allTests(Test::TestHelper* helper) cout << "testing activation timeout... " << flush; try { - test(admin->getServerState("server-activation-timeout") == IceGrid::Inactive); + test(admin->getServerState("server-activation-timeout") == IceGrid::ServerState::Inactive); const int nThreads = 5; - Ice::ObjectPrx proxy = communicator->stringToProxy("server-activation-timeout"); - vector<PingThreadPtr> threads; + auto proxy = communicator->stringToProxy("server-activation-timeout"); + vector<future<exception_ptr>> threads; threads.reserve(nThreads); - vector<PingThreadPtr>::const_iterator p; - int i; - for(i = 0; i < nThreads; i++) - { - threads.push_back(new PingThread(proxy, 1)); - } - for(p = threads.begin(); p != threads.end(); ++p) - { - (*p)->start(); - } - for(p = threads.begin(); p != threads.end(); ++p) + for(int i = 0; i < nThreads; i++) { - IceInternal::UniquePtr<Ice::LocalException> ex((*p)->waitUntilFinished()); - test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); + threads.push_back(async(launch::async, [&proxy] { return ping(proxy, 1); })); } - for(p = threads.begin(); p != threads.end(); ++p) + for(auto& p: threads) { - (*p)->getThreadControl().join(); + try + { + auto exception = p.get(); + test(exception); + rethrow_exception(exception); + } + catch(const Ice::NoEndpointException&) + { + } + catch(...) + { + test(false); + } } admin->stopServer("server-activation-timeout"); } @@ -562,7 +532,7 @@ allTests(Test::TestHelper* helper) cout << "testing deactivation timeout... " << flush; try { - test(admin->getServerState("server-deactivation-timeout") == IceGrid::Inactive); + test(admin->getServerState("server-deactivation-timeout") == IceGrid::ServerState::Inactive); communicator->stringToProxy("server-deactivation-timeout")->ice_ping(); admin->stopServer("server-deactivation-timeout"); } @@ -576,11 +546,11 @@ allTests(Test::TestHelper* helper) cout << "testing permanent disable on failure... " << flush; try { - test(admin->getServerState("server1") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1")); - waitForServerState(admin, "server1", IceGrid::Active); + test(admin->getServerState("server1") == IceGrid::ServerState::Inactive); + auto obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server1")); + waitForServerState(admin, "server1", IceGrid::ServerState::Active); obj->fail(); - waitForServerState(admin, "server1", IceGrid::Inactive); + waitForServerState(admin, "server1", IceGrid::ServerState::Inactive); try { obj->ice_ping(); @@ -591,19 +561,19 @@ allTests(Test::TestHelper* helper) } test(!admin->isServerEnabled("server1")); - test(admin->getServerState("server1-manual") == IceGrid::Inactive); + test(admin->getServerState("server1-manual") == IceGrid::ServerState::Inactive); admin->startServer("server1-manual"); - test(admin->getServerState("server1-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-manual")); - test(admin->getServerState("server1-manual") == IceGrid::Active); + test(admin->getServerState("server1-manual") == IceGrid::ServerState::Active); + obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server1-manual")); + test(admin->getServerState("server1-manual") == IceGrid::ServerState::Active); obj->fail(); - waitForServerState(admin, "server1-manual", IceGrid::Inactive); + waitForServerState(admin, "server1-manual", IceGrid::ServerState::Inactive); test(!admin->isServerEnabled("server1-manual")); - test(admin->getServerState("server1-always") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-always")); + test(admin->getServerState("server1-always") == IceGrid::ServerState::Active); + obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server1-always")); obj->fail(); - waitForServerState(admin, "server1-always", IceGrid::Inactive); + waitForServerState(admin, "server1-always", IceGrid::ServerState::Inactive); test(!admin->isServerEnabled("server1-always")); } catch(const Ice::LocalException& ex) @@ -616,33 +586,31 @@ allTests(Test::TestHelper* helper) cout << "testing temporary disable on failure... " << flush; try { - test(admin->getServerState("server2") == IceGrid::Inactive); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server2")); + test(admin->getServerState("server2") == IceGrid::ServerState::Inactive); + auto obj = Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("server2")); + obj = obj->ice_locatorCacheTimeout(0); while(true) { obj->ice_ping(); - waitForServerState(admin, "server2", IceGrid::Active); - IceUtil::Time now = IceUtil::Time::now(); + waitForServerState(admin, "server2", IceGrid::ServerState::Active); + auto now = std::chrono::steady_clock::now(); obj->fail(); - waitForServerState(admin, "server2", IceGrid::Inactive); + waitForServerState(admin, "server2", IceGrid::ServerState::Inactive); try { obj->ice_ping(); - test(IceUtil::Time::now() - now >= IceUtil::Time::seconds(3)); + test(chrono::steady_clock::now() - now >= 2s); } - catch (const Ice::NoEndpointException&) + catch(const Ice::NoEndpointException&) { - if (!admin->isServerEnabled("server2")) - { - break; // Success - } + break; // Success } } test(!admin->isServerEnabled("server2")); nRetry = 0; while(!admin->isServerEnabled("server2") && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + this_thread::sleep_for(500ms); ++nRetry; try { @@ -653,36 +621,36 @@ allTests(Test::TestHelper* helper) } } test(admin->isServerEnabled("server2")); - waitForServerState(admin, "server2", IceGrid::Active); + waitForServerState(admin, "server2", IceGrid::ServerState::Active); obj->ice_ping(); admin->stopServer("server2"); - test(admin->getServerState("server2-manual") == IceGrid::Inactive); + test(admin->getServerState("server2-manual") == IceGrid::ServerState::Inactive); admin->startServer("server2-manual"); - test(admin->getServerState("server2-manual") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-manual")); + test(admin->getServerState("server2-manual") == IceGrid::ServerState::Active); + obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server2-manual")); obj->fail(); - waitForServerState(admin, "server2-manual", IceGrid::Inactive); + waitForServerState(admin, "server2-manual", IceGrid::ServerState::Inactive); test(!admin->isServerEnabled("server2-manual")); admin->startServer("server2-manual"); test(admin->isServerEnabled("server2-manual")); - test(admin->getServerState("server2-manual") == IceGrid::Active); + test(admin->getServerState("server2-manual") == IceGrid::ServerState::Active); admin->stopServer("server2-manual"); - test(admin->getServerState("server2-always") == IceGrid::Active); - obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-always")); + test(admin->getServerState("server2-always") == IceGrid::ServerState::Active); + obj = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("server2-always")); obj->fail(); - waitForServerState(admin, "server2-always", IceGrid::Inactive); + waitForServerState(admin, "server2-always", IceGrid::ServerState::Inactive); test(!admin->isServerEnabled("server2-always")); nRetry = 0; while((!admin->isServerEnabled("server2-always") || - admin->getServerState("server2-always") != IceGrid::Active) && + admin->getServerState("server2-always") != IceGrid::ServerState::Active) && nRetry < 15) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + this_thread::sleep_for(500ms); ++nRetry; } - test(admin->isServerEnabled("server2-always") && admin->getServerState("server2-always") == IceGrid::Active); + test(admin->isServerEnabled("server2-always") && admin->getServerState("server2-always") == IceGrid::ServerState::Active); obj->ice_ping(); } catch(const Ice::LocalException& ex) diff --git a/cpp/test/IceGrid/activation/Client.cpp b/cpp/test/IceGrid/activation/Client.cpp index 2d596beb2e9..9c4f8efc387 100644 --- a/cpp/test/IceGrid/activation/Client.cpp +++ b/cpp/test/IceGrid/activation/Client.cpp @@ -13,7 +13,7 @@ class Client : public Test::TestHelper { public: - void run(int, char**); + void run(int argc, char** argv) override; }; void diff --git a/cpp/test/IceGrid/activation/Server.cpp b/cpp/test/IceGrid/activation/Server.cpp index 2b683cd5176..e0cc2928d4b 100644 --- a/cpp/test/IceGrid/activation/Server.cpp +++ b/cpp/test/IceGrid/activation/Server.cpp @@ -3,20 +3,19 @@ // #include <Ice/Ice.h> -#include <IceUtil/Thread.h> #include <TestI.h> #include <TestHelper.h> using namespace std; -class Server : public Test::TestHelper +class Server final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; -class TestActivationFailure : public std::runtime_error +class TestActivationFailure final : public std::runtime_error { public: @@ -29,21 +28,21 @@ public: void Server::run(int argc, char** argv) { - Ice::PropertiesPtr properties = createTestProperties(argc, argv); + auto properties = createTestProperties(argc, argv); if(properties->getPropertyAsInt("FailOnStartup") > 0) { throw TestActivationFailure("FailOnStartup"); } Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); - TestIPtr testI = ICE_MAKE_SHARED(TestI); + auto adapter = communicator->createObjectAdapter("TestAdapter"); + auto testI = make_shared<TestI>(); adapter->add(testI, Ice::stringToIdentity(properties->getProperty("Ice.Admin.ServerId"))); int delay = properties->getPropertyAsInt("ActivationDelay"); if(delay > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); + this_thread::sleep_for(chrono::seconds(delay)); } try @@ -58,7 +57,7 @@ Server::run(int argc, char** argv) delay = properties->getPropertyAsInt("DeactivationDelay"); if(delay > 0) { - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(delay)); + this_thread::sleep_for(chrono::seconds(delay)); } if(testI->isFailed()) diff --git a/cpp/test/IceGrid/activation/TestI.h b/cpp/test/IceGrid/activation/TestI.h index 35dc14c474c..41bf9ea266b 100644 --- a/cpp/test/IceGrid/activation/TestI.h +++ b/cpp/test/IceGrid/activation/TestI.h @@ -7,14 +7,14 @@ #include <Test.h> -class TestI : public ::Test::TestIntf +class TestI final : public Test::TestIntf { public: TestI(); - virtual void fail(const Ice::Current&); - virtual void shutdown(const Ice::Current&); + void fail(const Ice::Current&) override; + void shutdown(const Ice::Current&) override; bool isFailed() const; @@ -22,5 +22,5 @@ private: bool _failed; }; -ICE_DEFINE_PTR(TestIPtr, TestI); + #endif diff --git a/cpp/test/IceGrid/admin/Server.cpp b/cpp/test/IceGrid/admin/Server.cpp index 0267760d951..d3803457748 100644 --- a/cpp/test/IceGrid/admin/Server.cpp +++ b/cpp/test/IceGrid/admin/Server.cpp @@ -7,18 +7,18 @@ using namespace std; -class Server : public Test::TestHelper +class Server final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Server::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + auto adapter = communicator->createObjectAdapter("TestAdapter"); try { adapter->activate(); diff --git a/cpp/test/IceGrid/admin/test.py b/cpp/test/IceGrid/admin/test.py index 5e96d6787d3..65ef4f964cd 100644 --- a/cpp/test/IceGrid/admin/test.py +++ b/cpp/test/IceGrid/admin/test.py @@ -149,7 +149,7 @@ class IceGridAdminTestCase(IceGridTestCase): raise RuntimeError("failed!\n" + str(e)) routerProps= lambda process, current: { - 'Glacier2.SessionTimeout' : 5, + 'Glacier2.Client.ACM.Timeout' : 5, 'Glacier2.SessionManager' : 'TestIceGrid/AdminSessionManager', 'Glacier2.PermissionsVerifier' : 'Glacier2/NullPermissionsVerifier', 'Glacier2.SSLSessionManager' : 'TestIceGrid/AdminSSLSessionManager', diff --git a/cpp/test/IceGrid/allocation/AllTests.cpp b/cpp/test/IceGrid/allocation/AllTests.cpp index 3543e07e67c..268660f8120 100644 --- a/cpp/test/IceGrid/allocation/AllTests.cpp +++ b/cpp/test/IceGrid/allocation/AllTests.cpp @@ -2,19 +2,19 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/Thread.h> -#include <IceUtil/Random.h> #include <Ice/Ice.h> #include <IceGrid/IceGrid.h> #include <Glacier2/Router.h> #include <TestHelper.h> #include <Test.h> +#include <random> + using namespace std; using namespace Test; using namespace IceGrid; -class Callback : public IceUtil::Monitor<IceUtil::Mutex>, public virtual IceUtil::Shared +class Callback { public: @@ -23,36 +23,38 @@ public: } void - response(const Ice::ObjectPrx& obj) + response(shared_ptr<Ice::ObjectPrx> obj) { - Lock sync(*this); - _response = true; - _obj = obj; - notify(); + { + lock_guard<mutex> lg(_mutex); + _response = true; + _obj = move(obj); + } + + _condVar.notify_one(); } void - exception(const Ice::Exception&) + exception(exception_ptr) { - Lock sync(*this); - _exception = true; - notify(); + { + lock_guard<mutex> lg(_mutex); + _exception = true; + } + _condVar.notify_one(); } void waitResponse(const char*, int) { - Lock sync(*this); - while(!_response && !_exception) - { - wait(); - } + unique_lock<mutex> lock(_mutex); + _condVar.wait(lock, [&] { return _response || _exception; }); } bool - hasResponse(Ice::ObjectPrx& obj) + hasResponse(shared_ptr<Ice::ObjectPrx>& obj) { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); obj = _obj; return _response; } @@ -60,7 +62,7 @@ public: bool hasException() { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); return _exception; } @@ -68,50 +70,45 @@ private: bool _response; bool _exception; - Ice::ObjectPrx _obj; + mutex _mutex; + condition_variable _condVar; + shared_ptr<Ice::ObjectPrx> _obj; }; -typedef IceUtil::Handle<Callback> CallbackPtr; -class StressClient : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> +class StressClient { public: - StressClient(int id, const RegistryPrx& registry, bool destroySession) : - _communicator(registry->ice_getCommunicator()), + StressClient(int id, shared_ptr<RegistryPrx> registry, bool destroySession) : _id(id), - _registry(registry), + _registry(move(registry)), _notified(false), _terminated(false), _destroySession(destroySession) { } - StressClient(int id, const SessionPrx& session) : - _communicator(session->ice_getCommunicator()), + StressClient(int id, shared_ptr<SessionPrx> session) : _id(id), - _session(session), + _session(move(session)), _notified(false), _terminated(false), _destroySession(false) { } - virtual void run() { { - Lock sync(*this); - while(!_notified) - { - wait(); - } + unique_lock<mutex> lock(_mutex); + _condVar.wait(lock, [&] { return _notified == true; }); } - SessionPrx session; + shared_ptr<SessionPrx> session; while(true) { { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); if(_terminated) { if(!_session && session) @@ -133,15 +130,15 @@ public: else { session = _registry->createSession(os.str(), ""); - session->setAllocationTimeout(static_cast<Ice::Int>(IceUtilInternal::random(200))); // 200ms timeout + session->setAllocationTimeout(static_cast<int>(_rd() % 200)); // 200ms timeout } } assert(session); session->keepAlive(); - Ice::ObjectPrx object; - switch(IceUtilInternal::random(_destroySession ? 4 : 2)) + shared_ptr<Ice::ObjectPrx> object; + switch( _rd() % (_destroySession ? 4 : 2)) { case 0: object = allocate(session); @@ -163,8 +160,8 @@ public: if(object) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(IceUtilInternal::random(20))); - switch(IceUtilInternal::random(_destroySession ? 2 : 1)) + this_thread::sleep_for(20ms); + switch(_rd() % (_destroySession ? 2 : 1)) { case 0: session->releaseObject(object->ice_getIdentity()); @@ -179,11 +176,11 @@ public: } } - Ice::ObjectPrx - allocate(const SessionPrx& session) + shared_ptr<Ice::ObjectPrx> + allocate(const shared_ptr<SessionPrx>& session) { ostringstream os; - os << "stress-" << IceUtilInternal::random(6) + 1; + os << "stress-" << (_rd() % 6) + 1; try { return session->allocateObjectById(Ice::stringToIdentity(os.str())); @@ -200,8 +197,8 @@ public: return 0; } - Ice::ObjectPrx - allocateByType(const SessionPrx& session) + shared_ptr<Ice::ObjectPrx> + allocateByType(const shared_ptr<SessionPrx>& session) { try { @@ -214,68 +211,74 @@ public: } void - allocateAndDestroy(const SessionPrx& session) + allocateAndDestroy(const shared_ptr<SessionPrx>& session) { ostringstream os; - os << "stress-" << IceUtilInternal::random(3); - CallbackPtr asyncCB = new Callback(); - IceGrid::Callback_Session_allocateObjectByIdPtr cb = - IceGrid::newCallback_Session_allocateObjectById(asyncCB, &Callback::response, &Callback::exception); - session->begin_allocateObjectById(Ice::stringToIdentity(os.str()), cb); + os << "stress-" << (_rd() % 3); + + auto asyncCB = make_shared<Callback>(); + session->allocateObjectByIdAsync(Ice::stringToIdentity(os.str()), + [asyncCB](shared_ptr<Ice::ObjectPrx> o) { asyncCB->response(move(o)); }, + [asyncCB](exception_ptr e) { asyncCB->exception(e); }); session->destroy(); } void - allocateByTypeAndDestroy(const SessionPrx& session) + allocateByTypeAndDestroy(const shared_ptr<SessionPrx>& session) { - CallbackPtr asyncCB = new Callback(); - IceGrid::Callback_Session_allocateObjectByTypePtr cb = - IceGrid::newCallback_Session_allocateObjectByType(asyncCB, &Callback::response, &Callback::exception); - session->begin_allocateObjectByType("::StressTest", cb); + auto asyncCB = make_shared<Callback>(); + session->allocateObjectByTypeAsync("::StressTest", + [asyncCB](shared_ptr<Ice::ObjectPrx> o) { asyncCB->response(move(o)); }, + [asyncCB](exception_ptr e) { asyncCB->exception(e); }); session->destroy(); } void notifyThread() { - Lock sync(*this); - _notified = true; - notify(); + { + lock_guard<mutex> lg(_mutex); + _notified = true; + } + _condVar.notify_one(); } void terminate() { - Lock sync(*this); - _terminated = true; - notify(); + { + lock_guard<mutex> lg(_mutex); + _terminated = true; + } + _condVar.notify_one(); } protected: - const Ice::CommunicatorPtr _communicator; const int _id; - const RegistryPrx _registry; - const SessionPrx _session; + const shared_ptr<RegistryPrx> _registry; + const shared_ptr<SessionPrx> _session; bool _notified; bool _terminated; const bool _destroySession; + mutex _mutex; + condition_variable _condVar; + random_device _rd; }; -typedef IceUtil::Handle<StressClient> StressClientPtr; void allTests(Test::TestHelper* helper) { - Ice::CommunicatorPtr communicator = helper->communicator(); - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( + auto communicator = helper->communicator(); + auto registry = Ice::checkedCast<RegistryPrx>( communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - AdminSessionPrx session = registry->createAdminSession("foo", "bar"); + auto session = registry->createAdminSession("foo", "bar"); session->ice_getConnection()->setACM(registry->getACMTimeout(), - IceUtil::None, - Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + Ice::nullopt, + Ice::ACMHeartbeat::HeartbeatAlways); - AdminPrx admin = session->getAdmin(); + auto admin = session->getAdmin(); test(admin); cout << "starting router... " << flush; @@ -292,20 +295,20 @@ allTests(Test::TestHelper* helper) const int allocationTimeout = 5000; - Ice::ObjectPrx obj; - Ice::ObjectPrx dummy; + shared_ptr<Ice::ObjectPrx> obj; + shared_ptr<Ice::ObjectPrx> dummy; try { cout << "testing create session... " << flush; - SessionPrx session1 = registry->createSession("Client1", ""); - SessionPrx session2 = registry->createSession("Client2", ""); + auto session1 = registry->createSession("Client1", ""); + auto session2 = registry->createSession("Client2", ""); cout << "ok" << endl; cout << "testing allocate object by identity... " << flush; - Ice::Identity allocatable = Ice::stringToIdentity("allocatable"); - Ice::Identity allocatablebis = Ice::stringToIdentity("allocatablebis"); + auto allocatable = Ice::stringToIdentity("allocatable"); + auto allocatablebis = Ice::stringToIdentity("allocatablebis"); try { @@ -427,13 +430,11 @@ allTests(Test::TestHelper* helper) session2->setAllocationTimeout(allocationTimeout); - CallbackPtr asyncCB1 = new Callback(); - IceGrid::Callback_Session_allocateObjectByIdPtr cb1 = IceGrid::newCallback_Session_allocateObjectById(asyncCB1, - &Callback::response, - &Callback::exception); - - session2->begin_allocateObjectById(allocatable, cb1); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + auto asyncCB1 = make_shared<Callback>(); + session2->allocateObjectByIdAsync(allocatable, + [&asyncCB1](shared_ptr<Ice::ObjectPrx> o) { asyncCB1->response(o); }, + [&asyncCB1](exception_ptr e) { asyncCB1->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB1->hasResponse(dummy)); session1->releaseObject(allocatable); asyncCB1->waitResponse(__FILE__, __LINE__); @@ -457,12 +458,11 @@ allTests(Test::TestHelper* helper) { } session1->setAllocationTimeout(allocationTimeout); - asyncCB1 = new Callback(); - cb1 = IceGrid::newCallback_Session_allocateObjectById(asyncCB1, - &Callback::response, - &Callback::exception); - session1->begin_allocateObjectById(allocatable, cb1); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + asyncCB1 = make_shared<Callback>(); + session1->allocateObjectByIdAsync(allocatable, + [&asyncCB1](shared_ptr<Ice::ObjectPrx> o) { asyncCB1->response(o); }, + [&asyncCB1](exception_ptr e) { asyncCB1->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB1->hasResponse(dummy)); session2->releaseObject(allocatable); asyncCB1->waitResponse(__FILE__, __LINE__); @@ -578,12 +578,11 @@ allTests(Test::TestHelper* helper) session2->releaseObject(allocatablebis); session1->setAllocationTimeout(allocationTimeout); - CallbackPtr asyncCB3 = new Callback(); - IceGrid::Callback_Session_allocateObjectByTypePtr cb3 = - IceGrid::newCallback_Session_allocateObjectByType(asyncCB3, &Callback::response, &Callback::exception); - - session1->begin_allocateObjectByType("::Test", cb3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + auto asyncCB3 = make_shared<Callback>(); + session1->allocateObjectByTypeAsync("::Test", + [&asyncCB3](shared_ptr<Ice::ObjectPrx> o) { asyncCB3->response(o); }, + [&asyncCB3](exception_ptr e) { asyncCB3->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB3->hasResponse(dummy)); session2->releaseObject(obj->ice_getIdentity()); asyncCB3->waitResponse(__FILE__, __LINE__); @@ -600,7 +599,7 @@ allTests(Test::TestHelper* helper) // not be visible to the allocation system immediately. session1->allocateObjectByType("::Test"); session1->releaseObject(obj->ice_getIdentity()); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + this_thread::sleep_for(100ms); } test(false); } @@ -614,7 +613,7 @@ allTests(Test::TestHelper* helper) cout << "testing object allocation timeout... " << flush; session1->allocateObjectById(allocatable); - IceUtil::Time time = IceUtil::Time::now(); + auto time = chrono::system_clock::now(); session2->setAllocationTimeout(500); try { @@ -623,9 +622,9 @@ allTests(Test::TestHelper* helper) } catch(const AllocationTimeoutException&) { - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); + test(time + 100ms < chrono::system_clock::now()); } - time = IceUtil::Time::now(); + time = chrono::system_clock::now(); try { session2->allocateObjectById(allocatable); @@ -634,8 +633,8 @@ allTests(Test::TestHelper* helper) catch(const AllocationTimeoutException&) { } - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); - time = IceUtil::Time::now(); + test(time + 100ms < chrono::system_clock::now()); + time = chrono::system_clock::now(); try { session2->allocateObjectByType("::Test"); @@ -644,7 +643,7 @@ allTests(Test::TestHelper* helper) catch(const AllocationTimeoutException&) { } - test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); + test(time + 100ms < chrono::system_clock::now()); session1->releaseObject(allocatable); session2->setAllocationTimeout(0); @@ -755,10 +754,11 @@ allTests(Test::TestHelper* helper) session1->allocateObjectById(allocatable4); session2->setAllocationTimeout(allocationTimeout); - asyncCB1 = new Callback(); - cb1 = IceGrid::newCallback_Session_allocateObjectById(asyncCB1, &Callback::response, &Callback::exception); - session2->begin_allocateObjectById(allocatable3, cb1); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + asyncCB1 = make_shared<Callback>(); + session2->allocateObjectByIdAsync(allocatable3, + [&asyncCB1](shared_ptr<Ice::ObjectPrx> o) { asyncCB1->response(o); }, + [&asyncCB1](exception_ptr e) { asyncCB1->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB1->hasResponse(dummy)); session1->releaseObject(allocatable3); test(!asyncCB1->hasResponse(dummy)); @@ -769,10 +769,11 @@ allTests(Test::TestHelper* helper) session1->setAllocationTimeout(allocationTimeout); test(session2->allocateObjectByType("::TestServer1")); - asyncCB3 = new Callback(); - cb3 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB3, &Callback::response, &Callback::exception); - session1->begin_allocateObjectByType("::TestServer2", cb3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + asyncCB3 = make_shared<Callback>(); + session1->allocateObjectByTypeAsync("::TestServer2", + [&asyncCB3](shared_ptr<Ice::ObjectPrx> o) { asyncCB3->response(o); }, + [&asyncCB3](exception_ptr e) { asyncCB3->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB3->hasResponse(dummy)); session2->releaseObject(allocatable3); asyncCB3->waitResponse(__FILE__, __LINE__); @@ -806,9 +807,9 @@ allTests(Test::TestHelper* helper) session2->releaseObject(Ice::stringToIdentity("allocatable31")); session2->releaseObject(Ice::stringToIdentity("allocatable41")); - Ice::ObjectPrx obj1 = session1->allocateObjectByType("::TestMultipleServer"); + auto obj1 = session1->allocateObjectByType("::TestMultipleServer"); test(obj1); - Ice::ObjectPrx obj2 = session2->allocateObjectByType("::TestMultipleServer"); + auto obj2 = session2->allocateObjectByType("::TestMultipleServer"); test(obj2); try { @@ -840,7 +841,7 @@ allTests(Test::TestHelper* helper) // not be visible to the allocation system immediately. session1->allocateObjectByType("::TestServer1"); session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + this_thread::sleep_for(100ms); } test(false); } @@ -857,15 +858,15 @@ allTests(Test::TestHelper* helper) session2->setAllocationTimeout(allocationTimeout); session2->allocateObjectById(allocatable); - CallbackPtr asyncCB11 = new Callback(); - IceGrid::Callback_Session_allocateObjectByIdPtr cb11 = - IceGrid::newCallback_Session_allocateObjectById(asyncCB11, &Callback::response, &Callback::exception); - CallbackPtr asyncCB12 = new Callback(); - IceGrid::Callback_Session_allocateObjectByIdPtr cb12 = - IceGrid::newCallback_Session_allocateObjectById(asyncCB12, &Callback::response, &Callback::exception); - session1->begin_allocateObjectById(allocatable, cb11); - session1->begin_allocateObjectById(allocatable, cb12); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + auto asyncCB11 = make_shared<Callback>(); + auto asyncCB12 = make_shared<Callback>(); + session1->allocateObjectByIdAsync(allocatable, + [&asyncCB11](shared_ptr<Ice::ObjectPrx> o) { asyncCB11->response(o); }, + [&asyncCB11](exception_ptr e) { asyncCB11->exception(e); }); + session1->allocateObjectByIdAsync(allocatable, + [&asyncCB12](shared_ptr<Ice::ObjectPrx> o) { asyncCB12->response(o); }, + [&asyncCB12](exception_ptr e) { asyncCB12->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB11->hasResponse(dummy)); test(!asyncCB12->hasResponse(dummy)); session2->releaseObject(allocatable); @@ -876,41 +877,43 @@ allTests(Test::TestHelper* helper) session1->releaseObject(allocatable); session2->allocateObjectById(allocatable); - CallbackPtr asyncCB31 = new Callback(); - IceGrid::Callback_Session_allocateObjectByTypePtr cb31 = - IceGrid::newCallback_Session_allocateObjectByType(asyncCB31, &Callback::response, &Callback::exception); - CallbackPtr asyncCB32 = new Callback(); - IceGrid::Callback_Session_allocateObjectByTypePtr cb32 = - IceGrid::newCallback_Session_allocateObjectByType(asyncCB32, &Callback::response, &Callback::exception); - session1->begin_allocateObjectByType("::Test", cb31); - session1->begin_allocateObjectByType("::Test", cb32); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + auto asyncCB31 = make_shared<Callback>(); + auto asyncCB32 = make_shared<Callback>(); + session1->allocateObjectByTypeAsync("::Test", + [&asyncCB31](shared_ptr<Ice::ObjectPrx> o) { asyncCB31->response(o); }, + [&asyncCB31](exception_ptr e) { asyncCB31->exception(e); }); + session1->allocateObjectByTypeAsync("::Test", + [&asyncCB32](shared_ptr<Ice::ObjectPrx> o) { asyncCB32->response(o); }, + [&asyncCB32](exception_ptr e) { asyncCB32->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB31->hasResponse(dummy)); test(!asyncCB32->hasResponse(dummy)); session2->releaseObject(allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + this_thread::sleep_for(300ms); do { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } while(!asyncCB31->hasResponse(dummy) && !asyncCB32->hasResponse(dummy)); test((asyncCB31->hasResponse(dummy) && dummy && !asyncCB32->hasResponse(dummy)) || (asyncCB32->hasResponse(dummy) && dummy && !asyncCB31->hasResponse(dummy))); session1->releaseObject(allocatable); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - CallbackPtr asyncCB33 = asyncCB31->hasResponse(dummy) ? asyncCB32 : asyncCB31; + this_thread::sleep_for(300ms); + auto asyncCB33 = asyncCB31->hasResponse(dummy) ? asyncCB32 : asyncCB31; asyncCB33->waitResponse(__FILE__, __LINE__); test(asyncCB33->hasResponse(dummy) && dummy); session1->releaseObject(allocatable); session2->allocateObjectById(allocatable3); - asyncCB11 = new Callback(); - cb11 = IceGrid::newCallback_Session_allocateObjectById(asyncCB11, &Callback::response, &Callback::exception); - asyncCB12 = new Callback(); - cb12 = IceGrid::newCallback_Session_allocateObjectById(asyncCB12, &Callback::response, &Callback::exception); - session1->begin_allocateObjectById(allocatable3, cb11); - session1->begin_allocateObjectById(allocatable3, cb12); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + asyncCB11 = make_shared<Callback>(); + asyncCB12 = make_shared<Callback>(); + session1->allocateObjectByIdAsync(allocatable3, + [&asyncCB11](shared_ptr<Ice::ObjectPrx> o) { asyncCB11->response(o); }, + [&asyncCB11](exception_ptr e) { asyncCB11->exception(e); }); + session1->allocateObjectByIdAsync(allocatable3, + [&asyncCB12](shared_ptr<Ice::ObjectPrx> o) { asyncCB12->response(o); }, + [&asyncCB12](exception_ptr e) { asyncCB12->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB11->hasResponse(dummy)); test(!asyncCB12->hasResponse(dummy)); session2->releaseObject(allocatable3); @@ -921,52 +924,56 @@ allTests(Test::TestHelper* helper) session1->releaseObject(allocatable3); session2->allocateObjectById(allocatable3); - asyncCB31 = new Callback(); - cb31 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB31, &Callback::response, &Callback::exception); - asyncCB32 = new Callback(); - cb32 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB32, &Callback::response, &Callback::exception); - session1->begin_allocateObjectByType("::TestServer1", cb31); - session1->begin_allocateObjectByType("::TestServer1", cb32); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + asyncCB31 = make_shared<Callback>(); + asyncCB32 = make_shared<Callback>(); + session1->allocateObjectByTypeAsync("::TestServer1", + [&asyncCB31](shared_ptr<Ice::ObjectPrx> o) { asyncCB31->response(o); }, + [&asyncCB31](exception_ptr e) { asyncCB31->exception(e); }); + session1->allocateObjectByTypeAsync("::TestServer1", + [&asyncCB32](shared_ptr<Ice::ObjectPrx> o) { asyncCB32->response(o); }, + [&asyncCB32](exception_ptr e) { asyncCB32->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB31->hasResponse(dummy)); test(!asyncCB32->hasResponse(dummy)); session2->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + this_thread::sleep_for(300ms); do { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } while(!asyncCB31->hasResponse(dummy) && !asyncCB32->hasResponse(dummy)); test((asyncCB31->hasResponse(dummy) && dummy && !asyncCB32->hasResponse(dummy)) || (asyncCB32->hasResponse(dummy) && dummy && !asyncCB31->hasResponse(dummy))); session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + this_thread::sleep_for(300ms); asyncCB33 = asyncCB31->hasResponse(dummy) ? asyncCB32 : asyncCB31; asyncCB33->waitResponse(__FILE__, __LINE__); test(asyncCB33->hasResponse(dummy) && dummy); session1->releaseObject(allocatable3); session1->allocateObjectById(allocatable3); - asyncCB31 = new Callback(); - cb31 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB31, &Callback::response, &Callback::exception); - asyncCB32 = new Callback(); - cb32 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB32, &Callback::response, &Callback::exception); - session1->begin_allocateObjectByType("::TestServer1", cb31); - session1->begin_allocateObjectByType("::TestServer1", cb32); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + asyncCB31 = make_shared<Callback>(); + asyncCB32 = make_shared<Callback>(); + session1->allocateObjectByTypeAsync("::TestServer1", + [&asyncCB31](shared_ptr<Ice::ObjectPrx> o) { asyncCB31->response(o); }, + [&asyncCB31](exception_ptr e) { asyncCB31->exception(e); }); + session1->allocateObjectByTypeAsync("::TestServer1", + [&asyncCB32](shared_ptr<Ice::ObjectPrx> o) { asyncCB32->response(o); }, + [&asyncCB32](exception_ptr e) { asyncCB32->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB31->hasResponse(dummy)); test(!asyncCB32->hasResponse(dummy)); session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + this_thread::sleep_for(300ms); do { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } while(!asyncCB31->hasResponse(dummy) && !asyncCB32->hasResponse(dummy)); test((asyncCB31->hasResponse(dummy) && dummy && !asyncCB32->hasResponse(dummy)) || (asyncCB32->hasResponse(dummy) && dummy && !asyncCB31->hasResponse(dummy))); session1->releaseObject(allocatable3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); + this_thread::sleep_for(300ms); asyncCB33 = asyncCB31->hasResponse(dummy) ? asyncCB32 : asyncCB31; asyncCB33->waitResponse(__FILE__, __LINE__); test(asyncCB33->hasResponse(dummy) && dummy); @@ -980,17 +987,18 @@ allTests(Test::TestHelper* helper) test(obj && obj->ice_getIdentity().name == "allocatable"); session1->setAllocationTimeout(allocationTimeout); - asyncCB3 = new Callback(); - cb3 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB3, &Callback::response, &Callback::exception); - session1->begin_allocateObjectByType("::Test", cb3); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + asyncCB3 = make_shared<Callback>(); + session1->allocateObjectByTypeAsync("::Test", + [&asyncCB3](shared_ptr<Ice::ObjectPrx> o) { asyncCB3->response(o); }, + [&asyncCB3](exception_ptr e) { asyncCB3->exception(e); }); + this_thread::sleep_for(500ms); test(!asyncCB3->hasResponse(dummy)); session2->destroy(); asyncCB3->waitResponse(__FILE__, __LINE__); test(asyncCB3->hasResponse(obj)); session1->destroy(); - session2 = SessionPrx::uncheckedCast(registry->createSession("Client2", "")); + session2 = Ice::uncheckedCast<SessionPrx>(registry->createSession("Client2", "")); session2->setAllocationTimeout(0); session2->allocateObjectById(allocatable); session2->destroy(); @@ -1001,11 +1009,11 @@ allTests(Test::TestHelper* helper) session1 = registry->createSession("Client1", ""); session2 = registry->createSession("Client2", ""); - ServerDescriptorPtr objectAllocOriginal = admin->getServerInfo("ObjectAllocation").descriptor; - ServerDescriptorPtr objectAllocUpdate = ServerDescriptorPtr::dynamicCast(objectAllocOriginal->ice_clone()); + auto objectAllocOriginal = admin->getServerInfo("ObjectAllocation").descriptor; + auto objectAllocUpdate = dynamic_pointer_cast<ServerDescriptor>(objectAllocOriginal->ice_clone()); - ServerDescriptorPtr serverAllocOriginal = admin->getServerInfo("ServerAllocation").descriptor; - ServerDescriptorPtr serverAllocUpdate = ServerDescriptorPtr::dynamicCast(serverAllocOriginal->ice_clone()); + auto serverAllocOriginal = admin->getServerInfo("ServerAllocation").descriptor; + auto serverAllocUpdate = dynamic_pointer_cast<ServerDescriptor>(serverAllocOriginal->ice_clone()); NodeUpdateDescriptor nodeUpdate; nodeUpdate.name = "localnode"; @@ -1018,19 +1026,19 @@ allTests(Test::TestHelper* helper) { session1->allocateObjectById(allocatable3); - Ice::AsyncResultPtr r2 = session2->begin_allocateObjectById(allocatable4); + auto r2 = session2->allocateObjectByIdAsync(allocatable4); session1->allocateObjectById(allocatable4); session1->releaseObject(allocatable4); - test(!r2->isCompleted()); + test(r2.wait_for(chrono::milliseconds(0)) != future_status::ready); serverAllocUpdate->allocatable = false; admin->updateApplication(appUpdate); - test(!r2->isCompleted()); + test(r2.wait_for(chrono::milliseconds(0)) != future_status::ready); session1->releaseObject(allocatable3); - session2->end_allocateObjectById(r2); + r2.get(); session2->releaseObject(allocatable4); serverAllocUpdate->allocatable = true; @@ -1039,19 +1047,19 @@ allTests(Test::TestHelper* helper) { session1->allocateObjectById(allocatable); - Ice::AsyncResultPtr r2 = session2->begin_allocateObjectById(allocatable); + auto r2 = session2->allocateObjectByIdAsync(allocatable); objectAllocUpdate->deactivationTimeout = "23"; admin->updateApplication(appUpdate); session1->releaseObject(allocatable); - session2->end_allocateObjectById(r2); + r2.get(); session2->releaseObject(allocatable); } { session1->allocateObjectById(allocatable); - Ice::AsyncResultPtr r2 = session2->begin_allocateObjectById(allocatable); + auto r2 = session2->allocateObjectByIdAsync(allocatable); vector<ObjectDescriptor> allocatables = objectAllocUpdate->adapters[0].allocatables; objectAllocUpdate->adapters[0].allocatables.clear(); // Remove the allocatable object @@ -1059,7 +1067,7 @@ allTests(Test::TestHelper* helper) try { - session2->end_allocateObjectById(r2); + r2.get(); test(false); } catch(const ObjectNotRegisteredException&) @@ -1084,14 +1092,14 @@ allTests(Test::TestHelper* helper) cout << "ok" << endl; cout << "testing allocation with Glacier2 session... " << flush; - Ice::ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347"); - Glacier2::RouterPrx router1 = Glacier2::RouterPrx::checkedCast(routerBase->ice_connectionId("client1")); + auto routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347"); + auto router1 = Ice::checkedCast<Glacier2::RouterPrx>(routerBase->ice_connectionId("client1")); test(router1); - Glacier2::SessionPrx sessionBase = router1->createSession("test1", "abc123"); + auto sessionBase = router1->createSession("test1", "abc123"); try { - session1 = IceGrid::SessionPrx::checkedCast(sessionBase->ice_connectionId("client1")->ice_router(router1)); + session1 = Ice::checkedCast<SessionPrx>(sessionBase->ice_connectionId("client1")->ice_router(router1)); test(session1); session1->ice_ping(); @@ -1136,45 +1144,51 @@ allTests(Test::TestHelper* helper) cout << "stress test... " << flush; - SessionPrx stressSession = registry->createSession("StressSession", ""); + auto stressSession = registry->createSession("StressSession", ""); const int nClients = 10; - int i; - vector<StressClientPtr> clients; - for(i = 0; i < nClients - 2; ++i) + map<shared_ptr<StressClient>, future<void>> clients; + random_device rd; + + for(int i = 0; i < nClients - 2; ++i) { - if(IceUtilInternal::random(2) == 1) + shared_ptr<StressClient> client; + if(rd() % 2 == 1) { - clients.push_back(new StressClient(i, registry, false)); + client = make_shared<StressClient>(i, registry, false); } else { - clients.push_back(new StressClient(i, stressSession)); + client = make_shared<StressClient>(i, stressSession); } - clients.back()->start(); + + clients.insert(make_pair(client, async(launch::async, [=] { client->run(); }))); + } + + { + auto client8 = make_shared<StressClient>(8, registry, true); + clients.insert(make_pair(client8, async(launch::async, [=] { client8->run(); }))); + auto client9 = make_shared<StressClient>(9, registry, true); + clients.insert(make_pair(client9, async(launch::async, [=] { client9->run(); }))); } - clients.push_back(new StressClient(i++, registry, true)); - clients.back()->start(); - clients.push_back(new StressClient(i++, registry, true)); - clients.back()->start(); - for(vector<StressClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) + for(const auto& c : clients) { - (*p)->notifyThread(); + c.first->notifyThread(); } // // Let the stress client run for a bit. // - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(8)); + this_thread::sleep_for(8s); // // Terminate the stress clients. // - for(vector<StressClientPtr>::const_iterator q = clients.begin(); q != clients.end(); ++q) + for(auto& c : clients) { - (*q)->terminate(); - (*q)->getThreadControl().join(); + c.first->terminate(); + c.second.get(); } stressSession->destroy(); diff --git a/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp b/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp index 0651250f7dd..2358458e256 100644 --- a/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp +++ b/cpp/test/IceGrid/allocation/PermissionsVerifier.cpp @@ -8,12 +8,12 @@ using namespace std; -class PermissionsVerifierI : public Glacier2::PermissionsVerifier +class PermissionsVerifierI final : public Glacier2::PermissionsVerifier { public: - virtual bool - checkPermissions(const string&, const string&, string&, const Ice::Current&) const + bool + checkPermissions(string, string, string&, const Ice::Current&) const override { return true; } @@ -23,11 +23,11 @@ class Server : public Test::TestHelper { public: - virtual void run(int argc, char** argv) + void run(int argc, char** argv) override { Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("PermissionsVerifier"); - adapter->add(new PermissionsVerifierI, Ice::stringToIdentity("PermissionsVerifier")); + auto adapter = communicator->createObjectAdapter("PermissionsVerifier"); + adapter->add(make_shared<PermissionsVerifierI>(), Ice::stringToIdentity("PermissionsVerifier")); adapter->activate(); communicator->waitForShutdown(); } diff --git a/cpp/test/IceGrid/allocation/Server.cpp b/cpp/test/IceGrid/allocation/Server.cpp index 5b45a7e7468..b3fb5db6296 100644 --- a/cpp/test/IceGrid/allocation/Server.cpp +++ b/cpp/test/IceGrid/allocation/Server.cpp @@ -12,28 +12,28 @@ class Server : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Server::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); string name = properties->getProperty("Ice.ProgramName"); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Server"); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable")); - adapter->add(new TestI(properties), Ice::stringToIdentity("nonallocatable")); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable1")); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable2")); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable3")); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable4")); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable11")); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable21")); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable31")); - adapter->add(new TestI(properties), Ice::stringToIdentity("allocatable41")); + auto adapter = communicator->createObjectAdapter("Server"); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("nonallocatable")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable1")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable2")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable3")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable4")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable11")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable21")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable31")); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity("allocatable41")); try { diff --git a/cpp/test/IceGrid/allocation/TestI.cpp b/cpp/test/IceGrid/allocation/TestI.cpp index f91a7ac44b2..dfa2b6c6bbb 100644 --- a/cpp/test/IceGrid/allocation/TestI.cpp +++ b/cpp/test/IceGrid/allocation/TestI.cpp @@ -5,8 +5,8 @@ #include <Ice/Ice.h> #include <TestI.h> -TestI::TestI(const Ice::PropertiesPtr& properties) : - _properties(properties) +TestI::TestI(std::shared_ptr<Ice::Properties> properties) : + _properties(move(properties)) { } @@ -17,7 +17,7 @@ TestI::shutdown(const Ice::Current& current) } std::string -TestI::getProperty(const std::string& name, const Ice::Current&) +TestI::getProperty(std::string name, const Ice::Current&) { return _properties->getProperty(name); } diff --git a/cpp/test/IceGrid/allocation/TestI.h b/cpp/test/IceGrid/allocation/TestI.h index 1fcf402f93d..e6edeef7abd 100644 --- a/cpp/test/IceGrid/allocation/TestI.h +++ b/cpp/test/IceGrid/allocation/TestI.h @@ -7,18 +7,18 @@ #include <Test.h> -class TestI : public ::Test::TestIntf +class TestI final : public Test::TestIntf { public: - TestI(const Ice::PropertiesPtr&); + TestI(std::shared_ptr<Ice::Properties>); - virtual void shutdown(const Ice::Current&); - virtual std::string getProperty(const std::string&, const Ice::Current&); + void shutdown(const Ice::Current&) override; + std::string getProperty(std::string, const ::Ice::Current&) override; private: - Ice::PropertiesPtr _properties; + std::shared_ptr<Ice::Properties> _properties; }; #endif diff --git a/cpp/test/IceGrid/deployer/AllTests.cpp b/cpp/test/IceGrid/deployer/AllTests.cpp index 31123448eaf..47d88ae5d79 100644 --- a/cpp/test/IceGrid/deployer/AllTests.cpp +++ b/cpp/test/IceGrid/deployer/AllTests.cpp @@ -4,7 +4,6 @@ #include <Ice/Ice.h> #include <IceGrid/IceGrid.h> -#include <IceUtil/Thread.h> #include <TestHelper.h> #include <Test.h> @@ -50,29 +49,17 @@ bool isLongLineEnd(const string& line) } -struct ProxyIdentityEqual : public std::binary_function<Ice::ObjectPrx,string,bool> +function<bool(const shared_ptr<Ice::ObjectPrx>&)> +proxyIdentityEqual(const string& strId) { - -public: - - ProxyIdentityEqual(const Ice::CommunicatorPtr& communicator) : - _communicator(communicator) - { - } - - bool - operator()(const Ice::ObjectPrx& p1, const string& id) const + return [id = Ice::stringToIdentity(strId)](const shared_ptr<Ice::ObjectPrx>& obj) { - return p1->ice_getIdentity() == Ice::stringToIdentity(id); - } - -private: - - Ice::CommunicatorPtr _communicator; -}; + return obj->ice_getIdentity() == id; + }; +} void -logTests(const Ice::CommunicatorPtr& comm, const AdminSessionPrx& session) +logTests(const shared_ptr<Ice::Communicator>& comm, const shared_ptr<AdminSessionPrx>& session) { cout << "testing stderr/stdout/log files... " << flush; string testDir = comm->getProperties()->getProperty("TestDir"); @@ -102,7 +89,7 @@ logTests(const Ice::CommunicatorPtr& comm, const AdminSessionPrx& session) { } - Ice::ObjectPrx obj = TestIntfPrx::checkedCast(comm->stringToProxy("LogServer")); + auto obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("LogServer")); try { session->openServerStdErr("LogServer", -1)->destroy(); @@ -114,7 +101,7 @@ logTests(const Ice::CommunicatorPtr& comm, const AdminSessionPrx& session) test(false); } - FileIteratorPrx it; + shared_ptr<FileIteratorPrx> it; Ice::StringSeq lines; try { @@ -373,21 +360,21 @@ logTests(const Ice::CommunicatorPtr& comm, const AdminSessionPrx& session) void allTests(Test::TestHelper* helper) { - Ice::CommunicatorPtr comm = helper->communicator(); - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( + auto comm = helper->communicator(); + auto registry = Ice::checkedCast<IceGrid::RegistryPrx>( comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast( + auto query = Ice::checkedCast<IceGrid::QueryPrx>( comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Query")); test(query); - AdminSessionPrx session = registry->createAdminSession("foo", "bar"); + auto session = registry->createAdminSession("foo", "bar"); session->ice_getConnection()->setACM(registry->getACMTimeout(), - IceUtil::None, - Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + Ice::nullopt, + Ice::ACMHeartbeat::HeartbeatAlways); - AdminPrx admin = session->getAdmin(); + auto admin = session->getAdmin(); test(admin); cout << "testing server registration... " << flush; @@ -415,16 +402,16 @@ allTests(Test::TestHelper* helper) cout << "ok" << endl; cout << "testing object registration... " << flush; - Ice::ObjectProxySeq objs = query->findAllObjectsByType("::Test"); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"Server1")) != objs.end()); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"Server2")) != objs.end()); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"SimpleServer")) != objs.end()); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"IceBox1-Service1")) != objs.end()); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"IceBox1-Service2")) != objs.end()); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"IceBox2-Service1")) != objs.end()); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"IceBox2-Service2")) != objs.end()); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"SimpleIceBox-SimpleService")) != objs.end()); - test(find_if(objs.begin(), objs.end(), bind2nd(ProxyIdentityEqual(comm),"ReplicatedObject")) != objs.end()); + auto objs = query->findAllObjectsByType("::Test"); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("Server1")) != objs.end()); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("Server2")) != objs.end()); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("SimpleServer")) != objs.end()); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("IceBox1-Service1")) != objs.end()); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("IceBox1-Service2")) != objs.end()); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("IceBox2-Service1")) != objs.end()); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("IceBox2-Service2")) != objs.end()); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("SimpleIceBox-SimpleService")) != objs.end()); + test(find_if(objs.begin(), objs.end(), proxyIdentityEqual("ReplicatedObject")) != objs.end()); { test(comm->identityToString(query->findObjectByType("::TestId1")->ice_getIdentity()) == "cat/name1"); @@ -435,24 +422,24 @@ allTests(Test::TestHelper* helper) } { - Ice::ObjectPrx obj = query->findObjectByType("::Test"); + auto obj = query->findObjectByType("::Test"); string id = comm->identityToString(obj->ice_getIdentity()); test(id.find("Server") == 0 || id.find("IceBox") == 0 || id == "SimpleServer" || id == "SimpleIceBox-SimpleService" || id == "ReplicatedObject"); } { - Ice::ObjectPrx obj = query->findObjectByTypeOnLeastLoadedNode("::Test", LoadSample5); + auto obj = query->findObjectByTypeOnLeastLoadedNode("::Test", LoadSample::LoadSample5); string id = comm->identityToString(obj->ice_getIdentity()); test(id.find("Server") == 0 || id.find("IceBox") == 0 || id == "SimpleServer" || id == "SimpleIceBox-SimpleService" || id == "ReplicatedObject"); } { - Ice::ObjectPrx obj = query->findObjectByType("::Foo"); + auto obj = query->findObjectByType("::Foo"); test(!obj); - obj = query->findObjectByTypeOnLeastLoadedNode("::Foo", LoadSample15); + obj = query->findObjectByTypeOnLeastLoadedNode("::Foo", LoadSample::LoadSample15); test(!obj); } @@ -485,15 +472,15 @@ allTests(Test::TestHelper* helper) replicated14.name = "ReplicatedObject14"; test(query->findObjectById(replicated14)->ice_getEncodingVersion() == Ice::stringToEncodingVersion("1.4")); - Ice::LocatorPrx locator = comm->getDefaultLocator(); - test(query->findObjectById(encoding10_oneway) == locator->findObjectById(encoding10_oneway)); - test(query->findObjectById(encoding10_secure) == locator->findObjectById(encoding10_secure)); - test(query->findObjectById(oaoptions) == locator->findObjectById(oaoptions)); - test(query->findObjectById(comoptions) == locator->findObjectById(comoptions)); - test(query->findObjectById(options34) == locator->findObjectById(options34)); - test(query->findObjectById(simpleServer) == locator->findObjectById(simpleServer)); - test(query->findObjectById(replicated15) == locator->findObjectById(replicated15)); - test(query->findObjectById(replicated14) == locator->findObjectById(replicated14)); + auto locator = comm->getDefaultLocator(); + test(Ice::targetEqualTo(query->findObjectById(encoding10_oneway), locator->findObjectById(encoding10_oneway))); + test(Ice::targetEqualTo(query->findObjectById(encoding10_secure), locator->findObjectById(encoding10_secure))); + test(Ice::targetEqualTo(query->findObjectById(oaoptions), locator->findObjectById(oaoptions))); + test(Ice::targetEqualTo(query->findObjectById(comoptions), locator->findObjectById(comoptions))); + test(Ice::targetEqualTo(query->findObjectById(options34), locator->findObjectById(options34))); + test(Ice::targetEqualTo(query->findObjectById(simpleServer), locator->findObjectById(simpleServer))); + test(Ice::targetEqualTo(query->findObjectById(replicated15), locator->findObjectById(replicated15))); + test(Ice::targetEqualTo(query->findObjectById(replicated14), locator->findObjectById(replicated14))); cout << "ok" << endl; @@ -506,20 +493,20 @@ allTests(Test::TestHelper* helper) // server. Ensure we can reach each object. // cout << "pinging server objects... " << flush; - TestIntfPrx obj; - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server2@Server2.Server")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("SimpleServer@SimpleServer.Server")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service2@IceBox1Service2Adapter")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); - obj = TestIntfPrx::checkedCast( + shared_ptr<TestIntfPrx> obj; + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server1@Server1.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server2@Server2.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("SimpleServer@SimpleServer.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service2@IceBox1Service2Adapter")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); + obj = Ice::checkedCast<TestIntfPrx>( comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); cout << "ok" << endl; cout << "testing server configuration... " << flush; - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server1@Server1.Server")); test(obj->getProperty("Type") == "Server"); test(obj->getProperty("Name") == "Server1"); test(obj->getProperty("NameName") == "Server1Server1"); @@ -542,7 +529,7 @@ allTests(Test::TestHelper* helper) cout << "ok" << endl; cout << "testing service configuration... " << flush; - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); test(obj->getProperty("Service1.Type") == "standard"); test(obj->getProperty("Service1.ServiceName") == "Service1"); test(obj->getProperty("TestService1Identity") == "IceBox1-Service1"); @@ -558,7 +545,7 @@ allTests(Test::TestHelper* helper) test(obj->getProperty("PropertyWithEscapeSpace") == "foo\\ "); test(obj->getProperty("PropertyWithProperty") == "Plugin.EntryPoint=foo:bar --Ice.Config=\\\\\\server\\foo bar\\file.cfg"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); test(obj->getProperty("Service2.Type") == "nonstandard"); test(obj->getProperty("Service2.ServiceName") == "Service2"); test(obj->getProperty("Service2.DebugProperty") == ""); @@ -566,41 +553,41 @@ allTests(Test::TestHelper* helper) cout << "ok" << endl; cout << "testing server options... " << flush; - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server1@Server1.Server")); test(obj->getProperty("Test.Test") == "2"); test(obj->getProperty("Test.Test1") == "0"); cout << "ok" << endl; cout << "testing variables... " << flush; - vector<TestIntfPrx> proxies; - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server")); + vector<shared_ptr<TestIntfPrx>> proxies; + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server1@Server1.Server")); proxies.push_back(obj); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); proxies.push_back(obj); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("SimpleServer@SimpleServer.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("SimpleServer@SimpleServer.Server")); proxies.push_back(obj); - obj = TestIntfPrx::checkedCast( + obj = Ice::checkedCast<TestIntfPrx>( comm->stringToProxy("SimpleIceBox-SimpleService@SimpleIceBox.SimpleService.SimpleService")); proxies.push_back(obj); - for(vector<TestIntfPrx>::const_iterator p = proxies.begin(); p != proxies.end(); ++p) + for(const auto& p : proxies) { - test((*p)->getProperty("AppVarProp") == "AppVar"); - test((*p)->getProperty("NodeVarProp") == "NodeVar"); - test((*p)->getProperty("RecursiveAppVarProp") == "Test"); - test((*p)->getProperty("AppVarOverridedProp") == "OverridedInNode"); - test((*p)->getProperty("AppVarDefinedInNodeProp") == "localnode"); - test((*p)->getProperty("EscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("RecursiveEscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("Recursive2EscapedAppVarProp") == "${escaped}"); - test((*p)->getProperty("RecursiveNodeVarProp") == "localnode"); - test((*p)->getProperty("TestDirProp") != "NotThisValue"); + test(p->getProperty("AppVarProp") == "AppVar"); + test(p->getProperty("NodeVarProp") == "NodeVar"); + test(p->getProperty("RecursiveAppVarProp") == "Test"); + test(p->getProperty("AppVarOverridedProp") == "OverridedInNode"); + test(p->getProperty("AppVarDefinedInNodeProp") == "localnode"); + test(p->getProperty("EscapedAppVarProp") == "${escaped}"); + test(p->getProperty("RecursiveEscapedAppVarProp") == "${escaped}"); + test(p->getProperty("Recursive2EscapedAppVarProp") == "${escaped}"); + test(p->getProperty("RecursiveNodeVarProp") == "localnode"); + test(p->getProperty("TestDirProp") != "NotThisValue"); } cout << "ok" << endl; cout << "testing parameters... " << flush; - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server1@Server1.Server")); test(obj->getProperty("Param1Prop") == "Param1"); test(obj->getProperty("Param2Prop") == "AppVar"); test(obj->getProperty("ParamEscapedProp") == "${escaped}"); @@ -608,7 +595,7 @@ allTests(Test::TestHelper* helper) test(obj->getProperty("AppVarOverridedByParamProp") == "Overrided"); test(obj->getProperty("NodeVarOverridedByParamProp") == "Test"); test(obj->getProperty("DefaultParamProp") == "VALUE"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server2@Server2.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server2@Server2.Server")); test(obj->getProperty("Param1Prop") == "Param12"); test(obj->getProperty("Param2Prop") == "OverridedInNode"); test(obj->getProperty("ParamEscapedProp") == "${escaped}"); @@ -617,16 +604,16 @@ allTests(Test::TestHelper* helper) test(obj->getProperty("NodeVarOverridedByParamProp") == "Test"); test(obj->getProperty("DefaultParamProp") == "OTHERVALUE"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); test(obj->getProperty("AppVarOverridedByParamProp") == "Test"); test(obj->getProperty("NodeVarOverridedByParamProp") == "Overrided"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service2@IceBox1Service2Adapter")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service2@IceBox1Service2Adapter")); test(obj->getProperty("AppVarOverridedByParamProp") == "Test"); test(obj->getProperty("NodeVarOverridedByParamProp") == "Test"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1")); test(obj->getProperty("AppVarOverridedByParamProp") == "Test"); test(obj->getProperty("NodeVarOverridedByParamProp") == "Overrided"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); test(obj->getProperty("AppVarOverridedByParamProp") == "Test"); test(obj->getProperty("NodeVarOverridedByParamProp") == "Test"); @@ -648,37 +635,36 @@ allTests(Test::TestHelper* helper) test(info.descriptor->id == "SimpleServer"); test(info.descriptor->description == "SERVER NodeVar"); test(info.descriptor->adapters[0].description == "ADAPTER NodeVar"); - test(info.descriptor->dbEnvs[0].description == "DBENV NodeVar"); cout << "ok" << endl; cout << "testing property sets..." << flush; - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server1@Server1.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server1@Server1.Server")); test(obj->getProperty("AppProperty") == "AppVar"); test(obj->getProperty("AppProperty2") == "OverrideMe"); test(obj->getProperty("AppProperty21") == "Override"); test(obj->getProperty("NodeProperty") == "NodeVar"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server2@Server2.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server2@Server2.Server")); test(obj->getProperty("AppProperty") == "AppVar"); test(obj->getProperty("AppProperty2") == "OverrideMe"); test(obj->getProperty("AppProperty21") == "Override"); test(obj->getProperty("NodeProperty") == "NodeVar"); test(obj->getProperty("ServerInstanceProperty") == "Server2"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); test(obj->getProperty("AppProperty") == ""); // IceBox server properties aren't inherited for IceBox1 test(obj->getProperty("AppProperty2") == ""); test(obj->getProperty("AppProperty21") == ""); test(obj->getProperty("NodeProperty") == ""); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox2-Service1@IceBox2.Service1.Service1")); test(obj->getProperty("AppProperty") == "AppVar"); test(obj->getProperty("AppProperty2") == "OverrideMe"); test(obj->getProperty("AppProperty21") == "Override"); test(obj->getProperty("NodeProperty") == "NodeVar"); test(obj->getProperty("IceBoxInstanceProperty") == "IceBox2"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox2-Service2@IceBox2Service2Adapter")); test(obj->getProperty("AppProperty") == "AppVar"); test(obj->getProperty("AppProperty2") == "OverrideMe"); test(obj->getProperty("AppProperty21") == "Override"); @@ -686,17 +672,17 @@ allTests(Test::TestHelper* helper) test(obj->getProperty("IceBoxInstanceProperty") == "IceBox2"); test(obj->getProperty("ServiceInstanceProperty") == "Service2"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("SimpleServer@SimpleServer.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("SimpleServer@SimpleServer.Server")); test(obj->getProperty("AppProperty") == "AppVar"); test(obj->getProperty("AppProperty2") == "OverrideMe"); test(obj->getProperty("AppProperty21") == "Override"); test(obj->getProperty("NodeProperty") == "NodeVar"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service1@IceBox1.Service1.Service1")); test(obj->getProperty("ServerInstanceServiceProperty") == "service1"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox1-Service4@IceBox1.Service4.Service4")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox1-Service4@IceBox1.Service4.Service4")); test(obj->getProperty("ServerInstanceServiceProperty") == "service4"); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox2-Service4@IceBox2.Service4.Service4")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox2-Service4@IceBox2.Service4.Service4")); test(obj->getProperty("IceBoxInstanceProperty") == "overriden"); cout << "ok" << endl; @@ -707,8 +693,8 @@ allTests(Test::TestHelper* helper) templ.parameters.push_back("nam3"); templ.parameters.push_back("nam2"); templ.parameters.push_back("nam3"); - templ.descriptor = new ServerDescriptor(); - ServerDescriptorPtr server = ServerDescriptorPtr::dynamicCast(templ.descriptor); + templ.descriptor = make_shared<ServerDescriptor>(); + auto server = dynamic_pointer_cast<ServerDescriptor>(templ.descriptor); server->id = "test"; server->exe = "${test.dir}/server"; server->allocatable = false; @@ -739,26 +725,26 @@ allTests(Test::TestHelper* helper) void allTestsWithTarget(Test::TestHelper* helper) { - Ice::CommunicatorPtr comm = helper->communicator(); - RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( + auto comm = helper->communicator(); + auto registry = Ice::checkedCast<IceGrid::RegistryPrx>( comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - AdminSessionPrx session = registry->createAdminSession("foo", "bar"); + auto session = registry->createAdminSession("foo", "bar"); - session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); + session->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); - AdminPrx admin = session->getAdmin(); + auto admin = session->getAdmin(); test(admin); cout << "testing targets... " << flush; - TestIntfPrx obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server3@Server3.Server")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox3-Service1@IceBox3.Service1.Service1")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox3-Service3@IceBox3.Service3.Service3")); + auto obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server3@Server3.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox3-Service1@IceBox3.Service1.Service1")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox3-Service3@IceBox3.Service3.Service3")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("IceBox3-Service4@IceBox3.Service4.Service4")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("IceBox3-Service4@IceBox3.Service4.Service4")); - obj = TestIntfPrx::checkedCast(comm->stringToProxy("Server3@Server3.Server")); + obj = Ice::checkedCast<TestIntfPrx>(comm->stringToProxy("Server3@Server3.Server")); test(obj->getProperty("TargetProp") == "1"); cout << "ok" << endl; diff --git a/cpp/test/IceGrid/deployer/Server.cpp b/cpp/test/IceGrid/deployer/Server.cpp index f3e3fd320de..77c48d822b5 100644 --- a/cpp/test/IceGrid/deployer/Server.cpp +++ b/cpp/test/IceGrid/deployer/Server.cpp @@ -2,7 +2,11 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/DisableWarnings.h> +#ifdef _MSC_VER +// For getenv +# define _CRT_SECURE_NO_WARNINGS +#endif + #include <Ice/Ice.h> #include <TestI.h> #include <TestHelper.h> @@ -14,7 +18,7 @@ class Server : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -69,9 +73,9 @@ Server::run(int argc, char** argv) Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); string name = properties->getProperty("Ice.ProgramName"); - Ice::ObjectAdapterPtr adapter; + shared_ptr<Ice::ObjectAdapter> adapter; if(!properties->getProperty("ReplicatedAdapter").empty()) { @@ -80,8 +84,7 @@ Server::run(int argc, char** argv) } adapter = communicator->createObjectAdapter("Server"); - Ice::ObjectPtr object = new TestI(properties); - adapter->add(object, Ice::stringToIdentity(name)); + adapter->add(make_shared<TestI>(properties), Ice::stringToIdentity(name)); try { adapter->activate(); diff --git a/cpp/test/IceGrid/deployer/Service.cpp b/cpp/test/IceGrid/deployer/Service.cpp index 2071fde15cd..4605f2cecba 100644 --- a/cpp/test/IceGrid/deployer/Service.cpp +++ b/cpp/test/IceGrid/deployer/Service.cpp @@ -9,18 +9,15 @@ using namespace std; using namespace Ice; -class ServiceI : public ::IceBox::Service +class ServiceI : public IceBox::Service { public: - ServiceI(); - virtual ~ServiceI(); + void start(const string&, + const shared_ptr<Communicator>&, + const StringSeq&) override; - virtual void start(const string&, - const CommunicatorPtr&, - const StringSeq&); - - virtual void stop(); + void stop() override; }; extern "C" @@ -30,30 +27,21 @@ extern "C" // Factory function // ICE_DECLSPEC_EXPORT ::IceBox::Service* -create(CommunicatorPtr) +create(const shared_ptr<Communicator>&) { return new ServiceI; } } -ServiceI::ServiceI() -{ -} - -ServiceI::~ServiceI() -{ -} - void ServiceI::start(const string& name, - const CommunicatorPtr& communicator, + const shared_ptr<Communicator>& communicator, const StringSeq&) { - Ice::PropertiesPtr properties = communicator->getProperties(); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name); - Ice::ObjectPtr object = new TestI(properties); - adapter->add(object, stringToIdentity(properties->getProperty(name + ".Identity"))); + auto properties = communicator->getProperties(); + auto adapter = communicator->createObjectAdapter(name); + adapter->add(make_shared<TestI>(properties), stringToIdentity(properties->getProperty(name + ".Identity"))); adapter->activate(); } diff --git a/cpp/test/IceGrid/deployer/TestI.cpp b/cpp/test/IceGrid/deployer/TestI.cpp index f91a7ac44b2..dfa2b6c6bbb 100644 --- a/cpp/test/IceGrid/deployer/TestI.cpp +++ b/cpp/test/IceGrid/deployer/TestI.cpp @@ -5,8 +5,8 @@ #include <Ice/Ice.h> #include <TestI.h> -TestI::TestI(const Ice::PropertiesPtr& properties) : - _properties(properties) +TestI::TestI(std::shared_ptr<Ice::Properties> properties) : + _properties(move(properties)) { } @@ -17,7 +17,7 @@ TestI::shutdown(const Ice::Current& current) } std::string -TestI::getProperty(const std::string& name, const Ice::Current&) +TestI::getProperty(std::string name, const Ice::Current&) { return _properties->getProperty(name); } diff --git a/cpp/test/IceGrid/deployer/TestI.h b/cpp/test/IceGrid/deployer/TestI.h index 1fcf402f93d..8a96d53f0d9 100644 --- a/cpp/test/IceGrid/deployer/TestI.h +++ b/cpp/test/IceGrid/deployer/TestI.h @@ -7,18 +7,18 @@ #include <Test.h> -class TestI : public ::Test::TestIntf +class TestI final : public ::Test::TestIntf { public: - TestI(const Ice::PropertiesPtr&); + TestI(std::shared_ptr<Ice::Properties>); - virtual void shutdown(const Ice::Current&); - virtual std::string getProperty(const std::string&, const Ice::Current&); + void shutdown(const Ice::Current&) override; + std::string getProperty(std::string, const Ice::Current&) override; private: - Ice::PropertiesPtr _properties; + std::shared_ptr<Ice::Properties> _properties; }; #endif diff --git a/cpp/test/IceGrid/deployer/application.xml b/cpp/test/IceGrid/deployer/application.xml index ba46b25089c..8c34e74a075 100644 --- a/cpp/test/IceGrid/deployer/application.xml +++ b/cpp/test/IceGrid/deployer/application.xml @@ -117,10 +117,6 @@ <object identity="${ObjectCategory2}/${ObjectName2}" type="::TestId4"/> <object identity="${ObjectIdSlash}${ObjectName2}" type="::TestId5"/> </adapter> - - <dbenv name="DbEnv"> - <description>DBENV ${NodeVar}</description> - </dbenv> <option>--Test.Test=2</option> <env>MY_ENV_VARIABLE=12</env> <env>MY_UNIX_COMPOSED_VARIABLE=BAR;$MY_FOO</env> diff --git a/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp b/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp index 101e9dc6b27..1bf8a985730 100644 --- a/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp +++ b/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp @@ -2,7 +2,6 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/Thread.h> #include <Ice/Ice.h> #include <IceGrid/IceGrid.h> #include <TestHelper.h> @@ -13,7 +12,7 @@ using namespace Test; using namespace IceGrid; void -addProperty(const CommunicatorDescriptorPtr& communicator, const string& name, const string& value) +addProperty(const shared_ptr<CommunicatorDescriptor>& communicator, const string& name, const string& value) { PropertyDescriptor prop; prop.name = name; @@ -22,58 +21,49 @@ addProperty(const CommunicatorDescriptorPtr& communicator, const string& name, c } string -getProperty(const CommunicatorDescriptorPtr& communicator, const string& name) +getProperty(const shared_ptr<CommunicatorDescriptor>& communicator, const string& name) { PropertyDescriptorSeq& properties = communicator->propertySet.properties; - for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) + for(const auto& prop : properties) { - if(q->name == name) + if(prop.name == name) { - return q->value; + return prop.value; } } return ""; } void -removeProperty(const CommunicatorDescriptorPtr& communicator, const string& name) +removeProperty(const shared_ptr<CommunicatorDescriptor>& communicator, const string& name) { PropertyDescriptorSeq& properties = communicator->propertySet.properties; - for(PropertyDescriptorSeq::iterator q = properties.begin(); q != properties.end(); ++q) - { - if(q->name == name) - { - properties.erase(q); - break; - } - } + properties.erase(remove_if(properties.begin(), properties.end(),[&name](const auto& p) { return p.name == name; })); } PropertyDescriptor createProperty(const string& name, const string& value) { - PropertyDescriptor prop; - prop.name = name; - prop.value = value; - return prop; + return { name, value}; } bool -hasProperty(const CommunicatorDescriptorPtr& desc, const string& name, const string& value) +hasProperty(const shared_ptr<CommunicatorDescriptor>& communicator, const string& name, const string& value) { - for(PropertyDescriptorSeq::const_iterator p = desc->propertySet.properties.begin(); - p != desc->propertySet.properties.end(); ++p) + PropertyDescriptorSeq& properties = communicator->propertySet.properties; + for(const auto& prop : properties) { - if(p->name == name) + if(prop.name == name) { - return p->value == value; + return prop.value == value; } } return false; } void -updateServerRuntimeProperties(const AdminPrx& admin, const string&, const ServerDescriptorPtr& desc) +updateServerRuntimeProperties(const shared_ptr<AdminPrx>& admin, const string&, + const shared_ptr<ServerDescriptor>& desc) { ApplicationUpdateDescriptor update; update.name = "TestApp"; @@ -92,33 +82,33 @@ updateServerRuntimeProperties(const AdminPrx& admin, const string&, const Server } } -ServiceDescriptorPtr -getServiceDescriptor(const AdminPrx& admin, const string& service) +shared_ptr<ServiceDescriptor> +getServiceDescriptor(const shared_ptr<AdminPrx>& admin, const string& service) { - ServerInfo info = admin->getServerInfo("IceBox"); + auto info = admin->getServerInfo("IceBox"); test(info.descriptor); - IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor); - for(ServiceInstanceDescriptorSeq::const_iterator p = iceBox->services.begin(); p != iceBox->services.end(); ++p) + auto iceBox = dynamic_pointer_cast<IceBoxDescriptor>(info.descriptor); + for(const auto& serviceInstance : iceBox->services) { - if(p->descriptor->name == service) + if(serviceInstance.descriptor->name == service) { - return p->descriptor; + return serviceInstance.descriptor; } } - return 0; + return nullptr; } void -updateServiceRuntimeProperties(const AdminPrx& admin, const ServiceDescriptorPtr& desc) +updateServiceRuntimeProperties(const shared_ptr<AdminPrx>& admin, const shared_ptr<ServiceDescriptor>& desc) { - ServerInfo info = admin->getServerInfo("IceBox"); + auto info = admin->getServerInfo("IceBox"); test(info.descriptor); - IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor); - for(ServiceInstanceDescriptorSeq::const_iterator p = iceBox->services.begin(); p != iceBox->services.end(); ++p) + auto iceBox = dynamic_pointer_cast<IceBoxDescriptor>(info.descriptor); + for(const auto& serviceInstance : iceBox->services) { - if(p->descriptor->name == desc->name) + if(serviceInstance.descriptor->name == desc->name) { - p->descriptor->propertySet.properties = desc->propertySet.properties; + serviceInstance.descriptor->propertySet.properties = desc->propertySet.properties; } } ApplicationUpdateDescriptor update; @@ -146,20 +136,20 @@ updateServiceRuntimeProperties(const AdminPrx& admin, const ServiceDescriptorPtr void allTests(Test::TestHelper* helper) { - Ice::CommunicatorPtr communicator = helper->communicator(); - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( + auto communicator = helper->communicator(); + auto registry = Ice::checkedCast<IceGrid::RegistryPrx>( communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - AdminSessionPrx session = registry->createAdminSession("foo", "bar"); + auto session = registry->createAdminSession("foo", "bar"); session->ice_getConnection()->setACM(registry->getACMTimeout(), - IceUtil::None, - Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + Ice::nullopt, + Ice::ACMHeartbeat::HeartbeatAlways); - AdminPrx admin = session->getAdmin(); + auto admin = session->getAdmin(); test(admin); - Ice::PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); { ApplicationDescriptor testApp; @@ -176,7 +166,7 @@ allTests(Test::TestHelper* helper) cout << "testing server add... " << flush; - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); server->id = "Server"; server->exe = properties->getProperty("ServerDir") + "/server"; server->pwd = "."; @@ -221,8 +211,8 @@ allTests(Test::TestHelper* helper) TemplateDescriptor templ; templ.parameters.push_back("name"); - templ.descriptor = new ServerDescriptor(); - server = ServerDescriptorPtr::dynamicCast(templ.descriptor); + templ.descriptor = make_shared<ServerDescriptor>(); + server = dynamic_pointer_cast<ServerDescriptor>(templ.descriptor); server->id = "${name}"; server->exe = "${server.dir}/server"; server->pwd = "."; @@ -347,39 +337,39 @@ allTests(Test::TestHelper* helper) test(info.descriptor); addProperty(info.descriptor, "test", "test"); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test") == ""); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test") == ""); updateServerRuntimeProperties(admin, "Server", info.descriptor); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test") == "test"); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test") == "test"); test(serverPid == admin->getServerPid("Server")); admin->stopServer("Server"); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test") == "test"); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test") == "test"); test((serverPid = admin->getServerPid("Server")) > 0); test(hasProperty(admin->getServerInfo("Server").descriptor, "test", "test")); addProperty(info.descriptor, "test2", "test2"); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test2") == ""); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test2") == ""); updateServerRuntimeProperties(admin, "Server", info.descriptor); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test2") == "test2"); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test2") == "test2"); test(serverPid == admin->getServerPid("Server")); test(hasProperty(admin->getServerInfo("Server").descriptor, "test2", "test2")); removeProperty(info.descriptor, "test2"); updateServerRuntimeProperties(admin, "Server", info.descriptor); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test2") == ""); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test2") == ""); test(serverPid == admin->getServerPid("Server")); test(!hasProperty(admin->getServerInfo("Server").descriptor, "test2", "test2")); addProperty(info.descriptor, "test3", "test3"); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test3") == ""); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test3") == ""); updateServerRuntimeProperties(admin, "Server", info.descriptor); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test3") == "test3"); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test3") == "test3"); test(serverPid == admin->getServerPid("Server")); test(hasProperty(admin->getServerInfo("Server").descriptor, "test3", "test3")); admin->stopServer("Server"); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test") == "test"); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test2") == ""); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server"))->getProperty("test3") == "test3"); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test") == "test"); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test2") == ""); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server"))->getProperty("test3") == "test3"); test((serverPid = admin->getServerPid("Server")) > 0); test(hasProperty(admin->getServerInfo("Server").descriptor, "test", "test")); test(!hasProperty(admin->getServerInfo("Server").descriptor, "test2", "")); @@ -408,12 +398,12 @@ allTests(Test::TestHelper* helper) addProperty(server, "test", "test"); assert(templ.descriptor == server); update.serverTemplates["ServerTemplate"] = templ; - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server1"))->getProperty("test") == ""); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server1"))->getProperty("test") == ""); admin->updateApplicationWithoutRestart(update); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server1"))->getProperty("test") == "test"); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server1"))->getProperty("test") == "test"); test(server1Pid == admin->getServerPid("Server1")); admin->stopServer("Server1"); - test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("Server1"))->getProperty("test") == "test"); + test(Ice::uncheckedCast<TestIntfPrx>(communicator->stringToProxy("Server1"))->getProperty("test") == "test"); server1Pid = admin->getServerPid("Server1"); test(hasProperty(admin->getServerInfo("Server1").descriptor, "test", "test")); } @@ -492,35 +482,11 @@ allTests(Test::TestHelper* helper) test(false); } test(serverPid == admin->getServerPid("Server")); - - try - { - info = admin->getServerInfo("Server"); - test(info.descriptor); - DbEnvDescriptor dbEnv = DbEnvDescriptor(); - dbEnv.name = "foo"; - info.descriptor->dbEnvs.push_back(dbEnv); - update = empty; - update.nodes[0].servers.push_back(info.descriptor); - admin->updateApplicationWithoutRestart(update); - test(false); - } - catch(const DeploymentException&) - { - // Can't update server dbenvs without restart - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - test(false); - } - test(serverPid == admin->getServerPid("Server")); - cout << "ok" << endl; cout << "testing icebox server add... " << flush; - ServiceDescriptorPtr service = new ServiceDescriptor(); + auto service = make_shared<ServiceDescriptor>(); addProperty(service, "Ice.Warn.UnknownProperties", "0"); //addProperty(service, "Ice.Trace.Admin.Properties", "1"); service->name = "Service1"; @@ -538,21 +504,21 @@ allTests(Test::TestHelper* helper) adapter.objects.push_back(object); service->adapters.push_back(adapter); - IceBoxDescriptorPtr icebox = new IceBoxDescriptor(); + auto icebox = make_shared<IceBoxDescriptor>(); icebox->id = "IceBox"; icebox->exe = properties->getProperty("IceBoxExe"); icebox->activation = "on-demand"; icebox->allocatable = false; addProperty(icebox, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); icebox->services.resize(3); - icebox->services[0].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + icebox->services[0].descriptor = dynamic_pointer_cast<ServiceDescriptor>(service->ice_clone()); service->name = "Service2"; - icebox->services[1].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + icebox->services[1].descriptor = dynamic_pointer_cast<ServiceDescriptor>(service->ice_clone()); service->name = "Service3"; // Test also with shared communicator because it uses different proxy name // and thus different branches in code. addProperty(icebox, "IceBox.UseSharedCommunicator.Service3", "1"); - icebox->services[2].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + icebox->services[2].descriptor = dynamic_pointer_cast<ServiceDescriptor>(service->ice_clone()); try { @@ -590,7 +556,7 @@ allTests(Test::TestHelper* helper) { // can't add service without restart test(iceBoxPid == admin->getServerPid("IceBox")); - icebox = IceBoxDescriptorPtr::dynamicCast(admin->getServerInfo("IceBox").descriptor); + icebox = dynamic_pointer_cast<IceBoxDescriptor>(admin->getServerInfo("IceBox").descriptor); } catch(const Ice::Exception& ex) { @@ -610,7 +576,7 @@ allTests(Test::TestHelper* helper) { // can't remove service without restart test(iceBoxPid == admin->getServerPid("IceBox")); - icebox = IceBoxDescriptorPtr::dynamicCast(admin->getServerInfo("IceBox").descriptor); + icebox = dynamic_pointer_cast<IceBoxDescriptor>(admin->getServerInfo("IceBox").descriptor); } catch(const Ice::Exception& ex) { @@ -630,7 +596,7 @@ allTests(Test::TestHelper* helper) { // can't update service entry point without restart test(iceBoxPid == admin->getServerPid("IceBox")); - icebox = IceBoxDescriptorPtr::dynamicCast(admin->getServerInfo("IceBox").descriptor); + icebox = dynamic_pointer_cast<IceBoxDescriptor>(admin->getServerInfo("IceBox").descriptor); } catch(const Ice::Exception& ex) { @@ -638,14 +604,14 @@ allTests(Test::TestHelper* helper) test(false); } - ServiceDescriptorPtr svc1 = icebox->services[0].descriptor; - TestIntfPrx svc1Prx = TestIntfPrx::checkedCast(communicator->stringToProxy("IceBox.Service1")); + auto svc1 = icebox->services[0].descriptor; + auto svc1Prx = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("IceBox.Service1")); - ServiceDescriptorPtr svc2 = icebox->services[1].descriptor; - TestIntfPrx svc2Prx = TestIntfPrx::checkedCast(communicator->stringToProxy("IceBox.Service2")); + auto svc2 = icebox->services[1].descriptor; + auto svc2Prx = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("IceBox.Service2")); - ServiceDescriptorPtr svc3 = icebox->services[2].descriptor; - TestIntfPrx svc3Prx = TestIntfPrx::checkedCast(communicator->stringToProxy("IceBox.Service3")); + auto svc3 = icebox->services[2].descriptor; + auto svc3Prx = Ice::checkedCast<TestIntfPrx>(communicator->stringToProxy("IceBox.Service3")); addProperty(svc1, "test", "test"); test(svc1Prx->getProperty("test") == ""); @@ -686,9 +652,9 @@ allTests(Test::TestHelper* helper) // Wait for the server to be active to have the guarantee that // the property update will return once the properties are // updated. - while(admin->getServerState("IceBox") != IceGrid::Active) + while(admin->getServerState("IceBox") != IceGrid::ServerState::Active) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + this_thread::sleep_for(100ms); } test(hasProperty(getServiceDescriptor(admin, "Service1"), "test", "test")); test(!hasProperty(getServiceDescriptor(admin, "Service1"), "test2", "")); diff --git a/cpp/test/IceGrid/noRestartUpdate/Client.cpp b/cpp/test/IceGrid/noRestartUpdate/Client.cpp index 0d88f5c27be..cd37c6411ed 100644 --- a/cpp/test/IceGrid/noRestartUpdate/Client.cpp +++ b/cpp/test/IceGrid/noRestartUpdate/Client.cpp @@ -8,11 +8,11 @@ using namespace std; -class Client : public Test::TestHelper +class Client final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void diff --git a/cpp/test/IceGrid/noRestartUpdate/Server.cpp b/cpp/test/IceGrid/noRestartUpdate/Server.cpp index db88ace71a7..bea873f9998 100644 --- a/cpp/test/IceGrid/noRestartUpdate/Server.cpp +++ b/cpp/test/IceGrid/noRestartUpdate/Server.cpp @@ -8,7 +8,7 @@ using namespace std; -class Server : public Test::TestHelper +class Server final : public Test::TestHelper { public: @@ -19,13 +19,12 @@ void Server::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); string name = properties->getProperty("Ice.ProgramName"); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Server"); - Ice::ObjectPtr object = new TestI(adapter, properties); - adapter->add(object, Ice::stringToIdentity(name)); + auto adapter = communicator->createObjectAdapter("Server"); + adapter->add(make_shared<TestI>(adapter, properties), Ice::stringToIdentity(name)); try { diff --git a/cpp/test/IceGrid/noRestartUpdate/Service.cpp b/cpp/test/IceGrid/noRestartUpdate/Service.cpp index 847edb5b2af..8619d938614 100644 --- a/cpp/test/IceGrid/noRestartUpdate/Service.cpp +++ b/cpp/test/IceGrid/noRestartUpdate/Service.cpp @@ -9,18 +9,15 @@ using namespace std; using namespace Ice; -class ServiceI : public ::IceBox::Service +class ServiceI final : public IceBox::Service { public: - ServiceI(); - virtual ~ServiceI(); + void start(const string&, + const shared_ptr<Communicator>&, + const StringSeq&) override; - virtual void start(const string&, - const CommunicatorPtr&, - const StringSeq&); - - virtual void stop(); + void stop() override; }; extern "C" @@ -30,30 +27,21 @@ extern "C" // Factory function // ICE_DECLSPEC_EXPORT ::IceBox::Service* -create(CommunicatorPtr) +create(const shared_ptr<Communicator>&) { return new ServiceI; } } -ServiceI::ServiceI() -{ -} - -ServiceI::~ServiceI() -{ -} - void ServiceI::start(const string& name, - const CommunicatorPtr& communicator, + const shared_ptr<Communicator>& communicator, const StringSeq&) { - Ice::PropertiesPtr properties = communicator->getProperties(); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name); - Ice::ObjectPtr object = new TestI(adapter, properties); - adapter->add(object, stringToIdentity(properties->getProperty(name + ".Identity"))); + auto properties = communicator->getProperties(); + auto adapter = communicator->createObjectAdapter(name); + adapter->add(make_shared<TestI>(adapter, properties), stringToIdentity(properties->getProperty(name + ".Identity"))); adapter->activate(); } diff --git a/cpp/test/IceGrid/noRestartUpdate/TestI.cpp b/cpp/test/IceGrid/noRestartUpdate/TestI.cpp index 06688e08685..bb70d9b8da7 100644 --- a/cpp/test/IceGrid/noRestartUpdate/TestI.cpp +++ b/cpp/test/IceGrid/noRestartUpdate/TestI.cpp @@ -5,9 +5,9 @@ #include <Ice/Ice.h> #include <TestI.h> -TestI::TestI(const Ice::ObjectAdapterPtr& adapter, const Ice::PropertiesPtr& properties) : - _adapter(adapter), - _properties(properties) +TestI::TestI(std::shared_ptr<Ice::ObjectAdapter> adapter, std::shared_ptr<Ice::Properties> properties) : + _adapter(move(adapter)), + _properties(move(properties)) { } @@ -18,7 +18,7 @@ TestI::shutdown(const Ice::Current&) } std::string -TestI::getProperty(const std::string& name, const Ice::Current&) +TestI::getProperty(std::string name, const Ice::Current&) { return _properties->getProperty(name); } diff --git a/cpp/test/IceGrid/noRestartUpdate/TestI.h b/cpp/test/IceGrid/noRestartUpdate/TestI.h index 98cd86156ce..6a8ab0bf7b4 100644 --- a/cpp/test/IceGrid/noRestartUpdate/TestI.h +++ b/cpp/test/IceGrid/noRestartUpdate/TestI.h @@ -7,19 +7,19 @@ #include <Test.h> -class TestI : public ::Test::TestIntf +class TestI final : public ::Test::TestIntf { public: - TestI(const Ice::ObjectAdapterPtr&, const Ice::PropertiesPtr&); + TestI(std::shared_ptr<Ice::ObjectAdapter>, std::shared_ptr<Ice::Properties>); - virtual void shutdown(const Ice::Current&); - virtual std::string getProperty(const std::string&, const Ice::Current&); + void shutdown(const Ice::Current&) override; + std::string getProperty(std::string, const Ice::Current&) override; private: - Ice::ObjectAdapterPtr _adapter; - Ice::PropertiesPtr _properties; + std::shared_ptr<Ice::ObjectAdapter> _adapter; + std::shared_ptr<Ice::Properties> _properties; }; #endif diff --git a/cpp/test/IceGrid/replicaGroup/AllTests.cpp b/cpp/test/IceGrid/replicaGroup/AllTests.cpp index ab0d3913df3..45b68bbb36e 100644 --- a/cpp/test/IceGrid/replicaGroup/AllTests.cpp +++ b/cpp/test/IceGrid/replicaGroup/AllTests.cpp @@ -15,7 +15,8 @@ using namespace Test; using namespace IceGrid; void -instantiateServer(const AdminPrx& admin, const string& templ, const string& node, const map<string, string>& params, +instantiateServer(const shared_ptr<AdminPrx>& admin, const string& templ, const string& node, + const map<string, string>& params, const string& application = string("Test"), bool startServer = true) { ServerInstanceDescriptor desc; @@ -61,7 +62,7 @@ instantiateServer(const AdminPrx& admin, const string& templ, const string& node } void -removeServer(const AdminPrx& admin, const string& id) +removeServer(const shared_ptr<AdminPrx>& admin, const string& id) { try { @@ -102,20 +103,20 @@ removeServer(const AdminPrx& admin, const string& id) void allTests(Test::TestHelper* helper) { - Ice::CommunicatorPtr comm = helper->communicator(); - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( + auto comm = helper->communicator(); + auto registry = Ice::checkedCast<IceGrid::RegistryPrx>( comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast( + auto query = Ice::checkedCast<IceGrid::QueryPrx>( comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Query")); test(query); - AdminSessionPrx session = registry->createAdminSession("foo", "bar"); + auto session = registry->createAdminSession("foo", "bar"); session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, - Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + Ice::ACMHeartbeat::HeartbeatAlways); - AdminPrx admin = session->getAdmin(); + auto admin = session->getAdmin(); test(admin); set<string> serverReplicaIds; @@ -138,33 +139,33 @@ allTests(Test::TestHelper* helper) params["id"] = "Server3"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@RoundRobin")); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("dummy@RoundRobin")); Ice::ObjectProxySeq objs = query->findAllReplicas(obj); test(objs.size() == 3); test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end()); test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end()); test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end()); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); + obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("RoundRobin")); objs = query->findAllReplicas(obj); test(objs.size() == 3); test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end()); test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end()); test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end()); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@dummy")); + obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("dummy@dummy")); objs = query->findAllReplicas(obj); test(objs.empty()); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@Server1.ReplicatedAdapter")); + obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("dummy@Server1.ReplicatedAdapter")); objs = query->findAllReplicas(obj); test(objs.empty()); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy:tcp")); + obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("dummy:tcp")); objs = query->findAllReplicas(obj); test(objs.empty()); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy@Ordered")); + obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("dummy@Ordered")); objs = query->findAllReplicas(obj); test(objs.empty()); @@ -184,9 +185,9 @@ allTests(Test::TestHelper* helper) instantiateServer(admin, "Server", "localnode", params); params["id"] = "Server3"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("RoundRobin")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); try { test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter"); @@ -261,9 +262,9 @@ allTests(Test::TestHelper* helper) params["replicaGroup"] = "RoundRobin"; params["id"] = "IceBox1"; instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("RoundRobin")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); try { test(obj->getReplicaIdAndShutdown() == "IceBox1.Service1.Service1"); @@ -292,7 +293,7 @@ allTests(Test::TestHelper* helper) params["id"] = "Server3"; params["priority"] = "2"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Ordered")); try { test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter"); @@ -315,9 +316,9 @@ allTests(Test::TestHelper* helper) params["replicaGroup"] = "Ordered"; params["id"] = "IceBox1"; instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Ordered")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); try { test(obj->getReplicaIdAndShutdown() == "IceBox1.Service3.Service3"); @@ -343,9 +344,9 @@ allTests(Test::TestHelper* helper) instantiateServer(admin, "Server", "localnode", params); params["id"] = "Server3"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Random")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); set<string> replicaIds = serverReplicaIds; while(!replicaIds.empty()) { @@ -404,9 +405,9 @@ allTests(Test::TestHelper* helper) params["replicaGroup"] = "Random"; params["id"] = "IceBox1"; instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Random")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); set<string> replicaIds = svcReplicaIds; while(!replicaIds.empty()) { @@ -437,9 +438,9 @@ allTests(Test::TestHelper* helper) instantiateServer(admin, "Server", "localnode", params); params["id"] = "Server3"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Adaptive")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); set<string> replicaIds = serverReplicaIds; while(!replicaIds.empty()) { @@ -462,9 +463,9 @@ allTests(Test::TestHelper* helper) params["replicaGroup"] = "Adaptive"; params["id"] = "IceBox1"; instantiateServer(admin, "IceBox", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Adaptive")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); set<string> replicaIds = svcReplicaIds; while(!replicaIds.empty()) { @@ -496,14 +497,14 @@ allTests(Test::TestHelper* helper) params["id"] = "Server3"; instantiateServer(admin, "IceBox1", "localnode", params); - Ice::LocatorPrx locator = comm->getDefaultLocator(); + auto locator = comm->getDefaultLocator(); Ice::Context ctx; ctx["server"] = "Server3"; locator->ice_context(ctx); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Ordered-Filtered")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Ordered-Filtered")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); try { ctx["server"] = "Server3"; @@ -548,13 +549,13 @@ allTests(Test::TestHelper* helper) ctx["server"] = "Server3"; test(query->ice_context(ctx)->findObjectByTypeOnLeastLoadedNode( - "::Test::TestIntf2", LoadSample5)->ice_getAdapterId() == "Server3.Service.Service"); + "::Test::TestIntf2", LoadSample::LoadSample5)->ice_getAdapterId() == "Server3.Service.Service"); ctx["server"] = "Server1"; test(query->ice_context(ctx)->findObjectByTypeOnLeastLoadedNode( - "::Test::TestIntf2", LoadSample5)->ice_getAdapterId() == "Server1.ReplicatedAdapter"); + "::Test::TestIntf2", LoadSample::LoadSample5)->ice_getAdapterId() == "Server1.ReplicatedAdapter"); ctx["server"] = "Server2"; test(query->ice_context(ctx)->findObjectByTypeOnLeastLoadedNode( - "::Test::TestIntf2", LoadSample5)->ice_getAdapterId() == "Server2.ReplicatedAdapter"); + "::Test::TestIntf2", LoadSample::LoadSample5)->ice_getAdapterId() == "Server2.ReplicatedAdapter"); ctx["server"] = "Server3"; test(query->ice_context(ctx)->findAllObjectsByType("::Test::TestIntf2")[0]->ice_getAdapterId() == @@ -582,7 +583,7 @@ allTests(Test::TestHelper* helper) params["id"] = "UnknownServer"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Unknown")); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Unknown")); obj->getReplicaId(); removeServer(admin, "UnknownServer"); @@ -593,9 +594,9 @@ allTests(Test::TestHelper* helper) params["id"] = "ExcludeServer"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Exclude")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Exclude")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); try { obj->getReplicaId(); @@ -605,7 +606,7 @@ allTests(Test::TestHelper* helper) { } - Ice::LocatorPrx locator = comm->getDefaultLocator(); + auto locator = comm->getDefaultLocator(); try { Ice::Context ctx; @@ -637,9 +638,9 @@ allTests(Test::TestHelper* helper) cout << "testing load balancing n-replicas... " << flush; { - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-2")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("RoundRobin-2")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(-1)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); try { obj->ice_ping(); @@ -714,9 +715,9 @@ allTests(Test::TestHelper* helper) } { - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin-All")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(-1)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("RoundRobin-All")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(-1)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); try { obj->ice_ping(); @@ -781,13 +782,14 @@ allTests(Test::TestHelper* helper) instantiateServer(admin, "Server", "inactivenode", params); params["id"] = "Server2"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Random")); test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); // // Also make sure that findObjectByTypeOnLeastLoadedNode still work. // - obj = TestIntfPrx::uncheckedCast(query->findObjectByTypeOnLeastLoadedNode("::Test::TestIntf", LoadSample1)); + obj = Ice::uncheckedCast<TestIntfPrx>(query->findObjectByTypeOnLeastLoadedNode("::Test::TestIntf", + LoadSample::LoadSample1)); test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); removeServer(admin, "Server1"); @@ -798,7 +800,7 @@ allTests(Test::TestHelper* helper) instantiateServer(admin, "Server", "inactivenode", params); params["id"] = "Server2"; instantiateServer(admin, "Server", "localnode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin")); + obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("RoundRobin")); test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); removeServer(admin, "Server1"); removeServer(admin, "Server2"); @@ -808,7 +810,7 @@ allTests(Test::TestHelper* helper) instantiateServer(admin, "Server", "inactivenode", params); params["id"] = "Server2"; instantiateServer(admin, "Server", "localnode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Adaptive")); + obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Adaptive")); test(obj->getReplicaId() == "Server2.ReplicatedAdapter"); removeServer(admin, "Server1"); removeServer(admin, "Server2"); @@ -818,7 +820,7 @@ allTests(Test::TestHelper* helper) instantiateServer(admin, "IceBox", "localnode", params); params["id"] = "Server1"; instantiateServer(admin, "Server", "inactivenode", params); - obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); + obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Random")); test(svcReplicaIds.find(obj->getReplicaId()) != svcReplicaIds.end()); removeServer(admin, "IceBox1"); removeServer(admin, "Server1"); @@ -875,9 +877,9 @@ allTests(Test::TestHelper* helper) // Test has a replica group referenced by the Test1 application. } - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("Random")); - obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0)); - obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("Random")); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_locatorCacheTimeout(0)); + obj = Ice::uncheckedCast<TestIntfPrx>(obj->ice_connectionCached(false)); set<string> replicaIds; replicaIds.insert("Server1.ReplicatedAdapter"); replicaIds.insert("Server2.ReplicatedAdapter"); @@ -899,7 +901,7 @@ allTests(Test::TestHelper* helper) ReplicaGroupDescriptor replicaGroup; replicaGroup.id = "ReplicatedAdapterFromTest1"; - replicaGroup.loadBalancing = new RandomLoadBalancingPolicy(); + replicaGroup.loadBalancing = make_shared<RandomLoadBalancingPolicy>(); replicaGroup.loadBalancing->nReplicas = "0"; update = ApplicationUpdateDescriptor(); update.name = "Test1"; @@ -978,7 +980,7 @@ allTests(Test::TestHelper* helper) params["encoding"] = "1.0"; instantiateServer(admin, "Server", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy(*p)); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy(*p)); obj = obj->ice_locatorCacheTimeout(0); obj = obj->ice_connectionCached(false); @@ -1021,7 +1023,7 @@ allTests(Test::TestHelper* helper) params["encoding"] = "1.0"; instantiateServer(admin, "DynamicallyRegisteredServer", "localnode", params); - TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("DynamicRandom@DynamicRandom")); + auto obj = Ice::uncheckedCast<TestIntfPrx>(comm->stringToProxy("DynamicRandom@DynamicRandom")); obj = obj->ice_locatorCacheTimeout(0); obj = obj->ice_connectionCached(false); obj = obj->ice_encodingVersion(Ice::Encoding_1_1); @@ -1117,7 +1119,7 @@ allTests(Test::TestHelper* helper) app.descriptor.nodes.clear(); ReplicaGroupDescriptor replicaGroup; replicaGroup.id = "DynamicRandomRG"; - replicaGroup.loadBalancing = new RandomLoadBalancingPolicy("1"); + replicaGroup.loadBalancing = make_shared<RandomLoadBalancingPolicy>("1"); app.descriptor.replicaGroups.push_back(replicaGroup); try { diff --git a/cpp/test/IceGrid/replicaGroup/RegistryPlugin.cpp b/cpp/test/IceGrid/replicaGroup/RegistryPlugin.cpp index e5254890f9a..a8b8168ca94 100644 --- a/cpp/test/IceGrid/replicaGroup/RegistryPlugin.cpp +++ b/cpp/test/IceGrid/replicaGroup/RegistryPlugin.cpp @@ -13,34 +13,34 @@ using namespace IceGrid; namespace { -class RegistryPluginI : public Ice::Plugin +class RegistryPluginI final : public Ice::Plugin { public: - RegistryPluginI(const Ice::CommunicatorPtr&); + RegistryPluginI(const shared_ptr<Ice::Communicator>&); - virtual void initialize(); - virtual void destroy(); + void initialize() override; + void destroy() override; private: - const Ice::CommunicatorPtr _communicator; - ReplicaGroupFilterPtr _filterByServer; - ReplicaGroupFilterPtr _excludeServer2; - ReplicaGroupFilterPtr _excludeServer3; - TypeFilterPtr _type; + const shared_ptr<Ice::Communicator> _communicator; + shared_ptr<ReplicaGroupFilter> _filterByServer; + shared_ptr<ReplicaGroupFilter> _excludeServer2; + shared_ptr<ReplicaGroupFilter> _excludeServer3; + shared_ptr<TypeFilter> _type; }; -class ReplicaGroupFilterI : public IceGrid::ReplicaGroupFilter +class ReplicaGroupFilterI final : public IceGrid::ReplicaGroupFilter { public: - ReplicaGroupFilterI(const RegistryPluginFacadePtr& facade) : _facade(facade), _testFacade(true) + ReplicaGroupFilterI(const shared_ptr<RegistryPluginFacade>& facade) : _facade(facade), _testFacade(true) { } - virtual Ice::StringSeq - filter(const string& id, const Ice::StringSeq& adpts, const Ice::ConnectionPtr&, const Ice::Context& ctx) + Ice::StringSeq + filter(const string& id, const Ice::StringSeq& adpts, const shared_ptr<Ice::Connection>&, const Ice::Context& ctx) override { if(_testFacade) { @@ -67,7 +67,7 @@ public: } } - Ice::Context::const_iterator p = ctx.find("server"); + auto p = ctx.find("server"); if(p == ctx.end()) { return adpts; @@ -75,11 +75,11 @@ public: string server = p->second; Ice::StringSeq filteredAdapters; - for(Ice::StringSeq::const_iterator q = adpts.begin(); q != adpts.end(); ++q) + for(const auto& adapter : adpts) { - if(_facade->getAdapterServer(*q) == server) + if(_facade->getAdapterServer(adapter) == server) { - filteredAdapters.push_back(*q); + filteredAdapters.push_back(adapter); } } return filteredAdapters; @@ -87,22 +87,23 @@ public: private: - RegistryPluginFacadePtr _facade; + shared_ptr<RegistryPluginFacade> _facade; bool _testFacade; }; -class TypeFilterI : public IceGrid::TypeFilter +class TypeFilterI final : public IceGrid::TypeFilter { public: - TypeFilterI(const RegistryPluginFacadePtr& facade) : _facade(facade) + TypeFilterI(const shared_ptr<RegistryPluginFacade>& facade) : _facade(facade) { } - virtual Ice::ObjectProxySeq - filter(const string& /*type*/, const Ice::ObjectProxySeq& objects, const Ice::ConnectionPtr&, const Ice::Context& ctx) + Ice::ObjectProxySeq + filter(const string&, const Ice::ObjectProxySeq& objects, const shared_ptr<Ice::Connection>&, + const Ice::Context& ctx) override { - Ice::Context::const_iterator p = ctx.find("server"); + auto p = ctx.find("server"); if(p == ctx.end()) { return objects; @@ -110,11 +111,11 @@ public: string server = p->second; Ice::ObjectProxySeq filteredObjects; - for(Ice::ObjectProxySeq::const_iterator q = objects.begin(); q != objects.end(); ++q) + for(const auto& object : objects) { - if(_facade->getAdapterServer((*q)->ice_getAdapterId()) == server) + if(_facade->getAdapterServer(object->ice_getAdapterId()) == server) { - filteredObjects.push_back(*q); + filteredObjects.push_back(object); } } return filteredObjects; @@ -122,22 +123,23 @@ public: private: - RegistryPluginFacadePtr _facade; + shared_ptr<RegistryPluginFacade> _facade; }; -class ExcludeReplicaGroupFilterI : public IceGrid::ReplicaGroupFilter +class ExcludeReplicaGroupFilterI final : public IceGrid::ReplicaGroupFilter { public: - ExcludeReplicaGroupFilterI(const RegistryPluginFacadePtr& facade, const string& exclude) : + ExcludeReplicaGroupFilterI(const shared_ptr<RegistryPluginFacade>& facade, const string& exclude) : _facade(facade), _exclude(exclude) { } - virtual Ice::StringSeq - filter(const string& /*id*/, const Ice::StringSeq& adapters, const Ice::ConnectionPtr& /*con*/, const Ice::Context& ctx) + Ice::StringSeq + filter(const string&, const Ice::StringSeq& adapters, const shared_ptr<Ice::Connection>& , + const Ice::Context& ctx) override { - Ice::Context::const_iterator p = ctx.find("server"); + auto p = ctx.find("server"); if(p == ctx.end() || p->second == _exclude) { return Ice::StringSeq(); @@ -147,7 +149,7 @@ public: private: - const RegistryPluginFacadePtr _facade; + const shared_ptr<RegistryPluginFacade> _facade; const string _exclude; }; @@ -158,27 +160,27 @@ extern "C" { ICE_DECLSPEC_EXPORT Ice::Plugin* -createRegistryPlugin(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&) +createRegistryPlugin(const shared_ptr<Ice::Communicator>& communicator, const string&, const Ice::StringSeq&) { return new RegistryPluginI(communicator); } } -RegistryPluginI::RegistryPluginI(const Ice::CommunicatorPtr& communicator) : _communicator(communicator) +RegistryPluginI::RegistryPluginI(const shared_ptr<Ice::Communicator>& communicator) : _communicator(communicator) { } void RegistryPluginI::initialize() { - IceGrid::RegistryPluginFacadePtr facade = IceGrid::getRegistryPluginFacade(); + auto facade = IceGrid::getRegistryPluginFacade(); assert(facade); - _filterByServer = new ReplicaGroupFilterI(facade); - _excludeServer2 = new ExcludeReplicaGroupFilterI(facade, "Server2"); - _excludeServer3 = new ExcludeReplicaGroupFilterI(facade, "Server3"); - _type = new TypeFilterI(facade); + _filterByServer = make_shared<ReplicaGroupFilterI>(facade); + _excludeServer2 = make_shared<ExcludeReplicaGroupFilterI>(facade, "Server2"); + _excludeServer3 = make_shared<ExcludeReplicaGroupFilterI>(facade, "Server3"); + _type = make_shared<TypeFilterI>(facade); facade->addReplicaGroupFilter("filterByServer", _filterByServer); test(facade->removeReplicaGroupFilter("filterByServer", _filterByServer)); @@ -193,7 +195,7 @@ RegistryPluginI::initialize() void RegistryPluginI::destroy() { - IceGrid::RegistryPluginFacadePtr facade = IceGrid::getRegistryPluginFacade(); + auto facade = IceGrid::getRegistryPluginFacade(); assert(facade); facade->removeReplicaGroupFilter("filterByServer", _filterByServer); diff --git a/cpp/test/IceGrid/replicaGroup/Server.cpp b/cpp/test/IceGrid/replicaGroup/Server.cpp index d397d9ad8e7..6ec653b5e73 100644 --- a/cpp/test/IceGrid/replicaGroup/Server.cpp +++ b/cpp/test/IceGrid/replicaGroup/Server.cpp @@ -19,9 +19,9 @@ void Server::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::ObjectAdapterPtr adpt = communicator->createObjectAdapter("ReplicatedAdapter"); - Ice::PropertiesPtr properties = communicator->getProperties(); - Ice::ObjectPtr object = new TestI(properties); + auto adpt = communicator->createObjectAdapter("ReplicatedAdapter"); + auto properties = communicator->getProperties(); + auto object = make_shared<TestI>(properties); adpt->add(object, Ice::stringToIdentity(properties->getProperty("Ice.ProgramName"))); adpt->add(object, Ice::stringToIdentity(properties->getProperty("Identity"))); try diff --git a/cpp/test/IceGrid/replicaGroup/Service.cpp b/cpp/test/IceGrid/replicaGroup/Service.cpp index c5954bcf7dc..c14058a5de1 100644 --- a/cpp/test/IceGrid/replicaGroup/Service.cpp +++ b/cpp/test/IceGrid/replicaGroup/Service.cpp @@ -9,18 +9,15 @@ using namespace std; using namespace Ice; -class ServiceI : public ::IceBox::Service +class ServiceI final : public IceBox::Service { public: - ServiceI(); - virtual ~ServiceI(); + void start(const string&, + const shared_ptr<Communicator>&, + const StringSeq&) override; - virtual void start(const string&, - const CommunicatorPtr&, - const StringSeq&); - - virtual void stop(); + void stop() override; }; extern "C" @@ -30,28 +27,20 @@ extern "C" // Factory function // ICE_DECLSPEC_EXPORT ::IceBox::Service* -create(CommunicatorPtr) +create(const shared_ptr<Communicator>&) { return new ServiceI; } } -ServiceI::ServiceI() -{ -} - -ServiceI::~ServiceI() -{ -} - void ServiceI::start(const string& name, - const CommunicatorPtr& communicator, + const shared_ptr<Communicator>& communicator, const StringSeq&) { - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name); - Ice::ObjectPtr object = new TestI(communicator->getProperties()); + auto adapter = communicator->createObjectAdapter(name); + auto object = make_shared<TestI>(communicator->getProperties()); adapter->add(object, stringToIdentity(name)); adapter->add(object, stringToIdentity(communicator->getProperties()->getProperty("Identity"))); adapter->activate(); diff --git a/cpp/test/IceGrid/replication/AllTests.cpp b/cpp/test/IceGrid/replication/AllTests.cpp index 48617b06114..bad435fca86 100644 --- a/cpp/test/IceGrid/replication/AllTests.cpp +++ b/cpp/test/IceGrid/replication/AllTests.cpp @@ -6,7 +6,6 @@ #include <Ice/BuiltinSequences.h> #include <Ice/Locator.h> #include <IceGrid/IceGrid.h> -#include <IceUtil/Thread.h> #include <TestHelper.h> #include <Test.h> @@ -17,37 +16,28 @@ using namespace IceGrid; namespace { -const int sleepTime = 100; // 100ms -const int maxRetry = 240000 / sleepTime; // 4 minutes +const auto sleepTime = 100ms; +const int maxRetry = static_cast<int>(120000 / sleepTime.count()); // 2 minutes void -addProperty(const CommunicatorDescriptorPtr& communicator, const string& name, const string& value) -{ - PropertyDescriptor prop; - prop.name = name; - prop.value = value; - communicator->propertySet.properties.push_back(prop); -} - -void -waitForServerState(const IceGrid::AdminPrx& admin, const std::string& server, bool up) +waitForServerState(const shared_ptr<AdminPrx>& admin, const string& server, bool up) { int nRetry = 0; - while(nRetry < maxRetry) // One minute + while(nRetry < maxRetry) { - if(admin->getServerState(server) == (up ? Active : Inactive)) + if(admin->getServerState(server) == (up ? ServerState::Active : ServerState::Inactive)) { return; } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime)); + this_thread::sleep_for(sleepTime); ++nRetry; } test(false); } void -waitForReplicaState(const IceGrid::AdminPrx& admin, const std::string& replica, bool up) +waitForReplicaState(const shared_ptr<AdminPrx>& admin, const string& replica, bool up) { int nRetry = 0; while(nRetry < maxRetry) @@ -67,7 +57,7 @@ waitForReplicaState(const IceGrid::AdminPrx& admin, const std::string& replica, } } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime)); + this_thread::sleep_for(sleepTime); ++nRetry; } @@ -93,7 +83,7 @@ waitForReplicaState(const IceGrid::AdminPrx& admin, const std::string& replica, } void -waitForNodeState(const IceGrid::AdminPrx& admin, const std::string& node, bool up) +waitForNodeState(const shared_ptr<AdminPrx>& admin, const string& node, bool up) { int nRetry = 0; while(nRetry < maxRetry) @@ -113,7 +103,7 @@ waitForNodeState(const IceGrid::AdminPrx& admin, const std::string& node, bool u } } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime)); + this_thread::sleep_for(sleepTime); ++nRetry; } try @@ -137,17 +127,17 @@ waitForNodeState(const IceGrid::AdminPrx& admin, const std::string& node, bool u } void -instantiateServer(const AdminPrx& admin, const string& templ, const map<string, string>& params) +instantiateServer(const shared_ptr<AdminPrx>& admin, string templ, const map<string, string>& params) { ServerInstanceDescriptor desc; - desc._cpp_template = templ; + desc._cpp_template = move(templ); desc.parameterValues = params; NodeUpdateDescriptor nodeUpdate; nodeUpdate.name = "localnode"; - nodeUpdate.serverInstances.push_back(desc); + nodeUpdate.serverInstances.push_back(move(desc)); ApplicationUpdateDescriptor update; update.name = "Test"; - update.nodes.push_back(nodeUpdate); + update.nodes.push_back(move(nodeUpdate)); try { admin->updateApplication(update); @@ -165,7 +155,7 @@ instantiateServer(const AdminPrx& admin, const string& templ, const map<string, } void -removeServer(const AdminPrx& admin, const string& id) +removeServer(const shared_ptr<AdminPrx>& admin, const string& id) { try { @@ -188,7 +178,7 @@ removeServer(const AdminPrx& admin, const string& id) nodeUpdate.removeServers.push_back(id); ApplicationUpdateDescriptor update; update.name = "Test"; - update.nodes.push_back(nodeUpdate); + update.nodes.push_back(move(nodeUpdate)); try { admin->updateApplication(update); @@ -201,7 +191,7 @@ removeServer(const AdminPrx& admin, const string& id) } bool -waitAndPing(const Ice::ObjectPrx& obj) +waitAndPing(const shared_ptr<Ice::ObjectPrx>& obj) { int nRetry = 0; while(nRetry < maxRetry) @@ -213,15 +203,15 @@ waitAndPing(const Ice::ObjectPrx& obj) } catch(const Ice::LocalException&) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime)); + this_thread::sleep_for(sleepTime); ++nRetry; } } return false; } -AdminPrx -createAdminSession(const Ice::LocatorPrx& locator, const string& replica) +shared_ptr<AdminPrx> +createAdminSession(const shared_ptr<Ice::LocatorPrx>& locator, string replica) { test(waitAndPing(locator)); @@ -230,31 +220,43 @@ createAdminSession(const Ice::LocatorPrx& locator, const string& replica) { registryStr += "-" + replica; } - Ice::ObjectPrx obj = locator->ice_getCommunicator()->stringToProxy(registryStr)->ice_locator(locator); - RegistryPrx registry = RegistryPrx::checkedCast(obj); + auto obj = locator->ice_getCommunicator()->stringToProxy(registryStr)->ice_locator(locator); + auto registry = Ice::checkedCast<RegistryPrx>(obj); test(registry); - AdminSessionPrx session = AdminSessionPrx::checkedCast(registry->createAdminSession("foo", "bar")); + auto session = Ice::checkedCast<AdminSessionPrx>(registry->createAdminSession("foo", "bar")); test(session); return session->getAdmin(); } +bool +isObjectInfoEqual(const ObjectInfo& info1, const ObjectInfo& info2) +{ + return (info1.type == info2.type) && Ice::targetEqualTo(info1.proxy, info2.proxy); +} + +bool +isAdapterInfoEqual(const AdapterInfo& adpt1, const AdapterInfo& adpt2) +{ + return (adpt1.id == adpt2.id) && (adpt1.replicaGroupId == adpt2.replicaGroupId) && Ice::targetEqualTo(adpt1.proxy, adpt2.proxy); +} + } void -allTests(Test::TestHelper* helper) +allTests(TestHelper* helper) { - Ice::CommunicatorPtr comm = helper->communicator(); - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry")); + auto communicator = helper->communicator(); + auto registry = Ice::checkedCast<RegistryPrx>(communicator->stringToProxy( + communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); - AdminSessionPrx adminSession = registry->createAdminSession("foo", "bar"); + auto adminSession = registry->createAdminSession("foo", "bar"); adminSession->ice_getConnection()->setACM(registry->getACMTimeout(), - IceUtil::None, - Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + Ice::nullopt, + Ice::ACMHeartbeat::HeartbeatAlways); - AdminPrx admin = adminSession->getAdmin(); + auto admin = adminSession->getAdmin(); test(admin); map<string, string> params; @@ -277,17 +279,17 @@ allTests(Test::TestHelper* helper) params["port"] = "12052"; instantiateServer(admin, "IceGridRegistry", params); - Ice::LocatorPrx masterLocator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator-Master:default -p 12050")); - Ice::LocatorPrx slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator-Slave1:default -p 12051")); - Ice::LocatorPrx slave2Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator-Slave2:default -p 12052")); + auto masterLocator = Ice::uncheckedCast<Ice::LocatorPrx>( + communicator->stringToProxy("RepTestIceGrid/Locator-Master:default -p 12050")); + auto slave1Locator = Ice::uncheckedCast<Ice::LocatorPrx>( + communicator->stringToProxy("RepTestIceGrid/Locator-Slave1:default -p 12051")); + auto slave2Locator = Ice::uncheckedCast<Ice::LocatorPrx>( + communicator->stringToProxy("RepTestIceGrid/Locator-Slave2:default -p 12052")); - Ice::LocatorPrx replicatedLocator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator:default -p 12050:default -p 12051")); + auto replicatedLocator = Ice::uncheckedCast<Ice::LocatorPrx>( + communicator->stringToProxy("RepTestIceGrid/Locator:default -p 12050:default -p 12051")); - AdminPrx masterAdmin, slave1Admin, slave2Admin; + shared_ptr<AdminPrx> masterAdmin, slave1Admin, slave2Admin; admin->startServer("Master"); masterAdmin = createAdminSession(masterLocator, ""); @@ -310,53 +312,48 @@ allTests(Test::TestHelper* helper) { Ice::EndpointSeq endpoints; ObjectInfo info; - info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")); - ObjectInfo info1 = slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")); - test(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) == info); + auto info1 = slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")); + test(isObjectInfoEqual(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")), info)); test(info.type == Ice::Locator::ice_staticId()); endpoints = info.proxy->ice_getEndpoints(); test(endpoints.size() == 2); test(endpoints[0]->toString().find("-p 12050") != string::npos); test(endpoints[1]->toString().find("-p 12051") != string::npos); - info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")); - test(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); + test(isObjectInfoEqual(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")), info)); + test(info.type == Query::ice_staticId()); endpoints = info.proxy->ice_getEndpoints(); test(endpoints.size() == 2); test(endpoints[0]->toString().find("-p 12050") != string::npos); test(endpoints[1]->toString().find("-p 12051") != string::npos); - admin->startServer("Slave2"); slave2Admin = createAdminSession(slave2Locator, "Slave2"); - info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")); // We eventually need to wait here for the update of the replicated objects to propagate to the replica. int nRetry = 0; - while(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) != info && nRetry < maxRetry) + while(!isObjectInfoEqual(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")), info) && nRetry < maxRetry) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime)); + this_thread::sleep_for(sleepTime); ++nRetry; } - test(slave2Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) == info); + test(isObjectInfoEqual(slave2Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")), info)); test(info.type == Ice::Locator::ice_staticId()); endpoints = info.proxy->ice_getEndpoints(); test(endpoints.size() == 3); test(endpoints[0]->toString().find("-p 12050") != string::npos); test(endpoints[1]->toString().find("-p 12051") != string::npos); test(endpoints[2]->toString().find("-p 12052") != string::npos); - info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")); // We eventually need to wait here for the update of the replicated objects to propagate to the replica. nRetry = 0; - while(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")) != info && nRetry < maxRetry) + while(!isObjectInfoEqual(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")), info) && nRetry < maxRetry) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime)); + this_thread::sleep_for(sleepTime); ++nRetry; } - test(slave2Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); + test(isObjectInfoEqual(slave2Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")), info)); + test(info.type == Query::ice_staticId()); endpoints = info.proxy->ice_getEndpoints(); test(endpoints.size() == 3); test(endpoints[0]->toString().find("-p 12050") != string::npos); @@ -369,12 +366,12 @@ allTests(Test::TestHelper* helper) info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")); // We eventually need to wait here for the update of the replicated objects to propagate to the replica. nRetry = 0; - while(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) != info && nRetry < maxRetry) + while(!isObjectInfoEqual(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")), info) && nRetry < maxRetry) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime)); + this_thread::sleep_for(sleepTime); ++nRetry; } - test(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")) == info); + test(isObjectInfoEqual(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Locator")), info)); test(info.type == Ice::Locator::ice_staticId()); endpoints = info.proxy->ice_getEndpoints(); test(endpoints.size() == 2); @@ -383,24 +380,31 @@ allTests(Test::TestHelper* helper) info = masterAdmin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")); nRetry = 0; - while(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")) != info && nRetry < maxRetry) + while(!isObjectInfoEqual(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")), info) && nRetry < maxRetry) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(sleepTime)); + this_thread::sleep_for(sleepTime); ++nRetry; } - test(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")) == info); - test(info.type == IceGrid::Query::ice_staticId()); + test(isObjectInfoEqual(slave1Admin->getObjectInfo(Ice::stringToIdentity("RepTestIceGrid/Query")), info)); + test(info.type == Query::ice_staticId()); endpoints = info.proxy->ice_getEndpoints(); test(endpoints.size() == 2); test(endpoints[0]->toString().find("-p 12050") != string::npos); test(endpoints[1]->toString().find("-p 12051") != string::npos); - QueryPrx query; - query = QueryPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Query:" + endpoints[0]->toString())); - Ice::ObjectProxySeq objs = query->findAllObjectsByType("::IceGrid::Registry"); - test(objs.size() == 2); - query = QueryPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Query:" + endpoints[1]->toString())); - test(objs == query->findAllObjectsByType("::IceGrid::Registry")); + shared_ptr<QueryPrx> query; + query = Ice::uncheckedCast<QueryPrx>( + communicator->stringToProxy("RepTestIceGrid/Query:" + endpoints[0]->toString())); + auto objs1 = query->findAllObjectsByType("::IceGrid::Registry"); + test(objs1.size() == 2); + + query = Ice::uncheckedCast<QueryPrx>( + communicator->stringToProxy("RepTestIceGrid/Query:" + endpoints[1]->toString())); + auto objs2 = query->findAllObjectsByType("::IceGrid::Registry"); + for(size_t i = 0; i < objs1.size(); i++) + { + test(Ice::targetEqualTo(objs1[i], objs2[i])); + } } cout << "ok" << endl; @@ -411,14 +415,14 @@ allTests(Test::TestHelper* helper) // admin session creation for the creation of the admin // session above!) // - RegistryPrx masterRegistry = RegistryPrx::checkedCast( - comm->stringToProxy("RepTestIceGrid/Registry")->ice_locator(replicatedLocator)); - RegistryPrx slave1Registry = RegistryPrx::checkedCast( - comm->stringToProxy("RepTestIceGrid/Registry-Slave1")->ice_locator(replicatedLocator)); + auto masterRegistry = Ice::checkedCast<RegistryPrx>( + communicator->stringToProxy("RepTestIceGrid/Registry")->ice_locator(replicatedLocator)); + auto slave1Registry = Ice::checkedCast<RegistryPrx>( + communicator->stringToProxy("RepTestIceGrid/Registry-Slave1")->ice_locator(replicatedLocator)); - SessionPrx session = masterRegistry->createSession("dummy", "dummy"); + auto session = masterRegistry->createSession("dummy", "dummy"); session->destroy(); - if(comm->getProperties()->getProperty("Ice.Default.Protocol") == "ssl") + if(communicator->getProperties()->getProperty("Ice.Default.Protocol") == "ssl") { session = masterRegistry->createSessionFromSecureConnection(); session->destroy(); @@ -452,10 +456,10 @@ allTests(Test::TestHelper* helper) // // Test registry user-account mapper. // - UserAccountMapperPrx masterMapper = UserAccountMapperPrx::checkedCast( - comm->stringToProxy("RepTestIceGrid/RegistryUserAccountMapper")->ice_locator(replicatedLocator)); - UserAccountMapperPrx slave1Mapper = UserAccountMapperPrx::checkedCast( - comm->stringToProxy("RepTestIceGrid/RegistryUserAccountMapper-Slave1")->ice_locator(replicatedLocator)); + auto masterMapper = Ice::checkedCast<UserAccountMapperPrx>( + communicator->stringToProxy("RepTestIceGrid/RegistryUserAccountMapper")->ice_locator(replicatedLocator)); + auto slave1Mapper = Ice::checkedCast<UserAccountMapperPrx>( + communicator->stringToProxy("RepTestIceGrid/RegistryUserAccountMapper-Slave1")->ice_locator(replicatedLocator)); test(masterMapper->getUserAccount("Dummy User Account1") == "dummy1"); test(masterMapper->getUserAccount("Dummy User Account2") == "dummy2"); @@ -482,11 +486,11 @@ allTests(Test::TestHelper* helper) // Test SessionManager, SSLSessionManager, // AdminSessionManager, AdminSSLSessionManager // - comm->stringToProxy("RepTestIceGrid/SessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("RepTestIceGrid/SSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + communicator->stringToProxy("RepTestIceGrid/SessionManager")->ice_locator(replicatedLocator)->ice_ping(); + communicator->stringToProxy("RepTestIceGrid/SSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); try { - comm->stringToProxy("RepTestIceGrid/SessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + communicator->stringToProxy("RepTestIceGrid/SessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); test(false); } catch(const Ice::NotRegisteredException&) @@ -494,17 +498,17 @@ allTests(Test::TestHelper* helper) } try { - comm->stringToProxy("RepTestIceGrid/SSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + communicator->stringToProxy("RepTestIceGrid/SSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); test(false); } catch(const Ice::NotRegisteredException&) { } - comm->stringToProxy("RepTestIceGrid/AdminSessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("RepTestIceGrid/AdminSSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("RepTestIceGrid/AdminSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); - comm->stringToProxy("RepTestIceGrid/AdminSSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + communicator->stringToProxy("RepTestIceGrid/AdminSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + communicator->stringToProxy("RepTestIceGrid/AdminSSLSessionManager")->ice_locator(replicatedLocator)->ice_ping(); + communicator->stringToProxy("RepTestIceGrid/AdminSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); + communicator->stringToProxy("RepTestIceGrid/AdminSSLSessionManager-Slave1")->ice_locator(replicatedLocator)->ice_ping(); } cout << "ok" << endl; @@ -525,10 +529,10 @@ allTests(Test::TestHelper* helper) AdapterInfo adpt; adpt.id = "TestAdpt"; - adpt.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); + adpt.proxy = communicator->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); ObjectInfo obj; - obj.proxy = comm->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); + obj.proxy = communicator->stringToProxy("dummy:tcp -p 12345 -h 127.0.0.1"); obj.type = "::Hello"; // @@ -536,7 +540,7 @@ allTests(Test::TestHelper* helper) // forwarding to the master work (the slave locator registry // forwards everything to the master). // - Ice::LocatorRegistryPrx locatorRegistry = slave1Locator->getRegistry(); + auto locatorRegistry = slave1Locator->getRegistry(); // // Test addition of application, adapter, object. @@ -573,13 +577,13 @@ allTests(Test::TestHelper* helper) test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "added application"); - test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); + test(isAdapterInfoEqual(masterAdmin->getAdapterInfo("TestAdpt")[0], adpt)); + test(isAdapterInfoEqual(slave1Admin->getAdapterInfo("TestAdpt")[0], adpt)); + test(isAdapterInfoEqual(slave2Admin->getAdapterInfo("TestAdpt")[0], adpt)); - test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(isObjectInfoEqual(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()), obj)); + test(isObjectInfoEqual(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()), obj)); + test(isObjectInfoEqual(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()), obj)); slave2Admin->shutdown(); waitForServerState(admin, "Slave2", false); @@ -614,7 +618,7 @@ allTests(Test::TestHelper* helper) ApplicationUpdateDescriptor appUpdate; appUpdate.name = "TestApp"; - appUpdate.description = new BoxedString("updated2 application"); + appUpdate.description = make_shared<BoxedString>("updated2 application"); try { slave1Admin->updateApplication(appUpdate); @@ -629,7 +633,7 @@ allTests(Test::TestHelper* helper) adpt.replicaGroupId = "TestReplicaGroup"; locatorRegistry->setReplicatedAdapterDirectProxy(adpt.id, adpt.replicaGroupId, adpt.proxy); - obj.proxy = comm->stringToProxy("dummy:tcp -p 12346 -h 127.0.0.1"); + obj.proxy = communicator->stringToProxy("dummy:tcp -p 12346 -h 127.0.0.1"); try { slave1Admin->updateObject(obj.proxy); @@ -648,13 +652,13 @@ allTests(Test::TestHelper* helper) test(slave1Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); test(slave2Admin->getApplicationInfo("TestApp").descriptor.description == "updated2 application"); - test(masterAdmin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave1Admin->getAdapterInfo("TestAdpt")[0] == adpt); - test(slave2Admin->getAdapterInfo("TestAdpt")[0] == adpt); + test(isAdapterInfoEqual(masterAdmin->getAdapterInfo("TestAdpt")[0], adpt)); + test(isAdapterInfoEqual(slave1Admin->getAdapterInfo("TestAdpt")[0], adpt)); + test(isAdapterInfoEqual(slave2Admin->getAdapterInfo("TestAdpt")[0], adpt)); - test(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); - test(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()) == obj); + test(isObjectInfoEqual(masterAdmin->getObjectInfo(obj.proxy->ice_getIdentity()), obj)); + test(isObjectInfoEqual(slave1Admin->getObjectInfo(obj.proxy->ice_getIdentity()), obj)); + test(isObjectInfoEqual(slave2Admin->getObjectInfo(obj.proxy->ice_getIdentity()), obj)); slave2Admin->shutdown(); waitForServerState(admin, "Slave2", false); @@ -780,7 +784,7 @@ allTests(Test::TestHelper* helper) { // // Add an application which is using Node1. Otherwise, when a - // registry restarts it would throw aways the proxy of the nodes + // registry restarts it would throw away the proxy of the nodes // because the node isn't used by any application. // ApplicationDescriptor app; @@ -834,7 +838,7 @@ allTests(Test::TestHelper* helper) // if(!slave1Admin->pingNode("Node1")) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } test(slave1Admin->pingNode("Node1")); // Node should be re-connected. } @@ -855,7 +859,7 @@ allTests(Test::TestHelper* helper) { if(!slave2Admin->pingNode("Node1")) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } test(slave2Admin->pingNode("Node1")); // Node should be re-connected even if the master is down. } @@ -874,7 +878,7 @@ allTests(Test::TestHelper* helper) { if(!masterAdmin->pingNode("Node1")) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } test(masterAdmin->pingNode("Node1")); // Node should be re-connected. } @@ -890,7 +894,7 @@ allTests(Test::TestHelper* helper) { if(!slave1Admin->pingNode("Node1")) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } test(slave1Admin->pingNode("Node1")); // Node should be re-connected. } @@ -903,7 +907,7 @@ allTests(Test::TestHelper* helper) { if(!masterAdmin->pingNode("Node1")) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } test(masterAdmin->pingNode("Node1")); } @@ -916,7 +920,7 @@ allTests(Test::TestHelper* helper) { if(!slave2Admin->pingNode("Node1")) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } test(slave2Admin->pingNode("Node1")); } @@ -933,7 +937,7 @@ allTests(Test::TestHelper* helper) { if(!slave2Admin->pingNode("Node1")) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } test(slave2Admin->pingNode("Node1")); } @@ -953,51 +957,46 @@ allTests(Test::TestHelper* helper) app.name = "TestApp"; app.description = "added application"; - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); server->id = "Server"; - server->exe = comm->getProperties()->getProperty("ServerDir") + "/server"; + server->exe = communicator->getProperties()->getProperty("ServerDir") + "/server"; server->pwd = "."; server->allocatable = false; - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); server->activation = "on-demand"; AdapterDescriptor adapter; adapter.name = "TestAdapter"; adapter.id = "TestAdapter.Server"; adapter.registerProcess = false; adapter.serverLifetime = true; - PropertyDescriptor property; - property.name = "TestAdapter.Endpoints"; - property.value = "default"; - server->propertySet.properties.push_back(property); - property.name = "Identity"; - property.value = "test"; - server->propertySet.properties.push_back(property); + server->propertySet.properties.push_back(PropertyDescriptor{ "TestAdapter.Endpoints", "default" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "Identity", "test" }); ObjectDescriptor object; object.id = Ice::stringToIdentity("test"); object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); + adapter.objects.push_back(move(object)); + server->adapters.push_back(move(adapter)); app.nodes["Node1"].servers.push_back(server); masterAdmin->addApplication(app); try { - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); } catch(const Ice::LocalException& ex) { cerr << ex << endl; - ApplicationInfo appInfo = admin->getApplicationInfo("Test"); + auto appInfo = admin->getApplicationInfo("Test"); cerr << "properties-override = " << appInfo.descriptor.variables["properties-override"] << endl; - PropertyDescriptorSeq& seq = admin->getServerInfo("Node1").descriptor->propertySet.properties; - for(PropertyDescriptorSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + auto propertySeq = admin->getServerInfo("Node1").descriptor->propertySet.properties; + for(const auto& p : propertySeq) { - cerr << p->name << " = " << p->value << endl; + cerr << p.name << " = " << p.value << endl; } test(false); } @@ -1015,16 +1014,14 @@ allTests(Test::TestHelper* helper) NodeUpdateDescriptor node; node.name = "Node1"; node.servers.push_back(server); - update.nodes.push_back(node); - property.name = "Dummy"; - property.value = "val"; - server->propertySet.properties.push_back(property); + update.nodes.push_back(move(node)); + server->propertySet.properties.push_back(PropertyDescriptor{ "Dummy", "val" }); masterAdmin->updateApplication(update); try { - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); } catch(const Ice::LocalException& ex) { @@ -1049,7 +1046,7 @@ allTests(Test::TestHelper* helper) } try { - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) @@ -1066,7 +1063,7 @@ allTests(Test::TestHelper* helper) try { - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); } catch(const Ice::LocalException& ex) { @@ -1084,9 +1081,7 @@ allTests(Test::TestHelper* helper) slave2Admin->shutdown(); waitForServerState(admin, "Slave2", false); - property.name = "Dummy2"; - property.value = "val"; - server->propertySet.properties.push_back(property); + server->propertySet.properties.push_back(PropertyDescriptor{ "Dummy2", "val" }); masterAdmin->updateApplication(update); masterAdmin->shutdown(); @@ -1109,7 +1104,7 @@ allTests(Test::TestHelper* helper) try { - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); } catch(const Ice::LocalException& ex) { @@ -1122,7 +1117,7 @@ allTests(Test::TestHelper* helper) try { - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); } catch(const Ice::NoEndpointException&) { @@ -1130,7 +1125,7 @@ allTests(Test::TestHelper* helper) try { - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); } catch(const Ice::LocalException& ex) { @@ -1166,9 +1161,9 @@ allTests(Test::TestHelper* helper) try { - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); } catch(const Ice::LocalException& ex) { @@ -1188,37 +1183,32 @@ allTests(Test::TestHelper* helper) app.name = "TestApp"; app.description = "added application"; - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); server->id = "Server"; - server->exe = comm->getProperties()->getProperty("ServerDir") + "/server"; + server->exe = communicator->getProperties()->getProperty("ServerDir") + "/server"; server->pwd = "."; server->allocatable = false; - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); server->activation = "on-demand"; AdapterDescriptor adapter; adapter.name = "TestAdapter"; adapter.id = "TestAdapter.Server"; adapter.serverLifetime = true; adapter.registerProcess = false; - PropertyDescriptor property; - property.name = "TestAdapter.Endpoints"; - property.value = "default"; - server->propertySet.properties.push_back(property); - property.name = "Identity"; - property.value = "test"; - server->propertySet.properties.push_back(property); + server->propertySet.properties.push_back(PropertyDescriptor{ "TestAdapter.Endpoints", "default" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "Identity", "test" }); ObjectDescriptor object; object.id = Ice::stringToIdentity("test"); object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); + adapter.objects.push_back(move(object)); + server->adapters.push_back(move(adapter)); app.nodes["Node1"].servers.push_back(server); masterAdmin->addApplication(app); - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); masterAdmin->stopServer("Server"); // @@ -1236,8 +1226,8 @@ allTests(Test::TestHelper* helper) instantiateServer(admin, "IceGridRegistry", params); admin->startServer("Slave1"); - slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator-Master:default -p 12051")); + slave1Locator = Ice::uncheckedCast<Ice::LocatorPrx>( + communicator->stringToProxy("RepTestIceGrid/Locator-Master:default -p 12051")); slave1Admin = createAdminSession(slave1Locator, ""); waitForReplicaState(slave1Admin, "Slave2", true); @@ -1247,14 +1237,12 @@ allTests(Test::TestHelper* helper) NodeUpdateDescriptor node; node.name = "Node1"; node.servers.push_back(server); - update.nodes.push_back(node); - property.name = "Dummy"; - property.value = "val"; - server->propertySet.properties.push_back(property); + update.nodes.push_back(move(node)); + server->propertySet.properties.push_back(PropertyDescriptor{ "Dummy", "val" }); slave1Admin->updateApplication(update); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); slave1Admin->shutdown(); waitForServerState(admin, "Slave1", false); @@ -1276,20 +1264,20 @@ allTests(Test::TestHelper* helper) masterAdmin = createAdminSession(masterLocator, ""); admin->startServer("Slave1"); - slave1Locator = - Ice::LocatorPrx::uncheckedCast(comm->stringToProxy("RepTestIceGrid/Locator-Slave1:default -p 12051")); + slave1Locator = Ice::uncheckedCast<Ice::LocatorPrx>( + communicator->stringToProxy("RepTestIceGrid/Locator-Slave1:default -p 12051")); slave1Admin = createAdminSession(slave1Locator, "Slave1"); - comm->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(masterLocator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave1Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test")->ice_locator(slave2Locator)->ice_locatorCacheTimeout(0)->ice_ping(); masterAdmin->stopServer("Server"); waitForReplicaState(masterAdmin, "Slave1", true); waitForReplicaState(masterAdmin, "Slave2", true); - ApplicationInfo info = masterAdmin->getApplicationInfo("TestApp"); + auto info = masterAdmin->getApplicationInfo("TestApp"); test(info.revision == 2); masterAdmin->removeApplication("TestApp"); @@ -1317,49 +1305,43 @@ allTests(Test::TestHelper* helper) admin->startServer("Node2"); waitForNodeState(masterAdmin, "Node2", true); - Ice::LocatorPrx slave3Locator = - Ice::LocatorPrx::uncheckedCast( - comm->stringToProxy("RepTestIceGrid/Locator-Slave3 -e 1.0:default -p 12053")); - IceGrid::AdminPrx slave3Admin = createAdminSession(slave3Locator, "Slave3"); + auto slave3Locator = Ice::uncheckedCast<Ice::LocatorPrx>( + communicator->stringToProxy("RepTestIceGrid/Locator-Slave3 -e 1.0:default -p 12053")); + auto slave3Admin = createAdminSession(slave3Locator, "Slave3"); waitForNodeState(slave3Admin, "Node2", true); ApplicationDescriptor app; app.name = "TestApp"; app.description = "added application"; - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); server->id = "Server"; - server->exe = comm->getProperties()->getProperty("ServerDir") + "/server"; + server->exe = communicator->getProperties()->getProperty("ServerDir") + "/server"; server->pwd = "."; server->allocatable = false; - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); server->activation = "on-demand"; AdapterDescriptor adapter; adapter.name = "TestAdapter"; adapter.id = "TestAdapter.Server"; adapter.serverLifetime = true; adapter.registerProcess = false; - PropertyDescriptor property; - property.name = "TestAdapter.Endpoints"; - property.value = "default"; - server->propertySet.properties.push_back(property); - property.name = "Identity"; - property.value = "test"; - server->propertySet.properties.push_back(property); + server->propertySet.properties.push_back(PropertyDescriptor{ "TestAdapter.Endpoints", "default" }); + server->propertySet.properties.push_back(PropertyDescriptor { "Identity", "test" }); ObjectDescriptor object; object.id = Ice::stringToIdentity("test"); object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - app.nodes["Node2"].servers.push_back(server); + adapter.objects.push_back(move(object)); + server->adapters.push_back(move(adapter)); + app.nodes["Node2"].servers.push_back(move(server)); masterAdmin->addApplication(app); - comm->stringToProxy("test -e 1.0")->ice_locator( + communicator->stringToProxy("test -e 1.0")->ice_locator( masterLocator->ice_encodingVersion(Ice::Encoding_1_0))->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test -e 1.0")->ice_locator( + communicator->stringToProxy("test -e 1.0")->ice_locator( slave1Locator->ice_encodingVersion(Ice::Encoding_1_0))->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test -e 1.0")->ice_locator(slave3Locator)->ice_locatorCacheTimeout(0)->ice_ping(); + communicator->stringToProxy("test -e 1.0")->ice_locator(slave3Locator)->ice_locatorCacheTimeout(0)->ice_ping(); masterAdmin->stopServer("Server"); masterAdmin->removeApplication("TestApp"); @@ -1375,19 +1357,19 @@ allTests(Test::TestHelper* helper) app.replicaGroups.resize(1); app.replicaGroups[0].id = "TestReplicaGroup"; - app.replicaGroups[0].loadBalancing = new IceGrid::RandomLoadBalancingPolicy("2"); + app.replicaGroups[0].loadBalancing = make_shared<RandomLoadBalancingPolicy>("2"); ObjectDescriptor object; object.id = Ice::stringToIdentity("test"); object.type = "::Test::TestIntf"; - app.replicaGroups[0].objects.push_back(object); + app.replicaGroups[0].objects.push_back(move(object)); - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); server->id = "Server1"; - server->exe = comm->getProperties()->getProperty("ServerDir") + "/server"; + server->exe = communicator->getProperties()->getProperty("ServerDir") + "/server"; server->pwd = "."; server->allocatable = false; - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); server->activation = "on-demand"; AdapterDescriptor adapter; adapter.name = "TestAdapter"; @@ -1395,20 +1377,15 @@ allTests(Test::TestHelper* helper) adapter.replicaGroupId = "TestReplicaGroup"; adapter.serverLifetime = true; adapter.registerProcess = false; - PropertyDescriptor property; - property.name = "TestAdapter.Endpoints"; - property.value = "default"; - server->propertySet.properties.push_back(property); - property.name = "Identity"; - property.value = "test"; - server->propertySet.properties.push_back(property); - - server->adapters.push_back(adapter); + server->propertySet.properties.push_back(PropertyDescriptor{ "TestAdapter.Endpoints", "default" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "Identity", "test" }); + + server->adapters.push_back(move(adapter)); app.nodes["Node1"].servers.push_back(server); - ServerDescriptorPtr server2 = ServerDescriptorPtr::dynamicCast(server->ice_clone()); + auto server2 = dynamic_pointer_cast<ServerDescriptor>(server->ice_clone()); server2->id = "Server2"; - app.nodes["Node2"].servers.push_back(server2); + app.nodes["Node2"].servers.push_back(move(server2)); try { @@ -1419,16 +1396,16 @@ allTests(Test::TestHelper* helper) cerr << ex.reason << endl; } - comm->stringToProxy("test -e 1.0@TestReplicaGroup")->ice_locator( + communicator->stringToProxy("test -e 1.0@TestReplicaGroup")->ice_locator( masterLocator->ice_encodingVersion(Ice::Encoding_1_0))->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test -e 1.0@TestAdapter.Server1")->ice_locator( + communicator->stringToProxy("test -e 1.0@TestAdapter.Server1")->ice_locator( masterLocator->ice_encodingVersion(Ice::Encoding_1_0))->ice_locatorCacheTimeout(0)->ice_ping(); - comm->stringToProxy("test -e 1.0@TestAdapter.Server2")->ice_locator( + communicator->stringToProxy("test -e 1.0@TestAdapter.Server2")->ice_locator( masterLocator->ice_encodingVersion(Ice::Encoding_1_0))->ice_locatorCacheTimeout(0)->ice_ping(); - QueryPrx query = QueryPrx::uncheckedCast( - comm->stringToProxy("RepTestIceGrid/Query")->ice_locator(masterLocator)); - test(query->findAllReplicas(comm->stringToProxy("test")).size() == 2); + auto query = Ice::uncheckedCast<QueryPrx>( + communicator->stringToProxy("RepTestIceGrid/Query")->ice_locator(masterLocator)); + test(query->findAllReplicas(communicator->stringToProxy("test")).size() == 2); test(masterAdmin->getAdapterInfo("TestReplicaGroup").size() == 2); admin->sendSignal("Node2", "SIGSTOP"); @@ -1444,7 +1421,7 @@ allTests(Test::TestHelper* helper) { } - test(query->findAllReplicas(comm->stringToProxy("test")).size() == 2); + test(query->findAllReplicas(communicator->stringToProxy("test")).size() == 2); try { masterAdmin->ice_invocationTimeout(1000)->getAdapterInfo("TestReplicaGroup"); @@ -1456,7 +1433,7 @@ allTests(Test::TestHelper* helper) admin->sendSignal("Node2", "SIGCONT"); } - test(query->findAllReplicas(comm->stringToProxy("test")).size() == 2); + test(query->findAllReplicas(communicator->stringToProxy("test")).size() == 2); test(masterAdmin->ice_invocationTimeout(1000)->getAdapterInfo("TestReplicaGroup").size() == 2); masterAdmin->removeApplication("TestApp"); diff --git a/cpp/test/IceGrid/replication/Client.cpp b/cpp/test/IceGrid/replication/Client.cpp index b95771b42fb..472adec97a1 100644 --- a/cpp/test/IceGrid/replication/Client.cpp +++ b/cpp/test/IceGrid/replication/Client.cpp @@ -8,22 +8,20 @@ using namespace std; -class Client : public Test::TestHelper +class Client final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Client::run(int argc, char** argv) { - Ice::PropertiesPtr properties = createTestProperties(argc, argv); + auto properties = createTestProperties(argc, argv); properties->setProperty("Ice.Warn.Connections", "0"); - properties->setProperty("Ice.Default.Timeout", "100"); - properties->setProperty("Ice.Trace.Retry", "1"); - Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv, properties); + communicatorHolder->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); void allTests(Test::TestHelper*); allTests(this); } diff --git a/cpp/test/IceGrid/replication/Server.cpp b/cpp/test/IceGrid/replication/Server.cpp index d21343f8f68..a0979fb2694 100644 --- a/cpp/test/IceGrid/replication/Server.cpp +++ b/cpp/test/IceGrid/replication/Server.cpp @@ -8,19 +8,19 @@ using namespace std; -class Server : public Test::TestHelper +class Server final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Server::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); - adapter->add(new TestI(), Ice::stringToIdentity(communicator->getProperties()->getProperty("Identity"))); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv); + auto adapter = communicatorHolder->createObjectAdapter("TestAdapter"); + adapter->add(make_shared<TestI>(), Ice::stringToIdentity(communicatorHolder->getProperties()->getProperty("Identity"))); try { adapter->activate(); @@ -28,7 +28,7 @@ Server::run(int argc, char** argv) catch(const Ice::ObjectAdapterDeactivatedException&) { } - communicator->waitForShutdown(); + communicatorHolder->waitForShutdown(); } DEFINE_TEST(Server) diff --git a/cpp/test/IceGrid/replication/TestI.h b/cpp/test/IceGrid/replication/TestI.h index ec90fc41e3e..e92772c0574 100644 --- a/cpp/test/IceGrid/replication/TestI.h +++ b/cpp/test/IceGrid/replication/TestI.h @@ -7,7 +7,7 @@ #include <Test.h> -class TestI : public ::Test::TestIntf +class TestI final : public ::Test::TestIntf { public: diff --git a/cpp/test/IceGrid/session/AllTests.cpp b/cpp/test/IceGrid/session/AllTests.cpp index 53de990eaa9..e2eeacaffc6 100644 --- a/cpp/test/IceGrid/session/AllTests.cpp +++ b/cpp/test/IceGrid/session/AllTests.cpp @@ -2,7 +2,6 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/Thread.h> #include <Ice/Ice.h> #include <IceGrid/IceGrid.h> #include <Glacier2/Router.h> @@ -11,17 +10,9 @@ using namespace std; using namespace IceGrid; +using namespace Test; -void -addProperty(const CommunicatorDescriptorPtr& communicator, const string& name, const string& value) -{ - PropertyDescriptor prop; - prop.name = name; - prop.value = value; - communicator->propertySet.properties.push_back(prop); -} - -class ObserverBase : public IceUtil::Monitor<IceUtil::Mutex> +class ObserverBase { public: @@ -38,42 +29,32 @@ public: static void printStack() { - map<string, ObserverBase*>::const_iterator p; - for(p = _observers.begin(); p != _observers.end(); ++p) + for(const auto& p : _observers) { - vector<string>::const_iterator q = p->second->_stack.begin(); - if(p->second->_stack.size() > 10) + vector<string>::const_iterator q = p.second->_stack.begin(); + if (p.second->_stack.size() > 10) { - q = p->second->_stack.begin() + - static_cast<vector<string>::difference_type>(p->second->_stack.size() - 10); + q = p.second->_stack.begin() + + static_cast<vector<string>::difference_type>(p.second->_stack.size() - 10); } - cerr << "Last 10 updates of observer `" << p->second->_name << "':" << endl; - for(; q != p->second->_stack.end(); ++q) + cerr << "Last 10 updates of observer `" << p.second->_name << "':" << endl; + for (; q != p.second->_stack.end(); ++q) { cerr << " " << *q << endl; } - p->second->_stack.clear(); + p.second->_stack.clear(); } } void - trace(const string& msg) + waitForUpdate(int line) { - _stack.push_back(msg); - } - - void - waitForUpdate(const char*, int line) - { - Lock sync(*this); - - ostringstream os; - os << "wait for update from line " << line; - trace(os.str()); + unique_lock<mutex> lg(_mutex); + _stack.push_back("wait for update from line " + to_string(line)); while(!_updated) { - wait(); + _condVar.wait(lg); } --_updated; } @@ -83,19 +64,25 @@ protected: void updated(const string& update) { - trace(update); + _stack.push_back(update); ++_updated; - notifyAll(); + _condVar.notify_all(); } string _name; vector<string> _stack; int _updated; + mutex _mutex; + static map<string, ObserverBase*> _observers; + +private: + + condition_variable _condVar; }; map<string, ObserverBase*> ObserverBase::_observers; -class ApplicationObserverI : public ApplicationObserver, public ObserverBase +class ApplicationObserverI final : public ApplicationObserver, public ObserverBase { public: @@ -103,48 +90,48 @@ public: { } - virtual void - applicationInit(int serialP, const ApplicationInfoSeq& apps, const Ice::Current&) + void + applicationInit(int serialP, ApplicationInfoSeq apps, const Ice::Current&) override { - Lock sync(*this); - for(ApplicationInfoSeq::const_iterator p = apps.begin(); p != apps.end(); ++p) + lock_guard<mutex> lg(_mutex); + for(const auto& p : apps) { - if(p->descriptor.name != "Test") // Ignore the test application from application.xml! + if(p.descriptor.name != "Test") // Ignore the test application from application.xml! { - this->applications.insert(make_pair(p->descriptor.name, *p)); + applications.insert(make_pair(p.descriptor.name, p)); } } updated(updateSerial(serialP, "init update")); } - virtual void - applicationAdded(int serialP, const ApplicationInfo& app, const Ice::Current&) + void + applicationAdded(int serialP, ApplicationInfo app, const Ice::Current&) override { - Lock sync(*this); - this->applications.insert(make_pair(app.descriptor.name, app)); + lock_guard<mutex> lg(_mutex); + applications.insert(make_pair(app.descriptor.name, app)); updated(updateSerial(serialP, "application added `" + app.descriptor.name + "'")); } - virtual void - applicationRemoved(int serialP, const std::string& name, const Ice::Current&) + void + applicationRemoved(int serialP, std::string name, const Ice::Current&) override { - Lock sync(*this); - this->applications.erase(name); + lock_guard<mutex> lg(_mutex); + applications.erase(name); updated(updateSerial(serialP, "application removed `" + name + "'")); } - virtual void - applicationUpdated(int serialP, const ApplicationUpdateInfo& info, const Ice::Current&) + void + applicationUpdated(int serialP, ApplicationUpdateInfo info, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); const ApplicationUpdateDescriptor& desc = info.descriptor; - for(Ice::StringSeq::const_iterator q = desc.removeVariables.begin(); q != desc.removeVariables.end(); ++q) + for(const auto& p : desc.removeVariables) { - this->applications[desc.name].descriptor.variables.erase(*q); + applications[desc.name].descriptor.variables.erase(p); } - for(map<string, string>::const_iterator p = desc.variables.begin(); p != desc.variables.end(); ++p) + for(const auto& p : desc.variables) { - this->applications[desc.name].descriptor.variables[p->first] = p->second; + applications[desc.name].descriptor.variables[p.first] = p.second; } updated(updateSerial(serialP, "application updated `" + desc.name + "'")); } @@ -163,9 +150,8 @@ private: return os.str(); } }; -typedef IceUtil::Handle<ApplicationObserverI> ApplicationObserverIPtr; -class AdapterObserverI : public AdapterObserver, public ObserverBase +class AdapterObserverI final : public AdapterObserver, public ObserverBase { public: @@ -173,37 +159,37 @@ public: { } - virtual void - adapterInit(const AdapterInfoSeq& adaptersP, const Ice::Current&) + void + adapterInit(AdapterInfoSeq adaptersP, const Ice::Current&) override { - Lock sync(*this); - for(AdapterInfoSeq::const_iterator q = adaptersP.begin(); q != adaptersP.end(); ++q) + lock_guard<mutex> lg(_mutex); + for(const auto& p : adaptersP) { - adapters.insert(make_pair(q->id, *q)); + adapters.insert(make_pair(p.id, p)); } updated(updateSerial(0, "init update")); } void - adapterAdded(const AdapterInfo& info, const Ice::Current&) + adapterAdded(AdapterInfo info, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); adapters.insert(make_pair(info.id, info)); updated(updateSerial(0, "adapter added `" + info.id + "'")); } void - adapterUpdated(const AdapterInfo& info, const Ice::Current&) + adapterUpdated(AdapterInfo info, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); adapters[info.id] = info; updated(updateSerial(0, "adapter updated `" + info.id + "'")); } void - adapterRemoved(const string& id, const Ice::Current&) + adapterRemoved(string id, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); adapters.erase(id); updated(updateSerial(0, "adapter removed `" + id + "'")); } @@ -222,9 +208,8 @@ private: return os.str(); } }; -typedef IceUtil::Handle<AdapterObserverI> AdapterObserverIPtr; -class ObjectObserverI : public ObjectObserver, public ObserverBase +class ObjectObserverI final : public ObjectObserver, public ObserverBase { public: @@ -232,37 +217,37 @@ public: { } - virtual void - objectInit(const ObjectInfoSeq& objectsP, const Ice::Current&) + void + objectInit(ObjectInfoSeq objectsP, const Ice::Current&) override { - Lock sync(*this); - for(ObjectInfoSeq::const_iterator r = objectsP.begin(); r != objectsP.end(); ++r) + lock_guard<mutex> lg(_mutex); + for(const auto& p : objectsP) { - objects.insert(make_pair(r->proxy->ice_getIdentity(), *r)); + objects.insert(make_pair(p.proxy->ice_getIdentity(), p)); } updated(updateSerial(0, "init update")); } void - objectAdded(const ObjectInfo& info, const Ice::Current&) + objectAdded(ObjectInfo info, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); objects.insert(make_pair(info.proxy->ice_getIdentity(), info)); updated(updateSerial(0, "object added `" + info.proxy->ice_toString() + "'")); } void - objectUpdated(const ObjectInfo& info, const Ice::Current&) + objectUpdated(ObjectInfo info, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); objects[info.proxy->ice_getIdentity()] = info; updated(updateSerial(0, "object updated `" + info.proxy->ice_toString() + "'")); } void - objectRemoved(const Ice::Identity& id, const Ice::Current& current) + objectRemoved(Ice::Identity id, const Ice::Current& current) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); objects.erase(id); updated(updateSerial(0, "object removed `" + current.adapter->getCommunicator()->identityToString(id) + "'")); @@ -282,9 +267,8 @@ private: return os.str(); } }; -typedef IceUtil::Handle<ObjectObserverI> ObjectObserverIPtr; -class NodeObserverI : public NodeObserver, public ObserverBase +class NodeObserverI final : public NodeObserver, public ObserverBase { public: @@ -292,50 +276,50 @@ public: { } - virtual void - nodeInit(const NodeDynamicInfoSeq& info, const Ice::Current&) + void + nodeInit(NodeDynamicInfoSeq info, const Ice::Current&) override { - Lock sync(*this); - for(NodeDynamicInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) + lock_guard<mutex> lg(_mutex); + for(const auto& p : info) { - this->nodes[p->info.name] = filter(*p); + nodes[p.info.name] = filter(p); } updated("init"); } - virtual void - nodeUp(const NodeDynamicInfo& info, const Ice::Current&) + void + nodeUp(NodeDynamicInfo info, const Ice::Current&) override { - Lock sync(*this); - this->nodes[info.info.name] = filter(info); + lock_guard<mutex> lg(_mutex); + nodes[info.info.name] = filter(info); updated("node `" + info.info.name + "' up"); } - virtual void - nodeDown(const string& name, const Ice::Current&) + void + nodeDown(string name, const Ice::Current&) override { - Lock sync(*this); - this->nodes.erase(name); + lock_guard<mutex> lg(_mutex); + nodes.erase(name); updated("node `" + name + "' down"); } - virtual void - updateServer(const string& node, const ServerDynamicInfo& info, const Ice::Current&) + void + updateServer(string node, ServerDynamicInfo info, const Ice::Current&) override { if(info.id == "Glacier2" || info.id == "Glacier2Admin" || info.id == "PermissionsVerifierServer") { return; } - Lock sync(*this); + lock_guard<mutex> lg(_mutex); //cerr << node << " " << info.id << " " << info.state << " " << info.pid << endl; - ServerDynamicInfoSeq& servers = this->nodes[node].servers; + ServerDynamicInfoSeq& servers = nodes[node].servers; ServerDynamicInfoSeq::iterator p; for(p = servers.begin(); p != servers.end(); ++p) { if(p->id == info.id) { - if(info.state == Destroyed) + if(info.state == ServerState::Destroyed) { servers.erase(p); } @@ -346,28 +330,28 @@ public: break; } } - if(info.state != Destroyed && p == servers.end()) + if(info.state != ServerState::Destroyed && p == servers.end()) { servers.push_back(info); } ostringstream os; - os << "server `" << info.id << "' on node `" << node << "' state updated: " << info.state + os << "server `" << info.id << "' on node `" << node << "' state updated: " << static_cast<int>(info.state) << " (pid = " << info.pid << ")"; updated(os.str()); } - virtual void - updateAdapter(const string& node, const AdapterDynamicInfo& info, const Ice::Current&) + void + updateAdapter(string node, AdapterDynamicInfo info, const Ice::Current&) override { if(info.id == "PermissionsVerifierServer.Server") { return; } - Lock sync(*this); + lock_guard<mutex> lg(_mutex); //cerr << "update adapter: " << info.id << " " << (info.proxy ? "active" : "inactive") << endl; - AdapterDynamicInfoSeq& adapters = this->nodes[node].adapters; + AdapterDynamicInfoSeq& adapters = nodes[node].adapters; AdapterDynamicInfoSeq::iterator p; for(p = adapters.begin(); p != adapters.end(); ++p) { @@ -406,22 +390,22 @@ public: NodeDynamicInfo filtered; filtered.info = info.info; - for(ServerDynamicInfoSeq::const_iterator p = info.servers.begin(); p != info.servers.end(); ++p) + for(const auto& p : info.servers) { - if(p->id == "Glacier2" || p->id == "Glacier2Admin" || p->id == "PermissionsVerifierServer") + if(p.id == "Glacier2" || p.id == "Glacier2Admin" || p.id == "PermissionsVerifierServer") { continue; } - filtered.servers.push_back(*p); + filtered.servers.push_back(p); } - for(AdapterDynamicInfoSeq::const_iterator a = info.adapters.begin(); a != info.adapters.end(); ++a) + for(const auto& a : info.adapters) { - if(a->id == "PermissionsVerifierServer.Server") + if(a.id == "PermissionsVerifierServer.Server") { continue; } - filtered.adapters.push_back(*a); + filtered.adapters.push_back(a); } return filtered; @@ -429,9 +413,8 @@ public: map<string, NodeDynamicInfo> nodes; }; -typedef IceUtil::Handle<NodeObserverI> NodeObserverIPtr; -class RegistryObserverI : public RegistryObserver, public ObserverBase +class RegistryObserverI final : public RegistryObserver, public ObserverBase { public: @@ -439,36 +422,35 @@ public: { } - virtual void - registryInit(const RegistryInfoSeq& info, const Ice::Current&) + void + registryInit(RegistryInfoSeq info, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); for(RegistryInfoSeq::const_iterator p = info.begin(); p != info.end(); ++p) { - this->registries[p->name] = *p; + registries[p->name] = *p; } updated("init"); } - virtual void - registryUp(const RegistryInfo& info, const Ice::Current&) + void + registryUp(RegistryInfo info, const Ice::Current&) override { - Lock sync(*this); - this->registries[info.name] = info; + lock_guard<mutex> lg(_mutex); + registries[info.name] = info; updated("registry `" + info.name + "' up"); } - virtual void - registryDown(const string& name, const Ice::Current&) - { - Lock sync(*this); - this->registries.erase(name); - updated("registry `" + name + "' down"); - } + void + registryDown(string name, const Ice::Current&) override + { + lock_guard<mutex> lg(_mutex); + registries.erase(name); + updated("registry `" + name + "' down"); + } map<string, RegistryInfo> registries; }; -typedef IceUtil::Handle<RegistryObserverI> RegistryObserverIPtr; void testFailedAndPrintObservers(const char* expr, const char* file, unsigned int line) @@ -480,25 +462,19 @@ testFailedAndPrintObservers(const char* expr, const char* file, unsigned int lin #undef test #define test(ex) ((ex) ? ((void)0) : testFailedAndPrintObservers(#ex, __FILE__, __LINE__)) -#if defined(_AIX) && defined(__GNUC__) && !defined(__ibmxl__) -// Strange optimization bug with catching ExtendedPermissionDeniedException with GCC 8.1 on AIX -__attribute__((optimize("O0"))) -#endif void -allTests(Test::TestHelper* helper) +allTests(TestHelper* helper) { - Ice::CommunicatorPtr communicator = helper->communicator(); + auto communicator = helper->communicator(); bool encoding10 = communicator->getProperties()->getProperty("Ice.Default.EncodingVersion") == "1.0"; - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); + auto registry = Ice::checkedCast<RegistryPrx>(communicator->stringToProxy( + communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); - AdminSessionPrx session = registry->createAdminSession("admin3", "test3"); - session->ice_getConnection()->setACM(registry->getACMTimeout(), - IceUtil::None, - Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + auto session = registry->createAdminSession("admin3", "test3"); + session->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatAlways); - AdminPrx admin = session->getAdmin(); + auto admin = session->getAdmin(); test(admin); cout << "starting router... " << flush; @@ -525,21 +501,21 @@ allTests(Test::TestHelper* helper) } cout << "ok" << endl; - Ice::PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); - IceGrid::RegistryPrx registry1 = IceGrid::RegistryPrx::uncheckedCast(registry->ice_connectionId("reg1")); - IceGrid::RegistryPrx registry2 = IceGrid::RegistryPrx::uncheckedCast(registry->ice_connectionId("reg2")); + auto registry1 = Ice::uncheckedCast<RegistryPrx>(registry->ice_connectionId("reg1")); + auto registry2 = Ice::uncheckedCast<RegistryPrx>(registry->ice_connectionId("reg2")); - Glacier2::RouterPrx router = Glacier2::RouterPrx::uncheckedCast( + auto router = Ice::uncheckedCast<Glacier2::RouterPrx>( communicator->stringToProxy("Glacier2/router:default -p 12347 -h 127.0.0.1")); - Glacier2::RouterPrx adminRouter = Glacier2::RouterPrx::uncheckedCast( + auto adminRouter = Ice::uncheckedCast<Glacier2::RouterPrx>( communicator->stringToProxy("Glacier2/router:default -p 12348 -h 127.0.0.1")); - Glacier2::RouterPrx router1 = Glacier2::RouterPrx::uncheckedCast(router->ice_connectionId("router1")); - Glacier2::RouterPrx router2 = Glacier2::RouterPrx::uncheckedCast(router->ice_connectionId("router2")); + auto router1 = Ice::uncheckedCast<Glacier2::RouterPrx>(router->ice_connectionId("router1")); + auto router2 = Ice::uncheckedCast<Glacier2::RouterPrx>(router->ice_connectionId("router2")); - Glacier2::RouterPrx adminRouter1 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter1")); - Glacier2::RouterPrx adminRouter2 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter2")); + auto adminRouter1 = Ice::uncheckedCast<Glacier2::RouterPrx>(adminRouter->ice_connectionId("admRouter1")); + auto adminRouter2 = Ice::uncheckedCast<Glacier2::RouterPrx>(adminRouter->ice_connectionId("admRouter2")); // // TODO: Find a better way to wait for the Glacier2 router to be @@ -555,23 +531,23 @@ allTests(Test::TestHelper* helper) } catch(const Ice::LocalException&) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); + this_thread::sleep_for(100ms); } } { cout << "testing username/password sessions... " << flush; - SessionPrx session1, session2; + shared_ptr<SessionPrx> session1, session2; - session1 = SessionPrx::uncheckedCast(registry1->createSession("client1", "test1")->ice_connectionId("reg1")); - session2 = SessionPrx::uncheckedCast(registry2->createSession("client2", "test2")->ice_connectionId("reg2")); + session1 = Ice::uncheckedCast<SessionPrx>(registry1->createSession("client1", "test1")->ice_connectionId("reg1")); + session2 = Ice::uncheckedCast<SessionPrx>(registry2->createSession("client2", "test2")->ice_connectionId("reg2")); try { registry1->createSession("client3", "test1"); test(false); } - catch(const IceGrid::PermissionDeniedException&) + catch(const PermissionDeniedException&) { } try @@ -581,7 +557,7 @@ allTests(Test::TestHelper* helper) registry1->createSession("client3", "test1", ctx); test(false); } - catch(const IceGrid::PermissionDeniedException& ex) + catch(const PermissionDeniedException& ex) { test(ex.reason == "reason"); } @@ -626,18 +602,18 @@ allTests(Test::TestHelper* helper) session1->destroy(); session2->destroy(); - AdminSessionPrx adminSession1, adminSession2; + shared_ptr<AdminSessionPrx> adminSession1, adminSession2; - adminSession1 = AdminSessionPrx::uncheckedCast( + adminSession1 = Ice::uncheckedCast<AdminSessionPrx>( registry1->createAdminSession("admin1", "test1")->ice_connectionId("reg1")); - adminSession2 = AdminSessionPrx::uncheckedCast( + adminSession2 = Ice::uncheckedCast<AdminSessionPrx>( registry2->createAdminSession("admin2", "test2")->ice_connectionId("reg2")); try { registry1->createAdminSession("admin3", "test1"); test(false); } - catch(const IceGrid::PermissionDeniedException&) + catch(const PermissionDeniedException&) { } try @@ -647,7 +623,7 @@ allTests(Test::TestHelper* helper) registry1->createSession("admin3", "test1", ctx); test(false); } - catch(const IceGrid::PermissionDeniedException& ex) + catch(const PermissionDeniedException& ex) { test(ex.reason == "reason"); } @@ -702,10 +678,10 @@ allTests(Test::TestHelper* helper) { cout << "testing sessions from secure connection... " << flush; - SessionPrx session1, session2; + shared_ptr<SessionPrx> session1, session2; - session1 = SessionPrx::uncheckedCast(registry1->createSessionFromSecureConnection()->ice_connectionId("reg1")); - session2 = SessionPrx::uncheckedCast(registry2->createSessionFromSecureConnection()->ice_connectionId("reg2")); + session1 = Ice::uncheckedCast<SessionPrx>(registry1->createSessionFromSecureConnection()->ice_connectionId("reg1")); + session2 = Ice::uncheckedCast<SessionPrx>(registry2->createSessionFromSecureConnection()->ice_connectionId("reg2")); session1->ice_ping(); session2->ice_ping(); @@ -717,7 +693,7 @@ allTests(Test::TestHelper* helper) registry1->createSessionFromSecureConnection(ctx); test(false); } - catch(const IceGrid::PermissionDeniedException& ex) + catch(const PermissionDeniedException& ex) { test(ex.reason == "reason"); } @@ -742,11 +718,11 @@ allTests(Test::TestHelper* helper) session1->destroy(); session2->destroy(); - AdminSessionPrx adminSession1, adminSession2; + shared_ptr<AdminSessionPrx> adminSession1, adminSession2; - adminSession1 = AdminSessionPrx::uncheckedCast( + adminSession1 = Ice::uncheckedCast<AdminSessionPrx>( registry1->createAdminSessionFromSecureConnection()->ice_connectionId("reg1")); - adminSession2 = AdminSessionPrx::uncheckedCast( + adminSession2 = Ice::uncheckedCast<AdminSessionPrx>( registry2->createAdminSessionFromSecureConnection()->ice_connectionId("reg2")); adminSession1->ice_ping(); @@ -759,7 +735,7 @@ allTests(Test::TestHelper* helper) registry1->createAdminSessionFromSecureConnection(ctx); test(false); } - catch(const IceGrid::PermissionDeniedException& ex) + catch(const PermissionDeniedException& ex) { test(ex.reason == "reason"); } @@ -794,7 +770,7 @@ allTests(Test::TestHelper* helper) registry1->createSessionFromSecureConnection(); test(false); } - catch(const IceGrid::PermissionDeniedException&) + catch(const PermissionDeniedException&) { } try @@ -802,7 +778,7 @@ allTests(Test::TestHelper* helper) registry1->createAdminSessionFromSecureConnection(); test(false); } - catch(const IceGrid::PermissionDeniedException&) + catch(const PermissionDeniedException&) { } cout << "ok" << endl; @@ -811,17 +787,17 @@ allTests(Test::TestHelper* helper) { cout << "testing Glacier2 username/password sessions... " << flush; - SessionPrx session1, session2; + shared_ptr<SessionPrx> session1, session2; - Glacier2::SessionPrx base; + shared_ptr<Glacier2::SessionPrx> base; base = router1->createSession("client1", "test1"); test(base); - session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router1")->ice_router(router1)); + session1 = Ice::uncheckedCast<SessionPrx>(base->ice_connectionId("router1")->ice_router(router1)); base = router2->createSession("client2", "test2"); test(base); - session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router2")->ice_router(router2)); + session2 = Ice::uncheckedCast<SessionPrx>(base->ice_connectionId("router2")->ice_router(router2)); try { @@ -838,7 +814,7 @@ allTests(Test::TestHelper* helper) router->ice_connectionId("routerex")->createSession("client3", "test1", ctx); test(false); } - catch(const Test::ExtendedPermissionDeniedException& ex) + catch(const ExtendedPermissionDeniedException& ex) { test(!encoding10 && ex.reason == "reason"); } @@ -867,7 +843,7 @@ allTests(Test::TestHelper* helper) { } - Ice::ObjectPrx obj = communicator->stringToProxy("TestIceGrid/Query"); + auto obj = communicator->stringToProxy("TestIceGrid/Query"); obj->ice_connectionId("router1")->ice_router(router1)->ice_ping(); obj->ice_connectionId("router2")->ice_router(router2)->ice_ping(); @@ -892,13 +868,13 @@ allTests(Test::TestHelper* helper) router1->destroySession(); router2->destroySession(); - AdminSessionPrx admSession1, admSession2; + shared_ptr<AdminSessionPrx> admSession1, admSession2; base = adminRouter1->createSession("admin1", "test1"); - admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter1")->ice_router(adminRouter1)); + admSession1 = Ice::uncheckedCast<AdminSessionPrx>(base->ice_connectionId("admRouter1")->ice_router(adminRouter1)); base = adminRouter2->createSession("admin2", "test2"); - admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter2")->ice_router(adminRouter2)); + admSession2 = Ice::uncheckedCast<AdminSessionPrx>(base->ice_connectionId("admRouter2")->ice_router(adminRouter2)); try { @@ -915,7 +891,7 @@ allTests(Test::TestHelper* helper) adminRouter->ice_connectionId("routerex")->createSession("admin3", "test1", ctx); test(false); } - catch(const Test::ExtendedPermissionDeniedException& ex) + catch(const ExtendedPermissionDeniedException& ex) { test(!encoding10 && ex.reason == "reason"); } @@ -927,8 +903,8 @@ allTests(Test::TestHelper* helper) admSession1->ice_ping(); admSession2->ice_ping(); - Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter1"); - Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter2"); + auto admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter1"); + auto admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter2"); admin1->ice_ping(); admin2->ice_ping(); @@ -981,21 +957,21 @@ allTests(Test::TestHelper* helper) { cout << "testing Glacier2 sessions from secure connection... " << flush; - SessionPrx session1, session2; + shared_ptr<SessionPrx> session1, session2; - Glacier2::SessionPrx base; + shared_ptr<Glacier2::SessionPrx> base; // // BUGFIX: We can't re-use the same router proxies because of bug 1034. // - router1 = Glacier2::RouterPrx::uncheckedCast(router1->ice_connectionId("router11")); - router2 = Glacier2::RouterPrx::uncheckedCast(router2->ice_connectionId("router21")); + router1 = Ice::uncheckedCast<Glacier2::RouterPrx>(router1->ice_connectionId("router11")); + router2 = Ice::uncheckedCast<Glacier2::RouterPrx>(router2->ice_connectionId("router21")); base = router1->createSessionFromSecureConnection(); - session1 = SessionPrx::uncheckedCast(base->ice_connectionId("router11")->ice_router(router1)); + session1 = Ice::uncheckedCast<SessionPrx>(base->ice_connectionId("router11")->ice_router(router1)); base = router2->createSessionFromSecureConnection(); - session2 = SessionPrx::uncheckedCast(base->ice_connectionId("router21")->ice_router(router2)); + session2 = Ice::uncheckedCast<SessionPrx>(base->ice_connectionId("router21")->ice_router(router2)); session1->ice_ping(); session2->ice_ping(); @@ -1007,7 +983,7 @@ allTests(Test::TestHelper* helper) router->ice_connectionId("routerex")->createSessionFromSecureConnection(ctx); test(false); } - catch(const Test::ExtendedPermissionDeniedException& ex) + catch(const ExtendedPermissionDeniedException& ex) { test(!encoding10 && ex.reason == "reason"); } @@ -1033,7 +1009,7 @@ allTests(Test::TestHelper* helper) { } - Ice::ObjectPrx obj = communicator->stringToProxy("TestIceGrid/Query"); + shared_ptr<Ice::ObjectPrx> obj = communicator->stringToProxy("TestIceGrid/Query"); obj->ice_connectionId("router11")->ice_router(router1)->ice_ping(); obj->ice_connectionId("router21")->ice_router(router2)->ice_ping(); @@ -1058,19 +1034,19 @@ allTests(Test::TestHelper* helper) router1->destroySession(); router2->destroySession(); - AdminSessionPrx admSession1, admSession2; + shared_ptr<AdminSessionPrx> admSession1, admSession2; // // BUGFIX: We can't re-use the same router proxies because of bug 1034. // - adminRouter1 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter11")); - adminRouter2 = Glacier2::RouterPrx::uncheckedCast(adminRouter->ice_connectionId("admRouter21")); + adminRouter1 = Ice::uncheckedCast<Glacier2::RouterPrx>(adminRouter->ice_connectionId("admRouter11")); + adminRouter2 = Ice::uncheckedCast<Glacier2::RouterPrx>(adminRouter->ice_connectionId("admRouter21")); base = adminRouter1->createSessionFromSecureConnection(); - admSession1 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter11")->ice_router(adminRouter1)); + admSession1 = Ice::uncheckedCast<AdminSessionPrx>(base->ice_connectionId("admRouter11")->ice_router(adminRouter1)); base = adminRouter2->createSessionFromSecureConnection(); - admSession2 = AdminSessionPrx::uncheckedCast(base->ice_connectionId("admRouter21")->ice_router(adminRouter2)); + admSession2 = Ice::uncheckedCast<AdminSessionPrx>(base->ice_connectionId("admRouter21")->ice_router(adminRouter2)); admSession1->ice_ping(); admSession2->ice_ping(); @@ -1082,7 +1058,7 @@ allTests(Test::TestHelper* helper) adminRouter->ice_connectionId("routerex")->createSessionFromSecureConnection(ctx); test(false); } - catch(const Test::ExtendedPermissionDeniedException& ex) + catch(const ExtendedPermissionDeniedException& ex) { test(!encoding10 && ex.reason == "reason"); } @@ -1091,8 +1067,8 @@ allTests(Test::TestHelper* helper) test(encoding10 && ex.reason == "reason"); } - Ice::ObjectPrx admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter11"); - Ice::ObjectPrx admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter21"); + auto admin1 = admSession1->getAdmin()->ice_router(adminRouter1)->ice_connectionId("admRouter11"); + auto admin2 = admSession2->getAdmin()->ice_router(adminRouter2)->ice_connectionId("admRouter21"); admin1->ice_ping(); admin2->ice_ping(); @@ -1164,20 +1140,20 @@ allTests(Test::TestHelper* helper) { cout << "testing updates with admin sessions... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - AdminSessionPrx session2 = registry->createAdminSession("admin2", "test2"); + auto session1 = registry->createAdminSession("admin1", "test1"); + auto session2 = registry->createAdminSession("admin2", "test2"); - session1->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); - session2->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); + session1->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); + session2->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); - AdminPrx admin1 = session1->getAdmin(); - AdminPrx admin2 = session2->getAdmin(); + auto admin1 = session1->getAdmin(); + auto admin2 = session2->getAdmin(); - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.1"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); + auto adpt1 = communicator->createObjectAdapter(""); + auto appObs1 = make_shared<ApplicationObserverI>("appObs1.1"); + auto app1 = adpt1->addWithUUID(appObs1); + auto nodeObs1 = make_shared<NodeObserverI>("nodeObs1"); + auto no1 = adpt1->addWithUUID(nodeObs1); adpt1->activate(); registry->ice_getConnection()->setAdapter(adpt1); session1->setObserversByIdentity(Ice::Identity(), @@ -1186,20 +1162,20 @@ allTests(Test::TestHelper* helper) Ice::Identity(), Ice::Identity()); - Ice::ObjectAdapterPtr adpt2 = communicator->createObjectAdapterWithEndpoints("Observer2", "tcp"); - ApplicationObserverIPtr appObs2 = new ApplicationObserverI("appObs2"); - Ice::ObjectPrx app2 = adpt2->addWithUUID(appObs2); - NodeObserverIPtr nodeObs2 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no2 = adpt2->addWithUUID(nodeObs2); + auto adpt2 = communicator->createObjectAdapterWithEndpoints("Observer2", "default"); + auto appObs2 = make_shared<ApplicationObserverI>("appObs2"); + auto app2 = adpt2->addWithUUID(appObs2); + auto nodeObs2 = make_shared<NodeObserverI>("nodeObs1"); + auto no2 = adpt2->addWithUUID(nodeObs2); adpt2->activate(); session2->setObservers(0, - NodeObserverPrx::uncheckedCast(no2), - ApplicationObserverPrx::uncheckedCast(app2), + Ice::uncheckedCast<NodeObserverPrx>(no2), + Ice::uncheckedCast<ApplicationObserverPrx>(app2), 0, 0); - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); + appObs2->waitForUpdate(__LINE__); int serial = appObs1->serial; test(serial == appObs2->serial); @@ -1266,7 +1242,7 @@ allTests(Test::TestHelper* helper) { ApplicationDescriptor app; app.name = "Application"; - admin2->addApplication(app); + admin2->addApplication(move(app)); } catch(const Ice::UserException&) { @@ -1291,8 +1267,8 @@ allTests(Test::TestHelper* helper) test(false); } - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); + appObs2->waitForUpdate(__LINE__); test(serial + 1 == appObs1->serial); test(serial + 1 == appObs2->serial); @@ -1305,7 +1281,7 @@ allTests(Test::TestHelper* helper) ApplicationUpdateDescriptor update; update.name = "Application"; update.variables.insert(make_pair(string("test"), string("test"))); - admin1->updateApplication(update); + admin1->updateApplication(move(update)); session1->finishUpdate(); } catch(const Ice::UserException& ex) @@ -1314,28 +1290,13 @@ allTests(Test::TestHelper* helper) test(false); } - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); + appObs2->waitForUpdate(__LINE__); test(serial + 1 == appObs1->serial); test(serial + 1 == appObs2->serial); ++serial; - // - // We now allow modifying the database without holding the - // exclusive lock. - // -// try -// { -// ApplicationUpdateDescriptor update; -// update.name = "Application"; -// admin1->updateApplication(update); -// test(false); -// } -// catch(const AccessDeniedException&) -// { -// } - try { int s = session2->startUpdate(); @@ -1348,8 +1309,8 @@ allTests(Test::TestHelper* helper) test(false); } - appObs1->waitForUpdate(__FILE__, __LINE__); - appObs2->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); + appObs2->waitForUpdate(__LINE__); test(serial + 1 == appObs1->serial); test(serial + 1 == appObs2->serial); @@ -1381,32 +1342,28 @@ allTests(Test::TestHelper* helper) adpt1->destroy(); adpt2->destroy(); - // - // TODO: test session reaping? - // - cout << "ok" << endl; } { cout << "testing invalid configuration... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - AdminPrx admin1 = session1->getAdmin(); + auto session1 = registry->createAdminSession("admin1", "test1"); + auto admin1 = session1->getAdmin(); - Ice::LocatorRegistryPrx locatorRegistry = communicator->getDefaultLocator()->getRegistry(); + auto locatorRegistry = communicator->getDefaultLocator()->getRegistry(); try { ApplicationDescriptor app; app.name = string(512, 'A'); - admin1->addApplication(app); + admin1->addApplication(move(app)); test(false); } catch(const DeploymentException&) { } - Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); + auto obj = communicator->stringToProxy("dummy:tcp -p 10000"); try { locatorRegistry->setAdapterDirectProxy(string(512, 'A'), obj); @@ -1439,14 +1396,14 @@ allTests(Test::TestHelper* helper) { cout << "testing application observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - AdminPrx admin1 = session1->getAdmin(); + auto session1 = registry->createAdminSession("admin1", "test1"); + auto admin1 = session1->getAdmin(); - session1->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); + session1->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.2"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); + auto adpt1 = communicator->createObjectAdapter(""); + auto appObs1 = make_shared<ApplicationObserverI>("appObs1.2"); + auto app1 = adpt1->addWithUUID(appObs1); adpt1->activate(); registry->ice_getConnection()->setAdapter(adpt1); session1->setObserversByIdentity(Ice::Identity(), @@ -1455,7 +1412,7 @@ allTests(Test::TestHelper* helper) Ice::Identity(), Ice::Identity()); - appObs1->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); int serial = appObs1->serial; test(appObs1->applications.empty()); @@ -1466,8 +1423,8 @@ allTests(Test::TestHelper* helper) app.name = "Application"; int s = session1->startUpdate(); test(s == serial); - admin1->addApplication(app); - appObs1->waitForUpdate(__FILE__, __LINE__); + admin1->addApplication(move(app)); + appObs1->waitForUpdate(__LINE__); test(appObs1->applications.find("Application") != appObs1->applications.end()); test(++serial == appObs1->serial); } @@ -1482,8 +1439,8 @@ allTests(Test::TestHelper* helper) ApplicationUpdateDescriptor update; update.name = "Application"; update.variables.insert(make_pair(string("test"), string("test"))); - admin1->updateApplication(update); - appObs1->waitForUpdate(__FILE__, __LINE__); + admin1->updateApplication(move(update)); + appObs1->waitForUpdate(__LINE__); test(appObs1->applications.find("Application") != appObs1->applications.end()); test(appObs1->applications["Application"].descriptor.variables["test"] == "test"); test(++serial == appObs1->serial); @@ -1500,8 +1457,8 @@ allTests(Test::TestHelper* helper) app = appObs1->applications["Application"].descriptor; app.variables.clear(); app.variables["test1"] = "test"; - admin1->syncApplication(app); - appObs1->waitForUpdate(__FILE__, __LINE__); + admin1->syncApplication(move(app)); + appObs1->waitForUpdate(__LINE__); test(appObs1->applications.find("Application") != appObs1->applications.end()); test(appObs1->applications["Application"].descriptor.variables.size() == 1); test(appObs1->applications["Application"].descriptor.variables["test1"] == "test"); @@ -1516,7 +1473,7 @@ allTests(Test::TestHelper* helper) try { admin1->removeApplication("Application"); - appObs1->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); test(appObs1->applications.empty()); test(++serial == appObs1->serial); } @@ -1535,14 +1492,14 @@ allTests(Test::TestHelper* helper) { cout << "testing adapter observer... " << flush; - AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); - AdminPrx admin1 = session1->getAdmin(); + auto session1 = Ice::uncheckedCast<AdminSessionPrx>(registry->createAdminSession("admin1", "test1")); + auto admin1 = session1->getAdmin(); - session1->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); + session1->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - AdapterObserverIPtr adptObs1 = new AdapterObserverI("adptObs1"); - Ice::ObjectPrx adapter1 = adpt1->addWithUUID(adptObs1); + auto adpt1 = communicator->createObjectAdapter(""); + auto adptObs1 = make_shared<AdapterObserverI>("adptObs1"); + auto adapter1 = adpt1->addWithUUID(adptObs1); adpt1->activate(); registry->ice_getConnection()->setAdapter(adpt1); session1->setObserversByIdentity(Ice::Identity(), @@ -1551,57 +1508,57 @@ allTests(Test::TestHelper* helper) adapter1->ice_getIdentity(), Ice::Identity()); - adptObs1->waitForUpdate(__FILE__, __LINE__); // init + adptObs1->waitForUpdate(__LINE__); // init try { - Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); + auto obj = communicator->stringToProxy("dummy:tcp -p 10000"); - Ice::LocatorRegistryPrx locatorRegistry = communicator->getDefaultLocator()->getRegistry(); + auto locatorRegistry = communicator->getDefaultLocator()->getRegistry(); locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__LINE__); test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); + test(Ice::targetEqualTo(adptObs1->adapters["DummyAdapter"].proxy, obj)); obj = communicator->stringToProxy("dummy:tcp -p 10000 -h localhost"); locatorRegistry->setAdapterDirectProxy("DummyAdapter", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__LINE__); test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); + test(Ice::targetEqualTo(adptObs1->adapters["DummyAdapter"].proxy, obj)); obj = communicator->stringToProxy("dummy:tcp -p 10000 -h localhost"); locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__LINE__); test(adptObs1->adapters.find("DummyAdapter") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter"].proxy == obj); + test(Ice::targetEqualTo(adptObs1->adapters["DummyAdapter"].proxy, obj)); test(adptObs1->adapters["DummyAdapter"].replicaGroupId == "DummyReplicaGroup"); obj = communicator->stringToProxy("dummy:tcp -p 10000 -h localhost"); locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter1", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__LINE__); test(adptObs1->adapters.find("DummyAdapter1") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter1"].proxy == obj); + test(Ice::targetEqualTo(adptObs1->adapters["DummyAdapter1"].proxy, obj)); test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == "DummyReplicaGroup"); obj = communicator->stringToProxy("dummy:tcp -p 10000 -h localhost"); locatorRegistry->setReplicatedAdapterDirectProxy("DummyAdapter2", "DummyReplicaGroup", obj); - adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__LINE__); test(adptObs1->adapters.find("DummyAdapter2") != adptObs1->adapters.end()); - test(adptObs1->adapters["DummyAdapter2"].proxy == obj); + test(Ice::targetEqualTo(adptObs1->adapters["DummyAdapter2"].proxy, obj)); test(adptObs1->adapters["DummyAdapter2"].replicaGroupId == "DummyReplicaGroup"); admin->removeAdapter("DummyAdapter2"); - adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__LINE__); test(adptObs1->adapters.find("DummyAdapter2") == adptObs1->adapters.end()); admin->removeAdapter("DummyReplicaGroup"); - adptObs1->waitForUpdate(__FILE__, __LINE__); - adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__LINE__); + adptObs1->waitForUpdate(__LINE__); test(adptObs1->adapters["DummyAdapter"].replicaGroupId == ""); test(adptObs1->adapters["DummyAdapter1"].replicaGroupId == ""); locatorRegistry->setAdapterDirectProxy("DummyAdapter", 0); - adptObs1->waitForUpdate(__FILE__, __LINE__); + adptObs1->waitForUpdate(__LINE__); test(adptObs1->adapters.find("DummyAdapter") == adptObs1->adapters.end()); } catch(const Ice::UserException& ex) @@ -1619,14 +1576,14 @@ allTests(Test::TestHelper* helper) { cout << "testing object observer... " << flush; - AdminSessionPrx session1 = AdminSessionPrx::uncheckedCast(registry->createAdminSession("admin1", "test1")); - AdminPrx admin1 = session1->getAdmin(); + auto session1 = Ice::uncheckedCast<AdminSessionPrx>(registry->createAdminSession("admin1", "test1")); + auto admin1 = session1->getAdmin(); - session1->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); + session1->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ObjectObserverIPtr objectObs1 = new ObjectObserverI("objectObs1"); - Ice::ObjectPrx object1 = adpt1->addWithUUID(objectObs1); + auto adpt1 = communicator->createObjectAdapter(""); + auto objectObs1 = make_shared<ObjectObserverI>("objectObs1"); + auto object1 = adpt1->addWithUUID(objectObs1); adpt1->activate(); registry->ice_getConnection()->setAdapter(adpt1); session1->setObserversByIdentity(Ice::Identity(), @@ -1635,27 +1592,27 @@ allTests(Test::TestHelper* helper) Ice::Identity(), object1->ice_getIdentity()); - objectObs1->waitForUpdate(__FILE__, __LINE__); // init + objectObs1->waitForUpdate(__LINE__); // init try { - Ice::ObjectPrx obj = communicator->stringToProxy("dummy:tcp -p 10000"); + auto obj = communicator->stringToProxy("dummy:tcp -p 10000"); admin->addObjectWithType(obj, "::Dummy"); - objectObs1->waitForUpdate(__FILE__, __LINE__); + objectObs1->waitForUpdate(__LINE__); test(objectObs1->objects.find(Ice::stringToIdentity("dummy")) != objectObs1->objects.end()); test(objectObs1->objects[Ice::stringToIdentity("dummy")].type == "::Dummy"); - test(objectObs1->objects[Ice::stringToIdentity("dummy")].proxy == obj); + test(Ice::targetEqualTo(objectObs1->objects[Ice::stringToIdentity("dummy")].proxy, obj)); obj = communicator->stringToProxy("dummy:tcp -p 10000 -h localhost"); admin->updateObject(obj); - objectObs1->waitForUpdate(__FILE__, __LINE__); + objectObs1->waitForUpdate(__LINE__); test(objectObs1->objects.find(Ice::stringToIdentity("dummy")) != objectObs1->objects.end()); test(objectObs1->objects[Ice::stringToIdentity("dummy")].type == "::Dummy"); - test(objectObs1->objects[Ice::stringToIdentity("dummy")].proxy == obj); + test(Ice::targetEqualTo(objectObs1->objects[Ice::stringToIdentity("dummy")].proxy, obj)); admin->removeObject(obj->ice_getIdentity()); - objectObs1->waitForUpdate(__FILE__, __LINE__); + objectObs1->waitForUpdate(__LINE__); test(objectObs1->objects.find(Ice::stringToIdentity("dummy")) == objectObs1->objects.end()); } catch(const Ice::UserException& ex) @@ -1671,122 +1628,16 @@ allTests(Test::TestHelper* helper) } { -// cout << "???" << endl; - -// // -// // Setup a descriptor to deploy a node on the node. -// // -// ApplicationDescriptor nodeApp; -// nodeApp.name = "NodeApp"; -// ServerDescriptorPtr server = new ServerDescriptor(); -// server->id = "node-1"; -// server->exe = properties->getProperty("IceGridNodeExe"); -// server->options.push_back("--nowarn"); -// server->pwd = "."; -// addProperty(server, "IceGrid.Node.Name", "node-1"); -// addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); -// addProperty(server, "IceGrid.Node.Endpoints", "default"); -// NodeDescriptor node; -// node.servers.push_back(server); -// nodeApp.nodes["localnode"] = node; - -// try -// { -// int s = session1->startUpdate(); -// test(s == serial); -// admin1->addApplication(nodeApp); -// appObs1->waitForUpdate(__FILE__, __LINE__); // application added -// test(appObs1->applications.find("NodeApp") != appObs1->applications.end()); -// test(++serial == appObs1->serial); -// } -// catch(const DeploymentException& ex) -// { -// cerr << ex.reason << endl; -// test(false); -// } -// catch(const Ice::UserException& ex) -// { -// cerr << ex << endl; -// test(false); -// } - -// try -// { -// admin->startServer("node-1"); -// } -// catch(const NodeUnreachableException& ex) -// { -// cerr << ex << ":\n"; -// cerr << "node = " << ex.name << endl; -// cerr << "reason = " << ex.reason << endl; -// } -// appObs1->waitForUpdate(__FILE__, __LINE__); // object added (for node well-known proxy) -// test(++serial == appObs1->serial); - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// do -// { -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp -// } -// while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - -// try -// { -// admin->stopServer("node-1"); -// } -// catch(const NodeUnreachableException& ex) -// { -// cerr << ex << ":\n"; -// cerr << "node = " << ex.name << endl; -// cerr << "reason = " << ex.reason << endl; -// } -// appObs1->waitForUpdate(__FILE__, __LINE__); // object removed (for node well-known proxy) -// test(++serial == appObs1->serial); - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // updateServer -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown -// test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); - -// try -// { -// admin1->removeApplication("NodeApp"); -// appObs1->waitForUpdate(__FILE__, __LINE__); // application removed -// test(appObs1->applications.empty()); -// test(++serial == appObs1->serial); -// } -// catch(const DeploymentException& ex) -// { -// cerr << ex.reason << endl; -// test(false); -// } -// catch(const Ice::UserException& ex) -// { -// cerr << ex << endl; -// test(false); -// } - -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) -// nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) - -// session1->destroy(); -// adpt1->destroy(); - -// cout << "ok" << endl; - } - - { cout << "testing node observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + auto session1 = registry->createAdminSession("admin1", "test1"); - session1->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); + session1->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.3"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); + auto adpt1 = communicator->createObjectAdapter(""); + auto appObs1 = make_shared<ApplicationObserverI>("appObs1.3"); + auto app1 = adpt1->addWithUUID(appObs1); + auto nodeObs1 = make_shared<NodeObserverI>("nodeObs1"); + auto no1 = adpt1->addWithUUID(nodeObs1); adpt1->activate(); registry->ice_getConnection()->setAdapter(adpt1); session1->setObserversByIdentity(Ice::Identity(), @@ -1795,66 +1646,66 @@ allTests(Test::TestHelper* helper) Ice::Identity(), Ice::Identity()); - appObs1->waitForUpdate(__FILE__, __LINE__); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // init + appObs1->waitForUpdate(__LINE__); + nodeObs1->waitForUpdate(__LINE__); // init test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); test(appObs1->applications.empty()); ApplicationDescriptor nodeApp; nodeApp.name = "NodeApp"; - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); server->id = "node-1"; server->exe = properties->getProperty("IceGridNodeExe"); server->options.push_back("--nowarn"); server->pwd = "."; server->allocatable = false; - addProperty(server, "IceGrid.Node.Name", "node-1"); - addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1"); - addProperty(server, "IceGrid.Node.Endpoints", "default"); - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "IceGrid.Node.Name", "node-1" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-1" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "IceGrid.Node.Endpoints", "default" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); NodeDescriptor node; - node.servers.push_back(server); + node.servers.push_back(move(server)); nodeApp.nodes["localnode"] = node; session->startUpdate(); admin->addApplication(nodeApp); session->finishUpdate(); - appObs1->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); admin->startServer("node-1"); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__LINE__); // serverUpdate + nodeObs1->waitForUpdate(__LINE__); // serverUpdate do { - nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeUp + nodeObs1->waitForUpdate(__LINE__); // nodeUp } while(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Active); + test(nodeObs1->nodes["localnode"].servers[0].state == ServerState::Active); admin->stopServer("node-1"); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Deactivating) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Inactive) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // nodeDown - test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); + nodeObs1->waitForUpdate(__LINE__); // serverUpdate(Deactivating) + nodeObs1->waitForUpdate(__LINE__); // serverUpdate(Inactive) + nodeObs1->waitForUpdate(__LINE__); // nodeDown + test(nodeObs1->nodes["localnode"].servers[0].state == ServerState::Inactive); session->startUpdate(); admin->removeApplication("NodeApp"); session->finishUpdate(); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) + nodeObs1->waitForUpdate(__LINE__); // serverUpdate(Destroying) + nodeObs1->waitForUpdate(__LINE__); // serverUpdate(Destroyed) - appObs1->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); test(nodeObs1->nodes.find("node-1") == nodeObs1->nodes.end()); ApplicationDescriptor testApp; testApp.name = "TestApp"; - server = new ServerDescriptor(); + server = make_shared<ServerDescriptor>(); server->id = "Server"; server->exe = properties->getProperty("ServerDir") + "/server"; server->pwd = properties->getProperty("TestDir"); @@ -1865,75 +1716,75 @@ allTests(Test::TestHelper* helper) adapter.id = "ServerAdapter"; adapter.registerProcess = false; adapter.serverLifetime = true; - server->adapters.push_back(adapter); - addProperty(server, "Server.Endpoints", "default"); - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->adapters.push_back(move(adapter)); + server->propertySet.properties.push_back(PropertyDescriptor{ "Server.Endpoints", "default" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); node = NodeDescriptor(); node.servers.push_back(server); testApp.nodes["localnode"] = node; session->startUpdate(); - admin->addApplication(testApp); + admin->addApplication(move(testApp)); session->finishUpdate(); - appObs1->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); session->startUpdate(); admin->startServer("Server"); session->finishUpdate(); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate + nodeObs1->waitForUpdate(__LINE__); // serverUpdate + nodeObs1->waitForUpdate(__LINE__); // serverUpdate + nodeObs1->waitForUpdate(__LINE__); // adapterUpdate test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Active); + test(nodeObs1->nodes["localnode"].servers[0].state == ServerState::Active); test(nodeObs1->nodes["localnode"].adapters.size() == 1); test(nodeObs1->nodes["localnode"].adapters[0].proxy); test(nodeObs1->nodes["localnode"].servers[0].enabled); admin->enableServer("Server", false); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__LINE__); // serverUpdate test(!nodeObs1->nodes["localnode"].servers[0].enabled); admin->enableServer("Server", true); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate + nodeObs1->waitForUpdate(__LINE__); // serverUpdate test(nodeObs1->nodes["localnode"].servers[0].enabled); admin->stopServer("Server"); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate - nodeObs1->waitForUpdate(__FILE__, __LINE__); // adapterUpdate + nodeObs1->waitForUpdate(__LINE__); // serverUpdate + nodeObs1->waitForUpdate(__LINE__); // serverUpdate + nodeObs1->waitForUpdate(__LINE__); // adapterUpdate test(nodeObs1->nodes.find("localnode") != nodeObs1->nodes.end()); test(nodeObs1->nodes["localnode"].servers.size() == 1); - test(nodeObs1->nodes["localnode"].servers[0].state == Inactive); + test(nodeObs1->nodes["localnode"].servers[0].state == ServerState::Inactive); test(nodeObs1->nodes["localnode"].adapters.empty()); session->startUpdate(); admin->removeApplication("TestApp"); session->finishUpdate(); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroying) - nodeObs1->waitForUpdate(__FILE__, __LINE__); // serverUpdate(Destroyed) + nodeObs1->waitForUpdate(__LINE__); // serverUpdate(Destroying) + nodeObs1->waitForUpdate(__LINE__); // serverUpdate(Destroyed) test(nodeObs1->nodes["localnode"].servers.empty()); - appObs1->waitForUpdate(__FILE__, __LINE__); + appObs1->waitForUpdate(__LINE__); cout << "ok" << endl; } { cout << "testing registry observer... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + auto session1 = registry->createAdminSession("admin1", "test1"); - session1->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); + session1->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter(""); - ApplicationObserverIPtr appObs1 = new ApplicationObserverI("appObs1.4"); - Ice::ObjectPrx app1 = adpt1->addWithUUID(appObs1); - RegistryObserverIPtr registryObs1 = new RegistryObserverI("registryObs1"); - Ice::ObjectPrx ro1 = adpt1->addWithUUID(registryObs1); + auto adpt1 = communicator->createObjectAdapter(""); + auto appObs1 = make_shared<ApplicationObserverI>("appObs1.4"); + auto app1 = adpt1->addWithUUID(appObs1); + auto registryObs1 = make_shared<RegistryObserverI>("registryObs1"); + auto ro1 = adpt1->addWithUUID(registryObs1); adpt1->activate(); registry->ice_getConnection()->setAdapter(adpt1); session1->setObserversByIdentity(ro1->ice_getIdentity(), @@ -1942,20 +1793,20 @@ allTests(Test::TestHelper* helper) Ice::Identity(), Ice::Identity()); - appObs1->waitForUpdate(__FILE__, __LINE__); - registryObs1->waitForUpdate(__FILE__, __LINE__); // init + appObs1->waitForUpdate(__LINE__); + registryObs1->waitForUpdate(__LINE__); // init test(registryObs1->registries.find("Master") != registryObs1->registries.end()); test(appObs1->applications.empty()); - QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy("TestIceGrid/Query")); - Ice::ObjectProxySeq registries = query->findAllObjectsByType("::IceGrid::Registry"); + auto query = Ice::uncheckedCast<QueryPrx>(communicator->stringToProxy("TestIceGrid/Query")); + auto registries = query->findAllObjectsByType("::IceGrid::Registry"); const string prefix("Registry-"); - for(Ice::ObjectProxySeq::const_iterator p = registries.begin(); p != registries.end(); ++p) + for(const auto& p : registries) { - string name = (*p)->ice_getIdentity().name; + string name = p->ice_getIdentity().name; string::size_type pos = name.find(prefix); - if(pos != string::npos) + if (pos != string::npos) { name = name.substr(prefix.size()); test(registryObs1->registries.find(name) != registryObs1->registries.end()); @@ -1966,17 +1817,17 @@ allTests(Test::TestHelper* helper) { cout << "testing observer with direct proxy... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); + auto session1 = registry->createAdminSession("admin1", "test1"); - session1->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle); + session1->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatOnIdle); - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapterWithEndpoints("", "tcp"); - NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); + auto adpt1 = communicator->createObjectAdapterWithEndpoints("", "default"); + auto nodeObs1 = make_shared<NodeObserverI>("nodeObs1"); + auto no1 = adpt1->addWithUUID(nodeObs1); adpt1->activate(); - session1->setObservers(0, NodeObserverPrx::uncheckedCast(no1), 0, 0, 0); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // init + session1->setObservers(0, Ice::uncheckedCast<NodeObserverPrx>(no1), 0, 0, 0); + nodeObs1->waitForUpdate(__LINE__); // init session1->destroy(); adpt1->destroy(); @@ -1986,18 +1837,18 @@ allTests(Test::TestHelper* helper) { cout << "testing observer with indirect proxy... " << flush; - AdminSessionPrx session1 = registry->createAdminSession("admin1", "test1"); - communicator->getProperties()->setProperty("IndirectAdpt1.Endpoints", "tcp"); + auto session1 = registry->createAdminSession("admin1", "test1"); + communicator->getProperties()->setProperty("IndirectAdpt1.Endpoints", "default"); communicator->getProperties()->setProperty("IndirectAdpt1.AdapterId", "adapter1"); - Ice::ObjectAdapterPtr adpt1 = communicator->createObjectAdapter("IndirectAdpt1"); + auto adpt1 = communicator->createObjectAdapter("IndirectAdpt1"); test(communicator->getDefaultLocator()); - NodeObserverIPtr nodeObs1 = new NodeObserverI("nodeObs1"); - Ice::ObjectPrx no1 = adpt1->addWithUUID(nodeObs1); + auto nodeObs1 = make_shared<NodeObserverI>("nodeObs1"); + auto no1 = adpt1->addWithUUID(nodeObs1); assert(no1->ice_getAdapterId() == "adapter1"); adpt1->activate(); - session1->setObservers(0, NodeObserverPrx::uncheckedCast(no1), 0, 0, 0); - nodeObs1->waitForUpdate(__FILE__, __LINE__); // init + session1->setObservers(0, Ice::uncheckedCast<NodeObserverPrx>(no1), 0, 0, 0); + nodeObs1->waitForUpdate(__LINE__); // init session1->destroy(); adpt1->destroy(); diff --git a/cpp/test/IceGrid/session/Client.cpp b/cpp/test/IceGrid/session/Client.cpp index 882ba448080..88ac4d24d59 100644 --- a/cpp/test/IceGrid/session/Client.cpp +++ b/cpp/test/IceGrid/session/Client.cpp @@ -7,20 +7,20 @@ using namespace std; -class Client : public Test::TestHelper +class Client final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Client::run(int argc, char** argv) { - Ice::PropertiesPtr properties = createTestProperties(argc, argv); + auto properties = createTestProperties(argc, argv); properties->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); properties->setProperty("Ice.Warn.Connections", "0"); - Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv, properties); void allTests(Test::TestHelper*); allTests(this); } diff --git a/cpp/test/IceGrid/session/PermissionsVerifier.cpp b/cpp/test/IceGrid/session/PermissionsVerifier.cpp index de0951e9287..8cd13583259 100644 --- a/cpp/test/IceGrid/session/PermissionsVerifier.cpp +++ b/cpp/test/IceGrid/session/PermissionsVerifier.cpp @@ -10,12 +10,12 @@ using namespace std; -class AdminPermissionsVerifierI : public Glacier2::PermissionsVerifier +class AdminPermissionsVerifierI final : public Glacier2::PermissionsVerifier { public: - virtual bool - checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current& c) const + bool + checkPermissions(string userId, string passwd, string&, const Ice::Current& c) const override { if(c.ctx.find("throw") != c.ctx.end()) { @@ -27,24 +27,24 @@ public: } }; -class PermissionsVerifierServer : public Test::TestHelper +class PermissionsVerifierServer final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void PermissionsVerifierServer::run(int argc, char** argv) { shutdownOnInterrupt(); - Ice::PropertiesPtr properties = createTestProperties(argc, argv); + auto properties = createTestProperties(argc, argv); properties->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); - Ice::CommunicatorHolder communicator = initialize(argc, argv, properties); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("PermissionsVerifier"); - adapter->add(new AdminPermissionsVerifierI, Ice::stringToIdentity("AdminPermissionsVerifier")); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv, properties); + auto adapter = communicatorHolder->createObjectAdapter("PermissionsVerifier"); + adapter->add(make_shared<AdminPermissionsVerifierI>(), Ice::stringToIdentity("AdminPermissionsVerifier")); adapter->activate(); - communicator->waitForShutdown(); + communicatorHolder->waitForShutdown(); } DEFINE_TEST(PermissionsVerifierServer) diff --git a/cpp/test/IceGrid/session/Server.cpp b/cpp/test/IceGrid/session/Server.cpp index c154ef61e11..a6c16354d9f 100644 --- a/cpp/test/IceGrid/session/Server.cpp +++ b/cpp/test/IceGrid/session/Server.cpp @@ -10,12 +10,12 @@ using namespace std; -class ClientPermissionsVerifierI : public Glacier2::PermissionsVerifier +class ClientPermissionsVerifierI final : public Glacier2::PermissionsVerifier { public: - virtual bool - checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current& current) const + bool + checkPermissions(string userId, string passwd, string&, const Ice::Current& current) const override { if(current.ctx.find("throw") != current.ctx.end()) { @@ -25,19 +25,19 @@ public: } }; -class SSLPermissionsVerifierI : public Glacier2::SSLPermissionsVerifier +class SSLPermissionsVerifierI final : public Glacier2::SSLPermissionsVerifier { public: - virtual bool - authorize(const Glacier2::SSLInfo& info, string&, const Ice::Current& current) const + bool + authorize(Glacier2::SSLInfo info, string&, const Ice::Current& current) const override { if(current.ctx.find("throw") != current.ctx.end()) { throw Test::ExtendedPermissionDeniedException("reason"); } test(info.certs.size() > 0); - IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]); + auto cert = IceSSL::Certificate::decode(info.certs[0]); test(cert->getIssuerDN() == IceSSL::DistinguishedName( "emailAddress=info@zeroc.com,C=US,ST=Florida,L=Jupiter,O=ZeroC\\, Inc.,OU=Ice,CN=Ice Tests CA")); test(cert->getSubjectDN() == IceSSL::DistinguishedName( @@ -48,22 +48,22 @@ public: } }; -class Server : public Test::TestHelper +class Server final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Server::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Server"); - if(communicator->getProperties()->getPropertyAsInt("AddPermissionsVerifiers") > 0) + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv); + auto adapter = communicatorHolder->createObjectAdapter("Server"); + if(communicatorHolder->getProperties()->getPropertyAsInt("AddPermissionsVerifiers") > 0) { - adapter->add(new ClientPermissionsVerifierI(), Ice::stringToIdentity("ClientPermissionsVerifier")); - adapter->add(new SSLPermissionsVerifierI(), Ice::stringToIdentity("SSLPermissionsVerifier")); + adapter->add(make_shared<ClientPermissionsVerifierI>(), Ice::stringToIdentity("ClientPermissionsVerifier")); + adapter->add(make_shared<SSLPermissionsVerifierI>(), Ice::stringToIdentity("SSLPermissionsVerifier")); } adapter->activate(); @@ -74,7 +74,7 @@ Server::run(int argc, char** argv) catch(const Ice::ObjectAdapterDeactivatedException&) { } - communicator->waitForShutdown(); + communicatorHolder->waitForShutdown(); } DEFINE_TEST(Server) diff --git a/cpp/test/IceGrid/simple/AllTests.cpp b/cpp/test/IceGrid/simple/AllTests.cpp index 8ac52b2b58a..1cad53bcb30 100644 --- a/cpp/test/IceGrid/simple/AllTests.cpp +++ b/cpp/test/IceGrid/simple/AllTests.cpp @@ -2,31 +2,31 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/IceUtil.h> #include <Ice/Ice.h> #include <IceGrid/IceGrid.h> #include <TestHelper.h> #include <Test.h> using namespace std; +using namespace IceGrid; using namespace Test; void -allTests(Test::TestHelper* helper) +allTests(TestHelper* helper) { - Ice::CommunicatorPtr communicator = helper->communicator(); + auto communicator = helper->communicator(); cout << "testing stringToProxy... " << flush; - Ice::ObjectPrxPtr base = communicator->stringToProxy("test @ TestAdapter"); + auto base = communicator->stringToProxy("test @ TestAdapter"); test(base); cout << "ok" << endl; cout << "testing IceGrid.Locator is present... " << flush; - IceGrid::LocatorPrxPtr locator = ICE_UNCHECKED_CAST(IceGrid::LocatorPrx, base); + auto locator = Ice::uncheckedCast<LocatorPrx>(base); test(locator); cout << "ok" << endl; cout << "testing checked cast... " << flush; - TestIntfPrxPtr obj = ICE_CHECKED_CAST(TestIntfPrx, base); + auto obj = Ice::checkedCast<TestIntfPrx>(base); test(obj); test(Ice::targetEqualTo(obj, base)); cout << "ok" << endl; @@ -36,25 +36,22 @@ allTests(Test::TestHelper* helper) cout << "ok" << endl; cout << "testing locator finder... " << flush; - Ice::Identity finderId; - finderId.category = "Ice"; - finderId.name = "LocatorFinder"; - Ice::LocatorFinderPrxPtr finder = ICE_CHECKED_CAST(Ice::LocatorFinderPrx, - communicator->getDefaultLocator()->ice_identity(finderId)); + auto finder = Ice::checkedCast<Ice::LocatorFinderPrx>( + communicator->getDefaultLocator()->ice_identity(Ice::Identity{ "LocatorFinder", "Ice" })); test(finder->getLocator()); cout << "ok" << endl; - Ice::CommunicatorPtr com; + shared_ptr<Ice::Communicator> com; try { cout << "testing discovery... " << flush; { // Add test well-known object - IceGrid::RegistryPrxPtr registry = ICE_CHECKED_CAST(IceGrid::RegistryPrx, - communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); + auto registry = Ice::checkedCast<RegistryPrx>(communicator->stringToProxy( + communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - IceGrid::AdminSessionPrxPtr session = registry->createAdminSession("foo", "bar"); + auto session = registry->createAdminSession("foo", "bar"); session->getAdmin()->addObjectWithType(base, "::Test"); session->destroy(); @@ -76,11 +73,11 @@ allTests(Test::TestHelper* helper) com->stringToProxy("test @ TestAdapter")->ice_ping(); com->stringToProxy("test")->ice_ping(); test(com->getDefaultLocator()->getRegistry()); - test(ICE_CHECKED_CAST(IceGrid::LocatorPrx, com->getDefaultLocator())); - test(ICE_UNCHECKED_CAST(IceGrid::LocatorPrx, com->getDefaultLocator())->getLocalRegistry()); - test(ICE_UNCHECKED_CAST(IceGrid::LocatorPrx, com->getDefaultLocator())->getLocalQuery()); + test(Ice::checkedCast<LocatorPrx>(com->getDefaultLocator())); + test(Ice::uncheckedCast<LocatorPrx>(com->getDefaultLocator())->getLocalRegistry()); + test(Ice::uncheckedCast<LocatorPrx>(com->getDefaultLocator())->getLocalQuery()); - Ice::ObjectAdapterPtr adapter = com->createObjectAdapter("AdapterForDiscoveryTest"); + auto adapter = com->createObjectAdapter("AdapterForDiscoveryTest"); adapter->activate(); adapter->deactivate(); @@ -117,10 +114,10 @@ allTests(Test::TestHelper* helper) { } test(!com->getDefaultLocator()->getRegistry()); - test(!ICE_CHECKED_CAST(IceGrid::LocatorPrx, com->getDefaultLocator())); + test(!Ice::checkedCast<LocatorPrx>(com->getDefaultLocator())); try { - test(ICE_UNCHECKED_CAST(IceGrid::LocatorPrx, com->getDefaultLocator())->getLocalQuery()); + test(Ice::uncheckedCast<LocatorPrx>(com->getDefaultLocator())->getLocalQuery()); } catch(const Ice::OperationNotExistException&) { @@ -224,21 +221,21 @@ allTests(Test::TestHelper* helper) } void -allTestsWithDeploy(Test::TestHelper* helper) +allTestsWithDeploy(TestHelper* helper) { - Ice::CommunicatorPtr communicator = helper->communicator(); + auto communicator = helper->communicator(); cout << "testing stringToProxy... " << flush; - Ice::ObjectPrxPtr base = communicator->stringToProxy("test @ TestAdapter"); + auto base = communicator->stringToProxy("test @ TestAdapter"); test(base); - Ice::ObjectPrxPtr base2 = communicator->stringToProxy("test"); + auto base2 = communicator->stringToProxy("test"); test(base2); cout << "ok" << endl; cout << "testing checked cast... " << flush; - TestIntfPrxPtr obj = ICE_CHECKED_CAST(TestIntfPrx, base); + auto obj = Ice::checkedCast<TestIntfPrx>(base); test(obj); test(Ice::targetEqualTo(obj, base)); - TestIntfPrxPtr obj2 = ICE_CHECKED_CAST(TestIntfPrx, base2); + auto obj2 = Ice::checkedCast<TestIntfPrx>(base2); test(obj2); test(Ice::targetEqualTo(obj2, base2)); cout << "ok" << endl; @@ -249,9 +246,9 @@ allTestsWithDeploy(Test::TestHelper* helper) cout << "ok" << endl; cout << "testing encoding versioning... " << flush; - Ice::ObjectPrxPtr base10 = communicator->stringToProxy("test10 @ TestAdapter10"); + auto base10 = communicator->stringToProxy("test10 @ TestAdapter10"); test(base10); - Ice::ObjectPrxPtr base102 = communicator->stringToProxy("test10"); + auto base102 = communicator->stringToProxy("test10"); test(base102); try { @@ -301,15 +298,15 @@ allTestsWithDeploy(Test::TestHelper* helper) } cout << "ok" << endl; - IceGrid::RegistryPrxPtr registry = ICE_CHECKED_CAST(IceGrid::RegistryPrx, - communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); + auto registry = Ice::checkedCast<RegistryPrx>(communicator->stringToProxy( + communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - IceGrid::AdminSessionPrxPtr session = registry->createAdminSession("foo", "bar"); + auto session = registry->createAdminSession("foo", "bar"); - session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + session->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatAlways); - IceGrid::AdminPrxPtr admin = session->getAdmin(); + auto admin = session->getAdmin(); test(admin); admin->enableServer("server", false); @@ -318,7 +315,7 @@ allTestsWithDeploy(Test::TestHelper* helper) cout << "testing whether server is still reachable... " << flush; try { - obj = ICE_CHECKED_CAST(TestIntfPrx, base); + obj = Ice::checkedCast<TestIntfPrx>(base); test(false); } catch(const Ice::NoEndpointException&) @@ -326,7 +323,7 @@ allTestsWithDeploy(Test::TestHelper* helper) } try { - obj2 = ICE_CHECKED_CAST(TestIntfPrx, base2); + obj2 = Ice::checkedCast<TestIntfPrx>(base2); test(false); } catch(const Ice::NoEndpointException&) @@ -337,7 +334,7 @@ allTestsWithDeploy(Test::TestHelper* helper) try { - obj = ICE_CHECKED_CAST(TestIntfPrx, base); + obj = Ice::checkedCast<TestIntfPrx>(base); } catch(const Ice::NoEndpointException&) { @@ -345,7 +342,7 @@ allTestsWithDeploy(Test::TestHelper* helper) } try { - obj2 = ICE_CHECKED_CAST(TestIntfPrx, base2); + obj2 = Ice::checkedCast<TestIntfPrx>(base2); } catch(const Ice::NoEndpointException&) { diff --git a/cpp/test/IceGrid/simple/Client.cpp b/cpp/test/IceGrid/simple/Client.cpp index e7000c958db..41102fdbc56 100644 --- a/cpp/test/IceGrid/simple/Client.cpp +++ b/cpp/test/IceGrid/simple/Client.cpp @@ -3,18 +3,16 @@ // #include <Ice/Ice.h> -#include <IceUtil/IceUtil.h> #include <TestHelper.h> #include <Test.h> using namespace std; -using namespace Test; -class Client : public Test::TestHelper +class Client final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -23,7 +21,7 @@ Client::run(int argc, char** argv) #ifdef ICE_STATIC_LIBS Ice::registerIceLocatorDiscovery(false); #endif - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv); bool withDeploy = false; diff --git a/cpp/test/IceGrid/simple/Server.cpp b/cpp/test/IceGrid/simple/Server.cpp index 544f8f45358..4d750a79e48 100644 --- a/cpp/test/IceGrid/simple/Server.cpp +++ b/cpp/test/IceGrid/simple/Server.cpp @@ -8,21 +8,21 @@ using namespace std; -class Server : public Test::TestHelper +class Server final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Server::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); - string id = communicator->getProperties()->getPropertyWithDefault("Identity", "test"); - adapter->add(ICE_MAKE_SHARED(TestI), Ice::stringToIdentity(id)); + auto adapter = communicatorHolder->createObjectAdapter("TestAdapter"); + auto id = communicatorHolder->getProperties()->getPropertyWithDefault("Identity", "test"); + adapter->add(make_shared<TestI>(), Ice::stringToIdentity(id)); try { @@ -31,7 +31,7 @@ Server::run(int argc, char** argv) catch(const Ice::ObjectAdapterDeactivatedException&) { } - communicator->waitForShutdown(); + communicatorHolder->waitForShutdown(); } DEFINE_TEST(Server) diff --git a/cpp/test/IceGrid/simple/TestI.h b/cpp/test/IceGrid/simple/TestI.h index ac84ff4d278..2d416770376 100644 --- a/cpp/test/IceGrid/simple/TestI.h +++ b/cpp/test/IceGrid/simple/TestI.h @@ -7,13 +7,13 @@ #include <Test.h> -class TestI : public ::Test::TestIntf +class TestI final : public ::Test::TestIntf { public: TestI(); - virtual void shutdown(const Ice::Current&); + void shutdown(const Ice::Current&) override; }; #endif diff --git a/cpp/test/IceGrid/update/AllTests.cpp b/cpp/test/IceGrid/update/AllTests.cpp index 9896684cc3f..0e82f54dede 100644 --- a/cpp/test/IceGrid/update/AllTests.cpp +++ b/cpp/test/IceGrid/update/AllTests.cpp @@ -2,7 +2,6 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/Thread.h> #include <Ice/Ice.h> #include <IceGrid/IceGrid.h> #include <TestHelper.h> @@ -12,46 +11,27 @@ using namespace std; using namespace Test; using namespace IceGrid; -void -addProperty(const CommunicatorDescriptorPtr& communicator, const string& name, const string& value) -{ - PropertyDescriptor prop; - prop.name = name; - prop.value = value; - communicator->propertySet.properties.push_back(prop); -} - string -getProperty(const PropertyDescriptorSeq& properties, const string& name) +getProperty(const PropertyDescriptorSeq& properties, string name) { - for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) + for(const auto& q: properties) { - if(q->name == name) + if(q.name == name) { - return q->value; + return q.value; } } return ""; } -PropertyDescriptor -createProperty(const string& name, const string& value) -{ - PropertyDescriptor prop; - prop.name = name; - prop.value = value; - return prop; -} - bool -hasProperty(const CommunicatorDescriptorPtr& desc, const string& name, const string& value) +hasProperty(const shared_ptr<CommunicatorDescriptor>& desc, string name, string value) { - for(PropertyDescriptorSeq::const_iterator p = desc->propertySet.properties.begin(); - p != desc->propertySet.properties.end(); ++p) + for(const auto& p : desc->propertySet.properties) { - if(p->name == name) + if(p.name == name) { - return p->value == value; + return p.value == value; } } return false; @@ -60,20 +40,18 @@ hasProperty(const CommunicatorDescriptorPtr& desc, const string& name, const str void allTests(Test::TestHelper* helper) { - const Ice::CommunicatorPtr& communicator = helper->communicator(); - IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( - communicator->stringToProxy(communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); + auto communicator = helper->communicator(); + auto registry = Ice::checkedCast<RegistryPrx>(communicator->stringToProxy( + communicator->getDefaultLocator()->ice_getIdentity().category + "/Registry")); test(registry); - AdminSessionPrx session = registry->createAdminSession("foo", "bar"); + auto session = registry->createAdminSession("foo", "bar"); - session->ice_getConnection()->setACM(registry->getACMTimeout(), - IceUtil::None, - Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways)); + session->ice_getConnection()->setACM(registry->getACMTimeout(), Ice::nullopt, Ice::ACMHeartbeat::HeartbeatAlways); - AdminPrx admin = session->getAdmin(); + auto admin = session->getAdmin(); test(admin); - Ice::PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); { ApplicationDescriptor testApp; @@ -84,30 +62,30 @@ allTests(Test::TestHelper* helper) empty.name = "TestApp"; NodeUpdateDescriptor node; node.name = "localnode"; - empty.nodes.push_back(node); + empty.nodes.push_back(move(node)); ApplicationUpdateDescriptor update = empty; cout << "testing server add... " << flush; - ServerDescriptorPtr server = new ServerDescriptor(); + shared_ptr<ServerDescriptor> server = make_shared<ServerDescriptor>(); server->id = "Server"; server->exe = properties->getProperty("ServerDir") + "/server"; server->pwd = "."; server->allocatable = false; - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); AdapterDescriptor adapter; adapter.name = "Server"; adapter.id = "ServerAdapter"; adapter.registerProcess = false; adapter.serverLifetime = false; - addProperty(server, "Server.Endpoints", "default"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Server.Endpoints", "default" }); ObjectDescriptor object; object.id = Ice::stringToIdentity("test"); object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); - update.nodes[0].servers.push_back(server); + adapter.objects.push_back(move(object)); + server->adapters.push_back(move(adapter)); + update.nodes[0].servers.push_back(move(server)); admin->updateApplication(update); update.nodes[0].servers[0]->id = "Server2"; @@ -155,24 +133,24 @@ allTests(Test::TestHelper* helper) TemplateDescriptor templ; templ.parameters.push_back("name"); - templ.descriptor = new ServerDescriptor(); - server = ServerDescriptorPtr::dynamicCast(templ.descriptor); + templ.descriptor = make_shared<ServerDescriptor>(); + server = dynamic_pointer_cast<ServerDescriptor>(templ.descriptor); server->id = "${name}"; server->exe = "${test.dir}/server"; server->pwd = "."; server->allocatable = false; - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); adapter = AdapterDescriptor(); adapter.name = "Server"; adapter.id = "${server}"; adapter.registerProcess = false; adapter.serverLifetime = false; - addProperty(server, "Server.Endpoints", "default"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Server.Endpoints", "default" }); object = ObjectDescriptor(); object.id = Ice::stringToIdentity("${server}"); object.type = "::Test::TestIntf"; - adapter.objects.push_back(object); - server->adapters.push_back(adapter); + adapter.objects.push_back(move(object)); + server->adapters.push_back(move(adapter)); update = empty; update.serverTemplates["ServerTemplate"] = templ; try @@ -188,7 +166,7 @@ allTests(Test::TestHelper* helper) update = empty; ServerInstanceDescriptor instance; instance._cpp_template = "ServerTemplate"; - update.nodes[0].serverInstances.push_back(instance); + update.nodes[0].serverInstances.push_back(move(instance)); try { admin->updateApplication(update); @@ -210,7 +188,7 @@ allTests(Test::TestHelper* helper) instance = ServerInstanceDescriptor(); instance._cpp_template = "ServerTemplate"; instance.parameterValues["name"] = "Server1"; - update.nodes[0].serverInstances.push_back(instance); + update.nodes[0].serverInstances.push_back(move(instance)); try { admin->updateApplication(update); @@ -315,7 +293,7 @@ allTests(Test::TestHelper* helper) ServerInfo info = admin->getServerInfo("Server"); test(info.descriptor); - addProperty(info.descriptor, "test", "test"); + info.descriptor->propertySet.properties.push_back(PropertyDescriptor{ "test", "test" }); update = empty; update.nodes[0].servers.push_back(info.descriptor); try @@ -336,7 +314,7 @@ allTests(Test::TestHelper* helper) instance = ServerInstanceDescriptor(); instance._cpp_template = "ServerTemplate"; instance.parameterValues["name"] = "Server1"; - update.nodes[0].serverInstances.push_back(instance); + update.nodes[0].serverInstances.push_back(move(instance)); try { admin->updateApplication(update); @@ -348,7 +326,7 @@ allTests(Test::TestHelper* helper) } update = empty; - addProperty(server, "test", "test"); + server->propertySet.properties.push_back(PropertyDescriptor{ "test", "test" }); assert(templ.descriptor == server); update.serverTemplates["ServerTemplate"] = templ; try @@ -371,7 +349,7 @@ allTests(Test::TestHelper* helper) adapter.id = "Server1"; adapter.serverLifetime = false; adapter.registerProcess = false; - info.descriptor->adapters.push_back(adapter); + info.descriptor->adapters.push_back(move(adapter)); update = empty; update.nodes[0].servers.push_back(info.descriptor); try @@ -397,8 +375,8 @@ allTests(Test::TestHelper* helper) adapter.registerProcess = false; object = ObjectDescriptor(); object.id = Ice::stringToIdentity("test"); - adapter.objects.push_back(object); - info.descriptor->adapters.push_back(adapter); + adapter.objects.push_back(move(object)); + info.descriptor->adapters.push_back(move(adapter)); update = empty; update.nodes[0].servers.push_back(info.descriptor); try @@ -420,7 +398,7 @@ allTests(Test::TestHelper* helper) test(info.descriptor); object = ObjectDescriptor(); object.id = Ice::stringToIdentity("test"); - info.descriptor->adapters[0].objects.push_back(object); + info.descriptor->adapters[0].objects.push_back(move(object)); update = empty; update.nodes[0].servers.push_back(info.descriptor); try @@ -442,7 +420,7 @@ allTests(Test::TestHelper* helper) test(info.descriptor); object = ObjectDescriptor(); object.id = Ice::stringToIdentity("test1"); - info.descriptor->adapters[0].allocatables.push_back(object); + info.descriptor->adapters[0].allocatables.push_back(move(object)); update = empty; update.nodes[0].servers.push_back(info.descriptor); try @@ -459,7 +437,7 @@ allTests(Test::TestHelper* helper) test(info.descriptor); object = ObjectDescriptor(); object.id = Ice::stringToIdentity("test1"); - info.descriptor->adapters[0].allocatables.push_back(object); + info.descriptor->adapters[0].allocatables.push_back(move(object)); update = empty; update.nodes[0].servers.push_back(info.descriptor); try @@ -481,7 +459,7 @@ allTests(Test::TestHelper* helper) test(info.descriptor); object = ObjectDescriptor(); object.id = Ice::stringToIdentity("test"); - info.descriptor->adapters[0].allocatables.push_back(object); + info.descriptor->adapters[0].allocatables.push_back(move(object)); update = empty; update.nodes[0].servers.push_back(info.descriptor); try @@ -498,7 +476,7 @@ allTests(Test::TestHelper* helper) test(info.descriptor); object = ObjectDescriptor(); object.id = Ice::stringToIdentity("test"); - info.descriptor->adapters[0].allocatables.push_back(object); + info.descriptor->adapters[0].allocatables.push_back(move(object)); update = empty; update.nodes[0].servers.push_back(info.descriptor); try @@ -529,13 +507,13 @@ allTests(Test::TestHelper* helper) empty.name = "TestApp"; NodeUpdateDescriptor node; node.name = "localnode"; - empty.nodes.push_back(node); + empty.nodes.push_back(move(node)); ApplicationUpdateDescriptor update = empty; cout << "testing icebox server add... " << flush; - ServiceDescriptorPtr service = new ServiceDescriptor(); + auto service = make_shared<ServiceDescriptor>(); service->name = "Service1"; service->entry = "TestService:create"; AdapterDescriptor adapter; @@ -543,21 +521,21 @@ allTests(Test::TestHelper* helper) adapter.id = "${server}.${service}"; adapter.registerProcess = false; adapter.serverLifetime = false; - addProperty(service, "${service}.Endpoints", "default"); - service->adapters.push_back(adapter); + service->propertySet.properties.push_back(PropertyDescriptor{ "${service}.Endpoints", "default" }); + service->adapters.push_back(move(adapter)); - IceBoxDescriptorPtr server = new IceBoxDescriptor(); + auto server = make_shared<IceBoxDescriptor>(); server->id = "IceBox"; server->exe = properties->getProperty("IceBoxExe"); server->allocatable = false; - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); server->services.resize(3); - server->services[0].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + server->services[0].descriptor = dynamic_pointer_cast<ServiceDescriptor>(service->ice_clone()); service->name = "Service2"; - server->services[1].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + server->services[1].descriptor = dynamic_pointer_cast<ServiceDescriptor>(service->ice_clone()); service->name = "Service3"; - server->services[2].descriptor = ServiceDescriptorPtr::dynamicCast(service->ice_clone()); + server->services[2].descriptor = dynamic_pointer_cast<ServiceDescriptor>(service->ice_clone()); update.nodes[0].servers.push_back(server); try @@ -711,15 +689,15 @@ allTests(Test::TestHelper* helper) { cout << "testing variable update... " << flush; - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); server->id = "${name}"; server->exe = "server"; server->pwd = "."; server->allocatable = false; - addProperty(server, "ApplicationVar", "${appvar}"); - addProperty(server, "NodeVar", "${nodevar}"); - addProperty(server, "ServerParamVar", "${serverparamvar}"); + server->propertySet.properties.push_back(PropertyDescriptor{ "ApplicationVar", "${appvar}" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "NodeVar", "${nodevar}" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "ServerParamVar", "${serverparamvar}" }); TemplateDescriptor templ; templ.parameters.push_back("name"); @@ -738,7 +716,7 @@ allTests(Test::TestHelper* helper) serverInstance._cpp_template = "ServerTemplate"; serverInstance.parameterValues["name"] = "Server"; serverInstance.parameterValues["serverparamvar"] = "ServerParamValue"; - node.serverInstances.push_back(serverInstance); + node.serverInstances.push_back(move(serverInstance)); testApp.nodes["node1"] = node; @@ -781,7 +759,7 @@ allTests(Test::TestHelper* helper) NodeUpdateDescriptor nodeUpdate; nodeUpdate.name = "node1"; nodeUpdate.removeVariables.push_back("nodevar"); - update.nodes.push_back(nodeUpdate); + update.nodes.push_back(move(nodeUpdate)); try { admin->updateApplication(update); @@ -804,8 +782,8 @@ allTests(Test::TestHelper* helper) serverInstance.parameterValues["name"] = "Server"; nodeUpdate = NodeUpdateDescriptor(); nodeUpdate.name = "node1"; - nodeUpdate.serverInstances.push_back(serverInstance); - update.nodes.push_back(nodeUpdate); + nodeUpdate.serverInstances.push_back(move(serverInstance)); + update.nodes.push_back(move(nodeUpdate)); try { admin->updateApplication(update); @@ -830,7 +808,7 @@ allTests(Test::TestHelper* helper) nodeUpdate = NodeUpdateDescriptor(); nodeUpdate.name = "node1"; nodeUpdate.variables["serverparamvar"] = "nodeoverride"; - update.nodes.push_back(nodeUpdate); + update.nodes.push_back(move(nodeUpdate)); try { admin->updateApplication(update); @@ -848,7 +826,7 @@ allTests(Test::TestHelper* helper) nodeUpdate = NodeUpdateDescriptor(); nodeUpdate.name = "node1"; nodeUpdate.variables["appvar"] = "nodeoverride"; - update.nodes.push_back(nodeUpdate); + update.nodes.push_back(move(nodeUpdate)); try { admin->updateApplication(update); @@ -860,7 +838,6 @@ allTests(Test::TestHelper* helper) } serverAfter = admin->getServerInfo("Server"); - PropertyDescriptorSeq newProps = serverAfter.descriptor->propertySet.properties; test(getProperty(serverAfter.descriptor->propertySet.properties, "ApplicationVar") == "nodeoverride"); test(getProperty(serverAfter.descriptor->propertySet.properties, "NodeVar") == "NodeValue"); test(getProperty(serverAfter.descriptor->propertySet.properties, "ServerParamVar") == "ServerParamValue"); @@ -871,10 +848,10 @@ allTests(Test::TestHelper* helper) { cout << "testing property set update... " << flush; - ServiceDescriptorPtr service = new ServiceDescriptor(); + auto service = make_shared<ServiceDescriptor>(); service->name = "${name}"; service->entry = "dummy"; - addProperty(service, "ServiceProp", "test"); + service->propertySet.properties.push_back(PropertyDescriptor{ "ServiceProp", "test" }); TemplateDescriptor svcTempl; svcTempl.parameters.push_back("name"); @@ -883,16 +860,16 @@ allTests(Test::TestHelper* helper) ServiceInstanceDescriptor serviceInstance; serviceInstance._cpp_template = "ServiceTemplate"; serviceInstance.parameterValues["name"] = "Service"; - serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "test")); + serviceInstance.propertySet.properties.push_back(PropertyDescriptor{ "ServiceInstanceProp", "test" }); - IceBoxDescriptorPtr server = new IceBoxDescriptor(); + auto server = make_shared<IceBoxDescriptor>(); server->id = "${name}"; server->exe = "server"; server->pwd = "."; server->allocatable = false; server->propertySet.references.push_back("ApplicationPropertySet"); server->propertySet.references.push_back("NodePropertySet"); - addProperty(server, "ServerProp", "test"); + server->propertySet.properties.push_back(PropertyDescriptor{ "ServerProp", "test" }); server->services.push_back(serviceInstance); TemplateDescriptor templ; @@ -904,18 +881,18 @@ allTests(Test::TestHelper* helper) testApp.variables["appvar"] = "AppValue"; testApp.serverTemplates["ServerTemplate"] = templ; testApp.serviceTemplates["ServiceTemplate"] = svcTempl; - testApp.propertySets["ApplicationPropertySet"].properties.push_back(createProperty("ApplicationProp","test")); - testApp.propertySets["ApplicationPropertySet1"].properties.push_back(createProperty("ApplicationProp", "d")); + testApp.propertySets["ApplicationPropertySet"].properties.push_back(PropertyDescriptor{ "ApplicationProp","test" }); + testApp.propertySets["ApplicationPropertySet1"].properties.push_back(PropertyDescriptor{ "ApplicationProp", "d" }); NodeDescriptor node; node.variables["nodevar"] = "NodeValue"; - node.propertySets["NodePropertySet"].properties.push_back(createProperty("NodeProp", "test")); - node.propertySets["NodePropertySet1"].properties.push_back(createProperty("NodeProp", "test")); + node.propertySets["NodePropertySet"].properties.push_back(PropertyDescriptor{ "NodeProp", "test" }); + node.propertySets["NodePropertySet1"].properties.push_back(PropertyDescriptor{ "NodeProp", "test" }); ServerInstanceDescriptor serverInstance; serverInstance._cpp_template = "ServerTemplate"; serverInstance.parameterValues["name"] = "Server"; - serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "test")); + serverInstance.propertySet.properties.push_back(PropertyDescriptor{ "ServerInstanceProp", "test" }); node.serverInstances.push_back(serverInstance); testApp.nodes["node1"] = node; @@ -941,7 +918,7 @@ allTests(Test::TestHelper* helper) test(hasProperty(info.descriptor, "ApplicationProp", "test")); test(hasProperty(info.descriptor, "ServerInstanceProp", "test")); - ServiceDescriptorPtr svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + auto svc = dynamic_pointer_cast<IceBoxDescriptor>(info.descriptor)->services[0].descriptor; test(hasProperty(svc, "ServiceProp", "test")); ApplicationUpdateDescriptor empty; @@ -950,29 +927,29 @@ allTests(Test::TestHelper* helper) update = empty; service->propertySet.properties.clear(); - addProperty(service, "ServiceProp", "updated"); + service->propertySet.properties.push_back(PropertyDescriptor{ "ServiceProp", "updated" }); svcTempl.descriptor = service; update.serviceTemplates["ServiceTemplate"] = svcTempl; admin->updateApplication(update); info = admin->getServerInfo("Server"); - svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + svc = dynamic_pointer_cast<IceBoxDescriptor>(info.descriptor)->services[0].descriptor; test(hasProperty(svc, "ServiceProp", "updated")); update = empty; serviceInstance.propertySet.properties.clear(); - serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "updated")); + serviceInstance.propertySet.properties.push_back(PropertyDescriptor{ "ServiceInstanceProp", "updated" }); server->services.clear(); - server->services.push_back(serviceInstance); + server->services.push_back(move(serviceInstance)); templ.descriptor = server; update.serverTemplates["ServerTemplate"] = templ; admin->updateApplication(update); info = admin->getServerInfo("Server"); - svc = IceBoxDescriptorPtr::dynamicCast(info.descriptor)->services[0].descriptor; + svc = dynamic_pointer_cast<IceBoxDescriptor>(info.descriptor)->services[0].descriptor; test(hasProperty(svc, "ServiceInstanceProp", "updated")); update = empty; server->propertySet.properties.clear(); - addProperty(server, "ServerProp", "updated"); + server->propertySet.properties.push_back(PropertyDescriptor{ "ServerProp", "updated" }); templ.descriptor = server; update.serverTemplates["ServerTemplate"] = templ; admin->updateApplication(update); @@ -981,10 +958,10 @@ allTests(Test::TestHelper* helper) update = empty; serverInstance.propertySet.properties.clear(); - serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "updated")); + serverInstance.propertySet.properties.push_back(PropertyDescriptor{ "ServerInstanceProp", "updated" }); NodeUpdateDescriptor nodeUpdate; nodeUpdate.name = "node1"; - nodeUpdate.serverInstances.push_back(serverInstance); + nodeUpdate.serverInstances.push_back(move(serverInstance)); update.nodes.push_back(nodeUpdate); admin->updateApplication(update); info = admin->getServerInfo("Server"); @@ -994,8 +971,7 @@ allTests(Test::TestHelper* helper) nodeUpdate.name = "node1"; nodeUpdate.serverInstances.clear(); nodeUpdate.propertySets["NodePropertySet"].properties.clear(); - nodeUpdate.propertySets["NodePropertySet"].properties.push_back( - createProperty("NodeProp", "updated")); + nodeUpdate.propertySets["NodePropertySet"].properties.push_back(PropertyDescriptor{ "NodeProp", "updated" }); nodeUpdate.removePropertySets.push_back("NodePropertySet1"); update.nodes.push_back(nodeUpdate); admin->updateApplication(update); @@ -1008,7 +984,7 @@ allTests(Test::TestHelper* helper) update = empty; update.propertySets["ApplicationPropertySet"].properties.clear(); update.propertySets["ApplicationPropertySet"].properties.push_back( - createProperty("ApplicationProp", "updated")); + PropertyDescriptor{ "ApplicationProp", "updated" }); update.removePropertySets.push_back("ApplicationPropertySet1"); admin->updateApplication(update); info = admin->getServerInfo("Server"); @@ -1053,7 +1029,7 @@ allTests(Test::TestHelper* helper) testApp = admin->getApplicationInfo("TestApp").descriptor; test(testApp.description == "Description"); - update.description = new BoxedString("updatedDescription"); + update.description = make_shared<BoxedString>("updatedDescription"); try { admin->updateApplication(update); @@ -1066,7 +1042,7 @@ allTests(Test::TestHelper* helper) testApp = admin->getApplicationInfo("TestApp").descriptor; test(testApp.description == "updatedDescription"); - update.description = new BoxedString(""); + update.description = make_shared<BoxedString>(""); try { admin->updateApplication(update); @@ -1090,18 +1066,20 @@ allTests(Test::TestHelper* helper) ApplicationDescriptor nodeApp; nodeApp.name = "NodeApp"; - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); server->id = "node-${index}"; server->exe = properties->getProperty("IceGridNodeExe"); server->pwd = "."; server->allocatable = false; server->options.push_back("--nowarn"); - addProperty(server, "IceGrid.Node.Name", "node-${index}"); - addProperty(server, "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-${index}"); - addProperty(server, "IceGrid.Node.Endpoints", "default"); - addProperty(server, "IceGrid.Node.PropertiesOverride", properties->getProperty("NodePropertiesOverride")); - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "IceGrid.Node.Name", "node-${index}" }); + server->propertySet.properties.push_back( + PropertyDescriptor{ "IceGrid.Node.Data", properties->getProperty("TestDir") + "/db/node-${index}" }); + server->propertySet.properties.push_back(PropertyDescriptor{ "IceGrid.Node.Endpoints", "default" }); + server->propertySet.properties.push_back( + PropertyDescriptor{ "IceGrid.Node.PropertiesOverride", properties->getProperty("NodePropertiesOverride") }); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); nodeApp.serverTemplates["nodeTemplate"].descriptor = server; nodeApp.serverTemplates["nodeTemplate"].parameters.push_back("index"); @@ -1111,7 +1089,7 @@ allTests(Test::TestHelper* helper) instance.parameterValues["index"] = "1"; nodeApp.nodes["localnode"].serverInstances.push_back(instance); instance.parameterValues["index"] = "2"; - nodeApp.nodes["localnode"].serverInstances.push_back(instance); + nodeApp.nodes["localnode"].serverInstances.push_back(move(instance)); try { @@ -1144,7 +1122,7 @@ allTests(Test::TestHelper* helper) catch(const NodeNotExistException&) { } - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); + this_thread::sleep_for(500ms); ++retry; } test(admin->pingNode("node-1")); @@ -1152,19 +1130,19 @@ allTests(Test::TestHelper* helper) ApplicationDescriptor testApp; testApp.name = "TestApp"; - server = new ServerDescriptor(); + server = make_shared<ServerDescriptor>(); server->id = "Server"; server->exe = properties->getProperty("ServerDir") + "/server"; server->pwd = "."; server->allocatable = false; - addProperty(server, "Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); + server->propertySet.properties.push_back(PropertyDescriptor{ "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }); AdapterDescriptor adapter; adapter.name = "Server"; adapter.id = "ServerAdapter"; adapter.registerProcess = false; adapter.serverLifetime = true; - server->adapters.push_back(adapter); - addProperty(server, "Server.Endpoints", "default"); + server->adapters.push_back(move(adapter)); + server->propertySet.properties.push_back(PropertyDescriptor{ "Server.Endpoints", "default" }); testApp.nodes["node-1"].servers.push_back(server); try @@ -1180,7 +1158,7 @@ allTests(Test::TestHelper* helper) try { admin->startServer("Server"); - test(admin->getServerState("Server") == Active); + test(admin->getServerState("Server") == ServerState::Active); } catch(const ServerStartException& ex) { @@ -1203,7 +1181,7 @@ allTests(Test::TestHelper* helper) nodeUpdate.name = "node-2"; nodeUpdate.servers.push_back(server); nodeUpdate.removeServers.clear(); - update.nodes.push_back(nodeUpdate); + update.nodes.push_back(move(nodeUpdate)); try { @@ -1218,19 +1196,19 @@ allTests(Test::TestHelper* helper) { try { - test(admin->getServerInfo("Server").node == "node-2" && admin->getServerState("Server") == Inactive); + test(admin->getServerInfo("Server").node == "node-2" && admin->getServerState("Server") == ServerState::Inactive); admin->startServer("Server"); - test(admin->getServerState("Server") == Active); + test(admin->getServerState("Server") == ServerState::Active); break; } catch(const DeploymentException&) { - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } } - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); + this_thread::sleep_for(1s); update = ApplicationUpdateDescriptor(); update.name = "TestApp"; @@ -1240,8 +1218,8 @@ allTests(Test::TestHelper* helper) update.nodes.push_back(nodeUpdate); nodeUpdate = NodeUpdateDescriptor(); nodeUpdate.name = "unknownNode"; - nodeUpdate.servers.push_back(server); - update.nodes.push_back(nodeUpdate); + nodeUpdate.servers.push_back(move(server)); + update.nodes.push_back(move(nodeUpdate)); try { diff --git a/cpp/test/IceGrid/update/Client.cpp b/cpp/test/IceGrid/update/Client.cpp index 0d88f5c27be..91e32f73e0d 100644 --- a/cpp/test/IceGrid/update/Client.cpp +++ b/cpp/test/IceGrid/update/Client.cpp @@ -8,18 +8,18 @@ using namespace std; -class Client : public Test::TestHelper +class Client final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Client::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); - communicator->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv); + communicatorHolder->getProperties()->parseCommandLineOptions("", Ice::argsToStringSeq(argc, argv)); void allTests(Test::TestHelper*); allTests(this); } diff --git a/cpp/test/IceGrid/update/Server.cpp b/cpp/test/IceGrid/update/Server.cpp index 6cb98a3566b..c1a5e03658d 100644 --- a/cpp/test/IceGrid/update/Server.cpp +++ b/cpp/test/IceGrid/update/Server.cpp @@ -8,23 +8,22 @@ using namespace std; -class Server : public Test::TestHelper +class Server final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Server::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); - Ice::PropertiesPtr properties = communicator->getProperties(); - string name = properties->getProperty("Ice.ProgramName"); + Ice::CommunicatorHolder communicatorHolder = initialize(argc, argv); + auto properties = communicatorHolder->getProperties(); + auto name = properties->getProperty("Ice.ProgramName"); - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Server"); - Ice::ObjectPtr object = new TestI(properties); - adapter->add(object, Ice::stringToIdentity(name)); + auto adapter = communicatorHolder->createObjectAdapter("Server"); + adapter->add(make_shared<TestI>(move(properties)), Ice::stringToIdentity(name)); try { @@ -33,7 +32,7 @@ Server::run(int argc, char** argv) catch(const Ice::ObjectAdapterDeactivatedException&) { } - communicator->waitForShutdown(); + communicatorHolder->waitForShutdown(); } DEFINE_TEST(Server) diff --git a/cpp/test/IceGrid/update/TestI.cpp b/cpp/test/IceGrid/update/TestI.cpp index f91a7ac44b2..d4c0a856036 100644 --- a/cpp/test/IceGrid/update/TestI.cpp +++ b/cpp/test/IceGrid/update/TestI.cpp @@ -5,8 +5,10 @@ #include <Ice/Ice.h> #include <TestI.h> -TestI::TestI(const Ice::PropertiesPtr& properties) : - _properties(properties) +using namespace std; + +TestI::TestI(shared_ptr<Ice::Properties>&& properties) : + _properties(move(properties)) { } @@ -16,8 +18,8 @@ TestI::shutdown(const Ice::Current& current) current.adapter->getCommunicator()->shutdown(); } -std::string -TestI::getProperty(const std::string& name, const Ice::Current&) +string +TestI::getProperty(string name, const Ice::Current&) { return _properties->getProperty(name); } diff --git a/cpp/test/IceGrid/update/TestI.h b/cpp/test/IceGrid/update/TestI.h index 1fcf402f93d..045914921e1 100644 --- a/cpp/test/IceGrid/update/TestI.h +++ b/cpp/test/IceGrid/update/TestI.h @@ -7,18 +7,18 @@ #include <Test.h> -class TestI : public ::Test::TestIntf +class TestI final : public ::Test::TestIntf { public: - TestI(const Ice::PropertiesPtr&); + TestI(std::shared_ptr<Ice::Properties>&&); - virtual void shutdown(const Ice::Current&); - virtual std::string getProperty(const std::string&, const Ice::Current&); + void shutdown(const Ice::Current&) override; + std::string getProperty(std::string, const Ice::Current&) override; private: - Ice::PropertiesPtr _properties; + std::shared_ptr<Ice::Properties> _properties; }; #endif diff --git a/cpp/test/IceStorm/federation/Publisher.cpp b/cpp/test/IceStorm/federation/Publisher.cpp index a08a327b0e5..6bdfbebf08c 100644 --- a/cpp/test/IceStorm/federation/Publisher.cpp +++ b/cpp/test/IceStorm/federation/Publisher.cpp @@ -12,7 +12,7 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class Publisher : public Test::TestHelper +class Publisher final : public Test::TestHelper { public: @@ -23,8 +23,8 @@ void Publisher::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - PropertiesPtr properties = communicator->getProperties(); - const string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); + auto properties = communicator->getProperties(); + auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { ostringstream os; @@ -32,8 +32,8 @@ Publisher::run(int argc, char** argv) throw runtime_error(os.str()); } - ObjectPrx base = communicator->stringToProxy(managerProxy); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy(managerProxy); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { ostringstream os; @@ -41,13 +41,13 @@ Publisher::run(int argc, char** argv) throw runtime_error(os.str()); } - TopicPrx fed1 = manager->retrieve("fed1"); - TopicPrx fed2 = manager->retrieve("fed2"); - TopicPrx fed3 = manager->retrieve("fed3"); + auto fed1 = manager->retrieve("fed1"); + auto fed2 = manager->retrieve("fed2"); + auto fed3 = manager->retrieve("fed3"); - EventPrx eventFed1 = EventPrx::uncheckedCast(fed1->getPublisher()->ice_oneway()); - EventPrx eventFed2 = EventPrx::uncheckedCast(fed2->getPublisher()->ice_oneway()); - EventPrx eventFed3 = EventPrx::uncheckedCast(fed3->getPublisher()->ice_oneway()); + auto eventFed1 = uncheckedCast<EventPrx>(fed1->getPublisher()->ice_oneway()); + auto eventFed2 = uncheckedCast<EventPrx>(fed2->getPublisher()->ice_oneway()); + auto eventFed3 = uncheckedCast<EventPrx>(fed3->getPublisher()->ice_oneway()); Ice::Context context; @@ -91,9 +91,9 @@ Publisher::run(int argc, char** argv) // Before we exit, we ping all proxies as twoway, to make sure // that all oneways are delivered. // - EventPrx::uncheckedCast(eventFed1->ice_twoway())->ice_ping(); - EventPrx::uncheckedCast(eventFed2->ice_twoway())->ice_ping(); - EventPrx::uncheckedCast(eventFed3->ice_twoway())->ice_ping(); + eventFed1->ice_twoway()->ice_ping(); + eventFed2->ice_twoway()->ice_ping(); + eventFed3->ice_twoway()->ice_ping(); } DEFINE_TEST(Publisher) diff --git a/cpp/test/IceStorm/federation/Subscriber.cpp b/cpp/test/IceStorm/federation/Subscriber.cpp index fabd871da38..21b866dd631 100644 --- a/cpp/test/IceStorm/federation/Subscriber.cpp +++ b/cpp/test/IceStorm/federation/Subscriber.cpp @@ -5,8 +5,6 @@ #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> #include <Event.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/MutexPtrLock.h> #include <TestHelper.h> using namespace std; @@ -14,55 +12,25 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class EventI : public Event +class EventI final : public Event { public: - virtual void - pub(const string&, const Ice::Current& current) + void + pub(string, const Ice::Current& current) override { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(_countMutex); - if(++_count == 30 + 40 + 30) { current.adapter->getCommunicator()->shutdown(); } } - static IceUtil::Mutex* _countMutex; - private: - static int _count; -}; - -typedef IceUtil::Handle<EventI> EventIPtr; - -int EventI::_count = 0; -IceUtil::Mutex* EventI::_countMutex = 0; - -namespace -{ - -class Init -{ -public: - - Init() - { - EventI::_countMutex = new IceUtil::Mutex; - } - - ~Init() - { - delete EventI::_countMutex; - EventI::_countMutex = 0; - } + static atomic_int _count; }; -Init init; - -} +atomic_int EventI::_count = 0; void usage(const char* appName) @@ -74,11 +42,11 @@ usage(const char* appName) "-b Use batch reliability.\n"; } -class Subscriber : public Test::TestHelper +class Subscriber final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -114,15 +82,15 @@ Subscriber::run(int argc, char** argv) } } - PropertiesPtr properties = communicator->getProperties(); - string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); + auto properties = communicator->getProperties(); + auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { throw runtime_error("property `IceStormAdmin.TopicManager.Default' is not set"); } - ObjectPrx base = communicator->stringToProxy(managerProxy); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy(managerProxy); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { ostringstream os; @@ -130,13 +98,13 @@ Subscriber::run(int argc, char** argv) throw runtime_error(os.str()); } - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default"); + auto adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default"); // // Activate the servants. // - ObjectPrx objFed1 = adapter->addWithUUID(new EventI()); - ObjectPrx objFed2 = adapter->addWithUUID(new EventI()); - ObjectPrx objFed3 = adapter->addWithUUID(new EventI()); + auto objFed1 = adapter->addWithUUID(make_shared<EventI>()); + auto objFed2 = adapter->addWithUUID(make_shared<EventI>()); + auto objFed3 = adapter->addWithUUID(make_shared<EventI>()); IceStorm::QoS qos; if(batch) @@ -152,9 +120,9 @@ Subscriber::run(int argc, char** argv) objFed3 = objFed1->ice_oneway(); } - TopicPrx fed1 = manager->retrieve("fed1"); - TopicPrx fed2 = manager->retrieve("fed2"); - TopicPrx fed3 = manager->retrieve("fed3"); + auto fed1 = manager->retrieve("fed1"); + auto fed2 = manager->retrieve("fed2"); + auto fed3 = manager->retrieve("fed3"); fed1->subscribeAndGetPublisher(qos, objFed1); fed2->subscribeAndGetPublisher(qos, objFed2); diff --git a/cpp/test/IceStorm/federation2/Publisher.cpp b/cpp/test/IceStorm/federation2/Publisher.cpp index 8b2b853286e..4ff73cf0f13 100644 --- a/cpp/test/IceStorm/federation2/Publisher.cpp +++ b/cpp/test/IceStorm/federation2/Publisher.cpp @@ -2,7 +2,6 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/IceUtil.h> #include <IceUtil/Options.h> #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> @@ -14,11 +13,11 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class Publisher : public Test::TestHelper +class Publisher final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -29,22 +28,22 @@ Publisher::run(int argc, char** argv) opts.addOpt("", "count", IceUtilInternal::Options::NeedArg); opts.parse(argc, (const char**)argv); - PropertiesPtr properties = communicator->getProperties(); - string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); + auto properties = communicator->getProperties(); + auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { throw runtime_error("property `IceStormAdmin.TopicManager.Default' is not set"); } - ObjectPrx base = communicator->stringToProxy(managerProxy); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy(managerProxy); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { throw runtime_error("`" + managerProxy + "' is not running"); } - TopicPrx fed1 = manager->retrieve("fed1"); - EventPrx eventFed1 = EventPrx::uncheckedCast(fed1->getPublisher()->ice_oneway()); + auto fed1 = manager->retrieve("fed1"); + auto eventFed1 = uncheckedCast<EventPrx>(fed1->getPublisher()->ice_oneway()); string arg = opts.optArg("count"); int count = 1; @@ -63,14 +62,14 @@ Publisher::run(int argc, char** argv) // Before we exit, we ping all proxies as twoway, to make sure // that all oneways are delivered. // - EventPrx::uncheckedCast(eventFed1->ice_twoway())->ice_ping(); + eventFed1->ice_twoway()->ice_ping(); if(count == 0) { break; } --count; - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); + this_thread::sleep_for(1s); } } diff --git a/cpp/test/IceStorm/federation2/Subscriber.cpp b/cpp/test/IceStorm/federation2/Subscriber.cpp index 510c3e61e13..9e50e410459 100644 --- a/cpp/test/IceStorm/federation2/Subscriber.cpp +++ b/cpp/test/IceStorm/federation2/Subscriber.cpp @@ -5,8 +5,6 @@ #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> #include <Event.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/MutexPtrLock.h> #include <TestHelper.h> #include <fcntl.h> @@ -23,14 +21,14 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class EventI : public Event +class EventI final : public Event { public: - virtual void - pub(const string&, const Ice::Current& current) + void + pub(string, const Ice::Current& current) override { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(_countMutex); + lock_guard<mutex> lg(countMutex); if(++_count == 10) { @@ -38,40 +36,15 @@ public: } } - static IceUtil::Mutex* _countMutex; + static mutex countMutex; private: static int _count; }; -typedef IceUtil::Handle<EventI> EventIPtr; - int EventI::_count = 0; -IceUtil::Mutex* EventI::_countMutex = 0; - -namespace -{ - -class Init -{ -public: - - Init() - { - EventI::_countMutex = new IceUtil::Mutex; - } - - ~Init() - { - delete EventI::_countMutex; - EventI::_countMutex = 0; - } -}; - -Init init; - -} +mutex EventI::countMutex; void usage(const char* appName) @@ -84,11 +57,11 @@ usage(const char* appName) ; } -class Subscriber : public Test::TestHelper +class Subscriber final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -124,8 +97,8 @@ Subscriber::run(int argc, char** argv) } } - PropertiesPtr properties = communicator->getProperties(); - const string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); + auto properties = communicator->getProperties(); + auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { ostringstream os; @@ -133,8 +106,8 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectPrx base = communicator->stringToProxy(managerProxy); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy(managerProxy); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { ostringstream os; @@ -142,12 +115,12 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default"); + auto adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default"); // // Activate the servants. // - ObjectPrx obj = adapter->addWithUUID(new EventI()); + auto obj = adapter->addWithUUID(make_shared<EventI>()); IceStorm::QoS qos; if(batch) @@ -159,7 +132,7 @@ Subscriber::run(int argc, char** argv) obj = obj->ice_oneway(); } - TopicPrx fed1 = manager->retrieve("fed1"); + auto fed1 = manager->retrieve("fed1"); fed1->subscribeAndGetPublisher(qos, obj); diff --git a/cpp/test/IceStorm/persistent/Client.cpp b/cpp/test/IceStorm/persistent/Client.cpp index 4f86d352c64..94b7090e21b 100644 --- a/cpp/test/IceStorm/persistent/Client.cpp +++ b/cpp/test/IceStorm/persistent/Client.cpp @@ -11,19 +11,19 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class Client : public Test::TestHelper +class Client final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Client::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - PropertiesPtr properties = communicator->getProperties(); - string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); + auto properties = communicator->getProperties(); + auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { ostringstream os; @@ -31,8 +31,8 @@ Client::run(int argc, char** argv) throw invalid_argument(os.str()); } - IceStorm::TopicManagerPrx manager = - IceStorm::TopicManagerPrx::checkedCast(communicator->stringToProxy(managerProxy)); + auto manager = + checkedCast<IceStorm::TopicManagerPrx>(communicator->stringToProxy(managerProxy)); if(!manager) { ostringstream os; @@ -52,12 +52,12 @@ Client::run(int argc, char** argv) // Create topics // cerr << "creating topics and links..." << flush; - TopicPrx linkTo = 0; + shared_ptr<TopicPrx> linkTo; for(int i = 0; i < 10; ++i) { ostringstream topicName; topicName << "topic" << i; - TopicPrx topic = manager->create(topicName.str()); + auto topic = manager->create(topicName.str()); if(linkTo) { topic->link(linkTo, i + 1); @@ -74,7 +74,7 @@ Client::run(int argc, char** argv) { ostringstream topicName; topicName << "topic" << i; - TopicPrx topic = manager->retrieve(topicName.str()); + auto topic = manager->retrieve(topicName.str()); test(topic); ostringstream subscriber; diff --git a/cpp/test/IceStorm/rep1/Publisher.cpp b/cpp/test/IceStorm/rep1/Publisher.cpp index 479d0806f2c..e7200e25c47 100644 --- a/cpp/test/IceStorm/rep1/Publisher.cpp +++ b/cpp/test/IceStorm/rep1/Publisher.cpp @@ -4,7 +4,6 @@ #include <Ice/Ice.h> #include <IceUtil/Options.h> -#include <IceUtil/IceUtil.h> #include <IceStorm/IceStorm.h> #include <TestHelper.h> #include <Single.h> @@ -14,11 +13,11 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class Publisher : public Test::TestHelper +class Publisher final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -39,8 +38,8 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - PropertiesPtr properties = communicator->getProperties(); - string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); + auto properties = communicator->getProperties(); + auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { ostringstream os; @@ -48,7 +47,7 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( + auto manager = checkedCast<IceStorm::TopicManagerPrx>( communicator->stringToProxy(managerProxy)); if(!manager) { @@ -57,7 +56,7 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - TopicPrx topic; + shared_ptr<TopicPrx> topic; while(true) { try @@ -86,16 +85,16 @@ Publisher::run(int argc, char** argv) // if(opts.isSet("cycle")) { - Ice::ObjectPrx prx = topic->getPublisher()->ice_twoway(); - vector<SinglePrx> single; - Ice::EndpointSeq endpoints = prx->ice_getEndpoints(); - for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) + auto prx = uncheckedCast<SinglePrx>(topic->getPublisher()->ice_twoway()); + vector<shared_ptr<SinglePrx>> single; + auto endpoints = prx->ice_getEndpoints(); + for(const auto& p: endpoints) { - if((*p)->toString().substr(0, 3) != "udp") + if(p->toString().substr(0, 3) != "udp") { Ice::EndpointSeq e; - e.push_back(*p); - single.push_back(SinglePrx::uncheckedCast(prx->ice_endpoints(e))); + e.push_back(p); + single.push_back(prx->ice_endpoints(e)); } } if(single.size() <= 1) @@ -107,13 +106,13 @@ Publisher::run(int argc, char** argv) size_t which = 0; for(size_t i = 0; i < 1000; ++i) { - single[which]->event(static_cast<Ice::Int>(i)); + single[which]->event(static_cast<int>(i)); which = (which + 1) % single.size(); } } else { - SinglePrx single = SinglePrx::uncheckedCast(topic->getPublisher()->ice_twoway()); + auto single = uncheckedCast<SinglePrx>(topic->getPublisher()->ice_twoway()); for(int i = 0; i < 1000; ++i) { single->event(i); diff --git a/cpp/test/IceStorm/rep1/Sub.cpp b/cpp/test/IceStorm/rep1/Sub.cpp index f7a62cd15e8..115b8c89009 100644 --- a/cpp/test/IceStorm/rep1/Sub.cpp +++ b/cpp/test/IceStorm/rep1/Sub.cpp @@ -2,7 +2,6 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/IceUtil.h> #include <IceUtil/Options.h> #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> @@ -14,19 +13,20 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class SingleI : public Single +class SingleI final : public Single { public: - SingleI() {} - virtual void event(int, const Current&) {} + void event(int, const Current&) override + { + } }; -class Sub : public Test::TestHelper +class Sub final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -48,8 +48,8 @@ Sub::run(int argc, char** argv) throw invalid_argument(os.str()); } - PropertiesPtr properties = communicator->getProperties(); - string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); + auto properties = communicator->getProperties(); + auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { ostringstream os; @@ -57,8 +57,8 @@ Sub::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectPrx base = communicator->stringToProxy(managerProxy); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy(managerProxy); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { ostringstream os; @@ -66,11 +66,11 @@ Sub::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default"); + auto adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default"); - TopicPrx topic = manager->retrieve("single"); + auto topic = manager->retrieve("single"); - Ice::ObjectPrx prx = adapter->add(new SingleI(), stringToIdentity(opts.optArg("id"))); + auto prx = adapter->add(make_shared<SingleI>(), stringToIdentity(opts.optArg("id"))); if(opts.isSet("unsub")) { topic->unsubscribe(prx); diff --git a/cpp/test/IceStorm/rep1/Subscriber.cpp b/cpp/test/IceStorm/rep1/Subscriber.cpp index 9f567c24b95..57167dd4f50 100644 --- a/cpp/test/IceStorm/rep1/Subscriber.cpp +++ b/cpp/test/IceStorm/rep1/Subscriber.cpp @@ -2,7 +2,6 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/IceUtil.h> #include <IceUtil/Options.h> #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> @@ -14,11 +13,11 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class SingleI : public Single, public IceUtil::Monitor<IceUtil::Mutex> +class SingleI final : public Single { public: - SingleI(const CommunicatorPtr& communicator, const string& name, int max) : + SingleI(const shared_ptr<Communicator>& communicator, const string& name, int max) : _communicator(communicator), _name(name), _max(max), @@ -27,30 +26,29 @@ public: { } - virtual void - event(int i, const Current&) + void + event(int i, const Current&) override { if(_name == "twoway ordered" && i != _last) { cerr << endl << "received unordered event for `" << _name << "': " << i << " " << _last; test(false); } - Lock sync(*this); + lock_guard<mutex> lg(_mutex); ++_last; if(++_count == _max) { - notify(); + _condVar.notify_one(); } } - virtual void + void waitForEvents() { - Lock sync(*this); - IceUtil::Time timeout = IceUtil::Time::seconds(40); + unique_lock<mutex> lock(_mutex); while(_count < _max) { - if(!timedWait(timeout)) + if(_condVar.wait_for(lock, 40s) == cv_status::timeout) { test(false); } @@ -59,19 +57,20 @@ public: private: - CommunicatorPtr _communicator; + shared_ptr<Communicator> _communicator; const string _name; const int _max; int _count; int _last; + mutex _mutex; + condition_variable _condVar; }; -typedef IceUtil::Handle<SingleI> SingleIPtr; -class Subscriber : public Test::TestHelper +class Subscriber final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -94,8 +93,8 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - PropertiesPtr properties = communicator->getProperties(); - string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); + auto properties = communicator->getProperties(); + auto managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { ostringstream os; @@ -103,8 +102,8 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectPrx base = communicator->stringToProxy(managerProxy); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy(managerProxy); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { ostringstream os; @@ -112,9 +111,9 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default"); + auto adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default"); - TopicPrx topic; + shared_ptr<TopicPrx> topic; while(true) { try @@ -144,19 +143,19 @@ Subscriber::run(int argc, char** argv) // // Create subscribers with different QoS. // - SingleIPtr sub; + shared_ptr<SingleI> sub; IceStorm::QoS qos; if(opts.isSet("ordered")) { - sub = new SingleI(communicator.communicator(), "twoway ordered", events); + sub = make_shared<SingleI>(communicator.communicator(), "twoway ordered", events); qos["reliability"] = "ordered"; } else { - sub = new SingleI(communicator.communicator(), "twoway", events); + sub = make_shared<SingleI>(communicator.communicator(), "twoway", events); } - Ice::ObjectPrx prx = adapter->addWithUUID(sub); + auto prx = adapter->addWithUUID(sub); while(true) { diff --git a/cpp/test/IceStorm/repgrid/Client.cpp b/cpp/test/IceStorm/repgrid/Client.cpp index 12d1c751138..004945ab745 100644 --- a/cpp/test/IceStorm/repgrid/Client.cpp +++ b/cpp/test/IceStorm/repgrid/Client.cpp @@ -12,33 +12,27 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class SingleI : public Single, public IceUtil::Monitor<IceUtil::Mutex> +class SingleI final : public Single { public: - SingleI() : - _count(0) + void + event(int, const Current&) override { - } - - virtual void - event(int, const Current&) - { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); if(++_count == 1000) { - notify(); + _condVar.notify_one(); } } - virtual void + void waitForEvents() { - Lock sync(*this); - IceUtil::Time timeout = IceUtil::Time::seconds(20); + unique_lock<mutex> lock(_mutex); while(_count < 1000) { - if(!timedWait(timeout)) + if(_condVar.wait_for(lock, 20s) == cv_status::timeout) { test(false); } @@ -47,23 +41,24 @@ public: private: - int _count; + int _count = 0; + mutex _mutex; + condition_variable _condVar; }; -typedef IceUtil::Handle<SingleI> SingleIPtr; -class Client : public Test::TestHelper +class Client final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Client::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - ObjectPrx base = communicator->stringToProxy("Test.IceStorm/TopicManager"); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy("Test.IceStorm/TopicManager"); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { ostringstream os; @@ -71,22 +66,22 @@ Client::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default:udp"); + auto adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default:udp"); - TopicPrx topic = manager->create("single"); + auto topic = manager->create("single"); // // Create subscribers with different QoS. // - SingleIPtr sub = new SingleI; + auto sub = make_shared<SingleI>(); topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(sub)); adapter->activate(); // Ensure that getPublisher & getNonReplicatedPublisher work // correctly. - Ice::ObjectPrx p1 = topic->getPublisher(); - Ice::ObjectPrx p2 = topic->getNonReplicatedPublisher(); + auto p1 = topic->getPublisher(); + auto p2 = topic->getNonReplicatedPublisher(); test(p1->ice_getAdapterId() == "PublishReplicaGroup"); test(p2->ice_getAdapterId() == "Test.IceStorm1.Publish" || p2->ice_getAdapterId() == "Test.IceStorm2.Publish" || @@ -96,7 +91,7 @@ Client::run(int argc, char** argv) // Get a publisher object, create a twoway proxy and then cast to // a Single object. // - SinglePrx single = SinglePrx::uncheckedCast(topic->getPublisher()->ice_twoway()); + auto single = uncheckedCast<SinglePrx>(topic->getPublisher()->ice_twoway()); for(int i = 0; i < 1000; ++i) { single->event(i); diff --git a/cpp/test/IceStorm/repstress/Control.cpp b/cpp/test/IceStorm/repstress/Control.cpp index 1f63f5bf4dc..c8da41bf746 100644 --- a/cpp/test/IceStorm/repstress/Control.cpp +++ b/cpp/test/IceStorm/repstress/Control.cpp @@ -10,11 +10,11 @@ using namespace std; using namespace Ice; using namespace Test; -class Control : public Test::TestHelper +class Control final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -28,7 +28,7 @@ Control::run(int argc, char** argv) throw invalid_argument(os.str()); } - ControllerPrx control = ControllerPrx::uncheckedCast(communicator->stringToProxy(argv[1])); + auto control = uncheckedCast<ControllerPrx>(communicator->stringToProxy(argv[1])); control->stop(); } diff --git a/cpp/test/IceStorm/repstress/Publisher.cpp b/cpp/test/IceStorm/repstress/Publisher.cpp index 65fda890f83..32da8474ddd 100644 --- a/cpp/test/IceStorm/repstress/Publisher.cpp +++ b/cpp/test/IceStorm/repstress/Publisher.cpp @@ -3,7 +3,6 @@ // #include <Ice/Ice.h> -#include <IceUtil/IceUtil.h> #include <IceStorm/IceStorm.h> #include <Single.h> #include <Controller.h> @@ -14,33 +13,33 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class ControllerI : public Controller +class ControllerI final : public Controller { public: - virtual void stop(const Ice::Current& c) + void stop(const Ice::Current& c) override { c.adapter->getCommunicator()->shutdown(); } }; -class PublishThread : public IceUtil::Thread, public IceUtil::Mutex +class PublishThread final { public: - PublishThread(const SinglePrx& single) : - _single(single), + explicit PublishThread(shared_ptr<SinglePrx> single) : + _single(std::move(single)), _published(0), _destroy(false) { } - virtual void run() + void run() { while(true) { { - Lock sync(*this); + lock_guard<mutex> log(_mutex); if(_destroy) { cout << _published << endl; @@ -50,7 +49,7 @@ public: try { _single->event(_published); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1)); + this_thread::sleep_for(1ms); } catch(const Ice::UnknownException&) { @@ -64,31 +63,30 @@ public: void destroy() { - Lock sync(*this); + lock_guard<mutex> log(_mutex); _destroy = true; } private: - const SinglePrx _single; + const shared_ptr<SinglePrx> _single; int _published; bool _destroy; + mutex _mutex; }; -typedef IceUtil::Handle<PublishThread> PublishThreadPtr; -class Publisher : public Test::TestHelper +class Publisher final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Publisher::run(int argc, char** argv) { - Ice::CommunicatorHolder communicator = initialize(argc, argv); - PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { @@ -97,7 +95,7 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( + auto manager = checkedCast<IceStorm::TopicManagerPrx>( communicator->stringToProxy(managerProxy)); if(!manager) { @@ -106,27 +104,27 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - TopicPrx topic = manager->retrieve("single"); + auto topic = manager->retrieve("single"); assert(topic); // // Get a publisher object, create a twoway proxy, disable // connection caching and then cast to a Single object. // - SinglePrx single = SinglePrx::uncheckedCast(topic->getPublisher()->ice_twoway()->ice_connectionCached(false)); + auto single = uncheckedCast<SinglePrx>(topic->getPublisher()->ice_twoway()->ice_connectionCached(false)); - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("ControllerAdapter", "tcp"); - Ice::ObjectPrx controller = adapter->addWithUUID(new ControllerI); + auto adapter = communicator->createObjectAdapterWithEndpoints("ControllerAdapter", "tcp"); + auto controller = adapter->addWithUUID(make_shared<ControllerI>()); adapter->activate(); cout << communicator->proxyToString(controller) << endl; - PublishThreadPtr t = new PublishThread(single); - t->start(); + PublishThread pt(move(single)); + auto fut = std::async(launch::async, [&pt]{ pt.run(); }); communicator->waitForShutdown(); - t->destroy(); - t->getThreadControl().join(); + pt.destroy(); + fut.get(); } DEFINE_TEST(Publisher) diff --git a/cpp/test/IceStorm/repstress/Subscriber.cpp b/cpp/test/IceStorm/repstress/Subscriber.cpp index 10f2a028014..957893c880d 100644 --- a/cpp/test/IceStorm/repstress/Subscriber.cpp +++ b/cpp/test/IceStorm/repstress/Subscriber.cpp @@ -2,7 +2,6 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include <IceUtil/IceUtil.h> #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> #include <Single.h> @@ -14,57 +13,49 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class ControllerI : public Controller +class ControllerI final : public Controller { public: - virtual void stop(const Ice::Current& c) + void stop(const Ice::Current& c) override { c.adapter->getCommunicator()->shutdown(); } }; -class SingleI : public Single, public IceUtil::Monitor<IceUtil::Mutex> +class SingleI final : public Single { public: - SingleI() : - _nevents(0) + void + event(int, const Current&) override { - } - - virtual void - event(int, const Current&) - { - Lock sync(*this); ++_nevents; } int nevents() const { - Lock sync(*this); return _nevents; } private: - int _nevents; + atomic_int _nevents = 0; }; -typedef IceUtil::Handle<SingleI> SingleIPtr; -class Subscriber : public Test::TestHelper +class Subscriber final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Subscriber::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { @@ -73,8 +64,8 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectPrx base = communicator->stringToProxy(managerProxy); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy(managerProxy); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { ostringstream os; @@ -82,12 +73,12 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default"); - TopicPrx topic = manager->retrieve("single"); + auto adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default"); + auto topic = manager->retrieve("single"); - SingleIPtr sub = new SingleI(); - Ice::ObjectPrx prx = adapter->addWithUUID(sub); - Ice::ObjectPrx control = adapter->addWithUUID(new ControllerI); + auto sub = make_shared<SingleI>(); + auto prx = adapter->addWithUUID(sub); + auto control = adapter->addWithUUID(make_shared<ControllerI>()); IceStorm::QoS qos; diff --git a/cpp/test/IceStorm/single/Publisher.cpp b/cpp/test/IceStorm/single/Publisher.cpp index abe715961b2..9ff0d1c8b33 100644 --- a/cpp/test/IceStorm/single/Publisher.cpp +++ b/cpp/test/IceStorm/single/Publisher.cpp @@ -12,18 +12,18 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class Publisher : public Test::TestHelper +class Publisher final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Publisher::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { @@ -32,7 +32,7 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( + auto manager = checkedCast<IceStorm::TopicManagerPrx>( communicator->stringToProxy(managerProxy)); if(!manager) { @@ -41,14 +41,14 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - TopicPrx topic = manager->retrieve("single"); + auto topic = manager->retrieve("single"); assert(topic); // // Get a publisher object, create a twoway proxy and then cast to // a Single object. // - SinglePrx single = SinglePrx::uncheckedCast(topic->getPublisher()->ice_twoway()); + auto single = uncheckedCast<SinglePrx>(topic->getPublisher()->ice_twoway()); for(int i = 0; i < 1000; ++i) { single->event(i); diff --git a/cpp/test/IceStorm/single/Subscriber.cpp b/cpp/test/IceStorm/single/Subscriber.cpp index edf4ccc0b61..9e71d9070a0 100644 --- a/cpp/test/IceStorm/single/Subscriber.cpp +++ b/cpp/test/IceStorm/single/Subscriber.cpp @@ -12,7 +12,7 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class SingleI : public Single, public IceUtil::Monitor<IceUtil::Mutex> +class SingleI final : public Single { public: @@ -23,8 +23,8 @@ public: { } - virtual void - event(int i, const Current& current) + void + event(int i, const Current& current) override { if((_name == "default" || _name == "oneway" || _name == "batch" || _name == "datagram" || _name == "batch datagram") && current.requestId != 0) @@ -46,7 +46,7 @@ public: cerr << endl << "expected datagram to be received over udp"; test(false); } - Lock sync(*this); + lock_guard<mutex> lg(_mutex); if(_name == "per-request load balancing") { _connections.insert(current.con); @@ -54,19 +54,19 @@ public: ++_last; if(++_count == 1000) { - notify(); + _condVar.notify_one(); } } - virtual void + void waitForEvents() { - Lock sync(*this); + unique_lock<mutex> lock(_mutex); cout << "testing " << _name << " ... " << flush; bool datagram = _name == "datagram" || _name == "batch datagram"; while(_count < 1000) { - if(!timedWait(IceUtil::Time::seconds(30))) + if(_condVar.wait_for(lock, 30s) == cv_status::timeout) { if(datagram && _count > 0) { @@ -98,22 +98,23 @@ private: const string _name; int _count; int _last; - set<Ice::ConnectionPtr> _connections; + set<shared_ptr<Ice::Connection>> _connections; + mutex _mutex; + condition_variable _condVar; }; -typedef IceUtil::Handle<SingleI> SingleIPtr; -class Subscriber : public Test::TestHelper +class Subscriber final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void Subscriber::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); - PropertiesPtr properties = communicator->getProperties(); + auto properties = communicator->getProperties(); string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { @@ -122,8 +123,8 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - ObjectPrx base = communicator->stringToProxy(managerProxy); - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); + auto base = communicator->stringToProxy(managerProxy); + auto manager = checkedCast<IceStorm::TopicManagerPrx>(base); if(!manager) { ostringstream os; @@ -132,7 +133,7 @@ Subscriber::run(int argc, char** argv) } // Use 2 default endpoints to test per-request load balancing - ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default:default:udp"); + auto adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default:default:udp"); // // Test topic name that is too long @@ -149,7 +150,7 @@ Subscriber::run(int argc, char** argv) } } - TopicPrx topic = manager->retrieve("single"); + auto topic = manager->retrieve("single"); // // Test subscriber identity that is too long @@ -158,7 +159,7 @@ Subscriber::run(int argc, char** argv) { try { - Ice::ObjectPrx object = communicator->stringToProxy(string(512, 'A') + ":default -p 10000"); + auto object = communicator->stringToProxy(string(512, 'A') + ":default -p 10000"); topic->subscribeAndGetPublisher(IceStorm::QoS(), object); test(false); } @@ -170,48 +171,48 @@ Subscriber::run(int argc, char** argv) // // Create subscribers with different QoS. // - vector<SingleIPtr> subscribers; + vector<shared_ptr<SingleI>> subscribers; vector<Ice::Identity> subscriberIdentities; { - subscribers.push_back(new SingleI("default")); - Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back())->ice_oneway(); + subscribers.push_back(make_shared<SingleI>("default")); + auto object = adapter->addWithUUID(subscribers.back())->ice_oneway(); subscriberIdentities.push_back(object->ice_getIdentity()); topic->subscribeAndGetPublisher(IceStorm::QoS(), object); } { - subscribers.push_back(new SingleI("oneway")); - Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back())->ice_oneway(); + subscribers.push_back(make_shared<SingleI>("oneway")); + auto object = adapter->addWithUUID(subscribers.back())->ice_oneway(); subscriberIdentities.push_back(object->ice_getIdentity()); topic->subscribeAndGetPublisher(IceStorm::QoS(), object); } { - subscribers.push_back(new SingleI("twoway")); - Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back()); + subscribers.push_back(make_shared<SingleI>("twoway")); + auto object = adapter->addWithUUID(subscribers.back()); subscriberIdentities.push_back(object->ice_getIdentity()); topic->subscribeAndGetPublisher(IceStorm::QoS(), object); } { - subscribers.push_back(new SingleI("batch")); - Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back())->ice_batchOneway(); + subscribers.push_back(make_shared<SingleI>("batch")); + auto object = adapter->addWithUUID(subscribers.back())->ice_batchOneway(); subscriberIdentities.push_back(object->ice_getIdentity()); topic->subscribeAndGetPublisher(IceStorm::QoS(), object); } { - subscribers.push_back(new SingleI("twoway ordered")); // Ordered + subscribers.push_back(make_shared<SingleI>("twoway ordered")); // Ordered IceStorm::QoS qos; qos["reliability"] = "ordered"; - Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back()); + auto object = adapter->addWithUUID(subscribers.back()); subscriberIdentities.push_back(object->ice_getIdentity()); topic->subscribeAndGetPublisher(qos, object); } { - subscribers.push_back(new SingleI("per-request load balancing")); + subscribers.push_back(make_shared<SingleI>("per-request load balancing")); IceStorm::QoS qos; qos["locatorCacheTimeout"] = "10"; qos["connectionCached"] = "0"; - Ice::ObjectPrx object = adapter->addWithUUID(subscribers.back()); + auto object = adapter->addWithUUID(subscribers.back()); subscriberIdentities.push_back(object->ice_getIdentity()); topic->subscribeAndGetPublisher(qos, object); } @@ -220,9 +221,9 @@ Subscriber::run(int argc, char** argv) // (otherwise, if multiple UDP subscribers use the same connection we might get high // packet loss, see bug 1784). communicator->getProperties()->setProperty("UdpAdapter3.ThreadPool.Size", "1"); - ObjectAdapterPtr adpt = communicator->createObjectAdapterWithEndpoints("UdpAdapter3", "udp"); - subscribers.push_back(new SingleI("datagram")); - Ice::ObjectPrx object = adpt->addWithUUID(subscribers.back())->ice_datagram(); + auto adpt = communicator->createObjectAdapterWithEndpoints("UdpAdapter3", "udp"); + subscribers.push_back(make_shared<SingleI>("datagram")); + auto object = adpt->addWithUUID(subscribers.back())->ice_datagram(); subscriberIdentities.push_back(object->ice_getIdentity()); adpt->activate(); topic->subscribeAndGetPublisher(IceStorm::QoS(), object); @@ -232,9 +233,9 @@ Subscriber::run(int argc, char** argv) // (otherwise, if multiple UDP subscribers use the same connection we might get high // packet loss, see bug 1784). communicator->getProperties()->setProperty("UdpAdapter4.ThreadPool.Size", "1"); - ObjectAdapterPtr adpt = communicator->createObjectAdapterWithEndpoints("UdpAdapter4", "udp"); - subscribers.push_back(new SingleI("batch datagram")); - Ice::ObjectPrx object = adpt->addWithUUID(subscribers.back())->ice_batchDatagram(); + auto adpt = communicator->createObjectAdapterWithEndpoints("UdpAdapter4", "udp"); + subscribers.push_back(make_shared<SingleI>("batch datagram")); + auto object = adpt->addWithUUID(subscribers.back())->ice_batchDatagram(); subscriberIdentities.push_back(object->ice_getIdentity()); adpt->activate(); topic->subscribeAndGetPublisher(IceStorm::QoS(), object); @@ -244,14 +245,14 @@ Subscriber::run(int argc, char** argv) vector<Ice::Identity> ids = topic->getSubscribers(); test(ids.size() == subscriberIdentities.size()); - for(vector<Ice::Identity>::const_iterator i = ids.begin(); i != ids.end(); ++i) + for(const auto& p: ids) { - test(find(subscriberIdentities.begin(), subscriberIdentities.end(), *i) != subscriberIdentities.end()); + test(find(subscriberIdentities.begin(), subscriberIdentities.end(), p) != subscriberIdentities.end()); } - for(vector<SingleIPtr>::const_iterator p = subscribers.begin(); p != subscribers.end(); ++p) + for(const auto& p: subscribers) { - (*p)->waitForEvents(); + p->waitForEvents(); } } diff --git a/cpp/test/IceStorm/stress/Publisher.cpp b/cpp/test/IceStorm/stress/Publisher.cpp index 221d4c74d73..10b4c6feeb6 100644 --- a/cpp/test/IceStorm/stress/Publisher.cpp +++ b/cpp/test/IceStorm/stress/Publisher.cpp @@ -13,11 +13,11 @@ using namespace Ice; using namespace IceStorm; using namespace Test; -class Publisher : public Test::TestHelper +class Publisher final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -56,8 +56,8 @@ Publisher::run(int argc, char** argv) bool oneway = opts.isSet("oneway"); bool maxQueueTest = opts.isSet("maxQueueTest"); - PropertiesPtr properties = communicator->getProperties(); - const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default"; + auto properties = communicator->getProperties(); + string managerProxyProperty = "IceStormAdmin.TopicManager.Default"; string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { @@ -66,7 +66,7 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( + auto manager = checkedCast<IceStorm::TopicManagerPrx>( communicator->stringToProxy(managerProxy)); if(!manager) { @@ -75,13 +75,13 @@ Publisher::run(int argc, char** argv) throw invalid_argument(os.str()); } - TopicPrx topic = manager->retrieve("fed1"); + auto topic = manager->retrieve("fed1"); - EventPrx twowayProxy = EventPrx::uncheckedCast(topic->getPublisher()->ice_twoway()); - EventPrx proxy; + auto twowayProxy = uncheckedCast<EventPrx>(topic->getPublisher()->ice_twoway()); + shared_ptr<EventPrx> proxy; if(oneway) { - proxy = EventPrx::uncheckedCast(twowayProxy->ice_oneway()); + proxy = twowayProxy->ice_oneway(); } else { @@ -93,7 +93,7 @@ Publisher::run(int argc, char** argv) if(maxQueueTest && i == 10) { // Sleep one seconds to give some time to IceStorm to connect to the subscriber - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); + this_thread::sleep_for(1s); } proxy->pub(i); } diff --git a/cpp/test/IceStorm/stress/Subscriber.cpp b/cpp/test/IceStorm/stress/Subscriber.cpp index 77d5dd9e029..c7e3cdd3c2b 100644 --- a/cpp/test/IceStorm/stress/Subscriber.cpp +++ b/cpp/test/IceStorm/stress/Subscriber.cpp @@ -5,33 +5,29 @@ #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> #include <IceUtil/Options.h> -#include <IceUtil/Thread.h> -#include <IceUtil/Time.h> -#include <IceUtil/Random.h> #include <Event.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/MutexPtrLock.h> #include <TestHelper.h> +#include <random> using namespace std; using namespace Ice; using namespace IceStorm; using namespace Test; -struct Subscription; // Forward declaration. +struct Subscription; -class EventI : public Event, public IceUtil::Mutex +class EventI : public Event { public: - EventI(const CommunicatorPtr& communicator, int total) : - _communicator(communicator), _total(total), _count(0) + EventI(shared_ptr<Communicator> communicator, int total) : + _communicator(move(communicator)), _total(total), _count(0) { } - int count() const + int count() { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); return _count; } @@ -41,41 +37,36 @@ public: protected: - const CommunicatorPtr _communicator; + shared_ptr<Communicator> _communicator; const int _total; int _count; + mutex _mutex; }; -typedef IceUtil::Handle<EventI> EventIPtr; -struct Subscription +struct Subscription final { - Subscription() : activate(true) - { - } - - Ice::ObjectAdapterPtr adapter; - Ice::ObjectPrx obj; - EventIPtr servant; + shared_ptr<Ice::ObjectAdapter> adapter; + shared_ptr<Ice::ObjectPrx> obj; + shared_ptr<EventI> servant; IceStorm::QoS qos; - Ice::ObjectPrx publisher; - bool activate; + shared_ptr<Ice::ObjectPrx> publisher; + bool activate = true; }; -class OrderEventI : public EventI +class OrderEventI final : public EventI { public: - OrderEventI(const CommunicatorPtr& communicator, int total) : - EventI(communicator, total) + OrderEventI(shared_ptr<Communicator> communicator, int total) : + EventI(move(communicator), total) { } - virtual void - pub(int counter, const Ice::Current&) + void + pub(int counter, const Ice::Current&) override { - Lock sync(*this); - - if(counter != _count || counter == _total-1) + lock_guard<mutex> lg(_mutex); + if(counter != _count || counter == _total - 1) { if(counter != _count) { @@ -87,20 +78,19 @@ public: } }; -class CountEventI : public EventI +class CountEventI final : public EventI { public: - CountEventI(const CommunicatorPtr& communicator, int total) : - EventI(communicator, total) + CountEventI(shared_ptr<Communicator> communicator, int total) : + EventI(move(communicator), total) { } - virtual void - pub(int, const Ice::Current&) + void + pub(int, const Ice::Current&) override { - Lock sync(*this); - + lock_guard<mutex> lg(_mutex); if(++_count == _total) { _communicator->shutdown(); @@ -108,20 +98,19 @@ public: } }; -class SlowEventI : public EventI +class SlowEventI final : public EventI { public: - SlowEventI(const CommunicatorPtr& communicator, int total) : - EventI(communicator, total) + SlowEventI(shared_ptr<Communicator> communicator, int total) : + EventI(move(communicator), total) { } - virtual void - pub(int, const Ice::Current&) + void + pub(int, const Ice::Current&) override { - Lock sync(*this); - + lock_guard<mutex> lg(_mutex); // // Ignore events over and above the expected. // @@ -130,7 +119,7 @@ public: return; } // Sleep for 3 seconds - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(3)); + this_thread::sleep_for(3s); if(++_count == _total) { _communicator->shutdown(); @@ -138,35 +127,32 @@ public: } }; -class ErraticEventI : public EventI +class ErraticEventI final : public EventI { public: - ErraticEventI(const CommunicatorPtr& communicator, int total) : - EventI(communicator, total), _done(false) + ErraticEventI(shared_ptr<Communicator> communicator, int total) : + EventI(move(communicator), total) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(_remainingMutex); ++_remaining; } - virtual void - pub(int, const Ice::Current& current) + void + pub(int, const Ice::Current& current) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); // Randomly close the connection. - if(!_done && (IceUtilInternal::random(10) == 1 || ++_count == _total)) + if(!_done && (_rd() % 10 == 1 || ++_count == _total)) { _done = true; - current.con->close(ICE_SCOPED_ENUM(ConnectionClose, Forcefully)); + current.con->close(ConnectionClose::Forcefully); // Deactivate the OA. This ensures that the subscribers // that have subscribed with oneway QoS will be booted. current.adapter->deactivate(); _count = _total; { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync2(_remainingMutex); - --_remaining; - if(_remaining == 0) + if(--_remaining == 0) { _communicator->shutdown(); } @@ -174,30 +160,28 @@ public: } } - static IceUtil::Mutex* _remainingMutex; - private: - static int _remaining; - bool _done; + static atomic_int _remaining; + bool _done = false; + random_device _rd; }; -IceUtil::Mutex* ErraticEventI::_remainingMutex = 0; -int ErraticEventI::_remaining = 0; +atomic_int ErraticEventI::_remaining = 0; -class MaxQueueEventI : public EventI +class MaxQueueEventI final : public EventI { public: - MaxQueueEventI(const CommunicatorPtr& communicator, int expected, int total, bool removeSubscriber) : - EventI(communicator, total), _removeSubscriber(removeSubscriber), _expected(expected) + MaxQueueEventI(shared_ptr<Communicator> communicator, int expected, int total, bool removeSubscriber) : + EventI(move(communicator), total), _removeSubscriber(removeSubscriber), _expected(expected) { } - virtual void - pub(int counter, const Ice::Current&) + void + pub(int counter, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); if(counter != _count) { @@ -221,8 +205,8 @@ public: } } - virtual void - check(const Subscription& subscription) + void + check(const Subscription& subscription) override { if(_removeSubscriber) { @@ -236,7 +220,7 @@ public: while(--nRetry > 0) { subscription.publisher->ice_ping(); - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); + this_thread::sleep_for(200ms); } test(false); } @@ -252,19 +236,19 @@ private: int _expected; }; -class ControllerEventI: public EventI +class ControllerEventI final : public EventI { public: - ControllerEventI(const CommunicatorPtr& communicator, int total, const Ice::ObjectAdapterPtr& adapter) : - EventI(communicator, total), _adapter(adapter) + ControllerEventI(shared_ptr<Communicator> communicator, int total, shared_ptr<ObjectAdapter> adapter) : + EventI(move(communicator), total), _adapter(move(adapter)) { } - virtual void - pub(int, const Ice::Current&) + void + pub(int, const Ice::Current&) override { - Lock sync(*this); + lock_guard<mutex> lg(_mutex); if(++_count == _total) { _adapter->activate(); @@ -273,37 +257,14 @@ public: private: - const Ice::ObjectAdapterPtr _adapter; -}; - -namespace -{ - -class Init -{ -public: - - Init() - { - ErraticEventI::_remainingMutex = new IceUtil::Mutex; - } - - ~Init() - { - delete ErraticEventI::_remainingMutex; - ErraticEventI::_remainingMutex = 0; - } + const shared_ptr<Ice::ObjectAdapter> _adapter; }; -Init init; - -} - -class Subscriber : public Test::TestHelper +class Subscriber final : public Test::TestHelper { public: - void run(int, char**); + void run(int, char**) override; }; void @@ -345,16 +306,16 @@ Subscriber::run(int argc, char** argv) IceStorm::QoS cmdLineQos; vector<string> sqos = opts.argVec("qos"); - for(vector<string>::const_iterator q = sqos.begin(); q != sqos.end(); ++q) + for(const auto& q: sqos) { - string::size_type off = q->find(","); + string::size_type off = q.find(","); if(off == string::npos) { ostringstream os; os << argv[0] << ": parse error: no , in QoS"; throw invalid_argument(os.str()); } - cmdLineQos[q->substr(0, off)] = q->substr(off+1); + cmdLineQos[q.substr(0, off)] = q.substr(off+1); } bool slow = opts.isSet("slow"); @@ -375,8 +336,8 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - PropertiesPtr properties = communicator->getProperties(); - const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default"; + auto properties = communicator->getProperties(); + string managerProxyProperty = "IceStormAdmin.TopicManager.Default"; string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { @@ -385,7 +346,7 @@ Subscriber::run(int argc, char** argv) throw invalid_argument(os.str()); } - IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( + auto manager = checkedCast<IceStorm::TopicManagerPrx>( communicator->stringToProxy(managerProxy)); if(!manager) { @@ -404,7 +365,7 @@ Subscriber::run(int argc, char** argv) os << "SubscriberAdapter" << i; Subscription item; item.adapter = communicator->createObjectAdapterWithEndpoints(os.str(), "default"); - item.servant = new ErraticEventI(communicator.communicator(), events); + item.servant = make_shared<ErraticEventI>(communicator.communicator(), events); item.qos["reliability"] = "twoway"; subs.push_back(item); } @@ -413,7 +374,7 @@ Subscriber::run(int argc, char** argv) { Subscription item; item.adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default"); - item.servant = new SlowEventI(communicator.communicator(), events); + item.servant = make_shared<SlowEventI>(communicator.communicator(), events); item.qos = cmdLineQos; subs.push_back(item); } @@ -423,11 +384,11 @@ Subscriber::run(int argc, char** argv) item1.adapter = communicator->createObjectAdapterWithEndpoints("MaxQueueAdapter", "default"); if(maxQueueDropEvents) { - item1.servant = new MaxQueueEventI(communicator.communicator(), maxQueueDropEvents, events, false); + item1.servant = make_shared<MaxQueueEventI>(communicator.communicator(), maxQueueDropEvents, events, false); } else { - item1.servant = new MaxQueueEventI(communicator.communicator(), maxQueueRemoveSub, events, true); + item1.servant = make_shared<MaxQueueEventI>(communicator.communicator(), maxQueueRemoveSub, events, true); } item1.qos = cmdLineQos; item1.activate = false; @@ -435,7 +396,7 @@ Subscriber::run(int argc, char** argv) Subscription item2; item2.adapter = communicator->createObjectAdapterWithEndpoints("ControllerAdapter", "default"); - item2.servant = new ControllerEventI(communicator.communicator(), events, item1.adapter); + item2.servant = make_shared<ControllerEventI>(communicator.communicator(), events, item1.adapter); item2.qos["reliability"] = "oneway"; subs.push_back(item2); } @@ -444,29 +405,29 @@ Subscriber::run(int argc, char** argv) Subscription item; item.adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default"); item.qos = cmdLineQos; - map<string, string>::const_iterator p = item.qos.find("reliability"); + auto p = item.qos.find("reliability"); if(p != item.qos.end() && p->second == "ordered") { - item.servant = new OrderEventI(communicator.communicator(), events); + item.servant = make_shared<OrderEventI>(communicator.communicator(), events); } else { - item.servant = new CountEventI(communicator.communicator(), events); + item.servant = make_shared<CountEventI>(communicator.communicator(), events); } subs.push_back(item); } - TopicPrx topic = manager->retrieve("fed1"); + auto topic = manager->retrieve("fed1"); { - for(vector<Subscription>::iterator p = subs.begin(); p != subs.end(); ++p) + for(auto& p: subs) { - p->obj = p->adapter->addWithUUID(p->servant); + p.obj = p.adapter->addWithUUID(p.servant); IceStorm::QoS qos; string reliability = ""; - IceStorm::QoS::const_iterator q = p->qos.find("reliability"); - if(q != p->qos.end()) + IceStorm::QoS::const_iterator q = p.qos.find("reliability"); + if(q != p.qos.end()) { reliability = q->second; } @@ -480,22 +441,22 @@ Subscriber::run(int argc, char** argv) } else if(reliability == "batch") { - p->obj = p->obj->ice_batchOneway(); + p.obj = p.obj->ice_batchOneway(); } else //if(reliability == "oneway") { - p->obj = p->obj->ice_oneway(); + p.obj = p.obj->ice_oneway(); } - p->publisher = topic->subscribeAndGetPublisher(qos, p->obj); + p.publisher = topic->subscribeAndGetPublisher(qos, p.obj); } } { - for(vector<Subscription>::iterator p = subs.begin(); p != subs.end(); ++p) + for(const auto& p: subs) { - if(p->activate) + if(p.activate) { - p->adapter->activate(); + p.adapter->activate(); } } } @@ -503,14 +464,14 @@ Subscriber::run(int argc, char** argv) communicator->waitForShutdown(); { - for(vector<Subscription>::const_iterator p = subs.begin(); p != subs.end(); ++p) + for(const auto& p: subs) { - p->servant->check(*p); - topic->unsubscribe(p->obj); - if(p->servant->count() != events) + p.servant->check(p); + topic->unsubscribe(p.obj); + if(p.servant->count() != events) { ostringstream os; - os << "expected " << events << " events but got " << p->servant->count() << " events."; + os << "expected " << events << " events but got " << p.servant->count() << " events."; throw invalid_argument(os.str()); } } diff --git a/csharp/src/Ice/PropertyNames.cs b/csharp/src/Ice/PropertyNames.cs index d56ee2fbcfd..4d78ec7ebee 100644 --- a/csharp/src/Ice/PropertyNames.cs +++ b/csharp/src/Ice/PropertyNames.cs @@ -1,7 +1,7 @@ // // Copyright (c) ZeroC, Inc. All rights reserved. // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Fri Jan 29 15:05:58 2021 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Wed Feb 3 10:19:18 2021 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -1134,7 +1134,6 @@ namespace IceInternal new Property(@"^Glacier2\.Client\.ThreadPool\.ThreadIdleTime$", false, null), new Property(@"^Glacier2\.Client\.ThreadPool\.ThreadPriority$", false, null), new Property(@"^Glacier2\.Client\.MessageSizeMax$", false, null), - new Property(@"^Glacier2\.Client\.AlwaysBatch$", false, null), new Property(@"^Glacier2\.Client\.Buffered$", false, null), new Property(@"^Glacier2\.Client\.ForwardContext$", false, null), new Property(@"^Glacier2\.Client\.SleepTime$", false, null), @@ -1209,7 +1208,6 @@ namespace IceInternal new Property(@"^Glacier2\.Server\.ThreadPool\.ThreadIdleTime$", false, null), new Property(@"^Glacier2\.Server\.ThreadPool\.ThreadPriority$", false, null), new Property(@"^Glacier2\.Server\.MessageSizeMax$", false, null), - new Property(@"^Glacier2\.Server\.AlwaysBatch$", false, null), new Property(@"^Glacier2\.Server\.Buffered$", false, null), new Property(@"^Glacier2\.Server\.ForwardContext$", false, null), new Property(@"^Glacier2\.Server\.SleepTime$", false, null), @@ -1235,7 +1233,6 @@ namespace IceInternal new Property(@"^Glacier2\.SSLSessionManager\.CollocationOptimized$", false, null), new Property(@"^Glacier2\.SSLSessionManager\.Context\.[^\s]+$", false, null), new Property(@"^Glacier2\.SSLSessionManager$", false, null), - new Property(@"^Glacier2\.SessionTimeout$", false, null), new Property(@"^Glacier2\.Trace\.RoutingTable$", false, null), new Property(@"^Glacier2\.Trace\.Session$", false, null), null diff --git a/java-compat/src/Ice/src/main/java/IceInternal/PropertyNames.java b/java-compat/src/Ice/src/main/java/IceInternal/PropertyNames.java index ccdecc39504..9d175abe256 100644 --- a/java-compat/src/Ice/src/main/java/IceInternal/PropertyNames.java +++ b/java-compat/src/Ice/src/main/java/IceInternal/PropertyNames.java @@ -1,7 +1,7 @@ // // Copyright (c) ZeroC, Inc. All rights reserved. // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Fri Jan 29 15:05:58 2021 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Wed Feb 3 10:19:18 2021 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -1134,7 +1134,6 @@ public final class PropertyNames new Property("Glacier2\\.Client\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("Glacier2\\.Client\\.ThreadPool\\.ThreadPriority", false, null), new Property("Glacier2\\.Client\\.MessageSizeMax", false, null), - new Property("Glacier2\\.Client\\.AlwaysBatch", false, null), new Property("Glacier2\\.Client\\.Buffered", false, null), new Property("Glacier2\\.Client\\.ForwardContext", false, null), new Property("Glacier2\\.Client\\.SleepTime", false, null), @@ -1209,7 +1208,6 @@ public final class PropertyNames new Property("Glacier2\\.Server\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("Glacier2\\.Server\\.ThreadPool\\.ThreadPriority", false, null), new Property("Glacier2\\.Server\\.MessageSizeMax", false, null), - new Property("Glacier2\\.Server\\.AlwaysBatch", false, null), new Property("Glacier2\\.Server\\.Buffered", false, null), new Property("Glacier2\\.Server\\.ForwardContext", false, null), new Property("Glacier2\\.Server\\.SleepTime", false, null), @@ -1235,7 +1233,6 @@ public final class PropertyNames new Property("Glacier2\\.SSLSessionManager\\.CollocationOptimized", false, null), new Property("Glacier2\\.SSLSessionManager\\.Context\\.[^\\s]+", false, null), new Property("Glacier2\\.SSLSessionManager", false, null), - new Property("Glacier2\\.SessionTimeout", false, null), new Property("Glacier2\\.Trace\\.RoutingTable", false, null), new Property("Glacier2\\.Trace\\.Session", false, null), null diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/PropertyNames.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/PropertyNames.java index 878ba11d9dd..16f2b9e0520 100644 --- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/PropertyNames.java +++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/PropertyNames.java @@ -1,7 +1,7 @@ // // Copyright (c) ZeroC, Inc. All rights reserved. // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Fri Jan 29 15:05:58 2021 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Wed Feb 3 10:19:18 2021 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -1134,7 +1134,6 @@ public final class PropertyNames new Property("Glacier2\\.Client\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("Glacier2\\.Client\\.ThreadPool\\.ThreadPriority", false, null), new Property("Glacier2\\.Client\\.MessageSizeMax", false, null), - new Property("Glacier2\\.Client\\.AlwaysBatch", false, null), new Property("Glacier2\\.Client\\.Buffered", false, null), new Property("Glacier2\\.Client\\.ForwardContext", false, null), new Property("Glacier2\\.Client\\.SleepTime", false, null), @@ -1209,7 +1208,6 @@ public final class PropertyNames new Property("Glacier2\\.Server\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("Glacier2\\.Server\\.ThreadPool\\.ThreadPriority", false, null), new Property("Glacier2\\.Server\\.MessageSizeMax", false, null), - new Property("Glacier2\\.Server\\.AlwaysBatch", false, null), new Property("Glacier2\\.Server\\.Buffered", false, null), new Property("Glacier2\\.Server\\.ForwardContext", false, null), new Property("Glacier2\\.Server\\.SleepTime", false, null), @@ -1235,7 +1233,6 @@ public final class PropertyNames new Property("Glacier2\\.SSLSessionManager\\.CollocationOptimized", false, null), new Property("Glacier2\\.SSLSessionManager\\.Context\\.[^\\s]+", false, null), new Property("Glacier2\\.SSLSessionManager", false, null), - new Property("Glacier2\\.SessionTimeout", false, null), new Property("Glacier2\\.Trace\\.RoutingTable", false, null), new Property("Glacier2\\.Trace\\.Session", false, null), null diff --git a/js/src/Ice/PropertyNames.js b/js/src/Ice/PropertyNames.js index 2f393fa4389..d850306b18c 100644 --- a/js/src/Ice/PropertyNames.js +++ b/js/src/Ice/PropertyNames.js @@ -1,7 +1,7 @@ // // Copyright (c) ZeroC, Inc. All rights reserved. // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Fri Jan 29 15:05:58 2021 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Wed Feb 3 10:19:18 2021 // IMPORTANT: Do not edit this file -- any edits made here will be lost! diff --git a/scripts/Component.py b/scripts/Component.py index 22304270b87..11995d71e14 100644 --- a/scripts/Component.py +++ b/scripts/Component.py @@ -145,6 +145,11 @@ class Ice(Component): if testId == "IceStorm/repgrid": return False + # No C++98 tests for IceBridge, IceGrid, IceStorm and Glacier2 + if isinstance(mapping, CppMapping) and not current.config.cpp11: + if parent in ["IceBridge", "IceGrid", "IceStorm", "Glacier2"]: + return False + if current.config.xamarin and not current.config.uwp: # # With Xamarin on Android and iOS Ice/udp is only supported with IPv4 diff --git a/scripts/IceStormUtil.py b/scripts/IceStormUtil.py index f091de1c359..aa33c57361c 100644 --- a/scripts/IceStormUtil.py +++ b/scripts/IceStormUtil.py @@ -11,7 +11,7 @@ class IceStorm(ProcessFromBinDir, Server): def __init__(self, instanceName="IceStorm", replica=0, nreplicas=0, transient=False, portnum=0, createDb=True, cleanDb=True, *args, **kargs): - Server.__init__(self, exe="icebox", ready="IceStorm", mapping=Mapping.getByName("cpp"), *args, **kargs) + Server.__init__(self, exe="icebox++11", ready="IceStorm", mapping=Mapping.getByName("cpp"), *args, **kargs) self.portnum = portnum self.replica = replica self.nreplicas = nreplicas diff --git a/scripts/Util.py b/scripts/Util.py index e64b6b98f0a..a9d24326960 100644 --- a/scripts/Util.py +++ b/scripts/Util.py @@ -3187,6 +3187,9 @@ class CppMapping(Mapping): def __init__(self, options=[]): Mapping.Config.__init__(self, options) + # if self.buildConfig == platform.getDefaultBuildConfig(): + # self.buildConfig = "cpp98-shared" + # Derive from the build config the cpp11 option. This is used by canRun to allow filtering # tests on the cpp11 value in the testcase options specification self.cpp11 = self.buildConfig.lower().find("cpp11") >= 0 diff --git a/scripts/tests/Glacier2/application.py b/scripts/tests/Glacier2/application.py index 2b8886ebe4c..77d27b491cc 100644 --- a/scripts/tests/Glacier2/application.py +++ b/scripts/tests/Glacier2/application.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -Glacier2TestSuite(__name__, routerProps = { "Glacier2.SessionTimeout" : 30 }) +Glacier2TestSuite(__name__, routerProps = { "Glacier2.Client.ACM.Timeout" : 30 }) diff --git a/scripts/tests/Glacier2/router.py b/scripts/tests/Glacier2/router.py index a6245a800eb..a3b32fa7297 100644 --- a/scripts/tests/Glacier2/router.py +++ b/scripts/tests/Glacier2/router.py @@ -17,7 +17,7 @@ routerProps = { "Ice.Warn.Connections" : "0", "Glacier2.Filter.Category.Accept" : "c1 c2", "Glacier2.Filter.Category.AcceptUser" : "2", - "Glacier2.SessionTimeout" : "30", + "Glacier2.Client.ACM.Timeout" : "30", } traceProps = { diff --git a/scripts/tests/Glacier2/sessionHelper.py b/scripts/tests/Glacier2/sessionHelper.py index 2b8886ebe4c..77d27b491cc 100644 --- a/scripts/tests/Glacier2/sessionHelper.py +++ b/scripts/tests/Glacier2/sessionHelper.py @@ -3,4 +3,4 @@ # Copyright (c) ZeroC, Inc. All rights reserved. # -Glacier2TestSuite(__name__, routerProps = { "Glacier2.SessionTimeout" : 30 }) +Glacier2TestSuite(__name__, routerProps = { "Glacier2.Client.ACM.Timeout" : 30 }) |