Skip to content
Snippets Groups Projects
Commit 9167f90a authored by urbant's avatar urbant
Browse files

New tests covering changes in TTCN-3:2017 (generated)

parent 94e9854f
Branches
No related merge requests found
Showing
with 519 additions and 0 deletions
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 9:6.8, Verify conversion of XSD anySimpleType to TTCN-3 anytype
** @verdict pass accept, ttcn3verdict:pass
** @configuration any_to_anytype
***************************************************/
module Pos_Pos_0608_anytype_and_anysimpletype_types_006 {
import from schema_Pos_0608_anytype_and_anysimpletype_types_006 language "XSD" all;
template MyType m_msg := { integer := 1 };
/**
* @desc The timeout given in seconds after which the test case will be stopped.
*/
modulepar float PX_TC_EXECUTION_TIMEOUT := 5.0;
type universal charstring Raw;
type port P message {
inout all;
}
type component C {
port P p;
}
testcase TC_Pos_0608_anytype_and_anysimpletype_types_006() runs on C system C {
var Raw v_rcv;
map(self:p, system:p);
// encode the message
p.send(m_msg);
alt {
[] p.check(receive(Raw:?) -> value v_rcv) {
log("XML message ", v_rcv);
alt {
// match decoded value to pass test
[] p.receive(m_msg) {
setverdict(pass, "Decoded value matches encoded template");
}
[] p.receive {
setverdict(fail, "XML decoding failure");
}
}
}
[] p.receive {
setverdict(fail, "Raw decoding failure");
}
}
}
control {
execute(TC_Pos_0608_anytype_and_anysimpletype_types_006(), PX_TC_EXECUTION_TIMEOUT);
}
}
<?xml version="1.0" encoding="utf-8"?>
<ns:MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="schema:Pos_0608_anytype_and_anysimpletype_types_006">1</ns:MyType>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="schema:Pos_0608_anytype_and_anysimpletype_types_006"
xmlns:ns="schema:Pos_0608_anytype_and_anysimpletype_types_006">
<xsd:element name="MyType" type="xsd:anySimpleType"></xsd:element>
</xsd:schema>
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 9:6.8, Verify conversion of XSD anyType to TTCN-3 anytype
** @verdict pass accept, ttcn3verdict:pass
** @configuration any_to_anytype
***************************************************/
module Pos_Pos_0608_anytype_and_anysimpletype_types_007 {
import from schema_Pos_0608_anytype_and_anysimpletype_types_007 language "XSD" all;
template MyType m_msg := { embed_values := omit, attr := omit, elem_list := { { Something := 1 } } };
/**
* @desc The timeout given in seconds after which the test case will be stopped.
*/
modulepar float PX_TC_EXECUTION_TIMEOUT := 5.0;
type universal charstring Raw;
type port P message {
inout all;
}
type component C {
port P p;
}
testcase TC_Pos_0608_anytype_and_anysimpletype_types_007() runs on C system C {
var Raw v_rcv;
map(self:p, system:p);
// encode the message
p.send(m_msg);
alt {
[] p.check(receive(Raw:?) -> value v_rcv) {
log("XML message ", v_rcv);
alt {
// match decoded value to pass test
[] p.receive(m_msg) {
setverdict(pass, "Decoded value matches encoded template");
}
[] p.receive {
setverdict(fail, "XML decoding failure");
}
}
}
[] p.receive {
setverdict(fail, "Raw decoding failure");
}
}
}
control {
execute(TC_Pos_0608_anytype_and_anysimpletype_types_007(), PX_TC_EXECUTION_TIMEOUT);
}
}
<?xml version="1.0" encoding="utf-8"?>
<ns:MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="schema:Pos_0608_anytype_and_anysimpletype_types_007">
<ns:something>1</ns:something>
</ns:MyType>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="schema:Pos_0608_anytype_and_anysimpletype_types_007"
xmlns:ns="schema:Pos_0608_anytype_and_anysimpletype_types_007">
<xsd:element name='MyType' type='xsd:anyType'/>
<xsd:element name='something' type='xsd:int'/>
<xsd:attribute name='someattr' type='xsd:string'/>
</xsd:schema>
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 9:7.5.3, Verify transformation of union restricted by enum facets (anonymous union members)
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
module Pos_070503_derivation_by_union_007 {
import from schema_Pos_070503_derivation_by_union_007 language "XSD" all;
template MyType m_msg := { xsiType := alt_, content := x20 };
/**
* @desc The timeout given in seconds after which the test case will be stopped.
*/
modulepar float PX_TC_EXECUTION_TIMEOUT := 5.0;
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_070503_derivation_by_union_007() 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_070503_derivation_by_union_007.xml", { "Pos_070503_derivation_by_union_007.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_070503_derivation_by_union_007(), PX_TC_EXECUTION_TIMEOUT);
}
}
<?xml version="1.0" encoding="utf-8"?>
<ns:MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="schema:Pos_070503_derivation_by_union_007">20</ns:MyType>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="schema:Pos_070503_derivation_by_union_007"
xmlns:ns="schema:Pos_070503_derivation_by_union_007">
<xsd:simpleType name="e21unnamed">
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:float"/>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:integer"/>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
<xsd:element name="MyType">
<xsd:simpleType>
<xsd:restriction base="ns:e21unnamed">
<xsd:enumeration value="20"/>
<xsd:enumeration value="50.0"/>
<xsd:enumeration value="small-1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 9:7.5.3, Verify transformation of union restricted by enum facets (referenced union members)
** @verdict pass accept, ttcn3verdict:pass
***************************************************/
module Pos_070503_derivation_by_union_008 {
import from schema_Pos_070503_derivation_by_union_008 language "XSD" all;
template MyType m_msg := { xsiType := integer_, content := x20 };
/**
* @desc The timeout given in seconds after which the test case will be stopped.
*/
modulepar float PX_TC_EXECUTION_TIMEOUT := 5.0;
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_070503_derivation_by_union_008() 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_070503_derivation_by_union_008.xml", { "Pos_070503_derivation_by_union_008.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_070503_derivation_by_union_008(), PX_TC_EXECUTION_TIMEOUT);
}
}
<?xml version="1.0" encoding="utf-8"?>
<ns:MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:integer" xmlns:ns="schema:Pos_070503_derivation_by_union_008">20</ns:MyType>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="schema:Pos_070503_derivation_by_union_008"
xmlns:ns="schema:Pos_070503_derivation_by_union_008">
<xsd:simpleType name="e21memberlist">
<xsd:union memberTypes="xsd:integer xsd:boolean xsd:string "/>
</xsd:simpleType>
<xsd:element name="MyType">
<xsd:simpleType>
<xsd:restriction base="ns:e21memberlist">
<xsd:enumeration value="20"/>
<xsd:enumeration value="50.0"/>
<xsd:enumeration value="small-1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 9:7.7.1, Verify conversion of the any element to TTCN-3 anytype
** @verdict pass accept, ttcn3verdict:pass
** @configuration any_to_anytype
***************************************************/
module Pos_070701_the_any_element_007 {
import from schema_Pos_070701_the_any_element_007 language "XSD" all;
template MyType m_msg := { elem := { Test := "abc" } };
/**
* @desc The timeout given in seconds after which the test case will be stopped.
*/
modulepar float PX_TC_EXECUTION_TIMEOUT := 5.0;
type universal charstring Raw;
type port P message {
inout all;
}
type component C {
port P p;
}
testcase TC_Pos_070701_the_any_element_007() runs on C system C {
var Raw v_rcv;
map(self:p, system:p);
// encode the message
p.send(m_msg);
alt {
[] p.check(receive(Raw:?) -> value v_rcv) {
log("XML message ", v_rcv);
alt {
// match decoded value to pass test
[] p.receive(m_msg) {
setverdict(pass, "Decoded value matches encoded template");
}
[] p.receive {
setverdict(fail, "XML decoding failure");
}
}
}
[] p.receive {
setverdict(fail, "Raw decoding failure");
}
}
}
control {
execute(TC_Pos_070701_the_any_element_007(), PX_TC_EXECUTION_TIMEOUT);
}
}
<?xml version="1.0" encoding="utf-8"?>
<ns:MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="schema:Pos_070701_the_any_element_007">
<ns:test>abc</ns:test>
</ns:MyType>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="schema:Pos_070701_the_any_element_007"
xmlns:ns="schema:Pos_070701_the_any_element_007">
<xsd:element name="test" type="xsd:string"></xsd:element>
<xsd:element name="MyType">
<xsd:complexType>
<xsd:sequence>
<xsd:any namespace="##any"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
/***************************************************
** @author STF 548
** @version 0.0.1
** @purpose 9:7.7.2, Verify conversion of anyAttribute element to TTCN-3 anytype
** @verdict pass accept, ttcn3verdict:pass
** @configuration any_to_anytype
***************************************************/
module Pos_070702_the_anyattribute_element_006 {
import from schema_Pos_070702_the_anyattribute_element_006 language "XSD" all;
template MyType m_msg := { attr := { {Bar := "bar"}, { Foo := "foo" } }, base := "Hello world!" };
/**
* @desc The timeout given in seconds after which the test case will be stopped.
*/
modulepar float PX_TC_EXECUTION_TIMEOUT := 5.0;
type universal charstring Raw;
type port P message {
inout all;
}
type component C {
port P p;
}
testcase TC_Pos_070702_the_anyattribute_element_006() runs on C system C {
var Raw v_rcv;
map(self:p, system:p);
// encode the message
p.send(m_msg);
alt {
[] p.check(receive(Raw:?) -> value v_rcv) {
log("XML message ", v_rcv);
alt {
// match decoded value to pass test
[] p.receive(m_msg) {
setverdict(pass, "Decoded value matches encoded template");
}
[] p.receive {
setverdict(fail, "XML decoding failure");
}
}
}
[] p.receive {
setverdict(fail, "Raw decoding failure");
}
}
}
control {
execute(TC_Pos_070702_the_anyattribute_element_006(), PX_TC_EXECUTION_TIMEOUT);
}
}
<?xml version="1.0" encoding="utf-8"?>
<ns:MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ns:bar="bar" ns:foo="foo" xmlns:ns="schema:Pos_070702_the_anyattribute_element_006">Hello world!</ns:MyType>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="schema:Pos_070702_the_anyattribute_element_006"
xmlns:ns="schema:Pos_070702_the_anyattribute_element_006">
<attribute name="foo" type="string"/>
<attribute name="bar" type="string"/>
<element name="MyType">
<complexType>
<simpleContent>
<extension base="string">
<anyAttribute namespace="##targetNamespace"/>
</extension>
</simpleContent>
</complexType>
</element>
</schema>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment