Steve DiBenedetto | 6214e56 | 2014-03-15 16:27:04 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "mgmt/fib-enumeration-publisher.hpp" |
| 8 | |
| 9 | #include "mgmt/app-face.hpp" |
| 10 | #include "mgmt/internal-face.hpp" |
| 11 | |
| 12 | #include "tests/test-common.hpp" |
| 13 | #include "../face/dummy-face.hpp" |
| 14 | |
| 15 | #include "fib-enumeration-publisher-common.hpp" |
| 16 | |
| 17 | #include <ndn-cpp-dev/encoding/tlv.hpp> |
| 18 | |
| 19 | namespace nfd { |
| 20 | namespace tests { |
| 21 | |
| 22 | NFD_LOG_INIT("TestFibEnumerationPublisher"); |
| 23 | |
| 24 | |
| 25 | |
| 26 | BOOST_FIXTURE_TEST_SUITE(MgmtFibEnumeration, FibEnumerationPublisherFixture) |
| 27 | |
| 28 | BOOST_AUTO_TEST_CASE(TestFibEnumerationPublisher) |
| 29 | { |
| 30 | for (int i = 0; i < 87; i++) |
| 31 | { |
| 32 | Name prefix("/test"); |
| 33 | prefix.appendSegment(i); |
| 34 | |
| 35 | shared_ptr<DummyFace> dummy1(make_shared<DummyFace>()); |
| 36 | shared_ptr<DummyFace> dummy2(make_shared<DummyFace>()); |
| 37 | |
| 38 | shared_ptr<fib::Entry> entry = m_fib.insert(prefix).first; |
| 39 | entry->addNextHop(dummy1, std::numeric_limits<uint64_t>::max() - 1); |
| 40 | entry->addNextHop(dummy2, std::numeric_limits<uint64_t>::max() - 2); |
| 41 | |
| 42 | m_referenceEntries.insert(entry); |
| 43 | } |
| 44 | for (int i = 0; i < 2; i++) |
| 45 | { |
| 46 | Name prefix("/test2"); |
| 47 | prefix.appendSegment(i); |
| 48 | |
| 49 | shared_ptr<DummyFace> dummy1(make_shared<DummyFace>()); |
| 50 | shared_ptr<DummyFace> dummy2(make_shared<DummyFace>()); |
| 51 | |
| 52 | shared_ptr<fib::Entry> entry = m_fib.insert(prefix).first; |
| 53 | entry->addNextHop(dummy1, std::numeric_limits<uint8_t>::max() - 1); |
| 54 | entry->addNextHop(dummy2, std::numeric_limits<uint8_t>::max() - 2); |
| 55 | |
| 56 | m_referenceEntries.insert(entry); |
| 57 | } |
| 58 | |
| 59 | ndn::EncodingBuffer buffer; |
| 60 | |
| 61 | m_face->onReceiveData += |
| 62 | bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock, this, _1); |
| 63 | |
| 64 | m_publisher.publish(); |
| 65 | BOOST_REQUIRE(m_finished); |
| 66 | } |
| 67 | |
| 68 | BOOST_AUTO_TEST_SUITE_END() |
| 69 | |
| 70 | } // namespace tests |
| 71 | } // namespace nfd |