[Libreoffice-commits] online.git: loolwsd/test
Henry Castro
hcastro at collabora.com
Mon Apr 25 00:59:19 UTC 2016
loolwsd/test/httpcrashtest.cpp | 1 +
loolwsd/test/httpgettest.cpp | 31 +++++++++++++++++++++++++++++++
loolwsd/test/httpposttest.cpp | 35 ++++++++++++++++++++++++++++++++++-
loolwsd/test/httpwstest.cpp | 1 +
loolwsd/test/test.cpp | 7 +++++++
5 files changed, 74 insertions(+), 1 deletion(-)
New commits:
commit 9720ea378195c775e7114e0d2cc663e7c1c1a395
Author: Henry Castro <hcastro at collabora.com>
Date: Sun Apr 24 20:59:58 2016 -0400
loolwsd: test: add testParams
diff --git a/loolwsd/test/httpcrashtest.cpp b/loolwsd/test/httpcrashtest.cpp
index cc6357f..4d02c36 100644
--- a/loolwsd/test/httpcrashtest.cpp
+++ b/loolwsd/test/httpcrashtest.cpp
@@ -358,5 +358,6 @@ HTTPCrashTest::connectLOKit(Poco::Net::HTTPRequest& request,
}
CPPUNIT_TEST_SUITE_REGISTRATION(HTTPCrashTest);
+//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(HTTPCrashTest, "httpcrashtest");
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/test/httpgettest.cpp b/loolwsd/test/httpgettest.cpp
index 6784028..7961a29 100644
--- a/loolwsd/test/httpgettest.cpp
+++ b/loolwsd/test/httpgettest.cpp
@@ -33,11 +33,13 @@ class HTTPGetTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testDiscovery);
CPPUNIT_TEST(testLOleaflet);
+ CPPUNIT_TEST(testParams);
CPPUNIT_TEST_SUITE_END();
void testDiscovery();
void testLOleaflet();
+ void testParams();
#if ENABLE_SSL
public:
@@ -73,6 +75,7 @@ void HTTPGetTest::testDiscovery()
Poco::Net::HTTPResponse response;
session.receiveResponse(response);
+ CPPUNIT_ASSERT_EQUAL(Poco::Net::HTTPResponse::HTTP_OK, response.getStatus());
CPPUNIT_ASSERT_EQUAL(std::string("text/xml"), response.getContentType());
}
@@ -91,9 +94,37 @@ void HTTPGetTest::testLOleaflet()
Poco::Net::HTTPResponse response;
session.receiveResponse(response);
+ CPPUNIT_ASSERT_EQUAL(Poco::Net::HTTPResponse::HTTP_OK, response.getStatus());
CPPUNIT_ASSERT_EQUAL(std::string("text/html"), response.getContentType());
}
+void HTTPGetTest::testParams()
+{
+#if ENABLE_SSL
+ Poco::URI uri("https://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER));
+ Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort());
+#else
+ Poco::URI uri("http://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER));
+ Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
+#endif
+
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, "/loleaflet/dist/loleaflet.html?access_token=111111111");
+ Poco::Net::HTMLForm param(request);
+ session.sendRequest(request);
+
+ Poco::Net::HTTPResponse response;
+ std::istream& rs = session.receiveResponse(response);
+ CPPUNIT_ASSERT_EQUAL(Poco::Net::HTTPResponse::HTTP_OK, response.getStatus());
+
+ std::string html;
+ Poco::StreamCopier::copyToString(rs, html);
+
+ CPPUNIT_ASSERT(html.find(param["access_token"]) != std::string::npos);
+ CPPUNIT_ASSERT(html.find(uri.getHost()) != std::string::npos);
+ CPPUNIT_ASSERT(html.find(std::string(LOOLWSD_VERSION)) != std::string::npos);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(HTTPGetTest);
+//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(HTTPGetTest, "httpgettest");
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/test/httpposttest.cpp b/loolwsd/test/httpposttest.cpp
index 7ab2c9f..97c8058 100644
--- a/loolwsd/test/httpposttest.cpp
+++ b/loolwsd/test/httpposttest.cpp
@@ -39,6 +39,7 @@ class HTTPPostTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(testCountHowManyLoolkits);
CPPUNIT_TEST(testLOleaflet);
+ CPPUNIT_TEST(testParams);
CPPUNIT_TEST(testConvertTo);
// This should be the last test:
@@ -47,8 +48,9 @@ class HTTPPostTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST_SUITE_END();
void testCountHowManyLoolkits();
- void testConvertTo();
void testLOleaflet();
+ void testParams();
+ void testConvertTo();
void testNoExtraLoolKitsLeft();
#if ENABLE_SSL
@@ -95,9 +97,39 @@ void HTTPPostTest::testLOleaflet()
Poco::Net::HTTPResponse response;
std::istream& rs = session.receiveResponse(response);
+ CPPUNIT_ASSERT_EQUAL(Poco::Net::HTTPResponse::HTTP_OK, response.getStatus());
CPPUNIT_ASSERT_EQUAL(std::string("text/html"), response.getContentType());
}
+void HTTPPostTest::testParams()
+{
+#if ENABLE_SSL
+ Poco::URI uri("https://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER));
+ Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort());
+#else
+ Poco::URI uri("http://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER));
+ Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
+#endif
+
+ Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/loleaflet/dist/loleaflet.html");
+ Poco::Net::HTMLForm form;
+ form.set("access_token", "2222222222");
+ form.prepareSubmit(request);
+ std::ostream& ostr = session.sendRequest(request);
+ form.write(ostr);
+
+ Poco::Net::HTTPResponse response;
+ std::istream& rs = session.receiveResponse(response);
+ CPPUNIT_ASSERT_EQUAL(Poco::Net::HTTPResponse::HTTP_OK, response.getStatus());
+
+ std::string html;
+ Poco::StreamCopier::copyToString(rs, html);
+
+ CPPUNIT_ASSERT(html.find(form["access_token"]) != std::string::npos);
+ CPPUNIT_ASSERT(html.find(uri.getHost()) != std::string::npos);
+ CPPUNIT_ASSERT(html.find(std::string(LOOLWSD_VERSION)) != std::string::npos);
+}
+
void HTTPPostTest::testConvertTo()
{
const auto srcPath = Util::getTempFilePath(TDOC, "hello.odt");
@@ -148,5 +180,6 @@ void HTTPPostTest::testNoExtraLoolKitsLeft()
}
CPPUNIT_TEST_SUITE_REGISTRATION(HTTPPostTest);
+//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(HTTPPostTest, "httpposttest");
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 64dca86..bbeec92 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -1357,5 +1357,6 @@ HTTPWSTest::connectLOKit(Poco::Net::HTTPRequest& request,
}
CPPUNIT_TEST_SUITE_REGISTRATION(HTTPWSTest);
+//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(HTTPWSTest, "httpwstest");
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/test/test.cpp b/loolwsd/test/test.cpp
index ced03e0..78d0d92 100644
--- a/loolwsd/test/test.cpp
+++ b/loolwsd/test/test.cpp
@@ -16,6 +16,8 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/CompilerOutputter.h>
+class HTTPGetTest;
+
/// Dump all the tests registered.
void dumpTests(CPPUNIT_NS::Test* test)
{
@@ -43,9 +45,14 @@ int main(int /*argc*/, char** /*argv*/)
auto all = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
//dumpTests(all);
+ //CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("httpgettest");
+ //CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("httpposttest");
+ //CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("httpwstest");
+ //CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry("httpcrashtest");
CPPUNIT_NS::TestRunner runner;
runner.addTest(all);
+ //runner.addTest(registry.makeTest());
runner.run(controller);
CPPUNIT_NS::CompilerOutputter outputter(&result, std::cerr);
More information about the Libreoffice-commits
mailing list