diff options
author | DarkByt31 <avihs.29@gmail.com> | 2019-09-27 22:26:16 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-09-28 12:26:32 +0200 |
commit | dd014e7029628dd95d2026bcb4fe4a66d75785aa (patch) | |
tree | 0f3f367a34c7948a597b77c4035ac47bb5bb494f /test/WopiTestServer.hpp | |
parent | 022224b7b4bc6195cc9a7e6f637edd86574f0059 (diff) |
tdf#107038 Poco::Timestamp replacement with std::chrono
Util added getHttpTime
WhiteBoxTests added test for getHttpTime
Change-Id: Ifb6a3fb2dc9b059b925e7b881362b72759a8b56b
Reviewed-on: https://gerrit.libreoffice.org/79754
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'test/WopiTestServer.hpp')
-rw-r--r-- | test/WopiTestServer.hpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/test/WopiTestServer.hpp b/test/WopiTestServer.hpp index bdeecd96d..0845ba1a9 100644 --- a/test/WopiTestServer.hpp +++ b/test/WopiTestServer.hpp @@ -41,7 +41,7 @@ private: std::string _fileContent; /// Last modified time of the file - Poco::Timestamp _fileLastModifiedTime; + std::chrono::system_clock::time_point _fileLastModifiedTime; protected: const std::string& getWopiSrc() const { return _wopiSrc; } @@ -54,10 +54,10 @@ protected: void setFileContent(const std::string& fileContent) { _fileContent = fileContent; - _fileLastModifiedTime = Poco::Timestamp(); + _fileLastModifiedTime = std::chrono::system_clock::now(); } - const Poco::Timestamp& getFileLastModifiedTime() const { return _fileLastModifiedTime; } + const std::chrono::system_clock::time_point& getFileLastModifiedTime() const { return _fileLastModifiedTime; } public: WopiTestServer(std::string fileContent = "Hello, world") @@ -126,7 +126,7 @@ protected: fileInfo->set("UserFriendlyName", "test"); fileInfo->set("UserCanWrite", "true"); fileInfo->set("PostMessageOrigin", "localhost"); - fileInfo->set("LastModifiedTime", Poco::DateTimeFormatter::format(Poco::DateTime(_fileLastModifiedTime), Poco::DateTimeFormat::ISO8601_FRAC_FORMAT)); + fileInfo->set("LastModifiedTime", Util::getIso8601FracformatTime(_fileLastModifiedTime)); fileInfo->set("EnableOwnerTermination", "true"); std::ostringstream jsonStream; @@ -137,7 +137,7 @@ protected: std::ostringstream oss; oss << "HTTP/1.1 200 OK\r\n" - "Last-Modified: " << Poco::DateTimeFormatter::format(_fileLastModifiedTime, Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" + "Last-Modified: " << Util::getHttpTime(_fileLastModifiedTime) << "\r\n" "User-Agent: " WOPI_AGENT_STRING "\r\n" "Content-Length: " << responseString.size() << "\r\n" "Content-Type: " << mimeType << "\r\n" @@ -160,7 +160,7 @@ protected: std::ostringstream oss; oss << "HTTP/1.1 200 OK\r\n" - "Last-Modified: " << Poco::DateTimeFormatter::format(_fileLastModifiedTime, Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" + "Last-Modified: " << Util::getHttpTime(_fileLastModifiedTime) << "\r\n" "User-Agent: " WOPI_AGENT_STRING "\r\n" "Content-Length: " << _fileContent.size() << "\r\n" "Content-Type: " << mimeType << "\r\n" @@ -194,7 +194,7 @@ protected: std::ostringstream oss; oss << "HTTP/1.1 200 OK\r\n" - "Last-Modified: " << Poco::DateTimeFormatter::format(_fileLastModifiedTime, Poco::DateTimeFormat::HTTP_FORMAT) << "\r\n" + "Last-Modified: " << Util::getHttpTime(_fileLastModifiedTime) << "\r\n" "User-Agent: " WOPI_AGENT_STRING "\r\n" "Content-Length: " << content.size() << "\r\n" "Content-Type: application/json\r\n" @@ -214,9 +214,7 @@ protected: if (!wopiTimestamp.empty()) { - const std::string fileModifiedTime = - Poco::DateTimeFormatter::format(Poco::DateTime(_fileLastModifiedTime), - Poco::DateTimeFormat::ISO8601_FRAC_FORMAT); + const std::string fileModifiedTime = Util::getIso8601FracformatTime(_fileLastModifiedTime); if (wopiTimestamp != fileModifiedTime) { std::ostringstream oss; @@ -242,7 +240,7 @@ protected: oss << "HTTP/1.1 200 OK\r\n" "User-Agent: " WOPI_AGENT_STRING "\r\n" "\r\n" - "{\"LastModifiedTime\": \"" << Poco::DateTimeFormatter::format(_fileLastModifiedTime, Poco::DateTimeFormat::ISO8601_FRAC_FORMAT) << "\" }"; + "{\"LastModifiedTime\": \"" << Util::getIso8601FracformatTime(_fileLastModifiedTime) << "\" }"; socket->send(oss.str()); socket->shutdown(); |