loolwsd/LOOLWSD.cpp | 9 ++++----- loolwsd/test/httpwstest.cpp | 25 +++++++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-)
New commits: commit 0a92e023394268dbd184250582c671556359c9f3 Author: Henry Castro <hcas...@collabora.com> Date: Sun Apr 17 08:42:07 2016 -0400 loolwsd: test: update changes to WebSocketErrorMessageException diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index f954a53..90a7843 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -504,10 +504,8 @@ private: if (!child) { // Let the client know we can't serve now. - status = "statusindicator: fail"; - ws->sendFrame(status.data(), (int) status.size()); - ws->shutdown(); - throw WebSocketException("Failed to get new child. Client cannot serve now.", WebSocket::WS_ENDPOINT_GOING_AWAY); + Log::error("Failed to get new child. Client cannot serve now."); + throw WebSocketErrorMessageException(SERVICE_UNAVALABLE_INTERNAL_ERROR); } // Set one we just created. @@ -685,7 +683,8 @@ public: { const std::string msg = std::string("error: ") + exc.what(); ws->sendFrame(msg.data(), msg.size()); - ws->shutdown(); + // abnormal close frame handshake + ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, exc.what()); } catch (const std::exception& exc2) { diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp index cdaeeee..9b917af 100644 --- a/loolwsd/test/httpwstest.cpp +++ b/loolwsd/test/httpwstest.cpp @@ -33,6 +33,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <Common.hpp> +#include <UserMessages.hpp> #include <Util.hpp> #include <LOOLProtocol.hpp> @@ -170,7 +171,7 @@ void HTTPWSTest::testBadRequest() session.setKeepAlive(true); session.sendRequest(request); session.receiveResponse(response); - CPPUNIT_ASSERT(response.getStatus() == Poco::Net::HTTPResponse::HTTP_BAD_REQUEST); + CPPUNIT_ASSERT(response.getStatus() == Poco::Net::HTTPResponse::HTTPResponse::HTTP_SERVICE_UNAVAILABLE); } catch (const Poco::Exception& exc) { @@ -199,7 +200,7 @@ void HTTPWSTest::testHandShake() Poco::Net::WebSocket socket(session, request, response); const std::string prefixEdit = "editlock:"; - const char* fail = "fail"; + const char* fail = "error:"; std::string payload("statusindicator: find"); std::string receive; @@ -233,18 +234,26 @@ void HTTPWSTest::testHandShake() } else { - payload = "statusindicator: fail"; - CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes); - CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0); + // check error message + CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr); CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT); + + // close frame message + bytes = socket.receiveFrame(buffer, sizeof(buffer), flags); + CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr); + CPPUNIT_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE); } } else { - payload = "statusindicator: fail"; - CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes); - CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0); + // check error message + CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr); CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT); + + // close frame message + bytes = socket.receiveFrame(buffer, sizeof(buffer), flags); + CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr); + CPPUNIT_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE); } socket.shutdown(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits