summaryrefslogtreecommitdiff
path: root/ucb/qa
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-09-24 13:35:54 +0200
committerGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-09-25 10:57:29 +0000
commite62c02a089e454eeea472e758e113e7e28568a02 (patch)
treec8961938cac9945300571be9be7819df7d6aba03 /ucb/qa
parent0e156497a87608f266389192f6d22d35076a6694 (diff)
tdf#102499 (1): Add WebDAV test to check HTTP reponse status codes retry
Change-Id: I4ff36df3ac1cc0788322768378fb74f70892f922 Reviewed-on: https://gerrit.libreoffice.org/29245 Tested-by: Giuseppe Castagno <giuseppe.castagno@acca-esse.eu> Reviewed-by: Giuseppe Castagno <giuseppe.castagno@acca-esse.eu>
Diffstat (limited to 'ucb/qa')
-rw-r--r--ucb/qa/cppunit/webdav/webdav_options.cxx2
-rw-r--r--ucb/qa/cppunit/webdav/webdav_resource_access.cxx85
2 files changed, 87 insertions, 0 deletions
diff --git a/ucb/qa/cppunit/webdav/webdav_options.cxx b/ucb/qa/cppunit/webdav/webdav_options.cxx
index bad3adc8da77..924eaf9a142d 100644
--- a/ucb/qa/cppunit/webdav/webdav_options.cxx
+++ b/ucb/qa/cppunit/webdav/webdav_options.cxx
@@ -9,6 +9,8 @@
#include <test/bootstrapfixture.hxx>
#include <cppunit/plugin/TestPlugIn.h>
+#include "DAVResourceAccess.hxx"
+#include "DAVException.hxx"
#include "DAVTypes.hxx"
namespace
diff --git a/ucb/qa/cppunit/webdav/webdav_resource_access.cxx b/ucb/qa/cppunit/webdav/webdav_resource_access.cxx
new file mode 100644
index 000000000000..4097d9e4b73a
--- /dev/null
+++ b/ucb/qa/cppunit/webdav/webdav_resource_access.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <cppunit/plugin/TestPlugIn.h>
+#include "DAVResourceAccess.hxx"
+#include "DAVException.hxx"
+
+using namespace webdav_ucp;
+
+namespace
+{
+
+ class webdav_resource_access_test: public test::BootstrapFixture
+ {
+
+ public:
+ webdav_resource_access_test() : BootstrapFixture( true, true ) {}
+
+ // initialise your test code values here.
+ void setUp() override;
+
+ void tearDown() override;
+
+ void DAVCheckRetries();
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE( webdav_resource_access_test );
+ CPPUNIT_TEST( DAVCheckRetries );
+ CPPUNIT_TEST_SUITE_END();
+ }; // class webdav_local_test
+
+ // initialise your test code values here.
+ void webdav_resource_access_test::setUp()
+ {
+ }
+
+ void webdav_resource_access_test::tearDown()
+ {
+ }
+
+ // test when http connection should retry
+ void webdav_resource_access_test::DAVCheckRetries()
+ {
+ // instantiate a resource access class
+ DAVResourceAccess ResourceAccess(nullptr, nullptr, "http://url");
+ // first check: all http errors from 100 to 399 should return true, to force a retry
+ for (auto i = SC_CONTINUE; i < SC_BAD_REQUEST; i++)
+ {
+ const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i );
+ CPPUNIT_ASSERT_EQUAL( true , ResourceAccess.handleException( aTheException, 1 ) );
+ }
+ // http error code from 400 to 499 should NOT force a retry
+ for (auto i = SC_BAD_REQUEST; i < SC_INTERNAL_SERVER_ERROR; i++)
+ {
+ const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i );
+ CPPUNIT_ASSERT_EQUAL( false , ResourceAccess.handleException( aTheException, 1 ) );
+ }
+ // http error code from 500 (SC_INTERNAL_SERVER_ERROR) up should force a retry
+ // except: SC_NOT_IMPLEMENTED
+ for (auto i = SC_INTERNAL_SERVER_ERROR; i < 2000; i++)
+ {
+ const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i );
+ if( i != SC_NOT_IMPLEMENTED )
+ CPPUNIT_ASSERT_EQUAL( true , ResourceAccess.handleException( aTheException, 1 ) );
+ else
+ CPPUNIT_ASSERT_EQUAL( false , ResourceAccess.handleException( aTheException, 1 ) );
+ }
+ }
+
+ CPPUNIT_TEST_SUITE_REGISTRATION( webdav_resource_access_test );
+} // namespace rtl_random
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */