-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests that use the Dummy plugin to test execute and requestComm…
…ands methods.
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* DummyUDPProcessPluginTest.cpp | ||
* | ||
* Created on: 25 Sep 2024 | ||
* Author: Alan Greer | ||
*/ | ||
|
||
#include <boost/test/unit_test.hpp> | ||
#include <DebugLevelLogger.h> | ||
#include "FrameProcessorDefinitions.h" | ||
#include "DummyUDPProcessPlugin.h" | ||
#include "IpcMessage.h" | ||
|
||
class DummyUDPProcessPluginTestFixture { | ||
public: | ||
DummyUDPProcessPluginTestFixture() { | ||
set_debug_level(3); | ||
|
||
dummy_plugin.set_name("dummy"); | ||
} | ||
|
||
~DummyUDPProcessPluginTestFixture() {} | ||
|
||
FrameProcessor::DummyUDPProcessPlugin dummy_plugin; | ||
}; | ||
|
||
BOOST_FIXTURE_TEST_SUITE(DummyUDPProcessPluginUnitTest, DummyUDPProcessPluginTestFixture); | ||
|
||
BOOST_AUTO_TEST_CASE( DummyUDPProcessPlugin_commands ) | ||
{ | ||
OdinData::IpcMessage command_reply; | ||
OdinData::IpcMessage command_execute; | ||
OdinData::IpcMessage bad_command_execute; | ||
|
||
// Request the command set of the DummyUDPProcessPlugin | ||
BOOST_REQUIRE_NO_THROW(dummy_plugin.requestCommands(command_reply)); | ||
|
||
OdinData::IpcMessage sub_reply(command_reply.get_param<const rapidjson::Value&>(std::string("dummy")), | ||
command_reply.get_msg_type(), | ||
command_reply.get_msg_val()); | ||
|
||
// Verify that the command set includes the command to execute a print statement | ||
BOOST_CHECK_EQUAL(sub_reply.has_param(std::string("print")), true); | ||
|
||
OdinData::IpcMessage param_reply(sub_reply.get_param<const rapidjson::Value&>(std::string("print")), | ||
sub_reply.get_msg_type(), | ||
sub_reply.get_msg_val()); | ||
|
||
// Verify that the command has the parameter name, which names the configuration item to print | ||
BOOST_CHECK_EQUAL(param_reply.has_param(std::string("name")), true); | ||
|
||
// Verify that an incorrect commmand request is rejected | ||
BOOST_CHECK_THROW(dummy_plugin.execute(bad_command_execute, command_reply), std::runtime_error); | ||
|
||
BOOST_REQUIRE_NO_THROW(command_execute.set_param(std::string("print/name"), std::string("width"))); | ||
|
||
// Verify that a supported commmand request is accepted | ||
BOOST_REQUIRE_NO_THROW(dummy_plugin.execute(command_execute, command_reply)); | ||
}; | ||
|
||
BOOST_AUTO_TEST_SUITE_END(); //DummyUDPProcessPluginUnitTest |