tests: MockNfdMgmtFixture requires specific command Interest
MockNfdMgmtFixture previously allows a test case to respond to
the "last" command Interest, which causes difficulty when the
management client sends multiple command Interests together. It
now requires a specific command Interest for sending a response.
refs #3866
Change-Id: I80eeed2cdced618725a73f21bfaa387d831ca11a
diff --git a/tests/tools/nfdc/mock-nfd-mgmt-fixture.hpp b/tests/tools/nfdc/mock-nfd-mgmt-fixture.hpp
index 319a9f1..fd309bf 100644
--- a/tests/tools/nfdc/mock-nfd-mgmt-fixture.hpp
+++ b/tests/tools/nfdc/mock-nfd-mgmt-fixture.hpp
@@ -72,35 +72,15 @@
return ControlParameters(interest.getName().at(expectedPrefix.size()).blockFromValue());
}
- DEPRECATED(
- ndn::optional<ControlParameters>
- getCommand(const Name& expectedPrefix) const)
- {
- if (face.sentInterests.empty()) {
- return ndn::nullopt;
- }
- return parseCommand(face.sentInterests.back(), expectedPrefix);
- }
-
- /** \brief respond to the last command
+ /** \brief send successful response to a command Interest
*/
void
succeedCommand(const Interest& interest, const ControlParameters& parameters)
{
- ndn::nfd::ControlResponse resp(200, "OK");
- resp.setBody(parameters.wireEncode());
- this->sendCommandReply(interest, resp);
+ this->sendCommandReply(interest, 200, "OK", parameters.wireEncode());
}
- DEPRECATED(
- void
- succeedCommand(const ControlParameters& parameters))
- {
- this->succeedCommand(face.sentInterests.back(), parameters);
- }
-
- /** \brief respond to the last command
- * \pre last Interest is a command
+ /** \brief send failure response to a command Interest
*/
void
failCommand(const Interest& interest, uint32_t code, const std::string& text)
@@ -108,26 +88,14 @@
this->sendCommandReply(interest, {code, text});
}
- DEPRECATED(
- void
- failCommand(uint32_t code, const std::string& text))
- {
- this->sendCommandReply(face.sentInterests.back(), {code, text});
- }
-
+ /** \brief send failure response to a command Interest
+ */
void
failCommand(const Interest& interest, uint32_t code, const std::string& text, const ControlParameters& body)
{
this->sendCommandReply(interest, code, text, body.wireEncode());
}
- DEPRECATED(
- void
- failCommand(uint32_t code, const std::string& text, const ControlParameters& body))
- {
- this->failCommand(face.sentInterests.back(), code, text, body);
- }
-
protected: // StatusDataset
/** \brief send an empty dataset in reply to StatusDataset request
* \param prefix dataset prefix without version and segment
@@ -307,6 +275,7 @@
/** \brief require the command in \p interest has expected prefix
* \note This must be used in processInterest lambda, and the Interest must be named 'interest'.
+ * \return ControlParameters, or nullopt if \p interest does match \p expectedPrefix
*/
#define MOCK_NFD_MGMT_REQUIRE_COMMAND_IS(expectedPrefix) \
[interest] { \
@@ -316,12 +285,4 @@
return *params; \
} ()
-///\deprecated use MOCK_NFD_MGMT_REQUIRE_COMMAND_IS
-#define MOCK_NFD_MGMT_REQUIRE_LAST_COMMAND_IS(expectedPrefix) \
- [this] { \
- BOOST_REQUIRE_MESSAGE(!face.sentInterests.empty(), "no Interest expressed"); \
- const Interest& interest = face.sentInterests.back(); \
- return MOCK_NFD_MGMT_REQUIRE_COMMAND_IS(expectedPrefix); \
- } ()
-
#endif // NFD_TESTS_TOOLS_NFDC_MOCK_NFD_MGMT_FIXTURE_HPP