summaryrefslogtreecommitdiff
path: root/cpp/test/IceStorm/rep1
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2018-06-01 17:41:03 +0200
committerJose <jose@zeroc.com>2018-06-01 17:41:03 +0200
commitcbe92e540a7f02f0bdf93192424bd119189365b7 (patch)
tree411c50dc0ae9c669d31a940b1b4903b5deac4f12 /cpp/test/IceStorm/rep1
parentFixed Util.py check for binary installation directory on Windows (diff)
downloadice-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')
-rw-r--r--cpp/test/IceStorm/rep1/Publisher.cpp69
-rw-r--r--cpp/test/IceStorm/rep1/Sub.cpp70
-rw-r--r--cpp/test/IceStorm/rep1/Subscriber.cpp68
3 files changed, 78 insertions, 129 deletions
diff --git a/cpp/test/IceStorm/rep1/Publisher.cpp b/cpp/test/IceStorm/rep1/Publisher.cpp
index f3ccb3d5d2c..417da9bb57c 100644
--- a/cpp/test/IceStorm/rep1/Publisher.cpp
+++ b/cpp/test/IceStorm/rep1/Publisher.cpp
@@ -11,7 +11,7 @@
#include <IceUtil/Options.h>
#include <IceUtil/IceUtil.h>
#include <IceStorm/IceStorm.h>
-#include <TestCommon.h>
+#include <TestHelper.h>
#include <Single.h>
using namespace std;
@@ -19,9 +19,17 @@ using namespace Ice;
using namespace IceStorm;
using namespace Test;
-int
-run(int argc, 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);
IceUtilInternal::Options opts;
opts.addOpt("", "cycle");
@@ -31,25 +39,27 @@ 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());
}
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;
@@ -68,8 +78,9 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator)
}
catch(const IceStorm::NoSuchTopic& e)
{
- cerr << argv[0] << ": NoSuchTopic: " << e.name << endl;
- return EXIT_FAILURE;
+ ostringstream os;
+ os << argv[0] << ": NoSuchTopic: " << e.name;
+ throw invalid_argument(os.str());
}
}
assert(topic);
@@ -94,8 +105,9 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator)
}
if(single.size() <= 1)
{
- cerr << argv[0] << ": Not enough endpoints in publisher proxy" << endl;
- return EXIT_FAILURE;
+ ostringstream os;
+ os << argv[0] << ": Not enough endpoints in publisher proxy";
+ throw invalid_argument(os.str());
}
int which = 0;
for(int i = 0; i < 1000; ++i)
@@ -112,31 +124,6 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator)
single->event(i);
}
}
-
- 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/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)
diff --git a/cpp/test/IceStorm/rep1/Subscriber.cpp b/cpp/test/IceStorm/rep1/Subscriber.cpp
index f46565b3bcc..c97b122b5a3 100644
--- a/cpp/test/IceStorm/rep1/Subscriber.cpp
+++ b/cpp/test/IceStorm/rep1/Subscriber.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;
@@ -72,9 +72,17 @@ private:
};
typedef IceUtil::Handle<SingleI> SingleIPtr;
-int
-run(int argc, 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);
IceUtilInternal::Options opts;
opts.addOpt("", "ordered");
opts.addOpt("", "twoway");
@@ -86,25 +94,27 @@ 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");
@@ -125,8 +135,9 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator)
}
catch(const IceStorm::NoSuchTopic& e)
{
- cerr << argv[0] << ": NoSuchTopic: " << e.name << endl;
- return EXIT_FAILURE;
+ ostringstream os;
+ os << argv[0] << ": NoSuchTopic: " << e.name;
+ throw invalid_argument(os.str());
}
}
@@ -142,12 +153,12 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator)
IceStorm::QoS qos;
if(opts.isSet("ordered"))
{
- sub = new SingleI(communicator, "twoway ordered", events);
+ sub = new SingleI(communicator.communicator(), "twoway ordered", events);
qos["reliability"] = "ordered";
}
else
{
- sub = new SingleI(communicator, "twoway", events);
+ sub = new SingleI(communicator.communicator(), "twoway", events);
}
Ice::ObjectPrx prx = adapter->addWithUUID(sub);
@@ -177,31 +188,6 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator)
sub->waitForEvents();
topic->unsubscribe(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(Subscriber)