/***************************************************
 ** @author   STF 475
 ** @version  0.0.1
 ** @purpose  9:7.1.1
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/
module Pos_070101_id_001 {

    import from schema_Pos_070101_id_001 language "XSD" all;
    // TODO specify type for the template
    template __type__ m_msg := { };



    type universal charstring Raw;
    type universal charstring XsdFile;
    type record of XsdFile XsdFileList;

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

	external function matchFile(Raw p_textToMatch, XsdFile p_referenceXmlFile, XsdFileList p_xsdFileList, out universal charstring p_matchError) return boolean;

    testcase TC_Pos_070101_id_001() runs on C system C {
        var Raw v_rcv;
        var charstring v_matchError;
        map(self:p, system:p);
        p.send(m_msg);
        alt {
            []	p.check(receive(Raw:?) -> value v_rcv) {
            	log("XML message ", v_rcv);
                if (matchFile(v_rcv, "Pos_070101_id_001.xml", { "Pos_070101_id_001.xsd" }, v_matchError)) {
                    alt {
                        [] 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_070101_id_001(), 5.0);
    }

}
