1
%%-----------------------------------------------------------------
5
%% Copyright Ericsson AB 2004-2011. All Rights Reserved.
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/.
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
21
%%-----------------------------------------------------------------
22
%% File : interceptors_SUITE.erl
24
%%-----------------------------------------------------------------
26
-module(interceptors_SUITE).
28
-include_lib("test_server/include/test_server.hrl").
29
-include_lib("orber/include/corba.hrl").
30
-include_lib("orber/src/orber_iiop.hrl").
32
-define(default_timeout, ?t:minutes(3)).
34
-define(match(ExpectedRes, Expr),
36
AcTuAlReS = (catch (Expr)),
39
io:format("------ CORRECT RESULT ------~n~p~n",
43
io:format("###### ERROR ERROR ######~n~p~n",
49
-define(nomatch(Not, Expr),
51
AcTuAlReS = (catch (Expr)),
54
io:format("###### ERROR ERROR ######~n~p~n",
56
?line exit(AcTuAlReS);
58
io:format("------ CORRECT RESULT ------~n~p~n",
65
%%-----------------------------------------------------------------
67
%%-----------------------------------------------------------------
68
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
69
init_per_group/2,end_per_group/2]).
71
%%-----------------------------------------------------------------
73
%%-----------------------------------------------------------------
74
-export([in_reply/6, out_request/6]).
77
%%-----------------------------------------------------------------
81
%%-----------------------------------------------------------------
82
suite() -> [{ct_hooks,[ts_install_cth]}].
85
[local_pseudo, local_default, local_local, local_global].
90
init_per_suite(Config) ->
93
end_per_suite(_Config) ->
96
init_per_group(_GroupName, Config) ->
99
end_per_group(_GroupName, Config) ->
103
%%-----------------------------------------------------------------
104
%% Init and cleanup functions.
105
%%-----------------------------------------------------------------
106
init_per_testcase(_Case, Config) ->
107
?line Dog=test_server:timetrap(?default_timeout),
108
Path = code:which(?MODULE),
109
code:add_pathz(filename:join(filename:dirname(Path), "idl_output")),
110
corba:orb_init([{flags, (?ORB_ENV_USE_PI bor ?ORB_ENV_LOCAL_TYPECHECKING)},
111
{local_interceptors, {native, [?MODULE]}}]),
112
orber:jump_start(2945),
113
oe_orber_test_server:oe_register(),
114
[{watchdog, Dog}|Config].
117
end_per_testcase(_Case, Config) ->
118
oe_orber_test_server:oe_unregister(),
120
Path = code:which(?MODULE),
121
code:del_path(filename:join(filename:dirname(Path), "idl_output")),
122
Dog = ?config(watchdog, Config),
123
test_server:timetrap_cancel(Dog),
126
%%-----------------------------------------------------------------
127
%% Test Case: local_pseudo
129
%%-----------------------------------------------------------------
130
local_pseudo(doc) -> [""];
131
local_pseudo(suite) -> [];
133
?match({native, [?MODULE]}, orber:get_local_interceptors()),
135
Obj1 = orber_test_server:oe_create(state,[{pseudo,true}]),
136
Result11 = orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX),
137
?match([?USHORTMAX], put(out_request, undefined)),
138
?match(Result11, put(in_reply, undefined)),
140
Result12 = ?match({'EXCEPTION',_},
141
orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX+1)),
142
?match([(?USHORTMAX+1)], put(out_request, undefined)),
143
?nomatch(Result12, put(in_reply, undefined)),
145
Result13 = orber_test_server:testing_iiop_oneway_delay(Obj1, 0),
146
?match([0], put(out_request, undefined)),
147
?nomatch(Result13, put(in_reply, undefined)),
149
Result14 = ?match({'EXCEPTION', _},
150
orber_test_server:raise_local_exception(Obj1)),
151
?match([], put(out_request, undefined)),
152
?match(Result14, put(in_reply, undefined)),
154
Result15 = ?match({'EXCEPTION',_}, orber_test_server:stop_brutal(Obj1)),
155
?match([], put(out_request, undefined)),
156
?match(Result15, put(in_reply, undefined)),
159
Obj2 = orber_test_server:oe_create(state,[{pseudo,true},
160
{local_interceptors, false}]),
162
Result21 = orber_test_server:testing_iiop_ushort(Obj2, ?USHORTMAX),
163
?nomatch([?USHORTMAX], put(out_request, undefined)),
164
?nomatch(Result21, put(in_reply, undefined)),
166
Obj3 = orber_test_server:oe_create(state,[{pseudo,true},
167
{local_interceptors, true}]),
169
Result31 = orber_test_server:testing_iiop_ushort(Obj3, ?USHORTMAX),
170
?match([?USHORTMAX], put(out_request, undefined)),
171
?match(Result31, put(in_reply, undefined)),
175
%%-----------------------------------------------------------------
176
%% Test Case: local_default
178
%%-----------------------------------------------------------------
179
local_default(doc) -> [""];
180
local_default(suite) -> [];
182
?match({native, [?MODULE]}, orber:get_local_interceptors()),
184
Obj1 = orber_test_server:oe_create(state, []),
185
Result11 = orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX),
186
?match([?USHORTMAX], put(out_request, undefined)),
187
?match(Result11, put(in_reply, undefined)),
189
Result12 = ?match({'EXCEPTION',_},
190
orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX+1)),
191
?match([(?USHORTMAX+1)], put(out_request, undefined)),
192
?nomatch(Result12, put(in_reply, undefined)),
194
Result13 = orber_test_server:testing_iiop_oneway_delay(Obj1, 0),
195
?match([0], put(out_request, undefined)),
196
?nomatch(Result13, put(in_reply, undefined)),
198
Result14 = ?match({'EXCEPTION', _},
199
orber_test_server:raise_local_exception(Obj1)),
200
?match([], put(out_request, undefined)),
201
?match(Result14, put(in_reply, undefined)),
203
Result15 = ?match({'EXCEPTION',_}, orber_test_server:stop_brutal(Obj1)),
204
?match([], put(out_request, undefined)),
205
?match(Result15, put(in_reply, undefined)),
209
Obj2 = orber_test_server:oe_create(state,[{local_interceptors, false}]),
211
Result21 = orber_test_server:testing_iiop_ushort(Obj2, ?USHORTMAX),
212
?nomatch([?USHORTMAX], put(out_request, undefined)),
213
?nomatch(Result21, put(in_reply, undefined)),
216
Obj3 = orber_test_server:oe_create(state,[{local_interceptors, true}]),
218
Result31 = orber_test_server:testing_iiop_ushort(Obj3, ?USHORTMAX),
219
?match([?USHORTMAX], put(out_request, undefined)),
220
?match(Result31, put(in_reply, undefined)),
224
%%-----------------------------------------------------------------
225
%% Test Case: local_local
227
%%-----------------------------------------------------------------
228
local_local(doc) -> [""];
229
local_local(suite) -> [];
231
?match({native, [?MODULE]}, orber:get_local_interceptors()),
233
Obj1 = orber_test_server:oe_create(state, [{regname, {local, regname}}]),
234
Result11 = orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX),
235
?match([?USHORTMAX], put(out_request, undefined)),
236
?match(Result11, put(in_reply, undefined)),
238
Result12 = ?match({'EXCEPTION',_},
239
orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX+1)),
240
?match([(?USHORTMAX+1)], put(out_request, undefined)),
241
?nomatch(Result12, put(in_reply, undefined)),
243
Result13 = orber_test_server:testing_iiop_oneway_delay(Obj1, 0),
244
?match([0], put(out_request, undefined)),
245
?nomatch(Result13, put(in_reply, undefined)),
247
Result14 = ?match({'EXCEPTION', _},
248
orber_test_server:raise_local_exception(Obj1)),
249
?match([], put(out_request, undefined)),
250
?match(Result14, put(in_reply, undefined)),
252
Result15 = ?match({'EXCEPTION',_}, orber_test_server:stop_brutal(Obj1)),
253
?match([], put(out_request, undefined)),
254
?match(Result15, put(in_reply, undefined)),
257
Obj2 = orber_test_server:oe_create(state,[{regname, {local, regname}},
258
{local_interceptors, false}]),
260
Result21 = orber_test_server:testing_iiop_ushort(Obj2, ?USHORTMAX),
261
?nomatch([?USHORTMAX], put(out_request, undefined)),
262
?nomatch(Result21, put(in_reply, undefined)),
265
Obj3 = orber_test_server:oe_create(state,[{regname, {local, regname}},
266
{local_interceptors, true}]),
268
Result31 = orber_test_server:testing_iiop_ushort(Obj3, ?USHORTMAX),
269
?match([?USHORTMAX], put(out_request, undefined)),
270
?match(Result31, put(in_reply, undefined)),
274
%%-----------------------------------------------------------------
275
%% Test Case: local_global
277
%%-----------------------------------------------------------------
278
local_global(doc) -> [""];
279
local_global(suite) -> [];
281
?match({native, [?MODULE]}, orber:get_local_interceptors()),
283
Obj1 = orber_test_server:oe_create(state, [{regname, {global, regname}}]),
284
Result11 = orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX),
285
?match([?USHORTMAX], put(out_request, undefined)),
286
?match(Result11, put(in_reply, undefined)),
288
Result12 = ?match({'EXCEPTION',_},
289
orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX+1)),
290
?match([(?USHORTMAX+1)], put(out_request, undefined)),
291
?nomatch(Result12, put(in_reply, undefined)),
293
Result13 = orber_test_server:testing_iiop_oneway_delay(Obj1, 0),
294
?match([0], put(out_request, undefined)),
295
?nomatch(Result13, put(in_reply, undefined)),
297
Result14 = ?match({'EXCEPTION', _},
298
orber_test_server:raise_local_exception(Obj1)),
299
?match([], put(out_request, undefined)),
300
?match(Result14, put(in_reply, undefined)),
302
Result15 = ?match({'EXCEPTION',_}, orber_test_server:stop_brutal(Obj1)),
303
?match([], put(out_request, undefined)),
304
?match(Result15, put(in_reply, undefined)),
307
Obj2 = orber_test_server:oe_create(state,[{regname, {global, regname}},
308
{local_interceptors, false}]),
310
Result21 = orber_test_server:testing_iiop_ushort(Obj2, ?USHORTMAX),
311
?nomatch([?USHORTMAX], put(out_request, undefined)),
312
?nomatch(Result21, put(in_reply, undefined)),
315
Obj3 = orber_test_server:oe_create(state,[{regname, {global, regname}},
316
{local_interceptors, true}]),
318
Result31 = orber_test_server:testing_iiop_ushort(Obj3, ?USHORTMAX),
319
?match([?USHORTMAX], put(out_request, undefined)),
320
?match(Result31, put(in_reply, undefined)),
327
%%-----------------------------------------------------------------
329
%%-----------------------------------------------------------------
330
%%-----------------------------------------------------------------
331
%% function : in_reply
332
%%-----------------------------------------------------------------
333
in_reply(Ref, _ObjKey, Ctx, Op, Reply, _Args) ->
334
error_logger:info_msg("=============== in_reply =================
339
==========================================~n",
340
[Ref, Op, Reply, Ctx]),
341
put(in_reply, Reply),
344
%%-----------------------------------------------------------------
345
%% function : out_request
346
%%-----------------------------------------------------------------
347
out_request(Ref, _ObjKey, Ctx, Op, Params, _Args) ->
348
error_logger:info_msg("=============== out_request ==============
353
==========================================~n",
354
[Ref, Op, Params, Ctx]),
355
put(out_request, Params),