Commit | Line | Data |
---|---|---|
970ed795 | 1 | /****************************************************************************** |
3abe9331 | 2 | * Copyright (c) 2000-2015 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 | |
7 | ******************************************************************************/ | |
8 | module HN15589 { | |
9 | modulepar boolean Namespaces_verbose := false; | |
10 | #define verbose Namespaces_verbose | |
11 | #include "../macros.ttcnin" | |
12 | ||
13 | import from xtdp all; | |
14 | ||
15 | type component HN {} | |
16 | ||
17 | group xtdl { | |
18 | type union GroupA | |
19 | { | |
20 | universal charstring elem_A | |
21 | } | |
22 | with { | |
23 | variant "untagged"; | |
24 | variant (elem_A) "name as capitalized"; | |
25 | }; | |
26 | } | |
27 | with { | |
28 | variant "namespace as 'urn:xtdl' prefix 'xtdl' " | |
29 | variant "elementFormQualified"; | |
30 | } | |
31 | ||
32 | group xtdp { | |
33 | // in the original, xtdl is included by xtdp | |
34 | type record ComplexB | |
35 | { | |
36 | GroupA groupA | |
37 | } | |
38 | // GroupA is untagged, so the namespace is redundant | |
39 | //with { | |
40 | // variant (groupA) "namespace as 'urn:xtdl' prefix 'xtdl'"; | |
41 | //}; | |
42 | ||
43 | ||
44 | type record Elem_B | |
45 | { | |
46 | ComplexB subElem_B | |
47 | } | |
48 | with { | |
49 | variant "element"; | |
50 | }; | |
51 | ||
52 | } | |
53 | with { | |
54 | variant "namespace as 'urn:xtdp' "; // no prefix | |
55 | // by default, form is unqualified for local types | |
56 | } | |
57 | ||
58 | external function enc_Elem_B (in Elem_B p_message) return octetstring | |
59 | with {extension "prototype(convert) encode (XER:XER_EXTENDED)"} | |
60 | ||
61 | external function dec_Elem_B (in octetstring p_oct, out Elem_B p_message) return integer | |
62 | with {extension "prototype(backtrack) decode (XER:XER_EXTENDED) errorbehavior(ALL:WARNING)"} | |
63 | ||
64 | const charstring expected := | |
65 | "<tq0002:Elem_B xmlns:tq0002='urn:xtdp' xmlns:tq0001='urn:xtdl'>\n" & | |
66 | "\t<subElem_B>\n" & | |
67 | "\t\t<tq0001:Elem_A>B</tq0001:Elem_A>\n" & | |
68 | "\t</subElem_B>\n" & | |
69 | "</tq0002:Elem_B>\n\n"; | |
70 | ||
71 | const octetstring exp_o := char2oct(expected); | |
72 | ||
73 | testcase tc_encdec() runs on HN | |
74 | { | |
75 | var octetstring encoded := enc_Elem_B({subElem_B:= {groupA := {elem_A:="B"}}}); | |
76 | //action(encoded); | |
77 | ||
78 | var Elem_B b; | |
79 | // decode what we encoded | |
80 | var integer rez := dec_Elem_B(encoded, b); | |
81 | if (rez == 0) { setverdict(pass); } | |
82 | else { setverdict(fail, "Retcode=", rez); } | |
83 | ||
84 | if (encoded == exp_o) { setverdict(pass); } | |
85 | else { | |
86 | setverdict(fail, "mismatch: "); | |
87 | log("G0T: ", encoded); | |
88 | log("EXP: ", exp_o); | |
89 | } | |
90 | ||
91 | // decode what we think should be encoded | |
92 | rez := dec_Elem_B(exp_o, b); | |
93 | if (rez == 0) { setverdict(pass); } | |
94 | else { setverdict(fail, "Retcode=", rez); } | |
95 | ||
96 | // decode what we encoded | |
97 | rez := dec_Elem_B(encoded, b); | |
98 | if (rez == 0) { setverdict(pass); } | |
99 | else { setverdict(fail, "Retcode=", rez); } | |
100 | ||
101 | } | |
102 | ||
103 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
104 | ||
105 | group FlipFlop { | |
106 | type record Outer { | |
107 | Inner i | |
108 | } | |
109 | with { | |
110 | variant "element"; | |
111 | } | |
112 | ||
113 | type record Inner { | |
114 | Inner2 i2 | |
115 | } // unqualified by default | |
116 | with { | |
117 | variant (i2) "form as qualified"; | |
118 | } | |
119 | ||
120 | type record Inner2 { | |
121 | record of Vec3 v3_list | |
122 | } | |
123 | with { | |
124 | // variant "element"; | |
125 | variant (v3_list) "untagged" | |
126 | variant (v3_list[-]) "name as 'v3' " | |
127 | } | |
128 | ||
129 | type record Vec3 { | |
130 | Vec4 v4 | |
131 | } | |
132 | with { | |
133 | variant (v4) "form as qualified" | |
134 | } | |
135 | ||
136 | type record Vec4 { | |
137 | record of U5 u5_list | |
138 | } | |
139 | with { | |
140 | variant (u5_list) "untagged" | |
141 | variant (u5_list[-]) "name as 'u5'" | |
142 | } | |
143 | ||
144 | type record U5 { | |
145 | union { | |
146 | U6 u6, | |
147 | record {} e6 | |
148 | } choice | |
149 | } | |
150 | with { | |
151 | variant (choice) "untagged" | |
152 | } | |
153 | ||
154 | type union U6 { | |
155 | charstring s, | |
156 | record {} e | |
157 | } | |
158 | ||
159 | } // group | |
160 | with { | |
161 | variant "namespace as 'urn:xtdp' "; // no prefix; same URI as above | |
162 | } | |
163 | ||
164 | external function enc_Outer (in Outer p_message) return octetstring | |
165 | with {extension "prototype(convert) encode (XER:XER_EXTENDED)"} | |
166 | ||
167 | external function dec_Outer (in octetstring p_oct, out Outer p_message) return integer | |
168 | with {extension "prototype(backtrack) decode (XER:XER_EXTENDED) errorbehavior(ALL:WARNING)"} | |
169 | ||
170 | const charstring outstr := | |
171 | "<tq0002:Outer xmlns:tq0002='urn:xtdp'>\n" & | |
172 | "\t<i>\n" & | |
173 | "\t\t<tq0002:i2>\n" & | |
174 | "\t\t\t<v3>\n" & | |
175 | "\t\t\t\t<tq0002:v4>\n" & | |
176 | "\t\t\t\t\t<u5>\n" & | |
177 | "\t\t\t\t\t\t<u6>\n" & | |
178 | "\t\t\t\t\t\t\t<s>Hello</s>\n" & | |
179 | "\t\t\t\t\t\t</u6>\n" & | |
180 | "\t\t\t\t\t</u5>\n" & | |
181 | "\t\t\t\t\t<u5>\n" & | |
182 | "\t\t\t\t\t\t<u6>\n" & | |
183 | "\t\t\t\t\t\t\t<e/>\n" & | |
184 | "\t\t\t\t\t\t</u6>\n" & | |
185 | "\t\t\t\t\t</u5>\n" & | |
186 | "\t\t\t\t\t<u5>\n" & | |
187 | "\t\t\t\t\t\t<e6/>\n" & | |
188 | "\t\t\t\t\t</u5>\n" & | |
189 | "\t\t\t\t</tq0002:v4>\n" & | |
190 | "\t\t\t</v3>\n" & | |
191 | "\t\t</tq0002:i2>\n" & | |
192 | "\t</i>\n" & | |
193 | "</tq0002:Outer>\n\n"; | |
194 | //const octetstring ooo := char2oct(outstr); | |
195 | ||
196 | testcase tc_flipflop() runs on HN | |
197 | { | |
198 | const Outer limits := { | |
199 | i := { | |
200 | i2 := { | |
201 | v3_list := { | |
202 | { | |
203 | v4 := { | |
204 | u5_list := { | |
205 | { | |
206 | choice := { | |
207 | u6 := { | |
208 | s := "Hello" | |
209 | } | |
210 | } | |
211 | }, | |
212 | { | |
213 | choice := { | |
214 | u6 := { | |
215 | e := {} | |
216 | } | |
217 | } | |
218 | }, | |
219 | { | |
220 | choice := { | |
221 | e6 := {} | |
222 | } | |
223 | } | |
224 | } | |
225 | } | |
226 | } | |
227 | // { // Vec4 | |
228 | // /* U5 */ { u6 := { s := "Hello"} }, | |
229 | // /* U5 */ { u6 := { e := { } } }, | |
230 | // /* U5 */ { e6 := {} } | |
231 | // } | |
232 | } | |
233 | } | |
234 | } | |
235 | } | |
236 | var octetstring encoded := enc_Outer(limits); | |
237 | action(encoded); | |
238 | ||
239 | var charstring s_encoded := oct2char(encoded); | |
240 | ||
241 | if (match(s_encoded, outstr)) { setverdict(pass); } | |
242 | else { setverdict(fail, match(s_encoded, outstr) ); } | |
243 | ||
244 | var Outer space; | |
245 | var integer rez := dec_Outer(encoded, space); | |
246 | if (rez == 0) { setverdict(pass); } | |
247 | else { | |
248 | setverdict(fail, "result=", rez); | |
249 | } | |
250 | if (match(space, limits)) { setverdict(pass); } | |
251 | else { setverdict(fail, match(space, limits) ); } | |
252 | } | |
253 | ||
254 | /* * * * * * * * * * * * * * * * * * */ | |
255 | external function enc_msg (in XTDP_Message p_oct) return octetstring | |
256 | with {extension "prototype(convert) encode (XER:XER_EXTENDED) errorbehavior(ALL:WARNING)"} | |
257 | ||
258 | external function dec_msg (in octetstring o) return XTDP_Message | |
259 | with {extension "prototype(convert) decode (XER:XER_EXTENDED) errorbehavior(ALL:WARNING)"} | |
260 | ||
261 | const XTDP_Message source_message := { | |
262 | transactionID := 2, | |
263 | choice := { | |
264 | xTDP_AddRequests := { | |
265 | xTDP_AddRequest_list := { | |
266 | { | |
267 | requestId := 2, | |
268 | parentWidgetId := omit, | |
269 | widgets := { | |
270 | window := { | |
271 | height := 300.000000, | |
272 | id := "MyNewEPTFMainWindow", | |
273 | orientation := vertical, | |
274 | title := "My TTCN constructed window", | |
275 | width := 800.000000, | |
276 | image_list := { | |
277 | }, | |
278 | embeddedwidgets := { | |
279 | embeddedwidget_list := { | |
280 | { | |
281 | tabbox := { | |
282 | disabled := omit, | |
283 | flex := omit, | |
284 | id := "EPTF_Main_Tabbox", | |
285 | layout := omit, | |
286 | tabs := { | |
287 | {} | |
288 | }, | |
289 | tabpanels := { | |
290 | {} | |
291 | } | |
292 | } | |
293 | } | |
294 | } | |
295 | } | |
296 | } | |
297 | } | |
298 | } | |
299 | } | |
300 | } | |
301 | } | |
302 | } | |
303 | ||
304 | testcase tc_xtdp() runs on HN // not from control part | |
305 | { | |
306 | var octetstring o := enc_msg(source_message); | |
307 | action(o); | |
308 | ||
309 | var XTDP_Message roundtrip := dec_msg(o); | |
310 | if (roundtrip == source_message) { setverdict(pass); } | |
311 | else { setverdict(fail); } | |
312 | } | |
313 | ||
314 | control { | |
315 | execute(tc_encdec()); | |
316 | execute(tc_flipflop()); | |
317 | } | |
318 | ||
319 | } | |
320 | with { | |
321 | encode "XML"; | |
322 | variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; | |
323 | } | |
324 |