Commit 751a72c9 authored by YannGarcia's avatar YannGarcia
Browse files

Add testcases squeleton

parent 9fb8b953
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ $(cc_objects) : $(outdir)/%.o : %.cc
$(gen_sources): $(outdir)/.generate

$(outdir)/.generate: Makefile $(tt_sources)
	$(TTCN3_DIR)/bin/compiler -d -e -f -g -l -L -M -O -R -U none -x -X -o $(outdir) $(tt_sources)
	$(TTCN3_DIR)/bin/compiler -b -d -e -f -g -j -l -L -M -O -R -U none -x -o $(outdir) $(tt_sources)
	touch $@

$(foreach S, $(ttcn_sources),  $(eval $(outdir)/$(notdir $(patsubst %.ttcn, %.cc,  $(S))): $(S)))
+21 −3
Original line number Diff line number Diff line
@@ -22,12 +22,26 @@ int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& msg, OCTETSTR
    const http__www__cise__eu__servicemodel__v1__message::PullRequest& pull_request = msg.pull__request();
    loggers::get_instance().log_msg("xml_codec::encode: Process PullRequest: ", (const Base_Type&)pull_request);
    pull_request.encode(http__www__cise__eu__servicemodel__v1__message::PullRequest_descr_, encoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
  } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBody::ALT_pull__response)) {
    const http__www__cise__eu__servicemodel__v1__message::PullResponse& pull_response = msg.pull__response();
    loggers::get_instance().log_msg("xml_codec::encode: Process PullResponse: ", (const Base_Type&)pull_response);
    pull_response.encode(http__www__cise__eu__servicemodel__v1__message::PullResponse_descr_, encoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
  } else {
    loggers::get_instance().warning("xml_codec::encode: Unsupported variant");
    return -1;
  }
  data = OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data());
  { // TITAN issue:   loggers::get_instance().log_msg("xml_codec::encode: After encoding: ", data);
  { // TITAN issue: variant "namespace as 'http:www:cise:eu:servicemodel:v1:message' prefix 'ns4'" seems buggy
    std::string s(static_cast<const unsigned char*>(data), data.lengthof() + static_cast<const unsigned char*>(data));
    size_t idx = 0;
    std::string f("tq0001");
    std::string t("ns4");
    while ((idx = s.find(f)) != std::string::npos) {
      s.replace(idx, f.length(), t);
      idx += t.length();
    } // End of 'while' statement

    data = OCTETSTRING(s.length(), (const unsigned char*)s.c_str());
  }
  loggers::get_instance().log_msg("xml_codec::encode: After encoding: ", data);

@@ -50,17 +64,21 @@ int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes::
      loggers::get_instance().warning("xml_codec::decode: Failed to access p_params item (decode_str)");
      return -1; // TODO Use p_data instead of return -1
    }
    loggers::get_instance().log("xml_codec::decode: it->second='%c' / '%s'", it->second.c_str()[0], it->second.c_str());
    loggers::get_instance().log("xml_codec::decode: it->second='%s'", it->second.c_str());
  }

  TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
  TTCN_EncDec::clear_error();
  TTCN_Buffer decoding_buffer(p_data);
  TTCN_Buffer decoding_buffer(OCTETSTRING(it->second.length(), (const unsigned char*)it->second.c_str()));

  if ((it->second.find("<PullRequest") != std::string::npos) || (it->second.find(":PullRequest") != std::string::npos)) {
    http__www__cise__eu__servicemodel__v1__message::PullRequest pull_request;
    pull_request.decode(http__www__cise__eu__servicemodel__v1__message::PullRequest_descr_, decoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
    msg.pull__request() = pull_request;
  } else if ((it->second.find("<PullResponse") != std::string::npos) || (it->second.find(":PullResponse") != std::string::npos)) {
    http__www__cise__eu__servicemodel__v1__message::PullResponse pull_response;
    pull_response.decode(http__www__cise__eu__servicemodel__v1__message::PullResponse_descr_, decoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
    msg.pull__response() = pull_response;
  } else {
    loggers::get_instance().warning("xml_codec::decode: Unsupported variant");
    return -1;
+3 −0
Original line number Diff line number Diff line
@@ -61,7 +61,10 @@ system.httpPort_notif.params := "HTTP(codecs=xml:xml_codec)/TCP(debug=1,server_m
# In this section you can specify what parts of your test suite you want to execute.
#AtsCise_TestControl.control

# Check that the IUT sends a PullResponse when recieving a PullRequest with no Acknowledgement
AtsCise_TestCases.TC_CISE_xxx_BV_01
# Check that the IUT is requested to send a PullRequest with no Acknowledgement, the IUT sends a PullRequest with entry Acknowledgement set to False
#AtsCise_TestCases.TC_CISE_yyy_BV_01

[GROUPS]
# In this section you can specify groups of hosts. These groups can be used inside the
+100 −10
Original line number Diff line number Diff line
@@ -22,8 +22,12 @@ module AtsCise_TestCases {
  import from http_www_cise_eu_datamodel_v1_entity_vessel all;
  import from http_www_cise_eu_datamodel_v1_entity_cargo all;

  group test {
  group test1 {

    /**
     * @desc Check that the IUT sends a PullResponse when recieving a PullRequest with no Acknowledgement
     * @see ETSI GS CDM 004 Clause 5.4.2 Pull
     */
    testcase TC_CISE_xxx_BV_01() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var Headers v_headers;
@@ -40,12 +44,12 @@ module AtsCise_TestCases {
      }

      // Test component configuration
      f_cf_01_http_notif_up();//f_cf_01_http_up();
      f_cf_01_http_up();

      // Test adapter configuration

      // Preamble
      /*f_init_default_headers_list(-, -, v_headers);
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
@@ -59,7 +63,7 @@ module AtsCise_TestCases {
                                                                                                                      high,
                                                                                                                      m_service( // Sender
                                                                                                                                { string := PX_CISE_SERVICE_ID }, //m_service_id(PX_CISE_SERVICE_ID),
                                                                                                                                acknowledgement,
                                                                                                                                pull,
                                                                                                                                -,
                                                                                                                                PX_CISE_SEA_BASSIN,
                                                                                                                                consumer,
@@ -67,7 +71,7 @@ module AtsCise_TestCases {
                                                                                                                                vesselService
                                                                                                                                ),
                                                                                                                      {}, 
                                                                                                                      "",
                                                                                                                      -,
                                                                                                                      request,
                                                                                                                      {},
                                                                                                                      -, -, 
@@ -95,7 +99,7 @@ module AtsCise_TestCases {
                                                                                                                                                                ),
                                                                                                                      -,
                                                                                                                      1000 // ResponseTimeOut
                    ))))));*/
                    ))))));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
