1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 1997-2011. All Rights Reserved. 5: %% 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/. 11: %% 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 15: %% under the License. 16: %% 17: %% %CopyrightEnd% 18: %% 19: %% 20: %%----------------------------------------------------------------- 21: %% 22: %% Description: 23: %% Test suite for the IOR functions 24: %% 25: %%----------------------------------------------------------------- 26: -module(iop_ior_11_SUITE). 27: 28: -include_lib("test_server/include/test_server.hrl"). 29: -include_lib("orber/src/orber_iiop.hrl"). 30: 31: -define(default_timeout, ?t:minutes(3)). 32: 33: %%----------------------------------------------------------------- 34: %% External exports 35: %%----------------------------------------------------------------- 36: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 37: init_per_group/2,end_per_group/2]). 38: 39: %%----------------------------------------------------------------- 40: %% Internal exports 41: %%----------------------------------------------------------------- 42: -export([]). 43: -compile(export_all). 44: 45: %%----------------------------------------------------------------- 46: %% Func: all/1 47: %% Args: 48: %% Returns: 49: %%----------------------------------------------------------------- 50: suite() -> [{ct_hooks,[ts_install_cth]}]. 51: 52: all() -> 53: [encoding, create_and_get_ops]. 54: 55: groups() -> 56: []. 57: 58: init_per_suite(Config) -> 59: Config. 60: 61: end_per_suite(_Config) -> 62: ok. 63: 64: init_per_group(_GroupName, Config) -> 65: Config. 66: 67: end_per_group(_GroupName, Config) -> 68: Config. 69: 70: 71: %%----------------------------------------------------------------- 72: %% Init and cleanup functions. 73: %%----------------------------------------------------------------- 74: 75: init_per_testcase(_Case, Config) -> 76: ?line Dog=test_server:timetrap(?default_timeout), 77: [{watchdog, Dog}|Config]. 78: 79: 80: end_per_testcase(_Case, Config) -> 81: Dog = ?config(watchdog, Config), 82: test_server:timetrap_cancel(Dog), 83: ok. 84: 85: %%----------------------------------------------------------------- 86: %% Test Case: IOR encoding test 87: %% Description: Just testing the string_encoding function because the 88: %% other encodings is called from them. 89: %%----------------------------------------------------------------- 90: encoding(doc) -> ["Description", "more description"]; 91: encoding(suite) -> []; 92: encoding(_) -> 93: V = #'IIOP_Version'{major=1,minor=1}, 94: M0 = 'Module_Interface', 95: T0 = "IDL:Module/Interface:1.0", 96: H0 = "my.hostname.org", 97: P0 = 4040, 98: N0 = 'name', 99: Components = case orber:iiop_ssl_port() of 100: -1 -> 101: []; 102: SSLPort -> 103: [#'IOP_TaggedComponent'{tag=?TAG_SSL_SEC_TRANS, 104: component_data=[0 | 105: cdrlib:enc_unsigned_short(2, 106: cdrlib:enc_unsigned_short(2, 107: cdrlib:enc_unsigned_short(SSLPort, [])))]}] 108: end, 109: ?line O0 = corba_fake_mk_objkey(M0, registered, N0), 110: PB0 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O0, 111: components=Components}, 112: TP0 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB0}, 113: S0 = #'IOP_IOR'{type_id=T0, profiles=[TP0]}, 114: N1 = list_to_pid("<0.100.0>"), 115: ?line O1 = corba_fake_mk_objkey(M0, key, N1), 116: PB1 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O1, 117: components=[]}, 118: TP1 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB1}, 119: S1 = #'IOP_IOR'{type_id=T0, profiles=[TP1]}, 120: O2 = "This is an external objectkey", 121: PB2 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O2, 122: components=[]}, 123: TP2 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB2}, 124: S2 = #'IOP_IOR'{type_id=T0, profiles=[TP2]}, 125: ?line C0 = iop_ior:string_code(S0), 126: ?line {S0, <<>>, _} = iop_ior:string_decode(C0), 127: ?line C1 = iop_ior:string_code(S1), 128: ?line {S1, <<>>, _} = iop_ior:string_decode(C1), 129: ?line C2 = iop_ior:string_code(S2), 130: ?line {S2, <<>>, _} = iop_ior:string_decode(C2), 131: ok. 132: 133: 134: %%----------------------------------------------------------------- 135: %% Test Case: IOR creation test 136: %% Description: 137: %%----------------------------------------------------------------- 138: create_and_get_ops(doc) -> ["Description", "more description"]; 139: create_and_get_ops(suite) -> []; 140: create_and_get_ops(_) -> 141: V = #'IIOP_Version'{major=1,minor=1}, 142: CSC = #'IOP_TaggedComponent'{tag=?TAG_CODE_SETS, 143: component_data=?DEFAULT_CODESETS}, 144: M0 = 'Module_Interface', 145: T0 = "IDL:Module/Interface:1.0", 146: H0 = "my.hostname.org", 147: P0 = 4040, 148: N0 = 'name', 149: ?line O0 = corba_fake_mk_objkey(M0, registered, N0), 150: PB0 = #'IIOP_ProfileBody_1_1' 151: {iiop_version=V, host=H0, port=P0, object_key=O0, 152: components=[CSC]}, 153: TP0 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB0}, 154: S0 = #'IOP_IOR'{type_id=T0, profiles=[TP0]}, 155: ?line S0 = iop_ior:create({1, 1}, T0, [H0], P0, -1, O0, [CSC], 0, 0), 156: N1 = list_to_pid("<0.100.0>"), 157: ?line O1 = corba_fake_mk_objkey(M0, key, N1), 158: {_,_,K1,_,_,_} = O1, 159: PB1 = #'IIOP_ProfileBody_1_1' 160: {iiop_version=V, host=H0, port=P0, object_key=O1, 161: components=[CSC]}, 162: TP1 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB1}, 163: S1 = #'IOP_IOR'{type_id=T0, profiles=[TP1]}, 164: ?line S1 = iop_ior:create({1, 1}, T0, [H0], P0, -1, O1, [CSC], 0, 0), 165: O2 = "This is an external objectkey", 166: PB2 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O2, 167: components=[]}, 168: TP2 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB2}, 169: S2 = #'IOP_IOR'{type_id=T0, profiles=[TP2]}, 170: ?line {'internal_registered', N0, _, _, M0} = iop_ior:get_key(S0), 171: ?line {'internal', K1, _, _, M0} = iop_ior:get_key(S1), 172: ?line {'external', {H0, P0, O2, _,_, 173: #host_data{protocol = normal, 174: ssl_data = undefined, 175: version = {1,1}, 176: csiv2_mech = undefined, 177: csiv2_statefull = false, 178: charset = 65537, 179: wcharset = 65801, 180: ft_heartbeat = false, 181: ft_primary = false, 182: ft_group = undefined, 183: csiv2_addresses = []}}} = 184: iop_ior:get_key(S2), 185: ?line T0 = iop_ior:get_typeID(S0), 186: ?line O0 = iop_ior:get_objkey(S0), 187: ?line O1 = iop_ior:get_objkey(S1), 188: ?line O2 = iop_ior:get_objkey(S2), 189: ok. 190: 191: %%----------------------------------------------------------------- 192: %% Internal functions 193: %%----------------------------------------------------------------- 194: corba_fake_mk_objkey(Id, 'key', Pid) when is_pid(Pid) -> 195: Key = make_objkey(), 196: {Id, 'key', Key, term_to_binary(undefined), 0, 0}; 197: corba_fake_mk_objkey(Id, 'key', RegName) when is_atom(RegName) -> 198: Key = term_to_binary(RegName), 199: {Id, 'key', Key, term_to_binary(undefined), 0, 0}; 200: corba_fake_mk_objkey(Id, 'registered', RegName) when is_atom(RegName) -> 201: {Id, 'registered', RegName, term_to_binary(undefined), 0, 0}. 202: 203: make_objkey() -> 204: term_to_binary({now(), node()}).