Commit 9c8f61a3 authored by urbant's avatar urbant
Browse files

Test cases for sections 7.6.5 and 7.6.6

parent f049efb6
Loading
Loading
Loading
Loading
+83 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 475
 ** @version  0.0.1
 ** @purpose  9:7.6.5.1, Verify that choice content with nested elements is correctly transformed
 ** @verdict  pass accept, ttcn3verdict:pass
***************************************************/
// The following requirements are tested:
// Nested elements shall be mapped as fields of the enframing TTCN-3 union or 
// record of union field(see clause 7.6.5) according to clause 7.3.

module Pos_07060501_choice_with_nested_elements_001 {

   import from schema_Pos_07060501_choice_with_nested_elements_001 language "XSD" all;

   template MyType m_msg := { 
      choice := {
	     foo := 1
      }
   };


    type universal charstring Raw;

    type universal charstring File;
    type record of File FileList;

    type port P message {
        inout all;
    }
    type component C {
        port P p;
    }

	/**
	 * @desc lexical compare the charstring p_textToMatch with the contents of the reference XML file and returns true if they represent the same XML structure
	 * @param p_textToMatch text to be compared with the UTF-8 contents of the XML file
	 * @param p_referenceXmlFile the XML file
	 * @param p_xsdFileList the list of XSD files
	 * @param p_matchError the error result in case it did not match
	 * @param p_referenceTTCN3File the file of the TTCN-3 test module. This path is used to find the reference XML file relative to this path, by keeping the TTCN-3 code file system independent.
	 * @return true if p_textToMatch and the contents of p_referenceXmlFile represent the same XML structure
	 */
 	external function matchFile(Raw p_textToMatch, File p_referenceXmlFile, FileList p_xsdFileList, out universal charstring p_matchError, File p_referenceTTCN3File := __FILE__) return boolean;

    testcase TC_Pos_07060501_choice_with_nested_elements_001() runs on C system C {
        var Raw v_rcv;
        var universal charstring v_matchError;

        map(self:p, system:p);

		// encode the message
        p.send(m_msg);

        alt {
        	// compare the encoded message with the reference XML file
            []	p.check(receive(Raw:?) -> value v_rcv) {
            	log("XML message ", v_rcv);
                if (matchFile(v_rcv, "Pos_07060501_choice_with_nested_elements_001.xml", { "Pos_07060501_choice_with_nested_elements_001.xsd" }, v_matchError)) {
                    alt {
                    	// match decoded value to pass test
                        [] p.receive(m_msg) {
                        	setverdict(pass, "Decoded value matches encoded template and reference XML");
                        }
                        [] p.receive {
                            setverdict(fail, "XML decoding failure");
                        }
                    }
                } else {
                    setverdict(fail, v_matchError);
                }
            }
            [] p.receive {
                setverdict(fail, "Raw decoding failure");
            }
        }
    }

    control {
        execute(TC_Pos_07060501_choice_with_nested_elements_001(), 5.0);
    }


}
+4 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<ns:MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="schema:Pos_07060501_choice_with_nested_elements_001">
 <foo>1</foo>
</ns:MyType>
 No newline at end of file
+13 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
  targetNamespace="schema:Pos_07060501_choice_with_nested_elements_001"
  xmlns:ns="schema:Pos_07060501_choice_with_nested_elements_001">
  <element name="MyType">
	<complexType>
		<choice>
			<element name="foo" type="integer"/>
			<element name="bar" type="float"/>
		</choice>
	</complexType>
  </element>
</schema>
+89 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 475
 ** @version  0.0.1
 ** @purpose  9:7.6.5.2, Verify that choice content with nested group is correctly transformed
 ** @verdict  pass accept, ttcn3verdict:pass
***************************************************/
// The following requirements are tested:
// Nested group components shall be mapped along with other content as 
// a field of the enframing TTCN-3 union or record of union field (see clause
// 7.6.5). The type of this field shall refer to the TTCN-3 type generated for 
// the corresponding group and the name of the field shall be the name of the
// TTCN-3 type with the first character uncapitalized.

module Pos_07060502_choice_with_nested_group_001 {

   import from schema_Pos_07060502_choice_with_nested_group_001 language "XSD" all;

   template MyType m_msg := { 
      choice := {
	     group1 := {
	       foo := "foo",
	       bar := "bar"
	     }
      }
   };


    type universal charstring Raw;

    type universal charstring File;
    type record of File FileList;

    type port P message {
        inout all;
    }
    type component C {
        port P p;
    }

	/**
	 * @desc lexical compare the charstring p_textToMatch with the contents of the reference XML file and returns true if they represent the same XML structure
	 * @param p_textToMatch text to be compared with the UTF-8 contents of the XML file
	 * @param p_referenceXmlFile the XML file
	 * @param p_xsdFileList the list of XSD files
	 * @param p_matchError the error result in case it did not match
	 * @param p_referenceTTCN3File the file of the TTCN-3 test module. This path is used to find the reference XML file relative to this path, by keeping the TTCN-3 code file system independent.
	 * @return true if p_textToMatch and the contents of p_referenceXmlFile represent the same XML structure
	 */
 	external function matchFile(Raw p_textToMatch, File p_referenceXmlFile, FileList p_xsdFileList, out universal charstring p_matchError, File p_referenceTTCN3File := __FILE__) return boolean;

    testcase TC_Pos_07060502_choice_with_nested_group_001() runs on C system C {
        var Raw v_rcv;
        var universal charstring v_matchError;

        map(self:p, system:p);

		// encode the message
        p.send(m_msg);

        alt {
        	// compare the encoded message with the reference XML file
            []	p.check(receive(Raw:?) -> value v_rcv) {
            	log("XML message ", v_rcv);
                if (matchFile(v_rcv, "Pos_07060502_choice_with_nested_group_001.xml", { "Pos_07060502_choice_with_nested_group_001.xsd" }, v_matchError)) {
                    alt {
                    	// match decoded value to pass test
                        [] p.receive(m_msg) {
                        	setverdict(pass, "Decoded value matches encoded template and reference XML");
                        }
                        [] p.receive {
                            setverdict(fail, "XML decoding failure");
                        }
                    }
                } else {
                    setverdict(fail, v_matchError);
                }
            }
            [] p.receive {
                setverdict(fail, "Raw decoding failure");
            }
        }
    }

    control {
        execute(TC_Pos_07060502_choice_with_nested_group_001(), 5.0);
    }


}
+5 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<ns:MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="schema:Pos_07060502_choice_with_nested_group_001">
 <foo>foo</foo>
 <bar>bar</bar>
</ns:MyType>
 No newline at end of file
Loading