[Libreoffice-commits] online.git: test/countloolkits.hpp test/helpers.hpp test/httpcrashtest.cpp test/httpwserror.cpp test/test.cpp test/UnitAdmin.cpp test/UnitConvert.cpp test/UnitCopyPaste.cpp test/UnitFuzz.cpp test/UnitOOB.cpp test/UnitPasswordProtected.cpp test/UnitRenderingOptions.cpp test/UnitWOPIWatermark.cpp

Pranam Lashkari (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 13 08:20:43 UTC 2019


 test/UnitAdmin.cpp             |   35 ++++++++++++++++-------------------
 test/UnitConvert.cpp           |    1 -
 test/UnitCopyPaste.cpp         |    1 -
 test/UnitFuzz.cpp              |    1 -
 test/UnitOOB.cpp               |    1 -
 test/UnitPasswordProtected.cpp |   12 ++++--------
 test/UnitRenderingOptions.cpp  |    6 +++---
 test/UnitWOPIWatermark.cpp     |    2 +-
 test/countloolkits.hpp         |    1 -
 test/helpers.hpp               |    5 ++---
 test/httpcrashtest.cpp         |    1 -
 test/httpwserror.cpp           |    4 ++--
 test/test.cpp                  |    7 ++++---
 13 files changed, 32 insertions(+), 45 deletions(-)

New commits:
commit d7bc9ff2e4f1fc7f92c9a6942db6c439dc6d78e7
Author:     Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Wed Nov 13 12:18:30 2019 +0530
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Nov 13 09:20:25 2019 +0100

    killpoco: removed StringTokenizer from test directory
    
    removed use of Poco::StringTokenizer from the test directory using LOOLProtocol::tokenize and std::vecor<std::string>
    
    Change-Id: I20fc2e0ef0d0d8fc959fee7972aa095f2581c181
    Reviewed-on: https://gerrit.libreoffice.org/82565
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/test/UnitAdmin.cpp b/test/UnitAdmin.cpp
index bbc0cca62..b28caa467 100644
--- a/test/UnitAdmin.cpp
+++ b/test/UnitAdmin.cpp
@@ -17,8 +17,6 @@
 #include <Poco/Net/HTTPResponse.h>
 #include <Poco/Net/NameValueCollection.h>
 #include <Poco/Net/NetException.h>
-#include <Poco/StringTokenizer.h>
-#include <Poco/StringTokenizer.h>
 #include <Poco/URI.h>
 
 #include <Common.hpp>
@@ -35,7 +33,6 @@ using Poco::Net::HTTPCookie;
 using Poco::Net::HTTPRequest;
 using Poco::Net::HTTPResponse;
 using Poco::Net::HTTPClientSession;
-using Poco::StringTokenizer;
 
 // Inside the WSD process
 class UnitAdmin : public UnitWSD
@@ -143,8 +140,8 @@ private:
         }
         lock.unlock();
 
-        StringTokenizer tokens(_messageReceived, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-        if (tokens.count() != 1 ||
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' '));
+        if (tokens.size() != 1 ||
             tokens[0] != "NotAuthenticated")
         {
             LOG_INF("testWebSocketWithoutAuth: Unrecognized message format");
@@ -174,8 +171,8 @@ private:
         }
         lock.unlock();
 
