Commit 576498b5 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Review and clean up of TC_CSE_REG_CRE_007


Signed-off-by: Miguel Angel Reina Ortega's avatarreinaortega <miguelangel.reinaortega@etsi.org>
parent 3b6e230f
......@@ -517,7 +517,32 @@ module OneM2M_Functions {
return v_resourceIndex;
}
/**
* @desc Getting the latest local resource from an CseSimu component
* @param p_component CseSimu component
* @param p_resourceIndex Index of resource to be retrieved
*/
function f_getLatestLocalResource(in CseSimu p_component) runs on Tester return integer {
var MyResource v_resource;
var integer v_resourceIndex := -1;
f_connectInfoPort(p_component);
p_component.start(f_sendLatestLocalResource());
alt {
[]infoPort.receive(mw_resource) -> value v_resource {
v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);//TODO To set correctly parentIndex
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Getting last local resourceIndex saved in the vc_localResourcesList
* @param p_tester Given component
......@@ -655,7 +680,17 @@ module OneM2M_Functions {
infoPort.send(lengthof(vc_resourcesList)-1);
}
/**
* @desc Sending of the latest local resource through InfoPort
*/
function f_sendLatestLocalResource() runs on CseSimu {
infoPort.send(vc_localResourcesList[lengthof(vc_localResourcesList)-1]);
}
/**
* @desc Sending the address of the last resource saved in the vc_resourcesList
*/
......@@ -1994,43 +2029,40 @@ module OneM2M_Functions {
* @verdict
*/
//TODO TO BE FINALIZED
function f_cse_announcementProcedure_updateHandler() runs on CseSimu {
function f_cse_announcementProcedure_updateHandler(template RequestPrimitive p_requestprimitive := mw_update, in ResponseStatusCode p_responseStatusCode := int2004, template(omit) integer p_expectedResourceIndex := omit) runs on CseSimu {
// Local variables
var MsgIn v_request;
var integer v_parentIndex := vc_localRemoteCseIndex;
var integer v_announcedResourceIndex;
var ResponsePrimitive v_responsePrimitive;
var template Notification v_notificationRequest := mw_contentNotification_any;
var PrimitiveContent v_announcedResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
//Preparation of Notification response to be sent
v_responsePrimitive := valueof(m_responseNotification(int2004, omit));
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(mw_notifyNotification(v_notificationRequest))) -> value vc_request {
[] mccPortIn.receive(mw_request(p_requestprimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Notification received");
setverdict(pass, __SCOPE__ & ":INFO: Expected UPDATE Announcement received");
f_processUpdateRequestPrimitive(v_request.primitive.requestPrimitive);
mccPortIn.send(f_getMsgOutPrimitive(m_response(vc_response.primitive.responsePrimitive)));
}
[] mccPortIn.receive{
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
stop;
[] mccPortIn.receive(mw_request(?)) -> value v_request {
setverdict(fail, __SCOPE__ & ":ERROR: Request received with unexpected parameters");
v_responsePrimitive := valueof(m_responsePrimitive(int4000,v_request.primitive.requestPrimitive.requestIdentifier));
mccPortIn.send(f_getMsgOutPrimitive(m_response(v_responsePrimitive)));
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
stop;
setverdict(fail, __SCOPE__ & ":ERROR: No announcement received");
}
}
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
if(getverdict == pass) {
mccPortIn.send(f_getMsgOutPrimitive(m_httpResponse(v_responsePrimitive)));
} else {
v_responsePrimitive.responseStatusCode := int4000;
mccPortIn.send(f_getMsgOutPrimitive(m_httpResponse(v_responsePrimitive)));
}
f_checkCseSimuStatus();
} //end f_cse_notifyProcedure_updateHandler
} //end f_cse_announcementProcedure_updateHandler
/**
* @desc Handling of announcement of resources
......@@ -2039,42 +2071,37 @@ module OneM2M_Functions {
* @verdict
*/
//TODO To finalize this function
function f_cse_announcementProcedure_deleteHandler() runs on CseSimu {
function f_cse_announcementProcedure_deleteHandler(template RequestPrimitive p_requestprimitive := mw_delete, in ResponseStatusCode p_responseStatusCode := int2002, template(omit) integer p_expectedResourceIndex := omit) runs on CseSimu {
// Local variables
var MsgIn v_request;
var integer v_parentIndex := vc_localRemoteCseIndex;
var integer v_announcedResourceIndex;
var ResponsePrimitive v_responsePrimitive;
var template Notification v_notificationRequest := mw_contentNotification_any;
var PrimitiveContent v_announcedResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
//Preparation of Notification response to be sent
v_responsePrimitive := valueof(m_responseNotification(int2002, omit));
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(mw_notifyNotification(v_notificationRequest))) -> value vc_request {
[] mccPortIn.receive(mw_request(p_requestprimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Notification received");
//TODO Delete the resource of the local list
setverdict(pass, __SCOPE__ & ":INFO: Expected DELETE Announcement received");
f_processDeleteRequestPrimitive(v_request.primitive.requestPrimitive);
mccPortIn.send(f_getMsgOutPrimitive(m_response(vc_response.primitive.responsePrimitive)));
}
[] mccPortIn.receive{
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
stop;
[] mccPortIn.receive(mw_request(?)) -> value v_request {
setverdict(fail, __SCOPE__ & ":ERROR: Request received with unexpected parameters");
v_responsePrimitive := valueof(m_responsePrimitive(int4000,v_request.primitive.requestPrimitive.requestIdentifier));
mccPortIn.send(f_getMsgOutPrimitive(m_response(v_responsePrimitive)));
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
stop;
setverdict(fail, __SCOPE__ & ":ERROR: No announcement received");
}
}
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
if(getverdict == pass) {
mccPortIn.send(m_httpResponse(v_responsePrimitive));
} else {
v_responsePrimitive.responseStatusCode := int4000;
mccPortIn.send(m_httpResponse(v_responsePrimitive));
}
f_checkCseSimuStatus();
} //end f_cse_announcementProcedure_deleteHandler
......@@ -2623,10 +2650,21 @@ module OneM2M_Functions {
v_myResource.aEAnnc.resourceName := "aEAnnc" & int2str(v_resourceIndex);
}
v_myResource.aEAnnc.resourceType := p_resourceType;
v_myResource.aEAnnc.resourceID := "aeA" & int2str(v_resourceIndex);
v_myResource.aEAnnc.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.aEAnnc.creationTime := fx_generateTimestamp();
v_myResource.aEAnnc.lastModifiedTime := v_myResource.aEAnnc.creationTime;
if(v_myResource.aEAnnc.link[lengthof(v_myResource.aEAnnc.link)-1] == "S"){
v_myResource.aEAnnc.resourceID := "SaeA" & int2str(v_resourceIndex);
v_myResource.aEAnnc.aE_ID := v_myResource.aEAnnc.resourceID;
v_myResource.aEAnnc.link := substr(v_myResource.aEAnnc.link, 0, lengthof(v_myResource.aEAnnc.link)-1) & v_myResource.aEAnnc.resourceID;
} else {
v_myResource.aEAnnc.aE_ID := f_resourceIdCleaner(v_myResource.aEAnnc.link);
}
//TODO To be removed once link is fixed
v_myResource.aEAnnc.resourceID := "SaeA" & int2str(v_resourceIndex);
v_myResource.aEAnnc.link := substr(v_myResource.aEAnnc.link, 0, 11) & v_myResource.aEAnnc.resourceID;
}
} else if (p_resourceType == int10001 and ispresent (p_resource)) { //Acp Annc
if(ischosen(p_resource.accessControlPolicyAnnc)) {
......@@ -3862,15 +3900,15 @@ module OneM2M_Functions {
p_request.requestIdentifier := valueof(p_request.requestIdentifier) & f_rnd(1, 1000000);
if(p_resourceType != int10002) {
p_request.from_ := f_getOriginator(p_resourceIndex);
p_request.from_ := f_getOriginator(p_resourceIndex);
if(p_resourceType != int10002) {
//Only set To parameter if it has not been set yet
if(valueof(p_request.to_) == "NotInitialized") {
p_request.to_ := f_getResourceAddress(p_resourceIndex);
}
} else {
p_request.from_ := PX_CSE1_ID & "/" & f_getResourceId(vc_resourcesList[p_resourceIndex].resource);
//p_request.from_ := PX_CSE1_ID & "/" & f_getResourceId(vc_resourcesList[p_resourceIndex].resource);
p_request.to_ := f_getResourceAddress(p_resourceIndex, -, e_spRelative);
}
......@@ -4235,7 +4273,7 @@ module OneM2M_Functions {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else if (p_addressingMethod == e_hybrid){
} else {
if(p_targetResourceIndex == -1) {
return PX_CSE_RESOURCE_ID;
} else {
......@@ -4259,7 +4297,7 @@ module OneM2M_Functions {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else if (p_addressingMethod == e_hybrid){
} else {
if(p_targetResourceIndex == -1) {
return PX_CSE_ID & "/" & PX_CSE_RESOURCE_ID;
} else {
......@@ -4282,7 +4320,7 @@ module OneM2M_Functions {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else if (p_addressingMethod == e_hybrid){
} else {
if(p_targetResourceIndex == -1) {
return PX_SP_ID & PX_CSE_ID & "/" & PX_CSE_RESOURCE_ID;
} else {
......
......@@ -822,8 +822,11 @@ module OneM2M_Testcases_CSE_Release_1 {
function f_CSE_REG_CRE_007() runs on AeSimu {
var MsgIn v_response;
var RequestPrimitive v_request;
var template RequestPrimitive v_requestPrimitive;
var integer v_aeIndex := -1;
var integer v_aeAnncIndex := -1;
const charstring v_cseId := PX_CSE_ID;
template XSD.AnyURI v_link := pattern "{v_cseId}/?*";
//Test control
if(not(PICS_MN_CSE)) {
......@@ -832,39 +835,43 @@ module OneM2M_Testcases_CSE_Release_1 {
}
// Test component configuration
f_cf02Up();
f_cf02Up(int1);
//Preamble
vc_cse1.start(f_cse_registrationRemoteCse(mw_createRemoteCSE));
vc_cse1.done;
mcaPort.send(f_getMsgOutPrimitive(m_request(f_getCreateRequestPrimitive(int2, m_createAe(PX_APP_ID, omit, "S"),-1))));
v_requestPrimitive := mw_createAEAnnc_s_ae_id(PX_CSE_ID & "/S", -, -, v_link);
vc_cse1.start(f_cse_announcementProcedure_createHandler());
vc_cse1.done;
vc_cse1.start(f_cse_announcementProcedure_createHandler(v_requestPrimitive));
mcaPort.send(f_getMsgOutPrimitive(m_request(f_getCreateRequestPrimitive(int2, m_createAe(PX_APP_ID, omit, "S"),-1))));
//Test Body
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int2001))) -> value v_response {
tc_ac.stop;
//continue to test the content
if (ischosen(v_response.primitive.responsePrimitive.primitiveContent.aE)){
if (v_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID == PX_APP_ID){
setverdict(pass, __SCOPE__ & ": AE creation success.");
}else{
setverdict(fail, __SCOPE__ & ": Error in AE content.");
}
}else{
setverdict(fail, __SCOPE__ & ": primitiveContent doesn't exist");
}
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while creating AE");
}
}
vc_cse1.done;
v_aeAnncIndex := f_getLatestLocalResource(vc_cse1);
//continue to test the content
if (ischosen(v_response.primitive.responsePrimitive.primitiveContent.aE)){
if (v_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID == vc_resourcesList[v_aeAnncIndex].resource.aEAnnc.aE_ID){
setverdict(pass, __SCOPE__ & ": AE-ID correctly set to AE-ID provided by IN-CSE");
}else{
setverdict(fail, __SCOPE__ & ": AE-ID not set correctly");
}
}else{
setverdict(fail, __SCOPE__ & ": primitiveContent doesn't exist");
}
// Postamble
f_cse_postamble_deleteResources();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment