blob: 80b0c38a6898aec6db410a494fcee33e0a6697ec [file] [log] [blame]
Teng Liang04d5ce62018-08-06 10:20:24 +08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
Davide Pesavento3dade002019-03-19 11:29:56 -06003 * Copyright (c) 2014-2019, Regents of the University of California,
Teng Liang04d5ce62018-08-06 10:20:24 +08004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "rib/service.hpp"
Davide Pesavento2cae8ca2019-04-18 20:48:05 -040027#include "common/global.hpp"
Davide Pesavento3dade002019-03-19 11:29:56 -060028
Teng Liang04d5ce62018-08-06 10:20:24 +080029#include "tests/test-common.hpp"
Davide Pesavento3dade002019-03-19 11:29:56 -060030#include "tests/daemon/rib-io-fixture.hpp"
Teng Liang04d5ce62018-08-06 10:20:24 +080031
32namespace nfd {
33namespace rib {
34namespace tests {
35
Davide Pesavento14e71f02019-03-28 17:35:25 -040036using namespace nfd::tests;
37
38BOOST_FIXTURE_TEST_SUITE(TestService, RibIoFixture)
Teng Liang04d5ce62018-08-06 10:20:24 +080039
40BOOST_AUTO_TEST_CASE(Basic)
41{
Junxiao Shif4cfed12018-08-22 23:26:29 +000042 ConfigSection section;
43 section.put("face_system.unix.path", "/var/run/nfd.sock");
44
Teng Liang04d5ce62018-08-06 10:20:24 +080045 ndn::KeyChain ribKeyChain;
Teng Liang04d5ce62018-08-06 10:20:24 +080046
47 BOOST_CHECK_THROW(Service::get(), std::logic_error);
Junxiao Shif4cfed12018-08-22 23:26:29 +000048 BOOST_CHECK_THROW(Service(section, ribKeyChain), std::logic_error);
Teng Liang04d5ce62018-08-06 10:20:24 +080049
50 runOnRibIoService([&] {
51 {
52 BOOST_CHECK_THROW(Service::get(), std::logic_error);
Junxiao Shif4cfed12018-08-22 23:26:29 +000053 Service ribService(section, ribKeyChain);
Teng Liang04d5ce62018-08-06 10:20:24 +080054 BOOST_CHECK_EQUAL(&ribService, &Service::get());
55 }
56 BOOST_CHECK_THROW(Service::get(), std::logic_error);
Junxiao Shif4cfed12018-08-22 23:26:29 +000057 Service ribService(section, ribKeyChain);
58 BOOST_CHECK_THROW(Service(section, ribKeyChain), std::logic_error);
Teng Liang04d5ce62018-08-06 10:20:24 +080059 });
60}
61
62BOOST_AUTO_TEST_SUITE_END() // TestRibService
63
64} // namespace tests
65} // namespace rib
66} // namespace nfd