diff options
Diffstat (limited to 'cpp/test/IceSSL/configuration/Client.cpp')
-rw-r--r-- | cpp/test/IceSSL/configuration/Client.cpp | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/cpp/test/IceSSL/configuration/Client.cpp b/cpp/test/IceSSL/configuration/Client.cpp index 7a54eca2dac..931e45955da 100644 --- a/cpp/test/IceSSL/configuration/Client.cpp +++ b/cpp/test/IceSSL/configuration/Client.cpp @@ -9,25 +9,51 @@ #include <Ice/Ice.h> #include <IceSSL/IceSSL.h> +#include <TestCommon.h> +#include <Test.h> + +DEFINE_TEST("client") using namespace std; int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { + string testdir; +#if TARGET_OS_IPHONE == 0 if(argc < 2) { cerr << "Usage: " << argv[0] << " testdir" << endl; return 1; } + testdir = argv[1]; +#endif - void allTests(const Ice::CommunicatorPtr&, const string&, bool, bool); - - cerr << "testing with PKCS12 certificates..." << endl; - allTests(communicator, argv[1], true, false); - cerr << "testing with PEM certificates..." << endl; - allTests(communicator, argv[1], false, true); + 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) + { + cout << "unexpected exception: " << ex.what() << endl; + return EXIT_FAILURE; + } return EXIT_SUCCESS; } @@ -46,7 +72,8 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); + Ice::InitializationData initData = getTestInitData(argc, argv); + communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) @@ -57,15 +84,7 @@ main(int argc, char* argv[]) if(communicator) { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + communicator->destroy(); } return status; |