Commit 02d2b186 authored by pintar's avatar pintar
Browse files

New tests for clause 6.1.5

parent 1b524214
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 475
 ** @version  0.0.1
 ** @purpose  9:6.1.5, Verify if tool rejects validation in case of restricted value due xsd type declaration.
 ** @verdict  pass reject
 ***************************************************/
module Neg_060105_enumeration_001 {

    import from schema_Neg_060105_enumeration_001 language "XSD" all;
    
    template E1 m_msg :=5;



    type universal charstring Raw;

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

    testcase TC_Neg_060105_enumeration_001() runs on C system C {
        map(self:p, system:p);

		// encode the message
        p.send(m_msg);
		log("template should either be rejected by compiler or by runtime latest while encoding");

        setverdict(fail, "Invalid template should not be encoded");

        unmap(self:p, system:p);
    }

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

}
+17 −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:Neg_060105_enumeration_001"
    xmlns:ns="schema:Neg_060105_enumeration_001">
      <simpleType name="t1">
        <restriction>
          <simpleType>
            <restriction base="integer">
              <minInclusive value="1"/>
              <maxInclusive value="10"/>
            </restriction>
          </simpleType>
          <minExclusive value="5"/>
        </restriction>
      </simpleType>
    <element name="e1" type="ns:t1"/>
</schema>
 No newline at end of file
+40 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 475
 ** @version  0.0.1
 ** @purpose  9:6.1.5, Verify if tool rejects validation in case of restricted value due xsd type declaration.
 ** @verdict  pass reject
 ***************************************************/
module Neg_060105_enumeration_002 {

    import from schema_Neg_060105_enumeration_002 language "XSD" all;
    
    template E1 m_msg := black;



    type universal charstring Raw;

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

    testcase TC_Neg_060105_enumeration_002() runs on C system C {
        map(self:p, system:p);

		// encode the message
        p.send(m_msg);
		log("template should either be rejected by compiler or by runtime latest while encoding");

        setverdict(fail, "Invalid template should not be encoded");

        unmap(self:p, system:p);
    }

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

}
+19 −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:Neg_060105_enumeration_002"
    xmlns:ns="schema:Neg_060105_enumeration_002">
      <simpleType name="t1">
        <restriction>
          <simpleType>
            <restriction base="string">
              <enumeration value="white"/>
              <enumeration value="black"/>
              <enumeration value="red"/>
            </restriction>
          </simpleType>
          <minLength value="2"/>
          <maxLength value="4"/>
        </restriction>
      </simpleType>
    <element name="e1" type="ns:t1"/>
</schema>
 No newline at end of file
+75 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 475
 ** @version  0.0.1
 ** @purpose  9:6.1.5, Verify mapping of simple type definition that is a restriction of
 **           string type with an enumeration facet.
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/
module Pos_060105_enumeration_001 {

    import from schema_Pos_060105_enumeration_001 language "XSD" all;
    
    template E1 m_msg := on_;


    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_060105_enumeration_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_060105_enumeration_001.xml", { "Pos_060105_enumeration_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_060105_enumeration_001(), 5.0);
    }

}
Loading