blob: 725d51e03a989ea48154b954e3bb86c677c37e50 [file] [log] [blame]
Steve DiBenedetto6214e562014-03-15 16:27:04 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -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 *
10 * This file is part of NFD (Named Data Networking Forwarding Daemon).
11 * See AUTHORS.md for complete list of NFD authors and contributors.
12 *
13 * NFD is free software: you can redistribute it and/or modify it under the terms
14 * of the GNU General Public License as published by the Free Software Foundation,
15 * either version 3 of the License, or (at your option) any later version.
16 *
17 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 * PURPOSE. See the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
23 **/
Steve DiBenedetto6214e562014-03-15 16:27:04 -060024
25#include "mgmt/fib-enumeration-publisher.hpp"
26
27#include "mgmt/app-face.hpp"
28#include "mgmt/internal-face.hpp"
29
30#include "tests/test-common.hpp"
31#include "../face/dummy-face.hpp"
32
33#include "fib-enumeration-publisher-common.hpp"
34
35#include <ndn-cpp-dev/encoding/tlv.hpp>
36
37namespace nfd {
38namespace tests {
39
40NFD_LOG_INIT("TestFibEnumerationPublisher");
41
42
43
44BOOST_FIXTURE_TEST_SUITE(MgmtFibEnumeration, FibEnumerationPublisherFixture)
45
46BOOST_AUTO_TEST_CASE(TestFibEnumerationPublisher)
47{
48 for (int i = 0; i < 87; i++)
49 {
50 Name prefix("/test");
51 prefix.appendSegment(i);
52
53 shared_ptr<DummyFace> dummy1(make_shared<DummyFace>());
54 shared_ptr<DummyFace> dummy2(make_shared<DummyFace>());
55
56 shared_ptr<fib::Entry> entry = m_fib.insert(prefix).first;
57 entry->addNextHop(dummy1, std::numeric_limits<uint64_t>::max() - 1);
58 entry->addNextHop(dummy2, std::numeric_limits<uint64_t>::max() - 2);
59
60 m_referenceEntries.insert(entry);
61 }
62 for (int i = 0; i < 2; i++)
63 {
64 Name prefix("/test2");
65 prefix.appendSegment(i);
66
67 shared_ptr<DummyFace> dummy1(make_shared<DummyFace>());
68 shared_ptr<DummyFace> dummy2(make_shared<DummyFace>());
69
70 shared_ptr<fib::Entry> entry = m_fib.insert(prefix).first;
71 entry->addNextHop(dummy1, std::numeric_limits<uint8_t>::max() - 1);
72 entry->addNextHop(dummy2, std::numeric_limits<uint8_t>::max() - 2);
73
74 m_referenceEntries.insert(entry);
75 }
76
77 ndn::EncodingBuffer buffer;
78
79 m_face->onReceiveData +=
80 bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock, this, _1);
81
82 m_publisher.publish();
83 BOOST_REQUIRE(m_finished);
84}
85
86BOOST_AUTO_TEST_SUITE_END()
87
88} // namespace tests
89} // namespace nfd