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/rep1/Sub.cpp | |
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/rep1/Sub.cpp')
-rw-r--r-- | cpp/test/IceStorm/rep1/Sub.cpp | 70 |
1 files changed, 23 insertions, 47 deletions
diff --git a/cpp/test/IceStorm/rep1/Sub.cpp b/cpp/test/IceStorm/rep1/Sub.cpp index 0f4f920358b..2b6d468538b 100644 --- a/cpp/test/IceStorm/rep1/Sub.cpp +++ b/cpp/test/IceStorm/rep1/Sub.cpp @@ -12,7 +12,7 @@ #include <Ice/Ice.h> #include <IceStorm/IceStorm.h> #include <Single.h> -#include <TestCommon.h> +#include <TestHelper.h> using namespace std; using namespace Ice; @@ -27,9 +27,17 @@ public: virtual void event(int, const Current&) {} }; -int -run(int argc, char* argv[], const CommunicatorPtr& communicator) +class Sub : public Test::TestHelper { +public: + + void run(int, char**); +}; + +void +Sub::run(int argc, char** argv) +{ + Ice::CommunicatorHolder communicator = initialize(argc, argv); IceUtilInternal::Options opts; opts.addOpt("", "id", IceUtilInternal::Options::NeedArg); opts.addOpt("", "unsub"); @@ -40,39 +48,32 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } catch(const IceUtilInternal::BadOptException& e) { - cerr << argv[0] << ": " << e.reason << endl; - return EXIT_FAILURE; + ostringstream os; + os << argv[0] << ": " << e.reason; + throw invalid_argument(os.str()); } 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"); Ice::ObjectPrx prx = adapter->add(new SingleI(), stringToIdentity(opts.optArg("id"))); if(opts.isSet("unsub")) @@ -85,31 +86,6 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) qos["persistent"] = "true"; topic->subscribeAndGetPublisher(qos, prx); } - - 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(Sub) |