Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Davide Pesavento | b5f8bcc | 2017-02-05 17:58:05 -0500 | [diff] [blame^] | 3 | * Copyright (c) 2014-2017 Regents of the University of California, |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -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. |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 10 | * |
| 11 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 12 | * |
| 13 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 14 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 15 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 18 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 19 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 20 | * |
| 21 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 22 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 23 | * <http://www.gnu.org/licenses/>. |
| 24 | * |
| 25 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 26 | */ |
| 27 | |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 28 | #include "util/notification-subscriber.hpp" |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 29 | #include "simple-notification.hpp" |
Alexander Afanasyev | d3a55b2 | 2014-11-18 19:23:28 -0800 | [diff] [blame] | 30 | #include "util/dummy-client-face.hpp" |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 31 | |
Alexander Afanasyev | e4f8c3b | 2016-06-23 16:03:48 -0700 | [diff] [blame] | 32 | #include "../identity-management-time-fixture.hpp" |
Teng Liang | f8bf1b0 | 2016-07-17 11:54:19 -0700 | [diff] [blame] | 33 | #include "../make-interest-data.hpp" |
| 34 | #include "boost-test.hpp" |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 35 | |
| 36 | namespace ndn { |
Junxiao Shi | a60d936 | 2014-11-12 09:38:21 -0700 | [diff] [blame] | 37 | namespace util { |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 38 | namespace tests { |
| 39 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 40 | using namespace ndn::tests; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 41 | |
Alexander Afanasyev | 70244f4 | 2017-01-04 12:47:12 -0800 | [diff] [blame] | 42 | class NotificationSubscriberFixture : public IdentityManagementV1TimeFixture |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 43 | { |
| 44 | public: |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 45 | NotificationSubscriberFixture() |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 46 | : streamPrefix("ndn:/NotificationSubscriberTest") |
Alexander Afanasyev | e4f8c3b | 2016-06-23 16:03:48 -0700 | [diff] [blame] | 47 | , subscriberFace(io, m_keyChain) |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 48 | , subscriber(subscriberFace, streamPrefix, time::seconds(1)) |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 49 | , nextSendNotificationNo(0) |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 50 | { |
| 51 | } |
| 52 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 53 | /** \brief deliver one notification to subscriber |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 54 | */ |
| 55 | void |
| 56 | deliverNotification(const std::string& msg) |
| 57 | { |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 58 | SimpleNotification notification(msg); |
Alexander Afanasyev | 370d260 | 2014-08-20 10:21:34 -0500 | [diff] [blame] | 59 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 60 | Name dataName = streamPrefix; |
| 61 | dataName.appendSequenceNumber(nextSendNotificationNo); |
| 62 | Data data(dataName); |
| 63 | data.setContent(notification.wireEncode()); |
| 64 | data.setFreshnessPeriod(time::seconds(1)); |
| 65 | m_keyChain.sign(data); |
Alexander Afanasyev | 370d260 | 2014-08-20 10:21:34 -0500 | [diff] [blame] | 66 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 67 | lastDeliveredSeqNo = nextSendNotificationNo; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 68 | lastNotification.setMessage(""); |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 69 | ++nextSendNotificationNo; |
| 70 | subscriberFace.receive(data); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Teng Liang | f8bf1b0 | 2016-07-17 11:54:19 -0700 | [diff] [blame] | 73 | /** \brief deliver a Nack to subscriber |
| 74 | */ |
| 75 | void |
| 76 | deliverNack(const Interest& interest, const lp::NackReason& reason) |
| 77 | { |
| 78 | lp::Nack nack = makeNack(interest, reason); |
| 79 | subscriberFace.receive(nack); |
| 80 | } |
| 81 | |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 82 | void |
| 83 | afterNotification(const SimpleNotification& notification) |
| 84 | { |
| 85 | lastNotification = notification; |
| 86 | } |
| 87 | |
| 88 | void |
Teng Liang | f8bf1b0 | 2016-07-17 11:54:19 -0700 | [diff] [blame] | 89 | afterNack(const lp::Nack& nack) |
| 90 | { |
| 91 | lastNack = nack; |
| 92 | } |
| 93 | |
| 94 | void |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 95 | afterTimeout() |
| 96 | { |
| 97 | hasTimeout = true; |
| 98 | } |
| 99 | |
| 100 | void |
| 101 | afterDecodeError(const Data& data) |
| 102 | { |
| 103 | lastDecodeErrorData = data; |
| 104 | } |
| 105 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 106 | void |
| 107 | connectHandlers() |
| 108 | { |
| 109 | notificationConn = subscriber.onNotification.connect( |
| 110 | bind(&NotificationSubscriberFixture::afterNotification, this, _1)); |
Teng Liang | f8bf1b0 | 2016-07-17 11:54:19 -0700 | [diff] [blame] | 111 | nackConn = subscriber.onNack.connect( |
| 112 | bind(&NotificationSubscriberFixture::afterNack, this, _1)); |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 113 | subscriber.onTimeout.connect( |
| 114 | bind(&NotificationSubscriberFixture::afterTimeout, this)); |
| 115 | subscriber.onDecodeError.connect( |
| 116 | bind(&NotificationSubscriberFixture::afterDecodeError, this, _1)); |
| 117 | } |
| 118 | |
| 119 | void |
| 120 | disconnectHandlers() |
| 121 | { |
| 122 | notificationConn.disconnect(); |
Teng Liang | f8bf1b0 | 2016-07-17 11:54:19 -0700 | [diff] [blame] | 123 | nackConn.disconnect(); |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 126 | /** \return true if subscriberFace has an initial request (first sent Interest) |
| 127 | */ |
| 128 | bool |
| 129 | hasInitialRequest() const |
| 130 | { |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 131 | if (subscriberFace.sentInterests.empty()) |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 132 | return false; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 133 | |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 134 | const Interest& interest = subscriberFace.sentInterests[0]; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 135 | return interest.getName() == streamPrefix && |
| 136 | interest.getChildSelector() == 1 && |
| 137 | interest.getMustBeFresh() && |
| 138 | interest.getInterestLifetime() == subscriber.getInterestLifetime(); |
| 139 | } |
| 140 | |
| 141 | /** \return sequence number of the continuation request sent from subscriberFace |
| 142 | * or 0 if there's no such request as sole sent Interest |
| 143 | */ |
| 144 | uint64_t |
| 145 | getRequestSeqNo() const |
| 146 | { |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 147 | if (subscriberFace.sentInterests.size() != 1) |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 148 | return 0; |
| 149 | |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 150 | const Interest& interest = subscriberFace.sentInterests[0]; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 151 | const Name& name = interest.getName(); |
| 152 | if (streamPrefix.isPrefixOf(name) && |
| 153 | name.size() == streamPrefix.size() + 1 && |
| 154 | interest.getInterestLifetime() == subscriber.getInterestLifetime()) |
| 155 | return name[-1].toSequenceNumber(); |
| 156 | else |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | protected: |
| 161 | Name streamPrefix; |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 162 | DummyClientFace subscriberFace; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 163 | util::NotificationSubscriber<SimpleNotification> subscriber; |
Junxiao Shi | 728873f | 2015-01-20 16:01:26 -0700 | [diff] [blame] | 164 | util::signal::Connection notificationConn; |
Teng Liang | f8bf1b0 | 2016-07-17 11:54:19 -0700 | [diff] [blame] | 165 | util::signal::Connection nackConn; |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 166 | uint64_t nextSendNotificationNo; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 167 | uint64_t lastDeliveredSeqNo; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 168 | SimpleNotification lastNotification; |
Teng Liang | f8bf1b0 | 2016-07-17 11:54:19 -0700 | [diff] [blame] | 169 | lp::Nack lastNack; |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 170 | bool hasTimeout; |
| 171 | Data lastDecodeErrorData; |
| 172 | }; |
| 173 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 174 | BOOST_AUTO_TEST_SUITE(Util) |
| 175 | BOOST_FIXTURE_TEST_SUITE(TestNotificationSubscriber, NotificationSubscriberFixture) |
| 176 | |
| 177 | BOOST_AUTO_TEST_CASE(StartStop) |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 178 | { |
| 179 | BOOST_REQUIRE_EQUAL(subscriber.isRunning(), false); |
| 180 | |
| 181 | // has no effect because onNotification has no handler |
| 182 | subscriber.start(); |
| 183 | BOOST_REQUIRE_EQUAL(subscriber.isRunning(), false); |
| 184 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 185 | this->connectHandlers(); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 186 | subscriber.start(); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 187 | BOOST_REQUIRE_EQUAL(subscriber.isRunning(), true); |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 188 | advanceClocks(time::milliseconds(1)); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 189 | BOOST_CHECK(this->hasInitialRequest()); |
| 190 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 191 | subscriberFace.sentInterests.clear(); |
| 192 | this->disconnectHandlers(); |
| 193 | this->deliverNotification("n1"); |
| 194 | BOOST_REQUIRE_EQUAL(subscriberFace.sentInterests.size(), 0); |
| 195 | } |
| 196 | |
| 197 | BOOST_AUTO_TEST_CASE(Notifications) |
| 198 | { |
| 199 | this->connectHandlers(); |
| 200 | subscriber.start(); |
| 201 | advanceClocks(time::milliseconds(1)); |
| 202 | |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 203 | // respond to initial request |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 204 | subscriberFace.sentInterests.clear(); |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 205 | this->deliverNotification("n1"); |
| 206 | advanceClocks(time::milliseconds(1)); |
| 207 | BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n1"); |
| 208 | BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1); |
| 209 | |
| 210 | // respond to continuation request |
| 211 | subscriberFace.sentInterests.clear(); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 212 | this->deliverNotification("n2"); |
Alexander Afanasyev | d3a55b2 | 2014-11-18 19:23:28 -0800 | [diff] [blame] | 213 | advanceClocks(time::milliseconds(1)); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 214 | BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n2"); |
| 215 | BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1); |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 216 | } |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 217 | |
Teng Liang | f8bf1b0 | 2016-07-17 11:54:19 -0700 | [diff] [blame] | 218 | BOOST_AUTO_TEST_CASE(Nack) |
| 219 | { |
| 220 | this->connectHandlers(); |
| 221 | subscriber.start(); |
| 222 | advanceClocks(time::milliseconds(1)); |
| 223 | |
| 224 | // send the first Nack to initial request |
| 225 | BOOST_REQUIRE_EQUAL(subscriberFace.sentInterests.size(), 1); |
| 226 | Interest interest = subscriberFace.sentInterests[0]; |
| 227 | subscriberFace.sentInterests.clear(); |
| 228 | this->deliverNack(interest, lp::NackReason::CONGESTION); |
| 229 | advanceClocks(time::milliseconds(1)); |
| 230 | BOOST_CHECK_EQUAL(lastNack.getReason(), lp::NackReason::CONGESTION); |
| 231 | BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false); |
| 232 | advanceClocks(time::milliseconds(300)); |
| 233 | BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true); |
| 234 | |
| 235 | // send the second Nack to initial request |
| 236 | BOOST_REQUIRE_EQUAL(subscriberFace.sentInterests.size(), 1); |
| 237 | interest = subscriberFace.sentInterests[0]; |
| 238 | subscriberFace.sentInterests.clear(); |
| 239 | this->deliverNack(interest, lp::NackReason::CONGESTION); |
| 240 | advanceClocks(time::milliseconds(301)); |
| 241 | BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false); |
| 242 | advanceClocks(time::milliseconds(200)); |
| 243 | BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true); |
| 244 | |
| 245 | // send a notification to initial request |
| 246 | subscriberFace.sentInterests.clear(); |
| 247 | this->deliverNotification("n1"); |
| 248 | advanceClocks(time::milliseconds(1)); |
| 249 | |
| 250 | // send a Nack to subsequent request |
| 251 | BOOST_REQUIRE_EQUAL(subscriberFace.sentInterests.size(), 1); |
| 252 | interest = subscriberFace.sentInterests[0]; |
| 253 | subscriberFace.sentInterests.clear(); |
| 254 | this->deliverNack(interest, lp::NackReason::CONGESTION); |
| 255 | advanceClocks(time::milliseconds(1)); |
| 256 | BOOST_CHECK_EQUAL(lastNack.getReason(), lp::NackReason::CONGESTION); |
| 257 | BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false); |
| 258 | advanceClocks(time::milliseconds(300)); |
| 259 | BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true); |
| 260 | } |
| 261 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 262 | BOOST_AUTO_TEST_CASE(Timeout) |
| 263 | { |
| 264 | this->connectHandlers(); |
| 265 | subscriber.start(); |
Alexander Afanasyev | d3a55b2 | 2014-11-18 19:23:28 -0800 | [diff] [blame] | 266 | advanceClocks(time::milliseconds(1)); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 267 | |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 268 | subscriberFace.sentInterests.clear(); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 269 | lastNotification.setMessage(""); |
Alexander Afanasyev | d3a55b2 | 2014-11-18 19:23:28 -0800 | [diff] [blame] | 270 | advanceClocks(subscriber.getInterestLifetime(), 2); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 271 | BOOST_CHECK(lastNotification.getMessage().empty()); |
| 272 | BOOST_CHECK_EQUAL(hasTimeout, true); |
| 273 | BOOST_CHECK(this->hasInitialRequest()); |
| 274 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 275 | subscriberFace.sentInterests.clear(); |
| 276 | this->deliverNotification("n1"); |
| 277 | advanceClocks(time::milliseconds(1)); |
| 278 | BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n1"); |
| 279 | } |
| 280 | |
| 281 | BOOST_AUTO_TEST_CASE(SequenceError) |
| 282 | { |
| 283 | this->connectHandlers(); |
| 284 | subscriber.start(); |
| 285 | advanceClocks(time::milliseconds(1)); |
| 286 | |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 287 | Name wrongName = streamPrefix; |
| 288 | wrongName.append("%07%07"); |
| 289 | Data wrongData(wrongName); |
Alexander Afanasyev | e4f8c3b | 2016-06-23 16:03:48 -0700 | [diff] [blame] | 290 | m_keyChain.sign(wrongData); |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 291 | subscriberFace.receive(wrongData); |
| 292 | subscriberFace.sentInterests.clear(); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 293 | lastNotification.setMessage(""); |
Alexander Afanasyev | d3a55b2 | 2014-11-18 19:23:28 -0800 | [diff] [blame] | 294 | advanceClocks(time::milliseconds(1)); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 295 | BOOST_CHECK(lastNotification.getMessage().empty()); |
| 296 | BOOST_CHECK_EQUAL(lastDecodeErrorData.getName(), wrongName); |
| 297 | BOOST_CHECK(this->hasInitialRequest()); |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 298 | } |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 299 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 300 | BOOST_AUTO_TEST_CASE(PayloadError) |
| 301 | { |
| 302 | this->connectHandlers(); |
| 303 | subscriber.start(); |
| 304 | advanceClocks(time::milliseconds(1)); |
| 305 | |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 306 | subscriberFace.sentInterests.clear(); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 307 | lastNotification.setMessage(""); |
| 308 | this->deliverNotification("\x07n4"); |
Alexander Afanasyev | d3a55b2 | 2014-11-18 19:23:28 -0800 | [diff] [blame] | 309 | advanceClocks(time::milliseconds(1)); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 310 | BOOST_CHECK(lastNotification.getMessage().empty()); |
| 311 | BOOST_CHECK(this->hasInitialRequest()); |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Teng Liang | 93adaff | 2016-07-30 15:57:12 -0700 | [diff] [blame] | 314 | BOOST_AUTO_TEST_SUITE_END() // TestNotificationSubscriber |
| 315 | BOOST_AUTO_TEST_SUITE_END() // Util |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 316 | |
| 317 | } // namespace tests |
Junxiao Shi | a60d936 | 2014-11-12 09:38:21 -0700 | [diff] [blame] | 318 | } // namespace util |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 319 | } // namespace ndn |