@@ -109,11 +113,15 @@ module AtsCise_TestCases {
                                                                                                                    mw_pull_response(
                                                                                                                                     v_date_time,
                                                                                                                                     v_message_id,
                                                                                                                                     high
                                                                                                                                     high,
                                                                                                                                     -, -, -,
                                                                                                                                     success,
                                                                                                                                     -, -,
                                                                                                                                     v_correlation_id
                              )))))) -> value v_response {
            tc_ac.stop;
              
            log("*** " & testcasename() & ": PASS: IUT successfully responds to message ID tester ***");
            log("*** " & testcasename() & ": PASS: IUT successfully received PullResponse ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          }
          [] tc_ac.timeout {
@@ -123,10 +131,92 @@ module AtsCise_TestCases {
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_notif_down();//f_cf_01_http_down();
      f_cf_01_http_down();
    
    } // End of testcase TC_CISE_xxx_BV_01

  } // Enf of group test
  } // Enf of group test1

  group test2 {

    /**
     * @desc Check that the IUT is requested to send a PullRequest with no Acknowledgement, the IUT sends a PullRequest with entry Acknowledgement set to False
     * @see ETSI GS CDM 004 Clause 5.4.2 Pull
     */
    testcase TC_CISE_yyy_BV_01() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HttpMessage v_request;

      // Test control
      if (not(PICS_IUT_ADAPTOR)) {
        log("*** " & testcasename() & ": PICS_IUT_ADAPTOR required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_notif_up();

      // Test adapter configuration

      // Preamble
      action("Trigger PullRequest with no Acknowledgement...");
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort_notif.receive(
                                  mw_http_request(
                                                  mw_http_request_get(
                                                                      ?,
                                                                      ?,
                                                                      mw_http_message_body_xml(
                                                                                               mw_xml_body_pull_request(
                                                                                                                        mw_pull_request
                                  ))))) -> value v_request {
            var Headers v_headers;
            var PullRequest v_pull_request := v_request.request.body.xml_body.pull_request;

            tc_ac.stop;

            log("*** " & testcasename() & ": PASS: IUT successfully received PullRequest ***");

            // Send PullResponse
            f_init_default_headers_list(-, -, v_headers);
            httpPort_notif.send(
                                m_http_response(
                                                m_http_response_ok(
                                                                   mw_http_message_body_xml(
                                                                                            m_xml_body_pull_response(
                                                                                                                     m_pull_response(
                                                                                                                                     v_pull_request.creationDateTime,
                                                                                                                                     v_pull_request.messageID,
                                                                                                                                     v_pull_request.priority,
                                                                                                                                     v_pull_request.sender_,
                                                                                                                                     {}, 
                                                                                                                                     -,
                                                                                                                                     success,
                                                                                                                                     -,
                                                                                                                                     "ContextID", 
                                                                                                                                     v_pull_request.correlationID, 
                                                                                                                                     false
                                                                                             ))),
                                                                                             v_headers
                                 )));
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          }
          [] tc_ac.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
          }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_notif_down();
    
    } // End of testcase TC_CISE_yyy_BV_01

  } // Enf of group test2

} // End of module AtsCise_TestCases
+2 −2
Original line number Diff line number Diff line
@@ -532,7 +532,7 @@ with {
  variant (reliability) "name as capitalized";
  variant (ccRecipients_list) "untagged";
  variant (ccRecipients_list[-]) "name as 'CcRecipients'";
  variant (elem) "anyElement except unqualified, 'http://www.cise.eu/servicemodel/v1/message/'";
  variant (elem) "anyElement except 'Signature'"/*unqualified, 'http://www.cise.eu/servicemodel/v1/message/'"*/;
  variant (errorDetail) "name as capitalized";
  variant (resultCode) "name as capitalized";
  variant (fulfils) "name as capitalized";
@@ -614,7 +614,7 @@ with {
  variant (reliability) "name as capitalized";
  variant (ccRecipients_list) "untagged";
  variant (ccRecipients_list[-]) "name as 'CcRecipients'";
  variant (elem) "anyElement except unqualified, 'http://www.cise.eu/servicemodel/v1/message/'";
  variant (elem) "anyElement except 'Signature'"/*unqualified, 'http://www.cise.eu/servicemodel/v1/message/'"*/;
  variant (pullType) "name as capitalized";
  variant (responseTimeOut) "name as capitalized";
  variant (requests) "name as capitalized";
Loading