diff options
author | Jose <jose@zeroc.com> | 2018-06-01 17:41:03 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-06-01 17:41:03 +0200 |
commit | cbe92e540a7f02f0bdf93192424bd119189365b7 (patch) | |
tree | 411c50dc0ae9c669d31a940b1b4903b5deac4f12 /cpp/test/IceStorm/repstress | |
parent | Fixed Util.py check for binary installation directory on Windows (diff) | |
download | ice-cbe92e540a7f02f0bdf93192424bd119189365b7.tar.bz2 ice-cbe92e540a7f02f0bdf93192424bd119189365b7.tar.xz ice-cbe92e540a7f02f0bdf93192424bd119189365b7.zip |
Do not use Ice::Application for Ice testsuite
Diffstat (limited to 'cpp/test/IceStorm/repstress')
-rw-r--r-- | cpp/test/IceStorm/repstress/Control.cpp | 46 | ||||
-rw-r--r-- | cpp/test/IceStorm/repstress/Publisher.cpp | 67 | ||||
-rw-r--r-- | cpp/test/IceStorm/repstress/Subscriber.cpp | 66 |
3 files changed, 56 insertions, 123 deletions
diff --git a/cpp/test/IceStorm/repstress/Control.cpp b/cpp/test/IceStorm/repstress/Control.cpp index fc2a1bac933..7d01e359834 100644 --- a/cpp/test/IceStorm/repstress/Control.cpp +++ b/cpp/test/IceStorm/repstress/Control.cpp @@ -9,48 +9,32 @@ #include <Ice/Ice.h> #include <Controller.h> -#include <TestCommon.h> +#include <TestHelper.h> using namespace std; using namespace Ice; using namespace Test; -int -run(int argc, char* argv[], const CommunicatorPtr& communicator) +class Control : public Test::TestHelper { +public: + + void run(int, char**); +}; + +void +Control::run(int argc, char** argv) +{ + Ice::CommunicatorHolder communicator = initialize(argc, argv); if(argc < 2) { - cerr << "Usage: " << argv[0] << " proxy" << endl; - return EXIT_FAILURE; + ostringstream os; + os << "Usage: " << argv[0] << " proxy"; + throw invalid_argument(os.str()); } ControllerPrx control = ControllerPrx::uncheckedCast(communicator->stringToProxy(argv[1])); control->stop(); - - return EXIT_SUCCESS; } -int -main(int argc, char* argv[]) -{ - int status; - CommunicatorPtr communicator; - InitializationData initData = getTestInitData(argc, argv); - try - { - communicator = initialize(argc, argv, initData); - status = run(argc, argv, communicator); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - communicator->destroy(); - } - - return status; -} +DEFINE_TEST(Control) diff --git a/cpp/test/IceStorm/repstress/Publisher.cpp b/cpp/test/IceStorm/repstress/Publisher.cpp index e483aa54560..40fd957804f 100644 --- a/cpp/test/IceStorm/repstress/Publisher.cpp +++ b/cpp/test/IceStorm/repstress/Publisher.cpp @@ -12,7 +12,7 @@ #include <IceStorm/IceStorm.h> #include <Single.h> #include <Controller.h> -#include <TestCommon.h> +#include <TestHelper.h> using namespace std; using namespace Ice; @@ -81,37 +81,37 @@ private: }; typedef IceUtil::Handle<PublishThread> PublishThreadPtr; -int -run(int, char* argv[], const CommunicatorPtr& communicator) +class Publisher : public Test::TestHelper { +public: + + void run(int, char**); +}; + +void +Publisher::run(int argc, char** argv) +{ + + Ice::CommunicatorHolder communicator = initialize(argc, argv); PropertiesPtr properties = communicator->getProperties(); - const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default"; - string managerProxy = properties->getProperty(managerProxyProperty); + string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + ostringstream os; + os << argv[0] << ": property `IceStormAdmin.TopicManager.Default' is not set"; + throw invalid_argument(os.str()); } IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast( communicator->stringToProxy(managerProxy)); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + ostringstream os; + os << argv[0] << ": `" << managerProxy << "' is not running"; + throw invalid_argument(os.str()); } - TopicPrx topic; - try - { - topic = manager->retrieve("single"); - } - catch(const NoSuchTopic& e) - { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; - - } + TopicPrx topic = manager->retrieve("single"); assert(topic); // @@ -132,31 +132,6 @@ run(int, char* argv[], const CommunicatorPtr& communicator) t->destroy(); t->getThreadControl().join(); - - return EXIT_SUCCESS; } -int -main(int argc, char* argv[]) -{ - int status; - CommunicatorPtr communicator; - InitializationData initData = getTestInitData(argc, argv); - try - { - communicator = initialize(argc, argv, initData); - status = run(argc, argv, communicator); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - communicator->destroy(); - } - - return status; -} +DEFINE_TEST(Publisher) diff --git a/cpp/test/IceStorm/repstress/Subscriber.cpp b/cpp/test/IceStorm/repstress/Subscriber.cpp index 8f94b60b489..1d8ecab37e1 100644 --- a/cpp/test/IceStorm/repstress/Subscriber.cpp +++ b/cpp/test/IceStorm/repstress/Subscriber.cpp @@ -12,7 +12,7 @@ #include <IceStorm/IceStorm.h> #include <Single.h> #include <Controller.h> -#include <TestCommon.h> +#include <TestHelper.h> using namespace std; using namespace Ice; @@ -58,38 +58,37 @@ private: }; typedef IceUtil::Handle<SingleI> SingleIPtr; -int -run(int, char* argv[], const CommunicatorPtr& communicator) +class Subscriber : public Test::TestHelper { +public: + + void run(int, char**); +}; + +void +Subscriber::run(int argc, char** argv) +{ + Ice::CommunicatorHolder communicator = initialize(argc, argv); PropertiesPtr properties = communicator->getProperties(); - const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default"; - string managerProxy = properties->getProperty(managerProxyProperty); + string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default"); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + ostringstream os; + os << argv[0] << ": property `IceStormAdmin.TopicManager.Default' is not set"; + throw invalid_argument(os.str()); } ObjectPrx base = communicator->stringToProxy(managerProxy); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + ostringstream os; + os << argv[0] << ": `" << managerProxy << "' is not running"; + throw invalid_argument(os.str()); } ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default"); - - TopicPrx topic; - try - { - topic = manager->retrieve("single"); - } - catch(const IceStorm::NoSuchTopic& e) - { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; - } + TopicPrx topic = manager->retrieve("single"); SingleIPtr sub = new SingleI(); Ice::ObjectPrx prx = adapter->addWithUUID(sub); @@ -123,31 +122,6 @@ run(int, char* argv[], const CommunicatorPtr& communicator) communicator->waitForShutdown(); cout << sub->nevents() << endl; - - return EXIT_SUCCESS; } -int -main(int argc, char* argv[]) -{ - int status; - CommunicatorPtr communicator; - InitializationData initData = getTestInitData(argc, argv); - try - { - communicator = initialize(argc, argv, initData); - status = run(argc, argv, communicator); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - communicator->destroy(); - } - - return status; -} +DEFINE_TEST(Subscriber) |