Remove try/catch. Exception is avoided by CPPUNI_IGNORE

Signed-off-by: FrancisANDRE <zosrothko@orange.fr>
This commit is contained in:
FrancisANDRE 2015-12-21 23:39:35 +01:00
parent 609072a5ad
commit 6d96fb30ec
4 changed files with 65 additions and 74 deletions

View File

@ -307,27 +307,22 @@ void HTTPSClientSessionTest::testInterop()
void HTTPSClientSessionTest::testProxy() void HTTPSClientSessionTest::testProxy()
{ {
try { HTTPSTestServer srv;
HTTPSTestServer srv; HTTPSClientSession s("secure.appinf.com");
HTTPSClientSession s("secure.appinf.com"); s.setProxy(
s.setProxy( Application::instance().config().getString("testsuite.proxy.host"),
Application::instance().config().getString("testsuite.proxy.host"), Application::instance().config().getInt("testsuite.proxy.port")
Application::instance().config().getInt("testsuite.proxy.port") );
); HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt");
HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt"); s.sendRequest(request);
s.sendRequest(request); X509Certificate cert = s.serverCertificate();
X509Certificate cert = s.serverCertificate(); HTTPResponse response;
HTTPResponse response; std::istream& rs = s.receiveResponse(response);
std::istream& rs = s.receiveResponse(response); std::ostringstream ostr;
std::ostringstream ostr; StreamCopier::copyStream(rs, ostr);
StreamCopier::copyStream(rs, ostr); std::string str(ostr.str());
std::string str(ostr.str()); assert(str == "This is a test file for NetSSL.\n");
assert(str == "This is a test file for NetSSL.\n"); assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com");
assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com");
}
catch (Poco::Net::HTTPException e) {
std::cout << e.displayText() << std::endl;
}
} }
@ -480,7 +475,7 @@ CppUnit::Test* HTTPSClientSessionTest::suite()
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testKeepAlive); CppUnit_addTest(pSuite, HTTPSClientSessionTest, testKeepAlive);
CppUnit_addTest(pSuite, HTTPSClientSessionTest, testInterop); CppUnit_addTest(pSuite, HTTPSClientSessionTest, testInterop);
#ifdef FIXME #ifdef FIXME
should use a public proxy server testProxy should use a public proxy server
http://www.publicproxyservers.com/proxy/list1.html http://www.publicproxyservers.com/proxy/list1.html
Really working public proxy servers - page 1 of 6. Really working public proxy servers - page 1 of 6.
#endif #endif

View File

@ -85,21 +85,17 @@ void HTTPSStreamFactoryTest::testRedirect()
void HTTPSStreamFactoryTest::testProxy() void HTTPSStreamFactoryTest::testProxy()
{ {
try { HTTPSTestServer server;
HTTPSTestServer server; HTTPSStreamFactory factory(
HTTPSStreamFactory factory( Application::instance().config().getString("testsuite.proxy.host"),
Application::instance().config().getString("testsuite.proxy.host"), Application::instance().config().getInt("testsuite.proxy.port")
Application::instance().config().getInt("testsuite.proxy.port") );
); URI uri("https://secure.appinf.com/public/poco/NetSSL.txt");
URI uri("https://secure.appinf.com/public/poco/NetSSL.txt"); std::auto_ptr<std::istream> pStr(factory.open(uri));
std::auto_ptr<std::istream> pStr(factory.open(uri)); std::ostringstream ostr;
std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr);
StreamCopier::copyStream(*pStr.get(), ostr); assert(ostr.str().length() > 0);
assert(ostr.str().length() > 0);
}
catch (Poco::Net::HTTPException e) {
std::cout << e.displayText() << std::endl;
}
} }
@ -139,7 +135,7 @@ CppUnit::Test* HTTPSStreamFactoryTest::suite()
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testEmptyPath); CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testEmptyPath);
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testRedirect); CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testRedirect);
#ifdef FIXME #ifdef FIXME
should use a public proxy server testProxy should use a public proxy server
http://www.publicproxyservers.com/proxy/list1.html http://www.publicproxyservers.com/proxy/list1.html
Really working public proxy servers - page 1 of 6. Really working public proxy servers - page 1 of 6.
#endif #endif

View File

@ -314,27 +314,27 @@ void HTTPSClientSessionTest::testInterop()
void HTTPSClientSessionTest::testProxy() void HTTPSClientSessionTest::testProxy()
{ {
try { #ifdef FIXME
HTTPSTestServer srv; testProxy should use a public proxy server
HTTPSClientSession s("secure.appinf.com"); http://www.publicproxyservers.com/proxy/list1.html
s.setProxy( Really working public proxy servers - page 1 of 6.
Application::instance().config().getString("testsuite.proxy.host"), #endif
Application::instance().config().getInt("testsuite.proxy.port") HTTPSTestServer srv;
); HTTPSClientSession s("secure.appinf.com");
HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt"); s.setProxy(
s.sendRequest(request); Application::instance().config().getString("testsuite.proxy.host"),
Poco::Net::X509Certificate cert = s.serverCertificate(); Application::instance().config().getInt("testsuite.proxy.port")
HTTPResponse response; );
std::istream& rs = s.receiveResponse(response); HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt");
std::ostringstream ostr; s.sendRequest(request);
StreamCopier::copyStream(rs, ostr); Poco::Net::X509Certificate cert = s.serverCertificate();
std::string str(ostr.str()); HTTPResponse response;
assert(str == "This is a test file for NetSSL.\n"); std::istream& rs = s.receiveResponse(response);
assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com"); std::ostringstream ostr;
} StreamCopier::copyStream(rs, ostr);
catch (Poco::Exception e) { std::string str(ostr.str());
std::cout << e.displayText() << std::endl; assert(str == "This is a test file for NetSSL.\n");
} assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com");
} }

View File

@ -85,21 +85,21 @@ void HTTPSStreamFactoryTest::testRedirect()
void HTTPSStreamFactoryTest::testProxy() void HTTPSStreamFactoryTest::testProxy()
{ {
try { #ifdef FIXME
HTTPSTestServer server; testProxy should use a public proxy server
HTTPSStreamFactory factory( http://www.publicproxyservers.com/proxy/list1.html
Application::instance().config().getString("testsuite.proxy.host"), Really working public proxy servers - page 1 of 6.
Application::instance().config().getInt("testsuite.proxy.port") #endif
); HTTPSTestServer server;
URI uri("https://secure.appinf.com/public/poco/NetSSL.txt"); HTTPSStreamFactory factory(
std::auto_ptr<std::istream> pStr(factory.open(uri)); Application::instance().config().getString("testsuite.proxy.host"),
std::ostringstream ostr; Application::instance().config().getInt("testsuite.proxy.port")
StreamCopier::copyStream(*pStr.get(), ostr); );
assert(ostr.str().length() > 0); URI uri("https://secure.appinf.com/public/poco/NetSSL.txt");
} std::auto_ptr<std::istream> pStr(factory.open(uri));
catch (Poco::Exception e) { std::ostringstream ostr;
std::cout << e.displayText() << std::endl; StreamCopier::copyStream(*pStr.get(), ostr);
} assert(ostr.str().length() > 0);
} }