Commit | Line | Data |
---|---|---|
970ed795 | 1 | /****************************************************************************** |
d44e3c4f | 2 | * Copyright (c) 2000-2016 Ericsson Telecom AB |
970ed795 EL |
3 | * All rights reserved. This program and the accompanying materials |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
d44e3c4f | 7 | * |
8 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Raduly, Csaba | |
11 | * Szabados, Kristof | |
12 | * | |
970ed795 EL |
13 | ******************************************************************************/ |
14 | module xmlTest_encDec | |
15 | { | |
16 | ||
17 | //========================================================================= | |
18 | // Import Part | |
19 | //========================================================================= | |
20 | //import from XSD all; | |
21 | // import from PIPEasp_Types all; | |
22 | // import from PIPEasp_PortType all; | |
23 | // import from PIPEasp_Templates all; | |
24 | // import from xmlTest_Shell all; | |
25 | import from www_XmlTest_org_complex1_e all; | |
26 | ||
27 | external function f_enc_InternationalPrice(in InternationalPrice pdu, out octetstring stream) | |
28 | with { extension "prototype(fast) encode(XER:XER_EXTENDED)" } | |
29 | //0: OK | |
30 | //1: NOK | |
31 | ||
32 | external function f_dec_InternationalPrice(in octetstring stream, out InternationalPrice pdu) return integer | |
33 | with { extension "prototype(backtrack) decode(XER:XER_EXTENDED)" } | |
34 | ||
35 | //Encoding decoding test: | |
36 | function f_encDecTest_InternationalPrice() { | |
37 | var InternationalPrice vl_pdu:= { | |
38 | currency:="US", | |
39 | base:=54321.9 | |
40 | },vl_decodedPdu; | |
41 | var octetstring vl_expectedEncodedPdu:=char2oct("<ns:InternationalPrice ns:currency='US' xmlns:ns='www.XmlTest.org/complex1_e'>54321.900000</ns:InternationalPrice>\n\n") | |
42 | ; | |
43 | var octetstring vl_stream:=''O; | |
44 | ||
45 | f_enc_InternationalPrice(vl_pdu,vl_stream); | |
46 | if( not match(vl_stream,vl_expectedEncodedPdu)) { | |
47 | log("Actual encoded value: ", vl_stream); | |
48 | setverdict(fail); | |
49 | } | |
50 | ||
51 | //Check value decoded from the encoded vs original value: | |
52 | //log("Decoding comes"); | |
53 | var integer vl_retval:=f_dec_InternationalPrice(vl_stream, vl_decodedPdu); | |
54 | //log("retval:",vl_retval); | |
55 | if(f_dec_InternationalPrice(vl_stream, vl_decodedPdu)==0) { | |
56 | //log("The decoded pdu: ", vl_decodedPdu); | |
57 | if(match(vl_pdu,vl_decodedPdu)) { | |
58 | setverdict(pass); | |
59 | } else { | |
60 | log("Pdu could not decoded"); | |
61 | log(match(vl_pdu,vl_decodedPdu)); | |
62 | } | |
63 | } | |
64 | ||
65 | //Check value decoded from the expected value vs original value: | |
66 | if( f_dec_InternationalPrice(vl_expectedEncodedPdu, vl_decodedPdu)==0) { | |
67 | //log("The decoded pdu: ", vl_decodedPdu); | |
68 | if(match(vl_pdu,vl_decodedPdu)) { | |
69 | setverdict(pass); | |
70 | } else { | |
71 | log("Pdu could not decoded from the expected value"); | |
72 | log(match(vl_pdu,vl_decodedPdu)); | |
73 | } | |
74 | } | |
75 | ||
76 | } | |
77 | ||
78 | ||
79 | }//module |