From 6d96fb30ec0730c7019603cfd3438608428453d7 Mon Sep 17 00:00:00 2001 From: FrancisANDRE Date: Mon, 21 Dec 2015 23:39:35 +0100 Subject: [PATCH] Remove try/catch. Exception is avoided by CPPUNI_IGNORE Signed-off-by: FrancisANDRE --- .../testsuite/src/HTTPSClientSessionTest.cpp | 39 ++++++++--------- .../testsuite/src/HTTPSStreamFactoryTest.cpp | 28 ++++++------- .../testsuite/src/HTTPSClientSessionTest.cpp | 42 +++++++++---------- .../testsuite/src/HTTPSStreamFactoryTest.cpp | 30 ++++++------- 4 files changed, 65 insertions(+), 74 deletions(-) diff --git a/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp b/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp index 7f0508cc0..93d0678dc 100644 --- a/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp +++ b/NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp @@ -307,27 +307,22 @@ void HTTPSClientSessionTest::testInterop() void HTTPSClientSessionTest::testProxy() { - try { - HTTPSTestServer srv; - HTTPSClientSession s("secure.appinf.com"); - s.setProxy( - Application::instance().config().getString("testsuite.proxy.host"), - Application::instance().config().getInt("testsuite.proxy.port") - ); - HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt"); - s.sendRequest(request); - X509Certificate cert = s.serverCertificate(); - HTTPResponse response; - std::istream& rs = s.receiveResponse(response); - std::ostringstream ostr; - StreamCopier::copyStream(rs, ostr); - std::string str(ostr.str()); - assert(str == "This is a test file for NetSSL.\n"); - assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com"); - } - catch (Poco::Net::HTTPException e) { - std::cout << e.displayText() << std::endl; - } + HTTPSTestServer srv; + HTTPSClientSession s("secure.appinf.com"); + s.setProxy( + Application::instance().config().getString("testsuite.proxy.host"), + Application::instance().config().getInt("testsuite.proxy.port") + ); + HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt"); + s.sendRequest(request); + X509Certificate cert = s.serverCertificate(); + HTTPResponse response; + std::istream& rs = s.receiveResponse(response); + std::ostringstream ostr; + StreamCopier::copyStream(rs, ostr); + std::string str(ostr.str()); + assert(str == "This is a test file for NetSSL.\n"); + assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com"); } @@ -480,7 +475,7 @@ CppUnit::Test* HTTPSClientSessionTest::suite() CppUnit_addTest(pSuite, HTTPSClientSessionTest, testKeepAlive); CppUnit_addTest(pSuite, HTTPSClientSessionTest, testInterop); #ifdef FIXME - should use a public proxy server + testProxy should use a public proxy server http://www.publicproxyservers.com/proxy/list1.html Really working public proxy servers - page 1 of 6. #endif diff --git a/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp b/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp index 91dee0a4c..a19c20692 100644 --- a/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp +++ b/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp @@ -85,21 +85,17 @@ void HTTPSStreamFactoryTest::testRedirect() void HTTPSStreamFactoryTest::testProxy() { - try { - HTTPSTestServer server; - HTTPSStreamFactory factory( - Application::instance().config().getString("testsuite.proxy.host"), - Application::instance().config().getInt("testsuite.proxy.port") - ); - URI uri("https://secure.appinf.com/public/poco/NetSSL.txt"); - std::auto_ptr pStr(factory.open(uri)); - std::ostringstream ostr; - StreamCopier::copyStream(*pStr.get(), ostr); - assert(ostr.str().length() > 0); - } - catch (Poco::Net::HTTPException e) { - std::cout << e.displayText() << std::endl; - } + HTTPSTestServer server; + HTTPSStreamFactory factory( + Application::instance().config().getString("testsuite.proxy.host"), + Application::instance().config().getInt("testsuite.proxy.port") + ); + URI uri("https://secure.appinf.com/public/poco/NetSSL.txt"); + std::auto_ptr pStr(factory.open(uri)); + std::ostringstream ostr; + StreamCopier::copyStream(*pStr.get(), ostr); + assert(ostr.str().length() > 0); + } @@ -139,7 +135,7 @@ CppUnit::Test* HTTPSStreamFactoryTest::suite() CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testEmptyPath); CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testRedirect); #ifdef FIXME - should use a public proxy server + testProxy should use a public proxy server http://www.publicproxyservers.com/proxy/list1.html Really working public proxy servers - page 1 of 6. #endif diff --git a/NetSSL_Win/testsuite/src/HTTPSClientSessionTest.cpp b/NetSSL_Win/testsuite/src/HTTPSClientSessionTest.cpp index 0e2fb1df3..706b45a7f 100644 --- a/NetSSL_Win/testsuite/src/HTTPSClientSessionTest.cpp +++ b/NetSSL_Win/testsuite/src/HTTPSClientSessionTest.cpp @@ -314,27 +314,27 @@ void HTTPSClientSessionTest::testInterop() void HTTPSClientSessionTest::testProxy() { - try { - HTTPSTestServer srv; - HTTPSClientSession s("secure.appinf.com"); - s.setProxy( - Application::instance().config().getString("testsuite.proxy.host"), - Application::instance().config().getInt("testsuite.proxy.port") - ); - HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt"); - s.sendRequest(request); - Poco::Net::X509Certificate cert = s.serverCertificate(); - HTTPResponse response; - std::istream& rs = s.receiveResponse(response); - std::ostringstream ostr; - StreamCopier::copyStream(rs, ostr); - std::string str(ostr.str()); - assert(str == "This is a test file for NetSSL.\n"); - assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com"); - } - catch (Poco::Exception e) { - std::cout << e.displayText() << std::endl; - } +#ifdef FIXME + testProxy should use a public proxy server + http://www.publicproxyservers.com/proxy/list1.html + Really working public proxy servers - page 1 of 6. +#endif + HTTPSTestServer srv; + HTTPSClientSession s("secure.appinf.com"); + s.setProxy( + Application::instance().config().getString("testsuite.proxy.host"), + Application::instance().config().getInt("testsuite.proxy.port") + ); + HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt"); + s.sendRequest(request); + Poco::Net::X509Certificate cert = s.serverCertificate(); + HTTPResponse response; + std::istream& rs = s.receiveResponse(response); + std::ostringstream ostr; + StreamCopier::copyStream(rs, ostr); + std::string str(ostr.str()); + assert(str == "This is a test file for NetSSL.\n"); + assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com"); } diff --git a/NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp b/NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp index bfb96a93b..ade7c79a4 100644 --- a/NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp +++ b/NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp @@ -85,21 +85,21 @@ void HTTPSStreamFactoryTest::testRedirect() void HTTPSStreamFactoryTest::testProxy() { - try { - HTTPSTestServer server; - HTTPSStreamFactory factory( - Application::instance().config().getString("testsuite.proxy.host"), - Application::instance().config().getInt("testsuite.proxy.port") - ); - URI uri("https://secure.appinf.com/public/poco/NetSSL.txt"); - std::auto_ptr pStr(factory.open(uri)); - std::ostringstream ostr; - StreamCopier::copyStream(*pStr.get(), ostr); - assert(ostr.str().length() > 0); - } - catch (Poco::Exception e) { - std::cout << e.displayText() << std::endl; - } +#ifdef FIXME + testProxy should use a public proxy server + http://www.publicproxyservers.com/proxy/list1.html + Really working public proxy servers - page 1 of 6. +#endif + HTTPSTestServer server; + HTTPSStreamFactory factory( + Application::instance().config().getString("testsuite.proxy.host"), + Application::instance().config().getInt("testsuite.proxy.port") + ); + URI uri("https://secure.appinf.com/public/poco/NetSSL.txt"); + std::auto_ptr pStr(factory.open(uri)); + std::ostringstream ostr; + StreamCopier::copyStream(*pStr.get(), ostr); + assert(ostr.str().length() > 0); }