Commit 3f44c0583a3dd0dbc5b286304976ca52de095fa1

Authored by Miguel Angel Reina Ortega
1 parent bec8fb18

Implemented new test cases for hybrid addressing using the shortcut

Signed-off-by: reinaortega <miguelangel.reinaortega@etsi.org>
... ... @@ -5230,6 +5230,45 @@ module OneM2M_Functions {
5230 5230 //log("result: " & result);
5231 5231 return result;
5232 5232 }
  5233 +
  5234 + /**
  5235 + * @desc Replace the CSE-Name by the shortcut ("-") in a structured resource id format
  5236 + * @return Cleaned-up resourceID
  5237 + */
  5238 + function f_useShortcutInResourceId(in XSD.ID p_resourceID) return XSD.ID {
  5239 + var integer v_length := lengthof(p_resourceID);
  5240 + var integer i;
  5241 + var integer v_numberOfSlashes := 0;
  5242 + var XSD.ID v_modifiedResourceId:= "";
  5243 + var XSD.ID v_cseName := "";
  5244 +
  5245 + if(p_resourceID[0] == "/") {
  5246 + if(p_resourceID[1] == "/") {
  5247 + v_numberOfSlashes := 4;
  5248 + } else {
  5249 + v_numberOfSlashes := 2;
  5250 + }
  5251 + }
  5252 + //log("p_resourceID: " & p_resourceID);
  5253 + for (i := 0; i < v_length ; i := i+1){
  5254 + if(v_numberOfSlashes != 0) {
  5255 + if(p_resourceID[i]=="/"){
  5256 + v_numberOfSlashes := v_numberOfSlashes - 1;
  5257 + }
  5258 + v_modifiedResourceId := v_modifiedResourceId & p_resourceID[i];
  5259 + } else if (v_numberOfSlashes == 0){
  5260 + if(p_resourceID[i]=="/"){
  5261 + v_numberOfSlashes := v_numberOfSlashes - 1;
  5262 + v_modifiedResourceId := v_modifiedResourceId & "-/";
  5263 + log(__SCOPE__, "INFO: CSE Name to be removed from resource ID: " & v_cseName);
  5264 + }
  5265 + v_cseName := v_cseName & p_resourceID[i];
  5266 + } else if (v_numberOfSlashes == -1){
  5267 + v_modifiedResourceId := v_modifiedResourceId & p_resourceID[i];
  5268 + }
  5269 + }
  5270 + return v_modifiedResourceId;
  5271 + }
