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

TestCaseRecoveryAction_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseRecoveryAction_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 25.06.03 00008 // Author R. Totaro 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/Constants.h" 00013 #include "../GeneralInclude/TestConstants.h" 00014 #include "../FDIR/DC_NullRecoveryAction.h" 00015 #include "../FDIR/DC_DummyRecoveryAction.h" 00016 #include "TestCaseRecoveryAction_1.h" 00017 00018 TestCaseRecoveryAction_1::TestCaseRecoveryAction_1(void) : 00019 TestCaseGenericSetUp(ID_DUMMYRECOVERYACTION*10+1,"TestCaseRecoveryAction_1") { 00020 return; 00021 } 00022 00023 void TestCaseRecoveryAction_1::runTestCase(void) { 00024 DC_NullRecoveryAction *pNRA=new DC_NullRecoveryAction; 00025 DC_DummyRecoveryAction *pDRA=new DC_DummyRecoveryAction; 00026 00027 // Verify the correctness of the class ids 00028 if (pNRA->getClassId()!=ID_NULLRECOVERYACTION) { 00029 setTestResult(TEST_FAILURE,"Wrong class id"); 00030 return; 00031 } 00032 00033 if (pDRA->getClassId()!=ID_DUMMYRECOVERYACTION) { 00034 setTestResult(TEST_FAILURE,"Wrong class id"); 00035 return; 00036 } 00037 00038 // Initially there shall be no next recovery action 00039 if (pDRA->getNextRecoveryAction()) { 00040 setTestResult(TEST_FAILURE,"Initialization failure"); 00041 return; 00042 } 00043 00044 // The execution flag shall be true: calling execute() shall return 00045 // ACTION_SUCCESS. 00046 if (pDRA->execute()!=ACTION_SUCCESS) { 00047 setTestResult(TEST_FAILURE,"Execution flag wrongly set"); 00048 return; 00049 } 00050 00051 // We set the execution flag to false. A call to execute() 00052 // shall now return ACTION_CANNOT_EXECUTE. 00053 pDRA->setExecutionFlag(false); 00054 if (pDRA->execute()!=ACTION_CANNOT_EXECUTE) { 00055 setTestResult(TEST_FAILURE,"setExecutionFlag() failed"); 00056 return; 00057 } 00058 00059 // Invoking pNRA->execute() shall return ACTION_SUCCESS 00060 if (pNRA->execute()!=ACTION_SUCCESS) { 00061 setTestResult(TEST_FAILURE,"Execution flag wrongly set"); 00062 return; 00063 } 00064 00065 // We now set pDRA as pNRA's next recovery action and verify 00066 // it worked. 00067 pNRA->setNextRecoveryAction(pDRA); 00068 if (pNRA->getNextRecoveryAction()!=pDRA) { 00069 setTestResult(TEST_FAILURE,"setNextRecoveryAction() failed"); 00070 return; 00071 } 00072 00073 // We set pDRA's outcome to ACTION_FAILURE and its execution 00074 // flag to true. 00075 pDRA->setActionOutcome(ACTION_FAILURE); 00076 pDRA->setExecutionFlag(true); 00077 00078 // Calling pNRA->execute() shall now return pDRA's outcome 00079 // (that is ACTION_FAILURE). 00080 if (pNRA->execute()!=ACTION_FAILURE) { 00081 setTestResult(TEST_FAILURE,"Wrong outcome"); 00082 return; 00083 } 00084 00085 setTestResult(TEST_SUCCESS,"Test Successful"); 00086 return; 00087 }
Copyright 2003 P&P Software GmbH - All Rights Reserved