Junxiao Shi | f2bfb44 | 2018-01-05 12:34:57 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2014-2018, 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 "mgmt/cs-manager.hpp" |
| 27 | #include "nfd-manager-common-fixture.hpp" |
| 28 | #include <ndn-cxx/mgmt/nfd/cs-info.hpp> |
| 29 | |
| 30 | namespace nfd { |
| 31 | namespace tests { |
| 32 | |
| 33 | class CsManagerFixture : public NfdManagerCommonFixture |
| 34 | { |
| 35 | public: |
| 36 | CsManagerFixture() |
| 37 | : m_cs(m_forwarder.getCs()) |
| 38 | , m_fwCnt(const_cast<ForwarderCounters&>(m_forwarder.getCounters())) |
| 39 | , m_manager(m_cs, m_fwCnt, m_dispatcher, *m_authenticator) |
| 40 | { |
| 41 | setTopPrefix(); |
| 42 | // setPrivilege("cs"); not needed until there's a control command |
| 43 | } |
| 44 | |
| 45 | protected: |
| 46 | Cs& m_cs; |
| 47 | ForwarderCounters& m_fwCnt; |
| 48 | CsManager m_manager; |
| 49 | }; |
| 50 | |
| 51 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 52 | BOOST_FIXTURE_TEST_SUITE(TestCsManager, CsManagerFixture) |
| 53 | |
| 54 | BOOST_AUTO_TEST_CASE(Info) |
| 55 | { |
| 56 | m_fwCnt.nCsHits.set(362); |
| 57 | m_fwCnt.nCsMisses.set(1493); |
| 58 | |
| 59 | receiveInterest(Interest("/localhost/nfd/cs/info")); |
| 60 | Block dataset = concatenateResponses(); |
| 61 | dataset.parse(); |
| 62 | BOOST_REQUIRE_EQUAL(dataset.elements_size(), 1); |
| 63 | |
| 64 | ndn::nfd::CsInfo info(*dataset.elements_begin()); |
| 65 | BOOST_CHECK_EQUAL(info.getNHits(), 362); |
| 66 | BOOST_CHECK_EQUAL(info.getNMisses(), 1493); |
| 67 | } |
| 68 | |
| 69 | BOOST_AUTO_TEST_SUITE_END() // TestCsManager |
| 70 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
| 71 | |
| 72 | } // namespace tests |
| 73 | } // namespace nfd |