5233 5272  
5234 5273 /**
5235 5274 * @desc It removes the poa from a given url
... ...
... ... @@ -858,8 +858,69 @@ module OneM2M_PermutationFunctions {
858 858 // Tear down
859 859 f_cf01Down();
860 860  
861   - }//end f_CSE_GEN_CRE_002
862   -
  861 + }//end f_CSE_GEN_CRE_002
  862 +
  863 + function f_CSE_GEN_CRE_003(in PrimitiveScope p_primitiveScope) runs on AeSimu {
  864 +
  865 + // Local variables
  866 + var RequestPrimitive v_request;
  867 + var integer v_aeIndex := -1;
  868 + var integer v_resourceIndex := -1;
  869 + var AddressingMethod v_addressingMethod;
  870 + var PrimitiveScope v_primitiveScope;
  871 + var XSD.ID v_cseName := PX_CSE_NAME;
  872 +
  873 + // Test control
  874 + if(not(PICS_STRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT)) {
  875 + setverdict(inconc, __SCOPE__ & ": Structured-CSE-Relative-Resource-ID format support is required to run this test case");
  876 + stop;
  877 + }
  878 +
  879 + // Test component configuration
  880 + f_cf01Up();
  881 +
  882 + // Test adapter configuration
  883 +
  884 + // Preamble
  885 + v_aeIndex := f_cse_preamble_registerAe();//c_CRUDNDi);
  886 +
  887 + v_resourceIndex := f_cse_createResource(int3, m_createContainerBase, v_aeIndex);
  888 +
  889 + // Test Body
  890 + //Force usage of Non-Hierarchical addressing method
  891 + v_addressingMethod := e_hierarchical;
  892 + v_primitiveScope := p_primitiveScope;
  893 + v_request := f_getCreateRequestPrimitive(int3, m_createContainerBase, v_resourceIndex);
  894 + v_request.to_ := f_useShortcutInResourceId(f_getResourceAddress(v_resourceIndex, v_addressingMethod, v_primitiveScope));
  895 +
  896 + mcaPort.send(f_getMsgOutPrimitive(m_request(v_request)));
  897 + tc_ac.start;
  898 + alt {
  899 + [] mcaPort.receive(mw_response(mw_responsePrimitive(int2001))) {
  900 + tc_ac.stop;
  901 + setverdict(pass, __SCOPE__ & ": Container resource created using shortcut in hierarchical addressing method");
  902 + }
  903 + [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
  904 + tc_ac.stop;
  905 + setverdict(fail, __SCOPE__ & ": Wrong response status code in the response");
  906 + }
  907 + [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
  908 + tc_ac.stop;
  909 + setverdict(fail, __SCOPE__ & ": Error while creating container resource using shortcut in hierarchical addressing method");
  910 + }
  911 + [] tc_ac.timeout {
  912 + setverdict(fail, __SCOPE__ & ": No answer while creating resource");
  913 + }
  914 + }
  915 +
  916 + // Postamble
  917 + f_cse_postamble_deleteResources();
  918 +
  919 + // Tear down
  920 + f_cf01Down();
  921 +
  922 + }//end f_CSE_GEN_CRE_003
  923 +
863 924 } // end of group Create
864 925  
865 926 group Retrieve {
... ... @@ -977,6 +1038,62 @@ module OneM2M_PermutationFunctions {
977 1038  
978 1039 }//end f_CSE_GEN_RET_002
979 1040  
  1041 + function f_CSE_GEN_RET_003(in PrimitiveScope p_primitiveScope) runs on AeSimu {
  1042 +
  1043 + // Local variables
  1044 + var integer v_aeIndex := -1;
  1045 + var integer v_resourceIndex := -1;
  1046 + var AddressingMethod v_addressingMethod;
  1047 + var PrimitiveScope v_primitiveScope;
  1048 +
  1049 + // Test control
  1050 + if(not(PICS_STRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT)) {
  1051 + setverdict(inconc, __SCOPE__ & ": Structured-CSE-Relative-Resource-ID format support is required to run this test case");
  1052 + stop;
  1053 + }
  1054 +
  1055 + // Test component configuration
  1056 + f_cf01Up();
  1057 +
  1058 + // Test adapter configuration
  1059 +
  1060 + // Preamble
  1061 + v_aeIndex := f_cse_preamble_registerAe();//c_CRUDNDi);
  1062 +
  1063 + v_resourceIndex := f_cse_createResource(int3, m_createContainerBase, v_aeIndex);
  1064 +
  1065 + // Test Body
  1066 + //Force usage of Non-Hierarchical addressing method
  1067 + v_addressingMethod := e_hierarchical;
  1068 + v_primitiveScope := p_primitiveScope;
  1069 +
  1070 + mcaPort.send(f_getMsgOutPrimitive(m_request(m_retrieve(f_useShortcutInResourceId(f_getResourceAddress(v_resourceIndex, v_addressingMethod, v_primitiveScope)), f_getOriginator(v_resourceIndex)))));tc_ac.start;
  1071 + alt {
  1072 + [] mcaPort.receive(mw_response(mw_responsePrimitive(int2000))) {
  1073 + tc_ac.stop;
  1074 + setverdict(pass, __SCOPE__ & ": Container resource retrieved using shortcut in hierarchical addressing method");
  1075 + }
  1076 + [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
  1077 + tc_ac.stop;
  1078 + setverdict(fail, __SCOPE__ & ": Wrong response status code in the response");
  1079 + }
  1080 + [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
  1081 + tc_ac.stop;
  1082 + setverdict(fail, __SCOPE__ & ": Error while retrieving container resource using shortcut in hierarchical addressing method");
  1083 + }
  1084 + [] tc_ac.timeout {
  1085 + setverdict(fail, __SCOPE__ & ": No answer while retrieving resource");
  1086 + }
  1087 + }
  1088 +
  1089 + // Postamble
  1090 + f_cse_postamble_deleteResources();
  1091 +
  1092 + // Tear down
  1093 + f_cf01Down();
  1094 +
  1095 + }//end f_CSE_GEN_RET_003
  1096 +
980 1097 } // end of group Retrieve
981 1098  
982 1099 group Update {
... ... @@ -1107,6 +1224,69 @@ module OneM2M_PermutationFunctions {
1107 1224  
1108 1225 }//end f_CSE_GEN_UPD_002
1109 1226  
  1227 + function f_CSE_GEN_UPD_003(in PrimitiveScope p_primitiveScope) runs on AeSimu {
  1228 +
  1229 + // Local variables
  1230 + var RequestPrimitive v_updateRequest := valueof(m_updateContainerBase);
  1231 + var integer v_aeIndex := -1;
  1232 + var integer v_resourceIndex := -1;
  1233 + var AddressingMethod v_addressingMethod;
  1234 + var PrimitiveScope v_primitiveScope;
  1235 +
  1236 + // Test control
  1237 + if(not(PICS_STRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT)) {
  1238 + setverdict(inconc, __SCOPE__ & ": Structured-CSE-Relative-Resource-ID format support is required to run this test case");
  1239 + stop;
  1240 + }
  1241 +
  1242 + // Test component configuration
  1243 + f_cf01Up();
  1244 +
  1245 + // Test adapter configuration
  1246 +
  1247 + // Preamble
  1248 + v_aeIndex := f_cse_preamble_registerAe();//c_CRUDNDi);
  1249 +
  1250 + v_resourceIndex := f_cse_createResource(int3, m_createContainerBase, v_aeIndex);
  1251 +
  1252 + // Test Body
  1253 + //Force usage of Non-Hierarchical addressing method
  1254 + v_addressingMethod := e_hierarchical;
  1255 + v_primitiveScope := p_primitiveScope;
  1256 +
  1257 + v_updateRequest.primitiveContent.container.labels := {"MyLabel"};
  1258 +
  1259 + v_updateRequest := f_getUpdateRequestPrimitive(int3, v_resourceIndex, v_updateRequest);
  1260 + v_updateRequest.to_ := f_useShortcutInResourceId(f_getResourceAddress(v_resourceIndex, v_addressingMethod, v_primitiveScope));
  1261 +
  1262 + mcaPort.send(f_getMsgOutPrimitive(m_request(v_updateRequest)));
  1263 + tc_ac.start;
  1264 + alt {
  1265 + [] mcaPort.receive(mw_response(mw_responsePrimitive(int2004))) {
  1266 + tc_ac.stop;
  1267 + setverdict(pass, __SCOPE__ & ": Container resource updated using shortcut in hierarchical addressing method");
  1268 + }
  1269 + [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
  1270 + tc_ac.stop;
  1271 + setverdict(fail, __SCOPE__ & ": Wrong response status code in the response");
  1272 + }
  1273 + [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
  1274 + tc_ac.stop;
  1275 + setverdict(fail, __SCOPE__ & ": Error while updating container resource using shortcut in hierarchical addressing method");
  1276 + }
  1277 + [] tc_ac.timeout {
  1278 + setverdict(fail, __SCOPE__ & ": No answer while updating resource");
  1279 + }
  1280 + }
  1281 +
  1282 + // Postamble
  1283 + f_cse_postamble_deleteResources();
  1284 +
  1285 + // Tear down
  1286 + f_cf01Down();
  1287 +
  1288 + }//end f_CSE_GEN_UPD_003
  1289 +
1110 1290 } // end of group Update
1111 1291  
1112 1292 group Delete {
... ... @@ -1231,6 +1411,66 @@ module OneM2M_PermutationFunctions {
1231 1411  
1232 1412 }//end f_CSE_GEN_DEL_002
1233 1413  
  1414 + function f_CSE_GEN_DEL_003(in PrimitiveScope p_primitiveScope) runs on AeSimu {
  1415 +
  1416 + // Local variables
  1417 + var RequestPrimitive v_request;
  1418 + var integer v_aeIndex := -1;
  1419 + var integer v_resourceIndex := -1;
  1420 + var AddressingMethod v_addressingMethod;
  1421 + var PrimitiveScope v_primitiveScope;
  1422 +
  1423 + // Test control
  1424 + if(not(PICS_STRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT)) {
  1425 + setverdict(inconc, __SCOPE__ & ": Structured-CSE-Relative-Resource-ID format support is required to run this test case");
  1426 + stop;
  1427 + }
  1428 +
  1429 + // Test component configuration
  1430 + f_cf01Up();
  1431 +
  1432 + // Test adapter configuration
  1433 +
  1434 + // Preamble
  1435 + v_aeIndex := f_cse_preamble_registerAe();//c_CRUDNDi);
  1436 +
  1437 + v_resourceIndex := f_cse_createResource(int3, m_createContainerBase, v_aeIndex);
  1438 +
  1439 + // Test Body
  1440 + //Force usage of Non-Hierarchical addressing method
  1441 + v_addressingMethod := e_hierarchical;
  1442 + v_primitiveScope := p_primitiveScope;
  1443 +
  1444 + v_request := valueof(m_delete(f_useShortcutInResourceId(f_getResourceAddress(v_resourceIndex, v_addressingMethod, v_primitiveScope)), f_getOriginator(v_resourceIndex)));
  1445 +
  1446 + mcaPort.send(f_getMsgOutPrimitive(m_request(v_request)));
  1447 + tc_ac.start;
  1448 + alt {
  1449 + [] mcaPort.receive(mw_response(mw_responsePrimitive(int2002))) {
  1450 + tc_ac.stop;
  1451 + setverdict(pass, __SCOPE__ & ": Container resource deleted using shortcut in hierarchical addressing method");
  1452 + }
  1453 + [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
  1454 + tc_ac.stop;
  1455 + setverdict(fail, __SCOPE__ & ": Wrong response status code in the response");
  1456 + }
  1457 + [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
  1458 + tc_ac.stop;
  1459 + setverdict(fail, __SCOPE__ & ": Error while deleting container resource using shortcut in hierarchical addressing method");
  1460 + }
  1461 + [] tc_ac.timeout {
  1462 + setverdict(fail, __SCOPE__ & ": No answer while deleting resource");
  1463 + }
  1464 + }
  1465 +
  1466 + // Postamble
  1467 + f_cse_postamble_deleteResources();
  1468 +
  1469 + // Tear down
  1470 + f_cf01Down();
  1471 +
  1472 + }//end f_CSE_GEN_DEL_003
  1473 +
1234 1474 } // end of group Delete
1235 1475  
1236 1476 } // end of group Generic
... ...
... ... @@ -82,16 +82,183 @@ module OneM2M_Testcases_CSE_Release_2 {
82 82 group Generic {
83 83  
84 84 group Create {
  85 +
  86 + group g_CSE_GEN_CRE_003 {
  87 +
  88 + /**
  89 + * @desc Check that the IUT accepts the creation of a <container> resource using shortcut structured resource identifier
  90 + *
  91 + */
  92 + testcase TC_CSE_GEN_CRE_003_CSR() runs on Tester system CseSystem {
  93 + // Local variables
  94 +
  95 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  96 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  97 + v_ae1.done;
  98 +
  99 + v_ae1.start(f_CSE_GEN_CRE_003(e_cseRelative));
  100 + v_ae1.done;
  101 + }
  102 +
  103 + testcase TC_CSE_GEN_CRE_003_SPR() runs on Tester system CseSystem {
  104 + // Local variables
  105 +
  106 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  107 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  108 + v_ae1.done;
  109 +
  110 + v_ae1.start(f_CSE_GEN_CRE_003(e_spRelative));
  111 + v_ae1.done;
  112 + }
  113 +
  114 + testcase TC_CSE_GEN_CRE_003_ABS() runs on Tester system CseSystem {
  115 + // Local variables
  116 +
  117 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  118 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  119 + v_ae1.done;
  120 +
  121 + v_ae1.start(f_CSE_GEN_CRE_003(e_absolute));
  122 + v_ae1.done;
  123 + }
  124 +
  125 + }// end of group g_CSE_GEN_CRE_003
