Registration functions.

Fixes in Registration delete group
Signed-off-by: Antonio Castillo Verdugo's avataracverdugo <acverdugo@at4wireless.com>
parent 9c92c56e
......@@ -1465,6 +1465,8 @@ module OneM2M_Functions {
var MsgIn v_response;
var RequestPrimitive v_request;
var integer v_resourceIndex := -1;
var integer v_localResourceIndex := -1;
var PrimitiveContent v_remoteCSEResource;
v_request := f_getCreateRequestPrimitive(int16, p_requestPrimitive, -1);
......@@ -1476,6 +1478,8 @@ module OneM2M_Functions {
setverdict(pass, __SCOPE__&":INFO: Resource type RemoteCSE created successfuly");
f_checkAttributesToBeSaved(int16, v_request, v_response.primitive.responsePrimitive);
v_resourceIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int16, -1);
v_remoteCSEResource := f_cse_generateLocalResource(v_response.primitive.responsePrimitive.primitiveContent, 1, int16);
v_localResourceIndex := f_setLocalResource(v_remoteCSEResource, int16, -1);
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
......@@ -1506,6 +1510,7 @@ module OneM2M_Functions {
var MsgIn v_request;
var ResponsePrimitive v_response;
var PrimitiveContent v_remoteCSEResource;
var integer v_localResourceIndex := -1;
var integer v_resourceIndex := -1;
tc_ac.start;
......@@ -1513,7 +1518,11 @@ module OneM2M_Functions {
[] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type RemoteCSE created successfuly");
v_resourceIndex := f_cse_createLocalResource(v_request.primitive.requestPrimitive.primitiveContent, 1, int16, v_remoteCSEResource);//TODO Get index from v_request.primitive.requestPrimitive.to_
v_remoteCSEResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, 1, int16);//TODO Get index from v_request.primitive.requestPrimitive.to_
v_localResourceIndex := f_setLocalResource(v_remoteCSEResource, int16, -1);
v_resourceIndex := f_setResource(v_request.primitive.responsePrimitive.primitiveContent, int16, -1);
}
[] mccPortIn.receive {
tc_ac.stop;
......@@ -1584,44 +1593,43 @@ module OneM2M_Functions {
* @param p_modifiedResource Assigned and/or modified fields
* @return Internal resource index of the saved resource or -1
*/
function f_cse_createLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType, out PrimitiveContent p_myResource) runs on CseSimu return integer {
function f_cse_generateLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return PrimitiveContent {
var integer v_resourceIndex := lengthof(vc_resourcesList);
var integer v_resourceIndex := lengthof(vc_localResourcesList);
var PrimitiveContent v_myResource;
// TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
if(p_resourceType == int16 and ispresent(p_resource)) {
if(ischosen(p_resource.remoteCSE)){
p_myResource.remoteCSE := p_resource.remoteCSE;
v_myResource.remoteCSE := p_resource.remoteCSE;
if(not(ispresent(p_resource.remoteCSE.resourceName))) {
p_myResource.remoteCSE.resourceName := "remoteCSE" & int2char(v_resourceIndex);
v_myResource.remoteCSE.resourceName := "remoteCSE" & int2char(v_resourceIndex);
}
p_myResource.remoteCSE.resourceType := p_resourceType;
p_myResource.remoteCSE.resourceID := "remoteCSE" & int2char(v_resourceIndex);
p_myResource.remoteCSE.parentID := f_getResourceId(vc_resourcesList[p_parentIndex].resource);
p_myResource.remoteCSE.creationTime := fx_generateTimestamp();
v_myResource.remoteCSE.resourceType := p_resourceType;
v_myResource.remoteCSE.resourceID := "remoteCSE" & int2char(v_resourceIndex);
v_myResource.remoteCSE.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.remoteCSE.creationTime := fx_generateTimestamp();
if(not(ispresent(p_resource.remoteCSE.expirationTime))) {
p_myResource.remoteCSE.expirationTime := "20301231T012345";
v_myResource.remoteCSE.expirationTime := "20301231T012345";
}
p_myResource.remoteCSE.lastModifiedTime := p_myResource.remoteCSE. creationTime;
p_myResource.remoteCSE.announceTo := omit;
p_myResource.remoteCSE.announcedAttribute := omit;
v_myResource.remoteCSE.lastModifiedTime := v_myResource.remoteCSE. creationTime;
v_myResource.remoteCSE.announceTo := omit;
v_myResource.remoteCSE.announcedAttribute := omit;
if(not(ispresent(p_resource.remoteCSE.pointOfAccess))) {
//TODO Create a pollingChannel resource
p_myResource.remoteCSE.pointOfAccess := omit;
v_myResource.remoteCSE.pointOfAccess := omit;
}
if(vc_resourcesList[v_resourceIndex].resourceType == int5) {
p_myResource.remoteCSE.m2M_Ext_ID := omit;
p_myResource.remoteCSE.trigger_Recipient_ID:= omit;
if(vc_localResourcesList[v_resourceIndex].resourceType == int5) {
v_myResource.remoteCSE.m2M_Ext_ID := omit;
v_myResource.remoteCSE.trigger_Recipient_ID:= omit;
}
p_myResource.remoteCSE.nodeLink := omit;
return f_setResource(p_myResource, p_resourceType, p_parentIndex, false);
v_myResource.remoteCSE.nodeLink := omit;
}
}
return v_resourceIndex;
return v_myResource;
}//End of function
......@@ -2364,6 +2372,27 @@ module OneM2M_Functions {
}
/**
* @desc Saving of a local resource and its parent index in the internal resource list
* @param p_resource Resource to be saved
* @param p_parentIndex Parent index of resource to be saved
* @return Internal resource index of the saved resource
* @verdict
*/
function f_setLocalResource(PrimitiveContent p_resource, ResourceType p_resourceType, integer p_parentIndex := -1) runs on CseSimu return integer {
var integer v_newIndex := -1;
if(isbound(vc_localResourcesList)) {
vc_localResourcesList[lengthof(vc_localResourcesList)] := {p_parentIndex, p_resourceType, p_resource};
} else {
vc_localResourcesList[0] := {p_parentIndex, p_resourceType, p_resource};
}
v_newIndex := lengthof(vc_localResourcesList)-1;
return v_newIndex;
}
/**
* @desc Set Acpid into the requestPrimitive
* @param p_requestPrimitive RequestPrimitive to be modified
......
......@@ -62,6 +62,7 @@ module OneM2M_TestSystem {
port OneM2MPort mccPortIn;
//global variables
var MyResourcesList vc_localResourcesList;
var AeSimu vc_aeSimu;//For CF02 when CseSimu is master
var integer vc_remoteCseIndex;
var MsgIn vc_request;
......
......@@ -1764,16 +1764,31 @@ module OneM2M_Testcases_CSE {
}
/*testcase TC_CSE_REG_CRE_034_RN() runs on Tester system CseSystem {
//Local variables
var RequestPrimitive v_request;
var PrimitiveContent v_contentResponse;
p_request := valueof(m_createRemoteCSEBase);
p_request.primitiveContent.remoteCSE.cseType := int2; //MN_CSE
p_request.primitiveContent.remoteCSE.resourceName := c_defaultRemoteCSEResourceName;
p_contentResponse.remoteCSE := mw_contentRemoteCSEBase;
p_contentResponse.remoteCSE.cseType := int2; //MN_CSE
p_contentResponse.remoteCSE.resourceName := c_defaultRemoteCSEResourceName;
f_CSE_REG_CRE_034(p_request, p_contentResponse);
}*/
/**
* @desc Check that IUT accepts a CSE registration request with OPTIONAL_ATTRIBUTE attribute
*
*/
/*testcase TC_CSE_REG_CRE_034() runs on CseSimu system CseSystem {
function f_CSE_REG_CRE_034(RequestPrimitive p_request, PrimitiveContent p_contentResponse) runs on CseSimu{ //system CseSystem {
//Local variables
var MsgIn v_response;
var RequestPrimitive v_request;
var ResourceType v_resourceType := int16; //remoteCSE
var template PrimitiveContent v_contentResponse;
// Test control
// Test component configuration
......@@ -1782,35 +1797,10 @@ module OneM2M_Testcases_CSE {
// Test adapter configuration
// Preamble
v_request := valueof(m_createRemoteCSEBase);
v_request.primitiveContent.remoteCSE.cseType := int2; //MN_CSE
v_request.primitiveContent.remoteCSE.resourceName := c_defaultRemoteCSEResourceName;
vc_remoteCseIndex := f_cse_registerRemoteCse(v_request);
v_contentResponse.container := mw_contentRemoteCSEBase;
// Test Body
v_request := valueof(m_delete(f_getResourceAddress(vc_remoteCseIndex), f_getOriginator(-1, false)));
mccPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitive(int2002))) {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Deletion of <remoteCSE> resource has been accepted");
}
[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Wrong response status code in the response");
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Error while deleting <remoteCSE> resource");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while deleting resource");
}
}
//Test Body
vc_remoteCseIndex := f_cse_registerRemoteCse(p_request, p_contentResponse);
// Postamble
f_cse_postamble_deleteResourcesCSE();
......@@ -1818,7 +1808,7 @@ module OneM2M_Testcases_CSE {
// Tear down
f_cf04Down();
}//end TC_CSE_REG_CRE_034*/
}//end TC_CSE_REG_CRE_034
} //end group Create
......@@ -1900,7 +1890,7 @@ module OneM2M_Testcases_CSE {
var template PrimitiveContent v_contentResponse;
v_contentResponse.cSEBase := mw_contentCSEBase_rc1;
v_contentResponse.cSEBase.nodeLink := ?;
v_ae1.start(f_CSE_REG_RET_002(v_contentResponse));
v_ae1.done;
}
......@@ -2154,7 +2144,7 @@ module OneM2M_Testcases_CSE {
// Test Body
v_contentResponse.cSEBase := mw_contentCSEBase_rc1;
v_contentResponse.cSEBase.cseType := int1;
mcaPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(v_aeIndex))));//TODO Maybe PX_SUPER_AE_ID
tc_ac.start;
......@@ -2883,14 +2873,12 @@ module OneM2M_Testcases_CSE {
}//end TC_CSE_REG_DEL_001
/**
* @desc Check that the IUT accepts an delete request of <remoteCSE> resource.
* @desc Check that IUT accepts a <remoteCSE> delete request on TARGET_REMOTE_CSE_ADDRESS, and deletes the <remoteCSE> resource
*
*/
testcase TC_CSE_REG_DEL_002() runs on CseSimu system CseSystem {
//Local variables
var MsgIn v_response;
//Local variables
var RequestPrimitive v_request;
var ResourceType v_resourceType := int16; //remoteCSE
// Test control
// Test component configuration
......@@ -2899,10 +2887,10 @@ module OneM2M_Testcases_CSE {
// Test adapter configuration
// Preamble
vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
vc_remoteCseIndex := f_cse_registrationRemoteCse(mw_createRemoteCSEBase);
// Test Body
v_request := valueof(m_delete(f_getResourceAddress(vc_remoteCseIndex), f_getOriginator(-1, false)));
v_request := valueof(m_delete(f_getResourceAddress(vc_remoteCseIndex), f_getOriginator(vc_remoteCseIndex)));
mccPort.send(m_request(v_request));
tc_ac.start;
......@@ -2922,6 +2910,13 @@ module OneM2M_Testcases_CSE {
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while deleting resource");
}
}
// Check if the resource has been deleted or not
if(f_cse_isResourcePresent(vc_remoteCseIndex)) {
setverdict(fail, __SCOPE__ & ":INFO: Resource not deleted");
} else {
setverdict(pass, __SCOPE__ & ":INFO: Resource deleted");
}
// Postamble
......@@ -2952,7 +2947,7 @@ module OneM2M_Testcases_CSE {
v_aeIndex := f_cse_preamble_registerAe();//c_CRUDNDi);
// Test Body
v_request := valueof(m_delete(f_getResourceAddress(v_aeIndex), f_getOriginator()));
v_request := valueof(m_delete(f_getResourceAddress(v_aeIndex), f_getOriginator(v_aeIndex)));
mcaPort.send(m_request(v_request));
tc_ac.start;
......@@ -3021,61 +3016,6 @@ module OneM2M_Testcases_CSE {
f_cf04Down();
}//end TC_CSE_REG_DEL_004
/**
* @desc Check that IUT accepts a <remoteCSE> delete request on TARGET_REMOTE_CSE_ADDRESS, and deletes the <remoteCSE> resource
*
*/
testcase TC_CSE_REG_DEL_005() runs on CseSimu system CseSystem {
//Local variables
var RequestPrimitive v_request;
// Test control
// Test component configuration
f_cf04Up();
// Test adapter configuration
// Preamble
vc_remoteCseIndex := f_cse_registrationRemoteCse(mw_createRemoteCSEBase);
// Test Body
v_request := valueof(m_delete(f_getResourceAddress(vc_remoteCseIndex), f_getOriginator(-1, false)));
mccPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitive(int2002))) {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Deletion of <remoteCSE> resource has been accepted");
}
[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Wrong response status code in the response");
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Error while deleting <remoteCSE> resource");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while deleting resource");
}
}
// Check if the resource has been deleted or not
if(f_cse_isResourcePresent(vc_remoteCseIndex)) {
setverdict(fail, __SCOPE__ & ":INFO: Resource not deleted");
} else {
setverdict(pass, __SCOPE__ & ":INFO: Resource deleted");
}
// Postamble
f_cse_postamble_deleteResourcesCSE();
// Tear down
f_cf04Down();
}//end TC_CSE_REG_DEL_005
}// end group Delete
......
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