summaryrefslogtreecommitdiff
path: root/cesar/maximus/system/src/SystemManagerTest.cpp
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/maximus/system/src/SystemManagerTest.cpp
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/maximus/system/src/SystemManagerTest.cpp')
-rw-r--r--cesar/maximus/system/src/SystemManagerTest.cpp202
1 files changed, 202 insertions, 0 deletions
diff --git a/cesar/maximus/system/src/SystemManagerTest.cpp b/cesar/maximus/system/src/SystemManagerTest.cpp
new file mode 100644
index 0000000000..6b71009730
--- /dev/null
+++ b/cesar/maximus/system/src/SystemManagerTest.cpp
@@ -0,0 +1,202 @@
+
+#include "SystemManagerTest.h"
+
+#include "SystemManager.h"
+#include "SciServer.h"
+#include "PhyProcessor.h"
+#include "NetworkClockProcessor.h"
+#include "FunctionCallManager.h"
+#include "EthernetProcessor.h"
+
+#include "Error.h"
+#include "Logger.h"
+
+using namespace std;
+
+CPPUNIT_TEST_SUITE_REGISTRATION (SystemManagerTest);
+
+
+void SystemManagerTest::setUp (void)
+{
+ logTest();
+
+ mpSciServer = new SciServer ();
+ mpSystemManager = new SystemManager (mpSciServer);
+
+ mpFunctionCall = new FunctionCallManager (mpSciServer);
+ mpPhy = new PhyProcessor (mpSciServer);
+ mpEthernet = new EthernetProcessor (mpSciServer);
+ mpNetworkClock = new NetworkClockProcessor (mpSciServer, mpSystemManager, mpFunctionCall, mpPhy, mpEthernet);
+ mpSystemManager->setNetworkClock(mpNetworkClock);
+}
+
+
+void SystemManagerTest::tearDown (void)
+{
+ logTest();
+
+ if (NULL != mpSystemManager)
+ {
+ delete mpSystemManager;
+ mpSystemManager = NULL;
+ }
+ if (NULL != mpSciServer)
+ {
+ delete mpSciServer;
+ mpSciServer = NULL;
+ }
+ if (NULL != mpFunctionCall)
+ {
+ delete mpFunctionCall;
+ mpFunctionCall = NULL;
+ }
+ if (NULL != mpPhy)
+ {
+ delete mpPhy;
+ mpPhy = NULL;
+ }
+ if (NULL != mpEthernet)
+ {
+ delete mpEthernet;
+ mpEthernet = NULL;
+ }
+ if (NULL != mpNetworkClock)
+ {
+ delete mpNetworkClock;
+ mpNetworkClock = NULL;
+ }
+}
+
+
+void SystemManagerTest::createStationTest (void)
+{
+ logTest();
+
+ try
+ {
+ Sci_Msg_Station_Id stationId = mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable()); // will be deleted in 'tearDown()'
+ CPPUNIT_ASSERT_MESSAGE ( "createStation failed",
+ 0 != stationId );
+ }
+ catch ( Error &e )
+ {
+ e.display();
+ }
+}
+
+
+void SystemManagerTest::removeStationTest (void)
+{
+ logTest();
+
+ try
+ {
+ // Create Station 1
+ //
+ Sci_Msg_Station_Id stationId1 = mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable());
+
+ // Create Station 2
+ //
+ Sci_Msg_Station_Id stationId2 = mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable());
+
+ // Create Station 3
+ //
+ Sci_Msg_Station_Id stationId3 = mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable());
+
+ INetworkClock * pNetworkClock = new NetworkClockProcessor();
+ mpSystemManager->setNetworkClock(pNetworkClock);
+
+ CPPUNIT_ASSERT_MESSAGE ( "removeStation failed",
+ mpSystemManager->removeStation (stationId2) );
+
+ CPPUNIT_ASSERT_MESSAGE ( "removeStation failed",
+ mpSystemManager->removeStation (stationId1) );
+
+ CPPUNIT_ASSERT_MESSAGE ( "removeStation failed",
+ mpSystemManager->removeStation (stationId3) );
+
+ if (NULL != pNetworkClock)
+ {
+ delete (pNetworkClock);
+ pNetworkClock = NULL;
+ }
+ }
+ catch ( Error &e )
+ {
+ e.display();
+ }
+}
+
+
+void SystemManagerTest::areAllActiveStationsIdleTest (void)
+{
+ logTest();
+
+ try
+ {
+ // Create Station 1
+ //
+ mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable());
+
+ // Create Station 2
+ //
+ mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable());
+
+ // Create Station 3
+ //
+ mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable());
+
+ CPPUNIT_ASSERT_MESSAGE ( "areAllActiveStationsIdle failed",
+ !mpSystemManager->areAllActiveStationsIdle() );
+
+ CPPUNIT_ASSERT_MESSAGE ( "removeAllStations failed",
+ mpSystemManager->removeAllStations() );
+ }
+ catch ( Error &e )
+ {
+ e.display();
+ }
+}
+
+
+void SystemManagerTest::setNetworkClockTest (void)
+{
+ logTest();
+
+ INetworkClock * pNetworkClock = new NetworkClockProcessor();
+
+ CPPUNIT_ASSERT_MESSAGE ( "setNetworkClock failed",
+ mpSystemManager->setNetworkClock(pNetworkClock) );
+
+ if (NULL != pNetworkClock)
+ {
+ delete (pNetworkClock);
+ pNetworkClock = NULL;
+ }
+}
+
+
+void SystemManagerTest::setStationNameTest (void)
+{
+ logTest();
+
+ if (NULL == mpSystemManager)
+ {
+ CPPUNIT_FAIL ( "The initialized System Manager pointer is NULL" );
+ }
+ else
+ {
+ string stationName = "This is my station name";
+
+ Sci_Msg_Station_Id stationId = mpSystemManager->createStation(mpSystemManager->getDefaultStationExecutable());
+ mpSystemManager->updateStationStatus(stationId, MAXIMUS_STATION_STATUS_IDLE);
+ NetworkClockProcessor networkClock;
+ mpSystemManager->setNetworkClock((INetworkClock *)&networkClock);
+
+ CPPUNIT_ASSERT_MESSAGE ( "setStationName failed",
+ mpSystemManager->setStationName(stationId, stationName) );
+
+ mpSystemManager->removeStation(stationId);
+ }
+}
+