85 126  
  127 +
86 128 } // end of group Create
87 129  
88 130 group Retrieve {
  131 +
  132 + group g_CSE_GEN_RET_003 {
  133 +
  134 + /**
  135 + * @desc Check that the IUT accepts the retrieval of a <container> resource using shortcut structured resource identifier
  136 + *
  137 + */
  138 + testcase TC_CSE_GEN_RET_003_CSR() runs on Tester system CseSystem {
  139 + // Local variables
  140 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  141 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  142 + v_ae1.done;
  143 +
  144 + v_ae1.start(f_CSE_GEN_RET_003(e_cseRelative));
  145 + v_ae1.done;
  146 + }
  147 +
  148 + testcase TC_CSE_GEN_RET_003_SPR() runs on Tester system CseSystem {
  149 + // Local variables
  150 +
  151 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  152 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  153 + v_ae1.done;
  154 +
  155 + v_ae1.start(f_CSE_GEN_RET_003(e_spRelative));
  156 + v_ae1.done;
  157 + }
  158 +
  159 + testcase TC_CSE_GEN_RET_003_ABS() runs on Tester system CseSystem {
  160 + // Local variables
  161 +
  162 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  163 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  164 + v_ae1.done;
  165 +
  166 + v_ae1.start(f_CSE_GEN_RET_003(e_absolute));
  167 + v_ae1.done;
  168 + }
  169 +
  170 + } // end of group g_CSE_GEN_RET_003
  171 +
89 172 } // end of group Retrieve
90 173  
91 174 group Update {
  175 +
  176 + group g_CSE_GEN_UPD_003 {
  177 +
  178 + /**
  179 + * @desc Check that the IUT accepts the update of a <container> resource using shortcut structured resource identifier
  180 + *
  181 + */
  182 + testcase TC_CSE_GEN_UPD_003_CSR() runs on Tester system CseSystem {
  183 + // Local variables
  184 +
  185 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  186 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  187 + v_ae1.done;
  188 +
  189 + v_ae1.start(f_CSE_GEN_UPD_003(e_cseRelative));
  190 + v_ae1.done;
  191 + }
  192 +
  193 + testcase TC_CSE_GEN_UPD_003_SPR() runs on Tester system CseSystem {
  194 + // Local variables
  195 +
  196 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  197 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  198 + v_ae1.done;
  199 +
  200 + v_ae1.start(f_CSE_GEN_UPD_003(e_spRelative));
  201 + v_ae1.done;
  202 + }
  203 +
  204 + testcase TC_CSE_GEN_UPD_003_ABS() runs on Tester system CseSystem {
  205 + // Local variables
  206 +
  207 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  208 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  209 + v_ae1.done;
  210 +
  211 + v_ae1.start(f_CSE_GEN_UPD_003(e_absolute));
  212 + v_ae1.done;
  213 + }
  214 +
  215 + } // end of group g_CSE_GEN_UPD_003
  216 +
92 217 } // end of group Update
93 218  
94 219 group Delete {
  220 +
  221 + group g_CSE_GEN_DEL_003 {
  222 +
  223 + /**
  224 + * @desc Check that the IUT accepts the deletion of a <container> resource using shortcut structured resource identifier
  225 + *
  226 + */
  227 + testcase TC_CSE_GEN_DEL_003_CSR() runs on Tester system CseSystem {
  228 + // Local variables
  229 +
  230 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  231 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  232 + v_ae1.done;
  233 +
  234 + v_ae1.start(f_CSE_GEN_DEL_003(e_cseRelative));
  235 + v_ae1.done;
  236 + }
  237 +
  238 + testcase TC_CSE_GEN_DEL_003_SPR() runs on Tester system CseSystem {
  239 + // Local variables
  240 +
  241 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  242 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  243 + v_ae1.done;
  244 +
  245 + v_ae1.start(f_CSE_GEN_DEL_003(e_spRelative));
  246 + v_ae1.done;
  247 + }
  248 +
  249 + testcase TC_CSE_GEN_DEL_003_ABS() runs on Tester system CseSystem {
  250 + // Local variables
  251 +
  252 + var AeSimu v_ae1 := AeSimu.create("AE1") alive;
  253 + v_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
  254 + v_ae1.done;
  255 +
  256 + v_ae1.start(f_CSE_GEN_DEL_003(e_absolute));
  257 + v_ae1.done;
  258 + }
  259 +
  260 + } // end of group g_CSE_GEN_DEL_003
  261 +
95 262 } // end of group Delete
96 263  
97 264 } // end of group Generic
... ...