Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 2 | /** |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 3 | * Copyright (c) 2013-2016 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include "management/nfd-controller.hpp" |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 23 | #include "management/nfd-control-response.hpp" |
| 24 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 25 | #include <boost/tuple/tuple.hpp> |
| 26 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 27 | #include "nfd-controller-fixture.hpp" |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 28 | #include "../make-interest-data.hpp" |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ndn { |
| 31 | namespace nfd { |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 32 | namespace tests { |
| 33 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 34 | using ndn::util::makeData; |
| 35 | using ndn::util::makeNack; |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 36 | |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 37 | BOOST_AUTO_TEST_SUITE(Management) |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 38 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 39 | class CommandFixture : public ControllerFixture |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 40 | { |
| 41 | protected: |
| 42 | CommandFixture() |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 43 | : succeedCallback(bind(&CommandFixture::succeed, this, _1)) |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 44 | { |
| 45 | } |
| 46 | |
| 47 | private: |
| 48 | void |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 49 | succeed(const ControlParameters& parameters) |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 50 | { |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 51 | succeeds.push_back(parameters); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | protected: |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 55 | Controller::CommandSucceedCallback succeedCallback; |
| 56 | std::vector<ControlParameters> succeeds; |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 59 | // This test suite focuses on ControlCommand functionality of Controller. |
| 60 | // Individual commands are tested in nfd-control-command.t.cpp |
| 61 | // StatusDataset functionality is tested in nfd-status-dataset.t.cpp |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 62 | BOOST_FIXTURE_TEST_SUITE(TestNfdController, CommandFixture) |
| 63 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 64 | BOOST_AUTO_TEST_CASE(Success) |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 65 | { |
| 66 | ControlParameters parameters; |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 67 | parameters.setUri("tcp4://192.0.2.1:6363"); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 68 | |
| 69 | BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>( |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 70 | parameters, succeedCallback, failCallback)); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 71 | this->advanceClocks(time::milliseconds(1)); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 72 | |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 73 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
| 74 | const Interest& requestInterest = face.sentInterests[0]; |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 75 | |
| 76 | FaceCreateCommand command; |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 77 | BOOST_CHECK(Name("/localhost/nfd/faces/create").isPrefixOf(requestInterest.getName())); |
| 78 | // 9 components: ndn:/localhost/nfd/faces/create/<parameters>/<signed Interest x4> |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 79 | BOOST_REQUIRE_EQUAL(requestInterest.getName().size(), 9); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 80 | ControlParameters request; |
| 81 | // 4th component: <parameters> |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 82 | BOOST_REQUIRE_NO_THROW(request.wireDecode(requestInterest.getName().at(4).blockFromValue())); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 83 | BOOST_CHECK_NO_THROW(command.validateRequest(request)); |
| 84 | BOOST_CHECK_EQUAL(request.getUri(), parameters.getUri()); |
Junxiao Shi | 415b17c | 2014-11-12 00:43:25 -0700 | [diff] [blame] | 85 | BOOST_CHECK_EQUAL(requestInterest.getInterestLifetime(), CommandOptions::DEFAULT_TIMEOUT); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 86 | |
| 87 | ControlParameters responseBody; |
| 88 | responseBody.setUri("tcp4://192.0.2.1:6363") |
Yukai Tu | d93c5fc | 2015-08-25 11:37:16 +0800 | [diff] [blame] | 89 | .setFaceId(22) |
| 90 | .setFacePersistency(ndn::nfd::FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 91 | ControlResponse responsePayload(201, "created"); |
| 92 | responsePayload.setBody(responseBody.wireEncode()); |
| 93 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 94 | auto responseData = makeData(requestInterest.getName()); |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 95 | responseData->setContent(responsePayload.wireEncode()); |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 96 | face.receive(*responseData); |
Alexander Afanasyev | d3a55b2 | 2014-11-18 19:23:28 -0800 | [diff] [blame] | 97 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 98 | this->advanceClocks(time::milliseconds(1)); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 99 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 100 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 101 | BOOST_REQUIRE_EQUAL(succeeds.size(), 1); |
| 102 | BOOST_CHECK_EQUAL(succeeds.back().getUri(), responseBody.getUri()); |
| 103 | BOOST_CHECK_EQUAL(succeeds.back().getFaceId(), responseBody.getFaceId()); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 106 | BOOST_AUTO_TEST_CASE(SuccessNoCallback) |
| 107 | { |
| 108 | ControlParameters parameters; |
| 109 | parameters.setUri("tcp4://192.0.2.1:6363"); |
| 110 | |
| 111 | controller.start<FaceCreateCommand>(parameters, nullptr, failCallback); |
| 112 | this->advanceClocks(time::milliseconds(1)); |
| 113 | |
| 114 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
| 115 | const Interest& requestInterest = face.sentInterests[0]; |
| 116 | |
| 117 | ControlParameters responseBody; |
| 118 | responseBody.setUri("tcp4://192.0.2.1:6363") |
| 119 | .setFaceId(22) |
| 120 | .setFacePersistency(ndn::nfd::FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| 121 | ControlResponse responsePayload(201, "created"); |
| 122 | responsePayload.setBody(responseBody.wireEncode()); |
| 123 | |
| 124 | auto responseData = makeData(requestInterest.getName()); |
| 125 | responseData->setContent(responsePayload.wireEncode()); |
| 126 | face.receive(*responseData); |
| 127 | |
| 128 | BOOST_CHECK_NO_THROW(this->advanceClocks(time::milliseconds(1))); |
| 129 | |
| 130 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 131 | } |
| 132 | |
| 133 | BOOST_AUTO_TEST_CASE(OptionsPrefix) |
| 134 | { |
| 135 | ControlParameters parameters; |
| 136 | parameters.setName("/ndn/com/example"); |
| 137 | parameters.setFaceId(400); |
| 138 | |
| 139 | CommandOptions options; |
| 140 | options.setPrefix("/localhop/net/example/router1/nfd"); |
| 141 | |
| 142 | BOOST_CHECK_NO_THROW(controller.start<RibRegisterCommand>( |
| 143 | parameters, succeedCallback, failCallback, options)); |
| 144 | this->advanceClocks(time::milliseconds(1)); |
| 145 | |
| 146 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
| 147 | const Interest& requestInterest = face.sentInterests[0]; |
| 148 | |
| 149 | FaceCreateCommand command; |
| 150 | BOOST_CHECK(Name("/localhop/net/example/router1/nfd/rib/register").isPrefixOf( |
| 151 | requestInterest.getName())); |
| 152 | } |
| 153 | |
| 154 | BOOST_AUTO_TEST_CASE(InvalidRequest) |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 155 | { |
| 156 | ControlParameters parameters; |
| 157 | parameters.setName("ndn:/should-not-have-this-field"); |
| 158 | // Uri is missing |
| 159 | |
| 160 | BOOST_CHECK_THROW(controller.start<FaceCreateCommand>( |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 161 | parameters, succeedCallback, failCallback), |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 162 | ControlCommand::ArgumentError); |
| 163 | } |
| 164 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 165 | BOOST_AUTO_TEST_CASE(ErrorCode) |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 166 | { |
| 167 | ControlParameters parameters; |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 168 | parameters.setUri("tcp4://192.0.2.1:6363"); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 169 | |
| 170 | BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>( |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 171 | parameters, succeedCallback, failCallback)); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 172 | this->advanceClocks(time::milliseconds(1)); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 173 | |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 174 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
| 175 | const Interest& requestInterest = face.sentInterests[0]; |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 176 | |
| 177 | ControlResponse responsePayload(401, "Not Authenticated"); |
| 178 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 179 | auto responseData = makeData(requestInterest.getName()); |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 180 | responseData->setContent(responsePayload.wireEncode()); |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 181 | face.receive(*responseData); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 182 | this->advanceClocks(time::milliseconds(1)); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 183 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 184 | BOOST_CHECK_EQUAL(succeeds.size(), 0); |
| 185 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 186 | BOOST_CHECK_EQUAL(failCodes.back(), 401); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 189 | BOOST_AUTO_TEST_CASE(InvalidResponse) |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 190 | { |
| 191 | ControlParameters parameters; |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 192 | parameters.setUri("tcp4://192.0.2.1:6363"); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 193 | |
| 194 | BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>( |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 195 | parameters, succeedCallback, failCallback)); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 196 | this->advanceClocks(time::milliseconds(1)); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 197 | |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 198 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
| 199 | const Interest& requestInterest = face.sentInterests[0]; |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 200 | |
| 201 | ControlParameters responseBody; |
| 202 | responseBody.setUri("tcp4://192.0.2.1:6363") |
| 203 | .setName("ndn:/should-not-have-this-field"); |
| 204 | // FaceId is missing |
| 205 | ControlResponse responsePayload(201, "created"); |
| 206 | responsePayload.setBody(responseBody.wireEncode()); |
| 207 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 208 | auto responseData = makeData(requestInterest.getName()); |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 209 | responseData->setContent(responsePayload.wireEncode()); |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 210 | face.receive(*responseData); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 211 | this->advanceClocks(time::milliseconds(1)); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 212 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 213 | BOOST_CHECK_EQUAL(succeeds.size(), 0); |
| 214 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 217 | BOOST_AUTO_TEST_CASE(Nack) |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 218 | { |
| 219 | ControlParameters parameters; |
| 220 | parameters.setUri("tcp4://192.0.2.1:6363"); |
| 221 | |
| 222 | BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>( |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 223 | parameters, succeedCallback, failCallback)); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 224 | this->advanceClocks(time::milliseconds(1)); |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 225 | |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 226 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
| 227 | const Interest& requestInterest = face.sentInterests[0]; |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 228 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 229 | auto responseNack = makeNack(requestInterest, lp::NackReason::NO_ROUTE); |
Alexander Afanasyev | 9bdbb83 | 2015-12-30 12:54:22 -0800 | [diff] [blame] | 230 | face.receive(responseNack); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 231 | this->advanceClocks(time::milliseconds(1)); |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 232 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 233 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 234 | BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK); |
Junxiao Shi | b1990df | 2015-11-05 00:14:44 +0000 | [diff] [blame] | 235 | } |
| 236 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 237 | BOOST_AUTO_TEST_CASE(Timeout) |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 238 | { |
| 239 | ControlParameters parameters; |
| 240 | parameters.setUri("tcp4://192.0.2.1:6363"); |
| 241 | |
| 242 | CommandOptions options; |
| 243 | options.setTimeout(time::milliseconds(50)); |
| 244 | |
| 245 | BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>( |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 246 | parameters, succeedCallback, failCallback, options)); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 247 | this->advanceClocks(time::milliseconds(1), 101); // Face's PIT granularity is 100ms |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 248 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 249 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 250 | BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_TIMEOUT); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 253 | BOOST_AUTO_TEST_CASE(FailureNoCallback) |
| 254 | { |
| 255 | ControlParameters parameters; |
| 256 | parameters.setUri("tcp4://192.0.2.1:6363"); |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 257 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame^] | 258 | CommandOptions options; |
| 259 | options.setTimeout(time::milliseconds(50)); |
| 260 | |
| 261 | controller.start<FaceCreateCommand>(parameters, succeedCallback, nullptr, options); |
| 262 | BOOST_CHECK_NO_THROW(this->advanceClocks(time::milliseconds(100), 10)); |
| 263 | // timeout |
| 264 | |
| 265 | BOOST_CHECK_EQUAL(succeeds.size(), 0); |
| 266 | } |
| 267 | |
| 268 | BOOST_AUTO_TEST_SUITE_END() // TestNfdController |
| 269 | BOOST_AUTO_TEST_SUITE_END() // Management |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 270 | |
Alexander Afanasyev | 4abdbf1 | 2014-08-11 12:48:54 -0700 | [diff] [blame] | 271 | } // namespace tests |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 272 | } // namespace nfd |
| 273 | } // namespace ndn |