4
%% Copyright Ericsson AB 1999-2011. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
20
%%-----------------------------------------------------------------
23
%% Test suite for the CDR encode/decode functions
25
%%-----------------------------------------------------------------
26
-module(cdrcoding_10_SUITE).
29
-include("idl_output/Module.hrl").
30
-include_lib("test_server/include/test_server.hrl").
31
-include_lib("orber/include/corba.hrl").
32
-include_lib("orber/src/orber_iiop.hrl").
34
-define(default_timeout, ?t:minutes(20)).
36
%%-----------------------------------------------------------------
38
%%-----------------------------------------------------------------
39
-export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]).
41
%%-----------------------------------------------------------------
43
%%-----------------------------------------------------------------
46
%%-----------------------------------------------------------------
50
%%-----------------------------------------------------------------
51
suite() -> [{ct_hooks,[ts_install_cth]}].
58
[do_register, null_type, void_type, principal_type,
59
objref_type, struct_type, union_type, string_type,
60
array_type, any_type, typecode_type, alias_type,
61
exception_type, do_unregister]}].
63
init_per_group(_GroupName, Config) ->
66
end_per_group(_GroupName, Config) ->
71
[{group, types}, reply, cancel_request,
72
close_connection, message_error].
73
%% request, locate_request, locate_reply].
75
%%-----------------------------------------------------------------
76
%% Init and cleanup functions.
77
%%-----------------------------------------------------------------
79
init_per_testcase(_Case, Config) ->
80
Path = code:which(?MODULE),
81
code:add_pathz(filename:join(filename:dirname(Path), "idl_output")),
82
?line Dog=test_server:timetrap(?default_timeout),
83
[{watchdog, Dog}|Config].
86
end_per_testcase(_Case, Config) ->
87
Path = code:which(?MODULE),
88
code:del_path(filename:join(filename:dirname(Path), "idl_output")),
89
Dog = ?config(watchdog, Config),
90
test_server:timetrap_cancel(Dog),
93
init_per_suite(Config) when is_list(Config) ->
99
exit("Config not a list")
102
end_per_suite(Config) when is_list(Config) ->
106
%%-----------------------------------------------------------------
107
%% Test Case: type encoding tests
108
%% Description: Just testing the complex types, the others are
109
%% tested in the cdrlib SUITE.
110
%%-----------------------------------------------------------------
111
%types(Config) when list(Config) ->
112
% 'oe_orber_test':'oe_register'(),
125
% 'oe_orber_test':'oe_unregister'(),
128
do_register(doc) -> [];
129
do_register(suite) -> [];
130
do_register(Config) when is_list(Config) ->
131
io:format("Pwd: ~p, mod: ~p~n",[c:pwd(), c:m('oe_orber_test')]),
132
'oe_orber_test':'oe_register'(),
134
do_unregister(doc) -> [];
135
do_unregister(suite) -> [];
136
do_unregister(Config) when is_list(Config) ->
137
'oe_orber_test':'oe_unregister'(),
139
%%-----------------------------------------------------------------
140
%% Encode/decode test of type: null
141
%%-----------------------------------------------------------------
142
null_type(doc) -> [];
143
null_type(suite) -> [];
144
null_type(Config) when is_list(Config) ->
145
?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_null', 'null'),
146
?line {'null', <<>>, _} = cdr_decode:dec_type('tk_null', {1, 0}, B, 0, big),
149
%%-----------------------------------------------------------------
150
%% Encode/decode test of type: void
151
%%-----------------------------------------------------------------
152
void_type(doc) -> [];
153
void_type(suite) -> [];
154
void_type(Config) when is_list(Config) ->
155
?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_void', 'ok'),
156
?line {'ok', <<>>, _} = cdr_decode:dec_type('tk_void', {1, 0}, B, 0, big),
159
%%-----------------------------------------------------------------
160
%% Encode/decode test of type: principal
161
%%-----------------------------------------------------------------
162
principal_type(doc) -> [];
163
principal_type(suite) -> [];
164
principal_type(Config) when is_list(Config) ->
165
?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_Principal', "principal"),
166
?line {"principal", <<>>, _} = cdr_decode:dec_type('tk_Principal', {1, 0}, B0, 0, big),
167
?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_Principal', ""),
168
?line {"", <<>>, _} = cdr_decode:dec_type('tk_Principal', {1, 0}, B1, 0, big),
169
?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_Principal', "principal"),
170
?line {"principal", <<>>, _} =
171
cdr_decode:dec_type('tk_Principal', {1, 0}, B2, 0, big),
174
%%-----------------------------------------------------------------
175
%% Encode/decode test of type: object reference
176
%%-----------------------------------------------------------------
177
version() -> #'IIOP_Version'{major=1,minor=0}.
180
PB = #'IIOP_ProfileBody_1_0'{iiop_version=version(),
181
host="my.hostname.org",
183
object_key="ExternalKey: which is an arbitary octet sequence"},
184
TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB},
185
#'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]};
187
K = corba_fake_mk_objkey("IDL:Module/Interface:1.0", key,
188
list_to_pid("<0.100.0>")),
189
PB = #'IIOP_ProfileBody_1_0'{iiop_version=version(),
190
host="my.hostname.org",
193
TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB},
194
#'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]};
196
K = corba_fake_mk_objkey("IDL:Module/Interface:1.0", registered,
197
list_to_atom("orber_nameservice")),
198
PB = #'IIOP_ProfileBody_1_0'{iiop_version=version(),
199
host="my.hostname.org",
202
TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB},
203
#'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}.
205
objref_type(doc) -> [];
206
objref_type(suite) -> [];
207
objref_type(Config) when is_list(Config) ->
208
T = {'tk_objref', "IDL:Module/Interface:1.0", "Interface"},
210
?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, Objref0),
211
?line {Objref0, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B0, 0, big),
213
?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, Objref1),
214
?line {Objref1, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B1, 0, big),
216
?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, Objref2),
217
?line {Objref2, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B2, 0, big),
222
%%-----------------------------------------------------------------
223
%% Encode/decode test of type: struct
224
%%-----------------------------------------------------------------
225
struct_type(doc) -> [];
226
struct_type(suite) -> [];
227
struct_type(Config) when is_list(Config) ->
228
T0 = {'tk_struct',"IDL:Module/Struct0:1.0", "Module_Struct0",
229
[{"long", 'tk_long'}, {"short", 'tk_short'}, {"character", 'tk_char'}]},
230
S0 = #'Module_Struct0'{l=-4711, s=17, c=$a},
231
?line B0 = cdr_encode:enc_type({1, 0}, T0, S0),
232
?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B0, 0, big),
234
T1 = {'tk_struct', "IDL:Module/Struct1:1.0", "Module_Struct1",
235
[{"string", {'tk_string', 0}}, {"ushort", 'tk_ushort'}, {"ulong", 'tk_ulong'}]},
236
S1 = #'Module_Struct1'{s="Hi !!!!", us=17, ul=4711},
237
?line B1 = cdr_encode:enc_type({1, 0}, T1, S1),
238
?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B1, 0, big),
240
T2 = {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2",
241
[{"long_sequence", {'tk_sequence', 'tk_long', 0}},
242
{"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}},
243
{"octet", 'tk_octet'}]},
244
S2 = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], e=cow, o=$X},
245
?line B2 = cdr_encode:enc_type({1, 0}, T2, S2),
246
?line {S2, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B2, 0, big),
249
%%-----------------------------------------------------------------
250
%% Encode/decode test of type: union
251
%%-----------------------------------------------------------------
252
union_type(doc) -> [];
253
union_type(suite) -> [];
254
union_type(Config) when is_list(Config) ->
255
T0 = {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2,
256
[{0, "First", 'tk_short'},
257
{1, "Second", {'tk_string', 0}},
258
{2, "Third", 'tk_char'}]},
259
S0 = #'Module_Union'{label=1, value="Foo Bar !"},
260
?line B0 = cdr_encode:enc_type({1, 0}, T0, S0),
261
?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B0, 0, big),
262
S1 = #'Module_Union'{label=0, value=-17},
263
?line B1 = cdr_encode:enc_type({1, 0}, T0, S1),
264
?line {S1, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B1, 0, big),
265
S2 = #'Module_Union'{label=2, value=$X},
266
?line B2 = cdr_encode:enc_type({1, 0}, T0, S2),
267
?line {S2, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B2, 0, big),
268
T1 = {'tk_union', "IDL:Module/Union1:1.0", "Union1",
269
{'tk_enum', "IDL:Module/Enum:1.0",
270
"Module_Enum", ["horse", "pig", "cow"]}, "pig",
271
[{"horse", "First", 'tk_ushort'},
272
{"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}},
273
{"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0",
274
"Module_Enum1", ["orange", "banana", "apple"]}}]},
275
S3 = #'Module_Union1'{label=pig, value=["Foo", "Bar", "!"]},
276
?line B3 = cdr_encode:enc_type({1, 0}, T1, S3),
277
?line {S3, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B3, 0, big),
278
S4 = #'Module_Union1'{label=cow, value=apple},
279
?line B4 = cdr_encode:enc_type({1, 0}, T1, S4),
280
?line {S4, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B4, 0, big),
281
S5 = #'Module_Union1'{label=horse, value=17},
282
?line B5 = cdr_encode:enc_type({1, 0}, T1, S5),
283
?line {S5, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B5, 0, big),
284
T2 = {'tk_union', "IDL:Module/Union2:1.0", "Union2",
285
{'tk_enum', "IDL:Module/Enum:1.0",
286
"Module_Enum", ["horse", "pig", "cow"]}, "pig",
287
[{"horse", "First", {'tk_array', 'tk_long', 3}},
289
{'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2,
290
[{0, "First", 'tk_short'},
291
{1, "Second", {'tk_string', 0}},
292
{2, "Third", 'tk_char'}]}},
293
{"cow", "Third", {'tk_union', "IDL:Module/Union1:1.0", "Union1",
294
{'tk_enum', "IDL:Module/Enum:1.0",
295
"Module_Enum", ["horse", "pig", "cow"]}, "pig",
296
[{"horse", "First", 'tk_ushort'},
297
{"pig", "Second", {'tk_sequence',
298
{'tk_string', 0}, 0}},
299
{"cow", "Third", {'tk_enum',
300
"IDL:Module/Enum1:1.0",
304
S6 = #'Module_Union2'{label=pig, value=#'Module_Union'{label=0, value=-17}},
305
?line B6 = cdr_encode:enc_type({1, 0}, T2, S6),
306
?line {S6, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B6, 0, big),
307
S7 = #'Module_Union2'{label=cow, value=#'Module_Union1'{label=pig,
308
value=["Foo", "Bar", "!"]}},
309
?line B7 = cdr_encode:enc_type({1, 0}, T2, S7),
310
?line {S7, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B7, 0, big),
311
S8 = #'Module_Union2'{label=horse, value={-17, 1234567890, -987654321}},
312
?line B8 = cdr_encode:enc_type({1, 0}, T2, S8),
313
?line {S8, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B8, 0, big),
316
%%-----------------------------------------------------------------
317
%% Encode/decode test of type: string
318
%%-----------------------------------------------------------------
319
string_type(doc) -> [];
320
string_type(suite) -> [];
321
string_type(Config) when is_list(Config) ->
323
?line B0 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S0),
324
?line {S0, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B0, 0, big),
325
S1 = "Yes, Foo Bar !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! more than 5000 characters",
326
?line B1 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S1),
327
?line {S1, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B1, 0, big),
329
?line B2 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S2),
330
?line {S2, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B2, 0, big),
332
?line B3 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S3),
333
?line {S3, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B3, 0, big),
335
?line B4 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S4),
336
?line {S4, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B4, 0, big),
339
%%-----------------------------------------------------------------
340
%% Encode/decode test of type: array
341
%%-----------------------------------------------------------------
342
array_type(doc) -> [];
343
array_type(suite) -> [];
344
array_type(Config) when is_list(Config) ->
345
T0 = {'tk_array', 'tk_long', 5},
346
S0 = {-100, 0, 30000, -900100900, 123456789},
347
?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T0, S0),
348
?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B0, 0, big),
349
T1 = {'tk_array', {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}, 2},
351
?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T1, S1),
352
?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B1, 0, big),
353
T2 = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union",
354
{'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}, "pig",
355
[{"horse", "First", 'tk_ushort'},
356
{"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}},
357
{"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0",
358
"Module_Enum1", ["orange", "banana", "apple"]}}]}, 2},
359
S2 = {#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}},
360
?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T2, S2),
361
?line {S2, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B2, 0, big),
362
T3 = {'tk_array', {'tk_objref', "IDL:Module/Interface:1.0", "Interface"}, 3},
363
S3 = {objref(0), objref(1), objref(2)},
364
?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T3, S3),
365
?line {S3, <<>>, _} = cdr_decode:dec_type(T3, {1, 0}, B3, 0, big),
367
%%-----------------------------------------------------------------
368
%% Encode/decode test of type: TypeCode
369
%%-----------------------------------------------------------------
371
any_type(suite) -> [];
372
any_type(Config) when is_list(Config) ->
374
TC = {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2",
375
[{"long_sequence", {'tk_sequence', 'tk_long', 0}},
376
{"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum",
377
["horse", "pig", "cow"]}},
378
{"octet", 'tk_octet'}]},
379
S = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000],
381
Any = #any{typecode=TC,value=S},
382
?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,Any),
383
?line {Any, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B, 0, big),
384
TC1 = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union",
385
{'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum",
386
["horse", "pig", "cow"]}, 1,
387
[{"horse", "First", 'tk_ushort'},
388
{"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}},
389
{"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0",
390
"Module_Enum1", ["orange", "banana",
392
S1 = {#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}},
393
Any1 = #any{typecode=TC1,value=S1},
394
?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,Any1),
395
?line {Any1, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B1, 0, big),
399
%%-----------------------------------------------------------------
400
%% Encode/decode test of type: TypeCode
401
%%-----------------------------------------------------------------
402
typecode_type(doc) -> [];
403
typecode_type(suite) -> [];
404
typecode_type(Config) when is_list(Config) ->
406
TC = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union",
407
{'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum",
408
["horse", "pig", "cow"]}, 1,
409
[{"horse", "First", 'tk_ushort'},
410
{"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}},
411
{"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0",
412
"Module_Enum1", ["orange", "banana",
414
?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,TC),
415
?line {TC, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B, 0, big),
416
TC1 = {'tk_union', "IDL:Module/Union2:1.0", "Union2",
417
{'tk_enum', "IDL:Module/Enum:1.0",
418
"Module_Enum", ["horse", "pig", "cow"]}, 2,
419
[{"horse", "First", 'tk_long'},
421
{'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2,
422
[{0, "First", 'tk_short'},
423
{1, "Second", {'tk_string', 0}},
424
{2, "Third", 'tk_char'}]}},
425
{"cow", "Third", {'tk_union', "IDL:Module/Union1:1.0", "Union1",
426
{'tk_enum', "IDL:Module/Enum:1.0",
427
"Module_Enum", ["horse", "pig", "cow"]}, 2,
428
[{"horse", "First", 'tk_ushort'},
429
{"pig", "Second", {'tk_sequence',
430
{'tk_string', 0}, 0}},
431
{"cow", "Third", {'tk_enum',
432
"IDL:Module/Enum1:1.0",
436
?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, TC1),
437
?line {TC1, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B1, 0, big),
440
%%-----------------------------------------------------------------
441
%% Encode/decode test of type: TypeCode
442
%%-----------------------------------------------------------------
443
alias_type(doc) -> [];
444
alias_type(suite) -> [];
445
alias_type(Config) when is_list(Config) ->
446
T = {'tk_alias', "IDL:Module/Alias:1.0", "Alias",
447
{'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2",
448
[{"long_sequence", {'tk_sequence', 'tk_long', 0}},
449
{"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum",
450
["horse", "pig", "cow"]}},
451
{"octet", 'tk_octet'}]}},
452
S = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000],
454
?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,S),
455
?line {S, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B, 0, big),
456
T1 = {'tk_alias', "IDL:Module/Alias1:1.0", "Alias1",
457
{'tk_sequence', {'tk_union', "IDL:Module/Union:1.0", "Union",
458
{'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum",
459
["horse", "pig", "cow"]}, 2,
460
[{"horse", "First", 'tk_ushort'},
461
{"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}},
462
{"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0",
463
"Module_Enum1", ["orange", "banana",
465
S1 = [#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}],
466
?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T1, S1),
467
?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B1, 0, big),
470
%%-----------------------------------------------------------------
471
%% Encode/decode test of type: exception
472
%%-----------------------------------------------------------------
473
exception_type(doc) -> [];
474
exception_type(suite) -> [];
475
exception_type(Config) when is_list(Config) ->
480
system_exceptions() ->
481
E = #'UNKNOWN'{completion_status=?COMPLETED_YES},
482
{system_exception, T, E} = orber_exceptions:get_def(E),
483
?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,E),
484
?line {E, _} = cdr_decode:dec_system_exception({1, 0}, B, 0, big),
485
E1 = #'INV_OBJREF'{completion_status=?COMPLETED_NO},
486
{system_exception, T1, E1} = orber_exceptions:get_def(E1),
487
?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T1,E1),
488
?line {E1, _} = cdr_decode:dec_system_exception({1, 0}, B1, 0, big),
489
E2 = #'BAD_OPERATION'{completion_status=?COMPLETED_NO},
490
{system_exception, T2, E2} = orber_exceptions:get_def(E2),
491
?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T2,E2),
492
?line {E2, _} = cdr_decode:dec_system_exception({1, 0}, B2, 0, big),
493
E3 = #'INTF_REPOS'{completion_status=?COMPLETED_MAYBE},
494
{system_exception, T3, E3} = orber_exceptions:get_def(E3),
495
?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T3,E3),
496
?line {E3, _} = cdr_decode:dec_system_exception({1, 0}, B3, 0, big),
500
E = #'Module_Except1'{rest_of_name=["I","am","testing","exceptions"], why="Error"},
501
{user_exception, T, E} = orber_exceptions:get_def(E),
502
?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, E),
503
?line {E, _} = cdr_decode:dec_user_exception({1, 0}, B, 0, big),
504
E1 = #'Module_Except2'{e=banana,
505
s=#'Module_Struct2'{long_sequence=[12,-4040,
509
{user_exception, T1, E1} = orber_exceptions:get_def(E1),
510
?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T1, E1),
511
?line {E1, _} = cdr_decode:dec_user_exception({1, 0}, B1, 0, big),
512
E2 = #'Module_Except3'{u=#'Module_Union1'{label=pig,value=["high","and","low"]},s=1313, o=objref(0)},
513
{user_exception, T2, E2} = orber_exceptions:get_def(E2),
514
?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T2, E2),
515
?line {E2, _} = cdr_decode:dec_user_exception({1, 0}, B2, 0, big),
516
E3 = #'Module_Except4'{},
517
{user_exception, T3, E3} = orber_exceptions:get_def(E3),
518
?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T3, E3),
519
?line {E3, _} = cdr_decode:dec_user_exception({1, 0}, B3, 0, big),
522
%%-----------------------------------------------------------------
523
%% Test Case: request encoding test
524
%% Description: Precondition the stack must be started so the
525
%% objectkey is valid.
526
%%-----------------------------------------------------------------
527
%request(suite) -> [];
529
% exit(not_implemented).
531
%%-----------------------------------------------------------------
532
%% Test Case: reply encoding test
534
%%-----------------------------------------------------------------
535
reply(doc) -> ["Description", "more description"];
537
reply(Config) when is_list(Config) ->
538
R = #reply_header{service_context=[], request_id=1,
539
reply_status='no_exception'},
540
?line B = cdr_encode:enc_reply(
541
#giop_env{version = {1, 0}, request_id = 1,
542
reply_status = 'no_exception',
543
tc = {'tk_long', [], [{'tk_sequence',
544
{'tk_string', 0}, 0}]},
545
result = 1200, parameters = [["foo","Bar"]],
547
?line {R, 1200, [["foo","Bar"]]} =
548
cdr_decode:dec_message({'tk_long', [], [{'tk_sequence', {'tk_string', 0},0}]},
552
%%-----------------------------------------------------------------
553
%% Test Case: cancel_request encoding test
555
%%-----------------------------------------------------------------
556
cancel_request(doc) -> ["Description", "more description"];
557
cancel_request(suite) -> [];
558
cancel_request(Config) when is_list(Config) ->
559
R = #cancel_request_header{request_id=1},
560
?line B = cdr_encode:enc_cancel_request(#giop_env{version = {1, 0},
562
?line R = cdr_decode:dec_message([], B),
565
%%-----------------------------------------------------------------
566
%% Test Case: locate_request encoding test
568
%%-----------------------------------------------------------------
569
locate_request(doc) -> ["Description", "more description"];
570
locate_request(suite) -> [];
571
locate_request(Config) when is_list(Config) ->
572
io:format("Function not imlpemented yet"),
573
exit(not_implemented).
575
%%-----------------------------------------------------------------
576
%% Test Case: locate_reply encoding test
578
%%-----------------------------------------------------------------
579
locate_reply(doc) -> ["Description", "more description"];
580
locate_reply(suite) -> [];
581
locate_reply(Config) when is_list(Config) ->
582
io:format("Function not imlpemented yet"),
583
exit(not_implemented).
585
%%-----------------------------------------------------------------
586
%% Test Case: close_connection encoding test
588
%%-----------------------------------------------------------------
589
close_connection(doc) -> ["Description", "more description"];
590
close_connection(suite) -> [];
591
close_connection(Config) when is_list(Config) ->
592
?line B = cdr_encode:enc_close_connection(#giop_env{version = {1, 0}}),
593
?line 'close_connection' = cdr_decode:dec_message([], B),
596
%%-----------------------------------------------------------------
597
%% Test Case: message_error encoding test
599
%%-----------------------------------------------------------------
600
message_error(doc) -> ["Description", "more description"];
601
message_error(suite) -> [];
602
message_error(Config) when is_list(Config) ->
603
?line B = cdr_encode:enc_message_error(#giop_env{version = {1, 0}}),
604
?line 'message_error' = cdr_decode:dec_message([], B),
609
%%-----------------------------------------------------------------
610
%% Internal functions
611
%%-----------------------------------------------------------------
612
corba_fake_mk_objkey(Id, 'key', Pid) when is_pid(Pid) ->
614
{list_to_binary(Id), 'key', Key, term_to_binary(undefined),
615
term_to_binary(undefined), term_to_binary(undefined)};
616
corba_fake_mk_objkey(Id, 'key', RegName) when is_atom(RegName) ->
617
Key = term_to_binary(RegName),
618
{list_to_binary(Id), 'key', Key, term_to_binary(undefined),
619
term_to_binary(undefined), term_to_binary(undefined)};
620
corba_fake_mk_objkey(Id, 'registered', RegName) when is_atom(RegName) ->
621
{list_to_binary(Id), 'registered', RegName, term_to_binary(undefined),
622
term_to_binary(undefined), term_to_binary(undefined)}.
625
term_to_binary({now(), node()}).