-        StringTokenizer tokens(_messageReceived, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-        if (tokens.count() != 1 ||
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' '));
+        if (tokens.size() != 1 ||
             tokens[0] != "InvalidAuthToken")
         {
             LOG_INF("testWebSocketWithIncorrectAuthToken: Unrecognized message format");
@@ -226,8 +223,8 @@ private:
         lock.unlock();
 
         {
-            StringTokenizer tokens(_messageReceived, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-            if (tokens.count() != 5 ||
+            std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' '));
+            if (tokens.size() != 5 ||
                 tokens[0] != "adddoc" ||
                 tokens[2] != documentPath1.substr(documentPath1.find_last_of('/') + 1) )
             {
@@ -254,8 +251,8 @@ private:
         lock.unlock();
 
         {
-            StringTokenizer tokens(_messageReceived, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-            if (tokens.count() != 5 ||
+            std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' '));
+            if (tokens.size() != 5 ||
                 tokens[0] != "adddoc" ||
                 tokens[2] != documentPath1.substr(documentPath1.find_last_of('/') + 1) )
             {
@@ -289,8 +286,8 @@ private:
         lock.unlock();
 
         {
-            StringTokenizer tokens(_messageReceived, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-            if (tokens.count() != 5 ||
+            std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' '));
+            if (tokens.size() != 5 ||
                 tokens[0] != "adddoc" ||
                 tokens[2] != documentPath2.substr(documentPath2.find_last_of('/') + 1) )
             {
@@ -322,8 +319,8 @@ private:
         }
         lock.unlock();
 
-        StringTokenizer tokens(_messageReceived, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-        if (tokens.count() != 2 ||
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' '));
+        if (tokens.size() != 2 ||
             tokens[0] != "active_users_count")
         {
             LOG_INF("testUsersCount: Unrecognized message format");
@@ -355,8 +352,8 @@ private:
         }
         lock.unlock();
 
-        StringTokenizer tokens(_messageReceived, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-        if (tokens.count() != 2 ||
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' '));
+        if (tokens.size() != 2 ||
             tokens[0] != "active_docs_count" ||
             std::stoi(tokens[1]) != _docsCount)
         {
@@ -391,8 +388,8 @@ private:
         }
         lock.unlock();
 
-        StringTokenizer tokens(_messageReceived, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-        if (tokens.count() != 3 ||
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(_messageReceived, ' '));
+        if (tokens.size() != 3 ||
             tokens[0] != "rmdoc" ||
             stoi(tokens[1]) != _docPid1)
         {
diff --git a/test/UnitConvert.cpp b/test/UnitConvert.cpp
index 779eb9a44..61253cdda 100644
--- a/test/UnitConvert.cpp
+++ b/test/UnitConvert.cpp
@@ -23,7 +23,6 @@
 #include <helpers.hpp>
 
 #include <Poco/Timestamp.h>
-#include <Poco/StringTokenizer.h>
 #include <Poco/Net/HTTPServerRequest.h>
 #include <Poco/Net/HTMLForm.h>
 #include <Poco/Net/StringPartSource.h>
diff --git a/test/UnitCopyPaste.cpp b/test/UnitCopyPaste.cpp
index 018c60ea7..ca48667e7 100644
--- a/test/UnitCopyPaste.cpp
+++ b/test/UnitCopyPaste.cpp
@@ -18,7 +18,6 @@
 #include <common/Clipboard.hpp>
 #include <wsd/ClientSession.hpp>
 #include <Poco/Timestamp.h>
-#include <Poco/StringTokenizer.h>
 #include <Poco/Net/HTTPResponse.h>
 #include <Poco/Net/HTTPServerRequest.h>
 #include <Poco/Net/HTMLForm.h>
diff --git a/test/UnitFuzz.cpp b/test/UnitFuzz.cpp
index 8e48d13e6..940c9dcf8 100644
--- a/test/UnitFuzz.cpp
+++ b/test/UnitFuzz.cpp
@@ -21,7 +21,6 @@
 #include <Util.hpp>
 
 #include <Poco/Timestamp.h>
-#include <Poco/StringTokenizer.h>
 #include <Poco/Net/HTTPServerRequest.h>
 
 // Inside the WSD process
diff --git a/test/UnitOOB.cpp b/test/UnitOOB.cpp
index f648e423b..19cb7b599 100644
--- a/test/UnitOOB.cpp
+++ b/test/UnitOOB.cpp
@@ -23,7 +23,6 @@
 #include <Util.hpp>
 
 #include <Poco/Timestamp.h>
-#include <Poco/StringTokenizer.h>
 #include <Poco/Net/HTTPServerRequest.h>
 
 class UnitOOB : public UnitWSD
diff --git a/test/UnitPasswordProtected.cpp b/test/UnitPasswordProtected.cpp
index f20c6580d..7eac89f45 100644
--- a/test/UnitPasswordProtected.cpp
+++ b/test/UnitPasswordProtected.cpp
@@ -51,10 +51,8 @@ UnitBase::TestResult UnitPasswordProtected::testPasswordProtectedDocumentWithout
         helpers::sendTextFrame(socket, "load url=" + documentURL);
 
         const auto response = helpers::getResponseString(socket, "error:", testname);
-        Poco::StringTokenizer tokens(response, " ",
-                                     Poco::StringTokenizer::TOK_IGNORE_EMPTY
-                                         | Poco::StringTokenizer::TOK_TRIM);
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.count());
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(response, ' '));
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.size());
 
         std::string errorCommand;
         std::string errorKind;
@@ -89,10 +87,8 @@ UnitBase::TestResult UnitPasswordProtected::testPasswordProtectedDocumentWithWro
         helpers::sendTextFrame(socket, "load url=" + documentURL + " password=2");
 
         const auto response = helpers::getResponseString(socket, "error:", testname);
-        Poco::StringTokenizer tokens(response, " ",
-                                     Poco::StringTokenizer::TOK_IGNORE_EMPTY
-                                         | Poco::StringTokenizer::TOK_TRIM);
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.count());
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(response, ' '));
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.size());
 
         std::string errorCommand;
         std::string errorKind;
diff --git a/test/UnitRenderingOptions.cpp b/test/UnitRenderingOptions.cpp
index 526eed06c..6437fbc1f 100644
--- a/test/UnitRenderingOptions.cpp
+++ b/test/UnitRenderingOptions.cpp
@@ -50,9 +50,9 @@ void UnitRenderingOptions::invokeTest()
         const auto status = helpers::assertResponseString(socket, "status:", testname);
 
         // Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'.
-        Poco::StringTokenizer tokens(
-            status, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.count());
+        
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(status, ' '));
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), tokens.size());
 
         const std::string token = tokens[5];
         const std::string prefix = "height=";
