Skip to content
Snippets Groups Projects
Commit ac50b288 authored by Siddharth Trika's avatar Siddharth Trika
Browse files

New Testcases implemented for Semantics.

parent d0ee2f1e
No related branches found
No related tags found
1 merge request!63Merge Release4-onwards into Release4
...@@ -14616,6 +14616,222 @@ module OneM2M_Testcases_CSE_Release_3 { ...@@ -14616,6 +14616,222 @@ module OneM2M_Testcases_CSE_Release_3 {
f_cf01Down(); f_cf01Down();
}//end function f_CSE_SEM_CRE_016 }//end function f_CSE_SEM_CRE_016
/**
* @desc Check that the IUT rejects the creation request of a <semanticDescriptor> resource
* in which descriptorRepresentation attribute is set to "IRI".
*/
testcase TC_CSE_SEM_CRE_017() runs on Tester system CseSystem {
var AeSimu v_ae1 := AeSimu.create("AE1") alive;
v_ae1.start(f_CSE_SEM_CRE_017());
v_ae1.done;
}
function f_CSE_SEM_CRE_017() runs on AeSimu system CseSystem {
// Local variables
var MsgIn v_response;
var template RequestPrimitive v_request;
var integer v_aeIndex := -1;
var ResourceType v_resourceType := int24; //Semantic Descriptor
var SemanticFormat v_descriptorRepresentation := int1; //IRI
// Test control
// Test component configuration
f_cf01Up();
// Preamble
f_cse_createAccessControlPolicyAux(-, -, int63);
v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[vc_acpIndex].resource)}, -);
// Test Body
v_request := f_getCreateRequestPrimitive(v_resourceType, m_createSemanticDescriptorBase, v_aeIndex);
v_request.from_ := f_getOriginator(v_aeIndex);
v_request.primitiveContent.semanticDescriptor.descriptor := c_validDescriptor;
v_request.primitiveContent.semanticDescriptor.descriptorRepresentation := v_descriptorRepresentation;
f_send(e_mcaPort, m_request(valueof(v_request)));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int4000))) {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Semantic Descripter creation rejected with expected error code BAD_REQUEST");
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(?))) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Unexpected status code in Response Primitive.");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while creating semantic descriptor resource type");
}
}
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf01Down();
}//end function f_CSE_SEM_CRE_017
/**
* @desc Check that the IUT generates a Response Status Code indicating a “INVALID_SEMANTICS” error
* when any aspect of the semantic validation process fails
*
*/
testcase TC_CSE_SEM_CRE_018() runs on Tester system CseSystem {
var AeSimu v_ae1 := AeSimu.create("AE1") alive;
v_ae1.start(f_CSE_SEM_CRE_018());
v_ae1.done;
}
function f_CSE_SEM_CRE_018() runs on AeSimu system CseSystem {
var integer v_aeIndex := -1;
var integer v_cseBaseIndex := -1;
var integer v_remoteOntologyRepoIndex := -1;
var integer v_remoteOntologyIndex := -1;
var XSD.ID v_remoteOntologyRepoAddress;
var XSD.ID v_remoteOntologyAddress;
var RequestPrimitive v_requestSemanticDescriptor;
// Test control
// Test component configuration
f_cf02Up();
// Test adapter configuration
// Preamble
v_aeIndex := f_cse_preamble_registerAe();
v_cseBaseIndex := f_getLatestLocalResourceIndex(vc_cse1);
vc_cse1.start(f_cse_registerRemoteCse(m_createRemoteCSE_poa(-, -, -, -, -, {f_getLocalPoA()})));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_cse1);
vc_cse1.start(f_generateAndSetLocalResource(valueof(m_primitiveContentOntologyRepository(m_contentCreateOntologyRepository)), v_cseBaseIndex, int38));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_cse1);
v_remoteOntologyRepoAddress := f_getLatestLocalResourceAddress(vc_cse1, e_nonHierarchical, e_cseRelative);
v_remoteOntologyRepoIndex := f_getLatestLocalResourceIndex(vc_cse1);
vc_cse1.start(f_generateAndSetLocalResource(valueof(m_primitiveContentOntology(m_contentCreateOntology)), v_remoteOntologyRepoIndex, int39));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_cse1);
v_remoteOntologyAddress := f_getLatestLocalResourceAddress(vc_cse1, e_nonHierarchical, e_cseRelative);
v_remoteOntologyIndex := f_getLatestLocalResourceIndex(vc_cse1);
//Handle Retrieve Request in CSE
vc_cse1.start(f_cse_retrieveResourceHandler(v_remoteOntologyIndex));
//Create Semantic Descriptor
v_requestSemanticDescriptor := f_getCreateRequestPrimitive(int24, m_createSemanticDescriptorBase, v_aeIndex);
v_requestSemanticDescriptor.primitiveContent.semanticDescriptor.ontologyRef := v_remoteOntologyAddress;
v_requestSemanticDescriptor.primitiveContent.semanticDescriptor.validationEnable := true;
f_send(e_mcaPort, m_request(v_requestSemanticDescriptor));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int4120))) {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": INVALID_SEMANTICS: Semantic validation process fails");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Wrong status code in Response Primitive.");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Unexpected status code in Response Primitive.");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while creating Semantic Mashup Instance resource");
}
}
f_aeSimu_checkComponentDoneAndGetVerdict(vc_cse1);
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf01Down();
}//end function f_CSE_SEM_CRE_018
/**
* @desc Check that the IUT rejects the creation request of a <semanticDescriptor> resource
* indicating a “ONTOLOGY_NOT_AVAILABLE” error when referenced ontology of
* the local linked <semanticDescriptor> resources
* cannot be retrieved during a semantic validation process.
*/
testcase TC_CSE_SEM_CRE_019() runs on Tester system CseSystem {
var AeSimu v_ae1 := AeSimu.create("AE1") alive;
v_ae1.start(f_CSE_SEM_CRE_019());
v_ae1.done;
}
function f_CSE_SEM_CRE_019() runs on AeSimu system CseSystem {
// Local variables
var MsgIn v_response;
var template RequestPrimitive v_request;
var integer v_aeIndex := -1;
var integer v_semanticDescriptorIndex := -1;
var ResourceType v_resourceType := int24; //Semantic Descriptor
var ListOfURIs v_relatedSemantics := {"NotInitilized"};
// Test control
// Test component configuration
f_cf01Up();
// Preamble
f_cse_createAccessControlPolicyAux(-, -, int63);
v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[vc_acpIndex].resource)}, -);
v_semanticDescriptorIndex := f_cse_createResource(int24, m_createSemanticDescriptorBase, v_aeIndex);
v_relatedSemantics := {f_getResourceAddress(v_semanticDescriptorIndex)};
// Test Body
v_request := f_getCreateRequestPrimitive(v_resourceType, m_createSemanticDescriptorBase, v_aeIndex);
v_request.from_ := f_getOriginator(v_aeIndex);
v_request.primitiveContent.semanticDescriptor.validationEnable := true;
v_request.primitiveContent.semanticDescriptor.relatedSemantics := v_relatedSemantics; //linked semantic descriptor
f_send(e_mcaPort, m_request(valueof(v_request)));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int4118))) {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Semantic Descripter creation rejected with expected error code 4118 (ONTOLOGY_NOT_AVAILABLE)");
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(?))) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Unexpected status code in Response Primitive.");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while creating semantic descriptor resource type");
}
}
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf01Down();
}//end function f_CSE_SEM_CRE_019
} // end of group Create } // end of group Create
group Update { group Update {
...@@ -15546,6 +15762,151 @@ module OneM2M_Testcases_CSE_Release_3 { ...@@ -15546,6 +15762,151 @@ module OneM2M_Testcases_CSE_Release_3 {
f_cf01Down(); f_cf01Down();
}; // end TC_CSE_SEM_UPD_013 }; // end TC_CSE_SEM_UPD_013
/**
* @desc Check that the IUT rejects the update request of a <semanticDescriptor> resource indicating a "BAD_REQUEST" error
* when the request contains descriptorRepresentation attribute and is set to "IRI".
*
*/
testcase TC_CSE_SEM_UPD_014() runs on Tester system CseSystem {
var AeSimu v_ae1 := AeSimu.create("AE1") alive;
v_ae1.start(f_CSE_SEM_UPD_014());
v_ae1.done;
}
function f_CSE_SEM_UPD_014() runs on AeSimu system CseSystem {
// Local variables
var MsgIn v_response;
var integer v_aeIndex := -1;
var integer v_resourceIndex := -1;
var integer v_resourceIndex1 := -1;
var RequestPrimitive v_request;
var template RequestPrimitive p_createRequestPrimitive := m_createSemanticDescriptorBase;
var template RequestPrimitive p_updateRequestPrimitive := m_updateSemanticDescriptorBase;
var ResourceType p_resourceType := int24; //Semantic Descriptor
var SemanticFormat v_descriptorRepresentation := int1; //IRI
// Test control
// Test component configuration
f_cf01Up();
// Test adapter configuration
// Preamble
f_cse_createAccessControlPolicyAux(-, -, int63);
v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[vc_acpIndex].resource)}, -);
//Create Semantic Descritor
p_createRequestPrimitive.primitiveContent.semanticDescriptor.descriptor := c_validDescriptor;
v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex);
// Test Body
p_updateRequestPrimitive.primitiveContent.semanticDescriptor.descriptorRepresentation := v_descriptorRepresentation;
p_updateRequestPrimitive.primitiveContent.semanticDescriptor.descriptor := c_validDescriptor;
v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
f_send(e_mcaPort, m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int4000))) {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Update request rejected with expected error code BAD_REQUEST, as request contains descriptorRepresentation attribute set to IRI");
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(?))) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Unexpected status code in Response Primitive.");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while updating semantic descriptor resource type");
}
}
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf01Down();
}//end function f_CSE_SEM_UPD_014
/**
* @desc Check that the IUT rejects the update request of a <semanticDescriptor> resource indicating a "SPARQL_UPDATE_ERROR" error
* in which semanticOpExec attribute contains a valid SPARQL update request
* and request cannot be executed by the Hosting CSE.
*
*/
testcase TC_CSE_SEM_UPD_015() runs on Tester system CseSystem {
var AeSimu v_ae1 := AeSimu.create("AE1") alive;
v_ae1.start(f_CSE_SEM_UPD_015());
v_ae1.done;
}
function f_CSE_SEM_UPD_015() runs on AeSimu system CseSystem {
// Local variables
var MsgIn v_response;
var integer v_aeIndex := -1;
var integer v_resourceIndex := -1;
var integer v_resourceIndex1 := -1;
var RequestPrimitive v_request;
var template RequestPrimitive p_createRequestPrimitive := m_createSemanticDescriptorBase;
var template RequestPrimitive p_updateRequestPrimitive := m_updateSemanticDescriptorBase;
var ResourceType p_resourceType := int24; //Semantic Descriptor
var XSD.String v_semanticOpExec := "DELETE { ?person <http://bigco.example/HR/Person/fname> 'Miguel' }";
// Test control
// Test component configuration
f_cf01Up();
// Test adapter configuration
// Preamble
f_cse_createAccessControlPolicyAux(-, -, int63);
v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[vc_acpIndex].resource)}, -);
//Create Semantic Descritor
p_createRequestPrimitive.primitiveContent.semanticDescriptor.descriptor := c_validDescriptor;
v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex);
// Test Body
p_updateRequestPrimitive.primitiveContent.semanticDescriptor.semanticOpExec := v_semanticOpExec;
v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
f_send(e_mcaPort, m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int5212))) {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Update request responded with error SPARQL_UPDATE_ERROR, as SPARQL update request cannot be executed");
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(?))) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Unexpected status code in Response Primitive.");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while updating semantic descriptor resource type");
}
}
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf01Down();
}//end function f_CSE_SEM_UPD_015
} // end of group Update } // end of group Update
group Retrieve { group Retrieve {
...@@ -16509,7 +16870,225 @@ module OneM2M_Testcases_CSE_Release_3 { ...@@ -16509,7 +16870,225 @@ module OneM2M_Testcases_CSE_Release_3 {
// Tear down // Tear down
f_cf01Down(); f_cf01Down();
}; };
/**
* @desc Check that the IUT rejects a semantic query request
* with semanticsFilter condition set to a non-valid SPARQL query request.
*/
testcase TC_CSE_SEM_RET_013() runs on Tester system CseSystem {
var AeSimu v_ae1 := AeSimu.create("AE1") alive;
v_ae1.start(f_CSE_SEM_RET_013());
v_ae1.done;
}
function f_CSE_SEM_RET_013() runs on AeSimu system CseSystem {
// Local variables
var MsgIn v_response;
var integer v_aeIndex := -1;
var integer v_resourceIndex := -1;
var RequestPrimitive v_retrieveRequest;
var template RequestPrimitive p_createRequestPrimitive := m_createSemanticDescriptorBase;
var FilterCriteria v_filterCriteria := valueof(m_filterCriteria);
v_filterCriteria.semanticsFilter_list[0] := "SELECT WHERE FILTER name";//Invalid SPARQL query
var ResourceType p_resourceType := int24; //Semantic Descriptor
// Test control
// Test component configuration
f_cf01Up();
// Test adapter configuration
// Preamble
f_cse_createAccessControlPolicyAux(-, -, int63);
v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[vc_acpIndex].resource)}, -);
// Test Body
p_createRequestPrimitive.primitiveContent.semanticDescriptor.descriptor := c_validDescriptor;
v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex);
v_retrieveRequest := m_retrieveFilterCriteria(f_getResourceAddress(v_aeIndex), f_getOriginator(v_aeIndex), v_filterCriteria);
v_retrieveRequest.semanticQueryIndicator := true;
v_retrieveRequest.resultContent := int10; //ResultContent = 10 (Semantic Content)
f_send(e_mcaPort, m_request(valueof(v_retrieveRequest)));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int4000))) -> value v_response {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Rejected semantic query request with BAD_REQUEST as semanticsFilter condition set to a non-valid SPARQL query request.");
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(?))) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Unexpected status code in Response Primitive.");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while performing Semantic Query");
}
}
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf01Down();
}//end function f_CSE_SEM_RET_013
/**
* @desc Check that the IUT accepts a valid semantic query request for target resource and returns a valid query result.
*
*/
testcase TC_CSE_SEM_RET_014() runs on Tester system CseSystem {
var AeSimu v_ae1 := AeSimu.create("AE1") alive;
v_ae1.start(f_CSE_SEM_RET_014());
v_ae1.done;
}
function f_CSE_SEM_RET_014() runs on AeSimu system CseSystem {
// Local variables
var MsgIn v_response;
var integer v_aeIndex := -1;
var integer v_resourceIndex := -1;
var RequestPrimitive v_retrieveRequest;
var template RequestPrimitive p_createRequestPrimitive := m_createSemanticDescriptorBase;
var FilterCriteria v_filterCriteria := valueof(m_filterCriteria);
v_filterCriteria.semanticsFilter_list[0] := "SELECT DISTINCT * WHERE { ?s ?p ?o } LIMIT 1"; //Valid SPARQL Query
var ResourceType p_resourceType := int24; //Semantic Descriptor
// Test control
// Test component configuration
f_cf01Up();
// Test adapter configuration
// Preamble
f_cse_createAccessControlPolicyAux(-, -, int63);
v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[vc_acpIndex].resource)}, -);
// Test Body
p_createRequestPrimitive.primitiveContent.semanticDescriptor.descriptor := c_validDescriptor;
v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex);
v_retrieveRequest := m_retrieveFilterCriteria(f_getResourceAddress(v_aeIndex), f_getOriginator(v_aeIndex), v_filterCriteria);
v_retrieveRequest.semanticQueryIndicator := true;
v_retrieveRequest.resultContent := int10; //ResultContent = 10 (Semantic Content)
f_send(e_mcaPort, m_request(valueof(v_retrieveRequest)));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000))) -> value v_response {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ": Semantic query request executed successfully.");
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(?))) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Unexpected status code in Response Primitive.");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while performing Semantic Query");
}
}
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf01Down();
}//end function f_CSE_SEM_RET_014
/**
* @desc Check that the IUT returns successfully the attributes of the <semanticDescriptor> resource
* except the semanticOpEx attribute.
*
*/
testcase TC_CSE_SEM_RET_015() runs on Tester system CseSystem {
var AeSimu v_ae1 := AeSimu.create("AE1") alive;
v_ae1.start(f_CSE_SEM_RET_015());
v_ae1.done;
}
function f_CSE_SEM_RET_015() runs on AeSimu system CseSystem {
// Local variables
var MsgIn v_response;
var template RequestPrimitive v_retrieveRequest;
var template RequestPrimitive v_createRequestPrimitive := m_createSemanticDescriptorBase;
var integer v_aeIndex := -1;
var integer v_resourceIndex := -1;
var template PrimitiveContent v_contentResponse;
// Test component configuration
f_cf01Up(true);
// Test adapter configuration
// Preamble
f_cse_createAccessControlPolicyAux(-, -, int63);
v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[vc_acpIndex].resource)}, -);
v_resourceIndex := f_cse_createResource(int24, v_createRequestPrimitive, v_aeIndex); //SemanticDescriptor
// Test Body
v_retrieveRequest := m_retrieve(f_getResourceAddress(v_resourceIndex), f_getOriginator(v_resourceIndex));
f_send(e_mcaPort, m_request(valueof(v_retrieveRequest)));
v_contentResponse.semanticDescriptor := mw_retrievSemanticDescriptor; // check for attributes of resource representation
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000, v_contentResponse))) -> value v_response {
tc_ac.stop;
if(ispresent(v_response.primitive.responsePrimitive.primitiveContent.semanticDescriptor.semanticOpExec)){
setverdict(fail, __SCOPE__ & "semanticOpExec is included in the RETRIEVE response!");
} else {
setverdict(pass, __SCOPE__ & ": Response OK for retrieving with semanticOpeExec not present as expected.");
}
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000, ?))) -> value v_response {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Response OK for retrieving, but wrong content");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Wrong status code in Response Primitive.");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Unexpected status code in Response Primitive.");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No answer while creating resource");
}
}
// Postamble
f_cse_postamble_deleteResources();
// Tear down
f_cf01Down();
}//end function f_CSE_SEM_RET_015
} // end of group Retrieve } // end of group Retrieve
group Delete { group Delete {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment