Debian Codegraph @

ucb/qa/cppunit/webdav/webdav_local_neon.cxx

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #include <cppunit/TestFixture.h>
11 #include <cppunit/extensions/HelperMacros.h>
12 #include <cppunit/plugin/TestPlugIn.h>
13 #include <CurlUri.hxx>
14
15 using namespace http_dav_ucp;
16
17 namespace
18 {
19
20 class webdav_local_test: public CppUnit::TestFixture
21 {
22
23 public:
24 void WebdavUriTest();
25 void WebdavUriTest2();
26
27 // Change the following lines only, if you add, remove or rename
28 // member functions of the current class,
29 // because these macros are need by auto register mechanism.
30
31 CPPUNIT_TEST_SUITE( webdav_local_test );
32 CPPUNIT_TEST( WebdavUriTest );
33 CPPUNIT_TEST( WebdavUriTest2 );
34 CPPUNIT_TEST_SUITE_END();
35 }; // class webdav_local_test
36
37 void webdav_local_test::WebdavUriTest()
38 {
39 //try URL decomposition
40 CurlUri aURI(u"http://user%[email protected]:8040/aService/asegment/nextsegment/check.this?test=true&link=http://anotherserver.com/%3Fcheck=theapplication%26os=linuxintel%26lang=en-US%26version=5.2.0" );
41 CPPUNIT_ASSERT_EQUAL( u"http"_ustr, aURI.GetScheme() );
42 CPPUNIT_ASSERT_EQUAL( u"server.biz"_ustr, aURI.GetHost() );
43 CPPUNIT_ASSERT_EQUAL( u"user%40anothername"_ustr, aURI.GetUser() );
44 CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), aURI.GetPort() );
45 CPPUNIT_ASSERT_EQUAL( u"/aService/asegment/nextsegment/check.this?test=true&link=http://anotherserver.com/%3Fcheck=theapplication%26os=linuxintel%26lang=en-US%26version=5.2.0"_ustr, aURI.GetRelativeReference() );
46
47 CurlUri uri2(aURI.CloneWithRelativeRefPathAbsolute(u"/foo/bar"));
48 CPPUNIT_ASSERT_EQUAL( u"http"_ustr, uri2.GetScheme() );
49 CPPUNIT_ASSERT_EQUAL( u"server.biz"_ustr, uri2.GetHost() );
50 CPPUNIT_ASSERT_EQUAL( u"user%40anothername"_ustr, uri2.GetUser() );
51 CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri2.GetPort() );
52 CPPUNIT_ASSERT_EQUAL( u"/foo/bar"_ustr, uri2.GetRelativeReference() );
53 CPPUNIT_ASSERT_EQUAL( u"http://user%[email protected]:8040/foo/bar"_ustr, uri2.GetURI() );
54
55 CurlUri uri3(aURI.CloneWithRelativeRefPathAbsolute(u"/?query#fragment"));
56 CPPUNIT_ASSERT_EQUAL( u"http"_ustr, uri3.GetScheme() );
57 CPPUNIT_ASSERT_EQUAL( u"server.biz"_ustr, uri3.GetHost() );
58 CPPUNIT_ASSERT_EQUAL( u"user%40anothername"_ustr, uri3.GetUser() );
59 CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri3.GetPort() );
60 CPPUNIT_ASSERT_EQUAL( u"/?query#fragment"_ustr, uri3.GetRelativeReference() );
61 CPPUNIT_ASSERT_EQUAL( u"http://user%[email protected]:8040/?query#fragment"_ustr, uri3.GetURI() );
62 }
63
64 void webdav_local_test::WebdavUriTest2()
65 {
66 CurlUri aURI(u"https://foo:[email protected]:8040/aService#aaa" );
67 CPPUNIT_ASSERT_EQUAL( u"https"_ustr, aURI.GetScheme() );
68 CPPUNIT_ASSERT_EQUAL( u"server.biz"_ustr, aURI.GetHost() );
69 CPPUNIT_ASSERT_EQUAL( u"foo"_ustr, aURI.GetUser() );
70 CPPUNIT_ASSERT_EQUAL( u"bar"_ustr, aURI.GetPassword() );
71 CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), aURI.GetPort() );
72 CPPUNIT_ASSERT_EQUAL( u"/aService#aaa"_ustr, aURI.GetRelativeReference() );
73
74 CurlUri uri2(aURI.CloneWithRelativeRefPathAbsolute(u"/foo/bar"));
75 CPPUNIT_ASSERT_EQUAL( u"https"_ustr, uri2.GetScheme() );
76 CPPUNIT_ASSERT_EQUAL( u"server.biz"_ustr, uri2.GetHost() );
77 CPPUNIT_ASSERT_EQUAL( u"foo"_ustr, uri2.GetUser() );
78 CPPUNIT_ASSERT_EQUAL( u"bar"_ustr, uri2.GetPassword() );
79 CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), uri2.GetPort() );
80 CPPUNIT_ASSERT_EQUAL( u"/foo/bar"_ustr, uri2.GetRelativeReference() );
81 CPPUNIT_ASSERT_EQUAL( u"https://foo:[email protected]:8040/foo/bar"_ustr, uri2.GetURI() );
82
83 CurlUri uri3(aURI.CloneWithRelativeRefPathAbsolute(u"/?query"));
84 CPPUNIT_ASSERT_EQUAL( u"https"_ustr, uri3.GetScheme() );
85 CPPUNIT_ASSERT_EQUAL( u"server.biz"_ustr, uri3.GetHost() );
86 CPPUNIT_ASSERT_EQUAL( u"foo"_ustr, uri3.GetUser() );
87 CPPUNIT_ASSERT_EQUAL( u"bar"_ustr, uri3.GetPassword() );
88 CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri3.GetPort() );
89 CPPUNIT_ASSERT_EQUAL( u"/?query"_ustr, uri3.GetRelativeReference() );
90 CPPUNIT_ASSERT_EQUAL( u"https://foo:[email protected]:8040/?query"_ustr, uri3.GetURI() );
91 }
92
93 CPPUNIT_TEST_SUITE_REGISTRATION( webdav_local_test );
94 }
95
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */