Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 1 | /* -*- 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 | |
| 26 | #include "nfd-status/strategy-choice-module.hpp" |
| 27 | |
| 28 | #include "module-fixture.hpp" |
| 29 | |
| 30 | namespace nfd { |
| 31 | namespace tools { |
| 32 | namespace nfd_status { |
| 33 | namespace tests { |
| 34 | |
| 35 | BOOST_AUTO_TEST_SUITE(NfdStatus) |
| 36 | BOOST_FIXTURE_TEST_SUITE(TestStrategyChoiceModule, ModuleFixture<StrategyChoiceModule>) |
| 37 | |
| 38 | const 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 | |
| 55 | const std::string STATUS_TEXT = std::string(R"TEXT( |
| 56 | Strategy choices: |
| 57 | / strategy=/localhost/nfd/strategy/best-route/%FD%04 |
| 58 | /localhost strategy=/localhost/nfd/strategy/multicast/%FD%01 |
| 59 | )TEXT").substr(1); |
| 60 | |
| 61 | BOOST_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 | |
| 77 | BOOST_AUTO_TEST_SUITE_END() // TestStrategyChoiceModule |
| 78 | BOOST_AUTO_TEST_SUITE_END() // NfdStatus |
| 79 | |
| 80 | } // namespace tests |
| 81 | } // namespace nfd_status |
| 82 | } // namespace tools |
| 83 | } // namespace nfd |