summaryrefslogtreecommitdiff
path: root/cesar/maximus/system/src/SystemSciMsgTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/system/src/SystemSciMsgTest.cpp')
-rw-r--r--cesar/maximus/system/src/SystemSciMsgTest.cpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/cesar/maximus/system/src/SystemSciMsgTest.cpp b/cesar/maximus/system/src/SystemSciMsgTest.cpp
new file mode 100644
index 0000000000..b8015ffee7
--- /dev/null
+++ b/cesar/maximus/system/src/SystemSciMsgTest.cpp
@@ -0,0 +1,108 @@
+
+#include "SystemSciMsgTest.h"
+
+#include "SystemSciMsg.h"
+#include "SciServer.h"
+#include "SystemManager.h"
+#include "PhyProcessor.h"
+#include "NetworkClockProcessor.h"
+#include "FunctionCallManager.h"
+#include "EthernetProcessor.h"
+
+#include "Error.h"
+#include "Logger.h"
+
+#include <iostream>
+using namespace std;
+
+CPPUNIT_TEST_SUITE_REGISTRATION (SystemSciMsgTest);
+
+
+void SystemSciMsgTest::setUp (void)
+{
+ logTest();
+
+ mpSciServer = new SciServer();
+ mpSystemManager = new SystemManager (mpSciServer);
+ mpSystemSciMsg = new SystemSciMsg (mpSystemManager);
+}
+
+
+void SystemSciMsgTest::tearDown (void)
+{
+ logTest();
+
+ if (NULL != mpSystemSciMsg)
+ {
+ delete mpSystemSciMsg;
+ mpSystemSciMsg = NULL;
+ }
+ if (NULL != mpSystemManager)
+ {
+ delete (mpSystemManager);
+ mpSystemManager = NULL;
+ }
+ if (NULL != mpSciServer)
+ {
+ delete (mpSciServer);
+ mpSciServer = NULL;
+ }
+}
+
+
+void SystemSciMsgTest::dispatchMsgTest (void)
+{
+ logTest();
+
+ if (NULL != mpSystemSciMsg)
+ {
+ try
+ {
+ CPPUNIT_ASSERT_MESSAGE ( "setSpecializedSciMsgType failed",
+ mpSystemSciMsg->setSpecializedSciMsgType(SYSTEM_TYPE_IDLE) );
+
+ IFunctionCall * pFunctionCall = new FunctionCallManager (mpSciServer);
+ IPhy * pPhy = new PhyProcessor (mpSciServer);
+ IEthernet * pEthernet = new EthernetProcessor (mpSciServer);
+ INetworkClock * pNetworkClock = new NetworkClockProcessor (mpSciServer, mpSystemManager, pFunctionCall, pPhy, pEthernet);
+ mpSystemManager->setNetworkClock(pNetworkClock);
+ Sci_Msg_Station_Id stationId = mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable());
+
+ CPPUNIT_ASSERT_MESSAGE ( "setSciMsgStationId failed",
+ mpSystemSciMsg->setSciMsgStationId(stationId) );
+
+ CPPUNIT_ASSERT_MESSAGE ( "dispatchMsg failed",
+ mpSystemSciMsg->dispatchMsg() );
+
+ if (NULL != pFunctionCall)
+ {
+ delete (pFunctionCall);
+ pFunctionCall = NULL;
+ }
+ if (NULL != pPhy)
+ {
+ delete (pPhy);
+ pPhy = NULL;
+ }
+ if (NULL != pEthernet)
+ {
+ delete (pEthernet);
+ pEthernet = NULL;
+ }
+ if (NULL != pNetworkClock)
+ {
+ delete (pNetworkClock);
+ pNetworkClock = NULL;
+ }
+ }
+ catch ( Error &e )
+ {
+ e.display();
+ }
+ }
+ else
+ {
+ CPPUNIT_FAIL ( "Initialized SystemSciMsg pointer is NULL" );
+ }
+}
+