blob: 68dee9f487f61a9aa1571e47933f4ea65dee2e24 [file] [log] [blame]
Junxiao Shi38f4ce92016-08-04 10:01:52 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2016, Regents of the University of California,
4 * 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
Junxiao Shi331ade72016-08-19 14:07:19 +000026#include "nfdc/strategy-choice-module.hpp"
Junxiao Shi38f4ce92016-08-04 10:01:52 +000027
28#include "module-fixture.hpp"
29
30namespace nfd {
31namespace tools {
Junxiao Shi331ade72016-08-19 14:07:19 +000032namespace nfdc {
Junxiao Shi38f4ce92016-08-04 10:01:52 +000033namespace tests {
34
Junxiao Shi331ade72016-08-19 14:07:19 +000035BOOST_AUTO_TEST_SUITE(Nfdc)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000036BOOST_FIXTURE_TEST_SUITE(TestStrategyChoiceModule, ModuleFixture<StrategyChoiceModule>)
37
38const std::string STATUS_XML = stripXmlSpaces(R"XML(
39 <strategyChoices>
40 <strategyChoice>
41 <namespace>/</namespace>
42 <strategy>
43 <name>/localhost/nfd/strategy/best-route/%FD%04</name>
44 </strategy>
45 </strategyChoice>
46 <strategyChoice>
47 <namespace>/localhost</namespace>
48 <strategy>
49 <name>/localhost/nfd/strategy/multicast/%FD%01</name>
50 </strategy>
51 </strategyChoice>
52 </strategyChoices>
53)XML");
54
55const std::string STATUS_TEXT = std::string(R"TEXT(
56Strategy choices:
57 / strategy=/localhost/nfd/strategy/best-route/%FD%04
58 /localhost strategy=/localhost/nfd/strategy/multicast/%FD%01
59)TEXT").substr(1);
60
61BOOST_AUTO_TEST_CASE(Status)
62{
63 this->fetchStatus();
64 StrategyChoice payload1;
65 payload1.setName("/")
66 .setStrategy("/localhost/nfd/strategy/best-route/%FD%04");
67 StrategyChoice payload2;
68 payload2.setName("/localhost")
69 .setStrategy("/localhost/nfd/strategy/multicast/%FD%01");
70 this->sendDataset("/localhost/nfd/strategy-choice/list", payload1, payload2);
71 this->prepareStatusOutput();
72
73 BOOST_CHECK(statusXml.is_equal(STATUS_XML));
74 BOOST_CHECK(statusText.is_equal(STATUS_TEXT));
75}
76
77BOOST_AUTO_TEST_SUITE_END() // TestStrategyChoiceModule
Junxiao Shi331ade72016-08-19 14:07:19 +000078BOOST_AUTO_TEST_SUITE_END() // Nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +000079
80} // namespace tests
Junxiao Shi331ade72016-08-19 14:07:19 +000081} // namespace nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +000082} // namespace tools
83} // namespace nfd