summaryrefslogtreecommitdiff
path: root/cesar/maximus/coreengine/src/MsgTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/coreengine/src/MsgTest.cpp')
-rw-r--r--cesar/maximus/coreengine/src/MsgTest.cpp302
1 files changed, 0 insertions, 302 deletions
diff --git a/cesar/maximus/coreengine/src/MsgTest.cpp b/cesar/maximus/coreengine/src/MsgTest.cpp
deleted file mode 100644
index 9b5cc048f6..0000000000
--- a/cesar/maximus/coreengine/src/MsgTest.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-
-#include "MsgTest.h"
-
-#include "Msg.h"
-#include "Maximus.h"
-#include "FunctionSciMsg.h"
-#include "FunctionCallParameter.h"
-#include "Sta.h"
-#include "CoreEngine.h"
-
-#include "system_types.h" // for 'MAXIMUS_STATION_STATUS_IDLE'
-
-#include <iostream>
-using namespace std;
-
-CPPUNIT_TEST_SUITE_REGISTRATION (MsgTest);
-
-void callback1 (Msg & msg)
-{
- logTest();
-}
-
-void callback2 (Msg & msg)
-{
- logTest();
-}
-
-
-void MsgTest::setUp (void)
-{
- logTest();
-
- mpCoreEngine = new CoreEngine();
- mpMaximus = new Maximus(mpCoreEngine);
- mpMsg = new Msg(mpMaximus, mpCoreEngine->getFunctionCall(), mpCoreEngine->getSystem());
-}
-
-
-void MsgTest::tearDown (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- delete (mpMsg);
- mpMsg = NULL;
- }
- if (NULL != mpMaximus)
- {
- delete (mpMaximus);
- mpMaximus = NULL;
- }
- mpCoreEngine = NULL;
-}
-
-
-void MsgTest::add_param_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- mpMsg->add_param("name");
- mpMsg->add_param("unsigned char *", 6, (unsigned char *)"hello\0");
- string str("hello");
- mpMsg->add_param("string", str);
- mpMsg->add_param<int>("<int>", 123);
- unsigned int i = 456;
- mpMsg->add_param("<unsigned int>", i);
- mpMsg->add_param<bool>("<bool>", true);
-
- CPPUNIT_ASSERT_MESSAGE ( "add_param failed",
- (mpMsg->is_param("name"))
- && (mpMsg->is_param("unsigned char *"))
- && (mpMsg->is_param("string"))
- && (mpMsg->is_param("<int>"))
- && (mpMsg->is_param("<unsigned int>"))
- && (mpMsg->is_param("<bool>")) );
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::remove_param_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- mpMsg->add_param("name");
- mpMsg->remove_param("name");
-
- CPPUNIT_ASSERT_MESSAGE ( "remove_param failed",
- !mpMsg->is_param("name") );
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::set_cb_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- mpMsg->set_cb(&callback1);
- mpMsg->set_cb(&callback2);
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::remove_cb_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- mpMsg->set_cb(&callback1);
- mpMsg->remove_cb();
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::set_sta_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- Sta sta1 = mpMaximus->create_sta();
- Sta sta2 = mpMaximus->create_sta();
- mpMsg->set_sta(sta1);
- mpMsg->set_sta(sta2);
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::send_async_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- Sta sta = mpMaximus->create_sta();
- mpMsg->send_async(sta);
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::send_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- Sta sta = mpMaximus->create_sta();
- mpMsg->send(sta);
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::is_param_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- mpMsg->add_param("name");
-
- CPPUNIT_ASSERT_MESSAGE ( "is_param failed",
- mpMsg->is_param("name") );
-
- mpMsg->remove_param("name");
-
- CPPUNIT_ASSERT_MESSAGE ( "is_param failed",
- !mpMsg->is_param("name") );
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::bind_param_test (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- string str("hello");
- mpMsg->add_param("string", str);
- mpMsg->add_param<int>("int", 123);
- mpMsg->add_param<bool>("false", false);
- mpMsg->add_param<bool>("true", true);
-
- unsigned long length = str.length();
- unsigned char * pParam = new unsigned char [length];
- int i = mpMsg->bind_param<int>("int");
- bool bFalse = mpMsg->bind_param<bool>("false");
- bool bTrue = mpMsg->bind_param<bool>("true");
-
- CPPUNIT_ASSERT_MESSAGE ( "bind_param failed",
- (NULL != mpMsg->bind_param("string", length, pParam))
- && (0 == memcmp(pParam, str.c_str(), str.length()))
- && (mpMsg->is_param("int"))
- && (123 == i)
- && (mpMsg->is_param("false"))
- && !bFalse
- && (mpMsg->is_param("true"))
- && bTrue );
-
- if (NULL != pParam)
- {
- delete [] pParam;
- pParam = NULL;
- }
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::receiveResponseTest (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- FunctionSciMsg * pFunctionSciMsg = new FunctionSciMsg(mpCoreEngine->getFunctionCall());
- pFunctionSciMsg->addParameter(FunctionCallParameter("name", 6, (unsigned char *)"hello\0"));
- mpMsg->receiveResponse(*pFunctionSciMsg);
-
- CPPUNIT_ASSERT_MESSAGE ( "receiveResponse failed",
- mpMsg->is_param("name") );
-
- if (NULL != pFunctionSciMsg)
- {
- delete(pFunctionSciMsg);
- pFunctionSciMsg = NULL;
- }
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-
-
-void MsgTest::receiveAsynchronousResponseTest (void)
-{
- logTest();
-
- if (NULL != mpMsg)
- {
- FunctionSciMsg * pFunctionSciMsg = new FunctionSciMsg(mpCoreEngine->getFunctionCall());
- pFunctionSciMsg->addParameter(FunctionCallParameter("name", 6, (unsigned char *)"hello\0"));
- mpMsg->receiveAsynchronousResponse(*pFunctionSciMsg);
-
- CPPUNIT_ASSERT_MESSAGE ( "receiveAsynchronousResponse failed",
- mpMsg->is_param("name") );
-
- if (NULL != pFunctionSciMsg)
- {
- delete(pFunctionSciMsg);
- pFunctionSciMsg = NULL;
- }
- }
- else
- {
- CPPUNIT_FAIL ("Msg pointer is NULL");
- }
-}
-