diff --git a/test/UnitWOPIWatermark.cpp b/test/UnitWOPIWatermark.cpp
index a5d244ee5..b6de3cd90 100644
--- a/test/UnitWOPIWatermark.cpp
+++ b/test/UnitWOPIWatermark.cpp
@@ -136,7 +136,7 @@ public:
 
                 if(!tile.empty())
                 {
-                    Poco::StringTokenizer tokens(tile, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+                    std::vector<std::string> tokens(LOOLProtocol::tokenize(tile, ' '));
                     std::string nviewid = tokens[1].substr(std::string("nviewid=").size());
                     if (!nviewid.empty() && nviewid != "0")
                     {
diff --git a/test/countloolkits.hpp b/test/countloolkits.hpp
index 86c3ef724..7623ffdd5 100644
--- a/test/countloolkits.hpp
+++ b/test/countloolkits.hpp
@@ -18,7 +18,6 @@
 #include <Poco/DirectoryIterator.h>
 #include <Poco/FileStream.h>
 #include <Poco/StreamCopier.h>
-#include <Poco/StringTokenizer.h>
 
 #include <Common.hpp>
 #include "test.hpp"
diff --git a/test/helpers.hpp b/test/helpers.hpp
index fa106f993..b99177d1b 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -25,7 +25,6 @@
 #include <Poco/Net/SecureStreamSocket.h>
 #include <Poco/Net/Socket.h>
 #include <Poco/Path.h>
-#include <Poco/StringTokenizer.h>
 #include <Poco/URI.h>
 
 #include <cppunit/extensions/HelperMacros.h>
@@ -524,7 +523,7 @@ inline
 void parseDocSize(const std::string& message, const std::string& type,
                   int& part, int& parts, int& width, int& height, int& viewid)
 {
-    Poco::StringTokenizer tokens(message, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+    std::vector<std::string> tokens(LOOLProtocol::tokenize(message, ' '));
 
     // Expected format is something like 'type= parts= current= width= height='.
     const std::string text = tokens[0].substr(std::string("type=").size());
@@ -553,7 +552,7 @@ std::vector<char> assertTileMessage(LOOLWebSocket& ws, const std::string& testna
     const std::vector<char> response = getTileMessage(ws, testname);
 
     const std::string firstLine = LOOLProtocol::getFirstLine(response);
-    Poco::StringTokenizer tileTokens(firstLine, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+    std::vector<std::string> tileTokens(LOOLProtocol::tokenize(firstLine, ' '));
     CPPUNIT_ASSERT_EQUAL(std::string("tile:"), tileTokens[0]);
     CPPUNIT_ASSERT_EQUAL(std::string("part="), tileTokens[1].substr(0, std::string("part=").size()));
     CPPUNIT_ASSERT_EQUAL(std::string("width="), tileTokens[2].substr(0, std::string("width=").size()));
diff --git a/test/httpcrashtest.cpp b/test/httpcrashtest.cpp
index d0769e9ef..1d271725b 100644
--- a/test/httpcrashtest.cpp
+++ b/test/httpcrashtest.cpp
@@ -30,7 +30,6 @@
 #include <Poco/Net/Socket.h>
 #include <Poco/Path.h>
 #include <Poco/StreamCopier.h>
-#include <Poco/StringTokenizer.h>
 #include <Poco/Thread.h>
 #include <Poco/URI.h>
 #include <cppunit/extensions/HelperMacros.h>
diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp
index 1e08ba75c..9ba782803 100644
--- a/test/httpwserror.cpp
+++ b/test/httpwserror.cpp
@@ -107,8 +107,8 @@ void HTTPWSError::testBadDocLoadFail()
         sendTextFrame(socket, "load url=" + documentURL, testname);
 
         const auto response = getResponseString(socket, "error:", testname);
-        Poco::StringTokenizer tokens(response, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
-        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.count());
+        std::vector<std::string> tokens(LOOLProtocol::tokenize(response, ' '));
+        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), tokens.size());
 
         std::string errorCommand;
         std::string errorKind;
diff --git a/test/test.cpp b/test/test.cpp
index 79565a526..71d058e4e 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -29,10 +29,11 @@
 #include <Poco/DirectoryIterator.h>
 #include <Poco/FileStream.h>
 #include <Poco/StreamCopier.h>
-#include <Poco/StringTokenizer.h>
 
 #include <Log.hpp>
 
+#include "common/Protocol.hpp"
+
 class HTTPGetTest;
 
 bool filterTests(CPPUNIT_NS::TestRunner& runner, CPPUNIT_NS::Test* testRegistry, const std::string& testName)
@@ -217,8 +218,8 @@ std::vector<int> getProcPids(const char* exec_filename)
                 Poco::FileInputStream stat(procEntry.toString() + "/stat");
                 std::string statString;
                 Poco::StreamCopier::copyToString(stat, statString);
-                Poco::StringTokenizer tokens(statString, " ");
-                if (tokens.count() > 6 && tokens[1].find(exec_filename) == 0)
+                std::vector<std::string> tokens(LOOLProtocol::tokenize(statString, ' '));
+                if (tokens.size() > 6 && tokens[1].find(exec_filename) == 0)
                 {
                     // We could have several make checks running at once.
                     int kidGrp = std::atoi(tokens[4].c_str());


More information about the Libreoffice-commits mailing list