blob: 34cb5825be3f9afd83e5bae6a8f23d3f4c81e5d7 [file] [log] [blame]
Steve DiBenedetto6214e562014-03-15 16:27:04 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev319f2c82015-01-07 14:56:53 -08003 * Copyright (c) 2014-2015, 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
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080041BOOST_FIXTURE_TEST_SUITE(MgmtFibEnumerationPublisher, FibEnumerationPublisherFixture)
Steve DiBenedetto6214e562014-03-15 16:27:04 -060042
43BOOST_AUTO_TEST_CASE(TestFibEnumerationPublisher)
44{
45 for (int i = 0; i < 87; i++)
46 {
47 Name prefix("/test");
48 prefix.appendSegment(i);
49
50 shared_ptr<DummyFace> dummy1(make_shared<DummyFace>());
51 shared_ptr<DummyFace> dummy2(make_shared<DummyFace>());
52
53 shared_ptr<fib::Entry> entry = m_fib.insert(prefix).first;
54 entry->addNextHop(dummy1, std::numeric_limits<uint64_t>::max() - 1);
55 entry->addNextHop(dummy2, std::numeric_limits<uint64_t>::max() - 2);
56
57 m_referenceEntries.insert(entry);
58 }
59 for (int i = 0; i < 2; i++)
60 {
61 Name prefix("/test2");
62 prefix.appendSegment(i);
63
64 shared_ptr<DummyFace> dummy1(make_shared<DummyFace>());
65 shared_ptr<DummyFace> dummy2(make_shared<DummyFace>());
66
67 shared_ptr<fib::Entry> entry = m_fib.insert(prefix).first;
68 entry->addNextHop(dummy1, std::numeric_limits<uint8_t>::max() - 1);
69 entry->addNextHop(dummy2, std::numeric_limits<uint8_t>::max() - 2);
70
71 m_referenceEntries.insert(entry);
72 }
73
74 ndn::EncodingBuffer buffer;
75
Junxiao Shic099ddb2014-12-25 20:53:20 -070076 m_face->onReceiveData.connect(
77 bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock, this, _1));
Steve DiBenedetto6214e562014-03-15 16:27:04 -060078
79 m_publisher.publish();
80 BOOST_REQUIRE(m_finished);
81}
82
83BOOST_AUTO_TEST_SUITE_END()
84
85} // namespace tests
86} // namespace nfd