/***************************************************
 ** @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);
    }


}
