| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // Copyright (c) 2000-2018 Ericsson Telecom AB |
| // |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v1.0 |
| // which accompanies this distribution, and is available at |
| // http://www.eclipse.org/legal/epl-v10.html |
| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // File: MBT_Qtronic_Demo.ttcn |
| // Rev: <RnXnn> |
| // Prodnr: CNL 113 659 |
| // Updated: 2009-12-14 |
| // Contact: http://ttcn.ericsson.se |
| /////////////////////////////////////////////////////////////////////////////// |
| module MBT_Qtronic_Demo |
| { |
| |
| import from MBT_Qtronic_Testcases all; |
| import from MBT_Qtronic_Types all; |
| import from MBT_Qtronic_TestHarness all; |
| |
| import from MBT_SUT_SIP_Phone all; |
| |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_Base_Definitions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_RBTScheduler_Functions all; |
| import from EPTF_CLL_LGenBase_Definitions all; |
| import from EPTF_CLL_LGenBase_ConfigFunctions all; |
| import from EPTF_CLL_LGenBase_EventHandlingFunctions all; |
| |
| import from EPTF_MBT_LGen_Definitions all; |
| import from EPTF_MBT_LGen_Functions all; |
| |
| import from EPTF_SIP_LGen_Definitions all; |
| import from EPTF_SIP_LGen_Functions all; |
| import from EPTF_SIP_Common_Functions all; |
| import from EPTF_SIP_UserDatabase_Functions all; |
| import from EPTF_SIP_Transport_Definitions all; |
| import from EPTF_SIP_Transport_Functions all; |
| import from EPTF_SIP_MessageHandler_Functions all; |
| |
| import from EPTF_SIP_TestSteps all; |
| import from EPTF_SIP_Templates all; |
| import from EPTF_SIP_Events all; |
| import from EPTF_SIP_Transaction_Definitions all; |
| |
| import from TCCFileIO_Functions all; |
| import from TCCDateTime_Functions all; |
| |
| modulepar |
| { |
| charstring tsp_MBT_Tester_LocalIP := "159.107.193.33"; |
| integer tsp_MBT_Tester_LocalPort := 15000; |
| charstring tsp_MBT_Tester_RemoteIP := "159.107.193.33"; |
| integer tsp_MBT_Tester_RemotePort := 20000; |
| |
| charstring tsp_MBT_SIP_Transport := "udp"; |
| } |
| |
| type component MBT_Qtronic_Demo_Main_CT |
| extends |
| EPTF_Base_CT, |
| EPTF_MBT_Tester_CT |
| {} |
| |
| function f_MBT_Qtronic_Demo_beginTestCase() runs on Qtronic_CT |
| { |
| log(%definitionId, " started"); |
| |
| f_EPTF_Base_init_CT("mtc"); |
| |
| log(%definitionId, " Creating SUT"); |
| var MBT_Qtronic_Demo_SUT_CT vc_sut := MBT_Qtronic_Demo_SUT_CT.create; |
| connect(self:userIn, vc_sut:userIn); |
| connect(self:userOut, vc_sut:userOut); |
| connect(self:EPTF_MBT_TESTER_PCO,vc_sut:EPTF_MBT_PCO); |
| vc_sut.start(f_MBT_Qtronic_Demo_SUT_behavior()); |
| |
| EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_CommandResponse:?) from vc_sut; |
| |
| EPTF_MBT_TESTER_PCO.send(EPTF_MBT_ConfigRequest: |
| { |
| entityGroupName := "SUT_EntityType", |
| noEntities := 1, |
| behaviors := {"MBT_behavior", "Behavior_SIP", "SUT_Behavior"}, |
| fsmName := "MBT_Qtronic_Demo_SUT_FSM" |
| } |
| ) to vc_sut; |
| EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_ConfigResponse:?) from vc_sut; |
| log(%definitionId, " SUT ready"); |
| |
| log(%definitionId, " Creating LGen"); |
| var MBT_Qtronic_Demo_LGen_CT vc_lgen := MBT_Qtronic_Demo_LGen_CT.create; |
| connect(self:netIn, vc_lgen:netOut); |
| connect(self:netOut, vc_lgen:netIn); |
| connect(self:EPTF_MBT_TESTER_PCO,vc_lgen:EPTF_MBT_PCO); |
| vc_lgen.start(f_MBT_Qtronic_Demo_LGen_behavior()); |
| |
| EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_CommandResponse:?) from vc_lgen; |
| |
| EPTF_MBT_TESTER_PCO.send(EPTF_MBT_ConfigRequest: |
| { |
| entityGroupName := "MBT_EntityType", |
| noEntities := 1, |
| behaviors := {"MBT_behavior", "Behavior_SIP"}, |
| fsmName := "FSM_MBT" |
| } |
| ) to vc_lgen; |
| EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_ConfigResponse:?) from vc_lgen; |
| |
| log(%definitionId, " LGen ready"); |
| |
| log(%definitionId, " finished"); |
| } |
| |
| |
| function f_MBT_Qtronic_Demo_endTestCase() runs on Qtronic_CT |
| { |
| log("### MAIN: END TESTCASE started"); |
| |
| f_EPTF_Base_stopAll(none, true); |
| |
| log("### MAIN: END TESTCASE finished"); |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // |
| // M B T Applib |
| // |
| ///////////////////////////////////////////////////////////////////////// |
| |
| type component MBT_Qtronic_Demo_LGen_CT |
| extends |
| EPTF_MBT_LGen_CT, |
| EPTF_SIP_LGen_CT, EPTF_SIP_LocalTransport_CT |
| { |
| port netInPort netIn; |
| port netOutPort netOut; |
| } |
| |
| function f_MBT_Qtronic_Demo_LGen_behavior() runs on MBT_Qtronic_Demo_LGen_CT |
| { |
| //map(self:IPL4_PCO, system:IPL4_PCO); |
| |
| activate(as_MBT_Qtronic_Demo_LGen_userMessageHandler()); |
| |
| f_EPTF_MBT_init("MBT_Demo_LGen",0, "MBT_") |
| |
| f_SIP_applibInit("MBT_Demo_LGen"); |
| |
| f_EPTF_SIP_LocalTransport_init(tsp_MBT_SIP_Transport); |
| vf_EPTF_SIP_LocalTransport_receive := refers(f_EPTF_SIP_Message_MsgHandler); //receive callback function on LocalTransport |
| vf_EPTF_SIP_LGen_msgSender := refers(f_EPTF_SIP_LocalTransport_sendSIPMessage); //send callback function on LGen |
| v_removeUAS := refers(fcb_EPTF_SIP_LocalTransport_removeUAS); |
| |
| f_EPTF_MBT_initLGenFsm |
| ( |
| refers(f_MBT_Qtronic_Demo_LGen_createUserMessage), |
| refers(f_MBT_Qtronic_Demo_LGen_fillInDB) |
| ); |
| |
| EPTF_MBT_PCO.send(EPTF_MBT_CommandResponse:{ ready := {}}) to mtc; |
| |
| f_EPTF_Base_wait4Shutdown(); |
| } |
| |
| altstep as_MBT_Qtronic_Demo_LGen_userMessageHandler() |
| runs on MBT_Qtronic_Demo_LGen_CT |
| { |
| var SIPResp vl_SIPResp; |
| var SIPReq vl_SIPReq; |
| |
| var EPTF_LGenBase_TestStepArgs vl_stepArgs := |
| { eIdx := 0, refContext := { fCtxIdx := 0, fRefArgs := { } }, stepArgs := { } }; |
| |
| [] netOut.receive(SIPResp:?) -> value vl_SIPResp |
| { |
| f_EPTF_SchedulerComp_refreshSnapshotTime(); |
| log(%definitionId & "(): incoming ", vl_SIPResp); |
| |
| if (vl_SIPResp.status == 180) |
| { |
| vl_stepArgs.refContext.fRefArgs := {c_status_180Ringing_idx}; |
| f_SIP_step_createResponse(vl_stepArgs); |
| } |
| else if (vl_SIPResp.status == 200) |
| { |
| if (vl_SIPResp.cseq == "INVITE") |
| { |
| vl_stepArgs.refContext.fRefArgs := {c_status_200OK_idx, c_SIP_Method_INVITE}; |
| f_SIP_step_createResponse(vl_stepArgs); |
| } |
| else if (vl_SIPResp.cseq == "CANCEL") |
| { |
| vl_stepArgs.refContext.fRefArgs := {c_status_200OK_idx, c_SIP_Method_CANCEL}; |
| f_SIP_step_createResponse(vl_stepArgs); |
| } |
| } |
| else if (vl_SIPResp.status == 486) |
| { |
| vl_stepArgs.refContext.fRefArgs := {c_status_486BusyHere_idx}; |
| f_SIP_step_createResponse(vl_stepArgs); |
| } |
| else if (vl_SIPResp.status == 487) |
| { |
| vl_stepArgs.refContext.fRefArgs := {c_status_487RequestTerminated_idx, c_SIP_Method_INVITE}; |
| f_SIP_step_createResponse(vl_stepArgs); |
| } |
| else |
| { |
| log(%definitionId & "(): unhandled SIPResp"); |
| } |
| |
| repeat; |
| } |
| [] netOut.receive(SIPReq:?) -> value vl_SIPReq |
| { |
| f_EPTF_SchedulerComp_refreshSnapshotTime(); |
| log(%definitionId & "(): incoming ", vl_SIPReq); |
| |
| if (vl_SIPReq.op == "BYE") |
| { |
| f_SIP_step_createBYE(vl_stepArgs); |
| } |
| else |
| { |
| log(%definitionId & "(): unhandled SIPResp"); |
| } |
| repeat; |
| } |
| } |
| |
| function f_MBT_Qtronic_Demo_LGen_createUserMessage(in EPTF_LGenBase_TestStepArgs pl_ptr) |
| runs on MBT_Qtronic_Demo_LGen_CT |
| return boolean |
| { |
| log(%definitionId & " creating message for:\n", pl_ptr, "\n", pl_ptr.reportedEvent); |
| |
| var charstring vl_param := "sip:127.0.0.1:5061"; |
| |
| if (pl_ptr.reportedEvent.event.bIdx == v_SIP_myBIdx and pl_ptr.reportedEvent.event.iIdx == c_SIP_eventIdx_INVITE) |
| { |
| var integer vl_FSMIdx := -1; |
| pl_ptr.refContext.fCtxIdx := 0; |
| |
| if (not f_EPTF_SIP_FSMInitialized(pl_ptr.eIdx, pl_ptr.refContext.fCtxIdx, vl_FSMIdx)) |
| { |
| f_SIP_step_init(pl_ptr); |
| f_SIP_step_handleINVITE(pl_ptr); |
| } |
| netIn.send(SIPReq:{"INVITE", vl_param}); |
| } |
| else if (pl_ptr.reportedEvent.event.bIdx == v_SIP_myBIdx and pl_ptr.reportedEvent.event.iIdx == c_SIP_eventIdx_ACK) |
| { |
| netIn.send(SIPReq:{"ACK", vl_param}); |
| } |
| else if (pl_ptr.reportedEvent.event.bIdx == v_SIP_myBIdx and pl_ptr.reportedEvent.event.iIdx == c_SIP_eventIdx_BYE) |
| { |
| netIn.send(SIPReq:{"BYE", vl_param}); |
| } |
| else if (pl_ptr.reportedEvent.event.bIdx == v_SIP_myBIdx and pl_ptr.reportedEvent.event.iIdx == c_SIP_eventIdx_CANCEL) |
| { |
| netIn.send(SIPReq:{"CANCEL", vl_param}); |
| } |
| else if (pl_ptr.reportedEvent.event.bIdx == v_SIP_myBIdx and pl_ptr.reportedEvent.event.iIdx == 200) |
| { |
| netIn.send(SIPResp:{200, v_msgToProcess.response.msgHeader.cSeq.method}); |
| } |
| else if (pl_ptr.reportedEvent.event.bIdx == v_SIP_myBIdx and pl_ptr.reportedEvent.event.iIdx == c_SIP_eventIdx_retransmittedRequest) |
| { |
| netIn.send(SIPReq:{v_msgToProcess.request.msgHeader.cSeq.method, vl_param}); |
| } |
| else |
| { |
| log(%definitionId & "(): unhandled incoming message"); |
| return false; |
| } |
| return true; |
| } |
| |
| function f_MBT_Qtronic_Demo_LGen_fillInDB(in EPTF_MBT_ConfigRequest p_req) runs on MBT_Qtronic_Demo_LGen_CT |
| { |
| var integer vl_grpIdx := f_EPTF_LGenBase_entityGrpNameIndex(p_req.entityGroupName); |
| var integer vl_entityIdx := f_EPTF_LGenBase_getEGrpBaseOffset(vl_grpIdx); |
| |
| for (var integer i:=0; i<p_req.noEntities; i:=i+1) |
| { |
| var EPTF_IntegerList vl_bCtx := f_EPTF_LGenBase_getBehaviorCtx(i + vl_entityIdx, v_SIP_myBIdx); |
| f_EPTF_SIP_IPL4asp_SetUserData |
| ( |
| vl_bCtx[0], |
| tsp_MBT_Tester_LocalIP, // local IP |
| {tsp_MBT_Tester_LocalPort, tsp_MBT_Tester_LocalPort+1}, |
| tsp_MBT_SIP_Transport, |
| tsp_MBT_Tester_RemoteIP, // proxy ip |
| tsp_MBT_Tester_RemotePort // proxy port |
| ); |
| |
| f_EPTF_SIP_User_SetUserData( |
| vl_bCtx[0], |
| { |
| { |
| addr := { |
| nameAddr := { |
| displayName := "titansim_user_7465000", |
| addrSpec := { |
| scheme := "sip", |
| userInfo := { |
| userOrTelephoneSubscriber := "titansim_user_7465000", |
| password := omit |
| }, |
| hostPort := { |
| host := "tcj.ics.se", |
| portField := tsp_MBT_Tester_LocalPort |
| }, |
| urlParameters := omit, |
| headers := omit |
| } |
| } |
| }, |
| password := "pass2ICS" |
| } |
| }, |
| tsp_MBT_Tester_LocalIP, |
| {tsp_MBT_Tester_LocalPort, tsp_MBT_Tester_LocalPort+1}, |
| i + vl_entityIdx //entity index |
| ); |
| |
| f_EPTF_SIP_Session_AddData(vl_bCtx[0], f_EPTF_SIP_getTransport(tsp_MBT_SIP_Transport),345600); |
| |
| f_EPTF_SIP_IPL4asp_startListening(vl_bCtx[0], true); // Both UDP and TCP |
| } |
| } |
| |
| } |