102 lines
3.0 KiB
C++
102 lines
3.0 KiB
C++
/***************************************************************************
|
|
* Copyright (C) 2021 by gempa GmbH *
|
|
* *
|
|
* All Rights Reserved. *
|
|
* *
|
|
* NOTICE: All information contained herein is, and remains *
|
|
* the property of gempa GmbH and its suppliers, if any. The intellectual *
|
|
* and technical concepts contained herein are proprietary to gempa GmbH *
|
|
* and its suppliers. *
|
|
* Dissemination of this information or reproduction of this material *
|
|
* is strictly forbidden unless prior written permission is obtained *
|
|
* from gempa GmbH. *
|
|
***************************************************************************/
|
|
|
|
|
|
#define SEISCOMP_TEST_MODULE gempa
|
|
#include <seiscomp/unittest/unittests.h>
|
|
|
|
#include <gempa/caps/url.h>
|
|
|
|
|
|
namespace gc = Gempa::CAPS;
|
|
namespace bu = boost::unit_test;
|
|
|
|
using namespace gc;
|
|
using namespace std;
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(gempa_common_caps_url)
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
|
|
|
|
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
BOOST_AUTO_TEST_CASE(url_construct) {
|
|
Url url;
|
|
BOOST_CHECK_EQUAL(url.host, "");
|
|
BOOST_CHECK_EQUAL(url.user, "");
|
|
BOOST_CHECK_EQUAL(url.password, "");
|
|
BOOST_CHECK_EQUAL(url.port, 0);
|
|
BOOST_CHECK_EQUAL(url.protocol, "");
|
|
}
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
|
|
|
|
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
BOOST_AUTO_TEST_CASE(url_parse) {
|
|
{
|
|
Url url;
|
|
BOOST_CHECK(url.parse("localhost"));
|
|
BOOST_CHECK_EQUAL(url.host, "localhost");
|
|
BOOST_CHECK_EQUAL(url.port, 18002);
|
|
}
|
|
|
|
{
|
|
Url url;
|
|
BOOST_CHECK(url.parse("localhost:18003"));
|
|
BOOST_CHECK_EQUAL(url.host, "localhost");
|
|
BOOST_CHECK_EQUAL(url.port, 18003);
|
|
BOOST_CHECK_EQUAL(url.protocol, "caps");
|
|
}
|
|
|
|
{
|
|
Url url;
|
|
BOOST_CHECK(!url.parse("localhost:65536"));
|
|
BOOST_CHECK(!url.parse("localhost:-1"));
|
|
BOOST_CHECK(!url.parse("localhost:0"));
|
|
}
|
|
|
|
{
|
|
Url url;
|
|
BOOST_CHECK(url.parse("caps:gempa@localhost:18003"));
|
|
BOOST_CHECK_EQUAL(url.host, "localhost");
|
|
BOOST_CHECK_EQUAL(url.user, "caps");
|
|
BOOST_CHECK_EQUAL(url.password, "gempa");
|
|
BOOST_CHECK_EQUAL(url.port, 18003);
|
|
BOOST_CHECK_EQUAL(url.protocol, "caps");
|
|
|
|
}
|
|
|
|
{
|
|
Url url;
|
|
BOOST_CHECK(url.parse("capss://guest:guest@caps.gempa.de:18008"));
|
|
BOOST_CHECK_EQUAL(url.host, "caps.gempa.de");
|
|
BOOST_CHECK_EQUAL(url.user, "guest");
|
|
BOOST_CHECK_EQUAL(url.password, "guest");
|
|
BOOST_CHECK_EQUAL(url.port, 18008);
|
|
BOOST_CHECK_EQUAL(url.protocol, "capss");
|
|
}
|
|
|
|
}
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
|
|
|
|
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
BOOST_AUTO_TEST_SUITE_END()
|