[Libreoffice-commits] online.git: test/data test/integration-http-server.cpp
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 12 07:57:46 UTC 2019
test/data/convert-to.xlsx |binary
test/integration-http-server.cpp | 40 +++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
New commits:
commit f95cc10438f0cc3d584a6badc33256eb548db4e3
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Dec 12 05:33:09 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Dec 12 08:57:28 2019 +0100
A new convert-to unit test, hopefully taking longer to load.
Change-Id: I8d8291e272a175ab3c846b692bb34b185b2b8278
Reviewed-on: https://gerrit.libreoffice.org/85008
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/test/data/convert-to.xlsx b/test/data/convert-to.xlsx
new file mode 100644
index 000000000..7af9e7063
Binary files /dev/null and b/test/data/convert-to.xlsx differ
diff --git a/test/integration-http-server.cpp b/test/integration-http-server.cpp
index c19c57904..a2ceaca92 100644
--- a/test/integration-http-server.cpp
+++ b/test/integration-http-server.cpp
@@ -51,6 +51,7 @@ class HTTPServerTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testScriptsAndLinksGet);
CPPUNIT_TEST(testScriptsAndLinksPost);
CPPUNIT_TEST(testConvertTo);
+ CPPUNIT_TEST(testConvertTo2);
CPPUNIT_TEST(testConvertToWithForwardedClientIP);
CPPUNIT_TEST_SUITE_END();
@@ -62,6 +63,7 @@ class HTTPServerTest : public CPPUNIT_NS::TestFixture
void testScriptsAndLinksGet();
void testScriptsAndLinksPost();
void testConvertTo();
+ void testConvertTo2();
void testConvertToWithForwardedClientIP();
public:
@@ -375,6 +377,44 @@ void HTTPServerTest::testConvertTo()
CPPUNIT_ASSERT_EQUAL(expectedStream.str(), actualString);
}
+void HTTPServerTest::testConvertTo2()
+{
+ const std::string srcPath = FileUtil::getTempFilePath(TDOC, "convert-to.xlsx", "convertTo_");
+ std::unique_ptr<Poco::Net::HTTPClientSession> session(helpers::createSession(_uri));
+ session->setTimeout(Poco::Timespan(5, 0)); // 5 seconds.
+
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/lool/convert-to");
+ Poco::Net::HTMLForm form;
+ form.setEncoding(Poco::Net::HTMLForm::ENCODING_MULTIPART);
+ form.set("format", "png");
+ form.addPart("data", new Poco::Net::FilePartSource(srcPath));
+ form.prepareSubmit(request);
+ try
+ {
+ form.write(session->sendRequest(request));
+ }
+ catch (const std::exception& ex)
+ {
+ // In case the server is still starting up.
+ sleep(2);
+ form.write(session->sendRequest(request));
+ }
+
+ Poco::Net::HTTPResponse response;
+ std::stringstream actualStream;
+ std::istream& responseStream = session->receiveResponse(response);
+ Poco::StreamCopier::copyStream(responseStream, actualStream);
+
+ // Remove the temp files.
+ FileUtil::removeFile(srcPath);
+
+ std::string actualString = actualStream.str();
+ CPPUNIT_ASSERT(actualString.size() >= 100);
+// CPPUNIT_ASSERT_EQUAL(actualString[0], 0x89);
+ CPPUNIT_ASSERT_EQUAL(actualString[1], 'P');
+ CPPUNIT_ASSERT_EQUAL(actualString[2], 'N');
+ CPPUNIT_ASSERT_EQUAL(actualString[3], 'G');
+}
void HTTPServerTest::testConvertToWithForwardedClientIP()
{
More information about the Libreoffice-commits
mailing list