loolwsd/test/httpwserror.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
New commits: commit 78b2fae7e9683adbda3598bc1e1da1b8db21f5d6 Author: Henry Castro <hcas...@collabora.com> Date: Wed Sep 28 18:16:09 2016 -0400 loolwsd: test: update max connections diff --git a/loolwsd/test/httpwserror.cpp b/loolwsd/test/httpwserror.cpp index ab053b7..b8b8afb 100644 --- a/loolwsd/test/httpwserror.cpp +++ b/loolwsd/test/httpwserror.cpp @@ -36,12 +36,12 @@ class HTTPWSError : public CPPUNIT_NS::TestFixture CPPUNIT_TEST_SUITE(HTTPWSError); CPPUNIT_TEST(testMaxDocuments); - //CPPUNIT_TEST(testMaxConnections); + CPPUNIT_TEST(testMaxConnections); CPPUNIT_TEST_SUITE_END(); void testMaxDocuments(); - //void testMaxConnections(); + void testMaxConnections(); public: HTTPWSError() @@ -108,7 +108,7 @@ void HTTPWSError::testMaxDocuments() #endif } -/*void HTTPWSError::testMaxConnections() +void HTTPWSError::testMaxConnections() { #if MAX_CONNECTIONS > 0 try @@ -117,7 +117,6 @@ void HTTPWSError::testMaxDocuments() std::string docPath; std::string docURL; std::string message; - Poco::UInt16 statusCode; std::vector<std::shared_ptr<Poco::Net::WebSocket>> views; getDocumentPathAndURL("empty.odt", docPath, docURL); @@ -133,19 +132,31 @@ void HTTPWSError::testMaxDocuments() } // try to connect MAX_CONNECTIONS + 1 - std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(_uri)); - auto socketN = std::make_shared<Poco::Net::WebSocket>(*session, request, _response); - statusCode = getErrorCode(*socketN, message); - CPPUNIT_ASSERT_EQUAL(static_cast<Poco::UInt16>(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY), statusCode); - CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("This development build") != std::string::npos); - + { + // Load a document and get its status. + const std::string documentURL = "lool/ws/file:///fake.doc"; + + Poco::Net::HTTPResponse response; + Poco::Net::HTTPRequest requestN(Poco::Net::HTTPRequest::HTTP_GET, documentURL); + std::unique_ptr<Poco::Net::HTTPClientSession> session(helpers::createSession(_uri)); + requestN.set("Connection", "Upgrade"); + requestN.set("Upgrade", "websocket"); + requestN.set("Sec-WebSocket-Version", "13"); + requestN.set("Sec-WebSocket-Key", ""); + requestN.setChunkedTransferEncoding(false); + session->setKeepAlive(true); + session->sendRequest(requestN); + session->receiveResponse(response); + CPPUNIT_ASSERT_EQUAL(Poco::Net::HTTPResponse::HTTPResponse::HTTP_NOT_ACCEPTABLE, response.getStatus()); + CPPUNIT_ASSERT_MESSAGE("Wrong error message ", response.getReason().find("This development build") != std::string::npos); + } } catch (const Poco::Exception& exc) { CPPUNIT_FAIL(exc.displayText()); } #endif -}*/ +} CPPUNIT_TEST_SUITE_REGISTRATION(HTTPWSError); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits