blob: f24d58a2d86ea146ae20dfdeb91558c381549af5 [file] [log] [blame]
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "mgmt/strategy-choice-manager.hpp"
8#include "face/face.hpp"
9#include "mgmt/internal-face.hpp"
10#include "table/name-tree.hpp"
11#include "table/strategy-choice.hpp"
12#include "fw/forwarder.hpp"
13#include "fw/strategy.hpp"
14#include "tests/face/dummy-face.hpp"
Junxiao Shif3c07812014-03-11 21:48:49 -070015#include "tests/fw/dummy-strategy.hpp"
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070016
17#include "tests/test-common.hpp"
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070018#include "validation-common.hpp"
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070019
20namespace nfd {
21namespace tests {
22
23NFD_LOG_INIT("StrategyChoiceManagerTest");
24
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070025class StrategyChoiceManagerFixture : protected BaseFixture
26{
27public:
28
29 StrategyChoiceManagerFixture()
Junxiao Shif3c07812014-03-11 21:48:49 -070030 : m_strategyChoice(m_forwarder.getStrategyChoice())
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070031 , m_face(make_shared<InternalFace>())
32 , m_manager(m_strategyChoice, m_face)
33 , m_callbackFired(false)
34 {
Junxiao Shif3c07812014-03-11 21:48:49 -070035 m_strategyChoice.install(make_shared<DummyStrategy>(boost::ref(m_forwarder), "/localhost/nfd/strategy/test-strategy-a"));
36 m_strategyChoice.insert("ndn:/", "/localhost/nfd/strategy/test-strategy-a");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070037 }
38
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070039 virtual
40 ~StrategyChoiceManagerFixture()
41 {
42
43 }
44
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070045 void
46 validateControlResponseCommon(const Data& response,
47 const Name& expectedName,
48 uint32_t expectedCode,
49 const std::string& expectedText,
50 ControlResponse& control)
51 {
52 m_callbackFired = true;
53 Block controlRaw = response.getContent().blockFromValue();
54
55 control.wireDecode(controlRaw);
56
57 NFD_LOG_DEBUG("received control response"
58 << " Name: " << response.getName()
59 << " code: " << control.getCode()
60 << " text: " << control.getText());
61
62 BOOST_CHECK_EQUAL(response.getName(), expectedName);
63 BOOST_CHECK_EQUAL(control.getCode(), expectedCode);
64 BOOST_CHECK_EQUAL(control.getText(), expectedText);
65 }
66
67 void
68 validateControlResponse(const Data& response,
69 const Name& expectedName,
70 uint32_t expectedCode,
71 const std::string& expectedText)
72 {
73 ControlResponse control;
74 validateControlResponseCommon(response, expectedName,
75 expectedCode, expectedText, control);
76
77 if (!control.getBody().empty())
78 {
79 BOOST_FAIL("found unexpected control response body");
80 }
81 }
82
83 void
84 validateControlResponse(const Data& response,
85 const Name& expectedName,
86 uint32_t expectedCode,
87 const std::string& expectedText,
88 const Block& expectedBody)
89 {
90 ControlResponse control;
91 validateControlResponseCommon(response, expectedName,
92 expectedCode, expectedText, control);
93
94 BOOST_REQUIRE(!control.getBody().empty());
95 BOOST_REQUIRE(control.getBody().value_size() == expectedBody.value_size());
96
97 BOOST_CHECK(memcmp(control.getBody().value(), expectedBody.value(),
98 expectedBody.value_size()) == 0);
99
100 }
101
102 bool
103 didCallbackFire()
104 {
105 return m_callbackFired;
106 }
107
108 void
109 resetCallbackFired()
110 {
111 m_callbackFired = false;
112 }
113
114 shared_ptr<InternalFace>&
115 getFace()
116 {
117 return m_face;
118 }
119
120 StrategyChoiceManager&
121 getManager()
122 {
123 return m_manager;
124 }
125
126 StrategyChoice&
127 getStrategyChoice()
128 {
129 return m_strategyChoice;
130 }
131
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700132 void
133 addInterestRule(const std::string& regex,
134 ndn::IdentityCertificate& certificate)
135 {
136 m_manager.addInterestRule(regex, certificate);
137 }
138
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700139protected:
140 Forwarder m_forwarder;
Junxiao Shif3c07812014-03-11 21:48:49 -0700141 StrategyChoice& m_strategyChoice;
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700142 shared_ptr<InternalFace> m_face;
143 StrategyChoiceManager m_manager;
144
145private:
146 bool m_callbackFired;
147};
148
149class AllStrategiesFixture : public StrategyChoiceManagerFixture
150{
151public:
152 AllStrategiesFixture()
153 {
Junxiao Shif3c07812014-03-11 21:48:49 -0700154 m_strategyChoice.install(make_shared<DummyStrategy>(boost::ref(m_forwarder), "/localhost/nfd/strategy/test-strategy-b"));
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700155 }
156
157 virtual
158 ~AllStrategiesFixture()
159 {
160
161 }
162};
163
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700164template <typename T> class AuthorizedCommandFixture : public CommandFixture<T>
165{
166public:
167 AuthorizedCommandFixture()
168 {
169 const std::string regex = "^<localhost><nfd><strategy-choice>";
170 T::addInterestRule(regex, *CommandFixture<T>::m_certificate);
171 }
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700172
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700173 virtual
174 ~AuthorizedCommandFixture()
175 {
176
177 }
178};
179
180BOOST_FIXTURE_TEST_SUITE(MgmtStrategyChoiceManager,
181 AuthorizedCommandFixture<AllStrategiesFixture>)
182
183BOOST_FIXTURE_TEST_CASE(TestFireInterestFilter, AllStrategiesFixture)
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700184{
185 shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/strategy-choice"));
186
187 getFace()->onReceiveData +=
188 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
189 command->getName(), 400, "Malformed command");
190
191 getFace()->sendInterest(*command);
192
193 BOOST_REQUIRE(didCallbackFire());
194}
195
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700196BOOST_FIXTURE_TEST_CASE(MalformedCommmand, AllStrategiesFixture)
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700197{
198 shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/strategy-choice"));
199
200 getFace()->onReceiveData +=
201 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
202 command->getName(), 400, "Malformed command");
203
204 getManager().onStrategyChoiceRequest(*command);
205
206 BOOST_REQUIRE(didCallbackFire());
207}
208
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700209BOOST_FIXTURE_TEST_CASE(UnsignedCommand, AllStrategiesFixture)
210{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600211 ControlParameters parameters;
212 parameters.setName("/test");
213 parameters.setStrategy("/localhost/nfd/strategy/best-route");
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700214
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600215 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700216
217 Name commandName("/localhost/nfd/strategy-choice");
218 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600219 commandName.append(encodedParameters);
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700220
221 shared_ptr<Interest> command(make_shared<Interest>(commandName));
222
223 getFace()->onReceiveData +=
224 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
225 command->getName(), 401, "Signature required");
226
227 getManager().onStrategyChoiceRequest(*command);
228
229 BOOST_REQUIRE(didCallbackFire());
230}
231
232BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand,
233 UnauthorizedCommandFixture<StrategyChoiceManagerFixture>)
234{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600235 ControlParameters parameters;
236 parameters.setName("/test");
237 parameters.setStrategy("/localhost/nfd/strategy/best-route");
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700238
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600239 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700240
241 Name commandName("/localhost/nfd/strategy-choice");
242 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600243 commandName.append(encodedParameters);
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700244
245 shared_ptr<Interest> command(make_shared<Interest>(commandName));
246 generateCommand(*command);
247
248 getFace()->onReceiveData +=
249 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
250 command->getName(), 403, "Unauthorized command");
251
252 getManager().onStrategyChoiceRequest(*command);
253
254 BOOST_REQUIRE(didCallbackFire());
255}
256
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700257BOOST_AUTO_TEST_CASE(UnsupportedVerb)
258{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600259 ControlParameters parameters;
260 parameters.setName("/test");
261 parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700262
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600263 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700264
265 Name commandName("/localhost/nfd/strategy-choice");
266 commandName.append("unsupported");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600267 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700268
269 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700270 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700271
272 getFace()->onReceiveData +=
273 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
274 command->getName(), 501, "Unsupported command");
275
276 getManager().onValidatedStrategyChoiceRequest(command);
277
278 BOOST_REQUIRE(didCallbackFire());
279}
280
281BOOST_AUTO_TEST_CASE(BadOptionParse)
282{
283 Name commandName("/localhost/nfd/strategy-choice");
284 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600285 commandName.append("NotReallyParameters");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700286
287 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700288 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700289
290 getFace()->onReceiveData +=
291 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
292 command->getName(), 400, "Malformed command");
293
294 getManager().onValidatedStrategyChoiceRequest(command);
295
296 BOOST_REQUIRE(didCallbackFire());
297}
298
299BOOST_AUTO_TEST_CASE(SetStrategies)
300{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600301 ControlParameters parameters;
302 parameters.setName("/test");
303 parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700304
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600305 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700306
307 Name commandName("/localhost/nfd/strategy-choice");
308 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600309 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700310
311 shared_ptr<Interest> command(make_shared<Interest>(commandName));
312
313 getFace()->onReceiveData +=
314 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600315 command->getName(), 200, "Success", encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700316
317 getManager().onValidatedStrategyChoiceRequest(command);
318
319 BOOST_REQUIRE(didCallbackFire());
320 fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
321 BOOST_REQUIRE_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-b");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600322}
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700323
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600324BOOST_AUTO_TEST_CASE(SetStrategiesMissingName)
325{
326 ControlParameters parameters;
327 parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
328
329 Block encodedParameters(parameters.wireEncode());
330
331 Name commandName("/localhost/nfd/strategy-choice");
332 commandName.append("set");
333 commandName.append(encodedParameters);
334
335 shared_ptr<Interest> command(make_shared<Interest>(commandName));
336
337 getFace()->onReceiveData +=
338 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
339 command->getName(), 400, "Malformed command");
340
341 getManager().onValidatedStrategyChoiceRequest(command);
342
343 BOOST_REQUIRE(didCallbackFire());
344}
345
346BOOST_AUTO_TEST_CASE(SetStrategiesMissingStrategy)
347{
348 ControlParameters parameters;
349 parameters.setName("/test");
350
351 Block encodedParameters(parameters.wireEncode());
352
353 Name commandName("/localhost/nfd/strategy-choice");
354 commandName.append("set");
355 commandName.append(encodedParameters);
356
357 shared_ptr<Interest> command(make_shared<Interest>(commandName));
358
359 getFace()->onReceiveData +=
360 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
361 command->getName(), 400, "Malformed command");
362
363 getManager().onValidatedStrategyChoiceRequest(command);
364
365 BOOST_REQUIRE(didCallbackFire());
366 fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
367 BOOST_REQUIRE_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-a");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700368}
369
370BOOST_AUTO_TEST_CASE(SetUnsupportedStrategy)
371{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600372 ControlParameters parameters;
373 parameters.setName("/test");
374 parameters.setStrategy("/localhost/nfd/strategy/unit-test-doesnotexist");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700375
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600376 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700377
378 Name commandName("/localhost/nfd/strategy-choice");
379 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600380 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700381
382 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700383 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700384
385 getFace()->onReceiveData +=
386 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
387 command->getName(), 504, "Unsupported strategy");
388
389 getManager().onValidatedStrategyChoiceRequest(command);
390
391 BOOST_REQUIRE(didCallbackFire());
392 fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
393 BOOST_CHECK_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-a");
394}
395
396class DefaultStrategyOnlyFixture : public StrategyChoiceManagerFixture
397{
398public:
399 DefaultStrategyOnlyFixture()
400 : StrategyChoiceManagerFixture()
401 {
402
403 }
404
405 virtual
406 ~DefaultStrategyOnlyFixture()
407 {
408
409 }
410};
411
412
413/// \todo I'm not sure this code branch (code 405) can happen. The manager tests for the strategy first and will return 504.
414// BOOST_FIXTURE_TEST_CASE(SetNotInstalled, DefaultStrategyOnlyFixture)
415// {
416// BOOST_REQUIRE(!getStrategyChoice().hasStrategy("/localhost/nfd/strategy/test-strategy-b"));
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600417// ControlParameters parameters;
418// parameters.setName("/test");
419// parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700420
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600421// Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700422
423// Name commandName("/localhost/nfd/strategy-choice");
424// commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600425// commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700426
427// shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700428// generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700429
430// getFace()->onReceiveData +=
431// bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
432// command->getName(), 405, "Strategy not installed");
433
434// getManager().onValidatedStrategyChoiceRequest(command);
435
436// BOOST_REQUIRE(didCallbackFire());
437// fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
438// BOOST_CHECK_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-a");
439// }
440
441BOOST_AUTO_TEST_CASE(Unset)
442{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600443 ControlParameters parameters;
444 parameters.setName("/test");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700445
446 BOOST_REQUIRE(m_strategyChoice.insert("/test", "/localhost/nfd/strategy/test-strategy-b"));
447 BOOST_REQUIRE_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
448 "/localhost/nfd/strategy/test-strategy-b");
449
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600450 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700451
452 Name commandName("/localhost/nfd/strategy-choice");
453 commandName.append("unset");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600454 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700455
456 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700457 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700458
459 getFace()->onReceiveData +=
460 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600461 command->getName(), 200, "Success", encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700462
463 getManager().onValidatedStrategyChoiceRequest(command);
464
465 BOOST_REQUIRE(didCallbackFire());
466
467 BOOST_CHECK_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
468 "/localhost/nfd/strategy/test-strategy-a");
469}
470
471BOOST_AUTO_TEST_CASE(UnsetRoot)
472{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600473 ControlParameters parameters;
474 parameters.setName("/");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700475
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600476 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700477
478 Name commandName("/localhost/nfd/strategy-choice");
479 commandName.append("unset");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600480 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700481
482 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700483 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700484
485 getFace()->onReceiveData +=
486 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
487 command->getName(), 403, "Cannot unset root prefix strategy");
488
489 getManager().onValidatedStrategyChoiceRequest(command);
490
491 BOOST_REQUIRE(didCallbackFire());
492
493 BOOST_CHECK_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
494 "/localhost/nfd/strategy/test-strategy-a");
495}
496
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600497BOOST_AUTO_TEST_CASE(UnsetMissingName)
498{
499 ControlParameters parameters;
500
501 BOOST_REQUIRE(m_strategyChoice.insert("/test", "/localhost/nfd/strategy/test-strategy-b"));
502 BOOST_REQUIRE_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
503 "/localhost/nfd/strategy/test-strategy-b");
504
505 Block encodedParameters(parameters.wireEncode());
506
507 Name commandName("/localhost/nfd/strategy-choice");
508 commandName.append("unset");
509 commandName.append(encodedParameters);
510
511 shared_ptr<Interest> command(make_shared<Interest>(commandName));
512 generateCommand(*command);
513
514 getFace()->onReceiveData +=
515 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
516 command->getName(), 400, "Malformed command");
517
518 getManager().onValidatedStrategyChoiceRequest(command);
519
520 BOOST_REQUIRE(didCallbackFire());
521
522 BOOST_CHECK_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
523 "/localhost/nfd/strategy/test-strategy-b");
524}
525
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700526BOOST_AUTO_TEST_SUITE_END()
527
528} // namespace tests
529} // namespace nfd