summaryrefslogtreecommitdiff
path: root/cpp/test/IceStorm/repstress/Subscriber.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/IceStorm/repstress/Subscriber.cpp')
-rw-r--r--cpp/test/IceStorm/repstress/Subscriber.cpp66
1 files changed, 20 insertions, 46 deletions
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)