**FREE //===================================================================== // // Project.....: MEDDFN // // Member......: MEDDFNTSTE // // Description.: MEDDFN Error Test Program // // Erstellen mit: // // CRTRPGMOD MODULE(GOSCH1/MEDDFNTSTE) // SRCSTMF('/home/GOSCH/meddfn/meddfntste.rpgle') // OPTION(*EVENTF) // DBGVIEW(*SOURCE) // TGTRLS(*CURRENT) // // CRTPGM PGM(GOSCH1/MEDDFNTSTE) // MODULE(GOSCH1/MEDDFNTSTE) // BNDSRVPGM(GOSCH1/MEDDFNSRV) // ACTGRP(*NEW) // TGTRLS(*CURRENT) // //===================================================================== ctl-opt option(*srcstmt:*nodebugio); /COPY './meddfn_h.rpgle' /COPY './meddfnap_h.rpgle' /COPY './meddfnpr.rpgle' //===================================================================== // // Data // //===================================================================== dcl-ds MediaDefinition likeds(MD_MediaDefinition_T); dcl-ds Error likeds(MD_Error_T); //===================================================================== // // Prototypes // //===================================================================== dcl-pr TestCreateValidation; end-pr; dcl-pr TestRetrieveApiError; end-pr; dcl-pr TestDeleteApiError; end-pr; //===================================================================== // // Main // //===================================================================== TestCreateValidation(); TestRetrieveApiError(); TestDeleteApiError(); dsply '----------------------------------------'; dsply 'MEDDFN Error Test completed'; dsply '----------------------------------------'; //===================================================================== // End //===================================================================== *inlr = *on; return; //===================================================================== // // TestCreateValidation // //===================================================================== //===================================================================== // // TestCreateValidation // // Verifies that the public interface returns a MEDDFN validation // error when the media definition name is missing. // //===================================================================== dcl-proc TestCreateValidation; clear MediaDefinition; clear Error; MediaDefinition.LibraryName = 'QGPL'; MediaDefinition.NumberOfDevices = 1; dsply '----------------------------------------'; dsply 'Test: Create validation error'; dsply '----------------------------------------'; monitor; MD_CreateMediaDefinition( MediaDefinition : Error); on-error; // Expected: MD_CreateMediaDefinition sends an escape message. endmon; if Error.HasError; dsply 'PASS Error.HasError'; else; dsply 'FAIL Error.HasError'; endif; if Error.MessageID = 'MDF0001'; dsply 'PASS Error.MessageID'; else; dsply 'FAIL Error.MessageID'; endif; if %trim(Error.MessageData) = ''; dsply 'PASS Error.MessageData'; else; dsply 'INFO Error.MessageData contains data'; endif; end-proc; //===================================================================== // // TestRetrieveApiError // // Verifies that an IBM i API error is returned through MD_Error_T. // The object is deliberately not created. // //===================================================================== dcl-proc TestRetrieveApiError; clear MediaDefinition; clear Error; MediaDefinition.MediaDefinitionName = 'MEDDFNXERR'; MediaDefinition.LibraryName = 'GOSCH1'; dsply '----------------------------------------'; dsply 'Test: Retrieve API error'; dsply '----------------------------------------'; monitor; MD_RetrieveMediaDefinition( MediaDefinition : Error); on-error; // Expected: QSRRTVMD reports that the object does not exist. endmon; if Error.HasError; dsply 'PASS Error.HasError'; else; dsply 'FAIL Error.HasError'; endif; if %trim(Error.MessageID) <> ''; dsply 'PASS Error.MessageID'; else; dsply 'FAIL Error.MessageID'; endif; if %trim(Error.MessageData) <> ''; dsply 'PASS Error.MessageData'; else; dsply 'INFO Error.MessageData is empty'; endif; end-proc; //===================================================================== // // TestDeleteApiError // // Verifies IBM i API error handling for deletion of a non-existing // media definition. // //===================================================================== dcl-proc TestDeleteApiError; clear MediaDefinition; clear Error; MediaDefinition.MediaDefinitionName = 'MEDDFNXERR'; MediaDefinition.LibraryName = 'GOSCH1'; dsply '----------------------------------------'; dsply 'Test: Delete API error'; dsply '----------------------------------------'; monitor; MD_DeleteMediaDefinition( MediaDefinition : Error); on-error; // Expected: QSRDLTMD reports that the object does not exist. endmon; if Error.HasError; dsply 'PASS Error.HasError'; else; dsply 'FAIL Error.HasError'; endif; if %trim(Error.MessageID) <> ''; dsply 'PASS Error.MessageID'; else; dsply 'FAIL Error.MessageID'; endif; if %trim(Error.MessageData) <> ''; dsply 'PASS Error.MessageData'; else; dsply 'INFO Error.MessageData is empty'; endif; end-proc;