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 | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 2 | /** |
Yanbiao Li | cbdacb2 | 2016-08-02 16:02:35 +0800 | [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 | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include "management/nfd-control-command.hpp" |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 23 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 24 | #include "boost-test.hpp" |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 25 | |
| 26 | namespace ndn { |
| 27 | namespace nfd { |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 28 | namespace tests { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 29 | |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 30 | BOOST_AUTO_TEST_SUITE(ManagementNfdControlCommand) |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 31 | |
| 32 | BOOST_AUTO_TEST_CASE(FaceCreate) |
| 33 | { |
| 34 | FaceCreateCommand command; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 35 | |
| 36 | ControlParameters p1; |
| 37 | p1.setUri("tcp4://192.0.2.1") |
| 38 | .setFaceId(4); |
| 39 | BOOST_CHECK_THROW(command.validateRequest(p1), ControlCommand::ArgumentError); |
Yukai Tu | d93c5fc | 2015-08-25 11:37:16 +0800 | [diff] [blame] | 40 | BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 41 | |
| 42 | ControlParameters p2; |
| 43 | p2.setName("ndn:/example"); |
| 44 | BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError); |
| 45 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
| 46 | |
| 47 | ControlParameters p3; |
| 48 | p3.setUri("tcp4://192.0.2.1") |
| 49 | .setFaceId(0); |
| 50 | BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 51 | |
| 52 | ControlParameters p4; |
Yukai Tu | d93c5fc | 2015-08-25 11:37:16 +0800 | [diff] [blame] | 53 | p4.setUri("tcp4://192.0.2.1") |
| 54 | .setFacePersistency(ndn::nfd::FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| 55 | BOOST_CHECK_NO_THROW(command.validateRequest(p4)); |
| 56 | |
| 57 | p4.unsetFacePersistency(); |
| 58 | BOOST_CHECK_NO_THROW(command.validateRequest(p4)); |
| 59 | command.applyDefaultsToRequest(p4); |
| 60 | BOOST_REQUIRE(p4.hasFacePersistency()); |
| 61 | BOOST_CHECK_EQUAL(p4.getFacePersistency(), ndn::nfd::FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| 62 | |
| 63 | ControlParameters p5; |
| 64 | p5.setUri("tcp4://192.0.2.1") |
| 65 | .setFaceId(4) |
| 66 | .setFacePersistency(ndn::nfd::FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| 67 | BOOST_CHECK_NO_THROW(command.validateResponse(p5)); |
| 68 | |
| 69 | ControlParameters p6; |
| 70 | p6.setUri("tcp4://192.0.2.1:6363"); |
| 71 | Name n6; |
| 72 | BOOST_CHECK_NO_THROW(n6 = command.getRequestName("/PREFIX", p6)); |
| 73 | BOOST_CHECK(Name("ndn:/PREFIX/faces/create").isPrefixOf(n6)); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Yanbiao Li | cbdacb2 | 2016-08-02 16:02:35 +0800 | [diff] [blame] | 76 | BOOST_AUTO_TEST_CASE(FaceUpdate) |
| 77 | { |
| 78 | FaceUpdateCommand command; |
| 79 | |
| 80 | ControlParameters p1; |
| 81 | p1.setFaceId(0); |
| 82 | BOOST_CHECK_THROW(command.validateRequest(p1), ControlCommand::ArgumentError); |
| 83 | BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError); |
| 84 | |
| 85 | p1.setFaceId(1); |
| 86 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 87 | BOOST_CHECK_NO_THROW(command.validateResponse(p1)); |
| 88 | |
| 89 | ControlParameters p2; |
| 90 | p2.setFaceId(1) |
| 91 | .setFacePersistency(ndn::nfd::FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| 92 | BOOST_CHECK_NO_THROW(command.validateRequest(p2)); |
| 93 | BOOST_CHECK_NO_THROW(command.validateResponse(p2)); |
| 94 | |
| 95 | ControlParameters p3; |
| 96 | p3.setFacePersistency(ndn::nfd::FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| 97 | BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError); |
| 98 | BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError); |
| 99 | |
| 100 | ControlParameters p4; |
| 101 | p4.setFaceId(1) |
| 102 | .setName("/ndn/name"); |
| 103 | BOOST_CHECK_THROW(command.validateRequest(p4), ControlCommand::ArgumentError); |
| 104 | BOOST_CHECK_THROW(command.validateResponse(p4), ControlCommand::ArgumentError); |
| 105 | |
| 106 | ControlParameters p5; |
| 107 | p5.setFaceId(1) |
| 108 | .setUri("tcp4://192.0.2.1"); |
| 109 | BOOST_CHECK_THROW(command.validateRequest(p5), ControlCommand::ArgumentError); |
| 110 | BOOST_CHECK_THROW(command.validateResponse(p5), ControlCommand::ArgumentError); |
| 111 | } |
| 112 | |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 113 | BOOST_AUTO_TEST_CASE(FaceDestroy) |
| 114 | { |
| 115 | FaceDestroyCommand command; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 116 | |
| 117 | ControlParameters p1; |
| 118 | p1.setUri("tcp4://192.0.2.1") |
| 119 | .setFaceId(4); |
| 120 | BOOST_CHECK_THROW(command.validateRequest(p1), ControlCommand::ArgumentError); |
| 121 | BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError); |
| 122 | |
| 123 | ControlParameters p2; |
| 124 | p2.setFaceId(0); |
| 125 | BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError); |
| 126 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
| 127 | |
| 128 | ControlParameters p3; |
| 129 | p3.setFaceId(6); |
| 130 | BOOST_CHECK_NO_THROW(command.validateRequest(p3)); |
| 131 | BOOST_CHECK_NO_THROW(command.validateResponse(p3)); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 132 | Name n3; |
| 133 | BOOST_CHECK_NO_THROW(n3 = command.getRequestName("/PREFIX", p3)); |
| 134 | BOOST_CHECK(Name("ndn:/PREFIX/faces/destroy").isPrefixOf(n3)); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | BOOST_AUTO_TEST_CASE(FaceEnableLocalControl) |
| 138 | { |
| 139 | FaceEnableLocalControlCommand command; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 140 | |
| 141 | ControlParameters p1; |
| 142 | p1.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 143 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 144 | BOOST_CHECK_NO_THROW(command.validateResponse(p1)); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 145 | Name n1; |
| 146 | BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1)); |
| 147 | BOOST_CHECK(Name("ndn:/PREFIX/faces/enable-local-control").isPrefixOf(n1)); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 148 | |
| 149 | ControlParameters p2; |
| 150 | p2.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID) |
| 151 | .setFaceId(9); |
| 152 | BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError); |
| 153 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
Junxiao Shi | 6888bc1 | 2014-03-29 23:01:41 -0700 | [diff] [blame] | 154 | |
| 155 | ControlParameters p3; |
| 156 | p3.setLocalControlFeature(static_cast<LocalControlFeature>(666)); |
| 157 | BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError); |
| 158 | BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | BOOST_AUTO_TEST_CASE(FaceDisableLocalControl) |
| 162 | { |
| 163 | FaceDisableLocalControlCommand command; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 164 | |
| 165 | ControlParameters p1; |
| 166 | p1.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 167 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 168 | BOOST_CHECK_NO_THROW(command.validateResponse(p1)); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 169 | Name n1; |
| 170 | BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1)); |
| 171 | BOOST_CHECK(Name("ndn:/PREFIX/faces/disable-local-control").isPrefixOf(n1)); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 172 | |
| 173 | ControlParameters p2; |
| 174 | p2.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID) |
| 175 | .setFaceId(9); |
| 176 | BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError); |
| 177 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
Junxiao Shi | 6888bc1 | 2014-03-29 23:01:41 -0700 | [diff] [blame] | 178 | |
| 179 | ControlParameters p3; |
| 180 | p3.setLocalControlFeature(static_cast<LocalControlFeature>(666)); |
| 181 | BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError); |
| 182 | BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | BOOST_AUTO_TEST_CASE(FibAddNextHop) |
| 186 | { |
| 187 | FibAddNextHopCommand command; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 188 | |
| 189 | ControlParameters p1; |
| 190 | p1.setName("ndn:/") |
| 191 | .setFaceId(22); |
| 192 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 193 | BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 194 | Name n1; |
| 195 | BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1)); |
| 196 | BOOST_CHECK(Name("ndn:/PREFIX/fib/add-nexthop").isPrefixOf(n1)); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 197 | |
| 198 | ControlParameters p2; |
| 199 | p2.setName("ndn:/example") |
| 200 | .setFaceId(0) |
| 201 | .setCost(6); |
| 202 | BOOST_CHECK_NO_THROW(command.validateRequest(p2)); |
| 203 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
| 204 | |
| 205 | command.applyDefaultsToRequest(p1); |
| 206 | BOOST_REQUIRE(p1.hasCost()); |
| 207 | BOOST_CHECK_EQUAL(p1.getCost(), 0); |
Junxiao Shi | caac54e | 2014-05-20 15:27:01 -0700 | [diff] [blame] | 208 | |
| 209 | p1.unsetFaceId(); |
| 210 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 211 | command.applyDefaultsToRequest(p1); |
| 212 | BOOST_REQUIRE(p1.hasFaceId()); |
| 213 | BOOST_CHECK_EQUAL(p1.getFaceId(), 0); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | BOOST_AUTO_TEST_CASE(FibRemoveNextHop) |
| 217 | { |
| 218 | FibRemoveNextHopCommand command; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 219 | |
| 220 | ControlParameters p1; |
| 221 | p1.setName("ndn:/") |
| 222 | .setFaceId(22); |
| 223 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 224 | BOOST_CHECK_NO_THROW(command.validateResponse(p1)); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 225 | Name n1; |
| 226 | BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1)); |
| 227 | BOOST_CHECK(Name("ndn:/PREFIX/fib/remove-nexthop").isPrefixOf(n1)); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 228 | |
| 229 | ControlParameters p2; |
| 230 | p2.setName("ndn:/example") |
| 231 | .setFaceId(0); |
| 232 | BOOST_CHECK_NO_THROW(command.validateRequest(p2)); |
| 233 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
Junxiao Shi | caac54e | 2014-05-20 15:27:01 -0700 | [diff] [blame] | 234 | |
| 235 | p1.unsetFaceId(); |
| 236 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 237 | command.applyDefaultsToRequest(p1); |
| 238 | BOOST_REQUIRE(p1.hasFaceId()); |
| 239 | BOOST_CHECK_EQUAL(p1.getFaceId(), 0); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | BOOST_AUTO_TEST_CASE(StrategyChoiceSet) |
| 243 | { |
| 244 | StrategyChoiceSetCommand command; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 245 | |
| 246 | ControlParameters p1; |
| 247 | p1.setName("ndn:/") |
| 248 | .setStrategy("ndn:/strategy/P"); |
| 249 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 250 | BOOST_CHECK_NO_THROW(command.validateResponse(p1)); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 251 | Name n1; |
| 252 | BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1)); |
| 253 | BOOST_CHECK(Name("ndn:/PREFIX/strategy-choice/set").isPrefixOf(n1)); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 254 | |
| 255 | ControlParameters p2; |
| 256 | p2.setName("ndn:/example"); |
| 257 | BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError); |
| 258 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
| 259 | } |
| 260 | |
| 261 | BOOST_AUTO_TEST_CASE(StrategyChoiceUnset) |
| 262 | { |
| 263 | StrategyChoiceUnsetCommand command; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 264 | |
| 265 | ControlParameters p1; |
| 266 | p1.setName("ndn:/example"); |
| 267 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 268 | BOOST_CHECK_NO_THROW(command.validateResponse(p1)); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 269 | Name n1; |
| 270 | BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1)); |
| 271 | BOOST_CHECK(Name("ndn:/PREFIX/strategy-choice/unset").isPrefixOf(n1)); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 272 | |
| 273 | ControlParameters p2; |
| 274 | p2.setName("ndn:/example") |
| 275 | .setStrategy("ndn:/strategy/P"); |
| 276 | BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError); |
| 277 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
| 278 | |
| 279 | ControlParameters p3; |
| 280 | p3.setName("ndn:/"); |
| 281 | BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError); |
| 282 | BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError); |
| 283 | } |
| 284 | |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 285 | BOOST_AUTO_TEST_CASE(RibRegister) |
| 286 | { |
| 287 | RibRegisterCommand command; |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 288 | |
| 289 | ControlParameters p1; |
| 290 | p1.setName("ndn:/"); |
| 291 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 292 | BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 293 | Name n1; |
| 294 | BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1)); |
| 295 | BOOST_CHECK(Name("ndn:/PREFIX/rib/register").isPrefixOf(n1)); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 296 | |
| 297 | command.applyDefaultsToRequest(p1); |
| 298 | BOOST_REQUIRE(p1.hasOrigin()); |
| 299 | BOOST_CHECK_EQUAL(p1.getOrigin(), static_cast<uint64_t>(ROUTE_ORIGIN_APP)); |
| 300 | BOOST_REQUIRE(p1.hasCost()); |
| 301 | BOOST_CHECK_EQUAL(p1.getCost(), 0); |
| 302 | BOOST_REQUIRE(p1.hasFlags()); |
| 303 | BOOST_CHECK_EQUAL(p1.getFlags(), static_cast<uint64_t>(ROUTE_FLAG_CHILD_INHERIT)); |
Alexander Afanasyev | 21f13b0 | 2014-07-17 16:17:34 -0700 | [diff] [blame] | 304 | BOOST_CHECK_EQUAL(p1.hasExpirationPeriod(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 305 | |
| 306 | ControlParameters p2; |
| 307 | p2.setName("ndn:/example") |
| 308 | .setFaceId(2) |
| 309 | .setCost(6); |
| 310 | BOOST_CHECK_NO_THROW(command.validateRequest(p2)); |
| 311 | command.applyDefaultsToRequest(p2); |
Alexander Afanasyev | 21f13b0 | 2014-07-17 16:17:34 -0700 | [diff] [blame] | 312 | BOOST_CHECK_EQUAL(p2.hasExpirationPeriod(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 313 | BOOST_CHECK_NO_THROW(command.validateResponse(p2)); |
| 314 | } |
| 315 | |
| 316 | BOOST_AUTO_TEST_CASE(RibUnregister) |
| 317 | { |
| 318 | RibUnregisterCommand command; |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 319 | |
| 320 | ControlParameters p1; |
| 321 | p1.setName("ndn:/") |
| 322 | .setFaceId(22) |
| 323 | .setOrigin(ROUTE_ORIGIN_STATIC); |
| 324 | BOOST_CHECK_NO_THROW(command.validateRequest(p1)); |
| 325 | BOOST_CHECK_NO_THROW(command.validateResponse(p1)); |
Junxiao Shi | 5de006b | 2014-10-26 20:20:52 -0700 | [diff] [blame] | 326 | Name n1; |
| 327 | BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1)); |
| 328 | BOOST_CHECK(Name("ndn:/PREFIX/rib/unregister").isPrefixOf(n1)); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 329 | |
| 330 | ControlParameters p2; |
| 331 | p2.setName("ndn:/example") |
| 332 | .setFaceId(0) |
| 333 | .setOrigin(ROUTE_ORIGIN_APP); |
| 334 | BOOST_CHECK_NO_THROW(command.validateRequest(p2)); |
| 335 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
| 336 | |
| 337 | p2.unsetFaceId(); |
| 338 | BOOST_CHECK_NO_THROW(command.validateRequest(p2)); |
| 339 | BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); |
| 340 | } |
| 341 | |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 342 | BOOST_AUTO_TEST_SUITE_END() |
| 343 | |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 344 | } // namespace tests |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 345 | } // namespace nfd |
| 346 | } // namespace ndn |