1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 1998-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20%% 21 22-module(iiop_module_do_test_impl). 23 24 25-export([run_all/3, run_userexception/2, run_systemexception/2]). 26-export([createTestContext/0]). 27 28-export([start/0, stop/0]). 29-export([init/1, terminate/2]). 30 31 32init(_) -> 33 {ok, []}. 34 35terminate(Reason, _State) -> 36 io:format("~p terminating with reason ~p~n", [?MODULE, Reason]), 37 ok. 38 39createTestContext() -> 40 NS = corba:resolve_initial_references("NameService"), 41 NC = lname_component:set_id(lname_component:create(), "iiop_test"), 42 N = lname:insert_component(lname:create(), 1, NC), 43 'CosNaming_NamingContext':bind_new_context(NS, N). 44 45start() -> 46 SFok = corba:create('iiop_module_do_test', "IDL:iiop_module/do_test:1.0"), 47 NS = corba:resolve_initial_references("NameService"), 48 NC1 = lname_component:set_id(lname_component:create(), "iiop_test"), 49 NC2 = lname_component:set_id(lname_component:create(), "erl_dotest"), 50 N = lname:insert_component(lname:create(), 1, NC1), 51 N1 = lname:insert_component(N, 2, NC2), 52 'CosNaming_NamingContext':bind(NS, N1, SFok), 53 SFok. 54 55stop() -> 56 NS = corba:resolve_initial_references("NameService"), 57 NC1 = lname_component:set_id(lname_component:create(), "iiop_test"), 58 NC2 = lname_component:set_id(lname_component:create(), "erl_dotest"), 59 N = lname:insert_component(lname:create(), 1, NC1), 60 N1 = lname:insert_component(N, 2, NC2), 61 'CosNaming_NamingContext':unbind(NS, N1). 62 63run_all(S, X, TL) -> 64 ok = iiop_module_test:send_void(X), 65 {tk_short, P1} = lists:nth(1, TL), 66 {R1, IO1, O1} = iiop_module_test:send_short(X, P1, P1), 67 RL1= [{tk_short, R1}], 68 IOL1= [{tk_short, IO1}], 69 OL1= [{tk_short, O1}], 70 {tk_ushort, P2} = lists:nth(2, TL), 71 {R2, IO2, O2} = iiop_module_test:send_ushort(X, P2, P2), 72 RL2= [{tk_ushort, R2}|RL1], 73 IOL2= [{tk_ushort, IO2}|IOL1], 74 OL2= [{tk_ushort, O2}|OL1], 75 {tk_long, P3} = lists:nth(3, TL), 76 {R3, IO3, O3} = iiop_module_test:send_long(X, P3, P3), 77 RL3= [{tk_long, R3}|RL2], 78 IOL3= [{tk_long, IO3}|IOL2], 79 OL3= [{tk_long, O3}|OL2], 80 {tk_ulong, P4} = lists:nth(4, TL), 81 {R4, IO4, O4} = iiop_module_test:send_ulong(X, P4, P4), 82 RL4= [{tk_ulong, R4}|RL3], 83 IOL4= [{tk_ulong, IO4}|IOL3], 84 OL4= [{tk_ulong, O4}|OL3], 85 {tk_float, P5} = lists:nth(5, TL), 86 {R5, IO5, O5} = iiop_module_test:send_float(X, P5, P5), 87 RL5= [{tk_float, R5}|RL4], 88 IOL5= [{tk_float, IO5}|IOL4], 89 OL5= [{tk_float, O5}|OL4], 90 {tk_double, P6} = lists:nth(6, TL), 91 {R6, IO6, O6} = iiop_module_test:send_double(X, P6, P6), 92 RL6= [{tk_double, R6}|RL5], 93 IOL6= [{tk_double, IO6}|IOL5], 94 OL6= [{tk_double, O6}|OL5], 95 {tk_boolean, P7} = lists:nth(7, TL), 96 {R7, IO7, O7} = iiop_module_test:send_boolean(X, P7, P7), 97 RL7= [{tk_boolean, R7}|RL6], 98 IOL7= [{tk_boolean, IO7}|IOL6], 99 OL7= [{tk_boolean, O7}|OL6], 100 {tk_char, P8} = lists:nth(8, TL), 101 {R8, IO8, O8} = iiop_module_test:send_char(X, P8, P8), 102 RL= [{tk_char, R8} |RL7], 103 IOL= [{tk_char, IO8} |IOL7], 104 OL= [{tk_char, O8} |OL7], 105 {{lists:reverse(RL),lists:reverse(IOL),lists:reverse(OL)}, S}. 106 107run_systemexception(S, X) -> 108 iiop_module_test:ret_systemexception(X), 109 {ok, S}. 110 111run_userexception(S, X) -> 112 iiop_module_test:ret_userexception(X), 113 {ok, S}. 114