blob: ed330aaf535e99f3b89105eacf1ecfa3de0e90c7 [file] [log] [blame]
Steve DiBenedetto6214e562014-03-15 16:27:04 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Vince Lehman5144f822014-07-23 15:12:56 -07003 * Copyright (c) 2014, 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
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070010 *
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/>.
Vince Lehman5144f822014-07-23 15:12:56 -070024 */
Steve DiBenedetto6214e562014-03-15 16:27:04 -060025
26#include "mgmt/fib-enumeration-publisher.hpp"
27
28#include "mgmt/app-face.hpp"
29#include "mgmt/internal-face.hpp"
30
31#include "tests/test-common.hpp"
32#include "../face/dummy-face.hpp"
33
34#include "fib-enumeration-publisher-common.hpp"
35
Alexander Afanasyev4a771362014-04-24 21:29:33 -070036#include <ndn-cxx/encoding/tlv.hpp>
Steve DiBenedetto6214e562014-03-15 16:27:04 -060037
38namespace nfd {
39namespace tests {
40
41NFD_LOG_INIT("TestFibEnumerationPublisher");
42
43
44
45BOOST_FIXTURE_TEST_SUITE(MgmtFibEnumeration, FibEnumerationPublisherFixture)
46
47BOOST_AUTO_TEST_CASE(TestFibEnumerationPublisher)
48{
49 for (int i = 0; i < 87; i++)
50 {
51 Name prefix("/test");
52 prefix.appendSegment(i);
53
54 shared_ptr<DummyFace> dummy1(make_shared<DummyFace>());
55 shared_ptr<DummyFace> dummy2(make_shared<DummyFace>());
56
57 shared_ptr<fib::Entry> entry = m_fib.insert(prefix).first;
58 entry->addNextHop(dummy1, std::numeric_limits<uint64_t>::max() - 1);
59 entry->addNextHop(dummy2, std::numeric_limits<uint64_t>::max() - 2);
60
61 m_referenceEntries.insert(entry);
62 }
63 for (int i = 0; i < 2; i++)
64 {
65 Name prefix("/test2");
66 prefix.appendSegment(i);
67
68 shared_ptr<DummyFace> dummy1(make_shared<DummyFace>());
69 shared_ptr<DummyFace> dummy2(make_shared<DummyFace>());
70
71 shared_ptr<fib::Entry> entry = m_fib.insert(prefix).first;
72 entry->addNextHop(dummy1, std::numeric_limits<uint8_t>::max() - 1);
73 entry->addNextHop(dummy2, std::numeric_limits<uint8_t>::max() - 2);
74
75 m_referenceEntries.insert(entry);
76 }
77
78 ndn::EncodingBuffer buffer;
79
80 m_face->onReceiveData +=
81 bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock, this, _1);
82
83 m_publisher.publish();
84 BOOST_REQUIRE(m_finished);
85}
86
87BOOST_AUTO_TEST_SUITE_END()
88
89} // namespace tests
90} // namespace nfd