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