Skip to content

Commit

Permalink
Added tests that use the Dummy plugin to test execute and requestComm…
Browse files Browse the repository at this point in the history
…ands methods.
  • Loading branch information
ajgdls committed Sep 25, 2024
1 parent bda6e50 commit 5cc56cf
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cpp/frameProcessor/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ file(GLOB TEST_SOURCES
FrameProcessorTest.cpp
GapFillPluginTest.cpp
MetaMessageTest.cpp
DummyUDPProcessPluginTest.cpp
)
# Add tests for BloscPlugin if Blosc is present
if (${BLOSC_FOUND})
Expand Down Expand Up @@ -39,6 +40,7 @@ target_link_libraries(frameProcessorTest
LiveViewPlugin
SumPlugin
GapFillPlugin
DummyUDPProcessPlugin
${COMMON_LIBRARY})

# Link for BloscPlugin if Blosc is present
Expand Down
61 changes: 61 additions & 0 deletions cpp/frameProcessor/test/DummyUDPProcessPluginTest.cpp
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

0 comments on commit 5cc56cf

Please sign in to comment.