Last sync 2016.04.01
[deliverable/titan.core.git] / regression_test / XML / HR49727 / HR49727.ttcn
CommitLineData
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 * Ormandi, Matyas
11 *
970ed795
EL
12 ******************************************************************************/
13module HR49727 {
14
15import from http_jabber_org_protocol_pubsub all;
16import from http_jabber_org_protocol_pubsub_event all;
17
18
19//http_jabber_org_protocol_pubsub
20external function enc_Pubsub(in http_jabber_org_protocol_pubsub.Pubsub pdu) return octetstring
21with { extension "prototype (convert) encode(XER:XER_EXTENDED)" };
22external function dec_Pubsub(in octetstring stream) return http_jabber_org_protocol_pubsub.Pubsub
23with { extension "prototype (convert) decode(XER:XER_EXTENDED)" } ;
24
25//http_jabber_org_protocol_pubsub_event
26external function enc_Pubsub_Event(in http_jabber_org_protocol_pubsub_event.Event pdu) return octetstring
27with { extension "prototype (convert) encode(XER:XER_EXTENDED)" };
28external function dec_Pubsub_Event(in octetstring stream) return http_jabber_org_protocol_pubsub_event.Event
29with {
30 extension "prototype (convert) decode(XER:XER_EXTENDED)"
31 extension "errorbehavior(ALL:ERROR)"
32} ;
33
34
35type component szappan {}
36
37const charstring s1 := "<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">
38 <items node=\"toaster@esekilxxen1845.rnd.ericsson.se/1\">
39 <item id=\"toaster@esekilxxen1845.rnd.ericsson.se/1#always_on\">
40 <entry xmlns=\"http://ntaforum.org/2011/registry\">
41 <toolType>http://Example.org/tools/ttcn/titan</toolType>
42 <version>1.2.3.4567</version>
43 <published>2013-03-11T11:30:02-08:00</published>
44 <harness xmlns=\"http://ntaforum.org/2011/harness\" name=\"http://Example.org/ttcn/titan\">
45 <supportedMode>invisible_and_automated</supportedMode>
46 <supportedMode>visible_and_interactive</supportedMode>
47 </harness>
48<documentation xml:lang=\"en\">
49<vendor>TTCNTestTools</vendor>
50<name>TCC</name>
51<description>Automated Toaster</description>
52</documentation>
53<location>
54<workspaceID>0d9374c4-aa1e-47f5-8b61-98bae0ad8ca1</workspaceID>
55<ipv4>127.0.0.1</ipv4>
56<hostname>localhost</hostname>
57<description>1stfloor,bldg.A,BudapestHQ</description>
58</location>
59</entry></item></items></pubsub>"
60
61const http_jabber_org_protocol_pubsub.Pubsub v_Pubsub:= { choice :=
62 { choice_list :=
63 { { items :=
64 { max_items := omit,
65 node := "toaster@esekilxxen1845.rnd.ericsson.se/1",
66 subid := omit,
67 item_list := { {
68 id := "toaster@esekilxxen1845.rnd.ericsson.se/1#always_on",
69 sequence := {elem:="<entry xmlns=\"http://ntaforum.org/2011/registry\">
70 <toolType>http://Example.org/tools/ttcn/titan</toolType>
71 <version>1.2.3.4567</version>
72 <published>2013-03-11T11:30:02-08:00</published>
73 <harness xmlns=\"http://ntaforum.org/2011/harness\" name=\"http://Example.org/ttcn/titan\">
74 <supportedMode>invisible_and_automated</supportedMode>
75 <supportedMode>visible_and_interactive</supportedMode>
76 </harness>
77<documentation xml:lang=\"en\">
78<vendor>TTCNTestTools</vendor>
79<name>TCC</name>
80<description>Automated Toaster</description>
81</documentation>
82<location>
83<workspaceID>0d9374c4-aa1e-47f5-8b61-98bae0ad8ca1</workspaceID>
84<ipv4>127.0.0.1</ipv4>
85<hostname>localhost</hostname>
86<description>1stfloor,bldg.A,BudapestHQ</description>
87</location>
88</entry>" }}
89 }
90
91 }
92 } }
93 }
94 }
95
96const http_jabber_org_protocol_pubsub_event.Event v_Event:=
97{ choice := { items := { node := "toaster@esekilxxen1843.rnd.ericsson.se/1", choice := { item_list := { { id := "toaster@esekilxxen1843.rnd.ericsson.se/1#always_on", node := omit, publisher := omit, choice := { elem := "<tq0002:ele xmlns:tq0002=\"http://anything\"><a/></tq0002:ele>" } } } } } } }
98
99testcase decode() runs on szappan
100{
101 log("\nxml to decode:\n",s1);
102 var http_jabber_org_protocol_pubsub.Pubsub result := dec_Pubsub(char2oct(s1));
103 log("\ndecoded:\n",result);
104 if ( match(result,v_Pubsub) ) { setverdict(pass); } else { setverdict(fail, match(result,v_Pubsub)); }
105}
106
107testcase encode_decode() runs on szappan
108{
109 log("\nvar to encode:\n", v_Pubsub);
110 var octetstring encoded := enc_Pubsub(v_Pubsub);
111 log("\nencoded:\n", oct2char(encoded));
112 var http_jabber_org_protocol_pubsub.Pubsub decoded := dec_Pubsub(encoded);
113 log ("\nre-decoded\n", decoded);
114 if ( match(decoded,v_Pubsub) ) { setverdict(pass); } else { setverdict(fail, match(decoded,v_Pubsub)); }
115}
116
117
118testcase decode_untagged_empty() runs on szappan
119{
120 var charstring s2:="<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">\n<retract node=\"acme_proxy@mycorp.com/2\">\n<item id=\"acme_proxy@mycorp.com/2#sleeper1\"/>\n</retract>\n</pubsub>"
121 var Pubsub dec_s2_exp := { choice := { choice_list := { { retract := { node := "acme_proxy@mycorp.com/2", notify := omit, item_list := { { id := "acme_proxy@mycorp.com/2#sleeper1", sequence := omit } } } } } } }
122 var Pubsub decoded := dec_Pubsub(char2oct(s2));
123 log("\nxml to be decoded:\n", s2,"\nDecoded Pubsub: ", dec_Pubsub(char2oct(s2)));
124 if ( match(decoded,dec_s2_exp) ) { setverdict(pass); } else { setverdict(fail, match(decoded,dec_s2_exp)); }
125}
126
127testcase decode_encoded_union() runs on szappan
128{
129 var charstring s := "<tq0001:event xmlns:tq0001='http://jabber.org/protocol/pubsub#event'>\n\t<tq0001:items node='toaster@esekilxxen1843.rnd.ericsson.se/1'>\n\t\t<tq0001:item id='toaster@esekilxxen1843.rnd.ericsson.se/1#always_on'>\n\t\t\t<tq0002:ele xmlns:tq0002='http://anything'><a></a></tq0002:ele>\n\t\t</tq0001:item>\n\t</tq0001:items>\n</tq0001:event>\n\n"
130 var http_jabber_org_protocol_pubsub_event.Event dec := dec_Pubsub_Event(char2oct(s))
131 log("\n Event:\n",s, "\ndecoded:\n", dec, "\n")
132 if ( match(dec,v_Event) ) { setverdict(pass); } else { setverdict(fail, match(dec,v_Event)); }
133}
134
135control{
136 execute(decode());
137 execute(encode_decode());
138 execute(decode_untagged_empty());
139 execute(decode_encoded_union());
140}
141
142}
This page took 0.030624 seconds and 5 git commands to generate.