Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014-2019, Regents of the University of California, |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 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 | |
Spyridon Mastorakis | d0381c0 | 2015-02-19 10:29:41 -0800 | [diff] [blame] | 26 | #include "face/null-face.hpp" |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 27 | #include "face/null-transport.hpp" |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 28 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 29 | #include "tests/daemon/global-io-fixture.hpp" |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 30 | #include "transport-test-common.hpp" |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 31 | |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 32 | namespace nfd { |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 33 | namespace face { |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 34 | namespace tests { |
| 35 | |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 36 | using namespace nfd::tests; |
| 37 | |
| 38 | BOOST_AUTO_TEST_SUITE(Face) |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 39 | BOOST_FIXTURE_TEST_SUITE(TestNullFace, GlobalIoFixture) |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 40 | |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 41 | BOOST_AUTO_TEST_CASE(StaticProperties) |
| 42 | { |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 43 | FaceUri uri("testnull://hhppt12sy"); |
| 44 | auto face = makeNullFace(uri); |
| 45 | auto transport = face->getTransport(); |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 46 | |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 47 | checkStaticPropertiesInitialized(*transport); |
| 48 | |
| 49 | BOOST_CHECK_EQUAL(transport->getLocalUri(), uri); |
| 50 | BOOST_CHECK_EQUAL(transport->getRemoteUri(), uri); |
| 51 | BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL); |
| 52 | BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERMANENT); |
| 53 | BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 54 | BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED); |
| 55 | } |
| 56 | |
| 57 | BOOST_AUTO_TEST_CASE(ExpirationTime) |
| 58 | { |
| 59 | auto transport = make_unique<NullTransport>(); |
| 60 | |
| 61 | BOOST_CHECK_EQUAL(transport->getExpirationTime(), time::steady_clock::TimePoint::max()); |
| 62 | } |
| 63 | |
| 64 | BOOST_AUTO_TEST_CASE(SendQueue) |
| 65 | { |
| 66 | auto transport = make_unique<NullTransport>(); |
| 67 | |
| 68 | BOOST_CHECK_EQUAL(transport->getSendQueueCapacity(), QUEUE_UNSUPPORTED); |
| 69 | BOOST_CHECK_EQUAL(transport->getSendQueueLength(), QUEUE_UNSUPPORTED); |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 70 | } |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 71 | |
Spyridon Mastorakis | d0381c0 | 2015-02-19 10:29:41 -0800 | [diff] [blame] | 72 | BOOST_AUTO_TEST_CASE(Send) |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 73 | { |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 74 | auto face = makeNullFace(); |
| 75 | BOOST_CHECK_EQUAL(face->getState(), FaceState::UP); |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 76 | |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 77 | face->sendInterest(*makeInterest("/A"), 0); |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 78 | BOOST_CHECK_EQUAL(face->getState(), FaceState::UP); |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 79 | |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 80 | face->sendData(*makeData("/B"), 0); |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 81 | BOOST_CHECK_EQUAL(face->getState(), FaceState::UP); |
| 82 | } |
Spyridon Mastorakis | d0381c0 | 2015-02-19 10:29:41 -0800 | [diff] [blame] | 83 | |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 84 | BOOST_AUTO_TEST_CASE(PersistencyChange) |
| 85 | { |
| 86 | auto transport = make_unique<NullTransport>(); |
| 87 | |
| 88 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND), false); |
| 89 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERSISTENT), false); |
| 90 | BOOST_CHECK_EQUAL(transport->canChangePersistencyTo(ndn::nfd::FACE_PERSISTENCY_PERMANENT), true); |
| 91 | } |
| 92 | |
| 93 | BOOST_AUTO_TEST_CASE(Close) |
| 94 | { |
| 95 | auto transport = make_unique<NullTransport>(); |
| 96 | BOOST_CHECK_EQUAL(transport->getState(), TransportState::UP); |
| 97 | |
| 98 | transport->close(); |
| 99 | BOOST_CHECK_EQUAL(transport->getState(), TransportState::CLOSED); |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 100 | } |
| 101 | |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 102 | BOOST_AUTO_TEST_SUITE_END() // TestNullFace |
| 103 | BOOST_AUTO_TEST_SUITE_END() // Face |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 104 | |
| 105 | } // namespace tests |
Junxiao Shi | a044be7 | 2015-10-26 11:00:56 -0700 | [diff] [blame] | 106 | } // namespace face |
Alexander Afanasyev | 5d57f97 | 2015-02-11 21:04:29 -0800 | [diff] [blame] | 107 | } // namespace nfd |