summaryrefslogtreecommitdiff
path: root/cpp/test/IceSSL/configuration/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/IceSSL/configuration/Client.cpp')
-rw-r--r--cpp/test/IceSSL/configuration/Client.cpp93
1 files changed, 31 insertions, 62 deletions
diff --git a/cpp/test/IceSSL/configuration/Client.cpp b/cpp/test/IceSSL/configuration/Client.cpp
index 16834c0fa0f..16ce7baafc2 100644
--- a/cpp/test/IceSSL/configuration/Client.cpp
+++ b/cpp/test/IceSSL/configuration/Client.cpp
@@ -9,60 +9,28 @@
#include <Ice/Ice.h>
#include <IceSSL/IceSSL.h>
-#include <TestCommon.h>
+#include <TestHelper.h>
#include <Test.h>
#if defined(ICE_USE_OPENSSL)
-# include <IceSSL/OpenSSL.h>
+# include <IceSSL/OpenSSL.h>
#endif
-DEFINE_TEST("client")
-
using namespace std;
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
+class Client : public Test::TestHelper
{
- string testdir;
-#if TARGET_OS_IPHONE == 0
- if(argc < 2)
- {
- cerr << "Usage: " << argv[0] << " testdir" << endl;
- return 1;
- }
- testdir = argv[1];
-#endif
+public:
- Test::ServerFactoryPrxPtr allTests(const Ice::CommunicatorPtr&, const string&, bool);
-
- try
- {
- cerr << "testing with PKCS12 certificates..." << endl;
- Test::ServerFactoryPrxPtr factory = allTests(communicator, testdir, true);
-#if TARGET_OS_IPHONE == 0 && !defined(ICE_OS_UWP)
- cerr << "testing with PEM certificates..." << endl;
- factory = allTests(communicator, testdir, false);
-#endif
- if(factory)
- {
- factory->shutdown();
- }
- }
- catch(const IceSSL::CertificateReadException& ex)
- {
- cout << "couldn't read certificate: " << ex.reason << endl;
- return EXIT_FAILURE;
- }
- catch(const std::exception& ex)
+ Client() : Test::TestHelper(false)
{
- cout << "unexpected exception: " << ex.what() << endl;
- return EXIT_FAILURE;
}
- return EXIT_SUCCESS;
-}
-int
-main(int argc, char* argv[])
+ void run(int, char**);
+};
+
+void
+Client::run(int argc, char** argv)
{
//
// Explicitly register the IceSSL plugin to test registerIceSSL. The tests
@@ -73,29 +41,30 @@ main(int argc, char* argv[])
Ice::registerIceSSL();
#endif
-#ifdef ICE_STATIC_LIBS
- Ice::registerIceWS(true);
-#endif
-
- int status;
- Ice::CommunicatorPtr communicator;
-
- try
- {
- Ice::InitializationData initData = getTestInitData(argc, argv);
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
- }
- catch(const Ice::Exception& ex)
+ Ice::CommunicatorHolder communicator = initialize(argc, argv);
+ string testdir;
+#if TARGET_OS_IPHONE == 0
+ if(argc < 2)
{
- cerr << ex << endl;
- status = EXIT_FAILURE;
+ ostringstream os;
+ os << "Usage: " << argv[0] << " testdir";
+ throw std::invalid_argument(os.str());
}
+ testdir = argv[1];
+#endif
+
+ Test::ServerFactoryPrxPtr allTests(Test::TestHelper*, const string&, bool);
- if(communicator)
+ cerr << "testing with PKCS12 certificates..." << endl;
+ Test::ServerFactoryPrxPtr factory = allTests(this, testdir, true);
+#if TARGET_OS_IPHONE == 0 && !defined(ICE_OS_UWP)
+ cerr << "testing with PEM certificates..." << endl;
+ factory = allTests(this, testdir, false);
+#endif
+ if(factory)
{
- communicator->destroy();
+ factory->shutdown();
}
-
- return status;
}
+
+DEFINE_TEST(Client)