diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn index 02c3ea807a135b54c8b673785fa7e357747114da..08f0403185831daf122193664eaf23e4d18f1717 100644 --- a/LibOneM2M/OneM2M_Functions.ttcn +++ b/LibOneM2M/OneM2M_Functions.ttcn @@ -783,7 +783,11 @@ module OneM2M_Functions { for(i := lengthof(vc_resourcesIndexToBeDeleted) -1; i >=0; i := i - 1) { - v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i]); + if(ischosen(vc_resourcesList[vc_resourcesIndexToBeDeleted[i]].resource.remoteCSE)) { + v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i], e_nonHierarchical, e_spRelative); + } else { + v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i]); + } v_request := valueof(m_delete(v_resourceAddress, f_getOriginator(vc_resourcesIndexToBeDeleted[i],false))); @@ -1843,7 +1847,8 @@ module OneM2M_Functions { v_response.primitiveContent.remoteCSE := vc_localResourcesList[vc_localRemoteCseIndex].resource.remoteCSE; mccPortIn.send(m_response(v_response)); - v_resourceIndex := f_setResource(valueof(m_primitiveContentRemoteCSE(m_contentMyRemoteCSEResource)), int16, -1); + vc_remoteCseIndex := f_setResource(valueof(m_primitiveContentRemoteCSE(m_contentMyRemoteCSEResource)), int16, -1); + v_resourceIndex := vc_remoteCseIndex; v_remoteCSERegistered:=true; tc_ac.start; repeat; @@ -1913,7 +1918,7 @@ module OneM2M_Functions { if(p_resourceType == int5) { //CSEBase v_myResource.cSEBase.resourceName := PX_CSE1_NAME; v_myResource.cSEBase.resourceType := p_resourceType; - v_myResource.cSEBase.resourceID := PX_CSE1_ID; + v_myResource.cSEBase.resourceID := f_resourceIdCleaner(PX_CSE1_ID); v_myResource.cSEBase.parentID := omit; //Following TS-0001, it must be NULL v_myResource.cSEBase.creationTime := fx_generateTimestamp(); v_myResource.cSEBase.creationTime := "20171231T012345"; @@ -2013,6 +2018,106 @@ module OneM2M_Functions { return v_myResource; }//End of function + + /** + * @desc Update of a local resource (Test System simulating a CSE) + * @param p_localResourceIndex Resource index of resource to be updated + * @param p_resource Resource update + */ + function f_cse_updateLocalResource(in integer p_localResourceIndex, in PrimitiveContent p_resource) runs on CseSimu { + + // TODO To review the code (use of indexes, generation of value for certain attributes, etc..) + if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.remoteCSE) and ischosen(p_resource.remoteCSE)) {//RemoteCSE + + if(ispresent(p_resource.remoteCSE.accessControlPolicyIDs)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.accessControlPolicyIDs := p_resource.remoteCSE.accessControlPolicyIDs; + } + if(ispresent(p_resource.remoteCSE.expirationTime)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.expirationTime := p_resource.remoteCSE.expirationTime; + } + if(ispresent(p_resource.remoteCSE.labels)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.labels := p_resource.remoteCSE.labels; + } + if(ispresent(p_resource.remoteCSE.announceTo)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.announceTo := p_resource.remoteCSE.announceTo; + } + if(ispresent(p_resource.remoteCSE.announcedAttribute)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.announcedAttribute := p_resource.remoteCSE.announcedAttribute; + } + if(ispresent(p_resource.remoteCSE.pointOfAccess)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.pointOfAccess := p_resource.remoteCSE.pointOfAccess; + } + if(ispresent(p_resource.remoteCSE.m2M_Ext_ID)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.m2M_Ext_ID := p_resource.remoteCSE.m2M_Ext_ID; + } + if(ispresent(p_resource.remoteCSE.trigger_Recipient_ID)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.trigger_Recipient_ID := p_resource.remoteCSE.trigger_Recipient_ID; + } + if(ispresent(p_resource.remoteCSE.requestReachability)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.requestReachability := p_resource.remoteCSE.requestReachability; + } + if(ispresent(p_resource.remoteCSE.nodeLink)) { + vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.nodeLink := p_resource.remoteCSE.nodeLink; + } + + } else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.container) and (ischosen(p_resource.container))) {//Container + } + + }//End of function + + /** + * @desc Send response to the IUT (Test System simulating a CSE) + * @param p_requestPrimtive Received request primitive + */ + function f_cse_sendResponse(in MsgIn p_requestPrimitive) runs on CseSimu { + + var integer v_parentResourceIndex := -1; + var integer v_localResourceIndex := -1; + var ResponsePrimitive v_response; + var PrimitiveContent v_localResource; + + v_parentResourceIndex := f_getResourceIndex(p_requestPrimitive.primitive.requestPrimitive.to_); + if(v_parentResourceIndex == -1) { + log(__SCOPE__&": ERROR: Target resource not found"); + v_response := valueof(m_responsePrimitive(int4004,p_requestPrimitive.primitive.requestPrimitive.requestIdentifier)); + + } else { + v_localResource := f_cse_generateLocalResource(p_requestPrimitive.primitive.requestPrimitive.primitiveContent, v_parentResourceIndex, p_requestPrimitive.primitive.requestPrimitive.resourceType); + v_localResourceIndex := f_setLocalResource(v_localResource, p_requestPrimitive.primitive.requestPrimitive.resourceType, v_parentResourceIndex); + + v_response := valueof(m_responsePrimitive(int2001,p_requestPrimitive.primitive.requestPrimitive.requestIdentifier)); + v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource; + } + v_response.from_ := PX_CSE1_ID; + v_response.to_ := p_requestPrimitive.primitive.requestPrimitive.from_; + mccPortIn.send(m_response(v_response)); + + } + + /** + * @desc Receive response from the IUT + * @param p_requestPrimtive Received request primitive + */ + function f_cse_receiveResponse() runs on AeSimu { + + var integer v_localResourceIndex := -1; + + tc_ac.start; + alt { + [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response { + tc_ac.stop; + setverdict(pass, __SCOPE__&":INFO: Response received with positive response status code"); + } + [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response { + tc_ac.stop; + setverdict(pass, __SCOPE__&":INFO: Response received with negative response status code"); + } + [] tc_ac.timeout { + setverdict(inconc, __SCOPE__&":INFO: No response received"); + } + } + + } }//end group CseSimuFunctions @@ -2045,11 +2150,10 @@ module OneM2M_Functions { altstep a_cse_cf02_cse1() runs on CseSimu { var PrimitiveContent v_localResource; - var integer vc_localResourceIndex := -1; + var integer v_localResourceIndex := -1; var integer v_parentResourceIndex := -1; var MsgIn v_request; var ResponsePrimitive v_response; - var integer v_localResourceIndex := -1; [] mccPortIn.receive(mw_request(mw_create())) -> value v_request { log(__SCOPE__&": WARNING: Unexpected CREATE message received"); @@ -2061,16 +2165,16 @@ module OneM2M_Functions { v_response := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier)); } else { - v_localResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, vc_cSEBaseIndex, v_request.primitive.requestPrimitive.resourceType);//TODO Get index from v_request.primitive.requestPrimitive.to_ - vc_localResourceIndex := f_setLocalResource(v_localResource, v_request.primitive.requestPrimitive.resourceType, vc_cSEBaseIndex); + v_localResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentResourceIndex, v_request.primitive.requestPrimitive.resourceType); + v_localResourceIndex := f_setLocalResource(v_localResource, v_request.primitive.requestPrimitive.resourceType, v_parentResourceIndex); v_response := valueof(m_responsePrimitive(int2001,v_request.primitive.requestPrimitive.requestIdentifier)); - v_response.primitiveContent := vc_localResourcesList[vc_localResourceIndex].resource; + v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource; } v_response.from_ := PX_CSE1_ID; v_response.to_ := v_request.primitive.requestPrimitive.from_; mccPortIn.send(m_response(v_response)); - tc_ac.start(5.0); + tc_ac.start(10.0); repeat; } [] mccPortIn.receive(mw_request(mw_retrieve(?))) -> value v_request { @@ -2092,7 +2196,7 @@ module OneM2M_Functions { v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource; mccPortIn.send(m_response(v_response)); } - tc_ac.start(5.0); + tc_ac.start(10.0); repeat; } [] mccPortIn.receive(mw_request(mw_update())) -> value v_request { @@ -2111,10 +2215,11 @@ module OneM2M_Functions { v_response := valueof(m_responsePrimitive(int2004,v_request.primitive.requestPrimitive.requestIdentifier)); v_response.from_ := PX_CSE1_ID; v_response.to_ := v_request.primitive.requestPrimitive.from_; + f_cse_updateLocalResource(v_localResourceIndex, v_request.primitive.requestPrimitive.primitiveContent); v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource; mccPortIn.send(m_response(v_response)); } - tc_ac.start(5.0); + tc_ac.start(10.0); repeat; } [] mccPortIn.receive (mw_request(?)){ diff --git a/LibOneM2M/OneM2M_Templates.ttcn b/LibOneM2M/OneM2M_Templates.ttcn index 3970aef52096d9277fe148bd3e51c48e70d5f3c1..657f524965939d59a1fd507ee1febe7a064306ce 100644 --- a/LibOneM2M/OneM2M_Templates.ttcn +++ b/LibOneM2M/OneM2M_Templates.ttcn @@ -2866,7 +2866,7 @@ module OneM2M_Templates { resourceType := int16,//M resourceID := PX_CSE1_RESOURCE_ID,//M pointOfAccess := {PX_CSE1_ADDRESS},//O - cSEBase := PX_CSE1_NAME,//M + cSEBase := PX_CSE1_ID & "/" & PX_CSE1_NAME,//M cSE_ID := PX_CSE1_ID,//M requestReachability := true//M }; diff --git a/OneM2M_Testcases_CSE_Release_1.ttcn b/OneM2M_Testcases_CSE_Release_1.ttcn index 4e169f47fdd2880930d86101844ff1c2f20b1a8e..fc1bff43ce58416ea9b0df22eb8b1de75aa628ec 100644 --- a/OneM2M_Testcases_CSE_Release_1.ttcn +++ b/OneM2M_Testcases_CSE_Release_1.ttcn @@ -562,9 +562,11 @@ module OneM2M_Testcases_CSE_Release_1 { */ testcase TC_CSE_REG_CRE_005() runs on InCseSimu system CseSystem { - var template RequestPrimitive v_request; + var MsgIn v_request; + var template RequestPrimitive v_requestPrimitive; var integer v_cseBaseIndex := -1; var ResourceType v_resourceType := int2; + var boolean v_handleResponses := false; //Test control @@ -578,32 +580,37 @@ module OneM2M_Testcases_CSE_Release_1 { vc_ae1.start(f_cse_sendCreateRequestPrimitive(int2, m_createAe(PX_APP_ID, -, "S", omit))); vc_ae1.done; - v_request := mw_createAEAnnc(PX_CSE_ID & "/S", -, -, -); - v_request.primitiveContent.aEAnnc.app_ID := PX_APP_ID; + v_requestPrimitive := mw_createAEAnnc(PX_CSE_ID & "/S", -, -, -); + v_requestPrimitive.primitiveContent.aEAnnc.app_ID := PX_APP_ID; tc_ac.start; alt{ - [] mccPortIn.receive(mw_request(v_request)){ + [] mccPortIn.receive(mw_request(v_requestPrimitive)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__ & ": AE creation redirected."); + v_handleResponses := true; } - [] mccPortIn.receive(mw_request(mw_createAEAnnc())){ + [] mccPortIn.receive(mw_request(mw_createAEAnnc())) -> value v_request { tc_ac.stop; setverdict(fail, __SCOPE__ & ": AE creation redirected but wrong parameters"); + v_handleResponses := true; } - [] mccPortIn.receive(mw_request(?)){ + [] mccPortIn.receive(mw_request(?))-> value v_request { tc_ac.stop; setverdict(fail, __SCOPE__ & ": Unexpected message received"); + v_handleResponses := true; } [] tc_ac.timeout { setverdict(fail, __SCOPE__ & ": No answer while creating AE"); } } - - /*vc_cse1.start(f_cse_receiveCreateRequest(mw_createAEAnnc(-, -, -))); - vc_cse1.done;*/ - + // Postamble + if (v_handleResponses) { + vc_ae1.start(f_cse_receiveResponse()); + f_cse_sendResponse(v_request); + vc_ae1.done; + } f_cse_postamble_deleteResourcesCSE(); // Tear down