Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TestCaseDataPoolMonitor_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseDataPoolMonitor_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 30.10.03 (Version 1.0) 00008 // Author R. Totaro 00009 // 00010 // Change Record: 00011 00012 #include "../GeneralInclude/CompilerSwitches.h" 00013 #include "../GeneralInclude/ClassId.h" 00014 #include "../GeneralInclude/Constants.h" 00015 #include "../System/DC_DummyObsClock.h" 00016 #include "../FDIR/DC_OutOfRangeProfile.h" 00017 #include "../FDIR/DC_NullRecoveryAction.h" 00018 #include "../Data/DC_SampleFullDataPool.h" 00019 #include "../Data/DC_DataPoolMonitor.h" 00020 #include "TestCaseDataPoolMonitor_1.h" 00021 00022 TestCaseDataPoolMonitor_1::TestCaseDataPoolMonitor_1(void) : 00023 TestCaseWithEvtCheck(ID_DATAPOOLMONITOR*10+1,"TestCaseDataPoolMonitor_1") { 00024 return; 00025 } 00026 00027 void TestCaseDataPoolMonitor_1::runTestCase(void) { 00028 const unsigned int nEvt=getNumberOfEvents(); 00029 00030 // Create and initialize the data pool 00031 TD_DataPoolId id; 00032 RecoveryAction *pAction=new DC_NullRecoveryAction; 00033 DC_SampleFullDataPool *pDP =new DC_SampleFullDataPool; 00034 00035 pDP->setObsClock(new DC_DummyObsClock); 00036 00037 for (id=pDP->firstIdentifier();!pDP->isLastIdentifier();id=pDP->nextIdentifier()) { 00038 DC_OutOfRangeProfile *pProfile=new DC_OutOfRangeProfile; 00039 00040 pProfile->setLowerBound((TD_Float)0.0); 00041 pProfile->setUpperBound((TD_Float)2.0); 00042 pDP->setMonitoringProfile(id,pProfile); 00043 00044 pDP->setRecoveryAction(id,pAction); 00045 00046 if (pDP->isFloat(id)) 00047 pDP->setValue(id,(TD_Float)1.0); 00048 else 00049 pDP->setValue(id,(TD_Integer)1); 00050 } 00051 00052 // Link the data pool to the root object 00053 CC_RootObject::setDataPool(pDP); 00054 00055 // Create the object under test 00056 DC_DataPoolMonitor *pDPM=new DC_DataPoolMonitor; 00057 00058 // Verify correctness of the class identifier 00059 if (pDPM->getClassId()!=ID_DATAPOOLMONITOR) { 00060 setTestResult(TEST_FAILURE,"Wrong class identifier"); 00061 return; 00062 } 00063 00064 // Execute the data pool check and verify that the data are still valid 00065 pDPM->execute(); 00066 for (id=pDP->firstIdentifier();!pDP->isLastIdentifier();id=pDP->nextIdentifier()) { 00067 if (!pDP->isValid(id)) { 00068 setTestResult(TEST_FAILURE,"Wrong validity status"); 00069 return; 00070 } 00071 } 00072 00073 // Verify that no recovery action was executed 00074 if (getNumberOfEvents()!=nEvt+1) { 00075 setTestResult(TEST_FAILURE,"Wrong number of events"); 00076 return; 00077 } 00078 00079 // Set the values out of the allowed range and verify that their 00080 // validity flags are properly changed and that the recovery 00081 // actions are executed. 00082 unsigned int evtOffset=2; 00083 00084 for (id=pDP->firstIdentifier();!pDP->isLastIdentifier();id=pDP->nextIdentifier()) { 00085 if (pDP->isFloat(id)) 00086 pDP->setValue(id,(TD_Float)3.0); 00087 else 00088 pDP->setValue(id,(TD_Integer)3); 00089 } 00090 00091 pDPM->execute(); 00092 00093 // The execution of a recovery action should lead to two events being generated in 00094 // the event repository. It is checked that for each item in the repository, the 00095 // corresponding event was generated. 00096 for (id=pDP->firstIdentifier();!pDP->isLastIdentifier();id=pDP->nextIdentifier()) { 00097 if (pDP->isValid(id)) { 00098 setTestResult(TEST_FAILURE,"Failed to change the validity status"); 00099 return; 00100 } 00101 00102 // Terminate when the oldest event in the repository has been processed 00103 if ((getNumberOfEvents()-(nEvt+evtOffset))>=getEventRepositorySize()) 00104 break; 00105 00106 if (verifySpecificEvent(nEvt+evtOffset,EVT_PUNCTUAL_ACTION_EXEC)) { 00107 setTestResult(TEST_FAILURE,"Recovery action not executed"); 00108 return; 00109 } 00110 00111 evtOffset+=2; 00112 } 00113 00114 setTestResult(TEST_SUCCESS,"Test Successful"); 00115 return; 00116 }
Copyright 2003 P&P Software GmbH - All Rights Reserved