TestCodec_External.ttcn 4.65 KB
Newer Older
Yann Garcia's avatar
Yann Garcia committed
1 2 3 4 5
module TestCodec_External {
  
  // LibMec
  import from LocationAPI_TypesAndValues all;
  import from LocationAPI_Templates all;
Yann Garcia's avatar
Yann Garcia committed
6 7
  import from UEidentityAPI_TypesAndValues all;
  import from UEidentityAPI_Templates all;
Yann Garcia's avatar
Yann Garcia committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
  
  // TestCodec
  import from TestCodec_TestAndSystem all;
  
  testcase tc_encode_LocationInfo() runs on TCType system TCType {
    var LocationInfo v_location_info := valueof(m_location_info(10.0, 12.0, 9));
    var LocationInfo v_location_info_result;
    var universal charstring v_result;
    var universal charstring v_expected_result := "{\"latitude\":10.000000,\"longitude\":12.000000,\"accuracy\":9}";
    var bitstring v_enc_msg;
    var integer v_res;
    
    v_enc_msg := encvalue(v_location_info);
    v_result := oct2unichar(bit2oct(v_enc_msg), "UTF-8");
    log("v_result= ", v_result);
    if (match(v_expected_result, v_result)) {
      setverdict(pass, "Encoding succeed");
    } else {
      setverdict(fail, "Encoding failed");
    }
    
    v_res := decvalue(v_enc_msg, v_location_info_result);
    if (v_res == 0) {
      log("v_location_info_result= ", v_location_info_result);
      if (match(v_location_info, v_location_info_result)) {
        setverdict(pass, "Decoding succeed");
      } else {
        setverdict(fail, "Decoding failed");
      }
    } else {
      setverdict(fail, "Decoding operation failed");
    }
  } // End of testcase tc_encode_LocationInfo
  
Yann Garcia's avatar
Yann Garcia committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
  testcase tc_encode_UserInfo() runs on TCType system TCType {
    var UserInfo v_location_info := valueof(m_user_info("acr:10.0.0.1", "001010000000000000000000000000001", "zone01", "http://example.com/exampleAPI/location/v2/users?address=acr%3A10.0.0.1", TimeStamp:{ 1483231138, 0 }));
    var UserInfo v_location_info_result;
    var universal charstring v_result;
    var universal charstring v_expected_result := "{\"address\":\"acr:10.0.0.1\",\"accessPointId\":\"001010000000000000000000000000001\",\"zoneId\":\"zone01\",\"resourceURL\":\"http://example.com/exampleAPI/location/v2/users?address=acr%3A10.0.0.1\",\"timeStamp\":{\"seconds\":1483231138,\"nanoSeconds\":0}}";
    var bitstring v_enc_msg;
    var integer v_res;
    
    v_enc_msg := encvalue(v_location_info);
    v_result := oct2unichar(bit2oct(v_enc_msg), "UTF-8");
    log("v_result= ", v_result);
    if (match(v_expected_result, v_result)) {
      setverdict(pass, "Encoding succeed");
    } else {
      setverdict(fail, "Encoding failed");
    }
    
    v_res := decvalue(v_enc_msg, v_location_info_result);
    if (v_res == 0) {
      log("v_location_info_result= ", v_location_info_result);
      if (match(v_location_info, v_location_info_result)) {
        setverdict(pass, "Decoding succeed");
      } else {
        setverdict(fail, "Decoding failed");
      }
    } else {
      setverdict(fail, "Decoding operation failed");
    }
  } // End of testcase tc_encode_UserInfo
  
  testcase tc_encode_UeIdentityTags() runs on TCType system TCType {
    var UeIdentityTagInfo v_ue_identity_tags_info := valueof(m_ue_identity_tag_info({ m_ue_identity_tag_item("UeTagA", REGISTERED) } ));
    var UeIdentityTagInfo v_ue_identity_tags_info_result;
    var universal charstring v_result;
    var universal charstring v_expected_result := "{\"ueIdentityTags\":[{\"ueIdentityTag\":\"UeTagA\",\"state\":\"REGISTERED\"}]}";
    var bitstring v_enc_msg;
    var integer v_res;
    
    v_enc_msg := encvalue(v_ue_identity_tags_info);
    v_result := oct2unichar(bit2oct(v_enc_msg), "UTF-8");
    log("v_result= ", v_result);
    if (match(v_expected_result, v_result)) {
      setverdict(pass, "Encoding succeed");
    } else {
      setverdict(fail, "Encoding failed");
    }
    
    v_res := decvalue(v_enc_msg, v_ue_identity_tags_info_result);
    if (v_res == 0) {
      log("v_ue_identity_tags_info_result= ", v_ue_identity_tags_info_result);
      if (match(v_ue_identity_tags_info, v_ue_identity_tags_info_result)) {
        setverdict(pass, "Decoding succeed");
      } else {
        setverdict(fail, "Decoding failed");
      }
    } else {
      setverdict(fail, "Decoding operation failed");
    }

    v_enc_msg := oct2bit(char2oct("{\"ueIdentityTags\": [{ \"ueIdentityTag\": \"UeTagA\",\t\"state\": \"REGISTERED\"}]}"));
    v_res := decvalue(v_enc_msg, v_ue_identity_tags_info_result);
    if (v_res == 0) {
      log("v_ue_identity_tags_info_result (1)= ", v_ue_identity_tags_info_result);
      if (match(v_ue_identity_tags_info, v_ue_identity_tags_info_result)) {
        setverdict(pass, "Decoding succeed (1)");
      } else {
        setverdict(fail, "Decoding failed (1)");
      }
    } else {
      setverdict(fail, "Decoding operation failed (1)");
    }
  } // End of testcase tc_encode_UeIdentityTags
  
Yann Garcia's avatar
Yann Garcia committed
115
} // End of module TestCodec_External