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