blob: de343e06934bd583c5584b353fccc8b0cc1435bf [file] [log] [blame]
Alexander Afanasyev5d57f972015-02-11 21:04:29 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventocf7db2f2019-03-24 23:17:28 -04002/*
3 * Copyright (c) 2014-2019, Regents of the University of California,
Alexander Afanasyev5d57f972015-02-11 21:04:29 -08004 * 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 Mastorakisd0381c02015-02-19 10:29:41 -080026#include "face/null-face.hpp"
Davide Pesavento16916ae2019-03-29 23:53:26 -040027#include "face/null-transport.hpp"
Junxiao Shicde37ad2015-12-24 01:02:05 -070028
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040029#include "tests/daemon/global-io-fixture.hpp"
Eric Newberry8717e872015-11-23 12:41:50 -070030#include "transport-test-common.hpp"
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080031
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080032namespace nfd {
Junxiao Shia044be72015-10-26 11:00:56 -070033namespace face {
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080034namespace tests {
35
Junxiao Shia044be72015-10-26 11:00:56 -070036using namespace nfd::tests;
37
38BOOST_AUTO_TEST_SUITE(Face)
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040039BOOST_FIXTURE_TEST_SUITE(TestNullFace, GlobalIoFixture)
Junxiao Shia044be72015-10-26 11:00:56 -070040
Junxiao Shia044be72015-10-26 11:00:56 -070041BOOST_AUTO_TEST_CASE(StaticProperties)
42{
Davide Pesavento16916ae2019-03-29 23:53:26 -040043 FaceUri uri("testnull://hhppt12sy");
44 auto face = makeNullFace(uri);
45 auto transport = face->getTransport();
Junxiao Shia044be72015-10-26 11:00:56 -070046
Davide Pesavento16916ae2019-03-29 23:53:26 -040047 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
57BOOST_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
64BOOST_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 Shia044be72015-10-26 11:00:56 -070070}
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080071
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080072BOOST_AUTO_TEST_CASE(Send)
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080073{
Davide Pesavento16916ae2019-03-29 23:53:26 -040074 auto face = makeNullFace();
75 BOOST_CHECK_EQUAL(face->getState(), FaceState::UP);
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080076
ashiqopu075bb7d2019-03-10 01:38:21 +000077 face->sendInterest(*makeInterest("/A"), 0);
Davide Pesavento16916ae2019-03-29 23:53:26 -040078 BOOST_CHECK_EQUAL(face->getState(), FaceState::UP);
Alexander Afanasyev5d57f972015-02-11 21:04:29 -080079
ashiqopu075bb7d2019-03-10 01:38:21 +000080 face->sendData(*makeData("/B"), 0);
Davide Pesavento16916ae2019-03-29 23:53:26 -040081 BOOST_CHECK_EQUAL(face->getState(), FaceState::UP);
82}
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080083
Davide Pesavento16916ae2019-03-29 23:53:26 -040084BOOST_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
93BOOST_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 Afanasyev5d57f972015-02-11 21:04:29 -0800100}
101
Junxiao Shia044be72015-10-26 11:00:56 -0700102BOOST_AUTO_TEST_SUITE_END() // TestNullFace
103BOOST_AUTO_TEST_SUITE_END() // Face
Alexander Afanasyev5d57f972015-02-11 21:04:29 -0800104
105} // namespace tests
Junxiao Shia044be72015-10-26 11:00:56 -0700106} // namespace face
Alexander Afanasyev5d57f972015-02-11 21:04:29 -0800107} // namespace nfd