diff options
Diffstat (limited to 'lib')
91 files changed, 27307 insertions, 21 deletions
diff --git a/lib/cosEvent/doc/src/notes.xml b/lib/cosEvent/doc/src/notes.xml index 78299a38dc..b6c4531901 100644 --- a/lib/cosEvent/doc/src/notes.xml +++ b/lib/cosEvent/doc/src/notes.xml @@ -33,6 +33,22 @@ </header> <section> + <title>cosEvent 2.1.9</title> + + <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Test suites published.</p> + <p> + Own Id: OTP-8543 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosEvent 2.1.8</title> <section> diff --git a/lib/cosEvent/test/Makefile b/lib/cosEvent/test/Makefile new file mode 100644 index 0000000000..3d95075ee1 --- /dev/null +++ b/lib/cosEvent/test/Makefile @@ -0,0 +1,154 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1999-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(COSEVENT_VSN) +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/cosEvent_test + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +TEST_SPEC_FILE = cosEvent.spec + + +IDL_FILES = \ + event_test_server.idl \ + +IDLOUTDIR = idl_output + +MODULES = \ + event_test_PushC_impl \ + event_test_PullC_impl \ + event_test_PushS_impl \ + event_test_PullS_impl \ + event_channel_SUITE \ + generated_SUITE + +GEN_MOD_COS = \ + event_test_PullC \ + event_test_PushS \ + event_test_PullS \ + oe_event_test_server \ + event_test_PushC + +GEN_HRL_COS = \ + event_test.hrl \ + event_test_PushC.hrl \ + event_test_PullC.hrl \ + event_test_PushS.hrl \ + event_test_PullS.hrl \ + oe_event_test_server.hrl + + +GEN_MODULES = $(GEN_MOD_COS) + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = + +GEN_HRL_FILES = $(GEN_HRL_COS) + +GEN_FILES = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +GEN_TARGET_FILES = $(GEN_MODULES:%=$(IDLOUTDIR)/%.$(EMULATOR)) + +SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) + +TARGET_FILES = \ + $(GEN_TARGET_FILES) \ + $(SUITE_TARGET_FILES) + +# ---------------------------------------------------- +# PROGRAMS +# ---------------------------------------------------- +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/orber/ebin -pa $(ERL_TOP)/lib/ic/ebin + +ERL_COMPILE_FLAGS += $(ERL_IDL_FLAGS) \ + -pa $(ERL_TOP)/lib/test_server/ebin \ + -pa $(ERL_TOP)/lib/cosEvent/ebin \ + -pa $(ERL_TOP)/lib/cosEvent/test/idl_output \ + -I$(ERL_TOP)/lib/cosEvent \ + -I$(ERL_TOP)/lib/cosEvent/test/$(IDLOUTDIR) \ + -I$(ERL_TOP)/lib/test_server/include + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- +tests debug opt: $(TARGET_FILES) + +clean: + rm -f idl_output/* + rm -rf java_initial_reference_idl java_cos_naming_idl + rm -rf java_iiop_module_idl java_output/* + rm -f $(TARGET_FILES) + rm -f errs core *~ + + +docs: + +# ---------------------------------------------------- +# Special Targets +# ---------------------------------------------------- + +# +# Each IDL file produces many target files so no pattern +# rule can be used. +# +TGT_COS = \ + $(GEN_HRL_COS:%=$(IDLOUTDIR)/%) \ + $(GEN_MOD_COS:%=$(IDLOUTDIR)/%.erl) + + +$(TGT_COS): event_test_server.idl + erlc $(ERL_IDL_FLAGS) -o$(IDLOUTDIR) event_test_server.idl + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +# We don't copy generated intermediate erlang and hrl files + +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: + +release_docs_spec: + +release_tests_spec: tests + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(IDL_FILES) $(TEST_SPEC_FILE) \ + $(ERL_FILES) $(RELSYSDIR) + $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR) + $(INSTALL_DIR) $(RELSYSDIR)/$(IDLOUTDIR) + $(INSTALL_DATA) $(GEN_TARGET_FILES) $(GEN_FILES) \ + $(RELSYSDIR)/$(IDLOUTDIR) + diff --git a/lib/cosEvent/test/cosEvent.spec b/lib/cosEvent/test/cosEvent.spec new file mode 100644 index 0000000000..910f7a7c28 --- /dev/null +++ b/lib/cosEvent/test/cosEvent.spec @@ -0,0 +1,19 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{topcase, {dir, "../cosEvent_test"}}. diff --git a/lib/cosEvent/test/event_channel_SUITE.erl b/lib/cosEvent/test/event_channel_SUITE.erl new file mode 100644 index 0000000000..2b0cf1fe30 --- /dev/null +++ b/lib/cosEvent/test/event_channel_SUITE.erl @@ -0,0 +1,316 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- + +-module(event_channel_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +%%----------------------------------------------------------------- +%% Macros +%%----------------------------------------------------------------- + +-define(default_timeout, ?t:minutes(5)). + + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, event_objects_api/1, events_api/1, events_sync_api/1, + cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2, app_test/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- + +all(doc) -> ["API tests for the cosEvent interfaces", ""]; +all(suite) -> {req, + [mnesia, orber], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [events_api, events_sync_api, event_objects_api, app_test]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) when is_list(Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + mnesia:delete_schema([node()]), + mnesia:create_schema([node()]), + orber:install([node()]), + application:start(mnesia), + application:start(orber), + cosEventApp:install(), + cosEventApp:start(), + oe_event_test_server:oe_register(), + Config. + +finish_all(Config) when is_list(Config) -> + oe_event_test_server:oe_unregister(), + cosEventApp:stop(), + cosEventApp:uninstall(), + application:stop(orber), + application:stop(mnesia), + mnesia:delete_schema([node()]), + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Config. + +%%----------------------------------------------------------------- +%% Tests app file +%%----------------------------------------------------------------- +app_test(doc) -> []; +app_test(suite) -> []; +app_test(_Config) -> + ok=test_server:app_test(cosEvent), + ok. + + + +event_objects_api(doc) -> ["Testing the CosEvent API to setup a complete service", ""]; +event_objects_api(suite) -> []; +event_objects_api(_Config) -> + + Ch = ?match({_,key,_,_,_,_}, cosEventApp:start_channel([{typecheck, true}, + {pull_interval, 300}])), + + AC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_EventChannel':for_consumers(Ch)), + AS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_EventChannel':for_suppliers(Ch)), + + PPushS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_ConsumerAdmin':obtain_push_supplier(AC)), + PPullS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_ConsumerAdmin':obtain_pull_supplier(AC)), + + PPushC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_SupplierAdmin':obtain_push_consumer(AS)), + PPullC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_SupplierAdmin':obtain_pull_consumer(AS)), + + PushC=?match({_,key,_,_,_,_}, + 'event_test_PushC':oe_create([])), + PullC=?match({_,key,_,_,_,_}, + 'event_test_PullC':oe_create(PPullC)), + + PushS=?match({_,key,_,_,_,_}, + 'event_test_PushS':oe_create(PPushC)), + + PullS=?match({_,key,_,_,_,_}, + 'event_test_PullS':oe_create([])), + + NIL = corba:create_nil_objref(), + + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, + 'CosEventChannelAdmin_ProxyPushSupplier':connect_push_consumer(PPushS, NIL)), + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, + 'CosEventChannelAdmin_ProxyPushSupplier':connect_push_consumer(PPushS, PullS)), + ?match(ok, 'CosEventChannelAdmin_ProxyPushSupplier':connect_push_consumer(PPushS, PushC)), + ?match({'EXCEPTION',{'CosEventChannelAdmin_AlreadyConnected',_}}, + 'CosEventChannelAdmin_ProxyPushSupplier':connect_push_consumer(PPushS, PushC)), + + ?match(ok, 'CosEventChannelAdmin_ProxyPullSupplier':connect_pull_consumer(PPullS, NIL)), + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, + 'CosEventChannelAdmin_ProxyPullSupplier':connect_pull_consumer(PPullS, PullS)), + ?match(ok, 'CosEventChannelAdmin_ProxyPullSupplier':connect_pull_consumer(PPullS, PullC)), + ?match({'EXCEPTION',{'CosEventChannelAdmin_AlreadyConnected',_}}, + 'CosEventChannelAdmin_ProxyPullSupplier':connect_pull_consumer(PPullS, PullC)), + + ?match(ok, 'CosEventChannelAdmin_ProxyPushConsumer':connect_push_supplier(PPushC, NIL)), + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, + 'CosEventChannelAdmin_ProxyPushConsumer':connect_push_supplier(PPushC, PullS)), + ?match(ok, 'CosEventChannelAdmin_ProxyPushConsumer':connect_push_supplier(PPushC, PushS)), + ?match({'EXCEPTION',{'CosEventChannelAdmin_AlreadyConnected',_}}, + 'CosEventChannelAdmin_ProxyPushConsumer':connect_push_supplier(PPushC, PushS)), + + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, + 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PPullC, NIL)), + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, + 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PPullC, PushS)), + ?match(ok, 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PPullC, PullS)), + ?match({'EXCEPTION',{'CosEventChannelAdmin_AlreadyConnected',_}}, + 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PPullC, PullS)), + + + catch corba:dispose(AC), + %% Wait a couple of seconds to be sure all data removed from DB. + timer:sleep(2000), + + %% Since we terminated ConsumerAdmin only the Supplier Proxies should be terminated. + ?match(true, corba_object:non_existent(AC)), + ?match(true, corba_object:non_existent(PPushS)), + ?match(true, corba_object:non_existent(PPullS)), + + ?match(false, corba_object:non_existent(Ch)), + ?match(false, corba_object:non_existent(AS)), + ?match(false, corba_object:non_existent(PPullC)), + ?match(false, corba_object:non_existent(PPushC)), + + %% Terminate a proxy and check that its admin is unaffected. + catch corba:dispose(PPullC), + timer:sleep(2000), + ?match(false, corba_object:non_existent(AS)), + ?match(true, corba_object:non_existent(PPullC)), + + catch corba:dispose(Ch), + timer:sleep(2000), + + ?match(true, corba_object:non_existent(Ch)), + ?match(true, corba_object:non_existent(AS)), + ?match(true, corba_object:non_existent(PPullC)), + ?match(true, corba_object:non_existent(PPushC)), + + %% The client should be notified; wait for a couple of seconds and check it. + timer:sleep(2000), + ?match(true, corba_object:non_existent(PushC)), + ?match(true, corba_object:non_existent(PullC)), + ?match(true, corba_object:non_existent(PushS)), + ?match(true, corba_object:non_existent(PullS)), + + ok. + +events_api(doc) -> ["Testing the CosEvent API for sending events asynchronous", ""]; +events_api(suite) -> []; +events_api(_Config) -> + + Ch = ?match({_,key,_,_,_,_}, cosEventApp:start_channel([{typecheck, true}, + {pull_interval, 2}, + {blocking, false}])), + event_sender(Ch). + + +events_sync_api(doc) -> ["Testing the CosEvent API for sending events synchronous", ""]; +events_sync_api(suite) -> []; +events_sync_api(_Config) -> + + Ch = ?match({_,key,_,_,_,_}, cosEventApp:start_channel([{typecheck, true}, + {pull_interval, 2}, + {blocking, true}])), + event_sender(Ch). + +event_sender(Ch) -> + Event1 = #any{typecode=tk_long, value = 1}, + Event2 = #any{typecode=tk_long, value = 2}, + Event3 = #any{typecode=tk_long, value = 3}, + Event4 = #any{typecode=tk_long, value = 4}, + Event5 = #any{typecode=tk_long, value = 5}, + Event6 = #any{typecode=tk_long, value = 6}, + + AC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_EventChannel':for_consumers(Ch)), + AS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_EventChannel':for_suppliers(Ch)), + + PPushS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_ConsumerAdmin':obtain_push_supplier(AC)), + PPullS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_ConsumerAdmin':obtain_pull_supplier(AC)), + + PPushC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_SupplierAdmin':obtain_push_consumer(AS)), + PPullC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_SupplierAdmin':obtain_pull_consumer(AS)), + + PushC=?match({_,key,_,_,_,_}, 'event_test_PushC':oe_create([])), + PullC=?match({_,key,_,_,_,_}, 'event_test_PullC':oe_create(PPullS)), + + PushS=?match({_,key,_,_,_,_}, 'event_test_PushS':oe_create(PPushC)), + + PullS=?match({_,key,_,_,_,_}, 'event_test_PullS':oe_create([])), + + ?match(ok, 'CosEventChannelAdmin_ProxyPushSupplier':connect_push_consumer(PPushS, PushC)), + ?match(ok, 'CosEventChannelAdmin_ProxyPullSupplier':connect_pull_consumer(PPullS, PullC)), + ?match(ok, 'CosEventChannelAdmin_ProxyPushConsumer':connect_push_supplier(PPushC, PushS)), + ?match(ok, 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PPullC, PullS)), + + %% No events should be available at the consumer side at this point. + ?match({_, false}, event_test_PullC:do_try_pull(PullC)), + ?match([], event_test_PushC:get_data(PushC)), + + %% Push an event and wait to be sure it have reached the destination. + ?match(ok, event_test_PushS:do_push(PushS, Event1)), + ?match(ok, event_test_PushS:do_push(PushS, Event2)), + ?match(ok, event_test_PushS:do_push(PushS, Event3)), + timer:sleep(2000), + ?match({Event1, true}, event_test_PullC:do_try_pull(PullC)), + ?match({Event2, true}, event_test_PullC:do_try_pull(PullC)), + ?match({Event3, true}, event_test_PullC:do_try_pull(PullC)), + ?match({_, false}, event_test_PullC:do_try_pull(PullC)), + ?match([Event1, Event2, Event3], event_test_PushC:get_data(PushC)), + + ?match(ok, event_test_PullS:add_event(PullS, Event4)), + ?match(ok, event_test_PullS:add_event(PullS, Event5)), + ?match(ok, event_test_PullS:add_event(PullS, Event6)), + + %% Since the pull operation is blocking we do not need to "sleep". + %% The ProxyPullConsumer will pull for events according to the pull_interval + %% parameter given when started the channel. + ?match(Event4, event_test_PullC:do_pull(PullC)), + ?match(Event5, event_test_PullC:do_pull(PullC)), + ?match(Event6, event_test_PullC:do_pull(PullC)), + + timer:sleep(2000), + ?match([Event4, Event5, Event6], event_test_PushC:get_data(PushC)), + + + catch corba:dispose(Ch), + %% The client should be notified; wait for a couple of seconds and check it. + timer:sleep(2000), + ?match(true, corba_object:non_existent(PushC)), + ?match(true, corba_object:non_existent(PullC)), + ?match(true, corba_object:non_existent(PushS)), + ?match(true, corba_object:non_existent(PullS)), + + ok. diff --git a/lib/cosEvent/test/event_test_PullC_impl.erl b/lib/cosEvent/test/event_test_PullC_impl.erl new file mode 100644 index 0000000000..186d1cbd51 --- /dev/null +++ b/lib/cosEvent/test/event_test_PullC_impl.erl @@ -0,0 +1,43 @@ +%%------------------------------------------------------------------------ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%------------------------------------------------------------------------ +%% Description: a very simple implementation of PullConsumer interface +%%------------------------------------------------------------------------ +-module(event_test_PullC_impl). + +-export([init/1, terminate/2, disconnect_pull_consumer/1, do_pull/1, do_try_pull/1]). + +init(Proxy) -> + {ok, Proxy}. + +terminate(_From, _Reason) -> + ok. + +disconnect_pull_consumer(Proxy) -> + io:format("event_test_PullC terminates~n",[]), + {stop, normal, ok, Proxy}. + +do_pull(Proxy) -> + {reply, 'CosEventComm_PullSupplier':pull(Proxy), Proxy}. + +do_try_pull(Proxy) -> + {reply, 'CosEventComm_PullSupplier':try_pull(Proxy), Proxy}. + diff --git a/lib/cosEvent/test/event_test_PullS_impl.erl b/lib/cosEvent/test/event_test_PullS_impl.erl new file mode 100644 index 0000000000..b7fa0c34f0 --- /dev/null +++ b/lib/cosEvent/test/event_test_PullS_impl.erl @@ -0,0 +1,57 @@ +%%------------------------------------------------------------------------ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%------------------------------------------------------------------------ +%% Description: a very simple implementation of Pull Supplier interface +%%------------------------------------------------------------------------ +-module(event_test_PullS_impl). + +-include_lib("orber/include/corba.hrl"). + +-export([init/1, terminate/2, pull/1, try_pull/1, disconnect_pull_supplier/1, + add_event/2]). + +init(_) -> + {ok, []}. + +terminate(_From, _Reason) -> + ok. + +pull([]) -> + corba:raise(#'INTERNAL'{completion_status = ?COMPLETED_NO}); +pull([Event|Events]) -> + {reply, Event, Events}. + +try_pull([]) -> + {reply, {#any{typecode=tk_null, value = null}, false}, []}; +try_pull([Event|Events]) -> + {reply, {Event, true}, Events}. + +disconnect_pull_supplier(Events) -> + io:format("event_test_PullS terminates ~p~n", [Events]), + {stop, normal, ok, Events}. + + +add_event(Events, Event) -> + %% Store in FIFO order; don't really care if we use '++' since + %% this operation is used in tests only. + {reply, ok, Events ++ [Event]}. + + diff --git a/lib/cosEvent/test/event_test_PushC_impl.erl b/lib/cosEvent/test/event_test_PushC_impl.erl new file mode 100644 index 0000000000..6eadf74a31 --- /dev/null +++ b/lib/cosEvent/test/event_test_PushC_impl.erl @@ -0,0 +1,46 @@ +%%------------------------------------------------------------------------ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%------------------------------------------------------------------------ +%% Description: a very simple implementation of Push Consumer interface +%%------------------------------------------------------------------------ + +-module(event_test_PushC_impl). + +-export([init/1, terminate/2, push/2, disconnect_push_consumer/1, get_data/1]). + +init(_) -> + {ok, []}. + +terminate(_From, _Reason) -> + ok. + +push(Events, Event) -> + {reply, ok, [Event|Events]}. + +disconnect_push_consumer(Events) -> + io:format("event_test_PushC terminates: ~p~n", [Events]), + {stop, normal, ok, Events}. + + +get_data(Events) -> + %% Returns Events in FIFO order and reset state. + {reply, lists:reverse(Events), []}. + diff --git a/lib/cosEvent/test/event_test_PushS_impl.erl b/lib/cosEvent/test/event_test_PushS_impl.erl new file mode 100644 index 0000000000..da82e97211 --- /dev/null +++ b/lib/cosEvent/test/event_test_PushS_impl.erl @@ -0,0 +1,41 @@ +%%------------------------------------------------------------------------ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%------------------------------------------------------------------------ +%% Description: a very simple implementation of Push Supplier interface +%%------------------------------------------------------------------------ + +-module(event_test_PushS_impl). + +-export([init/1, terminate/2, disconnect_push_supplier/1, do_push/2]). + +init(Proxy) -> + {ok, Proxy}. + +terminate(_From, _Reason) -> + ok. + +disconnect_push_supplier(Proxy) -> + io:format("event_test_PullC terminates~n",[]), + {stop, normal, ok, Proxy}. + +do_push(Proxy, Event) -> + {reply, 'CosEventComm_PushConsumer':push(Proxy, Event), Proxy}. + diff --git a/lib/cosEvent/test/event_test_server.idl b/lib/cosEvent/test/event_test_server.idl new file mode 100644 index 0000000000..1719401ccd --- /dev/null +++ b/lib/cosEvent/test/event_test_server.idl @@ -0,0 +1,47 @@ +// +// %CopyrightBegin% +// +// Copyright Ericsson AB 2001-2010. All Rights Reserved. +// +// The contents of this file are subject to the Erlang Public License, +// Version 1.1, (the "License"); you may not use this file except in +// compliance with the License. You should have received a copy of the +// Erlang Public License along with this software. If not, it can be +// retrieved online at http://www.erlang.org/. +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +// the License for the specific language governing rights and limitations +// under the License. +// +// %CopyrightEnd% +// + +#ifndef _EVENT_TEST_SERVER_IDL +#define _EVENT_TEST_SERVER_IDL + +#include <../src/CosEventComm.idl> + +module event_test { + + interface PushC : CosEventComm::PushConsumer { + typedef sequence<any> AnySeq; + AnySeq get_data(); + }; + interface PullC : CosEventComm::PullConsumer { + any do_pull(); + any do_try_pull(out boolean has_event); + }; + + interface PushS : CosEventComm::PushSupplier { + void do_push(in any Event); + }; + interface PullS : CosEventComm::PullSupplier { + void add_event(in any Event); + }; + +}; + +#endif + + diff --git a/lib/cosEvent/test/generated_SUITE.erl b/lib/cosEvent/test/generated_SUITE.erl new file mode 100644 index 0000000000..2d75b18451 --- /dev/null +++ b/lib/cosEvent/test/generated_SUITE.erl @@ -0,0 +1,487 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : generated_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(generated_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + AcTuAlReS + end + end()). + + +-define(checktc(_Op), + fun(TC) -> + case orber_tc:check_tc(TC) of + false -> + io:format("###### ERROR ERROR ######~n~p - ~p~n", [Op, TC]), + ?line exit(TC); + true -> + true + end + end). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing IC generated files"]; +all(suite) -> + ['CosEventChannelAdmin_AlreadyConnected', 'CosEventChannelAdmin_TypeError', + 'CosEventComm_Disconnected', + 'CosEventChannelAdmin_ConsumerAdmin', 'CosEventChannelAdmin_EventChannel', + 'CosEventChannelAdmin_ProxyPullConsumer', 'CosEventChannelAdmin_ProxyPullSupplier', + 'CosEventChannelAdmin_ProxyPushConsumer', 'CosEventChannelAdmin_ProxyPushSupplier', + 'CosEventChannelAdmin_SupplierAdmin', oe_CosEventComm_CAdmin, + oe_CosEventComm_Channel, oe_CosEventComm_Event, oe_CosEventComm_PullerS, + oe_CosEventComm_PusherS, 'CosEventComm_PullConsumer', + 'CosEventComm_PullSupplier', 'CosEventComm_PushConsumer', + 'CosEventComm_PushSupplier']. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_AlreadyConnected' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_AlreadyConnected'(doc) -> [""]; +'CosEventChannelAdmin_AlreadyConnected'(suite) -> []; +'CosEventChannelAdmin_AlreadyConnected'(_) -> + ?match(true, orber_tc:check_tc('CosEventChannelAdmin_AlreadyConnected':tc())), + ?match("IDL:omg.org/CosEventChannelAdmin/AlreadyConnected:1.0", + 'CosEventChannelAdmin_AlreadyConnected':id()), + ?match("CosEventChannelAdmin_AlreadyConnected", + 'CosEventChannelAdmin_AlreadyConnected':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_TypeError' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_TypeError'(doc) -> [""]; +'CosEventChannelAdmin_TypeError'(suite) -> []; +'CosEventChannelAdmin_TypeError'(_) -> + ?match(true, orber_tc:check_tc('CosEventChannelAdmin_TypeError':tc())), + ?match("IDL:omg.org/CosEventChannelAdmin/TypeError:1.0", + 'CosEventChannelAdmin_TypeError':id()), + ?match("CosEventChannelAdmin_TypeError", + 'CosEventChannelAdmin_TypeError':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventComm_Disconnected' +%% Description: +%%----------------------------------------------------------------- +'CosEventComm_Disconnected'(doc) -> [""]; +'CosEventComm_Disconnected'(suite) -> []; +'CosEventComm_Disconnected'(_) -> + ?match(true, orber_tc:check_tc('CosEventComm_Disconnected':tc())), + ?match("IDL:omg.org/CosEventComm/Disconnected:1.0", + 'CosEventComm_Disconnected':id()), + ?match("CosEventComm_Disconnected", 'CosEventComm_Disconnected':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_ConsumerAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_ConsumerAdmin'(doc) -> [""]; +'CosEventChannelAdmin_ConsumerAdmin'(suite) -> []; +'CosEventChannelAdmin_ConsumerAdmin'(_) -> + ?nomatch(undefined, 'CosEventChannelAdmin_ConsumerAdmin':oe_tc(obtain_push_supplier)), + ?nomatch(undefined, 'CosEventChannelAdmin_ConsumerAdmin':oe_tc(obtain_pull_supplier)), + ?match(undefined, 'CosEventChannelAdmin_ConsumerAdmin':oe_tc(undefined)), + ?match([_|_], 'CosEventChannelAdmin_ConsumerAdmin':oe_get_interface()), + ?match("IDL:omg.org/CosEventChannelAdmin/ConsumerAdmin:1.0", + 'CosEventChannelAdmin_ConsumerAdmin':typeID()), + check_tc('CosEventChannelAdmin_ConsumerAdmin':oe_get_interface()), + ?match(true, 'CosEventChannelAdmin_ConsumerAdmin':oe_is_a('CosEventChannelAdmin_ConsumerAdmin':typeID())), + ?match(false, 'CosEventChannelAdmin_ConsumerAdmin':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_EventChannel' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_EventChannel'(doc) -> [""]; +'CosEventChannelAdmin_EventChannel'(suite) -> []; +'CosEventChannelAdmin_EventChannel'(_) -> + ?nomatch(undefined, 'CosEventChannelAdmin_EventChannel':oe_tc(for_consumers)), + ?nomatch(undefined, 'CosEventChannelAdmin_EventChannel':oe_tc(for_suppliers)), + ?nomatch(undefined, 'CosEventChannelAdmin_EventChannel':oe_tc(destroy)), + ?match(undefined, 'CosEventChannelAdmin_EventChannel':oe_tc(undefined)), + ?match([_|_], 'CosEventChannelAdmin_EventChannel':oe_get_interface()), + ?match("IDL:omg.org/CosEventChannelAdmin/EventChannel:1.0", + 'CosEventChannelAdmin_EventChannel':typeID()), + check_tc('CosEventChannelAdmin_EventChannel':oe_get_interface()), + ?match(true, 'CosEventChannelAdmin_EventChannel':oe_is_a('CosEventChannelAdmin_EventChannel':typeID())), + ?match(false, 'CosEventChannelAdmin_EventChannel':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_ProxyPullConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_ProxyPullConsumer'(doc) -> [""]; +'CosEventChannelAdmin_ProxyPullConsumer'(suite) -> []; +'CosEventChannelAdmin_ProxyPullConsumer'(_) -> + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPullConsumer':oe_tc(connect_pull_supplier)), + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPullConsumer':oe_tc(disconnect_pull_consumer)), + ?match(undefined, 'CosEventChannelAdmin_ProxyPullConsumer':oe_tc(undefined)), + ?match([_|_], 'CosEventChannelAdmin_ProxyPullConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosEventChannelAdmin/ProxyPullConsumer:1.0", + 'CosEventChannelAdmin_ProxyPullConsumer':typeID()), + check_tc('CosEventChannelAdmin_ProxyPullConsumer':oe_get_interface()), + ?match(true, 'CosEventChannelAdmin_ProxyPullConsumer':oe_is_a('CosEventChannelAdmin_ProxyPullConsumer':typeID())), + ?match(true, 'CosEventChannelAdmin_ProxyPullConsumer':oe_is_a('CosEventComm_PullConsumer':typeID())), + ?match(false, 'CosEventChannelAdmin_ProxyPullConsumer':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_ProxyPullSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_ProxyPullSupplier'(doc) -> [""]; +'CosEventChannelAdmin_ProxyPullSupplier'(suite) -> []; +'CosEventChannelAdmin_ProxyPullSupplier'(_) -> + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPullSupplier':oe_tc(connect_pull_consumer)), + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPullSupplier':oe_tc(pull)), + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPullSupplier':oe_tc(try_pull)), + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPullSupplier':oe_tc(disconnect_pull_supplier)), + ?match(undefined, 'CosEventChannelAdmin_ProxyPullSupplier':oe_tc(undefined)), + ?match([_|_], 'CosEventChannelAdmin_ProxyPullSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosEventChannelAdmin/ProxyPullSupplier:1.0", + 'CosEventChannelAdmin_ProxyPullSupplier':typeID()), + check_tc('CosEventChannelAdmin_ProxyPullSupplier':oe_get_interface()), + ?match(true, 'CosEventChannelAdmin_ProxyPullSupplier':oe_is_a('CosEventChannelAdmin_ProxyPullSupplier':typeID())), + ?match(true, 'CosEventChannelAdmin_ProxyPullSupplier':oe_is_a('CosEventComm_PullSupplier':typeID())), + ?match(false, 'CosEventChannelAdmin_ProxyPullSupplier':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_ProxyPushConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_ProxyPushConsumer'(doc) -> [""]; +'CosEventChannelAdmin_ProxyPushConsumer'(suite) -> []; +'CosEventChannelAdmin_ProxyPushConsumer'(_) -> + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPushConsumer':oe_tc(connect_push_supplier)), + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPushConsumer':oe_tc(push)), + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPushConsumer':oe_tc(disconnect_push_consumer)), + ?match(undefined, 'CosEventChannelAdmin_ProxyPushConsumer':oe_tc(undefined)), + ?match([_|_], 'CosEventChannelAdmin_ProxyPushConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosEventChannelAdmin/ProxyPushConsumer:1.0", + 'CosEventChannelAdmin_ProxyPushConsumer':typeID()), + check_tc('CosEventChannelAdmin_ProxyPushConsumer':oe_get_interface()), + ?match(true, 'CosEventChannelAdmin_ProxyPushConsumer':oe_is_a('CosEventChannelAdmin_ProxyPushConsumer':typeID())), + ?match(true, 'CosEventChannelAdmin_ProxyPushConsumer':oe_is_a('CosEventComm_PushConsumer':typeID())), + ?match(false, 'CosEventChannelAdmin_ProxyPushConsumer':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_ProxyPushSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_ProxyPushSupplier'(doc) -> [""]; +'CosEventChannelAdmin_ProxyPushSupplier'(suite) -> []; +'CosEventChannelAdmin_ProxyPushSupplier'(_) -> + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPushSupplier':oe_tc(connect_push_consumer)), + ?nomatch(undefined, 'CosEventChannelAdmin_ProxyPushSupplier':oe_tc(disconnect_push_supplier)), + ?match(undefined, 'CosEventChannelAdmin_ProxyPushSupplier':oe_tc(undefined)), + ?match([_|_], 'CosEventChannelAdmin_ProxyPushSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosEventChannelAdmin/ProxyPushSupplier:1.0", + 'CosEventChannelAdmin_ProxyPushSupplier':typeID()), + check_tc('CosEventChannelAdmin_ProxyPushSupplier':oe_get_interface()), + ?match(true, 'CosEventChannelAdmin_ProxyPushSupplier':oe_is_a('CosEventChannelAdmin_ProxyPushSupplier':typeID())), + ?match(true, 'CosEventChannelAdmin_ProxyPushSupplier':oe_is_a('CosEventComm_PushSupplier':typeID())), + ?match(false, 'CosEventChannelAdmin_ProxyPushSupplier':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventChannelAdmin_SupplierAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosEventChannelAdmin_SupplierAdmin'(doc) -> [""]; +'CosEventChannelAdmin_SupplierAdmin'(suite) -> []; +'CosEventChannelAdmin_SupplierAdmin'(_) -> + ?nomatch(undefined, 'CosEventChannelAdmin_SupplierAdmin':oe_tc(obtain_push_consumer)), + ?nomatch(undefined, 'CosEventChannelAdmin_SupplierAdmin':oe_tc(obtain_pull_consumer)), + ?match(undefined, 'CosEventChannelAdmin_SupplierAdmin':oe_tc(undefined)), + ?match([_|_], 'CosEventChannelAdmin_SupplierAdmin':oe_get_interface()), + ?match("IDL:omg.org/CosEventChannelAdmin/SupplierAdmin:1.0", + 'CosEventChannelAdmin_SupplierAdmin':typeID()), + check_tc('CosEventChannelAdmin_SupplierAdmin':oe_get_interface()), + ?match(true, 'CosEventChannelAdmin_SupplierAdmin':oe_is_a('CosEventChannelAdmin_SupplierAdmin':typeID())), + ?match(false, 'CosEventChannelAdmin_SupplierAdmin':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'oe_CosEventComm_CAdmin' +%% Description: +%%----------------------------------------------------------------- +'oe_CosEventComm_CAdmin'(doc) -> [""]; +'oe_CosEventComm_CAdmin'(suite) -> []; +'oe_CosEventComm_CAdmin'(_) -> + ?nomatch(undefined, 'oe_CosEventComm_CAdmin':oe_tc(obtain_push_supplier)), + ?nomatch(undefined, 'oe_CosEventComm_CAdmin':oe_tc(obtain_pull_supplier)), + ?nomatch(undefined, 'oe_CosEventComm_CAdmin':oe_tc(send)), + ?nomatch(undefined, 'oe_CosEventComm_CAdmin':oe_tc(send_sync)), + ?match(undefined, 'oe_CosEventComm_CAdmin':oe_tc(undefined)), + ?match([_|_], 'oe_CosEventComm_CAdmin':oe_get_interface()), + ?match("IDL:oe_CosEventComm/CAdmin:1.0", + 'oe_CosEventComm_CAdmin':typeID()), + check_tc('oe_CosEventComm_CAdmin':oe_get_interface()), + ?match(true, 'oe_CosEventComm_CAdmin':oe_is_a('oe_CosEventComm_CAdmin':typeID())), + ?match(true, 'oe_CosEventComm_CAdmin':oe_is_a('CosEventChannelAdmin_ConsumerAdmin':typeID())), + ?match(true, 'oe_CosEventComm_CAdmin':oe_is_a('oe_CosEventComm_Event':typeID())), + ?match(false, 'oe_CosEventComm_CAdmin':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'oe_CosEventComm_Channel' +%% Description: +%%----------------------------------------------------------------- +'oe_CosEventComm_Channel'(doc) -> [""]; +'oe_CosEventComm_Channel'(suite) -> []; +'oe_CosEventComm_Channel'(_) -> + ?nomatch(undefined, 'oe_CosEventComm_Channel':oe_tc(for_consumers)), + ?nomatch(undefined, 'oe_CosEventComm_Channel':oe_tc(for_suppliers)), + ?nomatch(undefined, 'oe_CosEventComm_Channel':oe_tc(destroy)), + ?nomatch(undefined, 'oe_CosEventComm_Channel':oe_tc(send)), + ?nomatch(undefined, 'oe_CosEventComm_Channel':oe_tc(send_sync)), + ?match(undefined, 'oe_CosEventComm_Channel':oe_tc(undefined)), + ?match([_|_], 'oe_CosEventComm_Channel':oe_get_interface()), + ?match("IDL:oe_CosEventComm/Channel:1.0", + 'oe_CosEventComm_Channel':typeID()), + check_tc('oe_CosEventComm_Channel':oe_get_interface()), + ?match(true, 'oe_CosEventComm_Channel':oe_is_a('oe_CosEventComm_Channel':typeID())), + ?match(true, 'oe_CosEventComm_Channel':oe_is_a('CosEventChannelAdmin_EventChannel':typeID())), + ?match(true, 'oe_CosEventComm_Channel':oe_is_a('oe_CosEventComm_Event':typeID())), + ?match(false, 'oe_CosEventComm_Channel':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'oe_CosEventComm_Event' +%% Description: +%%----------------------------------------------------------------- +'oe_CosEventComm_Event'(doc) -> [""]; +'oe_CosEventComm_Event'(suite) -> []; +'oe_CosEventComm_Event'(_) -> + ?nomatch(undefined, 'oe_CosEventComm_Event':oe_tc(send)), + ?nomatch(undefined, 'oe_CosEventComm_Event':oe_tc(send_sync)), + ?match(undefined, 'oe_CosEventComm_Event':oe_tc(undefined)), + ?match([_|_], 'oe_CosEventComm_Event':oe_get_interface()), + ?match("IDL:oe_CosEventComm/Event:1.0", + 'oe_CosEventComm_Event':typeID()), + check_tc('oe_CosEventComm_Event':oe_get_interface()), + ?match(true, 'oe_CosEventComm_Event':oe_is_a('oe_CosEventComm_Event':typeID())), + ?match(false, 'oe_CosEventComm_Event':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'oe_CosEventComm_PullerS' +%% Description: +%%----------------------------------------------------------------- +'oe_CosEventComm_PullerS'(doc) -> [""]; +'oe_CosEventComm_PullerS'(suite) -> []; +'oe_CosEventComm_PullerS'(_) -> + ?nomatch(undefined, 'oe_CosEventComm_PullerS':oe_tc(connect_pull_consumer)), + ?nomatch(undefined, 'oe_CosEventComm_PullerS':oe_tc(pull)), + ?nomatch(undefined, 'oe_CosEventComm_PullerS':oe_tc(try_pull)), + ?nomatch(undefined, 'oe_CosEventComm_PullerS':oe_tc(disconnect_pull_supplier)), + ?nomatch(undefined, 'oe_CosEventComm_PullerS':oe_tc(send)), + ?nomatch(undefined, 'oe_CosEventComm_PullerS':oe_tc(send_sync)), + ?match(undefined, 'oe_CosEventComm_PullerS':oe_tc(undefined)), + ?match([_|_], 'oe_CosEventComm_PullerS':oe_get_interface()), + ?match("IDL:oe_CosEventComm/PullerS:1.0", + 'oe_CosEventComm_PullerS':typeID()), + check_tc('oe_CosEventComm_PullerS':oe_get_interface()), + ?match(true, 'oe_CosEventComm_PullerS':oe_is_a('oe_CosEventComm_PullerS':typeID())), + ?match(true, 'oe_CosEventComm_PullerS':oe_is_a('CosEventChannelAdmin_ProxyPullSupplier':typeID())), + ?match(true, 'oe_CosEventComm_PullerS':oe_is_a('CosEventComm_PullSupplier':typeID())), + ?match(true, 'oe_CosEventComm_PullerS':oe_is_a('oe_CosEventComm_Event':typeID())), + ?match(false, 'oe_CosEventComm_PullerS':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'oe_CosEventComm_PusherS' +%% Description: +%%----------------------------------------------------------------- +'oe_CosEventComm_PusherS'(doc) -> [""]; +'oe_CosEventComm_PusherS'(suite) -> []; +'oe_CosEventComm_PusherS'(_) -> + ?nomatch(undefined, 'oe_CosEventComm_PusherS':oe_tc(connect_push_consumer)), + ?nomatch(undefined, 'oe_CosEventComm_PusherS':oe_tc(disconnect_push_supplier)), + ?nomatch(undefined, 'oe_CosEventComm_PusherS':oe_tc(send)), + ?nomatch(undefined, 'oe_CosEventComm_PusherS':oe_tc(send_sync)), + ?match(undefined, 'oe_CosEventComm_PusherS':oe_tc(undefined)), + ?match([_|_], 'oe_CosEventComm_PusherS':oe_get_interface()), + ?match("IDL:oe_CosEventComm/PusherS:1.0", + 'oe_CosEventComm_PusherS':typeID()), + check_tc('oe_CosEventComm_PusherS':oe_get_interface()), + ?match(true, 'oe_CosEventComm_PusherS':oe_is_a('oe_CosEventComm_PusherS':typeID())), + ?match(true, 'oe_CosEventComm_PusherS':oe_is_a('CosEventChannelAdmin_ProxyPushSupplier':typeID())), + ?match(true, 'oe_CosEventComm_PusherS':oe_is_a('CosEventComm_PushSupplier':typeID())), + ?match(true, 'oe_CosEventComm_PusherS':oe_is_a('oe_CosEventComm_Event':typeID())), + ?match(false, 'oe_CosEventComm_PusherS':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventComm_PullConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosEventComm_PullConsumer'(doc) -> [""]; +'CosEventComm_PullConsumer'(suite) -> []; +'CosEventComm_PullConsumer'(_) -> + ?nomatch(undefined, 'CosEventComm_PullConsumer':oe_tc(disconnect_pull_consumer)), + ?match(undefined, 'CosEventComm_PullConsumer':oe_tc(undefined)), + ?match([_|_], 'CosEventComm_PullConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosEventComm/PullConsumer:1.0", + 'CosEventComm_PullConsumer':typeID()), + check_tc('CosEventComm_PullConsumer':oe_get_interface()), + ?match(true, 'CosEventComm_PullConsumer':oe_is_a('CosEventComm_PullConsumer':typeID())), + ?match(false, 'CosEventComm_PullConsumer':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventComm_PullSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosEventComm_PullSupplier'(doc) -> [""]; +'CosEventComm_PullSupplier'(suite) -> []; +'CosEventComm_PullSupplier'(_) -> + ?nomatch(undefined, 'CosEventComm_PullSupplier':oe_tc(pull)), + ?nomatch(undefined, 'CosEventComm_PullSupplier':oe_tc(try_pull)), + ?nomatch(undefined, 'CosEventComm_PullSupplier':oe_tc(disconnect_pull_supplier)), + ?match(undefined, 'CosEventComm_PullSupplier':oe_tc(undefined)), + ?match([_|_], 'CosEventComm_PullSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosEventComm/PullSupplier:1.0", + 'CosEventComm_PullSupplier':typeID()), + check_tc('CosEventComm_PullSupplier':oe_get_interface()), + ?match(true, 'CosEventComm_PullSupplier':oe_is_a('CosEventComm_PullSupplier':typeID())), + ?match(false, 'CosEventComm_PullSupplier':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventComm_PushConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosEventComm_PushConsumer'(doc) -> [""]; +'CosEventComm_PushConsumer'(suite) -> []; +'CosEventComm_PushConsumer'(_) -> + ?nomatch(undefined, 'CosEventComm_PushConsumer':oe_tc(push)), + ?nomatch(undefined, 'CosEventComm_PushConsumer':oe_tc(disconnect_push_consumer)), + ?match(undefined, 'CosEventComm_PushConsumer':oe_tc(undefined)), + ?match([_|_], 'CosEventComm_PushConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosEventComm/PushConsumer:1.0", + 'CosEventComm_PushConsumer':typeID()), + check_tc('CosEventComm_PushConsumer':oe_get_interface()), + ?match(true, 'CosEventComm_PushConsumer':oe_is_a('CosEventComm_PushConsumer':typeID())), + ?match(false, 'CosEventComm_PushConsumer':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventComm_PushSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosEventComm_PushSupplier'(doc) -> [""]; +'CosEventComm_PushSupplier'(suite) -> []; +'CosEventComm_PushSupplier'(_) -> + ?nomatch(undefined, 'CosEventComm_PushSupplier':oe_tc(disconnect_push_supplier)), + ?match(undefined, 'CosEventComm_PushSupplier':oe_tc(undefined)), + ?match([_|_], 'CosEventComm_PushSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosEventComm/PushSupplier:1.0", + 'CosEventComm_PushSupplier':typeID()), + check_tc('CosEventComm_PushSupplier':oe_get_interface()), + ?match(true, 'CosEventComm_PushSupplier':oe_is_a('CosEventComm_PushSupplier':typeID())), + ?match(false, 'CosEventComm_PushSupplier':oe_is_a("wrong")), + ok. + + + +%%----------------------------------------------------------------- +%% MISC functions +%%----------------------------------------------------------------- +check_tc([]) -> + ok; +check_tc([{Op, {RetType, InParameters, OutParameters}}|T]) -> + io:format("checked - ~s~n", [Op]), + lists:all(?checktc(Op), [RetType|InParameters]), + lists:all(?checktc(Op), OutParameters), + check_tc(T). + + diff --git a/lib/cosEvent/test/idl_output/.gitignore b/lib/cosEvent/test/idl_output/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/lib/cosEvent/test/idl_output/.gitignore diff --git a/lib/cosEvent/vsn.mk b/lib/cosEvent/vsn.mk index 8915903bbe..9f326b39b6 100644 --- a/lib/cosEvent/vsn.mk +++ b/lib/cosEvent/vsn.mk @@ -1,7 +1,9 @@ -COSEVENT_VSN = 2.1.8 +COSEVENT_VSN = 2.1.9 -TICKETS = OTP-8355 \ +TICKETS = OTP-8543 + +TICKETS_2.1.8 = OTP-8355 \ OTP-8409 TICKETS_2.1.7 = OTP-8201 diff --git a/lib/cosEventDomain/doc/src/notes.xml b/lib/cosEventDomain/doc/src/notes.xml index 0ad42948af..deb1985c86 100644 --- a/lib/cosEventDomain/doc/src/notes.xml +++ b/lib/cosEventDomain/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2001</year><year>2009</year> + <year>2001</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>cosEventDomain Release Notes</title> @@ -32,6 +32,22 @@ </header> <section> + <title>cosEventDomain 1.1.9</title> + <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Test suites published.</p> + <p> + Own Id: OTP-8543 Aux Id:</p> + </item> + </list> + </section> + + </section> + + <section> <title>cosEventDomain 1.1.8</title> <section> diff --git a/lib/cosEventDomain/test/Makefile b/lib/cosEventDomain/test/Makefile new file mode 100644 index 0000000000..9893b05b8c --- /dev/null +++ b/lib/cosEventDomain/test/Makefile @@ -0,0 +1,104 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2001-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(COSEVENTDOMAIN_VSN) +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/cosEventDomain_test + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +TEST_SPEC_FILE = cosEventDomain.spec + + +MODULES = \ + event_domain_SUITE \ + generated_SUITE + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = + +SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) + +TARGET_FILES = \ + $(SUITE_TARGET_FILES) + +# ---------------------------------------------------- +# PROGRAMS +# ---------------------------------------------------- +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/orber/ebin -pa $(ERL_TOP)/lib/ic/ebin + +ERL_COMPILE_FLAGS += \ + $(ERL_IDL_FLAGS) \ + -pa $(ERL_TOP)/lib/test_server/ebin \ + -pa $(ERL_TOP)/lib/cosEventDomain/ebin \ + -pa $(ERL_TOP)/lib/cosEventDomain/include \ + -pa $(ERL_TOP)/lib/cosNotification/ebin \ + -pa $(ERL_TOP)/lib/cosNotification/include \ + -I$(ERL_TOP)/lib/cosEventDomain/include \ + -I$(ERL_TOP)/lib/cosNotification/include \ + -I$(ERL_TOP)/lib/cosNotification/ebin \ + -I$(ERL_TOP)/lib/test_server/include + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- +tests debug opt: $(TARGET_FILES) + +clean: + rm -f $(TARGET_FILES) + rm -f errs core *~ + + +docs: + +# ---------------------------------------------------- +# Special Targets +# ---------------------------------------------------- + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +# We don't copy generated intermediate erlang and hrl files + +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: + +release_docs_spec: + +release_tests_spec: tests + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(TEST_SPEC_FILE) \ + $(ERL_FILES) $(RELSYSDIR) + $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR) + diff --git a/lib/cosEventDomain/test/cosEventDomain.spec b/lib/cosEventDomain/test/cosEventDomain.spec new file mode 100644 index 0000000000..0d3e307071 --- /dev/null +++ b/lib/cosEventDomain/test/cosEventDomain.spec @@ -0,0 +1,19 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{topcase, {dir, "../cosEventDomain_test"}}. diff --git a/lib/cosEventDomain/test/event_domain_SUITE.erl b/lib/cosEventDomain/test/event_domain_SUITE.erl new file mode 100644 index 0000000000..ddf0af3489 --- /dev/null +++ b/lib/cosEventDomain/test/event_domain_SUITE.erl @@ -0,0 +1,456 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- + +-module(event_domain_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("cosNotification/include/CosNotifyChannelAdmin.hrl"). +-include_lib("cosNotification/include/CosNotification.hrl"). + +-include_lib("cosEventDomain/include/CosEventDomainAdmin.hrl"). +-include_lib("cosEventDomain/src/cosEventDomainApp.hrl"). + +%%----------------------------------------------------------------- +%% Macros +%%----------------------------------------------------------------- + +-define(default_timeout, ?t:minutes(5)). + + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, event_domain_api/1, event_domain_factory_api/1, + cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2, app_test/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- + +all(doc) -> ["API tests for the cosEventDomain interfaces", ""]; +all(suite) -> {req, + [mnesia, orber, cosNotification], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [event_domain_api, event_domain_factory_api, app_test]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) when is_list(Config) -> + mnesia:delete_schema([node()]), + mnesia:create_schema([node()]), + ok = corba:orb_init([{flags, 16#02}, + {orber_debug_level, 10}]), + orber:install([node()]), + application:start(mnesia), + application:start(orber), + cosEventApp:install(), + cosEventApp:start(), + cosNotificationApp:install(), + cosNotificationApp:start(), + cosEventDomainApp:install(), + cosEventDomainApp:start(), + Config. + +finish_all(Config) when is_list(Config) -> + cosEventDomainApp:stop(), + cosEventDomainApp:uninstall(), + cosNotificationApp:stop(), + cosNotificationApp:uninstall(), + cosEventApp:stop(), + cosEventApp:uninstall(), + application:stop(orber), + application:stop(mnesia), + mnesia:delete_schema([node()]), + Config. + +%%----------------------------------------------------------------- +%% Tests app file +%%----------------------------------------------------------------- +app_test(doc) -> []; +app_test(suite) -> []; +app_test(_Config) -> + ok=test_server:app_test(cosEventDomain), + ok. + + +event_domain_api(doc) -> ["Testing the CosEventDomain Domain API", ""]; +event_domain_api(suite) -> []; +event_domain_api(_Config) -> + + %% We will setup a cluster looking like: + %% 7-8---> + %% / + %% 2 - 4 6-> + %% \ / + %% 5---9-1-3 + + %% 2-4 + %% 4-1 + %% 1-3 + %% 3-6 + %% 5-9 + %% 9-1 + %% 4-7 + %% 7-8 + + + ChFac = ?match({_,key,_,_,_,_}, + cosNotificationApp:start_global_factory([{pullInterval,1}])), + {Ch0,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + Fac = ?match({_,key,_,_,_,_}, + cosEventDomainApp:start_factory()), + {ED, _} = ?match({{_,key,_,_,_,_}, _}, + 'CosEventDomainAdmin_EventDomainFactory':create_event_domain(Fac, [], [])), + ID0 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch0), + ?match(Ch0, 'CosEventDomainAdmin_EventDomain':get_channel(ED, ID0)), + ?match([0], 'CosEventDomainAdmin_EventDomain':get_all_channels(ED)), + ?match({'EXCEPTION',{'CosNotifyChannelAdmin_ChannelNotFound',_}}, + 'CosEventDomainAdmin_EventDomain':get_channel(ED, 100)), + ?match({'EXCEPTION',{'CosNotifyChannelAdmin_ChannelNotFound',_}}, + 'CosEventDomainAdmin_EventDomain':remove_channel(ED, 100)), + ?match(ok, 'CosEventDomainAdmin_EventDomain':remove_channel(ED, 0)), + ?match([], 'CosEventDomainAdmin_EventDomain':get_all_channels(ED)), + ?match({'EXCEPTION',{'CosNotifyChannelAdmin_ChannelNotFound',_}}, + 'CosEventDomainAdmin_EventDomain':remove_channel(ED, 0)), + + %% Create a new event channel. + {Ch1,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + {Ch2,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + {Ch3,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + {Ch4,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + {Ch5,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + {Ch6,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + {Ch7,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + {Ch8,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + {Ch9,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(ChFac, [], [])), + + ID1 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch1), + ID2 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch2), + ID3 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch3), + ID4 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch4), + ID5 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch5), + ID6 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch6), + ID7 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch7), + ID8 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch8), + ID9 = 'CosEventDomainAdmin_EventDomain':add_channel(ED, Ch9), + ?match([_,_,_,_,_,_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_all_channels(ED)), + + ?match([], 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + C1 = #'CosEventDomainAdmin_Connection'{supplier_id=ID2, + consumer_id=ID4, + ctype='STRUCTURED_EVENT', + notification_style='Pull'}, + C2 = #'CosEventDomainAdmin_Connection'{supplier_id=ID4, + consumer_id=ID1, + ctype='ANY_EVENT', + notification_style='Push'}, + C3 = #'CosEventDomainAdmin_Connection'{supplier_id=ID1, + consumer_id=ID3, + ctype='ANY_EVENT', + notification_style='Pull'}, + C4 = #'CosEventDomainAdmin_Connection'{supplier_id=ID3, + consumer_id=ID6, + ctype='STRUCTURED_EVENT', + notification_style='Push'}, + C5 = #'CosEventDomainAdmin_Connection'{supplier_id=ID5, + consumer_id=ID9, + ctype='ANY_EVENT', + notification_style='Pull'}, + C6 = #'CosEventDomainAdmin_Connection'{supplier_id=ID9, + consumer_id=ID1, + ctype='ANY_EVENT', + notification_style='Push'}, + C7 = #'CosEventDomainAdmin_Connection'{supplier_id=ID4, + consumer_id=ID7, + ctype='STRUCTURED_EVENT', + notification_style='Pull'}, + C8 = #'CosEventDomainAdmin_Connection'{supplier_id=ID7, + consumer_id=ID8, + ctype='ANY_EVENT', + notification_style='Push'}, + C9 = #'CosEventDomainAdmin_Connection'{supplier_id=ID8, + consumer_id=ID4, + ctype='ANY_EVENT', + notification_style='Pull'}, + C10 = #'CosEventDomainAdmin_Connection'{supplier_id=ID5, + consumer_id=ID4, + ctype='ANY_EVENT', + notification_style='Pull'}, + C11 = #'CosEventDomainAdmin_Connection'{supplier_id=ID4, + consumer_id=ID6, + ctype='ANY_EVENT', + notification_style='Pull'}, + C12 = #'CosEventDomainAdmin_Connection'{supplier_id=ID8, + consumer_id=ID6, + ctype='ANY_EVENT', + notification_style='Pull'}, + + CID1 = 'CosEventDomainAdmin_EventDomain':add_connection(ED, C1), + ?match([CID1], 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + _CID2 = 'CosEventDomainAdmin_EventDomain':add_connection(ED, C2), + ?match([_,_], + 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + _CID3 = 'CosEventDomainAdmin_EventDomain':add_connection(ED, C3), + ?match([_,_,_], + 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + _CID4 = 'CosEventDomainAdmin_EventDomain':add_connection(ED, C4), + ?match([_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + _CID5 = 'CosEventDomainAdmin_EventDomain':add_connection(ED, C5), + ?match([_,_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + _CID6 = 'CosEventDomainAdmin_EventDomain':add_connection(ED, C6), + ?match([_,_,_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + CID7 = 'CosEventDomainAdmin_EventDomain':add_connection(ED, C7), + ?match([_,_,_,_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + _CID8 = 'CosEventDomainAdmin_EventDomain':add_connection(ED, C8), + ?match([_,_,_,_,_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + + ?match({'EXCEPTION',{'CosEventDomainAdmin_AlreadyExists', _}}, + 'CosEventDomainAdmin_EventDomain':add_connection(ED, C8)), + %% No cycles should exist. + ?match([], 'CosEventDomainAdmin_EventDomain':get_cycles(ED)), + + ?match([_, _], 'CosEventDomainAdmin_EventDomain':get_qos(ED)), + AllowCyclic = #'CosNotification_Property'{name=?CycleDetection, + value=any:create(orber_tc:short(), + ?AuthorizeCycles)}, + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosEventDomainAdmin_EventDomain':set_qos(ED, [AllowCyclic])), + ForbidCyclic = #'CosNotification_Property'{name=?CycleDetection, + value=any:create(orber_tc:short(), + ?ForbidCycles)}, + %% The same as before; must work. + ?match(ok, 'CosEventDomainAdmin_EventDomain':set_qos(ED, [ForbidCyclic])), + + AllowDiamonds = #'CosNotification_Property'{name=?DiamondDetection, + value=any:create(orber_tc:short(), + ?AuthorizeDiamonds)}, + %% Since no diamonds allowed before this is always ok. + ?match(ok, 'CosEventDomainAdmin_EventDomain':set_qos(ED, [AllowDiamonds])), + + ?match([_, _], 'CosEventDomainAdmin_EventDomain':get_qos(ED)), + + ForbidDiamonds = #'CosNotification_Property'{name=?DiamondDetection, + value=any:create(orber_tc:short(), + ?ForbidDiamonds)}, + %% No diamonds created before. Hence, will work. + ?match(ok, 'CosEventDomainAdmin_EventDomain':set_qos(ED, [ForbidDiamonds])), + + ?match([_, _], 'CosEventDomainAdmin_EventDomain':get_qos(ED)), + + ?match({ok, [_]}, 'CosEventDomainAdmin_EventDomain':validate_qos(ED, + [ForbidDiamonds, + ForbidCyclic])), + %% No diamonds exists, hence, this is ok. + ?match({ok, [_]}, 'CosEventDomainAdmin_EventDomain':validate_qos(ED, + [AllowDiamonds, + ForbidCyclic])), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosEventDomainAdmin_EventDomain':validate_qos(ED, [ForbidDiamonds, + AllowCyclic])), + + %% Since the ED is started is asyclic we may not succeed with this invokation. + ?match({'EXCEPTION',{'CosEventDomainAdmin_CycleCreationForbidden',_,_}}, + 'CosEventDomainAdmin_EventDomain':add_connection(ED, C9)), + ?match([], 'CosEventDomainAdmin_EventDomain':get_offer_channels(ED, ID2)), + + ?match([2], 'CosEventDomainAdmin_EventDomain':get_offer_channels(ED, ID4)), + ?match([_,_,_], 'CosEventDomainAdmin_EventDomain':get_offer_channels(ED, ID8)), + ?match({'EXCEPTION',{'CosNotifyChannelAdmin_ChannelNotFound',_}}, + 'CosEventDomainAdmin_EventDomain':get_offer_channels(ED, 100)), + ?match([], 'CosEventDomainAdmin_EventDomain':get_subscription_channels(ED, ID8)), + ?match([_,_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_subscription_channels(ED, ID4)), + ?match([_,_,_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_subscription_channels(ED, ID2)), + ?match({'EXCEPTION',{'CosNotifyChannelAdmin_ChannelNotFound',_}}, + 'CosEventDomainAdmin_EventDomain':get_subscription_channels(ED, 100)), + Nil = corba:create_nil_objref(), + + P2=?match({_,key,_,_,_,_}, + 'CosEventDomainAdmin_EventDomain':connect_push_supplier_with_id(ED, Nil, ID2)), + P7=?match({_,key,_,_,_,_}, + 'CosEventDomainAdmin_EventDomain':connect_push_supplier_with_id(ED, Nil, ID7)), + P8=?match({_,key,_,_,_,_}, + 'CosEventDomainAdmin_EventDomain':connect_pull_consumer_with_id(ED, Nil, ID8)), + P6=?match({_,key,_,_,_,_}, + 'CosEventDomainAdmin_EventDomain':connect_pull_consumer_with_id(ED, Nil, ID6)), + E1 = #any{typecode=tk_long, value=1}, + E2 = #any{typecode=tk_long, value=2}, + + ?match(ok, 'CosNotifyChannelAdmin_ProxyPushConsumer':push(P2, E1)), + ?match(E1, 'CosNotifyChannelAdmin_ProxyPullSupplier':pull(P8)), + ?match(E1, 'CosNotifyChannelAdmin_ProxyPullSupplier':pull(P6)), + ?match(ok, 'CosNotifyChannelAdmin_ProxyPushConsumer':push(P7, E2)), + ?match(E2, 'CosNotifyChannelAdmin_ProxyPullSupplier':pull(P8)), + timer:sleep(10000), + ?match({_,false}, 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(P6)), + + ?match(ok, 'CosEventDomainAdmin_EventDomain':remove_connection(ED, CID7)), + + ?match({'EXCEPTION',{'CosEventDomainAdmin_ConnectionNotFound',_}}, + 'CosEventDomainAdmin_EventDomain':remove_connection(ED, CID7)), + + ?match({'EXCEPTION',{'CosEventDomainAdmin_ConnectionNotFound',_}}, + 'CosEventDomainAdmin_EventDomain':remove_connection(ED, 100)), + + ?match([], 'CosEventDomainAdmin_EventDomain':get_offer_channels(ED, ID7)), + ?match([2], 'CosEventDomainAdmin_EventDomain':get_offer_channels(ED, ID4)), + + ?match([8], 'CosEventDomainAdmin_EventDomain':get_subscription_channels(ED, ID7)), + ?match([_,_,_], 'CosEventDomainAdmin_EventDomain':get_subscription_channels(ED, ID4)), + + CID10 = ?match(8, 'CosEventDomainAdmin_EventDomain':add_connection(ED, C7)), + + %% Now we'll check diamond management. + %% Currently it should not be possible to create a diamond (due to QoS-setting). + ?match({'EXCEPTION',{'CosEventDomainAdmin_DiamondCreationForbidden',_,_}}, + 'CosEventDomainAdmin_EventDomain':add_connection(ED, C11)), + ?match({'EXCEPTION',{'CosEventDomainAdmin_DiamondCreationForbidden',_,_}}, + 'CosEventDomainAdmin_EventDomain':add_connection(ED, C10)), + ?match({'EXCEPTION',{'CosEventDomainAdmin_DiamondCreationForbidden',_,_}}, + 'CosEventDomainAdmin_EventDomain':add_connection(ED, C12)), + ?match(ok, 'CosEventDomainAdmin_EventDomain':set_qos(ED, [AllowDiamonds])), + + CID11 = ?match(9, 'CosEventDomainAdmin_EventDomain':add_connection(ED, C10)), + ?match([_,_,_,_,_,_,_,_,_], + 'CosEventDomainAdmin_EventDomain':get_all_connections(ED)), + ?match([_], 'CosEventDomainAdmin_EventDomain':get_diamonds(ED)), + + CID12 = ?match(10, 'CosEventDomainAdmin_EventDomain':add_connection(ED, C11)), + ?match([_, _, _], 'CosEventDomainAdmin_EventDomain':get_diamonds(ED)), + + CID13 = ?match(11, 'CosEventDomainAdmin_EventDomain':add_connection(ED, C12)), + + ?match([_, _, _], 'CosEventDomainAdmin_EventDomain':get_diamonds(ED)), + + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosEventDomainAdmin_EventDomain':set_qos(ED, [ForbidDiamonds])), + + ?match(ok, 'CosEventDomainAdmin_EventDomain':remove_connection(ED, CID10)), + ?match(ok, 'CosEventDomainAdmin_EventDomain':remove_connection(ED, CID11)), + ?match(ok, 'CosEventDomainAdmin_EventDomain':remove_connection(ED, CID12)), + ?match(ok, 'CosEventDomainAdmin_EventDomain':remove_connection(ED, CID13)), + ?match(ok, 'CosEventDomainAdmin_EventDomain':set_qos(ED, [ForbidDiamonds])), + ?match([_, _], 'CosEventDomainAdmin_EventDomain':get_qos(ED)), + ?match({'EXCEPTION',{'CosEventDomainAdmin_DiamondCreationForbidden',_,_}}, + 'CosEventDomainAdmin_EventDomain':add_connection(ED, C10)), + + ?match(ok, 'CosEventDomainAdmin_EventDomain':destroy(ED)), + + ok. + +event_domain_factory_api(doc) -> ["Testing the CosEventDomain Factory API", ""]; +event_domain_factory_api(suite) -> []; +event_domain_factory_api(_Config) -> + + Cyclic = #'CosNotification_Property'{name=?CycleDetection, + value=any:create(orber_tc:short(), + ?ForbidCycles)}, + + BadProp = #'CosNotification_Property'{name="Wrong", + value=any:create(orber_tc:short(), + ?ForbidCycles)}, + + BadQoSVal = #'CosNotification_Property'{name=?CycleDetection, + value=any:create(orber_tc:short(), + 10)}, + + Fac = ?match({_,key,_,_,_,_}, + cosEventDomainApp:start_factory()), + ?match([], 'CosEventDomainAdmin_EventDomainFactory':get_all_domains(Fac)), + ?match({'EXCEPTION',{'CosEventDomainAdmin_DomainNotFound',_}}, + 'CosEventDomainAdmin_EventDomainFactory':get_event_domain(Fac, 0)), + {ED,_} = 'CosEventDomainAdmin_EventDomainFactory':create_event_domain(Fac, [Cyclic], []), + ?match([0], 'CosEventDomainAdmin_EventDomainFactory':get_all_domains(Fac)), + ED = 'CosEventDomainAdmin_EventDomainFactory':get_event_domain(Fac, 0), + ?match({'EXCEPTION',{'CosEventDomainAdmin_DomainNotFound',_}}, + 'CosEventDomainAdmin_EventDomainFactory':get_event_domain(Fac, 1)), + corba:dispose(ED), + timer:sleep(3000), + ?match([], 'CosEventDomainAdmin_EventDomainFactory':get_all_domains(Fac)), + ?match({'EXCEPTION',{'CosEventDomainAdmin_DomainNotFound',_}}, + 'CosEventDomainAdmin_EventDomainFactory':get_event_domain(Fac, 0)), + {ED2,_} = ?match({{_,key,_,_,_,_}, _}, + 'CosEventDomainAdmin_EventDomainFactory':create_event_domain(Fac, [], [])), + ?match([1], 'CosEventDomainAdmin_EventDomainFactory':get_all_domains(Fac)), + ?match(ED2, 'CosEventDomainAdmin_EventDomainFactory':get_event_domain(Fac, 1)), + corba:dispose(ED2), + + ?match({'EXCEPTION', {'CosNotification_UnsupportedQoS',_,_}}, + 'CosEventDomainAdmin_EventDomainFactory':create_event_domain(Fac, [BadProp], [])), + ?match({'EXCEPTION',{'CosNotification_UnsupportedAdmin',_,_}}, + 'CosEventDomainAdmin_EventDomainFactory':create_event_domain(Fac, [], [BadProp])), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosEventDomainAdmin_EventDomainFactory':create_event_domain(Fac, [BadQoSVal], [])), + ?match({'EXCEPTION',{'CosNotification_UnsupportedAdmin',_,_}}, + 'CosEventDomainAdmin_EventDomainFactory':create_event_domain(Fac, [], [BadQoSVal])), + + corba:dispose(Fac), + ok. diff --git a/lib/cosEventDomain/test/generated_SUITE.erl b/lib/cosEventDomain/test/generated_SUITE.erl new file mode 100644 index 0000000000..6c6996ca79 --- /dev/null +++ b/lib/cosEventDomain/test/generated_SUITE.erl @@ -0,0 +1,390 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : generated_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(generated_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + AcTuAlReS + end + end()). + + +-define(checktc(_Op), + fun(TC) -> + case orber_tc:check_tc(TC) of + false -> + io:format("###### ERROR ERROR ######~n~p - ~p~n", [Op, TC]), + ?line exit(TC); + true -> + true + end + end). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing IC generated files"]; +all(suite) -> + ['CosEventDomainAdmin', 'CosEventDomainAdmin_DiamondSeq', + 'CosEventDomainAdmin_AlreadyExists', 'CosEventDomainAdmin_DomainIDSeq', + 'CosEventDomainAdmin_Connection', 'CosEventDomainAdmin_ConnectionIDSeq', + 'CosEventDomainAdmin_ConnectionNotFound', 'CosEventDomainAdmin_CycleCreationForbidden', + 'CosEventDomainAdmin_CycleSeq', 'CosEventDomainAdmin_DiamondCreationForbidden', + 'CosEventDomainAdmin_DomainNotFound', 'CosEventDomainAdmin_MemberIDSeq', + 'CosEventDomainAdmin_RouteSeq', 'CosEventDomainAdmin_EventDomainFactory', + 'CosEventDomainAdmin_EventDomain']. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin'(doc) -> ["CosEventDomainAdmin"]; +'CosEventDomainAdmin'(suite) -> []; +'CosEventDomainAdmin'(_) -> + ?match("CycleDetection", 'CosEventDomainAdmin':'CycleDetection'()), + ?match(0, 'CosEventDomainAdmin':'AuthorizeCycles'()), + ?match(1, 'CosEventDomainAdmin':'ForbidCycles'()), + ?match("DiamondDetection", 'CosEventDomainAdmin':'DiamondDetection'()), + ?match(0, 'CosEventDomainAdmin':'AuthorizeDiamonds'()), + ?match(1, 'CosEventDomainAdmin':'ForbidDiamonds'()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_DiamondSeq' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_DiamondSeq'(doc) -> ["CosEventDomainAdmin_DiamondSeq"]; +'CosEventDomainAdmin_DiamondSeq'(suite) -> []; +'CosEventDomainAdmin_DiamondSeq'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_DiamondSeq':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/DiamondSeq:1.0", + 'CosEventDomainAdmin_DiamondSeq':id()), + ?match("CosEventDomainAdmin_DiamondSeq", + 'CosEventDomainAdmin_DiamondSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_AlreadyExists' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_AlreadyExists'(doc) -> ["CosEventDomainAdmin_AlreadyExists"]; +'CosEventDomainAdmin_AlreadyExists'(suite) -> []; +'CosEventDomainAdmin_AlreadyExists'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_AlreadyExists':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/AlreadyExists:1.0", + 'CosEventDomainAdmin_AlreadyExists':id()), + ?match("CosEventDomainAdmin_AlreadyExists", + 'CosEventDomainAdmin_AlreadyExists':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_DomainIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_DomainIDSeq'(doc) -> ["CosEventDomainAdmin_DomainIDSeq"]; +'CosEventDomainAdmin_DomainIDSeq'(suite) -> []; +'CosEventDomainAdmin_DomainIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_DomainIDSeq':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/DomainIDSeq:1.0", + 'CosEventDomainAdmin_DomainIDSeq':id()), + ?match("CosEventDomainAdmin_DomainIDSeq", + 'CosEventDomainAdmin_DomainIDSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_Connection' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_Connection'(doc) -> ["CosEventDomainAdmin_Connection"]; +'CosEventDomainAdmin_Connection'(suite) -> []; +'CosEventDomainAdmin_Connection'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_Connection':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/Connection:1.0", + 'CosEventDomainAdmin_Connection':id()), + ?match("CosEventDomainAdmin_Connection", + 'CosEventDomainAdmin_Connection':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_ConnectionIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_ConnectionIDSeq'(doc) -> ["CosEventDomainAdmin_ConnectionIDSeq"]; +'CosEventDomainAdmin_ConnectionIDSeq'(suite) -> []; +'CosEventDomainAdmin_ConnectionIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_ConnectionIDSeq':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/ConnectionIDSeq:1.0", + 'CosEventDomainAdmin_ConnectionIDSeq':id()), + ?match("CosEventDomainAdmin_ConnectionIDSeq", + 'CosEventDomainAdmin_ConnectionIDSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_ConnectionNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_ConnectionNotFound'(doc) -> ["CosEventDomainAdmin_ConnectionNotFound"]; +'CosEventDomainAdmin_ConnectionNotFound'(suite) -> []; +'CosEventDomainAdmin_ConnectionNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_ConnectionNotFound':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/ConnectionNotFound:1.0", + 'CosEventDomainAdmin_ConnectionNotFound':id()), + ?match("CosEventDomainAdmin_ConnectionNotFound", + 'CosEventDomainAdmin_ConnectionNotFound':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_CycleCreationForbidden' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_CycleCreationForbidden'(doc) -> ["CosEventDomainAdmin_CycleCreationForbidden"]; +'CosEventDomainAdmin_CycleCreationForbidden'(suite) -> []; +'CosEventDomainAdmin_CycleCreationForbidden'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_CycleCreationForbidden':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/CycleCreationForbidden:1.0", + 'CosEventDomainAdmin_CycleCreationForbidden':id()), + ?match("CosEventDomainAdmin_CycleCreationForbidden", + 'CosEventDomainAdmin_CycleCreationForbidden':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_CycleSeq' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_CycleSeq'(doc) -> ["CosEventDomainAdmin_CycleSeq"]; +'CosEventDomainAdmin_CycleSeq'(suite) -> []; +'CosEventDomainAdmin_CycleSeq'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_CycleSeq':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/CycleSeq:1.0", + 'CosEventDomainAdmin_CycleSeq':id()), + ?match("CosEventDomainAdmin_CycleSeq", + 'CosEventDomainAdmin_CycleSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_DiamondCreationForbidden' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_DiamondCreationForbidden'(doc) -> ["CosEventDomainAdmin_DiamondCreationForbidden"]; +'CosEventDomainAdmin_DiamondCreationForbidden'(suite) -> []; +'CosEventDomainAdmin_DiamondCreationForbidden'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_DiamondCreationForbidden':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/DiamondCreationForbidden:1.0", + 'CosEventDomainAdmin_DiamondCreationForbidden':id()), + ?match("CosEventDomainAdmin_DiamondCreationForbidden", + 'CosEventDomainAdmin_DiamondCreationForbidden':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_DomainNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_DomainNotFound'(doc) -> ["CosEventDomainAdmin_DomainNotFound"]; +'CosEventDomainAdmin_DomainNotFound'(suite) -> []; +'CosEventDomainAdmin_DomainNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_DomainNotFound':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/DomainNotFound:1.0", + 'CosEventDomainAdmin_DomainNotFound':id()), + ?match("CosEventDomainAdmin_DomainNotFound", + 'CosEventDomainAdmin_DomainNotFound':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_MemberIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_MemberIDSeq'(doc) -> ["CosEventDomainAdmin_MemberIDSeq"]; +'CosEventDomainAdmin_MemberIDSeq'(suite) -> []; +'CosEventDomainAdmin_MemberIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_MemberIDSeq':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/MemberIDSeq:1.0", + 'CosEventDomainAdmin_MemberIDSeq':id()), + ?match("CosEventDomainAdmin_MemberIDSeq", + 'CosEventDomainAdmin_MemberIDSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_RouteSeq' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_RouteSeq'(doc) -> ["CosEventDomainAdmin_RouteSeq"]; +'CosEventDomainAdmin_RouteSeq'(suite) -> []; +'CosEventDomainAdmin_RouteSeq'(_) -> + ?match(true, orber_tc:check_tc('CosEventDomainAdmin_RouteSeq':tc())), + ?match("IDL:omg.org/CosEventDomainAdmin/RouteSeq:1.0", + 'CosEventDomainAdmin_RouteSeq':id()), + ?match("CosEventDomainAdmin_RouteSeq", + 'CosEventDomainAdmin_RouteSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_EventDomainFactory' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_EventDomainFactory'(doc) -> ["CosEventDomainAdmin_EventDomainFactory"]; +'CosEventDomainAdmin_EventDomainFactory'(suite) -> []; +'CosEventDomainAdmin_EventDomainFactory'(_) -> + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomainFactory':oe_tc(create_event_domain)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomainFactory':oe_tc(get_all_domains)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomainFactory':oe_tc(get_event_domain)), + ?match(undefined, 'CosEventDomainAdmin_EventDomainFactory':oe_tc(undefined)), + ?match([_|_], 'CosEventDomainAdmin_EventDomainFactory':oe_get_interface()), + ?match("IDL:omg.org/CosEventDomainAdmin/EventDomainFactory:1.0", + 'CosEventDomainAdmin_EventDomainFactory':typeID()), + check_tc('CosEventDomainAdmin_EventDomainFactory':oe_get_interface()), + ?match(true, 'CosEventDomainAdmin_EventDomainFactory':oe_is_a('CosEventDomainAdmin_EventDomainFactory':typeID())), + ?match(false, 'CosEventDomainAdmin_EventDomainFactory':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosEventDomainAdmin_EventDomain' +%% Description: +%%----------------------------------------------------------------- +'CosEventDomainAdmin_EventDomain'(doc) -> ["CosEventDomainAdmin_EventDomain"]; +'CosEventDomainAdmin_EventDomain'(suite) -> []; +'CosEventDomainAdmin_EventDomain'(_) -> + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(add_channel)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_all_channels)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_channel)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(remove_channel)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(add_connection)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_all_connections)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_connection)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(remove_connection)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_offer_channels)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_subscription_channels)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(destroy)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_cycles)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_diamonds)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(set_default_consumer_channel)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(set_default_supplier_channel)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_push_consumer)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_pull_consumer)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_push_supplier)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_pull_supplier)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_structured_push_consumer)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_structured_pull_consumer)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_structured_push_supplier)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_structured_pull_supplier)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_sequence_push_consumer)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_sequence_pull_consumer)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_sequence_push_supplier)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_sequence_pull_supplier)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_push_consumer_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_pull_consumer_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_push_supplier_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_pull_supplier_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_structured_push_consumer_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_structured_pull_consumer_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_structured_push_supplier_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_structured_pull_supplier_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_sequence_push_consumer_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_sequence_pull_consumer_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_sequence_push_supplier_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(connect_sequence_pull_supplier_with_id)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_qos)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(set_qos)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(get_admin)), + ?nomatch(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(set_admin)), + ?match(undefined, 'CosEventDomainAdmin_EventDomain':oe_tc(undefined)), + ?match([_|_], 'CosEventDomainAdmin_EventDomain':oe_get_interface()), + ?match("IDL:omg.org/CosEventDomainAdmin/EventDomain:1.0", + 'CosEventDomainAdmin_EventDomain':typeID()), + check_tc('CosEventDomainAdmin_EventDomain':oe_get_interface()), + ?match(true, 'CosEventDomainAdmin_EventDomain':oe_is_a('CosEventDomainAdmin_EventDomain':typeID())), + ?match(true, 'CosEventDomainAdmin_EventDomain':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosEventDomainAdmin_EventDomain':oe_is_a('CosNotification_AdminPropertiesAdmin':typeID())), + ?match(false, 'CosEventDomainAdmin_EventDomain':oe_is_a("wrong")), + ok. + + + +%%----------------------------------------------------------------- +%% MISC functions +%%----------------------------------------------------------------- +check_tc([]) -> + ok; +check_tc([{Op, {RetType, InParameters, OutParameters}}|T]) -> + io:format("checked - ~s~n", [Op]), + lists:all(?checktc(Op), [RetType|InParameters]), + lists:all(?checktc(Op), OutParameters), + check_tc(T). + + diff --git a/lib/cosEventDomain/vsn.mk b/lib/cosEventDomain/vsn.mk index 483b130819..dceee34181 100644 --- a/lib/cosEventDomain/vsn.mk +++ b/lib/cosEventDomain/vsn.mk @@ -1,7 +1,9 @@ -COSEVENTDOMAIN_VSN = 1.1.8 +COSEVENTDOMAIN_VSN = 1.1.9 -TICKETS = OTP-8353 \ +TICKETS = OTP-8543 + +TICKETS_1.1.8 = OTP-8353 \ OTP-8355 TICKETS_1.1.7 = OTP-8201 diff --git a/lib/cosNotification/doc/src/notes.xml b/lib/cosNotification/doc/src/notes.xml index 8062c883cf..de5a3e5f4c 100644 --- a/lib/cosNotification/doc/src/notes.xml +++ b/lib/cosNotification/doc/src/notes.xml @@ -33,6 +33,17 @@ <section> <title>cosNotification 1.1.14</title> + <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Test suites published.</p> + <p> + Own Id: OTP-8543 Aux Id:</p> + </item> + </list> + </section> <section> <title>Fixed Bugs and Malfunctions</title> diff --git a/lib/cosNotification/test/Makefile b/lib/cosNotification/test/Makefile new file mode 100644 index 0000000000..df8f9e919b --- /dev/null +++ b/lib/cosNotification/test/Makefile @@ -0,0 +1,190 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1999-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(COSNOTIFICATION_VSN) +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/cosNotification_test + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +TEST_SPEC_FILE = cosNotification.spec + + +IDL_FILES = + +IDLOUTDIR = idl_output + +MODULES = \ + notification_SUITE \ + grammar_SUITE \ + eventDB_SUITE \ + generated_SUITE \ + notify_test_impl + +GEN_MODULES = \ + oe_notify_test_server \ + notify_test_data \ + notify_test_computer \ + notify_test_studies \ + notify_test_ShortArray \ + notify_test_uni1 \ + notify_test_uni2 \ + notify_test_X \ + notify_test_K \ + notify_test_SeqPushC \ + notify_test_StrPushC \ + notify_test_AnyPushC \ + notify_test_SeqPullC \ + notify_test_StrPullC \ + notify_test_AnyPullC \ + notify_test_SeqPushS \ + notify_test_StrPushS \ + notify_test_AnyPushS \ + notify_test_SeqPullS \ + notify_test_StrPullS \ + notify_test_AnyPullS \ + notify_test_funcs + +GEN_HRL_FILES = \ + oe_notify_test_server.hrl \ + notify_test_SeqPushC.hrl \ + notify_test_StrPushC.hrl \ + notify_test_AnyPushC.hrl \ + notify_test_SeqPullC.hrl \ + notify_test_StrPullC.hrl \ + notify_test_AnyPullC.hrl \ + notify_test_SeqPushS.hrl \ + notify_test_StrPushS.hrl \ + notify_test_AnyPushS.hrl \ + notify_test_SeqPullS.hrl \ + notify_test_StrPullS.hrl \ + notify_test_AnyPullS.hrl \ + notify_test.hrl \ + notify_test_funcs.hrl + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = + +GEN_FILES = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +GEN_TARGET_FILES = $(GEN_MODULES:%=$(IDLOUTDIR)/%.$(EMULATOR)) + +SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) + +TARGET_FILES = \ + $(GEN_TARGET_FILES) \ + $(SUITE_TARGET_FILES) + + +# ---------------------------------------------------- +# PROGRAMS +# ---------------------------------------------------- +LOCAL_CLASSPATH = $(ERL_TOP)lib/cosNotification/priv:$(ERL_TOP)lib/cosNotification/test +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_IDL_FLAGS += \ + -pa $(ERL_TOP)/lib/cosNotification/ebin \ + -pa $(ERL_TOP)/lib/cosNotification/src \ + -pa $(ERL_TOP)/lib/cosTime/ebin \ + -pa $(ERL_TOP)/lib/cosTime/include \ + -pa $(ERL_TOP)/lib/orber/ebin \ + -pa $(ERL_TOP)/lib/ic/ebin \ + -pa $(ERL_TOP)/lib/cosNotification/include \ + -I$(ERL_TOP)/lib/cosEvent/src \ + -I$(ERL_TOP)/lib/cosNotification/include \ + +ERL_COMPILE_FLAGS += \ + $(ERL_IDL_FLAGS) \ + -pa $(ERL_TOP)/lib/orber/include \ + -pa $(ERL_TOP)/internal_tools/test_server/ebin \ + -pa $(ERL_TOP)/lib/cosNotification/ebin \ + -pa $(ERL_TOP)/lib/cosNotification/test/idl_output \ + -pa $(ERL_TOP)/lib/cosTime/ebin \ + -pa $(ERL_TOP)/lib/cosTime/include \ + -pa $(ERL_TOP)/lib/cosNotification/include \ + -pa $(ERL_TOP)/lib/ic/ebin \ + -I$(ERL_TOP)/lib/cosTime/ebin \ + -I$(ERL_TOP)/lib/cosTime/include \ + -I$(ERL_TOP)/lib/orber/include \ + -I$(ERL_TOP)/lib/cosNotification/src \ + -I$(ERL_TOP)/lib/cosNotification/include \ + -I$(ERL_TOP)/lib/cosNotification \ + -I$(ERL_TOP)/lib/cosNotification/test/$(IDLOUTDIR) \ + -I$(ERL_TOP)/lib/test_server/include + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- + + +tests debug opt: $(TARGET_FILES) + +clean: + rm -f idl_output/* + rm -f $(TARGET_FILES) + rm -f errs core *~ + +docs: + +# ---------------------------------------------------- +# Special Targets +# ---------------------------------------------------- + +TGT_TEST = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +$(TGT_TEST): notify_test_server.idl + erlc $(ERL_COMPILE_FLAGS) -o$(IDLOUTDIR) \ + +'{cfgfile,"notify_test_server.cfg"}' notify_test_server.idl + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +# We don't copy generated intermediate erlang and hrl files + +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: + +release_docs_spec: + +release_tests_spec: tests + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(IDL_FILES) $(TEST_SPEC_FILE) \ + $(ERL_FILES) $(RELSYSDIR) + $(INSTALL_DIR) $(RELSYSDIR)/$(IDLOUTDIR) + $(INSTALL_DATA) $(GEN_TARGET_FILES) $(GEN_FILES) \ + $(RELSYSDIR)/$(IDLOUTDIR) + $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR) + diff --git a/lib/cosNotification/test/cosNotification.spec b/lib/cosNotification/test/cosNotification.spec new file mode 100644 index 0000000000..8df89e7908 --- /dev/null +++ b/lib/cosNotification/test/cosNotification.spec @@ -0,0 +1,19 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{topcase, {dir, "../cosNotification_test"}}. diff --git a/lib/cosNotification/test/eventDB_SUITE.erl b/lib/cosNotification/test/eventDB_SUITE.erl new file mode 100644 index 0000000000..9ddfb3d902 --- /dev/null +++ b/lib/cosNotification/test/eventDB_SUITE.erl @@ -0,0 +1,902 @@ +%%-------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%-------------------------------------------------------------------- +%% File : eventDB_SUITE.erl +%% Purpose : +%%-------------------------------------------------------------------- + +-module(eventDB_SUITE). +%%--------------- INCLUDES ----------------------------------- +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/include/ifr_types.hrl"). +%% cosEvent files. +-include_lib("cosEvent/include/CosEventChannelAdmin.hrl"). +%% cosTime files. +-include_lib("cosTime/include/TimeBase.hrl"). +%% Application files +-include_lib("cosNotification/include/CosNotification.hrl"). +-include_lib("cosNotification/include/CosNotifyChannelAdmin.hrl"). +-include_lib("cosNotification/include/CosNotifyComm.hrl"). +-include_lib("cosNotification/include/CosNotifyFilter.hrl"). + +-include_lib("cosNotification/src/CosNotification_Definitions.hrl"). + +-include("idl_output/notify_test.hrl"). + +-include("test_server.hrl"). + +%%--------------- DEFINES ------------------------------------ +-define(default_timeout, ?t:minutes(20)). +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + + +-define(EVENT1, ?not_CreateSE("","event1","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 0)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=900000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=900000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 900000000)}], + [], any:create(orber_tc:null(), null))). +-define(EVENT2, ?not_CreateSE("","event2","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 0)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=800000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=800000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 800000000)}], + [], any:create(orber_tc:null(), null))). +-define(EVENT3, ?not_CreateSE("","event3","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 0)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=700000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=700000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 700000000)}], + [], any:create(orber_tc:null(), null))). +-define(EVENT4, ?not_CreateSE("","event4","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 2)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=300000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=300000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 300000000)}], + [], any:create(orber_tc:null(), null))). +-define(EVENT5, ?not_CreateSE("","event5","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 2)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=200000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=200000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 200000000)}], + [], any:create(orber_tc:null(), null))). +-define(EVENT6, ?not_CreateSE("","event6","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 0)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=500000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=500000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 500000000)}], + [], any:create(orber_tc:null(), null))). +-define(EVENT7, ?not_CreateSE("","event7","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), -1)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=400000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=400000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 400000000)}], + [], any:create(orber_tc:null(), null))). +-define(EVENT8, ?not_CreateSE("","event8","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), -1)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=600000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=600000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 600000000)}], + [], any:create(orber_tc:null(), null))). +-define(EVENT9, ?not_CreateSE("","event9","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 0)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=100000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), + #'TimeBase_UtcT' + {time=100000000, + inacclo=0, inacchi=0, tdf=2})}, + #'CosNotification_Property' + {name="Timeout", + value=any:create(orber_tc:unsigned_long_long(), 100000000)}], + [], any:create(orber_tc:null(), null))). + +-define(EVENTS, [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT5, ?EVENT6, ?EVENT7, + ?EVENT8, ?EVENT9]). + + +-define(PRIOORDER, [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3, ?EVENT6, ?EVENT9, + ?EVENT7, ?EVENT8]). + +-define(FIFOORDER, ?EVENTS). + +-define(DEADLINEORDER, [?EVENT9, ?EVENT5, ?EVENT4, ?EVENT7, ?EVENT6, ?EVENT8, ?EVENT3, + ?EVENT2, ?EVENT1]). + +-define(NO_OF_EVENTS, 9). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, reorder_api/1, lookup_api/1, + discard_api/1, max_events_api/1, gc_api/1, auto_gc_api/1, + start_stop_time_api/1, mapping_filter_api/1, persisten_event_api/1, + init_per_testcase/2, fin_per_testcase/2]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for the cosNotification interfaces", ""]; +all(suite) -> {req, + [mnesia, orber], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [persisten_event_api, start_stop_time_api, mapping_filter_api, + max_events_api, discard_api, reorder_api, lookup_api, gc_api, + auto_gc_api]. + + + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + orber:jump_start(), + cosTime:install_time(), + cosTime:start(), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + cosTime:stop(), + cosTime:uninstall_time(), + orber:jump_stop(), + Config. + + +%%----------------------------------------------------------------- +%% cosNotification_eventDB lookup API tests +%%----------------------------------------------------------------- +mapping_filter_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once. This case is supposed to test", + "that the events are delivered in the correct order", + "if a MappingFilter have benn associated.", + ""]; +mapping_filter_api(suite) -> []; +mapping_filter_api(_Config) -> + InitQoS = ?not_CreateInitQoS(), + InitQoS2 = ?not_SetMaxEventsPerConsumer(InitQoS,100), + InitQoS3 = ?not_SetStartTimeSupported(InitQoS2, false), + InitQoS4 = ?not_SetStopTimeSupported(InitQoS3, true), + QoS = ?not_SetDiscardPolicy(InitQoS4, ?not_AnyOrder), + + PriorityQoS = ?not_SetOrderPolicy(QoS, ?not_PriorityOrder), + DeadlineQoS = ?not_SetOrderPolicy(QoS, ?not_DeadlineOrder), + + %% "Calculate" data once: + %% NOTE! Even though the an Event do not match any of the constarints the + %% default value will be used. Hence, the events will not be stored in the + %% way described in the definitions above. For example, when using deadline order + %% all the events will be stored in FIFO order since the usag of a MappingFilter + %% all evnts will have the same deadline (except event6). + Events = ?EVENTS, + PrioOrder = [?EVENT6, ?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT5, ?EVENT7, + ?EVENT8, ?EVENT9], + DeadlineOrder = [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT5, ?EVENT7, ?EVENT8, + ?EVENT9], + + + FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), + ?match({_,key,_,_,_,_}, FiFac), + + PrioFilter = 'CosNotifyFilter_FilterFactory': + create_mapping_filter(FiFac, "EXTENDED_TCL", any:create(orber_tc:short(), 0)), + DLFilter = 'CosNotifyFilter_FilterFactory': + create_mapping_filter(FiFac, "EXTENDED_TCL", any:create(orber_tc:unsigned_long_long(), 1000000000)), + + ?match([_], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(PrioFilter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "", + type_name = "event6"}], + constraint_expr = "2==2"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + ?match([_], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(DLFilter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "", + type_name = "event6"}], + constraint_expr = "2==2"}, + result_to_set = any:create(orber_tc:unsigned_long_long(), 200000000)}])), + + + do_lookup(PriorityQoS, Events, PrioOrder, "Priority Order", undefined, PrioFilter, 0), + do_lookup(DeadlineQoS, Events, DeadlineOrder, "Deadline Order", DLFilter, undefined, 23000), + ok. + +do_lookup(QoS, Events, Return, Txt, DLFilter, PrioFilter, Timeout) -> + io:format("#################### ~s ###################~n", [Txt]), + Ref = cosNotification_eventDB:create_db(QoS, 60, 50, undefined), + create_loop(Events, Ref, DLFilter, PrioFilter), + timer:sleep(Timeout), + ?match({Return,_}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + cosNotification_eventDB:destroy_db(Ref). + +%%----------------------------------------------------------------- +%% cosNotification_eventDB discard API tests +%%----------------------------------------------------------------- +discard_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once. If MaxEvents limit is reached there", + "different ways we can discard the. This case will test", + "all permutations of order and discard policies.", + ""]; +discard_api(suite) -> []; +discard_api(_Config) -> + InitQoS1 = ?not_CreateInitQoS(), + InitQoS2 = ?not_SetPriority(InitQoS1, 10), + InitQoS3 = ?not_SetStartTimeSupported(InitQoS2, false), + QoS = ?not_SetMaxEventsPerConsumer(InitQoS3, 5), + %% The different order policies. To each order we must apply every possible + %% discard policy to each order policy setting. We also have to test and + %% change the policies for each setting. + AnyQoS = ?not_SetOrderPolicy(QoS, ?not_AnyOrder), + PriorityQoS = ?not_SetOrderPolicy(QoS, ?not_PriorityOrder), + FifoQoS = ?not_SetOrderPolicy(QoS, ?not_FifoOrder), + DeadlineQoS = ?not_SetOrderPolicy(QoS, ?not_DeadlineOrder), + + Events = ?EVENTS, + + %% Test using Any discard policy + do_discard(Events, ?not_SetDiscardPolicy(AnyQoS, ?not_AnyOrder), + [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3], + "Discard and Order eq. Any"), + do_discard(Events, ?not_SetDiscardPolicy(PriorityQoS, ?not_AnyOrder), + [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3], + "Discard Any and Order Priority"), + do_discard(Events, ?not_SetDiscardPolicy(FifoQoS, ?not_AnyOrder), + [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT5], + "Discard Any and Order Fifo"), + do_discard(Events, ?not_SetDiscardPolicy(DeadlineQoS, ?not_AnyOrder), + [?EVENT5, ?EVENT4, ?EVENT3, ?EVENT2, ?EVENT1], + "Discard Any and Order Deadline"), + + %% Test using RejectNewEvents discard policy + do_discard(Events, ?not_SetDiscardPolicy(AnyQoS, ?not_RejectNewEvents), + [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3], + "Discard RejectNewEvents and Order Any"), + do_discard(Events, ?not_SetDiscardPolicy(PriorityQoS, ?not_RejectNewEvents), + [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3], + "Discard RejectNewEvents and Order Priority"), + do_discard(Events, ?not_SetDiscardPolicy(FifoQoS, ?not_RejectNewEvents), + [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT5], + "Discard RejectNewEvents and Order Fifo"), + do_discard(Events, ?not_SetDiscardPolicy(DeadlineQoS, ?not_RejectNewEvents), + [?EVENT5, ?EVENT4, ?EVENT3, ?EVENT2, ?EVENT1], + "Discard RejectNewEvents and Order Deadline"), + + %% Test using Lifo discard policy + do_discard(Events, ?not_SetDiscardPolicy(AnyQoS, ?not_LifoOrder), + [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3], + "Discard Lifo and Order Any"), + do_discard(Events, ?not_SetDiscardPolicy(PriorityQoS, ?not_LifoOrder), + [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3], + "Discard Lifo and Order Priority"), + do_discard(Events, ?not_SetDiscardPolicy(FifoQoS, ?not_LifoOrder), + [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT5], + "Discard Lifo and Order Fifo"), + do_discard(Events, ?not_SetDiscardPolicy(DeadlineQoS, ?not_LifoOrder), + [?EVENT5, ?EVENT4, ?EVENT3, ?EVENT2, ?EVENT1], + "Discard Lifo and Order Deadline"), + + %% Test using Fifo discard policy + do_discard(Events, ?not_SetDiscardPolicy(AnyQoS, ?not_FifoOrder), + [?EVENT5, ?EVENT6, ?EVENT9, ?EVENT7, ?EVENT8], + "Discard Fifo and Order Any"), + do_discard(Events, ?not_SetDiscardPolicy(PriorityQoS, ?not_FifoOrder), + [?EVENT5, ?EVENT6, ?EVENT9, ?EVENT7, ?EVENT8], + "Discard Fifo and Order Priority"), + do_discard(Events, ?not_SetDiscardPolicy(FifoQoS, ?not_FifoOrder), + [?EVENT5, ?EVENT6, ?EVENT7, ?EVENT8, ?EVENT9], + "Discard Fifo and Order Fifo"), + do_discard(Events, ?not_SetDiscardPolicy(DeadlineQoS, ?not_FifoOrder), + [?EVENT9, ?EVENT5, ?EVENT7, ?EVENT6, ?EVENT8], + "Discard Fifo and Order Deadline"), + + %% Test using Priority discard policy + do_discard(Events, ?not_SetDiscardPolicy(AnyQoS, ?not_PriorityOrder), + [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3], + "Discard Priority and Order Any"), + do_discard(Events, ?not_SetDiscardPolicy(PriorityQoS, ?not_PriorityOrder), + [?EVENT4, ?EVENT5, ?EVENT1, ?EVENT2, ?EVENT3], + "Discard Priority and Order Priority"), + do_discard(Events, ?not_SetDiscardPolicy(FifoQoS, ?not_PriorityOrder), + [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT5], + "Discard Priority and Order Fifo"), + do_discard(Events, ?not_SetDiscardPolicy(DeadlineQoS, ?not_PriorityOrder), + [?EVENT5, ?EVENT4, ?EVENT3, ?EVENT2, ?EVENT1], + "Discard Priority and Order Deadline"), + + %% Test using Deadline discard policy + do_discard(Events, ?not_SetDiscardPolicy(AnyQoS, ?not_DeadlineOrder), + [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT6, ?EVENT8], + "Discard Deadline and Order Any"), + do_discard(Events, ?not_SetDiscardPolicy(PriorityQoS, ?not_DeadlineOrder), + [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT6, ?EVENT8], + "Discard Deadline and Order Priority"), + do_discard(Events, ?not_SetDiscardPolicy(FifoQoS, ?not_DeadlineOrder), + [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT6, ?EVENT8], + "Discard Deadline and Order Fifo"), + do_discard(Events, ?not_SetDiscardPolicy(DeadlineQoS, ?not_DeadlineOrder), + [?EVENT6, ?EVENT8, ?EVENT3, ?EVENT2, ?EVENT1], + "Discard Deadline and Order Deadline"), + + ok. + +do_discard(Events, QoS, Reply, Txt) -> + io:format("################# ~s #################~n", [Txt]), + Ref = cosNotification_eventDB:create_db(QoS, 60, 50, undefined), + create_loop(Events, Ref), + ?match({Reply,_}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + cosNotification_eventDB:destroy_db(Ref). + + +%%----------------------------------------------------------------- +%% cosNotification_eventDB lookup API tests +%%----------------------------------------------------------------- +lookup_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once. This case is supposed to test", + "that the events are delivered in the correct order.", + ""]; +lookup_api(suite) -> []; +lookup_api(_Config) -> + InitQoS = ?not_CreateInitQoS(), + InitQoS2 = ?not_SetMaxEventsPerConsumer(InitQoS,100), + InitQoS3 = ?not_SetStartTimeSupported(InitQoS2, false), + QoS = ?not_SetDiscardPolicy(InitQoS3, ?not_AnyOrder), + + AnyQoS = ?not_SetOrderPolicy(QoS, ?not_AnyOrder), + PriorityQoS = ?not_SetOrderPolicy(QoS, ?not_PriorityOrder), + FifoQoS = ?not_SetOrderPolicy(QoS, ?not_FifoOrder), + DeadlineQoS = ?not_SetOrderPolicy(QoS, ?not_DeadlineOrder), + + %% "Calculate" data once: + Events = ?EVENTS, + PrioOrder = ?PRIOORDER, + FifoOrder = ?FIFOORDER, + DeadlineOrder = ?DEADLINEORDER, + + do_lookup(PriorityQoS, Events, PrioOrder, "Priority Order"), + do_lookup(FifoQoS, Events, FifoOrder, "Fifo Order"), + do_lookup(DeadlineQoS, Events, DeadlineOrder, "Deadline Order"), + do_lookup(AnyQoS, Events, PrioOrder, "Any Order"), + ok. + +do_lookup(QoS, Events, Return, Txt) -> + io:format("#################### ~s ###################~n", [Txt]), + Ref = cosNotification_eventDB:create_db(QoS, 60, 50, undefined), + create_loop(Events, Ref), + ?match({Return,_}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + cosNotification_eventDB:destroy_db(Ref). + + +%%----------------------------------------------------------------- +%% cosNotification_eventDB max events API tests +%%----------------------------------------------------------------- +max_events_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once. If the MaxEvents QoS is updated we must be", + "able to reduce the amount of stored events.", + ""]; +max_events_api(suite) -> []; +max_events_api(_Config) -> + + QoS1 = ?not_CreateInitQoS(), + QoS2 = ?not_SetOrderPolicy(QoS1, ?not_FifoOrder), + QoS3 = ?not_SetDiscardPolicy(QoS2, ?not_RejectNewEvents), + QoS4 = ?not_SetStartTimeSupported(QoS3, false), + QoS_NO_OF_EVENTS = ?not_SetMaxEventsPerConsumer(QoS4, ?NO_OF_EVENTS), + QoS_5_EVENTS = ?not_SetMaxEventsPerConsumer(QoS4, 5), + + Events = ?EVENTS, + Events5 = [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT5], + + %% Initiate DB and 'NO_OF_EVENTS' events. + Ref1 = cosNotification_eventDB:create_db(QoS_NO_OF_EVENTS, 60, 50, undefined), + create_loop(Events, Ref1), + + %% Reduce the limit to 5 and extract all and see if it's ok. + Ref2 = cosNotification_eventDB:update(Ref1, QoS_5_EVENTS), + ?match({Events5, true}, cosNotification_eventDB:get_events(Ref2, ?NO_OF_EVENTS)), + + %% Add 'NO_OF_EVENTS' events. Since the only allow 5 events the DB will only + %% contain 5 events. + create_loop(Events, Ref2), + Ref3 = cosNotification_eventDB:update(Ref2, QoS_NO_OF_EVENTS), + + ?match({Events5, true}, cosNotification_eventDB:get_events(Ref3, ?NO_OF_EVENTS)), + create_loop(Events, Ref3), + ?match({Events, true}, cosNotification_eventDB:get_events(Ref3, ?NO_OF_EVENTS)), + cosNotification_eventDB:destroy_db(Ref3), + ok. + + +%%----------------------------------------------------------------- +%% cosNotification_eventDB persisten events API tests +%%----------------------------------------------------------------- +persisten_event_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once.", + ""]; +persisten_event_api(suite) -> []; +persisten_event_api(_Config) -> + + QoS1 = ?not_CreateInitQoS(), + QoS2 = ?not_SetOrderPolicy(QoS1, ?not_FifoOrder), + QoS3 = ?not_SetDiscardPolicy(QoS2, ?not_RejectNewEvents), + QoS4 = ?not_SetStartTimeSupported(QoS3, false), + QoS = ?not_SetMaxEventsPerConsumer(QoS4, ?NO_OF_EVENTS), + + Event1 = ?EVENT1, + + Ref = cosNotification_eventDB:create_db(QoS, 60, 50, undefined), + %% Clean DB, should be empty + ?match(0, cosNotification_eventDB:status(Ref, eventCounter)), + cosNotification_eventDB:add_event(Ref, Event1), + ?match(1, cosNotification_eventDB:status(Ref, eventCounter)), + %% Get event without removing it. Should still be one event stored + ?match({[Event1], _, _}, cosNotification_eventDB:get_events(Ref, 2, false)), + ?match(1, cosNotification_eventDB:status(Ref, eventCounter)), + {_, _, Keys} = + ?match({Event1, _, _}, cosNotification_eventDB:get_event(Ref, false)), + ?match(1, cosNotification_eventDB:status(Ref, eventCounter)), + %% Clear the events and check that the DB is empty. + cosNotification_eventDB:delete_events(Keys), + ?match(0, cosNotification_eventDB:status(Ref, eventCounter)), + ?match({[], _, []}, cosNotification_eventDB:get_event(Ref, false)), + ?match({[], _, []}, cosNotification_eventDB:get_events(Ref, 2, false)), + + cosNotification_eventDB:destroy_db(Ref), + ok. + +%%----------------------------------------------------------------- +%% cosNotification_eventDB gc API tests +%%----------------------------------------------------------------- +gc_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once. If Deadline defined the events that", + "are older must be discarded.", + ""]; +gc_api(suite) -> []; +gc_api(_Config) -> + + QoS1 = ?not_CreateInitQoS(), + QoS2 = ?not_SetOrderPolicy(QoS1, ?not_FifoOrder), + QoS3 = ?not_SetDiscardPolicy(QoS2, ?not_RejectNewEvents), + QoS4 = ?not_SetStartTimeSupported(QoS3, false), + QoS_NO_OF_EVENTS = ?not_SetMaxEventsPerConsumer(QoS4, ?NO_OF_EVENTS), + + Events = ?EVENTS, + Events6 = [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT6, ?EVENT7, ?EVENT8], + %% Initiate DB and 'NO_OF_EVENTS' events. + Ref = cosNotification_eventDB:create_db(QoS_NO_OF_EVENTS, 60, 50, undefined), + create_loop(Events, Ref), + + %% Sleep so some events will get 'old'. + timer:sleep(23000), + + %% Reduce the limit to 5 and extract all and see if it's ok. + cosNotification_eventDB:gc_events(Ref, high), + + %% Since gc is done by another process we must wait so it will have a chance + %% to complete the job. + timer:sleep(2000), + + ?match({Events6, true}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + + create_loop(Events, Ref), + timer:sleep(23000), + ?match({Events6, true}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + cosNotification_eventDB:destroy_db(Ref), + ok. + + +%%----------------------------------------------------------------- +%% cosNotification_eventDB gc API tests +%%----------------------------------------------------------------- +auto_gc_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once. If Deadline defined the events that", + "are older must be discarded.", + ""]; +auto_gc_api(suite) -> []; +auto_gc_api(_Config) -> + + QoS1 = ?not_CreateInitQoS(), + QoS2 = ?not_SetOrderPolicy(QoS1, ?not_FifoOrder), + QoS3 = ?not_SetDiscardPolicy(QoS2, ?not_RejectNewEvents), + QoS4 = ?not_SetStopTimeSupported(QoS3, true), + QoS5 = ?not_SetStartTimeSupported(QoS4, false), + QoS_NO_OF_EVENTS = ?not_SetMaxEventsPerConsumer(QoS5, ?NO_OF_EVENTS), + + Events6 = [?EVENT1, ?EVENT2, ?EVENT3, ?EVENT7, ?EVENT8, ?EVENT9], + %% Initiate DB + Ref = cosNotification_eventDB:create_db(QoS_NO_OF_EVENTS, 50, 50, undefined), + create_loop([?EVENT1, ?EVENT2, ?EVENT3, ?EVENT4, ?EVENT6], Ref), + + %% Sleep so some events will get 'old'. + timer:sleep(60000), + create_loop([?EVENT7, ?EVENT8, ?EVENT9], Ref), + + %% Since gc is done by another process we must wait so it will have a chance + %% to complete the job. + timer:sleep(2000), + + ?match({Events6, true}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + + cosNotification_eventDB:destroy_db(Ref), + + ok. + + +%%----------------------------------------------------------------- +%% cosNotification_eventDB start- and stop-time API tests +%%----------------------------------------------------------------- +start_stop_time_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once. If Deadline defined the events that", + "are older must be discarded.", + ""]; +start_stop_time_api(suite) -> []; +start_stop_time_api(_Config) -> + + QoS1 = ?not_CreateInitQoS(), + QoS2 = ?not_SetOrderPolicy(QoS1, ?not_FifoOrder), + QoS3 = ?not_SetDiscardPolicy(QoS2, ?not_RejectNewEvents), + QoS4 = ?not_SetStopTimeSupported(QoS3, true), + QoS5 = ?not_SetStartTimeSupported(QoS4, true), + QoS_NO_OF_EVENTS = ?not_SetMaxEventsPerConsumer(QoS5, ?NO_OF_EVENTS), + + %% Initiate DB + TimeService = cosTime:start_time_service(2, 0), + Ref = cosNotification_eventDB:create_db(QoS_NO_OF_EVENTS, 50, 50, TimeService), + + T1 = 'CosTime_UTO':'_get_utc_time'('CosTime_UTO': + absolute_time('CosTime_TimeService': + new_universal_time(TimeService, + 100000000, 0, 2))), + T2 = 'CosTime_UTO':'_get_utc_time'('CosTime_UTO': + absolute_time('CosTime_TimeService': + new_universal_time(TimeService, + 200000000, 0, 2))), + T3 = 'CosTime_UTO':'_get_utc_time'('CosTime_UTO': + absolute_time('CosTime_TimeService': + new_universal_time(TimeService, + 300000000, 0, 2))), + T4 = 'CosTime_UTO':'_get_utc_time'('CosTime_UTO': + absolute_time('CosTime_TimeService': + new_universal_time(TimeService, + 400000000, 0, 2))), + %% Delivered after 10 seconds discarded after 20. + EVENT1 = ?not_CreateSE("","event1","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 1)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), T1)}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), T2)}], + [], any:create(orber_tc:null(), null)), + + %% Delivered after 30 seconds discarded after 10, i.e., always discarded. + EVENT2 = ?not_CreateSE("","event2","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 3)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), T3)}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), T1)}], + [], any:create(orber_tc:null(), null)), + + %% Delivered after 20 seconds discarded after 40 + EVENT3 = ?not_CreateSE("","event3","", + [#'CosNotification_Property' + {name="Priority", + value=any:create(orber_tc:short(), 2)}, + #'CosNotification_Property' + {name="StartTime", + value=any:create('TimeBase_UtcT':tc(), T2)}, + #'CosNotification_Property' + {name="StopTime", + value=any:create('TimeBase_UtcT':tc(), T4)}], + [], any:create(orber_tc:null(), null)), + + + + + create_loop([EVENT1, EVENT2, EVENT3], Ref), + + ?match({[], false}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + + %% Sleep so some events will get 'old'. + timer:sleep(12000), + + ?match({[EVENT1], true}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + + ?match({[], false}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + + timer:sleep(10000), + + ?match({[EVENT3], true}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + + timer:sleep(20000), + + %% See if EVENT2 really have been discarded. + ?match({[], false}, cosNotification_eventDB:get_events(Ref, ?NO_OF_EVENTS)), + + cosNotification_eventDB:destroy_db(Ref), + + cosTime:stop_time_service(TimeService), + + ok. + + +%%----------------------------------------------------------------- +%% cosNotification_eventDB order API tests +%%----------------------------------------------------------------- +reorder_api(doc) -> ["The event DB is used to store events which cannot be", + "delivered at once. If the QoS is updated we must be", + "able to change the ordering of events as the discard", + "and order policies tells us.", + ""]; +reorder_api(suite) -> []; +reorder_api(_Config) -> + %% We need to test switching between: + %% * Priority -> Fifo + %% * Priority -> Deadline + %% * Fifo -> Priority + %% * Fifo -> Deadline + %% * Deadline -> Priority + %% * Deadline -> Fifo + QoS = ?not_CreateInitQoS(), + QoS2 = ?not_SetMaxEventsPerConsumer(QoS,100), + QoS3 = ?not_SetPriority(QoS2, 10), + QoS4 = ?not_SetStartTimeSupported(QoS3, false), + QoS5 = ?not_SetOrderPolicy(QoS4, ?not_AnyOrder), + + + %% Test all order policies using Any order discard policy. + reorder_helper(?not_SetDiscardPolicy(QoS5, ?not_AnyOrder), "Discard Any"), + reorder_helper(?not_SetDiscardPolicy(QoS5, ?not_PriorityOrder), "Discard Priority"), + reorder_helper(?not_SetDiscardPolicy(QoS5, ?not_DeadlineOrder), "Discard Deadline"), + reorder_helper(?not_SetDiscardPolicy(QoS5, ?not_FifoOrder), "Discard Fifo"), + reorder_helper(?not_SetDiscardPolicy(QoS5, ?not_LifoOrder), "Discard Lifo"), + reorder_helper(?not_SetDiscardPolicy(QoS5, ?not_RejectNewEvents), "Reject New Events"), + + ok. + + +reorder_helper(QoS, Txt) -> + io:format("$$$$$$$$$$$$$$$$$$$$ ~s $$$$$$$$$$$$$$$$$$$~n", [Txt]), + %% Create a DB with the above settings. + Ref = cosNotification_eventDB:create_db(QoS, 60, 50, undefined), + + Events = ?EVENTS, + PrioOrder = ?PRIOORDER, + FifoOrder = ?FIFOORDER, + DeadlineOrder = ?DEADLINEORDER, + + %% Test all order policies using Any order discard policy. + Ref2 = do_reorder(Ref, Events, ?not_SetOrderPolicy(QoS, ?not_FifoOrder), + FifoOrder, "Priority -> Fifo"), + Ref3 = do_reorder(Ref2, Events, ?not_SetOrderPolicy(QoS, ?not_PriorityOrder), + PrioOrder, "Fifo -> Priority"), + Ref4 = do_reorder(Ref3, Events, ?not_SetOrderPolicy(QoS, ?not_DeadlineOrder), + DeadlineOrder, "Priority -> Deadline"), + + Ref5 = do_reorder(Ref4, Events, ?not_SetOrderPolicy(QoS, ?not_PriorityOrder), + PrioOrder, "Deadline -> Priority"), + + Ref6 = do_reorder(Ref5, Events, ?not_SetOrderPolicy(QoS, ?not_FifoOrder), + FifoOrder, "Priority -> Fifo"), + + Ref7 = do_reorder(Ref6, Events, ?not_SetOrderPolicy(QoS, ?not_DeadlineOrder), + DeadlineOrder, "Fifo -> Deadline"), + + Ref8 = do_reorder(Ref7, Events, ?not_SetOrderPolicy(QoS, ?not_FifoOrder), + FifoOrder, "Deadline -> Fifo"), + cosNotification_eventDB:destroy_db(Ref8), + ok. + + + +do_reorder(Ref, Events, QoS, Reply, Txt) -> + create_loop(Events, Ref), + io:format("################# ~s #################~n", [Txt]), + NewRef = cosNotification_eventDB:update(Ref, QoS), + ?match({Reply,_}, cosNotification_eventDB:get_events(NewRef, ?NO_OF_EVENTS)), + NewRef. + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- +%% This functions takes as argument a list of structured events. +create_loop([], _Ref) -> + ok; +create_loop([H|T], Ref) -> + catch cosNotification_eventDB:add_event(Ref, H), + create_loop(T, Ref). + +create_loop([], _Ref, _Life, _Prio) -> + ok; +create_loop([H|T], Ref, Life, Prio) -> + catch cosNotification_eventDB:add_event(Ref, H, Life, Prio), + create_loop(T, Ref, Life, Prio). + +%%-------------------- End of Module ------------------------------ diff --git a/lib/cosNotification/test/generated_SUITE.erl b/lib/cosNotification/test/generated_SUITE.erl new file mode 100644 index 0000000000..34b84041f0 --- /dev/null +++ b/lib/cosNotification/test/generated_SUITE.erl @@ -0,0 +1,2042 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : generated_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(generated_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + AcTuAlReS + end + end()). + + +-define(checktc(_Op), + fun(TC) -> + case orber_tc:check_tc(TC) of + false -> + io:format("###### ERROR ERROR ######~n~p - ~p~n", [Op, TC]), + ?line exit(TC); + true -> + true + end + end). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing IC generated files"]; +all(suite) -> + ['CosNotification', 'CosNotification_AdminPropertiesAdmin', + 'CosNotification_EventHeader', 'CosNotification_EventType', + 'CosNotification_FixedEventHeader', 'CosNotification_NamedPropertyRange', + 'CosNotification_Property', 'CosNotification_PropertyError', + 'CosNotification_PropertyRange', 'CosNotification_QoSAdmin', + 'CosNotification_StructuredEvent', 'CosNotification_UnsupportedAdmin', + 'CosNotification_UnsupportedQoS', 'CosNotification_EventBatch', + 'CosNotification_EventTypeSeq', 'CosNotification_NamedPropertyRangeSeq', + 'CosNotification_PropertyErrorSeq', 'CosNotifyChannelAdmin_AdminLimit', + 'CosNotifyChannelAdmin_AdminNotFound', 'CosNotifyChannelAdmin_ChannelNotFound', + 'CosNotifyChannelAdmin_ConnectionAlreadyActive', 'CosNotifyChannelAdmin_ConnectionAlreadyInactive', + 'CosNotifyChannelAdmin_NotConnected', 'CosNotifyChannelAdmin_AdminIDSeq', + 'CosNotifyChannelAdmin_ChannelIDSeq', 'CosNotifyChannelAdmin_ProxyIDSeq', + 'CosNotifyFilter_CallbackNotFound', 'CosNotifyFilter_ConstraintExp', + 'CosNotifyFilter_ConstraintInfo', 'CosNotifyFilter_ConstraintNotFound', + 'CosNotifyFilter_DuplicateConstraintID', 'CosNotifyFilter_FilterNotFound', + 'CosNotifyFilter_InvalidConstraint', 'CosNotifyFilter_InvalidGrammar', + 'CosNotifyFilter_InvalidValue', 'CosNotifyFilter_MappingConstraintInfo', + 'CosNotifyFilter_MappingConstraintPair', 'CosNotifyFilter_UnsupportedFilterableData', + 'CosNotifyFilter_CallbackIDSeq', 'CosNotifyFilter_ConstraintExpSeq', + 'CosNotifyFilter_ConstraintIDSeq', 'CosNotifyFilter_ConstraintInfoSeq', + 'CosNotifyFilter_FilterIDSeq', 'CosNotifyFilter_MappingConstraintInfoSeq', + 'CosNotifyFilter_MappingConstraintPairSeq', 'CosNotifyComm_InvalidEventType', + 'CosNotifyChannelAdmin_ConsumerAdmin', 'CosNotifyChannelAdmin_EventChannel', + 'CosNotifyChannelAdmin_EventChannelFactory', 'CosNotifyChannelAdmin_ProxyConsumer', + 'CosNotifyChannelAdmin_ProxyNotFound', 'CosNotifyChannelAdmin_ProxyPullConsumer', + 'CosNotifyChannelAdmin_ProxyPullSupplier', 'CosNotifyChannelAdmin_ProxyPushConsumer', + 'CosNotifyChannelAdmin_ProxyPushSupplier', 'CosNotifyChannelAdmin_ProxySupplier', + 'CosNotifyChannelAdmin_SequenceProxyPullConsumer', 'CosNotifyChannelAdmin_SequenceProxyPullSupplier', + 'CosNotifyChannelAdmin_SequenceProxyPushConsumer', 'CosNotifyChannelAdmin_SequenceProxyPushSupplier', + 'CosNotifyChannelAdmin_StructuredProxyPullConsumer', 'CosNotifyChannelAdmin_StructuredProxyPullSupplier', + 'CosNotifyChannelAdmin_StructuredProxyPushConsumer', 'CosNotifyChannelAdmin_StructuredProxyPushSupplier', + 'CosNotifyChannelAdmin_SupplierAdmin', 'CosNotifyFilter_Filter', + 'CosNotifyFilter_FilterAdmin', 'CosNotifyFilter_FilterFactory', + 'CosNotifyFilter_MappingFilter', 'CosNotifyComm_NotifyPublish', + 'CosNotifyComm_NotifySubscribe', 'CosNotifyComm_PullConsumer', + 'CosNotifyComm_PullSupplier', 'CosNotifyComm_PushConsumer', + 'CosNotifyComm_PushSupplier', 'CosNotifyComm_SequencePullConsumer', + 'CosNotifyComm_SequencePullSupplier', 'CosNotifyComm_SequencePushConsumer', + 'CosNotifyComm_SequencePushSupplier', 'CosNotifyComm_StructuredPullConsumer', + 'CosNotifyComm_StructuredPullSupplier', 'CosNotifyComm_StructuredPushConsumer', + 'CosNotifyComm_StructuredPushSupplier', 'oe_CosNotificationComm_Event', + 'CosNotification_PropertySeq']. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification' +%% Description: +%%----------------------------------------------------------------- +'CosNotification'(doc) -> ["CosNotification"]; +'CosNotification'(suite) -> []; +'CosNotification'(_) -> + ?match("EventReliability", 'CosNotification':'EventReliability'()), + ?match(0, 'CosNotification':'BestEffort'()), + ?match(1, 'CosNotification':'Persistent'()), + ?match("ConnectionReliability", 'CosNotification':'ConnectionReliability'()), + ?match("Priority", 'CosNotification':'Priority'()), + ?match(-32767, 'CosNotification':'LowestPriority'()), + ?match(32767, 'CosNotification':'HighestPriority'()), + ?match(0, 'CosNotification':'DefaultPriority'()), + ?match("StartTime", 'CosNotification':'StartTime'()), + ?match("StopTime", 'CosNotification':'StopTime'()), + ?match("Timeout", 'CosNotification':'Timeout'()), + ?match("OrderPolicy", 'CosNotification':'OrderPolicy'()), + ?match(0, 'CosNotification':'AnyOrder'()), + ?match(1, 'CosNotification':'FifoOrder'()), + ?match(2, 'CosNotification':'PriorityOrder'()), + ?match(3, 'CosNotification':'DeadlineOrder'()), + ?match("DiscardPolicy", 'CosNotification':'DiscardPolicy'()), + ?match(4, 'CosNotification':'LifoOrder'()), + ?match(5, 'CosNotification':'RejectNewEvents'()), + ?match("MaximumBatchSize", 'CosNotification':'MaximumBatchSize'()), + ?match("PacingInterval", 'CosNotification':'PacingInterval'()), + ?match("StartTimeSupported", 'CosNotification':'StartTimeSupported'()), + ?match("StopTimeSupported", 'CosNotification':'StopTimeSupported'()), + ?match("MaxEventsPerConsumer", 'CosNotification':'MaxEventsPerConsumer'()), + ?match("MaxQueueLength", 'CosNotification':'MaxQueueLength'()), + ?match("MaxConsumers", 'CosNotification':'MaxConsumers'()), + ?match("MaxSuppliers", 'CosNotification':'MaxSuppliers'()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_EventHeader' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_EventHeader'(doc) -> ["CosNotification_EventHeader"]; +'CosNotification_EventHeader'(suite) -> []; +'CosNotification_EventHeader'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_EventHeader':tc())), + ?match("IDL:omg.org/CosNotification/EventHeader:1.0", + 'CosNotification_EventHeader':id()), + ?match("CosNotification_EventHeader", + 'CosNotification_EventHeader':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_EventType' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_EventType'(doc) -> ["CosNotification_EventType"]; +'CosNotification_EventType'(suite) -> []; +'CosNotification_EventType'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_EventType':tc())), + ?match("IDL:omg.org/CosNotification/EventType:1.0", + 'CosNotification_EventType':id()), + ?match("CosNotification_EventType", + 'CosNotification_EventType':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_FixedEventHeader' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_FixedEventHeader'(doc) -> ["CosNotification_FixedEventHeader"]; +'CosNotification_FixedEventHeader'(suite) -> []; +'CosNotification_FixedEventHeader'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_FixedEventHeader':tc())), + ?match("IDL:omg.org/CosNotification/FixedEventHeader:1.0", + 'CosNotification_FixedEventHeader':id()), + ?match("CosNotification_FixedEventHeader", + 'CosNotification_FixedEventHeader':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_NamedPropertyRange' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_NamedPropertyRange'(doc) -> ["CosNotification_NamedPropertyRange"]; +'CosNotification_NamedPropertyRange'(suite) -> []; +'CosNotification_NamedPropertyRange'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_NamedPropertyRange':tc())), + ?match("IDL:omg.org/CosNotification/NamedPropertyRange:1.0", + 'CosNotification_NamedPropertyRange':id()), + ?match("CosNotification_NamedPropertyRange", + 'CosNotification_NamedPropertyRange':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_Property' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_Property'(doc) -> ["CosNotification_Property"]; +'CosNotification_Property'(suite) -> []; +'CosNotification_Property'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_Property':tc())), + ?match("IDL:omg.org/CosNotification/Property:1.0", + 'CosNotification_Property':id()), + ?match("CosNotification_Property", + 'CosNotification_Property':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_PropertyError' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_PropertyError'(doc) -> ["CosNotification_PropertyError"]; +'CosNotification_PropertyError'(suite) -> []; +'CosNotification_PropertyError'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_PropertyError':tc())), + ?match("IDL:omg.org/CosNotification/PropertyError:1.0", + 'CosNotification_PropertyError':id()), + ?match("CosNotification_PropertyError", + 'CosNotification_PropertyError':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_PropertyRange' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_PropertyRange'(doc) -> [""]; +'CosNotification_PropertyRange'(suite) -> []; +'CosNotification_PropertyRange'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_PropertyRange':tc())), + ?match("IDL:omg.org/CosNotification/PropertyRange:1.0", + 'CosNotification_PropertyRange':id()), + ?match("CosNotification_PropertyRange", + 'CosNotification_PropertyRange':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_StructuredEvent' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_StructuredEvent'(doc) -> ["CosNotification_StructuredEvent"]; +'CosNotification_StructuredEvent'(suite) -> []; +'CosNotification_StructuredEvent'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_StructuredEvent':tc())), + ?match("IDL:omg.org/CosNotification/StructuredEvent:1.0", + 'CosNotification_StructuredEvent':id()), + ?match("CosNotification_StructuredEvent", + 'CosNotification_StructuredEvent':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_UnsupportedAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_UnsupportedAdmin'(doc) -> ["CosNotification_UnsupportedAdmin"]; +'CosNotification_UnsupportedAdmin'(suite) -> []; +'CosNotification_UnsupportedAdmin'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_UnsupportedAdmin':tc())), + ?match("IDL:omg.org/CosNotification/UnsupportedAdmin:1.0", + 'CosNotification_UnsupportedAdmin':id()), + ?match("CosNotification_UnsupportedAdmin", + 'CosNotification_UnsupportedAdmin':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_UnsupportedQoS' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_UnsupportedQoS'(doc) -> ["CosNotification_UnsupportedQoS"]; +'CosNotification_UnsupportedQoS'(suite) -> []; +'CosNotification_UnsupportedQoS'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_UnsupportedQoS':tc())), + ?match("IDL:omg.org/CosNotification/UnsupportedQoS:1.0", + 'CosNotification_UnsupportedQoS':id()), + ?match("CosNotification_UnsupportedQoS", + 'CosNotification_UnsupportedQoS':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_EventBatch' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_EventBatch'(doc) -> ["CosNotification_EventBatch"]; +'CosNotification_EventBatch'(suite) -> []; +'CosNotification_EventBatch'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_EventBatch':tc())), + ?match("IDL:omg.org/CosNotification/EventBatch:1.0", + 'CosNotification_EventBatch':id()), + ?match("CosNotification_EventBatch", + 'CosNotification_EventBatch':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_EventTypeSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_EventTypeSeq'(doc) -> ["CosNotification_EventTypeSeq"]; +'CosNotification_EventTypeSeq'(suite) -> []; +'CosNotification_EventTypeSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_EventTypeSeq':tc())), + ?match("IDL:omg.org/CosNotification/EventTypeSeq:1.0", + 'CosNotification_EventTypeSeq':id()), + ?match("CosNotification_EventTypeSeq", + 'CosNotification_EventTypeSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_NamedPropertyRangeSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_NamedPropertyRangeSeq'(doc) -> ["CosNotification_NamedPropertyRangeSeq"]; +'CosNotification_NamedPropertyRangeSeq'(suite) -> []; +'CosNotification_NamedPropertyRangeSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_NamedPropertyRangeSeq':tc())), + ?match("IDL:omg.org/CosNotification/NamedPropertyRangeSeq:1.0", + 'CosNotification_NamedPropertyRangeSeq':id()), + ?match("CosNotification_NamedPropertyRangeSeq", + 'CosNotification_NamedPropertyRangeSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_PropertyErrorSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_PropertyErrorSeq'(doc) -> ["CosNotification_PropertyErrorSeq"]; +'CosNotification_PropertyErrorSeq'(suite) -> []; +'CosNotification_PropertyErrorSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_PropertyErrorSeq':tc())), + ?match("IDL:omg.org/CosNotification/PropertyErrorSeq:1.0", + 'CosNotification_PropertyErrorSeq':id()), + ?match("CosNotification_PropertyErrorSeq", + 'CosNotification_PropertyErrorSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_PropertySeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_PropertySeq'(doc) -> ["CosNotification_PropertySeq"]; +'CosNotification_PropertySeq'(suite) -> []; +'CosNotification_PropertySeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotification_PropertySeq':tc())), + ?match("IDL:omg.org/CosNotification/PropertySeq:1.0", + 'CosNotification_PropertySeq':id()), + ?match("CosNotification_PropertySeq", + 'CosNotification_PropertySeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_AdminLimit' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_AdminLimit'(doc) -> ["CosNotifyChannelAdmin_AdminLimit"]; +'CosNotifyChannelAdmin_AdminLimit'(suite) -> []; +'CosNotifyChannelAdmin_AdminLimit'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_AdminLimit':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/AdminLimit:1.0", + 'CosNotifyChannelAdmin_AdminLimit':id()), + ?match("CosNotifyChannelAdmin_AdminLimit", + 'CosNotifyChannelAdmin_AdminLimit':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_AdminLimitExceeded' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_AdminLimitExceeded'(doc) -> ["CosNotifyChannelAdmin_AdminLimitExceeded"]; +'CosNotifyChannelAdmin_AdminLimitExceeded'(suite) -> []; +'CosNotifyChannelAdmin_AdminLimitExceeded'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_AdminLimitExceeded':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/AdminLimitExceeded:1.0", + 'CosNotifyChannelAdmin_AdminLimitExceeded':id()), + ?match("CosNotifyChannelAdmin_AdminLimitExceeded", + 'CosNotifyChannelAdmin_AdminLimitExceeded':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_AdminNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_AdminNotFound'(doc) -> ["CosNotifyChannelAdmin_AdminNotFound"]; +'CosNotifyChannelAdmin_AdminNotFound'(suite) -> []; +'CosNotifyChannelAdmin_AdminNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_AdminNotFound':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/AdminNotFound:1.0", + 'CosNotifyChannelAdmin_AdminNotFound':id()), + ?match("CosNotifyChannelAdmin_AdminNotFound", + 'CosNotifyChannelAdmin_AdminNotFound':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ChannelNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ChannelNotFound'(doc) -> ["CosNotifyChannelAdmin_ChannelNotFound"]; +'CosNotifyChannelAdmin_ChannelNotFound'(suite) -> []; +'CosNotifyChannelAdmin_ChannelNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_ChannelNotFound':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ChannelNotFound:1.0", + 'CosNotifyChannelAdmin_ChannelNotFound':id()), + ?match("CosNotifyChannelAdmin_ChannelNotFound", + 'CosNotifyChannelAdmin_ChannelNotFound':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ConnectionAlreadyActive' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ConnectionAlreadyActive'(doc) -> ["CosNotifyChannelAdmin_ConnectionAlreadyActive"]; +'CosNotifyChannelAdmin_ConnectionAlreadyActive'(suite) -> []; +'CosNotifyChannelAdmin_ConnectionAlreadyActive'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_ConnectionAlreadyActive':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ConnectionAlreadyActive:1.0", + 'CosNotifyChannelAdmin_ConnectionAlreadyActive':id()), + ?match("CosNotifyChannelAdmin_ConnectionAlreadyActive", + 'CosNotifyChannelAdmin_ConnectionAlreadyActive':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ConnectionAlreadyInactive' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ConnectionAlreadyInactive'(doc) -> ["CosNotifyChannelAdmin_ConnectionAlreadyInactive"]; +'CosNotifyChannelAdmin_ConnectionAlreadyInactive'(suite) -> []; +'CosNotifyChannelAdmin_ConnectionAlreadyInactive'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_ConnectionAlreadyInactive':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ConnectionAlreadyInactive:1.0", + 'CosNotifyChannelAdmin_ConnectionAlreadyInactive':id()), + ?match("CosNotifyChannelAdmin_ConnectionAlreadyInactive", + 'CosNotifyChannelAdmin_ConnectionAlreadyInactive':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_NotConnected' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_NotConnected'(doc) -> ["CosNotifyChannelAdmin_NotConnected"]; +'CosNotifyChannelAdmin_NotConnected'(suite) -> []; +'CosNotifyChannelAdmin_NotConnected'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_NotConnected':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/NotConnected:1.0", + 'CosNotifyChannelAdmin_NotConnected':id()), + ?match("CosNotifyChannelAdmin_NotConnected", + 'CosNotifyChannelAdmin_NotConnected':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_AdminIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_AdminIDSeq'(doc) -> ["CosNotifyChannelAdmin_AdminIDSeq"]; +'CosNotifyChannelAdmin_AdminIDSeq'(suite) -> []; +'CosNotifyChannelAdmin_AdminIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_AdminIDSeq':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/AdminIDSeq:1.0", + 'CosNotifyChannelAdmin_AdminIDSeq':id()), + ?match("CosNotifyChannelAdmin_AdminIDSeq", + 'CosNotifyChannelAdmin_AdminIDSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ChannelIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ChannelIDSeq'(doc) -> ["CosNotifyChannelAdmin_ChannelIDSeq"]; +'CosNotifyChannelAdmin_ChannelIDSeq'(suite) -> []; +'CosNotifyChannelAdmin_ChannelIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_ChannelIDSeq':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ChannelIDSeq:1.0", + 'CosNotifyChannelAdmin_ChannelIDSeq':id()), + ?match("CosNotifyChannelAdmin_ChannelIDSeq", + 'CosNotifyChannelAdmin_ChannelIDSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ProxyIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ProxyIDSeq'(doc) -> ["CosNotifyChannelAdmin_ProxyIDSeq"]; +'CosNotifyChannelAdmin_ProxyIDSeq'(suite) -> []; +'CosNotifyChannelAdmin_ProxyIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_ProxyIDSeq':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ProxyIDSeq:1.0", + 'CosNotifyChannelAdmin_ProxyIDSeq':id()), + ?match("CosNotifyChannelAdmin_ProxyIDSeq", + 'CosNotifyChannelAdmin_ProxyIDSeq':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_CallbackNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_CallbackNotFound'(doc) -> ["CosNotifyFilter_CallbackNotFound"]; +'CosNotifyFilter_CallbackNotFound'(suite) -> []; +'CosNotifyFilter_CallbackNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_CallbackNotFound':tc())), + ?match("IDL:omg.org/CosNotifyFilter/CallbackNotFound:1.0", + 'CosNotifyFilter_CallbackNotFound':id()), + ?match("CosNotifyFilter_CallbackNotFound", + 'CosNotifyFilter_CallbackNotFound':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_ConstraintExp' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_ConstraintExp'(doc) -> ["CosNotifyFilter_ConstraintExp"]; +'CosNotifyFilter_ConstraintExp'(suite) -> []; +'CosNotifyFilter_ConstraintExp'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_ConstraintExp':tc())), + ?match("IDL:omg.org/CosNotifyFilter/ConstraintExp:1.0", + 'CosNotifyFilter_ConstraintExp':id()), + ?match("CosNotifyFilter_ConstraintExp", + 'CosNotifyFilter_ConstraintExp':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_ConstraintInfo' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_ConstraintInfo'(doc) -> ["CosNotifyFilter_ConstraintInfo"]; +'CosNotifyFilter_ConstraintInfo'(suite) -> []; +'CosNotifyFilter_ConstraintInfo'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_ConstraintInfo':tc())), + ?match("IDL:omg.org/CosNotifyFilter/ConstraintInfo:1.0", + 'CosNotifyFilter_ConstraintInfo':id()), + ?match("CosNotifyFilter_ConstraintInfo", + 'CosNotifyFilter_ConstraintInfo':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_ConstraintNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_ConstraintNotFound'(doc) -> ["CosNotifyFilter_ConstraintNotFound"]; +'CosNotifyFilter_ConstraintNotFound'(suite) -> []; +'CosNotifyFilter_ConstraintNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_ConstraintNotFound':tc())), + ?match("IDL:omg.org/CosNotifyFilter/ConstraintNotFound:1.0", + 'CosNotifyFilter_ConstraintNotFound':id()), + ?match("CosNotifyFilter_ConstraintNotFound", + 'CosNotifyFilter_ConstraintNotFound':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_DuplicateConstraintID' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_DuplicateConstraintID'(doc) -> ["CosNotifyFilter_DuplicateConstraintID"]; +'CosNotifyFilter_DuplicateConstraintID'(suite) -> []; +'CosNotifyFilter_DuplicateConstraintID'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_DuplicateConstraintID':tc())), + ?match("IDL:omg.org/CosNotifyFilter/DuplicateConstraintID:1.0", + 'CosNotifyFilter_DuplicateConstraintID':id()), + ?match("CosNotifyFilter_DuplicateConstraintID", + 'CosNotifyFilter_DuplicateConstraintID':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_FilterNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_FilterNotFound'(doc) -> ["CosNotifyFilter_FilterNotFound"]; +'CosNotifyFilter_FilterNotFound'(suite) -> []; +'CosNotifyFilter_FilterNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_FilterNotFound':tc())), + ?match("IDL:omg.org/CosNotifyFilter/FilterNotFound:1.0", + 'CosNotifyFilter_FilterNotFound':id()), + ?match("CosNotifyFilter_FilterNotFound", + 'CosNotifyFilter_FilterNotFound':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_InvalidConstraint' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_InvalidConstraint'(doc) -> ["CosNotifyFilter_InvalidConstraint"]; +'CosNotifyFilter_InvalidConstraint'(suite) -> []; +'CosNotifyFilter_InvalidConstraint'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_InvalidConstraint':tc())), + ?match("IDL:omg.org/CosNotifyFilter/InvalidConstraint:1.0", + 'CosNotifyFilter_InvalidConstraint':id()), + ?match("CosNotifyFilter_InvalidConstraint", + 'CosNotifyFilter_InvalidConstraint':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_InvalidGrammar' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_InvalidGrammar'(doc) -> ["CosNotifyFilter_InvalidGrammar"]; +'CosNotifyFilter_InvalidGrammar'(suite) -> []; +'CosNotifyFilter_InvalidGrammar'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_InvalidGrammar':tc())), + ?match("IDL:omg.org/CosNotifyFilter/InvalidGrammar:1.0", + 'CosNotifyFilter_InvalidGrammar':id()), + ?match("CosNotifyFilter_InvalidGrammar", + 'CosNotifyFilter_InvalidGrammar':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_InvalidValue' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_InvalidValue'(doc) -> ["CosNotifyFilter_InvalidValue"]; +'CosNotifyFilter_InvalidValue'(suite) -> []; +'CosNotifyFilter_InvalidValue'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_InvalidValue':tc())), + ?match("IDL:omg.org/CosNotifyFilter/InvalidValue:1.0", + 'CosNotifyFilter_InvalidValue':id()), + ?match("CosNotifyFilter_InvalidValue", + 'CosNotifyFilter_InvalidValue':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_MappingConstraintInfo' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_MappingConstraintInfo'(doc) -> ["CosNotifyFilter_MappingConstraintInfo"]; +'CosNotifyFilter_MappingConstraintInfo'(suite) -> []; +'CosNotifyFilter_MappingConstraintInfo'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_MappingConstraintInfo':tc())), + ?match("IDL:omg.org/CosNotifyFilter/MappingConstraintInfo:1.0", + 'CosNotifyFilter_MappingConstraintInfo':id()), + ?match("CosNotifyFilter_MappingConstraintInfo", + 'CosNotifyFilter_MappingConstraintInfo':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_MappingConstraintPair' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_MappingConstraintPair'(doc) -> ["CosNotifyFilter_MappingConstraintPair"]; +'CosNotifyFilter_MappingConstraintPair'(suite) -> []; +'CosNotifyFilter_MappingConstraintPair'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_MappingConstraintPair':tc())), + ?match("IDL:omg.org/CosNotifyFilter/MappingConstraintPair:1.0", + 'CosNotifyFilter_MappingConstraintPair':id()), + ?match("CosNotifyFilter_MappingConstraintPair", + 'CosNotifyFilter_MappingConstraintPair':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_UnsupportedFilterableData' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_UnsupportedFilterableData'(doc) -> ["CosNotifyFilter_UnsupportedFilterableData"]; +'CosNotifyFilter_UnsupportedFilterableData'(suite) -> []; +'CosNotifyFilter_UnsupportedFilterableData'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_UnsupportedFilterableData':tc())), + ?match("IDL:omg.org/CosNotifyFilter/UnsupportedFilterableData:1.0", + 'CosNotifyFilter_UnsupportedFilterableData':id()), + ?match("CosNotifyFilter_UnsupportedFilterableData", + 'CosNotifyFilter_UnsupportedFilterableData':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_CallbackIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_CallbackIDSeq'(doc) -> ["CosNotifyFilter_CallbackIDSeq"]; +'CosNotifyFilter_CallbackIDSeq'(suite) -> []; +'CosNotifyFilter_CallbackIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_CallbackIDSeq':tc())), + ?match("IDL:omg.org/CosNotifyFilter/CallbackIDSeq:1.0", + 'CosNotifyFilter_CallbackIDSeq':id()), + ?match("CosNotifyFilter_CallbackIDSeq", + 'CosNotifyFilter_CallbackIDSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_ConstraintExpSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_ConstraintExpSeq'(doc) -> ["CosNotifyFilter_ConstraintExpSeq"]; +'CosNotifyFilter_ConstraintExpSeq'(suite) -> []; +'CosNotifyFilter_ConstraintExpSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_ConstraintExpSeq':tc())), + ?match("IDL:omg.org/CosNotifyFilter/ConstraintExpSeq:1.0", + 'CosNotifyFilter_ConstraintExpSeq':id()), + ?match("CosNotifyFilter_ConstraintExpSeq", + 'CosNotifyFilter_ConstraintExpSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_ConstraintIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_ConstraintIDSeq'(doc) -> ["CosNotifyFilter_ConstraintIDSeq"]; +'CosNotifyFilter_ConstraintIDSeq'(suite) -> []; +'CosNotifyFilter_ConstraintIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_ConstraintIDSeq':tc())), + ?match("IDL:omg.org/CosNotifyFilter/ConstraintIDSeq:1.0", + 'CosNotifyFilter_ConstraintIDSeq':id()), + ?match("CosNotifyFilter_ConstraintIDSeq", + 'CosNotifyFilter_ConstraintIDSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_ConstraintInfoSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_ConstraintInfoSeq'(doc) -> ["CosNotifyFilter_ConstraintInfoSeq"]; +'CosNotifyFilter_ConstraintInfoSeq'(suite) -> []; +'CosNotifyFilter_ConstraintInfoSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_ConstraintInfoSeq':tc())), + ?match("IDL:omg.org/CosNotifyFilter/ConstraintInfoSeq:1.0", + 'CosNotifyFilter_ConstraintInfoSeq':id()), + ?match("CosNotifyFilter_ConstraintInfoSeq", + 'CosNotifyFilter_ConstraintInfoSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_FilterIDSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_FilterIDSeq'(doc) -> ["CosNotifyFilter_FilterIDSeq"]; +'CosNotifyFilter_FilterIDSeq'(suite) -> []; +'CosNotifyFilter_FilterIDSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_FilterIDSeq':tc())), + ?match("IDL:omg.org/CosNotifyFilter/FilterIDSeq:1.0", + 'CosNotifyFilter_FilterIDSeq':id()), + ?match("CosNotifyFilter_FilterIDSeq", + 'CosNotifyFilter_FilterIDSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_MappingConstraintInfoSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_MappingConstraintInfoSeq'(doc) -> ["CosNotifyFilter_MappingConstraintInfoSeq"]; +'CosNotifyFilter_MappingConstraintInfoSeq'(suite) -> []; +'CosNotifyFilter_MappingConstraintInfoSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_MappingConstraintInfoSeq':tc())), + ?match("IDL:omg.org/CosNotifyFilter/MappingConstraintInfoSeq:1.0", + 'CosNotifyFilter_MappingConstraintInfoSeq':id()), + ?match("CosNotifyFilter_MappingConstraintInfoSeq", + 'CosNotifyFilter_MappingConstraintInfoSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_MappingConstraintPairSeq' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_MappingConstraintPairSeq'(doc) -> ["CosNotifyFilter_MappingConstraintPairSeq"]; +'CosNotifyFilter_MappingConstraintPairSeq'(suite) -> []; +'CosNotifyFilter_MappingConstraintPairSeq'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyFilter_MappingConstraintPairSeq':tc())), + ?match("IDL:omg.org/CosNotifyFilter/MappingConstraintPairSeq:1.0", + 'CosNotifyFilter_MappingConstraintPairSeq':id()), + ?match("CosNotifyFilter_MappingConstraintPairSeq", + 'CosNotifyFilter_MappingConstraintPairSeq':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_InvalidEventType' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_InvalidEventType'(doc) -> ["CosNotifyComm_InvalidEventType"]; +'CosNotifyComm_InvalidEventType'(suite) -> []; +'CosNotifyComm_InvalidEventType'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyComm_InvalidEventType':tc())), + ?match("IDL:omg.org/CosNotifyComm/InvalidEventType:1.0", + 'CosNotifyComm_InvalidEventType':id()), + ?match("CosNotifyComm_InvalidEventType", + 'CosNotifyComm_InvalidEventType':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ProxyNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ProxyNotFound'(doc) -> ["CosNotifyChannelAdmin_ProxyNotFound"]; +'CosNotifyChannelAdmin_ProxyNotFound'(suite) -> []; +'CosNotifyChannelAdmin_ProxyNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosNotifyChannelAdmin_ProxyNotFound':tc())), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ProxyNotFound:1.0", + 'CosNotifyChannelAdmin_ProxyNotFound':id()), + ?match("CosNotifyChannelAdmin_ProxyNotFound", + 'CosNotifyChannelAdmin_ProxyNotFound':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_AdminPropertiesAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_AdminPropertiesAdmin'(doc) -> ["CosNotification_AdminPropertiesAdmin"]; +'CosNotification_AdminPropertiesAdmin'(suite) -> []; +'CosNotification_AdminPropertiesAdmin'(_) -> + ?nomatch(undefined, 'CosNotification_AdminPropertiesAdmin':oe_tc(get_admin)), + ?nomatch(undefined, 'CosNotification_AdminPropertiesAdmin':oe_tc(set_admin)), + ?match(undefined, 'CosNotification_AdminPropertiesAdmin':oe_tc(undefined)), + ?match([_|_], 'CosNotification_AdminPropertiesAdmin':oe_get_interface()), + ?match("IDL:omg.org/CosNotification/AdminPropertiesAdmin:1.0", + 'CosNotification_AdminPropertiesAdmin':typeID()), + check_tc('CosNotification_AdminPropertiesAdmin':oe_get_interface()), + ?match(true, 'CosNotification_AdminPropertiesAdmin':oe_is_a('CosNotification_AdminPropertiesAdmin':typeID())), + ?match(false, 'CosNotification_AdminPropertiesAdmin':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotification_QoSAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosNotification_QoSAdmin'(doc) -> ["CosNotification_QoSAdmin"]; +'CosNotification_QoSAdmin'(suite) -> []; +'CosNotification_QoSAdmin'(_) -> + ?nomatch(undefined, 'CosNotification_QoSAdmin':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotification_QoSAdmin':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotification_QoSAdmin':oe_tc(validate_qos)), + ?match(undefined, 'CosNotification_QoSAdmin':oe_tc(undefined)), + ?match([_|_], 'CosNotification_QoSAdmin':oe_get_interface()), + ?match("IDL:omg.org/CosNotification/QoSAdmin:1.0", + 'CosNotification_QoSAdmin':typeID()), + check_tc('CosNotification_QoSAdmin':oe_get_interface()), + ?match(true, 'CosNotification_QoSAdmin':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(false, 'CosNotification_QoSAdmin':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ConsumerAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ConsumerAdmin'(doc) -> ["CosNotifyChannelAdmin_ConsumerAdmin"]; +'CosNotifyChannelAdmin_ConsumerAdmin'(suite) -> []; +'CosNotifyChannelAdmin_ConsumerAdmin'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_get_MyID')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_get_MyChannel')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_get_MyOperator')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_get_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_set_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_get_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_set_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_get_pull_suppliers')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc('_get_push_suppliers')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(get_proxy_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(obtain_notification_pull_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(obtain_notification_push_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(destroy)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(obtain_push_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(obtain_pull_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_ConsumerAdmin':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ConsumerAdmin:1.0", + 'CosNotifyChannelAdmin_ConsumerAdmin':typeID()), + check_tc('CosNotifyChannelAdmin_ConsumerAdmin':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_is_a('CosNotifyChannelAdmin_ConsumerAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_is_a('CosEventChannelAdmin_ConsumerAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_ConsumerAdmin':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_EventChannel' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_EventChannel'(doc) -> ["CosNotifyChannelAdmin_EventChannel"]; +'CosNotifyChannelAdmin_EventChannel'(suite) -> []; +'CosNotifyChannelAdmin_EventChannel'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc('_get_MyFactory')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc('_get_default_consumer_admin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc('_get_default_supplier_admin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc('_get_default_filter_factory')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(new_for_consumers)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(new_for_suppliers)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(get_consumeradmin)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(get_supplieradmin)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(get_all_consumeradmins)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(get_all_supplieradmins)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(get_admin)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(set_admin)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(for_consumers)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(for_suppliers)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(destroy)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_EventChannel':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_EventChannel':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/EventChannel:1.0", + 'CosNotifyChannelAdmin_EventChannel':typeID()), + check_tc('CosNotifyChannelAdmin_EventChannel':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_EventChannel':oe_is_a('CosNotifyChannelAdmin_EventChannel':typeID())), + ?match(true, 'CosNotifyChannelAdmin_EventChannel':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_EventChannel':oe_is_a('CosNotification_AdminPropertiesAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_EventChannel':oe_is_a('CosEventChannelAdmin_EventChannel':typeID())), + ?match(true, 'CosNotifyChannelAdmin_EventChannel':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_EventChannel':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_EventChannelFactory' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_EventChannelFactory'(doc) -> ["CosNotifyChannelAdmin_EventChannelFactory"]; +'CosNotifyChannelAdmin_EventChannelFactory'(suite) -> []; +'CosNotifyChannelAdmin_EventChannelFactory'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannelFactory':oe_tc(create_channel)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannelFactory':oe_tc(get_all_channels)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_EventChannelFactory':oe_tc(get_event_channel)), + ?match(undefined, 'CosNotifyChannelAdmin_EventChannelFactory':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_EventChannelFactory':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/EventChannelFactory:1.0", + 'CosNotifyChannelAdmin_EventChannelFactory':typeID()), + check_tc('CosNotifyChannelAdmin_EventChannelFactory':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_EventChannelFactory':oe_is_a('CosNotifyChannelAdmin_EventChannelFactory':typeID())), + ?match(false, 'CosNotifyChannelAdmin_EventChannelFactory':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ProxyConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ProxyConsumer'(doc) -> ["CosNotifyChannelAdmin_ProxyConsumer"]; +'CosNotifyChannelAdmin_ProxyConsumer'(suite) -> []; +'CosNotifyChannelAdmin_ProxyConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(obtain_subscription_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(remove_all_filters)), + ?match(undefined, 'CosNotifyChannelAdmin_ProxyConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_ProxyConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ProxyConsumer:1.0", + 'CosNotifyChannelAdmin_ProxyConsumer':typeID()), + check_tc('CosNotifyChannelAdmin_ProxyConsumer':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_ProxyConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyConsumer':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyConsumer':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(false, 'CosNotifyChannelAdmin_ProxyConsumer':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ProxyPullConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ProxyPullConsumer'(doc) -> ["CosNotifyChannelAdmin_ProxyPullConsumer"]; +'CosNotifyChannelAdmin_ProxyPullConsumer'(suite) -> []; +'CosNotifyChannelAdmin_ProxyPullConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(connect_any_pull_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(suspend_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(resume_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(obtain_subscription_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(offer_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(disconnect_pull_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(connect_pull_supplier)), + ?match(undefined, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ProxyPullConsumer:1.0", + 'CosNotifyChannelAdmin_ProxyPullConsumer':typeID()), + check_tc('CosNotifyChannelAdmin_ProxyPullConsumer':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyPullConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a('CosNotifyComm_PullConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a('CosEventComm_PullConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a('CosEventChannelAdmin_ProxyPullConsumer':typeID())), + ?match(false, 'CosNotifyChannelAdmin_ProxyPullConsumer':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ProxyPullSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ProxyPullSupplier'(doc) -> ["CosNotifyChannelAdmin_ProxyPullSupplier"]; +'CosNotifyChannelAdmin_ProxyPullSupplier'(suite) -> []; +'CosNotifyChannelAdmin_ProxyPullSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc('_get_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc('_set_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc('_get_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc('_set_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(obtain_offered_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(pull)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(try_pull)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(disconnect_pull_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(connect_pull_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ProxyPullSupplier:1.0", + 'CosNotifyChannelAdmin_ProxyPullSupplier':typeID()), + check_tc('CosNotifyChannelAdmin_ProxyPullSupplier':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('CosNotifyChannelAdmin_ProxyPullSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('CosNotifyChannelAdmin_ProxySupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('CosNotifyComm_PullSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('CosEventComm_PullSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('CosEventChannelAdmin_ProxyPullSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_ProxyPullSupplier':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ProxyPushConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ProxyPushConsumer'(doc) -> ["CosNotifyChannelAdmin_ProxyPushConsumer"]; +'CosNotifyChannelAdmin_ProxyPushConsumer'(suite) -> []; +'CosNotifyChannelAdmin_ProxyPushConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(connect_any_push_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(obtain_subscription_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(offer_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(push)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(disconnect_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(connect_push_supplier)), + ?match(undefined, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ProxyPushConsumer:1.0", + 'CosNotifyChannelAdmin_ProxyPushConsumer':typeID()), + check_tc('CosNotifyChannelAdmin_ProxyPushConsumer':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyPushConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a('CosNotifyComm_PushConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a('CosEventComm_PushConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a('CosEventChannelAdmin_ProxyPushConsumer':typeID())), + ?match(false, 'CosNotifyChannelAdmin_ProxyPushConsumer':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ProxyPushSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ProxyPushSupplier'(doc) -> ["CosNotifyChannelAdmin_ProxyPushSupplier"]; +'CosNotifyChannelAdmin_ProxyPushSupplier'(suite) -> []; +'CosNotifyChannelAdmin_ProxyPushSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(connect_any_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(suspend_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(resume_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc('_get_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc('_set_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc('_get_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc('_set_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(obtain_offered_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(disconnect_push_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(connect_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ProxyPushSupplier:1.0", + 'CosNotifyChannelAdmin_ProxyPushSupplier':typeID()), + check_tc('CosNotifyChannelAdmin_ProxyPushSupplier':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('CosNotifyChannelAdmin_ProxyPushSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('CosNotifyChannelAdmin_ProxySupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('CosNotifyComm_PushSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('CosEventComm_PushSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('CosEventChannelAdmin_ProxyPushSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_ProxyPushSupplier':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_ProxySupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_ProxySupplier'(doc) -> ["CosNotifyChannelAdmin_ProxySupplier"]; +'CosNotifyChannelAdmin_ProxySupplier'(suite) -> []; +'CosNotifyChannelAdmin_ProxySupplier'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc('_get_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc('_set_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc('_get_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc('_set_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(obtain_offered_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(remove_all_filters)), + ?match(undefined, 'CosNotifyChannelAdmin_ProxySupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_ProxySupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/ProxySupplier:1.0", + 'CosNotifyChannelAdmin_ProxySupplier':typeID()), + check_tc('CosNotifyChannelAdmin_ProxySupplier':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_ProxySupplier':oe_is_a('CosNotifyChannelAdmin_ProxySupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxySupplier':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_ProxySupplier':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(false, 'CosNotifyChannelAdmin_ProxySupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_SequenceProxyPullConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_SequenceProxyPullConsumer'(doc) -> ["CosNotifyChannelAdmin_SequenceProxyPullConsumer"]; +'CosNotifyChannelAdmin_SequenceProxyPullConsumer'(suite) -> []; +'CosNotifyChannelAdmin_SequenceProxyPullConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(connect_sequence_pull_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(suspend_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(resume_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(obtain_subscription_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(disconnect_sequence_pull_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/SequenceProxyPullConsumer:1.0", + 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':typeID()), + check_tc('CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_is_a('CosNotifyChannelAdmin_SequenceProxyPullConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_is_a('CosNotifyComm_SequencePullConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_SequenceProxyPullSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_SequenceProxyPullSupplier'(doc) -> ["CosNotifyChannelAdmin_SequenceProxyPullSupplier"]; +'CosNotifyChannelAdmin_SequenceProxyPullSupplier'(suite) -> []; +'CosNotifyChannelAdmin_SequenceProxyPullSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(connect_sequence_pull_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc('_get_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc('_set_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc('_get_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc('_set_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(obtain_offered_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(pull_structured_events)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(try_pull_structured_events)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(disconnect_sequence_pull_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/SequenceProxyPullSupplier:1.0", + 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':typeID()), + check_tc('CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_is_a('CosNotifyChannelAdmin_SequenceProxyPullSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_is_a('CosNotifyChannelAdmin_ProxySupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_is_a('CosNotifyComm_SequencePullSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_SequenceProxyPushConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_SequenceProxyPushConsumer'(doc) -> ["CosNotifyChannelAdmin_SequenceProxyPushConsumer"]; +'CosNotifyChannelAdmin_SequenceProxyPushConsumer'(suite) -> []; +'CosNotifyChannelAdmin_SequenceProxyPushConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(connect_sequence_push_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(obtain_subscription_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(push_structured_events)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(disconnect_sequence_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/SequenceProxyPushConsumer:1.0", + 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':typeID()), + check_tc('CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_is_a('CosNotifyChannelAdmin_SequenceProxyPushConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_is_a('CosNotifyComm_SequencePushConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_SequenceProxyPushSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_SequenceProxyPushSupplier'(doc) -> ["CosNotifyChannelAdmin_SequenceProxyPushSupplier"]; +'CosNotifyChannelAdmin_SequenceProxyPushSupplier'(suite) -> []; +'CosNotifyChannelAdmin_SequenceProxyPushSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(connect_sequence_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(suspend_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(resume_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc('_get_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc('_set_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc('_get_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc('_set_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(obtain_offered_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(disconnect_sequence_push_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/SequenceProxyPushSupplier:1.0", + 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':typeID()), + check_tc('CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_is_a('CosNotifyChannelAdmin_SequenceProxyPushSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_is_a('CosNotifyChannelAdmin_ProxySupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_is_a('CosNotifyComm_SequencePushSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_StructuredProxyPullConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_StructuredProxyPullConsumer'(doc) -> ["CosNotifyChannelAdmin_StructuredProxyPullConsumer"]; +'CosNotifyChannelAdmin_StructuredProxyPullConsumer'(suite) -> []; +'CosNotifyChannelAdmin_StructuredProxyPullConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(connect_structured_pull_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(suspend_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(resume_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(obtain_subscription_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(disconnect_structured_pull_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/StructuredProxyPullConsumer:1.0", + 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':typeID()), + check_tc('CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_is_a('CosNotifyChannelAdmin_StructuredProxyPullConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_is_a('CosNotifyComm_StructuredPullConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_StructuredProxyPullSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_StructuredProxyPullSupplier'(doc) -> ["CosNotifyChannelAdmin_StructuredProxyPullSupplier"]; +'CosNotifyChannelAdmin_StructuredProxyPullSupplier'(suite) -> []; +'CosNotifyChannelAdmin_StructuredProxyPullSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(connect_structured_pull_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc('_get_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc('_set_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc('_get_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc('_set_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(obtain_offered_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(pull_structured_event)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(try_pull_structured_event)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(disconnect_structured_pull_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/StructuredProxyPullSupplier:1.0", + 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':typeID()), + check_tc('CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_is_a('CosNotifyChannelAdmin_StructuredProxyPullSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_is_a('CosNotifyChannelAdmin_ProxySupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_is_a('CosNotifyComm_StructuredPullSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_StructuredProxyPushConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_StructuredProxyPushConsumer'(doc) -> ["CosNotifyChannelAdmin_StructuredProxyPushConsumer"]; +'CosNotifyChannelAdmin_StructuredProxyPushConsumer'(suite) -> []; +'CosNotifyChannelAdmin_StructuredProxyPushConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(connect_structured_push_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(obtain_subscription_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(push_structured_event)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(disconnect_structured_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/StructuredProxyPushConsumer:1.0", + 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':typeID()), + check_tc('CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_is_a('CosNotifyChannelAdmin_StructuredProxyPushConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_is_a('CosNotifyChannelAdmin_ProxyConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_is_a('CosNotifyComm_StructuredPushConsumer':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_StructuredProxyPushSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_StructuredProxyPushSupplier'(doc) -> ["CosNotifyChannelAdmin_StructuredProxyPushSupplier"]; +'CosNotifyChannelAdmin_StructuredProxyPushSupplier'(suite) -> []; +'CosNotifyChannelAdmin_StructuredProxyPushSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(connect_structured_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(suspend_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(resume_connection)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc('_get_MyType')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc('_get_MyAdmin')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc('_get_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc('_set_priority_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc('_get_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc('_set_lifetime_filter')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(obtain_offered_types)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(validate_event_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(disconnect_structured_push_supplier)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/StructuredProxyPushSupplier:1.0", + 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':typeID()), + check_tc('CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_is_a('CosNotifyChannelAdmin_StructuredProxyPushSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_is_a('CosNotifyChannelAdmin_ProxySupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_is_a('CosNotifyComm_StructuredPushSupplier':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyChannelAdmin_SupplierAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyChannelAdmin_SupplierAdmin'(doc) -> ["CosNotifyChannelAdmin_SupplierAdmin"]; +'CosNotifyChannelAdmin_SupplierAdmin'(suite) -> []; +'CosNotifyChannelAdmin_SupplierAdmin'(_) -> + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc('_get_MyID')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc('_get_MyChannel')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc('_get_MyOperator')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc('_get_pull_consumers')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc('_get_push_consumers')), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(get_proxy_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(obtain_notification_pull_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(obtain_notification_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(destroy)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(get_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(set_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(validate_qos)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(offer_change)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(remove_all_filters)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(obtain_push_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(obtain_pull_consumer)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(callSeq)), + ?nomatch(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(callAny)), + ?match(undefined, 'CosNotifyChannelAdmin_SupplierAdmin':oe_tc(undefined)), + ?match([_|_], 'CosNotifyChannelAdmin_SupplierAdmin':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyChannelAdmin/SupplierAdmin:1.0", + 'CosNotifyChannelAdmin_SupplierAdmin':typeID()), + check_tc('CosNotifyChannelAdmin_SupplierAdmin':oe_get_interface()), + ?match(true, 'CosNotifyChannelAdmin_SupplierAdmin':oe_is_a('CosNotifyChannelAdmin_SupplierAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SupplierAdmin':oe_is_a('CosNotification_QoSAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SupplierAdmin':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SupplierAdmin':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SupplierAdmin':oe_is_a('CosEventChannelAdmin_SupplierAdmin':typeID())), + ?match(true, 'CosNotifyChannelAdmin_SupplierAdmin':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'CosNotifyChannelAdmin_SupplierAdmin':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_Filter' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_Filter'(doc) -> ["CosNotifyFilter_Filter"]; +'CosNotifyFilter_Filter'(suite) -> []; +'CosNotifyFilter_Filter'(_) -> + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc('_get_constraint_grammar')), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(add_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(modify_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(get_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(get_all_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(remove_all_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(destroy)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(match)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(match_structured)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(match_typed)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(attach_callback)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(detach_callback)), + ?nomatch(undefined, 'CosNotifyFilter_Filter':oe_tc(get_callbacks)), + ?match(undefined, 'CosNotifyFilter_Filter':oe_tc(undefined)), + ?match([_|_], 'CosNotifyFilter_Filter':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyFilter/Filter:1.0", + 'CosNotifyFilter_Filter':typeID()), + check_tc('CosNotifyFilter_Filter':oe_get_interface()), + ?match(true, 'CosNotifyFilter_Filter':oe_is_a('CosNotifyFilter_Filter':typeID())), + ?match(false, 'CosNotifyFilter_Filter':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_FilterAdmin' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_FilterAdmin'(doc) -> ["CosNotifyFilter_FilterAdmin"]; +'CosNotifyFilter_FilterAdmin'(suite) -> []; +'CosNotifyFilter_FilterAdmin'(_) -> + ?nomatch(undefined, 'CosNotifyFilter_FilterAdmin':oe_tc(add_filter)), + ?nomatch(undefined, 'CosNotifyFilter_FilterAdmin':oe_tc(remove_filter)), + ?nomatch(undefined, 'CosNotifyFilter_FilterAdmin':oe_tc(get_filter)), + ?nomatch(undefined, 'CosNotifyFilter_FilterAdmin':oe_tc(get_all_filters)), + ?nomatch(undefined, 'CosNotifyFilter_FilterAdmin':oe_tc(remove_all_filters)), + ?match(undefined, 'CosNotifyFilter_FilterAdmin':oe_tc(undefined)), + ?match([_|_], 'CosNotifyFilter_FilterAdmin':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyFilter/FilterAdmin:1.0", + 'CosNotifyFilter_FilterAdmin':typeID()), + check_tc('CosNotifyFilter_FilterAdmin':oe_get_interface()), + ?match(true, 'CosNotifyFilter_FilterAdmin':oe_is_a('CosNotifyFilter_FilterAdmin':typeID())), + ?match(false, 'CosNotifyFilter_FilterAdmin':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_FilterFactory' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_FilterFactory'(doc) -> ["CosNotifyFilter_FilterFactory"]; +'CosNotifyFilter_FilterFactory'(suite) -> []; +'CosNotifyFilter_FilterFactory'(_) -> + ?nomatch(undefined, 'CosNotifyFilter_FilterFactory':oe_tc(create_filter)), + ?nomatch(undefined, 'CosNotifyFilter_FilterFactory':oe_tc(create_mapping_filter)), + ?match(undefined, 'CosNotifyFilter_FilterFactory':oe_tc(undefined)), + ?match([_|_], 'CosNotifyFilter_FilterFactory':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyFilter/FilterFactory:1.0", + 'CosNotifyFilter_FilterFactory':typeID()), + check_tc('CosNotifyFilter_FilterFactory':oe_get_interface()), + ?match(true, 'CosNotifyFilter_FilterFactory':oe_is_a('CosNotifyFilter_FilterFactory':typeID())), + ?match(false, 'CosNotifyFilter_FilterFactory':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyFilter_MappingFilter' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyFilter_MappingFilter'(doc) -> ["CosNotifyFilter_MappingFilter"]; +'CosNotifyFilter_MappingFilter'(suite) -> []; +'CosNotifyFilter_MappingFilter'(_) -> + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc('_get_constraint_grammar')), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc('_get_value_type')), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc('_get_default_value')), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(add_mapping_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(modify_mapping_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(get_mapping_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(get_all_mapping_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(remove_all_mapping_constraints)), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(destroy)), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(match)), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(match_structured)), + ?nomatch(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(match_typed)), + ?match(undefined, 'CosNotifyFilter_MappingFilter':oe_tc(undefined)), + ?match([_|_], 'CosNotifyFilter_MappingFilter':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyFilter/MappingFilter:1.0", + 'CosNotifyFilter_MappingFilter':typeID()), + check_tc('CosNotifyFilter_MappingFilter':oe_get_interface()), + ?match(true, 'CosNotifyFilter_MappingFilter':oe_is_a('CosNotifyFilter_MappingFilter':typeID())), + ?match(false, 'CosNotifyFilter_MappingFilter':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_NotifyPublish' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_NotifyPublish'(doc) -> ["CosNotifyComm_NotifyPublish"]; +'CosNotifyComm_NotifyPublish'(suite) -> []; +'CosNotifyComm_NotifyPublish'(_) -> + ?nomatch(undefined, 'CosNotifyComm_NotifyPublish':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyComm_NotifyPublish':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_NotifyPublish':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/NotifyPublish:1.0", + 'CosNotifyComm_NotifyPublish':typeID()), + check_tc('CosNotifyComm_NotifyPublish':oe_get_interface()), + ?match(true, 'CosNotifyComm_NotifyPublish':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyComm_NotifyPublish':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_NotifySubscribe' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_NotifySubscribe'(doc) -> ["CosNotifyComm_NotifySubscribe"]; +'CosNotifyComm_NotifySubscribe'(suite) -> []; +'CosNotifyComm_NotifySubscribe'(_) -> + ?nomatch(undefined, 'CosNotifyComm_NotifySubscribe':oe_tc(subscription_change)), + ?match(undefined, 'CosNotifyComm_NotifySubscribe':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_NotifySubscribe':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/NotifySubscribe:1.0", + 'CosNotifyComm_NotifySubscribe':typeID()), + check_tc('CosNotifyComm_NotifySubscribe':oe_get_interface()), + ?match(true, 'CosNotifyComm_NotifySubscribe':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(false, 'CosNotifyComm_NotifySubscribe':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_PullConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_PullConsumer'(doc) -> ["CosNotifyComm_PullConsumer"]; +'CosNotifyComm_PullConsumer'(suite) -> []; +'CosNotifyComm_PullConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyComm_PullConsumer':oe_tc(offer_change)), + ?nomatch(undefined, 'CosNotifyComm_PullConsumer':oe_tc(disconnect_pull_consumer)), + ?match(undefined, 'CosNotifyComm_PullConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_PullConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/PullConsumer:1.0", + 'CosNotifyComm_PullConsumer':typeID()), + check_tc('CosNotifyComm_PullConsumer':oe_get_interface()), + ?match(true, 'CosNotifyComm_PullConsumer':oe_is_a('CosNotifyComm_PullConsumer':typeID())), + ?match(true, 'CosNotifyComm_PullConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(true, 'CosNotifyComm_PullConsumer':oe_is_a('CosEventComm_PullConsumer':typeID())), + ?match(false, 'CosNotifyComm_PullConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_PullSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_PullSupplier'(doc) -> ["CosNotifyComm_PullSupplier"]; +'CosNotifyComm_PullSupplier'(suite) -> []; +'CosNotifyComm_PullSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyComm_PullSupplier':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyComm_PullSupplier':oe_tc(pull)), + ?nomatch(undefined, 'CosNotifyComm_PullSupplier':oe_tc(try_pull)), + ?nomatch(undefined, 'CosNotifyComm_PullSupplier':oe_tc(disconnect_pull_supplier)), + ?match(undefined, 'CosNotifyComm_PullSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_PullSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/PullSupplier:1.0", + 'CosNotifyComm_PullSupplier':typeID()), + check_tc('CosNotifyComm_PullSupplier':oe_get_interface()), + ?match(true, 'CosNotifyComm_PullSupplier':oe_is_a('CosNotifyComm_PullSupplier':typeID())), + ?match(true, 'CosNotifyComm_PullSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyComm_PullSupplier':oe_is_a('CosEventComm_PullSupplier':typeID())), + ?match(false, 'CosNotifyComm_PullSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_PushConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_PushConsumer'(doc) -> ["CosNotifyComm_PushConsumer"]; +'CosNotifyComm_PushConsumer'(suite) -> []; +'CosNotifyComm_PushConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyComm_PushConsumer':oe_tc(offer_change)), + ?nomatch(undefined, 'CosNotifyComm_PushConsumer':oe_tc(push)), + ?nomatch(undefined, 'CosNotifyComm_PushConsumer':oe_tc(disconnect_push_consumer)), + ?match(undefined, 'CosNotifyComm_PushConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_PushConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/PushConsumer:1.0", + 'CosNotifyComm_PushConsumer':typeID()), + check_tc('CosNotifyComm_PushConsumer':oe_get_interface()), + ?match(true, 'CosNotifyComm_PushConsumer':oe_is_a('CosNotifyComm_PushConsumer':typeID())), + ?match(true, 'CosNotifyComm_PushConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(true, 'CosNotifyComm_PushConsumer':oe_is_a('CosEventComm_PushConsumer':typeID())), + ?match(false, 'CosNotifyComm_PushConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_PushSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_PushSupplier'(doc) -> ["CosNotifyComm_PushSupplier"]; +'CosNotifyComm_PushSupplier'(suite) -> []; +'CosNotifyComm_PushSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyComm_PushSupplier':oe_tc(subscription_change)), + ?nomatch(undefined, 'CosNotifyComm_PushSupplier':oe_tc(disconnect_push_supplier)), + ?match(undefined, 'CosNotifyComm_PushSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_PushSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/PushSupplier:1.0", + 'CosNotifyComm_PushSupplier':typeID()), + check_tc('CosNotifyComm_PushSupplier':oe_get_interface()), + ?match(true, 'CosNotifyComm_PushSupplier':oe_is_a('CosNotifyComm_PushSupplier':typeID())), + ?match(true, 'CosNotifyComm_PushSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(true, 'CosNotifyComm_PushSupplier':oe_is_a('CosEventComm_PushSupplier':typeID())), + ?match(false, 'CosNotifyComm_PushSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_SequencePullConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_SequencePullConsumer'(doc) -> ["CosNotifyComm_SequencePullConsumer"]; +'CosNotifyComm_SequencePullConsumer'(suite) -> []; +'CosNotifyComm_SequencePullConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyComm_SequencePullConsumer':oe_tc(disconnect_sequence_pull_consumer)), + ?nomatch(undefined, 'CosNotifyComm_SequencePullConsumer':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyComm_SequencePullConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_SequencePullConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/SequencePullConsumer:1.0", + 'CosNotifyComm_SequencePullConsumer':typeID()), + check_tc('CosNotifyComm_SequencePullConsumer':oe_get_interface()), + ?match(true, 'CosNotifyComm_SequencePullConsumer':oe_is_a('CosNotifyComm_SequencePullConsumer':typeID())), + ?match(true, 'CosNotifyComm_SequencePullConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyComm_SequencePullConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_SequencePullSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_SequencePullSupplier'(doc) -> ["CosNotifyComm_SequencePullSupplier"]; +'CosNotifyComm_SequencePullSupplier'(suite) -> []; +'CosNotifyComm_SequencePullSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyComm_SequencePullSupplier':oe_tc(pull_structured_events)), + ?nomatch(undefined, 'CosNotifyComm_SequencePullSupplier':oe_tc(try_pull_structured_events)), + ?nomatch(undefined, 'CosNotifyComm_SequencePullSupplier':oe_tc(disconnect_sequence_pull_supplier)), + ?nomatch(undefined, 'CosNotifyComm_SequencePullSupplier':oe_tc(subscription_change)), + ?match(undefined, 'CosNotifyComm_SequencePullSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_SequencePullSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/SequencePullSupplier:1.0", + 'CosNotifyComm_SequencePullSupplier':typeID()), + check_tc('CosNotifyComm_SequencePullSupplier':oe_get_interface()), + ?match(true, 'CosNotifyComm_SequencePullSupplier':oe_is_a('CosNotifyComm_SequencePullSupplier':typeID())), + ?match(true, 'CosNotifyComm_SequencePullSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(false, 'CosNotifyComm_SequencePullSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_SequencePushConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_SequencePushConsumer'(doc) -> ["CosNotifyComm_SequencePushConsumer"]; +'CosNotifyComm_SequencePushConsumer'(suite) -> []; +'CosNotifyComm_SequencePushConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyComm_SequencePushConsumer':oe_tc(push_structured_events)), + ?nomatch(undefined, 'CosNotifyComm_SequencePushConsumer':oe_tc(disconnect_sequence_push_consumer)), + ?nomatch(undefined, 'CosNotifyComm_SequencePushConsumer':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyComm_SequencePushConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_SequencePushConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/SequencePushConsumer:1.0", + 'CosNotifyComm_SequencePushConsumer':typeID()), + check_tc('CosNotifyComm_SequencePushConsumer':oe_get_interface()), + ?match(true, 'CosNotifyComm_SequencePushConsumer':oe_is_a('CosNotifyComm_SequencePushConsumer':typeID())), + ?match(true, 'CosNotifyComm_SequencePushConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyComm_SequencePushConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_SequencePushSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_SequencePushSupplier'(doc) -> ["CosNotifyComm_SequencePushSupplier"]; +'CosNotifyComm_SequencePushSupplier'(suite) -> []; +'CosNotifyComm_SequencePushSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyComm_SequencePushSupplier':oe_tc(disconnect_sequence_push_supplier)), + ?nomatch(undefined, 'CosNotifyComm_SequencePushSupplier':oe_tc(subscription_change)), + ?match(undefined, 'CosNotifyComm_SequencePushSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_SequencePushSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/SequencePushSupplier:1.0", + 'CosNotifyComm_SequencePushSupplier':typeID()), + check_tc('CosNotifyComm_SequencePushSupplier':oe_get_interface()), + ?match(true, 'CosNotifyComm_SequencePushSupplier':oe_is_a('CosNotifyComm_SequencePushSupplier':typeID())), + ?match(true, 'CosNotifyComm_SequencePushSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(false, 'CosNotifyComm_SequencePushSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_StructuredPullConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_StructuredPullConsumer'(doc) -> ["CosNotifyComm_StructuredPullConsumer"]; +'CosNotifyComm_StructuredPullConsumer'(suite) -> []; +'CosNotifyComm_StructuredPullConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyComm_StructuredPullConsumer':oe_tc(disconnect_structured_pull_consumer)), + ?nomatch(undefined, 'CosNotifyComm_StructuredPullConsumer':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyComm_StructuredPullConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_StructuredPullConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/StructuredPullConsumer:1.0", + 'CosNotifyComm_StructuredPullConsumer':typeID()), + check_tc('CosNotifyComm_StructuredPullConsumer':oe_get_interface()), + ?match(true, 'CosNotifyComm_StructuredPullConsumer':oe_is_a('CosNotifyComm_StructuredPullConsumer':typeID())), + ?match(true, 'CosNotifyComm_StructuredPullConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyComm_StructuredPullConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_StructuredPullSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_StructuredPullSupplier'(doc) -> ["CosNotifyComm_StructuredPullSupplier"]; +'CosNotifyComm_StructuredPullSupplier'(suite) -> []; +'CosNotifyComm_StructuredPullSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyComm_StructuredPullSupplier':oe_tc(pull_structured_event)), + ?nomatch(undefined, 'CosNotifyComm_StructuredPullSupplier':oe_tc(try_pull_structured_event)), + ?nomatch(undefined, 'CosNotifyComm_StructuredPullSupplier':oe_tc(disconnect_structured_pull_supplier)), + ?nomatch(undefined, 'CosNotifyComm_StructuredPullSupplier':oe_tc(subscription_change)), + ?match(undefined, 'CosNotifyComm_StructuredPullSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_StructuredPullSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/StructuredPullSupplier:1.0", + 'CosNotifyComm_StructuredPullSupplier':typeID()), + check_tc('CosNotifyComm_StructuredPullSupplier':oe_get_interface()), + ?match(true, 'CosNotifyComm_StructuredPullSupplier':oe_is_a('CosNotifyComm_StructuredPullSupplier':typeID())), + ?match(true, 'CosNotifyComm_StructuredPullSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(false, 'CosNotifyComm_StructuredPullSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_StructuredPushConsumer' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_StructuredPushConsumer'(doc) -> ["CosNotifyComm_StructuredPushConsumer"]; +'CosNotifyComm_StructuredPushConsumer'(suite) -> []; +'CosNotifyComm_StructuredPushConsumer'(_) -> + ?nomatch(undefined, 'CosNotifyComm_StructuredPushConsumer':oe_tc(push_structured_event)), + ?nomatch(undefined, 'CosNotifyComm_StructuredPushConsumer':oe_tc(disconnect_structured_push_consumer)), + ?nomatch(undefined, 'CosNotifyComm_StructuredPushConsumer':oe_tc(offer_change)), + ?match(undefined, 'CosNotifyComm_StructuredPushConsumer':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_StructuredPushConsumer':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/StructuredPushConsumer:1.0", + 'CosNotifyComm_StructuredPushConsumer':typeID()), + check_tc('CosNotifyComm_StructuredPushConsumer':oe_get_interface()), + ?match(true, 'CosNotifyComm_StructuredPushConsumer':oe_is_a('CosNotifyComm_StructuredPushConsumer':typeID())), + ?match(true, 'CosNotifyComm_StructuredPushConsumer':oe_is_a('CosNotifyComm_NotifyPublish':typeID())), + ?match(false, 'CosNotifyComm_StructuredPushConsumer':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNotifyComm_StructuredPushSupplier' +%% Description: +%%----------------------------------------------------------------- +'CosNotifyComm_StructuredPushSupplier'(doc) -> ["CosNotifyComm_StructuredPushSupplier"]; +'CosNotifyComm_StructuredPushSupplier'(suite) -> []; +'CosNotifyComm_StructuredPushSupplier'(_) -> + ?nomatch(undefined, 'CosNotifyComm_StructuredPushSupplier':oe_tc(disconnect_structured_push_supplier)), + ?nomatch(undefined, 'CosNotifyComm_StructuredPushSupplier':oe_tc(subscription_change)), + ?match(undefined, 'CosNotifyComm_StructuredPushSupplier':oe_tc(undefined)), + ?match([_|_], 'CosNotifyComm_StructuredPushSupplier':oe_get_interface()), + ?match("IDL:omg.org/CosNotifyComm/StructuredPushSupplier:1.0", + 'CosNotifyComm_StructuredPushSupplier':typeID()), + check_tc('CosNotifyComm_StructuredPushSupplier':oe_get_interface()), + ?match(true, 'CosNotifyComm_StructuredPushSupplier':oe_is_a('CosNotifyComm_StructuredPushSupplier':typeID())), + ?match(true, 'CosNotifyComm_StructuredPushSupplier':oe_is_a('CosNotifyComm_NotifySubscribe':typeID())), + ?match(false, 'CosNotifyComm_StructuredPushSupplier':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'oe_CosNotificationComm_Event' +%% Description: +%%----------------------------------------------------------------- +'oe_CosNotificationComm_Event'(doc) -> ["oe_CosNotificationComm_Event"]; +'oe_CosNotificationComm_Event'(suite) -> []; +'oe_CosNotificationComm_Event'(_) -> + ?nomatch(undefined, 'oe_CosNotificationComm_Event':oe_tc(callSeq)), + ?nomatch(undefined, 'oe_CosNotificationComm_Event':oe_tc(callAny)), + ?match(undefined, 'oe_CosNotificationComm_Event':oe_tc(undefined)), + ?match([_|_], 'oe_CosNotificationComm_Event':oe_get_interface()), + ?match("IDL:oe_CosNotificationComm/Event:1.0", + 'oe_CosNotificationComm_Event':typeID()), + check_tc('oe_CosNotificationComm_Event':oe_get_interface()), + ?match(true, 'oe_CosNotificationComm_Event':oe_is_a('oe_CosNotificationComm_Event':typeID())), + ?match(false, 'oe_CosNotificationComm_Event':oe_is_a("wrong")), + ok. + + + + +%%----------------------------------------------------------------- +%% MISC functions +%%----------------------------------------------------------------- +check_tc([]) -> + ok; +check_tc([{Op, {RetType, InParameters, OutParameters}}|T]) -> + io:format("checked - ~s~n", [Op]), + lists:all(?checktc(Op), [RetType|InParameters]), + lists:all(?checktc(Op), OutParameters), + check_tc(T). + + diff --git a/lib/cosNotification/test/grammar_SUITE.erl b/lib/cosNotification/test/grammar_SUITE.erl new file mode 100644 index 0000000000..30aec89e5f --- /dev/null +++ b/lib/cosNotification/test/grammar_SUITE.erl @@ -0,0 +1,1094 @@ +%%-------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%-------------------------------------------------------------------- +%% File : grammar_SUITE.erl +%% Purpose : Testing the CosNotification BNF grammar. +%%-------------------------------------------------------------------- + +-module(grammar_SUITE). + + + +%%--------------- INCLUDES ----------------------------------- +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/include/ifr_types.hrl"). +%% cosEvent files. +-include_lib("cosEvent/include/CosEventChannelAdmin.hrl"). +%% Application files +-include_lib("cosNotification/include/CosNotification.hrl"). +-include_lib("cosNotification/include/CosNotifyChannelAdmin.hrl"). +-include_lib("cosNotification/include/CosNotifyComm.hrl"). +-include_lib("cosNotification/include/CosNotifyFilter.hrl"). + +-include_lib("cosNotification/src/CosNotification_Definitions.hrl"). + +-include("idl_output/notify_test.hrl"). + +-include("test_server.hrl"). + +%%--------------- DEFINES ------------------------------------ +-define(default_timeout, ?t:minutes(20)). +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, + union_api/1, enum_api/1, simple_types_api/1, + components_api/1, positional_api/1, variable_api/1, + init_per_testcase/2, fin_per_testcase/2]). + +-import(cosNotification_Filter, [create_filter/1, eval/2]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for the cosNotification interfaces", ""]; +all(suite) -> {req, + [], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [variable_api, union_api, enum_api, simple_types_api, components_api, + positional_api]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Config. + + +%%----------------------------------------------------------------- +%% simple types grammar tests +%%----------------------------------------------------------------- +simple_types_api(doc) -> ["CosNotification simple types grammar tests", ""]; +simple_types_api(suite) -> []; +simple_types_api(_Config) -> + %% Will always be true, no matter what kind of event we receive. + {ok,T1} = ?match({ok, _}, create_filter("2==2 and 3<4")), + ?match(true, eval(T1, ?not_CreateSE("DomainName","TypeName","EventName", + [],[], any:create(orber_tc:null(), null)))), + + %% Will always be true, no matter what kind of event we receive. + {ok,T2} = ?match({ok, _}, create_filter("")), + ?match(true, eval(T2, ?not_CreateSE("DomainName","TypeName","EventName", + [],[], any:create(orber_tc:null(), null)))), + + %% Check if $variable works + {ok,T3} = ?match({ok, _}, create_filter("$city == \'Berlin\'")), + ?match(true, eval(T3, ?not_CreateSE("DomainName","TypeName","EventName", + [#'CosNotification_Property'{name="city", + value=any:create(orber_tc:string(0), "Berlin")}], + [], any:create(orber_tc:null(), null)))), + ?match(false, eval(T3, ?not_CreateSE("DomainName","TypeName", "EventName", + [#'CosNotification_Property'{name="city", + value=any:create(orber_tc:string(0), "Dallas")}], + + [], any:create(orber_tc:null(), null)))), + + + {ok,T4} = ?match({ok, _}, create_filter("$zip == 44")), + ?match(true, eval(T4, ?not_CreateSE("DomainName","TypeName", "EventName", + [#'CosNotification_Property'{name="zip", + value=any:create(orber_tc:short(), 44)}], + + [], any:create(orber_tc:null(), null)))), + ?match(true, eval(T4, ?not_CreateSE("DomainName","TypeName", "EventName", + [],[], + any:create('CosNotification_Property':tc(), + #'CosNotification_Property' + {name="zip", + value=any:create(orber_tc:short(), + 44)})))), + ?match(false, eval(T4, ?not_CreateSE("DomainName","TypeName", "EventName", + [#'CosNotification_Property'{name="zip", + value=any:create(orber_tc:short(), 33)}], + + [], any:create(orber_tc:null(), null)))), + + %% Will always be true, no matter what kind of event we receive. + {ok,T5} = ?match({ok, _}, create_filter("\'oo'\~\'foobar\'")), + ?match(true, eval(T5, ?not_CreateSE("DomainName","TypeName","EventName", + [],[], any:create(orber_tc:null(), null)))), + %% Will always be false, no matter what kind of event we receive. + {ok,T6} = ?match({ok, _}, create_filter("\'o1'\~\'foobar\'")), + ?match(false, eval(T6, ?not_CreateSE("DomainName","TypeName","EventName", + [],[], any:create(orber_tc:null(), null)))), + + %% Can we apply the ~ operation as above using a variable + {ok,T7} = ?match({ok, _}, create_filter("$str~\'foobar\'")), + ?match(true, eval(T7, ?not_CreateSE("DomainName","TypeName","EventName", + [#'CosNotification_Property'{name="str", + value=any:create(orber_tc:string(0), "oo")}], + [], any:create(orber_tc:null(), null)))), + ?match(false, eval(T7, ?not_CreateSE("DomainName","TypeName","EventName", + [#'CosNotification_Property'{name="str", + value=any:create(orber_tc:string(0), "ok")}], + [], any:create(orber_tc:null(), null)))), + + + + {ok,_T8} = ?match({ok, _}, create_filter("$\\zip == 44444")), + + ok. + +%%----------------------------------------------------------------- +%% enum grammar tests +%%----------------------------------------------------------------- +enum_api(doc) -> ["CosNotification enum grammar tests", ""]; +enum_api(suite) -> []; +enum_api(_Config) -> + %% Accept events whose 'in' enum is set to the value 'HOUSE' or 'CAR'. + {ok,T1} = ?match({ok, _}, create_filter("$.\\in == HOUSE or $.\\in == CAR")), + + ?match(true, eval(T1, any:create(orber_tc:alias("IFRId","in",tk_any), + any:create({tk_enum, "IFRId", "in", ["HOUSE", "CAR"]}, + 'HOUSE')))), + ?match(false, eval(T1, any:create(orber_tc:alias("IFRId","in",tk_any), + any:create({tk_enum, "IFRId", "in", ["HOUSE", "CAR"]}, + 'GARAGE')))), + ok. + + +%%----------------------------------------------------------------- +%% Union grammar tests +%%----------------------------------------------------------------- +union_api(doc) -> ["CosNotification union grammar tests", ""]; +union_api(suite) -> []; +union_api(_Config) -> + {ok,T1} = ?match({ok, _}, create_filter("exist $.uni1._d and $.uni1._d == 1 and $.uni1.(1) == 10")), + {ok,T2} = ?match({ok, _}, create_filter("default $.uni1._d and $.uni1.() == 10")), + {ok,T3} = ?match({ok, _}, create_filter("default $.uni1._d and $.uni1.(999) == 10")), + ?match(true, eval(T1, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(orber_tc:alias("IDL:notify_test/namedAny:1.0", + "uni1", + tk_any), + any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 1, + value=10}))))), + ?match(true, eval(T2, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(orber_tc:alias("IDL:notify_test/namedAny:1.0", + "uni1", + tk_any), + any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 100, + value=10}))))), + ?match(true, eval(T3, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(orber_tc:alias("IDL:notify_test/namedAny:1.0", + "uni1", + tk_any), + any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 100, + value=10}))))), + ?match(true, eval(T1, any:create(orber_tc:alias("IDL:notify_test/namedAny:1.0", + "uni1", + tk_any), + any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 1, + value=10})))), + ?match(false, eval(T2, any:create(orber_tc:alias("IDL:notify_test/namedAny:1.0", + "uni1", + tk_any), + any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 1, + value=10})))), + ?match(false, eval(T3, any:create(orber_tc:alias("IDL:notify_test/namedAny:1.0", + "uni1", + tk_any), + any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 1, + value=10})))), + ?match(true, eval(T1, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(notify_test_studies:tc(), #notify_test_studies + {uni1 = #notify_test_uni1{label= 1, value=10}, + gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 60)}], + monthly_attendance = {0,1,2,10}})))), + ?match(false, eval(T2, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(notify_test_studies:tc(), #notify_test_studies + {uni1 = #notify_test_uni1{label= 1, value=10}, + gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 60)}], + monthly_attendance = {0,1,2,10}})))), + ?match(false, eval(T3, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(notify_test_studies:tc(), #notify_test_studies + {uni1 = #notify_test_uni1{label= 1, value=10}, + gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 60)}], + monthly_attendance = {0,1,2,10}})))), + ?match(true, eval(T1, any:create(notify_test_studies:tc(), #notify_test_studies + {uni1 = #notify_test_uni1{label= 1, value=10}, + gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 60)}], + monthly_attendance = {0,1,2,10}}))), + ?match(false, eval(T2, any:create(notify_test_studies:tc(), #notify_test_studies + {uni1 = #notify_test_uni1{label= 1, value=10}, + gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 60)}], + monthly_attendance = {0,1,2,10}}))), + ?match(false, eval(T3, any:create(notify_test_studies:tc(), #notify_test_studies + {uni1 = #notify_test_uni1{label= 1, value=10}, + gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 60)}], + monthly_attendance = {0,1,2,10}}))), + + {ok,T4} = ?match({ok, _}, create_filter("exist $.alias.uni1._d and $.alias.uni1._d == 1 and $.alias.uni1.(1) == 10")), + ?match(true, eval(T4, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(orber_tc:alias(notify_test_studies:id(), + "alias", + notify_test_studies:tc()), + #notify_test_studies + {uni1 = #notify_test_uni1{label= 1, value=10}, + gpa = 90, tests = [], + monthly_attendance = {0,1,2,10}})))), + ?match(true, eval(T4, any:create(orber_tc:alias(notify_test_studies:id(), + "alias", + notify_test_studies:tc()), + #notify_test_studies + {uni1 = #notify_test_uni1{label= 1, value=10}, + gpa = 90, tests = [], + monthly_attendance = {0,1,2,10}}))), + %% Accept events with a default union discriminator set to the value 2. + {ok,T5} = ?match({ok, _}, create_filter("default $._d and $.defvalue == 2")), + ?match(true, eval(T5, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 100, value=2}))), + %% label not default. + ?match(false, eval(T5, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 2, value=2}))), + %% Default does not exist (nor the component defvalue) + ?match(false, eval(T5, any:create(notify_test_uni2:tc(), + #notify_test_uni2{label= 100, value=2}))), + %% Both wrong + ?match(false, eval(T5, any:create(notify_test_uni2:tc(), + #notify_test_uni2{label= 2, value=2}))), + + {ok,T6} = ?match({ok, _}, create_filter("default $._d and $.(-8) == 2")), + ?match(true, eval(T6, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 100, value=2}))), + %% label not default. + ?match(false, eval(T6, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 2, value=2}))), + %% Default does not exist (nor the component defvalue) + ?match(false, eval(T6, any:create(notify_test_uni2:tc(), + #notify_test_uni2{label= 100, value=2}))), + %% Both wrong + ?match(false, eval(T6, any:create(notify_test_uni2:tc(), + #notify_test_uni2{label= 2, value=2}))), + %% the same as the above, but we try to access a label that is not default + {ok,T7} = ?match({ok, _}, create_filter("default $._d and $.(2) == 2")), + ?match({error, _}, eval(T7, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 100, value=2}))), + + %% Must be a default-union with its 'defvalue' set to 2. + {ok,T8} = ?match({ok, _}, create_filter("default $._d and $.('defvalue') == 2")), + ?match(true, eval(T8, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 100, value=2}))), + %% label not default. + ?match(false, eval(T8, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 2, value=2}))), + %% Default does not exist (nor the component defvalue) + ?match(false, eval(T8, any:create(notify_test_uni2:tc(), + #notify_test_uni2{label= 100, value=2}))), + %% Both wrong + ?match(false, eval(T8, any:create(notify_test_uni2:tc(), + #notify_test_uni2{label= 2, value=2}))), + + %% Must be a default-union with its value set to 2. + {ok,T9} = ?match({ok, _}, create_filter("default $._d and $.(+100) == 2")), + ?match(true, eval(T9, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 100, value=2}))), + %% label not default. + ?match(false, eval(T9, any:create(notify_test_uni1:tc(), + #notify_test_uni1{label= 2, value=2}))), + %% Default does not exist (nor the component defvalue) + ?match(false, eval(T9, any:create(notify_test_uni2:tc(), + #notify_test_uni2{label= 100, value=2}))), + %% Both wrong + ?match(false, eval(T9, any:create(notify_test_uni2:tc(), + #notify_test_uni2{label= 2, value=2}))), + + %% So far, we have only tested to access the union itself. No will use more + %% complex union members. + %% T10 and T11 is "equal" + {ok,T10} = ?match({ok, _}, create_filter("$.M < 54")), + {ok,T11} = ?match({ok, _}, create_filter("$.(5) < 54")), + ?match(false, eval(T10, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value=54}))), + ?match(false, eval(T11, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value=54}))), + ?match(true, eval(T10, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value=50}))), + ?match(true, eval(T11, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value=50}))), + ?match({error,_}, eval(T10, any:create(notify_test_K:tc(), + #notify_test_K{label= -1, value=50}))), + ?match({error,_}, eval(T11, any:create(notify_test_K:tc(), + #notify_test_K{label= -1, value=50}))), + + %% T12 and T13 is "equal" + {ok,T12} = ?match({ok, _}, create_filter("$.L.C < 128")), + {ok,T13} = ?match({ok, _}, create_filter("$.(3).2 < 128")), + ?match(true, eval(T12, any:create(notify_test_K:tc(), + #notify_test_K{label= 3, value= + #notify_test_X{'A' = 1, + 'B' = "string", + 'C' = 120}}))), + ?match(true, eval(T13, any:create(notify_test_K:tc(), + #notify_test_K{label= 3, value= + #notify_test_X{'A' = 1, + 'B' = "string", + 'C' = 120}}))), + ?match(false, eval(T12, any:create(notify_test_K:tc(), + #notify_test_K{label= 3, value= + #notify_test_X{'A' = 1, + 'B' = "string", + 'C' = 200}}))), + ?match(false, eval(T13, any:create(notify_test_K:tc(), + #notify_test_K{label= 3, value= + #notify_test_X{'A' = 1, + 'B' = "string", + 'C' = 200}}))), + + %% Test if 'putty' is a substring of K + {ok,T15} = ?match({ok, _}, create_filter("'putty' ~ $.(2)")), + {ok,T16} = ?match({ok, _}, create_filter("'putty' ~ $.K")), + ?match(true, eval(T15, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "isputtyok"}))), + ?match(true, eval(T16, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "isputtyok"}))), + ?match(false, eval(T15, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "notputtok"}))), + ?match(false, eval(T16, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "notputtok"}))), + + {ok,_T17} = ?match({ok, _}, create_filter("'putty' ~ $.(3).1")), + {ok,_T18} = ?match({ok, _}, create_filter("'putty' ~ $.L.B")), + ?match(true, eval(T12, any:create(notify_test_K:tc(), + #notify_test_K{label= 3, value= + #notify_test_X{'A' = 1, + 'B' = "isputtyok", + 'C' = 120}}))), + ?match(true, eval(T13, any:create(notify_test_K:tc(), + #notify_test_K{label= 3, value= + #notify_test_X{'A' = 1, + 'B' = "isputtyok", + 'C' = 120}}))), + ?match(false, eval(T12, any:create(notify_test_K:tc(), + #notify_test_K{label= 3, value= + #notify_test_X{'A' = 1, + 'B' = "notputtok", + 'C' = 200}}))), + ?match(false, eval(T13, any:create(notify_test_K:tc(), + #notify_test_K{label= 3, value= + #notify_test_X{'A' = 1, + 'B' = "notputtok", + 'C' = 200}}))), + + %% Please observe that the switch 0 and 2 is defined to be equivalent. + {ok,T19} = ?match({ok, _}, create_filter("$._d == 2 and $.(0) != 'hoob'")), + {ok,T20} = ?match({ok, _}, create_filter("$._d == 2 and $.(2) != 'hoob'")), + ?match(true, eval(T19, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "nothoob"}))), + ?match(true, eval(T20, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "nothoob"}))), + ?match(false, eval(T19, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "hoob"}))), + ?match(false, eval(T20, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "hoob"}))), + + ?match(false, eval(T19, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value= 55}))), + ?match(false, eval(T20, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value= 55}))), + + ?match(false, eval(T19, any:create(notify_test_K:tc(), + #notify_test_K{label= 100, value= "nothoob"}))), + ?match(false, eval(T20, any:create(notify_test_K:tc(), + #notify_test_K{label= 100, value= "nothoob"}))), + + {ok,T21} = ?match({ok, _}, create_filter("exist $.K")), + {ok,T22} = ?match({ok, _}, create_filter("exist $.(0) or exist $.(2)")), + ?match(true, eval(T21, any:create(notify_test_K:tc(), + #notify_test_K{label= 0, value= "hoob"}))), + ?match(true, eval(T22, any:create(notify_test_K:tc(), + #notify_test_K{label= 0, value= "hoob"}))), + ?match(true, eval(T21, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "hoob"}))), + ?match(true, eval(T22, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "hoob"}))), + ?match(false, eval(T21, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value= 55}))), + ?match(false, eval(T22, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value= 55}))), + + + %% Please observe that the switch 0 and 2 is defined to be equivalent. + {ok,T23} = ?match({ok, _}, create_filter("exist $.(2)")), + {ok,T24} = ?match({ok, _}, create_filter("exist $.(0)")), + ?match(true, eval(T23, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "hoob"}))), + ?match(false, eval(T24, any:create(notify_test_K:tc(), + #notify_test_K{label= 2, value= "hoob"}))), + ?match(false, eval(T23, any:create(notify_test_K:tc(), + #notify_test_K{label= 0, value= "hoob"}))), + ?match(true, eval(T24, any:create(notify_test_K:tc(), + #notify_test_K{label= 0, value= "hoob"}))), + ?match(false, eval(T23, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value= 55}))), + ?match(false, eval(T24, any:create(notify_test_K:tc(), + #notify_test_K{label= 5, value= 55}))), + + ok. + +%%----------------------------------------------------------------- +%% Variables grammar tests +%%----------------------------------------------------------------- +variable_api(doc) -> ["CosNotification variables grammar tests", ""]; +variable_api(suite) -> []; +variable_api(_Config) -> + %% Accept all "CommunicationsAlarm" events + {ok,T0} = ?match({ok, _}, create_filter("$type_name == 'CommunicationsAlarm'")), + + ?match(true, eval(T0, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(orber_tc:null(), null)))), + ?match(false, eval(T0, ?not_CreateSE("DomainName","CommunicationsOK", + "EventName", [],[], + any:create(orber_tc:null(), null)))), + ?match(true, eval(T0, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName", [],[], + any:create(orber_tc:alias("IFRId", "type_name", + orber_tc:string(0)), + "CommunicationsOK")))), + + ?match(true, eval(T0, any:create(orber_tc:alias("IFRId", "type_name", + orber_tc:string(0)), + "CommunicationsAlarm"))), + ?match(false, eval(T0, any:create(orber_tc:alias("IFRId", "type_name", + orber_tc:string(0)), + "CommunicationsOK"))), + + + %% Accept all "CommunicationsAlarm" events but no "lost_packet" messages. + {ok,T1} = ?match({ok, _}, create_filter("$type_name == 'CommunicationsAlarm' and not ($event_name == 'lost_packet')")), + + ?match(true, eval(T1, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName",[],[], + any:create(orber_tc:null(), null)))), + ?match(false, eval(T1, ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", [],[], + any:create(orber_tc:null(), null)))), + ?match(true, + eval(T1, any:create(orber_tc:sequence('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="type_name", + value=any:create(orber_tc:string(0), "CommunicationsAlarm")}, + #'CosNotification_Property'{name="event_name", + value=any:create(orber_tc:string(0), "EventName")}]))), + ?match(false, + eval(T1, any:create(orber_tc:sequence('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="type_name", + value=any:create(orber_tc:string(0), "CommunicationsAlarm")}, + #'CosNotification_Property'{name="event_name", + value=any:create(orber_tc:string(0), "lost_packet")}]))), + + + %% Accept "CommunicationsAlarm" events with priorities ranging from 1 to 5. + {ok,T2} = ?match({ok, _}, create_filter("$type_name == 'CommunicationsAlarm' and $priority >= 1 and $priority <= 5")), + ?match(true, eval(T2, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 2)}], + [], any:create(orber_tc:null(), null)))), + ?match(false, eval(T2, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 20)}], + [], any:create(orber_tc:null(), null)))), + + %% Select "MOVIE" events featuring at least 3 of the Marx Brothers. + {ok,T3} = ?match({ok, _}, create_filter("$type_name == 'MOVIE' and (('groucho' in $starlist) + ('chico' in $starlist) + ('harpo' in $starlist) + ('zeppo' in $starlist) + ('gummo' in $starlist)) > 2")), + ?match(true, eval(T3, ?not_CreateSE("DomainName","MOVIE", + "EventName", + [#'CosNotification_Property'{name="starlist", + value=any:create(orber_tc:sequence(orber_tc:string(0),0), + ["groucho", "harpo", "sam", "gummo"])}], + [], any:create(orber_tc:null(), null)))), + ?match(false, eval(T3, ?not_CreateSE("DomainName","MOVIE", + "EventName", + [#'CosNotification_Property'{name="starlist", + value=any:create(orber_tc:sequence(orber_tc:string(0),0), + ["frodo", "bilbo", "sam", "gummo"])}], + [], any:create(orber_tc:null(), null)))), + %% Accept students that took all 3 tests and had an average score of at least 80%. + {ok,T4} = ?match({ok, _}, create_filter("$test._length == 3 and ($test[0].score + $test[1].score + $test[2].score)/3 >=80")), + ?match(true, eval(T4, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="test", + value=any:create(orber_tc:array(notify_test_data:tc(),0), + {#notify_test_data{score=75}, + #notify_test_data{score=80}, + #notify_test_data{score=85}})}], + any:create(orber_tc:null(), null)))), + ?match(false, eval(T4, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="test", + value=any:create(orber_tc:array(notify_test_data:tc(),0), + {#notify_test_data{score=75}, + #notify_test_data{score=80}, + #notify_test_data{score=80}})}], + any:create(orber_tc:null(), null)))), + ?match(false, eval(T4, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="test", + value=any:create(orber_tc:array(notify_test_data:tc(),0), + {#notify_test_data{score=75}, + #notify_test_data{score=85}})}], + any:create(orber_tc:null(), null)))), + %% Select processes that exceed a certain usage threshold. + {ok,T5} = ?match({ok, _}, create_filter("$memsize / 5.5 + $cputime * 1275.0 + $filesize * 1.25 > 500000.0")), + ?match(true, eval(T5, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="cputime", + value=any:create(orber_tc:float(), 0.00078431137)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500000)}], + any:create(orber_tc:null(), null)))), + ?match(false, eval(T5, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="cputime", + value=any:create(orber_tc:float(), 0.00078431137)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500)}], + any:create(orber_tc:null(), null)))), + ?match({error, _}, eval(T5, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500)}], + any:create(orber_tc:null(), null)))), + + ?match(true, eval(T5, ?not_CreateSE("DomainName","TypeName", + "EventName", [], [], + any:create(orber_tc:sequence('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="cputime", + value=any:create(orber_tc:float(), 0.00078431137)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500000)}])))), + ?match(false, eval(T5, ?not_CreateSE("DomainName","TypeName", + "EventName", [], [], + any:create(orber_tc:sequence('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="cputime", + value=any:create(orber_tc:float(), 0.00078431137)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500)}])))), + ?match({error, _}, eval(T5, ?not_CreateSE("DomainName","TypeName", + "EventName", [], [], + any:create(orber_tc:sequence('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500)}])))), + + ?match(true, eval(T5, any:create(orber_tc:sequence('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="cputime", + value=any:create(orber_tc:float(), 0.00078431137)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500000)}]))), + ?match(false, eval(T5, any:create(orber_tc:sequence('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="cputime", + value=any:create(orber_tc:float(), 0.00078431137)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500)}]))), + ?match({error, _}, eval(T5, any:create(orber_tc:sequence('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="memsize", + value=any:create(orber_tc:float(), 5.5)}, + #'CosNotification_Property'{name="filesize", + value=any:create(orber_tc:float(), 500)}]))), + + %% Accept events where a threshold has the unscoped type name 'data'. + {ok,T6} = ?match({ok, _}, create_filter("exist $threshold._type_id and $threshold._type_id == 'data'")), + ?match(true, eval(T6, any:create(orber_tc:alias(notify_test_data:id(), + "threshold", + notify_test_data:tc()), + #notify_test_data{score = 10, name = "Erlang"}))), + + + + ?match(true, eval(T6, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property' + {name="threshold", + value=any:create(notify_test_data:tc(), + #notify_test_data + {score = 10, + name = "Erlang"})}], + any:create(orber_tc:null(), null)))), + + + ?match(true, eval(T6, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property' + {name="NotThreshold", + value=any:create(notify_test_data:tc(), + #notify_test_data + {score = 10, + name = "Erlang"})}], + any:create(orber_tc:alias(notify_test_data:id(), + "threshold", + notify_test_data:tc()), + #notify_test_data{score = 10, name = "Erlang"})))), + + + + %% Accept events with a serviceUser property of the correct standard type. + {ok,T7} = ?match({ok, _}, create_filter("$violation(TestData)._repos_id == 'IDL:notify_test/data:1.0'")), + ?match(true, eval(T7, ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property' + {name="violation", + value=any:create(orber_tc:array('CosNotification_Property':tc(),0), + [#'CosNotification_Property' + {name="TestData", + value=any:create(notify_test_data:tc(), + #notify_test_data + {score=100, + name="perfect score"})}])}], + any:create(orber_tc:null(), null)))), + + {ok,T8} = ?match({ok, _}, create_filter("$type_name == 'CommunicationsAlarm' and $event_name == 'lost_packet' and $priority < 2")), + %% All correct + Event1 = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + %% Priority to high + Event2 = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 2)}], + [], any:create(orber_tc:null(), null)), + %% Misspell event_name, i.e., lost_packets instead of lost_packet + Event3 = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packets", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + %% Another type_name + Event4 = ?not_CreateSE("DomainName","TemperatureAlarm", + "lost_packets", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + + ?match(true, eval(T8, Event1)), + ?match(false, eval(T8, Event2)), + ?match(false, eval(T8, Event3)), + ?match(false, eval(T8, Event4)), + + {ok,T9} = ?match({ok, _}, create_filter("$gpa < 80 or $tests(midterm) > $tests(final) or $monthly_attendance[3] < 10")), + + %% midterm > final yields true, the others false + Event5 = ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property' + {name="tests", + value=any:create(orber_tc:array('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="midterm", + value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property'{name="final", + value=any:create(orber_tc:short(), 60)}])}, + #'CosNotification_Property'{name="monthly_attendance", + value=any:create(orber_tc:array(orber_tc:short(), 0), + {0,1,2,10})}, + #'CosNotification_Property'{name="gpa", + value=any:create(orber_tc:short(), 90)}], + any:create(orber_tc:null(), null)), + + %% monthly_attendance[3] < 10 yields true, the others false + Event6 = ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="tests", + value=any:create(orber_tc:array('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="midterm", + value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property'{name="final", + value=any:create(orber_tc:short(), 80)}])}, + #'CosNotification_Property'{name="monthly_attendance", + value=any:create(orber_tc:array(orber_tc:short(), 0), + {0,1,2,9})}, + #'CosNotification_Property'{name="gpa", + value=any:create(orber_tc:short(), 90)}], + any:create(orber_tc:null(), null)), + + %% gpa < 80 true, rest false. + Event7 = ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="tests", + value=any:create(orber_tc:array('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="midterm", + value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property'{name="final", + value=any:create(orber_tc:short(), 80)}])}, + #'CosNotification_Property'{name="monthly_attendance", + value=any:create(orber_tc:array(orber_tc:short(), 0), + {0,1,2,10})}, + #'CosNotification_Property'{name="gpa", + value=any:create(orber_tc:short(), 70)}], + any:create(orber_tc:null(), null)), + + %% All false + Event8 = ?not_CreateSE("DomainName","TypeName", + "EventName", [], + [#'CosNotification_Property'{name="tests", + value=any:create(orber_tc:array('CosNotification_Property':tc(),0), + [#'CosNotification_Property'{name="midterm", + value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property'{name="final", + value=any:create(orber_tc:short(), 80)}])}, + #'CosNotification_Property'{name="monthly_attendance", + value=any:create(orber_tc:array(orber_tc:short(), 0), + {0,1,2,10})}, + #'CosNotification_Property'{name="gpa", + value=any:create(orber_tc:short(), 80)}], + any:create(orber_tc:null(), null)), + + ?match(true, eval(T9, Event5)), + ?match(true, eval(T9, Event6)), + ?match(true, eval(T9, Event7)), + ?match(false, eval(T9, Event8)), + ok. + +%%----------------------------------------------------------------- +%% Misc grammar tests +%%----------------------------------------------------------------- +positional_api(doc) -> ["CosNotification positional notation grammar tests", ""]; +positional_api(suite) -> []; +positional_api(_Config) -> + {ok,T1} = ?match({ok, _}, create_filter("$.3 < 80 or $.1(midterm) > $.1(final) or $.2[3] < 10")), + + %% midterm > final yields true, the others false + Event1 = any:create(notify_test_studies:tc(), #notify_test_studies + {gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 60)}], + monthly_attendance = {0,1,2,10}}), + %% monthly_attendance[3] < 10 yields true, the others false + Event2 = any:create(notify_test_studies:tc(), #notify_test_studies + {gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 80)}], + monthly_attendance = {0,1,2,9}}), + %% gpa < 80 true, rest false. + Event3 = any:create(notify_test_studies:tc(), #notify_test_studies + {gpa = 70, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 80)}], + monthly_attendance = {0,1,2,10}}), + %% All false + Event4 = any:create(notify_test_studies:tc(), #notify_test_studies + {gpa = 80, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 80)}], + monthly_attendance = {0,1,2,10}}), + + ?match(true, eval(T1, Event1)), + ?match(true, eval(T1, Event2)), + ?match(true, eval(T1, Event3)), + ?match(false, eval(T1, Event4)), + + {ok,T2} = ?match({ok, _}, create_filter("$.0.0.0.1 == 'CommunicationsAlarm'")), + + Event5 = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", [], [], + any:create(orber_tc:null(), null)), + + ?match(true, eval(T2, Event5)), + + ok. + +%%----------------------------------------------------------------- +%% Components grammar tests +%%----------------------------------------------------------------- +components_api(doc) -> ["CosNotification components grammar tests", ""]; +components_api(suite) -> []; +components_api(_Config) -> + {ok,T1} = ?match({ok, _}, create_filter("$ == 2")), + ?match(true, eval(T1, ?not_CreateSE("DomainName","TypeName","EventName", + [],[], any:create(orber_tc:short(), 2)))), + ?match(true, eval(T1, any:create(orber_tc:short(), 2))), + ?match(false, eval(T1, ?not_CreateSE("DomainName","TypeName","EventName", + [],[], any:create(orber_tc:short(), 3)))), + ?match(false, eval(T1, any:create(orber_tc:short(), 3))), + + %% Select "MOVIE" events featuring at least 3 of the Marx Brothers. + {ok,T2} = ?match({ok, _}, create_filter("$type_name == 'MOVIE' and (('groucho' in $.starlist) + ('chico' in $.starlist) + ('harpo' in $.starlist) + ('zeppo' in $.starlist) + ('gummo' in $.starlist)) > 2")), + ?match(true, eval(T2, ?not_CreateSE("DomainName","MOVIE", "EventName", [], [], + any:create(orber_tc:alias("IFRId","starlist",tk_any), + any:create(orber_tc:sequence(orber_tc:string(0),0), + ["groucho", "harpo", "sam", "gummo"]))))), + ?match(false, eval(T2, ?not_CreateSE("DomainName","MOVIE", "EventName", [], [], + any:create(orber_tc:alias("IFRId","starlist",tk_any), + any:create(orber_tc:sequence(orber_tc:string(0),0), + ["frodo", "bilbo", "sam", "gummo"]))))), + + %% Accept only recent events (e.g., generated within the last 15 minutes or so). + {ok,_T3} = ?match({ok, _}, create_filter("$origination_timestamp.high + 2 < $curtime.high")), + + + %% Accept students that took all 3 tests and had an average score of at least 80%. + {ok,T4} = ?match({ok, _}, create_filter("$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80")), + ?match(true, eval(T4, ?not_CreateSE("DomainName","TypeName", "EventName", [], [], + any:create(orber_tc:alias("IFRId","test",tk_any), + any:create(orber_tc:array(notify_test_data:tc(),0), + {#notify_test_data{score=75}, + #notify_test_data{score=80}, + #notify_test_data{score=85}}))))), + ?match(false, eval(T4, ?not_CreateSE("DomainName","TypeName", "EventName", [], [], + any:create(orber_tc:alias("IFRId","test",tk_any), + any:create(orber_tc:array(notify_test_data:tc(),0), + {#notify_test_data{score=75}, + #notify_test_data{score=80}, + #notify_test_data{score=80}}))))), + ?match(false, eval(T4, ?not_CreateSE("DomainName","TypeName", "EventName", [], [], + any:create(orber_tc:alias("IFRId","test",tk_any), + any:create(orber_tc:array(notify_test_data:tc(),0), + {#notify_test_data{score=75}, + #notify_test_data{score=80}}))))), + + %% Select processes that exceed a certain usage threshold. + {ok,T5} = ?match({ok, _}, create_filter("$.memsize / 5.5 + $.cputime * 1275.0 + $.filesize * 1.25 > 500000.0")), + ?match(true, eval(T5, ?not_CreateSE("DomainName","TypeName", "EventName", [], [], + any:create(notify_test_computer:tc(), + #notify_test_computer + {memsize=5.5, + cputime = 0.00078431137, + filesize = 500000})))), + ?match(false, eval(T5, ?not_CreateSE("DomainName","TypeName", "EventName", [], [], + any:create(notify_test_computer:tc(), + #notify_test_computer + {memsize=5.5, + cputime = 0.00078431137, + filesize = 500})))), + ?match({error,_}, eval(T5, ?not_CreateSE("DomainName","TypeName", "EventName", [], [], + any:create(notify_test_computer:tc(), + #notify_test_computer + {memsize=5.5, + cputime = 0.00078431137})))), + + %% Accept only Notification Service structured events. + {ok,T6} = ?match({ok, _}, create_filter("$._repos_id == 'IDL:omg.org/CosNotification/StructuredEvent:1.0'")), + ?match(true, eval(T6, ?not_CreateSE("DomainName","CommunicationsAlarm", + "EventName", + [], [], any:create(orber_tc:null(), null)))), + + + + %% Accept only those events that have a specified security "rights list". + {ok,T7} = ?match({ok, _}, create_filter("exist $.header.variable_header(required_rights)")), + ?match(false, eval(T7, ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)))), + ?match(true, eval(T7, ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="required_rights", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)))), + + + {ok,T8} = ?match({ok, _}, create_filter("$.header.fixed_header.event_type.type_name == 'CommunicationsAlarm' and $.header.fixed_header.event_name == 'lost_packet' and $.header.variable_header(priority) < 2")), + %% All correct + Event1 = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + %% Priority to high + Event2 = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 2)}], + [], any:create(orber_tc:null(), null)), + %% Misspell event_name, i.e., lost_packets instead of lost_packet + Event3 = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packets", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + %% Another type_name + Event4 = ?not_CreateSE("DomainName","TemperatureAlarm", + "lost_packets", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + + ?match(true, eval(T8, Event1)), + ?match(false, eval(T8, Event2)), + ?match(false, eval(T8, Event3)), + ?match(false, eval(T8, Event4)), + + + {ok,T9} = ?match({ok, _}, create_filter("$.gpa < 80 or $.tests(midterm) > $.tests(final) or $.monthly_attendance[3] < 10")), + + %% midterm > final yields true, the others false + Event5 = ?not_CreateSE("DomainName","TypeName", + "EventName", [], [], + any:create(notify_test_studies:tc(), #notify_test_studies + {gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 60)}], + monthly_attendance = {0,1,2,10}})), + %% monthly_attendance[3] < 10 yields true, the others false + Event6 = ?not_CreateSE("DomainName","TypeName", + "EventName", [], [], + any:create(notify_test_studies:tc(), #notify_test_studies + {gpa = 90, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 80)}], + monthly_attendance = {0,1,2,9}})), + %% gpa < 80 true, rest false. + Event7 = ?not_CreateSE("DomainName","TypeName", + "EventName", [], [], + any:create(notify_test_studies:tc(), #notify_test_studies + {gpa = 70, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 80)}], + monthly_attendance = {0,1,2,10}})), + %% All false + Event8 = ?not_CreateSE("DomainName","TypeName", + "EventName", [], [], + any:create(notify_test_studies:tc(), #notify_test_studies + {gpa = 80, + tests = [#'CosNotification_Property' + {name="midterm", value=any:create(orber_tc:short(), 70)}, + #'CosNotification_Property' + {name="final", value=any:create(orber_tc:short(), 80)}], + monthly_attendance = {0,1,2,10}})), + + ?match(true, eval(T9, Event5)), + ?match(true, eval(T9, Event6)), + ?match(true, eval(T9, Event7)), + ?match(false, eval(T9, Event8)), + ok. + + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- + +%%-------------------- End of Module ------------------------------ diff --git a/lib/cosNotification/test/notification_SUITE.erl b/lib/cosNotification/test/notification_SUITE.erl new file mode 100644 index 0000000000..e2c560e4de --- /dev/null +++ b/lib/cosNotification/test/notification_SUITE.erl @@ -0,0 +1,2185 @@ +%%-------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%-------------------------------------------------------------------- +%% File : notification_SUITE.erl +%% Purpose : +%%-------------------------------------------------------------------- + +-module(notification_SUITE). + +%%--------------- INCLUDES ----------------------------------- +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/include/ifr_types.hrl"). +%% cosEvent files. +-include_lib("cosEvent/include/CosEventChannelAdmin.hrl"). +%% Application files +-include_lib("cosNotification/include/CosNotification.hrl"). +-include_lib("cosNotification/include/CosNotifyChannelAdmin.hrl"). +-include_lib("cosNotification/include/CosNotifyComm.hrl"). +-include_lib("cosNotification/include/CosNotifyFilter.hrl"). + +-include_lib("cosNotification/src/CosNotification_Definitions.hrl"). + +-include("idl_output/notify_test.hrl"). + +-include("test_server.hrl"). + +%%--------------- DEFINES ------------------------------------ +-define(default_timeout, ?t:minutes(20)). +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(defaultQoS, + [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), + value=any:create(orber_tc:long(), 100)}, + #'CosNotification_Property'{name='CosNotification':'PacingInterval'(), + value=any:create(orber_tc:unsigned_long_long(), + 20000000)}, + #'CosNotification_Property'{name='CosNotification':'OrderPolicy'(), + value=any:create(orber_tc:short(), + 'CosNotification':'AnyOrder'())}, + #'CosNotification_Property'{name='CosNotification':'EventReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'BestEffort'())}, + #'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'BestEffort'())}, + #'CosNotification_Property'{name='CosNotification':'DiscardPolicy'(), + value=any:create(orber_tc:short(), + 'CosNotification':'AnyOrder'())}, + #'CosNotification_Property'{name='CosNotification':'StartTimeSupported'(), + value=any:create(orber_tc:boolean(), false)}, + #'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), + value=any:create(orber_tc:boolean(), false)}, + #'CosNotification_Property'{name='CosNotification':'Priority'(), + value=any:create(orber_tc:short(), + 'CosNotification':'DefaultPriority'())}]). +-define(defaultQoS2, + [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), + value=any:create(orber_tc:long(), 1)}, + #'CosNotification_Property'{name='CosNotification':'PacingInterval'(), + value=any:create(orber_tc:unsigned_long_long(), + 0)}, + #'CosNotification_Property'{name='CosNotification':'OrderPolicy'(), + value=any:create(orber_tc:short(), + 'CosNotification':'AnyOrder'())}, + #'CosNotification_Property'{name='CosNotification':'EventReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'BestEffort'())}, + #'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'BestEffort'())}, + #'CosNotification_Property'{name='CosNotification':'DiscardPolicy'(), + value=any:create(orber_tc:short(), + 'CosNotification':'AnyOrder'())}, + #'CosNotification_Property'{name='CosNotification':'StartTimeSupported'(), + value=any:create(orber_tc:boolean(), false)}, + #'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), + value=any:create(orber_tc:boolean(), false)}, + #'CosNotification_Property'{name='CosNotification':'Priority'(), + value=any:create(orber_tc:short(), + 'CosNotification':'DefaultPriority'())}]). +-define(defaultAdm, + [#'CosNotification_Property'{name='CosNotification':'MaxQueueLength'(), + value=any:create(orber_tc:long(), 100)}, + #'CosNotification_Property'{name='CosNotification':'MaxConsumers'(), + value=any:create(orber_tc:long(), 100)}, + #'CosNotification_Property'{name='CosNotification':'MaxSuppliers'(), + value=any:create(orber_tc:long(), 100)}]). + +-define(FAC_OPT, []). + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, qos_api/1, adm_api/1, + cosevent_api/1, filter_adm_api/1, events_api/1, events2_api/1, + event_qos_api/1, filter_api/1, mapping_filter_api/1, subscription_api/1, + init_per_testcase/2, fin_per_testcase/2, persistent_max_events_api/1, + persistent_timeout_events_api/1, persistent_recover_events_api/1, + app_test/1]). + +-export([terminated/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for the cosNotification interfaces", ""]; +all(suite) -> {req, + [mnesia, orber], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [persistent_max_events_api, persistent_timeout_events_api, + persistent_recover_events_api, mapping_filter_api, filter_api, filter_adm_api, + event_qos_api, qos_api, adm_api, cosevent_api, subscription_api, + events_api, events2_api, app_test]. + + + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ok = corba:orb_init([{flags, 16#02}, {orber_debug_level, 10}]), + orber:jump_start(), + cosNotificationApp:install_event(), + cosNotificationApp:install(), + 'oe_notify_test_server':'oe_register'(), + cosNotificationApp:start(), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + cosNotificationApp:stop(), + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + 'oe_notify_test_server':'oe_unregister'(), + cosNotificationApp:uninstall(), + cosNotificationApp:uninstall_event(), + orber:jump_stop(), + Config. + + +%%----------------------------------------------------------------- +%% Tests app file +%%----------------------------------------------------------------- +app_test(doc) -> []; +app_test(suite) -> []; +app_test(_Config) -> + ok=test_server:app_test(cosNotification), + ok. + + +%%----------------------------------------------------------------- +%% Persistent events max limit +%%----------------------------------------------------------------- +persistent_max_events_api(doc) -> ["CosNotification QoS EventReliability Persistent", + ""]; +persistent_max_events_api(suite) -> []; +persistent_max_events_api(_Config) -> + QoSPersistent = + [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + QoSEventPersistent = + [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + application:set_env(cosNotification, notify, ?MODULE), + application:set_env(cosNotification, max_events, 2), + application:set_env(cosNotification, timeout_events, 300000), + application:set_env(cosNotification, interval_events, 10000), + %% Initialize the application. + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS2, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), + + %% Create the Admin objects + {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'AND_OP')), + {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'AND_OP')), + + %% Create Proxies and clients + {SequenceProxyPushSupplier,_ID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'SEQUENCE_EVENT')), + PushSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',SequenceProxyPushSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(SequenceProxyPushSupplier, PushSeqC)), + + {SequenceProxyPushConsumer,_ID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'SEQUENCE_EVENT')), + PushSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',SequenceProxyPushConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(SequenceProxyPushConsumer, PushSeqS)), + + %% Create a couple of Events to test with. + Event = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + + ?match(ok, 'notify_test_SeqPushC':doAction(PushSeqC, {action, action})), + + %% Push and check the state. + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), + ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), + + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), + ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), + %% Now we've reached the limit. This call will terminate the proxy. + %% We cannot check for data at this point since the broken connection + %% will result in that the client terminates. + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), + timer:sleep(5000), + ?match(true, corba_object:non_existent(SequenceProxyPushSupplier)), + ?match(true, corba_object:non_existent(PushSeqC)), + + + catch corba:dispose(SequenceProxyPushConsumer), + catch corba:dispose(SequenceProxyPushSupplier), + catch corba:dispose(AdminConsumer), + catch corba:dispose(AdminSupplier), + catch corba:dispose(Ch), + catch cosNotificationApp:stop_factory(Fac), + catch corba:dispose(PushSeqS), + catch corba:dispose(PushSeqC), + application:set_env(cosNotification, notify, undefined), + application:set_env(cosNotification, max_events, undefined), + application:set_env(cosNotification, timeout_events, undefined), + application:set_env(cosNotification, interval_events, undefined), + ok. + +terminated(Items) -> + io:format("Proxy terminated due to: ~p~n", [Items]). + +%%----------------------------------------------------------------- +%% Persistent events timeout +%%----------------------------------------------------------------- +persistent_timeout_events_api(doc) -> + ["CosNotification QoS EventReliability Persistent", + ""]; +persistent_timeout_events_api(suite) -> []; +persistent_timeout_events_api(_Config) -> + QoSPersistent = + [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + QoSEventPersistent = + [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + application:set_env(cosNotification, notify, ?MODULE), + application:set_env(cosNotification, max_events, 1000), + application:set_env(cosNotification, timeout_events, 4000), + application:set_env(cosNotification, interval_events, 1000), + %% Initialize the application. + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS2, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), + + %% Create the Admin objects + {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'AND_OP')), + {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'AND_OP')), + + %% Create Proxies and clients + {SequenceProxyPushSupplier,_ID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'SEQUENCE_EVENT')), + PushSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',SequenceProxyPushSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(SequenceProxyPushSupplier, PushSeqC)), + + {SequenceProxyPushConsumer,_ID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'SEQUENCE_EVENT')), + PushSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',SequenceProxyPushConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(SequenceProxyPushConsumer, PushSeqS)), + + %% Create a couple of Events to test with. + Event = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + + ?match(ok, 'notify_test_SeqPushC':doAction(PushSeqC, {action, action})), + + %% Push and check the state. + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), + ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), + + %% Now we've reached the limit. This call will terminate the proxy. + %% We cannot check for data at this point since the broken connection + %% will result in that the client terminates. + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), + timer:sleep(10000), + ?match(true, corba_object:non_existent(SequenceProxyPushSupplier)), + ?match(true, corba_object:non_existent(PushSeqC)), + + + catch corba:dispose(SequenceProxyPushConsumer), + catch corba:dispose(SequenceProxyPushSupplier), + catch corba:dispose(AdminConsumer), + catch corba:dispose(AdminSupplier), + catch corba:dispose(Ch), + catch cosNotificationApp:stop_factory(Fac), + catch corba:dispose(PushSeqS), + catch corba:dispose(PushSeqC), + application:set_env(cosNotification, notify, undefined), + application:set_env(cosNotification, max_events, undefined), + application:set_env(cosNotification, timeout_events, undefined), + application:set_env(cosNotification, interval_events, undefined), + ok. + +%%----------------------------------------------------------------- +%% Persistent events max limit +%%----------------------------------------------------------------- +persistent_recover_events_api(doc) -> + ["CosNotification QoS EventReliability Persistent", + ""]; +persistent_recover_events_api(suite) -> []; +persistent_recover_events_api(_Config) -> + QoSPersistent = + [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + QoSEventPersistent = + [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + application:set_env(cosNotification, notify, ?MODULE), + application:set_env(cosNotification, max_events, 1000), + application:set_env(cosNotification, timeout_events, 100000), + application:set_env(cosNotification, interval_events, 1000), + %% Initialize the application. + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS2, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), + + %% Create the Admin objects + {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'AND_OP')), + {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'AND_OP')), + + %% Create Proxies and clients + {SequenceProxyPushSupplier,_ID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'SEQUENCE_EVENT')), + PushSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',SequenceProxyPushSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(SequenceProxyPushSupplier, PushSeqC)), + + {SequenceProxyPushConsumer,_ID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'SEQUENCE_EVENT')), + PushSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',SequenceProxyPushConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(SequenceProxyPushConsumer, PushSeqS)), + + %% Create a couple of Events to test with. + Event = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + + ?match(ok, 'notify_test_SeqPushC':doAction(PushSeqC, {action, action})), + + %% Push and check the state. + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), + ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), + %% Allow the proxy to try a few times and then change the client behavior + timer:sleep(4000), + ?match(ok, 'notify_test_SeqPushC':doAction(PushSeqC, {action, undefined})), + %% Wait some time so that the proxy timeout has kicked in. + timer:sleep(4000), + + %% Now the communication should work again. + ?match([Event], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), + + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), + timer:sleep(4000), + ?match([Event], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + catch corba:dispose(SequenceProxyPushConsumer), + catch corba:dispose(SequenceProxyPushSupplier), + catch corba:dispose(AdminConsumer), + catch corba:dispose(AdminSupplier), + catch corba:dispose(Ch), + catch cosNotificationApp:stop_factory(Fac), + catch corba:dispose(PushSeqS), + catch corba:dispose(PushSeqC), + application:set_env(cosNotification, notify, undefined), + application:set_env(cosNotification, max_events, undefined), + application:set_env(cosNotification, timeout_events, undefined), + application:set_env(cosNotification, interval_events, undefined), + ok. + + +%%----------------------------------------------------------------- +%% CosNotifyFilter::Filter API tests +%%----------------------------------------------------------------- +mapping_filter_api(doc) -> ["CosNotifyFilter::MappingFilter API tests.", ""]; +mapping_filter_api(suite) -> []; +mapping_filter_api(_Config) -> + FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), + ?match({_,key,_,_,_,_}, FiFac), + + Filter = 'CosNotifyFilter_FilterFactory':create_mapping_filter(FiFac, + "EXTENDED_TCL", + any:create(orber_tc:short(), 10)), + ?match({_,key,_,_,_,_}, Filter), + + ?match("EXTENDED_TCL", 'CosNotifyFilter_MappingFilter':'_get_constraint_grammar'(Filter)), + + %% Test before we add any constarints. + ?match([], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), + ?match({'EXCEPTION', {'CosNotifyFilter_ConstraintNotFound', _, 1}}, + 'CosNotifyFilter_MappingFilter':get_mapping_constraints(Filter, [1])), + ?match(ok, 'CosNotifyFilter_MappingFilter':remove_all_mapping_constraints(Filter)), + + %% Try adding an incorrect constraint_expr + ?match({'EXCEPTION',{'CosNotifyFilter_InvalidConstraint',_,_}}, + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "name", + type_name = "type"}], + constraint_expr = "2==2 and 3<"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + %% Try adding two correct constraint_expr + ?line[{_,_,CID1,_},{_,_,CID2,_}]= + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}, {'CosNotifyFilter_MappingConstraintInfo',_,_,_}], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "name", + type_name = "type"}], + constraint_expr = "2==2 and 3<4"}, + result_to_set = any:create(orber_tc:short(), 10)}, + #'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "name2", + type_name = "type2"}], + constraint_expr = "$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,CID2,_}, {'CosNotifyFilter_MappingConstraintInfo',_,CID1,_}], + 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,CID1,_}], + 'CosNotifyFilter_MappingFilter':get_mapping_constraints(Filter, [CID1])), + ?match(ok, 'CosNotifyFilter_MappingFilter':remove_all_mapping_constraints(Filter)), + ?match([], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), + + %% Try adding a constraint_expr with using invalid value, i.e., not short. + ?match({'EXCEPTION',{'CosNotifyFilter_InvalidValue',_,_,_}}, + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "name", + type_name = "type"}], + constraint_expr = "2==2 and 3<8"}, + result_to_set = any:create(orber_tc:long(), 10)}])), + + %% Try adding one correct and one incorrect constraint_expr + ?match({'EXCEPTION',{'CosNotifyFilter_InvalidConstraint',_,_}}, + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "name", + type_name = "type"}], + constraint_expr = "2==2 and 3<"}, + result_to_set = any:create(orber_tc:short(), 10)}, + #'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "name2", + type_name = "type2"}], + constraint_expr = "$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + + %% Following testcases test different domain_name and type_name, e.g., + %% wildcards etc. + [{_,ConInfoData,CID3,_}] = + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "domain", + type_name = ""}, + #'CosNotification_EventType' + {domain_name = "*", + type_name = "type"}], + constraint_expr = "2==2 and 3<4"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + + %% Try removing a constraint + ?match(ok, 'CosNotifyFilter_MappingFilter':modify_mapping_constraints(Filter,[CID3],[])), + ?match([], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), + + %% Add e new constraint + [{_,_,CID4,_}] = + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "domain1", + type_name = ""}, + #'CosNotification_EventType' + {domain_name = "domain2", + type_name = "*"}], + constraint_expr = "2==2 and 3<4"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + + %% Try to update the constraint associated with CID4 to equal CID3. + ?match(ok, 'CosNotifyFilter_MappingFilter':modify_mapping_constraints(Filter,[], + [#'CosNotifyFilter_MappingConstraintInfo' + {constraint_expression= + #'CosNotifyFilter_ConstraintExp' + {event_types =[#'CosNotification_EventType' + {domain_name = "domain", + type_name = ""}, + #'CosNotification_EventType' + {domain_name = "*", + type_name = "type"}], + constraint_expr = "2==2 and 3<4"}, + constraint_id=CID4, + value = any:create(orber_tc:short(), 10)}])), + + ?match([{_,ConInfoData,CID4,_}], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), + + ?match({'EXCEPTION', {'CosNotifyFilter_ConstraintNotFound', _, CID3}}, + 'CosNotifyFilter_MappingFilter':get_mapping_constraints(Filter, [CID3])), + ?match(ok, 'CosNotifyFilter_MappingFilter':remove_all_mapping_constraints(Filter)), + ?match([], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), + + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "", + type_name = "type1"}, + #'CosNotification_EventType' + {domain_name = "*", + type_name = "type2"}], + constraint_expr = "2==2 and 3<4"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "domain1", + type_name = "type1"}, + #'CosNotification_EventType' + {domain_name = "domain2", + type_name = "type2"}], + constraint_expr = "2==2 and 3<4"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "dom*", + type_name = "type1"}, + #'CosNotification_EventType' + {domain_name = "domain2", + type_name = "typ*"}], + constraint_expr = "2==2 and 3<4"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + + ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], + 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, + [#'CosNotifyFilter_MappingConstraintPair' + {constraint_expression = #'CosNotifyFilter_ConstraintExp' + {event_types = [#'CosNotification_EventType' + {domain_name = "dom*1", + type_name = "type1"}, + #'CosNotification_EventType' + {domain_name = "domain2", + type_name = "typ*2"}], + constraint_expr = "2==2 and 3<4"}, + result_to_set = any:create(orber_tc:short(), 10)}])), + + catch corba:dispose(FiFac), + catch corba:dispose(Filter), + ok. + + +%%----------------------------------------------------------------- +%% CosNotifyFilter::Filter API tests +%%----------------------------------------------------------------- +filter_api(doc) -> ["CosNotifyFilter::Filter API tests.", ""]; +filter_api(suite) -> []; +filter_api(_Config) -> + Fac = cosNotificationApp:start_global_factory(?FAC_OPT), + ?match({_,key,_,_,_,_}, Fac), + {Ch, _Id1} = 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm), + AC= 'CosNotifyChannelAdmin_EventChannel':for_consumers(Ch), + + FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), + ?match({_,key,_,_,_,_}, FiFac), + + Filter = 'CosNotifyFilter_FilterFactory':create_filter(FiFac,"EXTENDED_TCL"), + ?match({_,key,_,_,_,_}, Filter), + + ?match("EXTENDED_TCL", 'CosNotifyFilter_Filter':'_get_constraint_grammar'(Filter)), + + %% Test Callback management. + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, + 'CosNotifyFilter_Filter':attach_callback(Filter, Ch)), + ?match([], 'CosNotifyFilter_Filter':get_callbacks(Filter)), + ?match({'EXCEPTION',{'CosNotifyFilter_CallbackNotFound',_}}, + 'CosNotifyFilter_Filter':detach_callback(Filter, 0)), + ID='CosNotifyFilter_Filter':attach_callback(Filter, AC), + ?match([ID], 'CosNotifyFilter_Filter':get_callbacks(Filter)), + ?match(ok, 'CosNotifyFilter_Filter':detach_callback(Filter, ID)), + ?match([], 'CosNotifyFilter_Filter':get_callbacks(Filter)), + + %% This callback is just attached so we can test that we can call notify_subscribe. + _ID2='CosNotifyFilter_Filter':attach_callback(Filter, AC), + + %% Test before we add any constarints. + ?match([], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), + ?match({'EXCEPTION', {'CosNotifyFilter_ConstraintNotFound', _, 1}}, + 'CosNotifyFilter_Filter':get_constraints(Filter, [1])), + ?match(ok, 'CosNotifyFilter_Filter':remove_all_constraints(Filter)), + + %% Try adding an incorrect constraint_expr + ?match({'EXCEPTION',{'CosNotifyFilter_InvalidConstraint',_,_}}, + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "name", + type_name = "type"}], + constraint_expr = "2==2 and 3<"}])), + %% Try adding two correct constraint_expr + ?line[{_,_,CID1},{_,_,CID2}]= + ?match([{'CosNotifyFilter_ConstraintInfo',_,_}, {'CosNotifyFilter_ConstraintInfo',_,_}], + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "name", + type_name = "type"}], + constraint_expr = "2==2 and 3<4"}, + #'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "name2", + type_name = "type2"}], + constraint_expr = "$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80"}])), + + ?match([{'CosNotifyFilter_ConstraintInfo',_,CID2}, {'CosNotifyFilter_ConstraintInfo',_,CID1}], + 'CosNotifyFilter_Filter':get_all_constraints(Filter)), + ?match([{'CosNotifyFilter_ConstraintInfo',_,CID1}], + 'CosNotifyFilter_Filter':get_constraints(Filter, [CID1])), + ?match(ok, 'CosNotifyFilter_Filter':remove_all_constraints(Filter)), + ?match([], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), + + %% Try adding one correct and one incorrect constraint_expr + ?match({'EXCEPTION',{'CosNotifyFilter_InvalidConstraint',_,_}}, + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "name", + type_name = "type"}], + constraint_expr = "2==2 and 3<"}, + #'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "name2", + type_name = "type2"}], + constraint_expr = "$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80"}])), + + %% Following testcases test different domain_name and type_name, e.g., + %% wildcards etc. + [{_,ConInfoData,CID3}] = + ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "domain", + type_name = ""}, + #'CosNotification_EventType'{ + domain_name = "*", + type_name = "type"}], + constraint_expr = "2==2 and 3<4"}])), + + %% Try removing a constraint + ?match(ok, 'CosNotifyFilter_Filter':modify_constraints(Filter,[CID3],[])), + ?match([], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), + + %% Add e new constraint + [{_,_,CID4}] = + ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "domain1", + type_name = ""}, + #'CosNotification_EventType'{ + domain_name = "domain2", + type_name = "*"}], + constraint_expr = "2==2 and 3<4"}])), + + %% Try to update the constraint associated with CID4 to equal CID3. + ?match(ok, 'CosNotifyFilter_Filter':modify_constraints(Filter,[], + [#'CosNotifyFilter_ConstraintInfo'{constraint_expression= + #'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "domain", + type_name = ""}, + #'CosNotification_EventType'{ + domain_name = "*", + type_name = "type"}], + constraint_expr = "2==2 and 3<4"}, + constraint_id=CID4}])), + + ?match([{_,ConInfoData,CID4}], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), + + ?match({'EXCEPTION', {'CosNotifyFilter_ConstraintNotFound', _, CID3}}, + 'CosNotifyFilter_Filter':get_constraints(Filter, [CID3])), + ?match(ok, 'CosNotifyFilter_Filter':remove_all_constraints(Filter)), + ?match([], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), + + ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "", + type_name = "type1"}, + #'CosNotification_EventType'{ + domain_name = "*", + type_name = "type2"}], + constraint_expr = "2==2 and 3<4"}])), + + ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "domain1", + type_name = "type1"}, + #'CosNotification_EventType'{ + domain_name = "domain2", + type_name = "type2"}], + constraint_expr = "2==2 and 3<4"}])), + + ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "dom*", + type_name = "type1"}, + #'CosNotification_EventType'{ + domain_name = "domain2", + type_name = "typ*"}], + constraint_expr = "2==2 and 3<4"}])), + + ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "dom*1", + type_name = "type1"}, + #'CosNotification_EventType'{ + domain_name = "domain2", + type_name = "typ*2"}], + constraint_expr = "2==2 and 3<4"}])), + + catch corba:dispose(FiFac), + catch corba:dispose(Filter), + catch corba:dispose(AC), + catch corba:dispose(Ch), + catch corba:dispose(Fac), + ok. + +%%----------------------------------------------------------------- +%% Subscription handling API tests +%%----------------------------------------------------------------- +subscription_api(doc) -> ["CosNotification subscription handling", ""]; +subscription_api(suite) -> []; +subscription_api(_Config) -> + %% Initialize the application. + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + + %% Create the Admin objects + {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'OR_OP')), + {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'OR_OP')), + + %% Create Suppliers Proxies + {StructuredProxyPullSupplier,_}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'STRUCTURED_EVENT')), + {StructuredProxyPushSupplier,_}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'STRUCTURED_EVENT')), + + %% Now we must create a Client for each proxy and connect them. + PushStrC=?match({_,key,_,_,_,_}, 'notify_test_StrPushC':oe_create(['PUSH_STRUCTURED',StructuredProxyPushSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':connect_structured_push_consumer(StructuredProxyPushSupplier, PushStrC)), + PullStrC=?match({_,key,_,_,_,_}, 'notify_test_StrPullC':oe_create(['PULL_STRUCTURED',StructuredProxyPullSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':connect_structured_pull_consumer(StructuredProxyPullSupplier, PullStrC)), + + %% Create Consumers Proxies + {StructuredProxyPullConsumer,_}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(AdminSupplier, 'STRUCTURED_EVENT')), + {StructuredProxyPushConsumer,_}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'STRUCTURED_EVENT')), + + %% Now we must create a Client for each proxy and connect them. + PushStrS=?match({_,key,_,_,_,_}, 'notify_test_StrPushS':oe_create(['PUSH_STRUCTURED',StructuredProxyPushConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':connect_structured_push_supplier(StructuredProxyPushConsumer, PushStrS)), + + PullStrS=?match({_,key,_,_,_,_}, 'notify_test_StrPullS':oe_create(['PULL_STRUCTURED',StructuredProxyPullConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':connect_structured_pull_supplier(StructuredProxyPullConsumer, PullStrS)), + + ES1=[#'CosNotification_EventType'{domain_name = "name1", type_name = "type1"}, + #'CosNotification_EventType'{domain_name = "name2", type_name = "type2"}], + ES2=[#'CosNotification_EventType'{domain_name = "name3", type_name = "type3"}, + #'CosNotification_EventType'{domain_name = "name4", type_name = "type4"}], + + %% Initially it should have no associated types. Test that and set that + %% all updates should be forwarded to client. + ?match([], 'CosNotifyChannelAdmin_StructuredProxyPushConsumer': + obtain_subscription_types(StructuredProxyPushConsumer, + 'ALL_NOW_UPDATES_ON')), + ?match([], 'CosNotifyChannelAdmin_StructuredProxyPullConsumer': + obtain_subscription_types(StructuredProxyPullConsumer, + 'ALL_NOW_UPDATES_ON')), + + %% Update the offered types. + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer': + offer_change(StructuredProxyPushConsumer, ES1, [])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer': + offer_change(StructuredProxyPullConsumer, ES1, [])), + + %% To be sure, wait a couple of seconds. + timer:sleep(5000), + ?match([{'CosNotification_EventType',_,_}, + {'CosNotification_EventType',_,_}], + 'notify_test_StrPushC':doAction(PushStrS, return_data)), + ?match([{'CosNotification_EventType',_,_}, + {'CosNotification_EventType',_,_}], + 'notify_test_StrPullC':doAction(PullStrS, return_data)), + + %% Update the offered types. Remove ES1 and add ES2. + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer': + offer_change(StructuredProxyPushConsumer, ES2, ES1)), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer': + offer_change(StructuredProxyPullConsumer, ES2, ES1)), + + %% To be sure, wait a couple of seconds. + timer:sleep(5000), + ?match([{'CosNotification_EventType',_,_}, + {'CosNotification_EventType',_,_}], + 'notify_test_StrPushC':doAction(PushStrS, return_data)), + ?match([{'CosNotification_EventType',_,_}, + {'CosNotification_EventType',_,_}], + 'notify_test_StrPullC':doAction(PullStrS, return_data)), + + %% Now, the objects should only contain 'ES2'. Test it. + ?match([{'CosNotification_EventType',_,_}, + {'CosNotification_EventType',_,_}], + 'CosNotifyChannelAdmin_StructuredProxyPushConsumer': + obtain_subscription_types(StructuredProxyPushConsumer, + 'ALL_NOW_UPDATES_ON')), + ?match([{'CosNotification_EventType',_,_}, + {'CosNotification_EventType',_,_}], + 'CosNotifyChannelAdmin_StructuredProxyPullConsumer': + obtain_subscription_types(StructuredProxyPullConsumer, + 'ALL_NOW_UPDATES_ON')), + + %% Now we will use wildcards, empty strings and test if they really + %% are ignored if so requested. + ES3=[#'CosNotification_EventType'{domain_name = "name1", type_name = "*"}, + #'CosNotification_EventType'{domain_name = "*", type_name = "type2"}], + ES4=[#'CosNotification_EventType'{domain_name = "name1", type_name = "*"}, + #'CosNotification_EventType'{domain_name = "name2", type_name = ""}], + ES5=[#'CosNotification_EventType'{domain_name = "na*", type_name = "type1"}], + ES6=[#'CosNotification_EventType'{domain_name = "n*1", type_name = "type1"}], + ES7=[#'CosNotification_EventType'{domain_name = "*1", type_name = "type1"}], + ES8=[#'CosNotification_EventType'{domain_name = "n*m*1", type_name = "type1"}], + ES9=[#'CosNotification_EventType'{domain_name = "n**1", type_name = "type1"}], + ES10=[#'CosNotification_EventType'{domain_name = "nam*1", type_name = "type1"}], + + Event1 = ?not_CreateSE("name1","type1", + "event_name", + [#'CosNotification_Property'{name="property_name", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + Event2 = ?not_CreateSE("name2","type1", + "event_name", + [#'CosNotification_Property'{name="property_name", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + Event3 = ?not_CreateSE("mame1","type1", + "event_name", + [#'CosNotification_Property'{name="property_name", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + Event4 = ?not_CreateSE("naame1","type1", + "event_name", + [#'CosNotification_Property'{name="property_name", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + Event5 = ?not_CreateSE("nname1","type1", + "event_name", + [#'CosNotification_Property'{name="property_name", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + Event6 = ?not_CreateSE("name12","type1", + "event_name", + [#'CosNotification_Property'{name="property_name", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': + subscription_change(StructuredProxyPullSupplier, ES3, [])), + + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), + + ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': + subscription_change(StructuredProxyPullSupplier, ES4, ES3)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), + ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': + subscription_change(StructuredProxyPullSupplier, ES5, ES4)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), + ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': + subscription_change(StructuredProxyPullSupplier, ES6, ES5)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), + ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': + subscription_change(StructuredProxyPullSupplier, ES7, ES6)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), + ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': + subscription_change(StructuredProxyPullSupplier, ES8, ES7)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), + ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': + subscription_change(StructuredProxyPullSupplier, ES9, ES8)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), + ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event2)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event3)), + + timer:sleep(5000), + ?match({_NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), + + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': + subscription_change(StructuredProxyPullSupplier, ES10, ES9)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), + ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event4)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event5)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event6)), + + timer:sleep(5000), + ?match({_NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), + + + catch corba:dispose(StructuredProxyPushConsumer), + catch corba:dispose(StructuredProxyPullConsumer), + catch corba:dispose(StructuredProxyPushSupplier), + catch corba:dispose(StructuredProxyPullSupplier), + catch corba:dispose(AdminConsumer), + catch corba:dispose(AdminSupplier), + catch corba:dispose(Ch), + catch cosNotificationApp:stop_factory(Fac), + + timer:sleep(5000), + ?match(true, corba_object:non_existent(PullStrS)), + ?match(true, corba_object:non_existent(PushStrS)), + ?match(true, corba_object:non_existent(PullStrC)), + ?match(true, corba_object:non_existent(PushStrC)), + + ok. + +%%----------------------------------------------------------------- +%% Filter admin API tests +%%----------------------------------------------------------------- +filter_adm_api(doc) -> ["CosNotification filter admin tests", ""]; +filter_adm_api(suite) -> []; +filter_adm_api(_Config) -> + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + + FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), + ?match({_,key,_,_,_,_}, FiFac), + + Filter = 'CosNotifyFilter_FilterFactory':create_filter(FiFac,"EXTENDED_TCL"), + ?match({_,key,_,_,_,_}, Filter), + + AC=?match({_,key,_,_,_,_}, + 'CosNotifyChannelAdmin_EventChannel':for_consumers(Ch)), + filter_tests('CosNotifyChannelAdmin_ConsumerAdmin', AC, Filter, Ch), + + AS=?match({_,key,_,_,_,_}, + 'CosNotifyChannelAdmin_EventChannel':for_suppliers(Ch)), + filter_tests('CosNotifyChannelAdmin_SupplierAdmin', AS, Filter, Ch), + + PushS=?match({_,key,_,_,_,_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_push_supplier(AC)), + filter_tests('CosNotifyChannelAdmin_ProxyPushSupplier', PushS, Filter, Ch), + + PullS=?match({_,key,_,_,_,_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_pull_supplier(AC)), + filter_tests('CosNotifyChannelAdmin_ProxyPullSupplier', PullS, Filter, Ch), + + PushC=?match({_,key,_,_,_,_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_push_consumer(AS)), + filter_tests('CosNotifyChannelAdmin_ProxyPushConsumer', PushC, Filter, Ch), + + PullC=?match({_,key,_,_,_,_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_pull_consumer(AS)), + filter_tests('CosNotifyChannelAdmin_ProxyPullConsumer', PullC, Filter, Ch), + + catch corba:dispose(FiFac), + catch corba:dispose(Filter), + catch corba:dispose(PushS), + catch corba:dispose(PullS), + catch corba:dispose(PushC), + catch corba:dispose(PullC), + catch corba:dispose(AC), + catch corba:dispose(AS), + catch corba:dispose(Ch), + catch cosNotificationApp:stop_factory(Fac), + ok. + +filter_tests(Mod, Obj, Filter, Ch) -> + io:format("############ TESTING MODULE ~p FILTER ############~n", [Mod]), + %% No filter added. + ?match([], Mod:get_all_filters(Obj)), + ?match(ok, Mod:remove_all_filters(Obj)), + ?match({'EXCEPTION',{'CosNotifyFilter_FilterNotFound',_}}, + Mod:get_filter(Obj, 0)), + %% Try add a Filter which is not a filter. + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, Mod:add_filter(Obj, Ch)), + %% Try to remove a single filter. + ?match({'EXCEPTION',{'CosNotifyFilter_FilterNotFound',_}}, + Mod:remove_filter(Obj, 0)), + ID = Mod:add_filter(Obj, Filter), + ?match([ID], Mod:get_all_filters(Obj)), + ?match(Filter, Mod:get_filter(Obj, ID)), + ?match(ok, Mod:remove_filter(Obj, ID)), + ?match([], Mod:get_all_filters(Obj)), + ID2 = Mod:add_filter(Obj, Filter), + ?match([ID2], Mod:get_all_filters(Obj)), + ?match(ok, Mod:remove_all_filters(Obj)), + ?match([], Mod:get_all_filters(Obj)), + ok. + +%%----------------------------------------------------------------- +%% Creating different event pushing and pulling API tests +%%----------------------------------------------------------------- +events_api(doc) -> ["CosNotification event pushing and pulling tests", ""]; +events_api(suite) -> []; +events_api(_Config) -> + %% Initialize the application. + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + {Ch, Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + events_api_helper(Fac, Ch, Id1). + +events2_api(doc) -> ["CosNotification event pushing and pulling tests II", ""]; +events2_api(suite) -> []; +events2_api(_Config) -> + %% Initialize the application. + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + {Ch, Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS2, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + events_api_helper(Fac, Ch, Id1). + +events_api_helper(Fac, Ch, _Id1) -> + %% Now we will set up a test environment, with the following structure: + %% + %% Channel + %% / \ + %% Supplier Adm Consumer Adm + %% / \ + %% 1 proxy of each possible type + %% To each proxy we will connect a test client + %% The events will flow in ===>> direction. + %% + %% For the supplier Admins this include: + %% - ProxyPushConsumer + %% - SequenceProxyPushConsumer + %% - StructuredProxyPushConsumer + %% - ProxyPullConsumer + %% - SequenceProxyPullConsumer + %% - StructuredProxyPullConsumer + %% + %% For the consumer Admins this include: + %% - ProxyPushSupplier + %% - SequenceProxyPushSupplier + %% - StructuredProxyPushSupplier + %% - ProxyPullSupplier + %% - SequenceProxyPullSupplier + %% - StructuredProxyPullSupplier + %% + %% + %% We will not use any Filters to begin with, just want to make sure we can + %% deliver events from all start- to end-points. + + %% Create the Admin objects + {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'AND_OP')), + {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'AND_OP')), + + %% Create Suppliers Proxies + {ProxyPullSupplier,_ID1}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'ANY_EVENT')), + {StructuredProxyPullSupplier,_ID2}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'STRUCTURED_EVENT')), + {SequenceProxyPullSupplier,_ID3}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'SEQUENCE_EVENT')), + + {ProxyPushSupplier,_I4D}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'ANY_EVENT')), + {StructuredProxyPushSupplier,_ID5}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'STRUCTURED_EVENT')), + {SequenceProxyPushSupplier,_ID6}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'SEQUENCE_EVENT')), + + %% Now we must create a Client for each proxy and connect them. + PushAnyC=?match({_,key,_,_,_,_}, 'notify_test_AnyPushC':oe_create(['PUSH_ANY', ProxyPushSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_ProxyPushSupplier':connect_any_push_consumer(ProxyPushSupplier, PushAnyC)), + + PushStrC=?match({_,key,_,_,_,_}, 'notify_test_StrPushC':oe_create(['PUSH_STRUCTURED',StructuredProxyPushSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':connect_structured_push_consumer(StructuredProxyPushSupplier, PushStrC)), + + PushSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',SequenceProxyPushSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(SequenceProxyPushSupplier, PushSeqC)), + + PullAnyC=?match({_,key,_,_,_,_}, 'notify_test_AnyPullC':oe_create(['PULL_ANY', ProxyPullSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_ProxyPullSupplier':connect_any_pull_consumer(ProxyPullSupplier, PullAnyC)), + + PullStrC=?match({_,key,_,_,_,_}, 'notify_test_StrPullC':oe_create(['PULL_STRUCTURED',StructuredProxyPullSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':connect_structured_pull_consumer(StructuredProxyPullSupplier, PullStrC)), + + PullSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPullC':oe_create(['PULL_SEQUENCE',SequenceProxyPullSupplier], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':connect_sequence_pull_consumer(SequenceProxyPullSupplier, PullSeqC)), + + + %% Create Consumers Proxies + {ProxyPullConsumer,_ID7}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(AdminSupplier, 'ANY_EVENT')), + {StructuredProxyPullConsumer,_ID8}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(AdminSupplier, 'STRUCTURED_EVENT')), + {SequenceProxyPullConsumer,_ID9}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(AdminSupplier, 'SEQUENCE_EVENT')), + + {ProxyPushConsumer,_ID10}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'ANY_EVENT')), + {StructuredProxyPushConsumer,_ID11}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'STRUCTURED_EVENT')), + {SequenceProxyPushConsumer,_ID12}=?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'SEQUENCE_EVENT')), + + %% Now we must create a Client for each proxy and connect them. + PushAnyS=?match({_,key,_,_,_,_}, 'notify_test_AnyPushS':oe_create(['PUSH_ANY', ProxyPushConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_ProxyPushConsumer':connect_any_push_supplier(ProxyPushConsumer, PushAnyS)), + + PushStrS=?match({_,key,_,_,_,_}, 'notify_test_StrPushS':oe_create(['PUSH_STRUCTURED',StructuredProxyPushConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':connect_structured_push_supplier(StructuredProxyPushConsumer, PushStrS)), + + PushSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',SequenceProxyPushConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(SequenceProxyPushConsumer, PushSeqS)), + + PullAnyS=?match({_,key,_,_,_,_}, 'notify_test_AnyPullS':oe_create(['PULL_ANY', ProxyPullConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_ProxyPullConsumer':connect_any_pull_supplier(ProxyPullConsumer, PullAnyS)), + + PullStrS=?match({_,key,_,_,_,_}, 'notify_test_StrPullS':oe_create(['PULL_STRUCTURED',StructuredProxyPullConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':connect_structured_pull_supplier(StructuredProxyPullConsumer, PullStrS)), + + PullSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPullS':oe_create(['PULL_SEQUENCE',SequenceProxyPullConsumer], + [{local_typecheck, false}])), + ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':connect_sequence_pull_supplier(SequenceProxyPullConsumer, PullSeqS)), + + + %% Create a couple of Events to test with. + Event = ?not_CreateSE("DomainName","CommunicationsAlarm", + "lost_packet", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 1)}], + [], any:create(orber_tc:null(), null)), + + Event2 = ?not_CreateSE("DomainName","TemperatureAlarm", + "over_heated", + [#'CosNotification_Property'{name="priority", + value=any:create(orber_tc:short(), 10)}], + [], any:create(orber_tc:null(), null)), + + + AnyEvent = any:create(orber_tc:long(), 100), + + StrEvent = ?not_CreateSE("","%ANY","",[],[],AnyEvent), + NilAnyEvent = any:create(orber_tc:null(), null), + NilStrEvent = ?not_CreateSE("","","",[],[],NilAnyEvent), + + ConvertedStr = any:create('CosNotification_StructuredEvent':tc(), Event), + + io:format("###################### PUSH STRUCTURED ########################"), + + %% Test with pushing a structured event. + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Check if the Clients have received and stored the events. + ?match([{any,_,Event}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([Event], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([Event], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match({any,_,Event}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([Event], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), + + io:format("###################### PUSH SEQUENCE ########################"), + + %% Create an Event Sequence and push it. + EventSeq = [Event, Event2], + + %% Test with pushing a event sequence. + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, EventSeq)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Instruct the Clients to pull the events and check if they match. + ?match({any,_,Event}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([Event,Event2], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,2})), + ?match({any,_,Event2}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(Event2, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + %% Check if the Push Clients have received and stored the events. + ?match([{any,_,Event}, {any,_,Event2}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([Event, Event2], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([Event, Event2], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + io:format("###################### PUSH ANY ########################"), + + %% Test with pushing an any event. + ?match(ok,'CosEventChannelAdmin_ProxyPushConsumer':push(ProxyPushConsumer, AnyEvent)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Check if the Clients have received and stored the events. + ?match([AnyEvent], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([StrEvent], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([StrEvent], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match(AnyEvent, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(StrEvent, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([StrEvent], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,10})), + + + + io:format("###################### PUSH CONVERTED ANY #############"), + + %% Test with pushing a structured event. + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, StrEvent)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Check if the Clients have received and stored the events. + ?match([AnyEvent], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([StrEvent], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([StrEvent], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match(AnyEvent, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(StrEvent, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([StrEvent], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), + + + io:format("###################### PUSH CONVERTED STRUCTURED ########"), + + %% Test with pushing an any event. + ?match(ok,'CosEventChannelAdmin_ProxyPushConsumer':push(ProxyPushConsumer, ConvertedStr)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Check if the Clients have received and stored the events. + ?match([ConvertedStr], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([Event], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([Event], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match(ConvertedStr, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([Event], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,10})), + + + io:format("###################### TRY PULL ########################"), + + %% Now we will push an any event after a delay. This means that try_pull-functions, + %% since it's not blocking, will return, [], NilAny or NilStructured events and + %% the Boolean false. + spawn(notify_test_impl, delay, [ProxyPushConsumer, AnyEvent, 20000, + 'CosEventChannelAdmin_ProxyPushConsumer',push]), + ?match([], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match({NilAnyEvent,false}, 'notify_test_AnyPullC':doAction(PullAnyC, try_pull_any)), + ?match({NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), + ?match({[],false}, 'notify_test_SeqPullC':doAction(PullSeqC, {try_pull_seq,10})), + + + %% Instruct the Clients to pull the events and check if they match. + %% Pull is blocking so in the print-out we should see that nothing + %% is returned until the pushed event reaches the end proxies. + ?match(AnyEvent, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(StrEvent, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([StrEvent], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), + + %% To make sure there are no other circumstanses which lead to a delay we + %% hold for some time. + timer:sleep(5000), + %% Check if the Clients have received and stored the events. + ?match([AnyEvent], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([StrEvent], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([StrEvent], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Test with pushing a event sequence but only pull sequences of length 1. + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, EventSeq)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + %% Pull 1 event at a time. + ?match([Event], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), + ?match([Event2], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), + + %% Following cases already tested; done for clean up. + ?match({any,_,Event}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match({any,_,Event2}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(Event2, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([{any,_,Event}, {any,_,Event2}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([Event, Event2], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([Event, Event2], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + %% clean up done + + + io:format("###################### PROXY PULLER ########################"), + + %% Now we will just add Events to a cleint and wait for the Notification service + %% to pull the events and forward them to the consumer clients. + ?match(ok, 'notify_test_SeqPushC':doAction(PullAnyS, {set_data, [AnyEvent]})), + + + %% Instruct the Clients to pull the events and check if they match. + %% Pull is blocking so in the print-out we should see that nothing + %% is returned until the pushed event reaches the end proxies. + ?match(AnyEvent, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(StrEvent, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([StrEvent], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,10})), + + %% To make sure there are no other circumstanses which lead to a delay we + %% hold for some time. + timer:sleep(5000), + %% Check if the Clients have received and stored the events. + ?match([AnyEvent], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([StrEvent], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([StrEvent], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + io:format("###################### SUSPENDED CONNECTION ################"), + + + %% Suspend the connections + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushSupplier':suspend_connection(SequenceProxyPushSupplier)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushSupplier':suspend_connection(StructuredProxyPushSupplier)), + + %% Test with pushing a event sequence. + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, EventSeq)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Instruct the Clients to pull the events and check if they match. + ?match({any,_,Event}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([Event,Event2], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,2})), + ?match({any,_,Event2}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(Event2, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + + %% Check if the Any Client have received and stored the events. + ?match([{any,_,Event}, {any,_,Event2}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + + %% Check if the other Clients have received any events. Error if have. + ?match([], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushSupplier':resume_connection(SequenceProxyPushSupplier)), + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushSupplier':resume_connection(StructuredProxyPushSupplier)), + + %% To be sure the test case don't fail due to time-race, sleep. + timer:sleep(5000), + + ?match([Event, Event2], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([Event, Event2], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + + io:format("###################### FILTER EVENTS #######################"), + + %% Now we will add filters and see if the system behaves correctly. + FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), + Filter = 'CosNotifyFilter_FilterFactory':create_filter(FiFac,"EXTENDED_TCL"), + %% Add constraints to the Filter + ?line[{_,_,CID1},{_,_,CID2}]= + ?match([{'CosNotifyFilter_ConstraintInfo',_,_}, {'CosNotifyFilter_ConstraintInfo',_,_}], + 'CosNotifyFilter_Filter':add_constraints(Filter, + [#'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "Spare*", + type_name = "MOVIE"}], + constraint_expr = "$type_name == 'MOVIE' and (('groucho' in $starlist) + ('chico' in $starlist) + ('harpo' in $starlist) + ('zeppo' in $starlist) + ('gummo' in $starlist)) > 2"}, + #'CosNotifyFilter_ConstraintExp'{event_types = + [#'CosNotification_EventType'{ + domain_name = "*", + type_name = "TestResults"}], + constraint_expr = "$test._length == 3 and ($test[0].score + $test[1].score + $test[2].score)/3 >=80"}])), + + ?match([{'CosNotifyFilter_ConstraintInfo',_,CID2}, {'CosNotifyFilter_ConstraintInfo',_,CID1}], + 'CosNotifyFilter_Filter':get_all_constraints(Filter)), + ?match([{'CosNotifyFilter_ConstraintInfo',_,CID1}], + 'CosNotifyFilter_Filter':get_constraints(Filter, [CID1])), + + %% Associate the Filter with different objects. + %% Since we use the same filter for both objects the events will never reach the admin. + _FilterID = 'CosNotifyChannelAdmin_ConsumerAdmin':add_filter(AdminConsumer, Filter), + + _FilterID2 = 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':add_filter(StructuredProxyPushConsumer, Filter), + event_filtering(FiFac, Filter, AdminConsumer, StructuredProxyPushConsumer, PushAnyC, + PushStrC, PushSeqC, PullAnyC, PullStrC, PullSeqC), + %% Remove the proxy filter so we can check if the events are filtered correctly by the admin. + ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':remove_all_filters(StructuredProxyPushConsumer)), + event_filtering(FiFac, Filter, AdminConsumer, StructuredProxyPushConsumer, PushAnyC, + PushStrC, PushSeqC, PullAnyC, PullStrC, PullSeqC), + + + catch corba:dispose(Filter), + catch corba:dispose(FiFac), + catch corba:dispose(SequenceProxyPushConsumer), + catch corba:dispose(StructuredProxyPushConsumer), + catch corba:dispose(ProxyPushConsumer), + catch corba:dispose(SequenceProxyPullConsumer), + catch corba:dispose(StructuredProxyPullConsumer), + catch corba:dispose(ProxyPullConsumer), + catch corba:dispose(SequenceProxyPushSupplier), + catch corba:dispose(StructuredProxyPushSupplier), + catch corba:dispose(ProxyPushSupplier), + catch corba:dispose(SequenceProxyPullSupplier), + catch corba:dispose(StructuredProxyPullSupplier), + catch corba:dispose(ProxyPullSupplier), + catch corba:dispose(AdminConsumer), + catch corba:dispose(AdminSupplier), + catch corba:dispose(Ch), + catch cosNotificationApp:stop_factory(Fac), + %% The Clients should have terminated by now. Check if it is so. + timer:sleep(5000), + ?match(true, corba_object:non_existent(PullSeqS)), + ?match(true, corba_object:non_existent(PullStrS)), + ?match(true, corba_object:non_existent(PullAnyS)), + ?match(true, corba_object:non_existent(PushSeqS)), + ?match(true, corba_object:non_existent(PushStrS)), + ?match(true, corba_object:non_existent(PushAnyS)), + ?match(true, corba_object:non_existent(PullSeqC)), + ?match(true, corba_object:non_existent(PullStrC)), + ?match(true, corba_object:non_existent(PullAnyC)), + ?match(true, corba_object:non_existent(PushSeqC)), + ?match(true, corba_object:non_existent(PushStrC)), + ?match(true, corba_object:non_existent(PushAnyC)), + ok. + +event_filtering(_FiFac, _Filter, _AdminConsumer, StructuredProxyPushConsumer, PushAnyC, PushStrC, PushSeqC, PullAnyC, PullStrC, PullSeqC) -> + NilAnyEvent = any:create(orber_tc:null(), null), + NilStrEvent = ?not_CreateSE("","","",[],[],NilAnyEvent), + + TrueEvent1 = ?not_CreateSE("SpareTime","MOVIE", + "EventName", + [#'CosNotification_Property'{name="starlist", + value=any:create(orber_tc:sequence(orber_tc:string(0),0), + ["groucho", "harpo", "sam", "gummo"])}], + [], any:create(orber_tc:null(), null)), + TrueEvent2 = ?not_CreateSE("Studies","TestResults", + "EventName", [], + [#'CosNotification_Property'{name="test", + value=any:create(orber_tc:array(notify_test_data:tc(),3), + {#notify_test_data{score=75, + name="name"}, + #notify_test_data{score=80, + name="name"}, + #notify_test_data{score=85, + name="name"}})}], + any:create(orber_tc:null(), null)), + + FalseEvent1 = ?not_CreateSE("SpareTime","MOVIE", + "EventName", + [#'CosNotification_Property'{name="starlist", + value=any:create(orber_tc:sequence(orber_tc:string(0),0), + ["frodo", "bilbo", "sam", "gummo"])}], + [], any:create(orber_tc:null(), null)), + FalseEvent2 = ?not_CreateSE("Studies","TestResults", + "EventName", [], + [#'CosNotification_Property'{name="test", + value=any:create(orber_tc:array(notify_test_data:tc(),3), + {#notify_test_data{score=75, + name="name"}, + #notify_test_data{score=80, + name="name"}, + #notify_test_data{score=80, + name="name"}})}], + any:create(orber_tc:null(), null)), + %% Test with pushing the first structured event that should not be filtered away. + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, TrueEvent1)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Check if the Clients have received and stored the events. + ?match([{any,_,TrueEvent1}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([TrueEvent1], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([TrueEvent1], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match({any,_,TrueEvent1}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(TrueEvent1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([TrueEvent1], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), + + %% Test with pushing the second structured event that should not be filtered away. + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, TrueEvent2)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Check if the Clients have received and stored the events. + ?match([{any,_,TrueEvent2}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([TrueEvent2], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([TrueEvent2], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match({any,_,TrueEvent2}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), + ?match(TrueEvent2, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), + ?match([TrueEvent2], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), + + %% Test with pushing the first structured event that should be filtered away. + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, FalseEvent1)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Check if the Clients have received and stored the events. + ?match([], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match({NilAnyEvent,false}, 'notify_test_AnyPullC':doAction(PullAnyC, try_pull_any)), + ?match({NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), + ?match({[],false}, 'notify_test_SeqPullC':doAction(PullSeqC, {try_pull_seq,10})), + + %% Test with pushing the second structured event that should be filtered away. + ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, FalseEvent2)), + + %% Wait for a while so we are sure that all events have been delivered as far + %% as the Notification service can automatically. + timer:sleep(5000), + + %% Check if the Clients have received and stored the events. + ?match([], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), + ?match([], 'notify_test_StrPushC':doAction(PushStrC, return_data)), + ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), + + %% Instruct the Clients to pull the events and check if they match. + ?match({NilAnyEvent,false}, 'notify_test_AnyPullC':doAction(PullAnyC, try_pull_any)), + ?match({NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), + ?match({[],false}, 'notify_test_SeqPullC':doAction(PullSeqC, {try_pull_seq,10})). + + + +%%----------------------------------------------------------------- +%% Creating different cosEvent API tests +%%----------------------------------------------------------------- +cosevent_api(doc) -> ["CosNotification Objects tested with CosEvent API", ""]; +cosevent_api(suite) -> []; +cosevent_api(_Config) -> + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + AC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_EventChannel':for_consumers(Ch)), + AS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_EventChannel':for_suppliers(Ch)), + + PushS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_ConsumerAdmin':obtain_push_supplier(AC)), + PullS=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_ConsumerAdmin':obtain_pull_supplier(AC)), + + PushC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_SupplierAdmin':obtain_push_consumer(AS)), + PullC=?match({_,key,_,_,_,_}, + 'CosEventChannelAdmin_SupplierAdmin':obtain_pull_consumer(AS)), + + PushAnyC=?match({_,key,_,_,_,_}, + 'notify_test_AnyPushC':oe_create(['PUSH_ANY', PushC], + [{local_typecheck, false}])), + PushStrC=?match({_,key,_,_,_,_}, + 'notify_test_StrPushC':oe_create(['PUSH_STRUCTURED',false], + [{local_typecheck, false}])), + PushSeqC=?match({_,key,_,_,_,_}, + 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',false], + [{local_typecheck, false}])), + + PullAnyC=?match({_,key,_,_,_,_}, + 'notify_test_AnyPullC':oe_create(['PULL_ANY', PullC], + [{local_typecheck, false}])), + PullStrC=?match({_,key,_,_,_,_}, + 'notify_test_StrPullC':oe_create(['PULL_STRUCTURED',false], + [{local_typecheck, false}])), + PullSeqC=?match({_,key,_,_,_,_}, + 'notify_test_SeqPullC':oe_create(['PULL_SEQUENCE',false], + [{local_typecheck, false}])), + + PushAnyS=?match({_,key,_,_,_,_}, + 'notify_test_AnyPushS':oe_create(['PUSH_ANY', PushC], + [{local_typecheck, false}])), + PushStrS=?match({_,key,_,_,_,_}, + 'notify_test_StrPushS':oe_create(['PUSH_STRUCTURED',false], + [{local_typecheck, false}])), + PushSeqS=?match({_,key,_,_,_,_}, + 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',false], + [{local_typecheck, false}])), + + PullAnyS=?match({_,key,_,_,_,_}, + 'notify_test_AnyPullS':oe_create(['PULL_ANY', PullS], + [{local_typecheck, false}])), + PullStrS=?match({_,key,_,_,_,_}, + 'notify_test_StrPullS':oe_create(['PULL_STRUCTURED',false], + [{local_typecheck, false}])), + PullSeqS=?match({_,key,_,_,_,_}, + 'notify_test_SeqPullS':oe_create(['PULL_SEQUENCE',false], + [{local_typecheck, false}])), + + %% In the OMG specification Proxies do not inherrit from CosEvent. Must use + %% Notify interface. + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, + 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PullC, PushStrS)), + + ?match(ok, + 'CosEventChannelAdmin_ProxyPushSupplier':connect_push_consumer(PushS, PushAnyC)), + ?match(ok, + 'CosEventChannelAdmin_ProxyPullSupplier':connect_pull_consumer(PullS, PullAnyC)), + + ?match(ok, + 'CosEventChannelAdmin_ProxyPushConsumer':connect_push_supplier(PushC, PushAnyS)), + ?match(ok, + 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PullC, PullAnyS)), + + ?match({'EXCEPTION',{'CosEventChannelAdmin_AlreadyConnected',_}}, + 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PullC, PullAnyS)), + + ?match({'EXCEPTION',{'CosEventChannelAdmin_AlreadyConnected',_}}, + 'CosNotifyChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PullC, PullAnyS)), + + ?match(true, corba_object:is_a(PushS, "IDL:omg.org/CosNotifyChannelAdmin/ProxyPushSupplier:1.0")), + ?match(true, corba_object:is_a(PushS, "IDL:omg.org/CosEventChannelAdmin/ProxyPushSupplier:1.0")), + + catch corba:dispose(PushStrC), + catch corba:dispose(PushSeqC), + catch corba:dispose(PullStrC), + catch corba:dispose(PullSeqC), + catch corba:dispose(PushStrS), + catch corba:dispose(PushSeqS), + catch corba:dispose(PullStrS), + catch corba:dispose(PullSeqS), + catch corba:dispose(PushS), + catch corba:dispose(PullS), + catch corba:dispose(PushC), + catch corba:dispose(PullC), + catch corba:dispose(AC), + catch corba:dispose(AS), + catch corba:dispose(Ch), + catch cosNotificationApp:stop_factory(Fac), + + %% The Clients should have terminated by now. Check if it is so. + timer:sleep(5000), + ?match(true, corba_object:non_existent(PullAnyS)), + ?match(true, corba_object:non_existent(PushAnyS)), + ?match(true, corba_object:non_existent(PullAnyC)), + ?match(true, corba_object:non_existent(PushAnyC)), + + + ok. + +%%----------------------------------------------------------------- +%% AdminPropertiesAdmin API tests +%%----------------------------------------------------------------- +adm_api(doc) -> ["CosNotification AdminPropertiesAdmin tests", ""]; +adm_api(suite) -> []; +adm_api(_Config) -> + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + + %% We need a few AdminProp:s to "play" with. + MQ0 = [#'CosNotification_Property'{name='CosNotification':'MaxQueueLength'(), + value=any:create(orber_tc:long(), 0)}], + MC0 = [#'CosNotification_Property'{name='CosNotification':'MaxConsumers'(), + value=any:create(orber_tc:long(), 0)}], + MS0 = [#'CosNotification_Property'{name='CosNotification':'MaxSuppliers'(), + value=any:create(orber_tc:long(), 0)}], + MQError1 = [#'CosNotification_Property'{name='CosNotification':'MaxQueueLength'(), + value=any:create(orber_tc:'float'(), 1.5)}], + MQError2 = [#'CosNotification_Property'{name='CosNotification':'MaxQueueLength'(), + value=any:create(orber_tc:long(), -1)}], + + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + + %% Set new admin + ?match(ok, 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MQ0)), + %% It should be a list of three items. If we support more admin:s this + %% must be updated. + ?match([_,_,_], 'CosNotification_AdminPropertiesAdmin':get_admin(Ch)), + + %% Try to set admin with an uncorrect value, i.e., not integer >= 0. + ?match({'EXCEPTION',{'CosNotification_UnsupportedAdmin',_,_}}, + 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MQError1)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedAdmin',_,_}}, + 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MQError2)), + + %% Try setting the other two admins and chech if the value is correct. + ?match(ok, 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MC0)), + ?match([_,_,_], 'CosNotification_AdminPropertiesAdmin':get_admin(Ch)), + + ?match(ok, 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MS0)), + ?match([_,_,_], 'CosNotification_AdminPropertiesAdmin':get_admin(Ch)), + + catch corba:dispose(Ch), + catch cosNotificationApp:stop_factory(Fac), + ok. + + +%%----------------------------------------------------------------- +%% QoSAdm API tests +%%----------------------------------------------------------------- +qos_api(doc) -> ["CosNotification QoSAdmin tests", ""]; +qos_api(suite) -> []; +qos_api(_Config) -> + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), + ?match({_,key,_,_,_,_}, Ch), + + + QoSPersistent = [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + QoSBestEffort = [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'BestEffort'())}], + + QoSEventPersistent = [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + QoSEventBestEffort = [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'BestEffort'())}], + + QoSOKMaxBatchSize = [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), + value=any:create(orber_tc:long(), 200)}], + QoSToHighMaxBatchSize = [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), + value=any:create(orber_tc:long(), 100000000)}], + + QoSToLowMaxBatchSize = [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), + value=any:create(orber_tc:long(), -1)}], + + QoSOKStopTimeSupp = [#'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), + value=any:create(orber_tc:boolean(), true)}], + QoSWrongStopTimeSupp = [#'CosNotification_Property'{name="StopTimeSupp", + value=any:create(orber_tc:boolean(), true)}], + + QoSOKStartTimeSupp = [#'CosNotification_Property'{name='CosNotification':'StartTimeSupported'(), + value=any:create(orber_tc:boolean(), true)}], + QoSWrongStartTimeSupp = [#'CosNotification_Property'{name="StartTimeSupp", + value=any:create(orber_tc:boolean(), true)}], + QoSOKTimout = [#'CosNotification_Property'{name='CosNotification':'Timeout'(), + value=any:create(orber_tc:unsigned_long_long(), 100)}], + + + %% The most complex QoS to set is ConnectionReliability, and the reason for this + %% is that we cannot set the Channel to offer best effort while its children + %% offer persistent. A child may only offer Persistent if its parent do, which + %% is why we must check the following: + %% + %% # Persistent Change to Best Effort + %% _____ + %% | | (1) -> Check if children BE + %% |Chann| (2) ok <- + %% ----- + %% | + %% _____ + %% | | (3) -> Check if children BE + %% |Admin| (4) Check if parent Pers. <- + %% ----- + %% | + %% _____ + %% | | (5) -> ok + %% |Proxy| (6) Check if parent Pers. <- + %% ----- + %% NOTE: a parent always exists but we may change the QoS before creating any + %% childrens. The cases (2) and (5) is always ok, i.e., no need to confirm + %% with parent or children. + + %% We only have a channel. At the moment we can set ConnectionReliability + %% without asking anyone. + Q1='CosNotification_QoSAdmin':get_qos(Ch), + ?match({ok, _}, 'CosNotification_QoSAdmin':validate_qos(Ch, QoSBestEffort)), + + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), + %% Match if no problems occur if we try to set QoS as is. + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), + + %% Check validate. + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), + ?match({ok, _}, 'CosNotification_QoSAdmin':validate_qos(Ch, QoSOKTimout)), + ?match({ok, _}, 'CosNotification_QoSAdmin':validate_qos(Ch, QoSEventBestEffort)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventBestEffort)), + ?match({ok, _}, 'CosNotification_QoSAdmin':validate_qos(Ch, QoSOKTimout)), + + Q2='CosNotification_QoSAdmin':get_qos(Ch), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), + ?match(Q1, 'CosNotification_QoSAdmin':get_qos(Ch)), + + %% Now we add an Admin object. An Admin object cannot switch ConnectionReliability + %% to BestEffort without checking with its children or Persistent without + %% confirming this with its Parent. At the moment, however, we only have a parent. + {CAdm, Id2} = 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch, 'AND_OP'), + ?match(Q1,'CosNotification_QoSAdmin':get_qos(CAdm)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(CAdm, QoSPersistent)), + ?match(Q1, 'CosNotification_QoSAdmin':get_qos(CAdm)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(CAdm, QoSBestEffort)), + ?match(Q1, 'CosNotification_QoSAdmin':get_qos(CAdm)), + + %% Check if we can extract the Admin from the channel correctly. + ?match([0,Id2],'CosNotifyChannelAdmin_EventChannel':get_all_consumeradmins(Ch)), + ?match(CAdm,'CosNotifyChannelAdmin_EventChannel':get_consumeradmin(Ch, Id2)), + ?match(Ch, 'CosNotifyChannelAdmin_ConsumerAdmin':'_get_MyChannel'(CAdm)), + ?match(Id2, 'CosNotifyChannelAdmin_ConsumerAdmin':'_get_MyID'(CAdm)), + + %% Change the channel to provide Persistent service. Now we can set the + %% Admin service to Persistent to. (4) + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(CAdm, QoSPersistent)), + ?match(Q2, 'CosNotification_QoSAdmin':get_qos(CAdm)), + + %% Since the Admin object now provide Persistent the Channel cannot switch + %% to BestEffort. (1) + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), + %% Should still match Persistent. + ?match(Q2, 'CosNotification_QoSAdmin':get_qos(Ch)), + {PSup, _Id3} = 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(CAdm, 'ANY_EVENT'), + ?match(Q2, 'CosNotification_QoSAdmin':get_qos(CAdm)), + ?match('PUSH_ANY', 'CosNotifyChannelAdmin_ProxyPushConsumer':'_get_MyType'(PSup)), + ?match(CAdm, 'CosNotifyChannelAdmin_ProxyPushConsumer':'_get_MyAdmin'(PSup)), + ?match(Q2, 'CosNotification_QoSAdmin':get_qos(PSup)), + + %% At this point they all offer persistent connection, which means we have + %% to start with the proxy if we want to change to Best Effort. Hence, + %% the following two cases will fail. + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(CAdm, QoSBestEffort)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, QoSBestEffort)), + %% Still not possible to change channel to Best Effort. + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(CAdm, QoSBestEffort)), + %% Now we change the channel to Best Effort. + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), + + %% Test if really are Best Effort + ?match(Q1, 'CosNotification_QoSAdmin':get_qos(Ch)), + ?match(Q1, 'CosNotification_QoSAdmin':get_qos(CAdm)), + ?match(Q1, 'CosNotification_QoSAdmin':get_qos(PSup)), + + %% Testing MaximumBatchSize (The highest value is defined in + %% CosNotification_Common.erl + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSOKMaxBatchSize)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(Ch, QoSToHighMaxBatchSize)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(Ch, QoSToLowMaxBatchSize)), + + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSOKStartTimeSupp)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSOKStopTimeSupp)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(Ch, QoSWrongStartTimeSupp)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(Ch, QoSWrongStopTimeSupp)), + + catch corba:dispose(CAdm), + catch corba:dispose(PSup), + catch corba:dispose(Ch), + cosNotificationApp:stop_factory(Fac), + ok. + +%%----------------------------------------------------------------- +%% QoSAdm API tests +%%----------------------------------------------------------------- +event_qos_api(doc) -> ["CosNotification QoSAdmin tests", ""]; +event_qos_api(suite) -> []; +event_qos_api(_Config) -> + Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), + ?match({_,key,_,_,_,_}, Fac), + + %% Create some objects to test with. We start with default settings. + {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), + {CAdm, _Id2} = 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch, 'AND_OP'), + {PSup, _Id3} = 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(CAdm, 'ANY_EVENT'), + + %% Try setting an unsupported QoS. + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name="Unsupported QoS", + value=any:create(orber_tc:short(), 1)}])), + %% Try setting min and max priority. + ?match({ok, _}, 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_Priority, + value=any:create(orber_tc:short(), + ?not_LowestPriority)}, + #'CosNotification_Property'{name=?not_Priority, + value=any:create(orber_tc:short(), + ?not_HighestPriority)}])), + %% Try setting priority values which are 1 to high and 1 to low respectively. + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_Priority, + value=any:create(orber_tc:short(), + ?not_LowestPriority-1)}, + #'CosNotification_Property'{name=?not_Priority, + value=any:create(orber_tc:short(), + ?not_HighestPriority+1)}])), + %% Try setting start- and stop-time (false default). Note the value associated + %% with this property is not really a short but that is not what we are testing + %% here so... + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_StartTime, + value=any:create(orber_tc:short(), 0)}])), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_StopTime, + value=any:create(orber_tc:short(), 0)}])), + %% Allow StopTime + ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, [#'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), + value=any:create(orber_tc:boolean(), true)}])), + ?match({ok,_}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_StopTime, + value=any:create(orber_tc:short(), 0)}])), + %% Allow StartTime + ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, [#'CosNotification_Property'{name='CosNotification':'StartTimeSupported'(), + value=any:create(orber_tc:boolean(), true)}])), + ?match({ok,_}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_StopTime, + value=any:create(orber_tc:short(), 0)}, + #'CosNotification_Property'{name=?not_StartTime, + value=any:create(orber_tc:short(), 0)}])), + + %% We must reset StopTime since we cannot guarantee that an event will be delivered + %% if risk beeing discarded due to a delay. + ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, [#'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), + value=any:create(orber_tc:boolean(), false)}])), + %% Does it accept Best Effort EventReliability? Must always be true. + ?match({ok,_}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_EventReliability, + value=any:create(orber_tc:short(), ?not_BestEffort)}])), + %% Default is Best Effort; test if we can set Persistent EventReliability. + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_EventReliability, + value=any:create(orber_tc:short(), ?not_Persistent)}])), + + %% Set Persistent + QoSPersistent = [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(CAdm, QoSPersistent)), + ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, QoSPersistent)), + + %% Does it accept Best Effort EventReliability? Must always be true. + ?match({ok, _}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_EventReliability, + value=any:create(orber_tc:short(), ?not_BestEffort)}])), + %% Test if we can use Persistent EventReliability. + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_EventReliability, + value=any:create(orber_tc:short(), ?not_Persistent)}])), + QoSEventPersistent = [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), + value=any:create(orber_tc:short(), + 'CosNotification':'Persistent'())}], + ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(CAdm, QoSEventPersistent)), + ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, + 'CosNotification_QoSAdmin':set_qos(PSup, QoSEventPersistent)), + + ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, [#'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), + value=any:create(orber_tc:boolean(), true)}])), + ?match({ok,_}, + 'CosNotifyChannelAdmin_ProxyConsumer': + validate_event_qos(PSup, + [#'CosNotification_Property'{name=?not_StopTime, + value=any:create(orber_tc:short(), 0)}, + #'CosNotification_Property'{name=?not_StartTime, + value=any:create(orber_tc:short(), 0)}])), + catch corba:dispose(CAdm), + catch corba:dispose(PSup), + catch corba:dispose(Ch), + cosNotificationApp:stop_factory(Fac), + ok. + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- + +%%-------------------- End of Module ------------------------------ diff --git a/lib/cosNotification/test/notify_test_impl.erl b/lib/cosNotification/test/notify_test_impl.erl new file mode 100644 index 0000000000..483610befd --- /dev/null +++ b/lib/cosNotification/test/notify_test_impl.erl @@ -0,0 +1,299 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%---------------------------------------------------------------------- +%% File : notify_test_impl.erl +%%---------------------------------------------------------------------- + +-module(notify_test_impl). + +-include_lib("orber/include/corba.hrl"). +-include("idl_output/notify_test.hrl"). + +%%--------------- specified functions ------------------------ +-export([stop_normal/2, + stop_brutal/2, + print/2, + doAction/3, + delay/5, + %% Exports from CosNotifyComm::StructuredPushConsumer + push_structured_event/3, disconnect_structured_push_consumer/2, + %% Exports from "CosNotifyComm::SequencePushConsumer" + push_structured_events/3, disconnect_sequence_push_consumer/2, + %% Exports from CosEventComm::PushConsumer + push/3, disconnect_push_consumer/2, + %% Exports from CosNotifyComm::NotifyPublish + disconnect_sequence_pull_consumer/2, + %% Exports from CosNotifyComm::StructuredPullConsumer + disconnect_structured_pull_consumer/2, + %% Exports from CosEventComm::PullConsumer + disconnect_pull_consumer/2, + %% Exports from CosNotifyComm::SequencePushSupplier + disconnect_sequence_push_supplier/2, + %% Exports from CosNotifyComm::StructuredPushSupplier + disconnect_structured_push_supplier/2, + %% Exports from CosEventComm::PushSupplier + disconnect_push_supplier/2, + %% Exports from CosNotifyComm::SequencePullSupplier + pull_structured_events/3, + try_pull_structured_events/3, + disconnect_sequence_pull_supplier/2, + %% Exports from CosNotifyComm::StructuredPullSupplier + pull_structured_event/2, + try_pull_structured_event/2, + disconnect_structured_pull_supplier/2, + %% Exports from CosEventComm::PullSupplier + pull/2, + try_pull/2, + disconnect_pull_supplier/2, + %% Exports from CosNotifyComm::SequencePullConsumer + offer_change/4, + %% Exports from CosNotifyComm::NotifySubscribe + subscription_change/4]). + +%%--------------- gen_server specific ------------------------ +-export([init/1, terminate/2]). +-export([handle_call/3, handle_cast/2, handle_info/2, code_change/3]). +%% Data structures +-record(state, {myType, proxy, data, action}). + +%%--------------- LOCAL DATA --------------------------------- + +%%------------------------------------------------------------ +%% function : init, terminate +%%------------------------------------------------------------ +init([MyType, Proxy]) -> + process_flag(trap_exit,true), + {ok, #state{myType=MyType, proxy=Proxy, data=[]}}. + +terminate(Reason, State) -> + io:format("notify_test:terminate(~p ~p)~n",[Reason, State#state.myType]), + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. +handle_call(_,_, State) -> + {noreply, State}. +handle_cast(_, State) -> + {noreply, State}. +handle_info(_Info, State) -> + {noreply, State}. + +%%--------------- SERVER FUNCTIONS --------------------------- + +print(Self, State) -> + io:format("notify_test:print(~p ~p)~n",[Self, State]), + {reply, ok, State}. + +doAction(_Self, State, {set_data, Data}) -> + io:format("notify_test:doAction(add_data) ~p~n",[Data]), + {reply, ok, State#state{data=Data}}; +doAction(_Self, State, {add_data, Data}) -> + io:format("notify_test:doAction(add_data) ~p~n",[Data]), + {reply, ok, State#state{data=State#state.data++Data}}; +doAction(_Self, State, return_data) -> + io:format("notify_test:doAction(return_data)~n",[]), + {reply, State#state.data, State#state{data=[]}}; +doAction(_Self, State, clear_data) -> + io:format("notify_test:doAction(return_data)~n",[]), + {reply, ok, State#state{data=[]}}; +doAction(_Self, State, pull_any) -> + io:format("notify_test:doAction(pull_any)~n",[]), + Event='CosNotifyChannelAdmin_ProxyPullSupplier':pull(State#state.proxy), + {reply, Event, State}; +doAction(_Self, State, {pull_seq, Max}) -> + io:format("notify_test:doAction(pull_sequence)~n",[]), + Event='CosNotifyChannelAdmin_SequenceProxyPullSupplier':pull_structured_events(State#state.proxy, Max), + {reply, Event, State}; +doAction(_Self, State, pull_str) -> + Event='CosNotifyChannelAdmin_StructuredProxyPullSupplier':pull_structured_event(State#state.proxy), + io:format("notify_test:doAction(pull_structured)~n",[]), + {reply, Event, State}; +doAction(_Self, State, try_pull_any) -> + io:format("notify_test:doAction(try_pull_any)~n",[]), + Event='CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(State#state.proxy), + {reply, Event, State}; +doAction(_Self, State, {try_pull_seq, Max}) -> + io:format("notify_test:doAction(try_pull_sequence)~n",[]), + Event='CosNotifyChannelAdmin_SequenceProxyPullSupplier':try_pull_structured_events(State#state.proxy, Max), + {reply, Event, State}; +doAction(_Self, State, try_pull_str) -> + Event='CosNotifyChannelAdmin_StructuredProxyPullSupplier':try_pull_structured_event(State#state.proxy), + io:format("notify_test:doAction(try_pull_structured)~n",[]), + {reply, Event, State}; +doAction(_Self, State, {action, Action}) -> + io:format("notify_test:doAction(~p)~n",[Action]), + {reply, ok, State#state{action = Action}}; + +doAction(_, State, _) -> + {reply, nop, State}. + +stop_normal(_Self, State) -> + {stop, normal, ok, State}. + +stop_brutal(_Self, _State) -> + exit("killed_brutal"). + + + +%%--------------- CosNotifyComm::NotifyPublish -------- +offer_change(_Self, State, Added, Removed) -> + ND=loop(Removed, State#state.data), + ND2=Added++ND, + {reply, ok, State#state{data=ND2}}. + +loop([],Data) -> + Data; +loop([H|T], Data) -> + ND=lists:delete(H,Data), + loop(T, ND). + +%%--------------- CosNotifyComm::NotifySubscribe -------- +subscription_change(_Self, State, Added, Removed) -> + ND=loop(Removed, State#state.data), + ND2=Added++ND, + {reply, ok, State#state{data=ND2}}. + +%%--------------- CosNotifyComm::SequencePushConsumer -------- +push_structured_events(_Self, #state{action = undefined} = State, Event) -> + io:format("notify_test:push_structured_events(~p)~n",[Event]), + {reply, ok, State#state{data=State#state.data++Event}}; +push_structured_events(_Self, #state{action = Action} = State, Event) -> + io:format("notify_test:push_structured_events(~p)~nAction: ~p~n", + [Event, Action]), + corba:raise(#'INTERNAL'{completion_status=?COMPLETED_NO}), + {reply, ok, State#state{data=State#state.data++Event}}. +disconnect_sequence_push_consumer(_Self, State) -> + io:format("disconnect_sequence_push_consumer~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosNotifyComm::StructuredPushConsumer -------- +push_structured_event(_Self, State, Event) -> + io:format("notify_test:push_structured_event(~p)~n",[Event]), + {reply, ok, State#state{data=State#state.data++[Event]}}. +disconnect_structured_push_consumer(_Self, State) -> + io:format("disconnect_structured_push_consumer~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosEventComm::PushConsumer -------- +push(_Self, State, Event) -> + io:format("notify_test:push(~p)~n",[Event]), + {reply, ok, State#state{data=State#state.data++[Event]}}. +disconnect_push_consumer(_Self, State) -> + io:format("disconnect_push_consumer~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosNotifyComm::SequencePullConsumer -------- +disconnect_sequence_pull_consumer(_Self, State) -> + io:format("disconnect_sequence_pull_consumer~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosNotifyComm::StructuredPullConsumer -------- +disconnect_structured_pull_consumer(_Self, State) -> + io:format("disconnect_structured_pull_consumer~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosEventComm::PullConsumer -------- +disconnect_pull_consumer(_Self, State) -> + io:format("disconnect_pull_consumer~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosNotifyComm::SequencePushSupplier -------- +disconnect_sequence_push_supplier(_Self, State) -> + io:format("disconnect_sequence_push_supplier~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosNotifyComm::StructuredPushSupplier -------- +disconnect_structured_push_supplier(_Self, State) -> + io:format("disconnect_structured_push_supplier~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosEventComm::PushSupplier -------- +disconnect_push_supplier(_Self, State) -> + io:format("disconnect_push_supplier~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosNotifyComm::SequencePullSupplier -------- +pull_structured_events(_Self, State, _Max) -> + io:format("notify_test:pullstructured_events()~n",[]), + {reply, ok, State}. +try_pull_structured_events(_Self, State, Max) -> + io:format("notify_test:try_pull_structured_events()~n",[]), + case State#state.data of + [] -> + {reply, {[],false}, State}; + List -> + R = split(List,Max), + {reply, {lists:sublist(List, Max), true}, State#state{data=R}} + end. + +split([],_) -> + []; +split(R,0) -> + R; +split([_H|T],Max) -> + split(T, Max-1). + +disconnect_sequence_pull_supplier(_Self, State) -> + io:format("disconnect_sequence_pull_supplier~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosNotifyComm::StructuredPullSupplier -------- +pull_structured_event(_Self, State) -> + io:format("notify_test:pull_structured_event()~n",[]), + {reply, ok, State}. +try_pull_structured_event(_Self, State) -> + io:format("notify_test:try_pull_structured_event()~n",[]), + case State#state.data of + [] -> + {reply, {[],false}, State}; + [H|T] -> + {reply, {H, true}, State#state{data=T}} + end. +disconnect_structured_pull_supplier(_Self, State) -> + io:format("disconnect_structured_pull_supplier~n",[]), + {stop, normal, ok, State}. + +%%--------------- CosEventComm::PullSupplier -------- +pull(_Self, State) -> + io:format("notify_test:pull()~n",[]), + {reply, 'CosEventComm_PullSupplier':pull(State#state.proxy), State}. +try_pull(_Self, State) -> + io:format("notify_test:try_pull()~n",[]), + case State#state.data of + [] -> + {reply, {[],false}, State}; + [H|T] -> + {reply, {H, true}, State#state{data=T}} + end. +disconnect_pull_supplier(_Self, State) -> + io:format("disconnect_pull_supplier~n",[]), + {stop, normal, ok, State}. + +%%--------------- LOCAL FUNCTIONS ---------------------------- + +delay(Obj, Event, Time, Mod, F) -> + io:format("notify_test:delay(~p) TIME: ~p~n",[Event, now()]), + timer:sleep(Time), + Mod:F(Obj, Event), + io:format("notify_test:delay() DONE: ~p~n",[now()]), + ok. + +%%--------------- END OF MODULE ------------------------------ + diff --git a/lib/cosNotification/test/notify_test_server.cfg b/lib/cosNotification/test/notify_test_server.cfg new file mode 100644 index 0000000000..8621327b57 --- /dev/null +++ b/lib/cosNotification/test/notify_test_server.cfg @@ -0,0 +1,54 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{this, "notify_test::SeqPushC"}. +{{handle_info, "notify_test::SeqPushC"}, true}. +{{impl, "notify_test::SeqPushC"}, "notify_test_impl"}. +{this, "notify_test::StrPushC"}. +{{handle_info, "notify_test::StrPushC"}, true}. +{{impl, "notify_test::StrPushC"}, "notify_test_impl"}. +{this, "notify_test::AnyPushC"}. +{{handle_info, "notify_test::AnyPushC"}, true}. +{{impl, "notify_test::AnyPushC"}, "notify_test_impl"}. +{this, "notify_test::SeqPullC"}. +{{handle_info, "notify_test::SeqPullC"}, true}. +{{impl, "notify_test::SeqPullC"}, "notify_test_impl"}. +{this, "notify_test::StrPullC"}. +{{handle_info, "notify_test::StrPullC"}, true}. +{{impl, "notify_test::StrPullC"}, "notify_test_impl"}. +{this, "notify_test::AnyPullC"}. +{{handle_info, "notify_test::AnyPullC"}, true}. +{{impl, "notify_test::AnyPullC"}, "notify_test_impl"}. +{this, "notify_test::SeqPushS"}. +{{handle_info, "notify_test::SeqPushS"}, true}. +{{impl, "notify_test::SeqPushS"}, "notify_test_impl"}. +{this, "notify_test::StrPushS"}. +{{handle_info, "notify_test::StrPushS"}, true}. +{{impl, "notify_test::StrPushS"}, "notify_test_impl"}. +{this, "notify_test::AnyPushS"}. +{{handle_info, "notify_test::AnyPushS"}, true}. +{{impl, "notify_test::AnyPushS"}, "notify_test_impl"}. +{this, "notify_test::SeqPullS"}. +{{handle_info, "notify_test::SeqPullS"}, true}. +{{impl, "notify_test::SeqPullS"}, "notify_test_impl"}. +{this, "notify_test::StrPullS"}. +{{handle_info, "notify_test::StrPullS"}, true}. +{{impl, "notify_test::StrPullS"}, "notify_test_impl"}. +{this, "notify_test::AnyPullS"}. +{{handle_info, "notify_test::AnyPullS"}, true}. +{{impl, "notify_test::AnyPullS"}, "notify_test_impl"}. diff --git a/lib/cosNotification/test/notify_test_server.idl b/lib/cosNotification/test/notify_test_server.idl new file mode 100644 index 0000000000..4dc0202890 --- /dev/null +++ b/lib/cosNotification/test/notify_test_server.idl @@ -0,0 +1,113 @@ +// +// %CopyrightBegin% +// +// Copyright Ericsson AB 1999-2010. All Rights Reserved. +// +// The contents of this file are subject to the Erlang Public License, +// Version 1.1, (the "License"); you may not use this file except in +// compliance with the License. You should have received a copy of the +// Erlang Public License along with this software. If not, it can be +// retrieved online at http://www.erlang.org/. +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +// the License for the specific language governing rights and limitations +// under the License. +// +// %CopyrightEnd% +// + +#ifndef _NOTIFY_TEST_SERVER_IDL +#define _NOTIFY_TEST_SERVER_IDL + +#include <CosNotification.idl> +#include <CosNotifyComm.idl> + +module notify_test { + + enum action {PULL_SEQ, PULL_STR, PULL_ANY, PUSH_SEQ, PUSH_STR, PUSH_ANY}; + + struct data { + short score; + string name; + }; + + struct computer { + float memsize; + float cputime; + float filesize; + }; + + struct X { + long A; + string B; + short C; + }; + + + union K switch(short) { + case -1: short neg; + case 0: + case 2: string K; + case 3: X L; + case 5: long M; + default: short N; + }; + + union uni1 switch(long) { + case 1: + case 2: long lo; + case 3: short sh; + default: short defvalue; + }; + + union uni2 switch(long) { + case 1: + case 2: long lo; + case 3: short sh; + }; + + typedef any namedAny; + typedef short ShortArray[4]; + struct studies { + uni1 uni1; + CosNotification::PropertySeq tests; + ShortArray monthly_attendance; + short gpa; + }; + + interface funcs { + void print(); + void doAction(in action Act); + }; + + // interface server + interface SeqPushC : funcs, CosNotifyComm::SequencePushConsumer { + }; + interface StrPushC : funcs, CosNotifyComm::StructuredPushConsumer { + }; + interface AnyPushC : funcs, CosEventComm::PushConsumer { + }; + interface SeqPullC : funcs, CosNotifyComm::SequencePullConsumer { + }; + interface StrPullC : funcs, CosNotifyComm::StructuredPullConsumer { + }; + interface AnyPullC : funcs, CosEventComm::PullConsumer { + }; + + interface SeqPushS : funcs, CosNotifyComm::SequencePushSupplier { + }; + interface StrPushS : funcs, CosNotifyComm::StructuredPushSupplier { + }; + interface AnyPushS : funcs, CosEventComm::PushSupplier { + }; + interface SeqPullS : funcs, CosNotifyComm::SequencePullSupplier { + }; + interface StrPullS : funcs, CosNotifyComm::StructuredPullSupplier { + }; + interface AnyPullS : funcs, CosEventComm::PullSupplier { + }; + +}; + +#endif diff --git a/lib/cosNotification/vsn.mk b/lib/cosNotification/vsn.mk index f4196a2f33..a19facffd5 100644 --- a/lib/cosNotification/vsn.mk +++ b/lib/cosNotification/vsn.mk @@ -1,6 +1,7 @@ COSNOTIFICATION_VSN = 1.1.14 -TICKETS = OTP-8489 +TICKETS = OTP-8489 \ + OTP-8543 TICKETS_1.1.13 = OTP-8353 \ OTP-8354 \ diff --git a/lib/cosProperty/doc/src/notes.xml b/lib/cosProperty/doc/src/notes.xml index e80c90849f..11e6205ee9 100644 --- a/lib/cosProperty/doc/src/notes.xml +++ b/lib/cosProperty/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>cosProperty Release Notes</title> @@ -32,6 +32,22 @@ </header> <section> + <title>cosProperty 1.1.12</title> + + <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Test suites published.</p> + <p> + Own Id: OTP-8543 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosProperty 1.1.11</title> <section> diff --git a/lib/cosProperty/test/Makefile b/lib/cosProperty/test/Makefile new file mode 100644 index 0000000000..ac0f4e298d --- /dev/null +++ b/lib/cosProperty/test/Makefile @@ -0,0 +1,129 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2000-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(COSPROPERTY_VSN) +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/cosProperty_test + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +TEST_SPEC_FILE = cosProperty.spec + + +IDL_FILES = + +IDLOUTDIR = idl_output + +MODULES = \ + property_SUITE \ + generated_SUITE + +GEN_MODULES = \ + +GEN_HRL_FILES = \ + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = + +GEN_FILES = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +GEN_TARGET_FILES = $(GEN_MODULES:%=$(IDLOUTDIR)/%.$(EMULATOR)) + +SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) + +TARGET_FILES = \ + $(GEN_TARGET_FILES) \ + $(SUITE_TARGET_FILES) + + +# ---------------------------------------------------- +# PROGRAMS +# ---------------------------------------------------- +LOCAL_CLASSPATH = $(ERL_TOP)lib/cosProperty/priv:$(ERL_TOP)lib/cosProperty/test +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/cosProperty/ebin \ + -pa $(ERL_TOP)/lib/cosProperty/src \ + -pa $(ERL_TOP)/lib/orber/ebin \ + -pa $(ERL_TOP)/lib/ic/ebin + +ERL_COMPILE_FLAGS += \ + $(ERL_IDL_FLAGS) \ + -pa $(ERL_TOP)/lib/orber/include \ + -pa $(ERL_TOP)/internal_tools/test_server/ebin \ + -pa $(ERL_TOP)/lib/cosProperty/ebin \ + -pa $(ERL_TOP)/lib/cosProperty/test/idl_output \ + -I$(ERL_TOP)/lib/orber/include \ + -I$(ERL_TOP)/lib/cosProperty/src \ + -I$(ERL_TOP)/lib/cosProperty \ + -I$(ERL_TOP)/lib/cosProperty/test/$(IDLOUTDIR) \ + -I$(ERL_TOP)/lib/test_server/include + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- + + +tests debug opt: $(TARGET_FILES) + +clean: + rm -f idl_output/* + rm -f $(TARGET_FILES) + rm -f errs core *~ + +docs: + +# ---------------------------------------------------- +# Special Targets +# ---------------------------------------------------- + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +# We don't copy generated intermediate erlang and hrl files + +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: + +release_docs_spec: + +release_tests_spec: tests + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(IDL_FILES) $(TEST_SPEC_FILE) \ + $(ERL_FILES) $(RELSYSDIR) + $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR) +# $(INSTALL_DIR) $(RELSYSDIR)/$(IDLOUTDIR) +# $(INSTALL_DATA) $(GEN_TARGET_FILES) $(GEN_FILES) \ +# $(RELSYSDIR)/$(IDLOUTDIR) + diff --git a/lib/cosProperty/test/cosProperty.spec b/lib/cosProperty/test/cosProperty.spec new file mode 100644 index 0000000000..d3e0001eef --- /dev/null +++ b/lib/cosProperty/test/cosProperty.spec @@ -0,0 +1,20 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{topcase, {dir, "../cosProperty_test"}}. + diff --git a/lib/cosProperty/test/generated_SUITE.erl b/lib/cosProperty/test/generated_SUITE.erl new file mode 100644 index 0000000000..80a7953949 --- /dev/null +++ b/lib/cosProperty/test/generated_SUITE.erl @@ -0,0 +1,571 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : generated_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(generated_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + AcTuAlReS + end + end()). + + +-define(checktc(_Op), + fun(TC) -> + case orber_tc:check_tc(TC) of + false -> + io:format("###### ERROR ERROR ######~n~p - ~p~n", [Op, TC]), + ?line exit(TC); + true -> + true + end + end). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing IC generated files"]; +all(suite) -> + ['CosPropertyService_ConflictingProperty', 'CosPropertyService_ConstraintNotSupported', + 'CosPropertyService_FixedProperty', 'CosPropertyService_InvalidPropertyName', + 'CosPropertyService_MultipleExceptions', 'CosPropertyService_Properties', + 'CosPropertyService_Property', 'CosPropertyService_PropertyDef', + 'CosPropertyService_PropertyDefs', 'CosPropertyService_PropertyException', + 'CosPropertyService_PropertyExceptions', 'CosPropertyService_PropertyMode', + 'CosPropertyService_PropertyModes', 'CosPropertyService_PropertyNames', + 'CosPropertyService_PropertyNotFound', 'CosPropertyService_PropertyTypes', + 'CosPropertyService_ReadOnlyProperty', 'CosPropertyService_UnsupportedMode', + 'CosPropertyService_UnsupportedProperty', 'CosPropertyService_UnsupportedTypeCode', + 'CosPropertyService_PropertyNamesIterator', 'CosPropertyService_PropertiesIterator', + 'CosPropertyService_PropertySet', 'CosPropertyService_PropertySetDef', + 'CosPropertyService_PropertySetDefFactory', 'CosPropertyService_PropertySetFactory']. + + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + + + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_ConflictingProperty' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_ConflictingProperty'(doc) -> ["CosPropertyService_ConflictingProperty"]; +'CosPropertyService_ConflictingProperty'(suite) -> []; +'CosPropertyService_ConflictingProperty'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_ConflictingProperty':tc())), + ?match("IDL:omg.org/CosPropertyService/ConflictingProperty:1.0", + 'CosPropertyService_ConflictingProperty':id()), + ?match("CosPropertyService_ConflictingProperty", + 'CosPropertyService_ConflictingProperty':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_ConstraintNotSupported' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_ConstraintNotSupported'(doc) -> ["CosPropertyService_ConstraintNotSupported"]; +'CosPropertyService_ConstraintNotSupported'(suite) -> []; +'CosPropertyService_ConstraintNotSupported'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_ConstraintNotSupported':tc())), + ?match("IDL:omg.org/CosPropertyService/ConstraintNotSupported:1.0", + 'CosPropertyService_ConstraintNotSupported':id()), + ?match("CosPropertyService_ConstraintNotSupported", + 'CosPropertyService_ConstraintNotSupported':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_FixedProperty' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_FixedProperty'(doc) -> ["CosPropertyService_FixedProperty"]; +'CosPropertyService_FixedProperty'(suite) -> []; +'CosPropertyService_FixedProperty'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_FixedProperty':tc())), + ?match("IDL:omg.org/CosPropertyService/FixedProperty:1.0", + 'CosPropertyService_FixedProperty':id()), + ?match("CosPropertyService_FixedProperty", + 'CosPropertyService_FixedProperty':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_InvalidPropertyName' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_InvalidPropertyName'(doc) -> ["CosPropertyService_InvalidPropertyName"]; +'CosPropertyService_InvalidPropertyName'(suite) -> []; +'CosPropertyService_InvalidPropertyName'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_InvalidPropertyName':tc())), + ?match("IDL:omg.org/CosPropertyService/InvalidPropertyName:1.0", + 'CosPropertyService_InvalidPropertyName':id()), + ?match("CosPropertyService_InvalidPropertyName", + 'CosPropertyService_InvalidPropertyName':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_MultipleExceptions' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_MultipleExceptions'(doc) -> ["CosPropertyService_MultipleExceptions"]; +'CosPropertyService_MultipleExceptions'(suite) -> []; +'CosPropertyService_MultipleExceptions'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_MultipleExceptions':tc())), + ?match("IDL:omg.org/CosPropertyService/MultipleExceptions:1.0", + 'CosPropertyService_MultipleExceptions':id()), + ?match("CosPropertyService_MultipleExceptions", + 'CosPropertyService_MultipleExceptions':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_Properties' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_Properties'(doc) -> ["CosPropertyService_Properties"]; +'CosPropertyService_Properties'(suite) -> []; +'CosPropertyService_Properties'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_Properties':tc())), + ?match("IDL:omg.org/CosPropertyService/Properties:1.0", + 'CosPropertyService_Properties':id()), + ?match("CosPropertyService_Properties", + 'CosPropertyService_Properties':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_Property' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_Property'(doc) -> ["CosPropertyService_Property"]; +'CosPropertyService_Property'(suite) -> []; +'CosPropertyService_Property'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_Property':tc())), + ?match("IDL:omg.org/CosPropertyService/Property:1.0", + 'CosPropertyService_Property':id()), + ?match("CosPropertyService_Property", + 'CosPropertyService_Property':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyDef' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyDef'(doc) -> ["CosPropertyService_PropertyDef"]; +'CosPropertyService_PropertyDef'(suite) -> []; +'CosPropertyService_PropertyDef'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyDef':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyDef:1.0", + 'CosPropertyService_PropertyDef':id()), + ?match("CosPropertyService_PropertyDef", + 'CosPropertyService_PropertyDef':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyDefs' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyDefs'(doc) -> ["CosPropertyService_PropertyDefs"]; +'CosPropertyService_PropertyDefs'(suite) -> []; +'CosPropertyService_PropertyDefs'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyDefs':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyDefs:1.0", + 'CosPropertyService_PropertyDefs':id()), + ?match("CosPropertyService_PropertyDefs", + 'CosPropertyService_PropertyDefs':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyException' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyException'(doc) -> ["CosPropertyService_PropertyException"]; +'CosPropertyService_PropertyException'(suite) -> []; +'CosPropertyService_PropertyException'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyException':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyException:1.0", + 'CosPropertyService_PropertyException':id()), + ?match("CosPropertyService_PropertyException", + 'CosPropertyService_PropertyException':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyExceptions' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyExceptions'(doc) -> ["CosPropertyService_PropertyExceptions"]; +'CosPropertyService_PropertyExceptions'(suite) -> []; +'CosPropertyService_PropertyExceptions'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyExceptions':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyExceptions:1.0", + 'CosPropertyService_PropertyExceptions':id()), + ?match("CosPropertyService_PropertyExceptions", + 'CosPropertyService_PropertyExceptions':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyMode' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyMode'(doc) -> ["CosPropertyService_PropertyMode"]; +'CosPropertyService_PropertyMode'(suite) -> []; +'CosPropertyService_PropertyMode'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyMode':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyMode:1.0", + 'CosPropertyService_PropertyMode':id()), + ?match("CosPropertyService_PropertyMode", + 'CosPropertyService_PropertyMode':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyModes' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyModes'(doc) -> ["CosPropertyService_PropertyModes"]; +'CosPropertyService_PropertyModes'(suite) -> []; +'CosPropertyService_PropertyModes'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyModes':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyModes:1.0", + 'CosPropertyService_PropertyModes':id()), + ?match("CosPropertyService_PropertyModes", + 'CosPropertyService_PropertyModes':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyNames' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyNames'(doc) -> ["CosPropertyService_PropertyNames"]; +'CosPropertyService_PropertyNames'(suite) -> []; +'CosPropertyService_PropertyNames'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyNames':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyNames:1.0", + 'CosPropertyService_PropertyNames':id()), + ?match("CosPropertyService_PropertyNames", + 'CosPropertyService_PropertyNames':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyNotFound' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyNotFound'(doc) -> ["CosPropertyService_PropertyNotFound"]; +'CosPropertyService_PropertyNotFound'(suite) -> []; +'CosPropertyService_PropertyNotFound'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyNotFound':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyNotFound:1.0", + 'CosPropertyService_PropertyNotFound':id()), + ?match("CosPropertyService_PropertyNotFound", + 'CosPropertyService_PropertyNotFound':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyTypes' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyTypes'(doc) -> ["CosPropertyService_PropertyTypes"]; +'CosPropertyService_PropertyTypes'(suite) -> []; +'CosPropertyService_PropertyTypes'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_PropertyTypes':tc())), + ?match("IDL:omg.org/CosPropertyService/PropertyTypes:1.0", + 'CosPropertyService_PropertyTypes':id()), + ?match("CosPropertyService_PropertyTypes", + 'CosPropertyService_PropertyTypes':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_ReadOnlyProperty' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_ReadOnlyProperty'(doc) -> ["CosPropertyService_ReadOnlyProperty"]; +'CosPropertyService_ReadOnlyProperty'(suite) -> []; +'CosPropertyService_ReadOnlyProperty'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_ReadOnlyProperty':tc())), + ?match("IDL:omg.org/CosPropertyService/ReadOnlyProperty:1.0", + 'CosPropertyService_ReadOnlyProperty':id()), + ?match("CosPropertyService_ReadOnlyProperty", + 'CosPropertyService_ReadOnlyProperty':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_UnsupportedMode' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_UnsupportedMode'(doc) -> ["CosPropertyService_UnsupportedMode"]; +'CosPropertyService_UnsupportedMode'(suite) -> []; +'CosPropertyService_UnsupportedMode'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_UnsupportedMode':tc())), + ?match("IDL:omg.org/CosPropertyService/UnsupportedMode:1.0", + 'CosPropertyService_UnsupportedMode':id()), + ?match("CosPropertyService_UnsupportedMode", + 'CosPropertyService_UnsupportedMode':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_UnsupportedProperty' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_UnsupportedProperty'(doc) -> ["CosPropertyService_UnsupportedProperty"]; +'CosPropertyService_UnsupportedProperty'(suite) -> []; +'CosPropertyService_UnsupportedProperty'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_UnsupportedProperty':tc())), + ?match("IDL:omg.org/CosPropertyService/UnsupportedProperty:1.0", + 'CosPropertyService_UnsupportedProperty':id()), + ?match("CosPropertyService_UnsupportedProperty", + 'CosPropertyService_UnsupportedProperty':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_UnsupportedTypeCode' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_UnsupportedTypeCode'(doc) -> ["CosPropertyService_UnsupportedTypeCode"]; +'CosPropertyService_UnsupportedTypeCode'(suite) -> []; +'CosPropertyService_UnsupportedTypeCode'(_) -> + ?match(true, orber_tc:check_tc('CosPropertyService_UnsupportedTypeCode':tc())), + ?match("IDL:omg.org/CosPropertyService/UnsupportedTypeCode:1.0", + 'CosPropertyService_UnsupportedTypeCode':id()), + ?match("CosPropertyService_UnsupportedTypeCode", + 'CosPropertyService_UnsupportedTypeCode':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertyNamesIterator' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertyNamesIterator'(doc) -> ["CosPropertyService_PropertyNamesIterator"]; +'CosPropertyService_PropertyNamesIterator'(suite) -> []; +'CosPropertyService_PropertyNamesIterator'(_) -> + ?nomatch(undefined, 'CosPropertyService_PropertyNamesIterator':oe_tc(reset)), + ?nomatch(undefined, 'CosPropertyService_PropertyNamesIterator':oe_tc(next_one)), + ?nomatch(undefined, 'CosPropertyService_PropertyNamesIterator':oe_tc(next_n)), + ?nomatch(undefined, 'CosPropertyService_PropertyNamesIterator':oe_tc(destroy)), + ?match(undefined, 'CosPropertyService_PropertyNamesIterator':oe_tc(undefined)), + ?match([_|_], 'CosPropertyService_PropertyNamesIterator':oe_get_interface()), + ?match("IDL:omg.org/CosPropertyService/PropertyNamesIterator:1.0", + 'CosPropertyService_PropertyNamesIterator':typeID()), + check_tc('CosPropertyService_PropertyNamesIterator':oe_get_interface()), + ?match(true, 'CosPropertyService_PropertyNamesIterator':oe_is_a('CosPropertyService_PropertyNamesIterator':typeID())), + ?match(false, 'CosPropertyService_PropertyNamesIterator':oe_is_a("wrong")), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertiesIterator' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertiesIterator'(doc) -> ["CosPropertyService_PropertiesIterator"]; +'CosPropertyService_PropertiesIterator'(suite) -> []; +'CosPropertyService_PropertiesIterator'(_) -> + ?nomatch(undefined, 'CosPropertyService_PropertiesIterator':oe_tc(reset)), + ?nomatch(undefined, 'CosPropertyService_PropertiesIterator':oe_tc(next_one)), + ?nomatch(undefined, 'CosPropertyService_PropertiesIterator':oe_tc(next_n)), + ?nomatch(undefined, 'CosPropertyService_PropertiesIterator':oe_tc(destroy)), + ?match(undefined, 'CosPropertyService_PropertiesIterator':oe_tc(undefined)), + ?match([_|_], 'CosPropertyService_PropertiesIterator':oe_get_interface()), + ?match("IDL:omg.org/CosPropertyService/PropertiesIterator:1.0", + 'CosPropertyService_PropertiesIterator':typeID()), + check_tc('CosPropertyService_PropertiesIterator':oe_get_interface()), + ?match(true, 'CosPropertyService_PropertiesIterator':oe_is_a('CosPropertyService_PropertiesIterator':typeID())), + ?match(false, 'CosPropertyService_PropertiesIterator':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertySet' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertySet'(doc) -> ["CosPropertyService_PropertySet"]; +'CosPropertyService_PropertySet'(suite) -> []; +'CosPropertyService_PropertySet'(_) -> + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(define_property)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(define_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(get_number_of_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(get_all_property_names)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(get_property_value)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(get_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(get_all_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(delete_property)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(delete_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(delete_all_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySet':oe_tc(is_property_defined)), + ?match(undefined, 'CosPropertyService_PropertySet':oe_tc(undefined)), + ?match([_|_], 'CosPropertyService_PropertySet':oe_get_interface()), + ?match("IDL:omg.org/CosPropertyService/PropertySet:1.0", + 'CosPropertyService_PropertySet':typeID()), + check_tc('CosPropertyService_PropertySet':oe_get_interface()), + ?match(true, 'CosPropertyService_PropertySet':oe_is_a('CosPropertyService_PropertySet':typeID())), + ?match(false, 'CosPropertyService_PropertySet':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertySetDef' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertySetDef'(doc) -> ["CosPropertyService_PropertySetDef"]; +'CosPropertyService_PropertySetDef'(suite) -> []; +'CosPropertyService_PropertySetDef'(_) -> + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_allowed_property_types)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_allowed_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(define_property_with_mode)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(define_properties_with_modes)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_property_mode)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_property_modes)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(set_property_mode)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(set_property_modes)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(define_property)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(define_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_number_of_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_all_property_names)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_property_value)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(get_all_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(delete_property)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(delete_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(delete_all_properties)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDef':oe_tc(is_property_defined)), + ?match(undefined, 'CosPropertyService_PropertySetDef':oe_tc(undefined)), + ?match([_|_], 'CosPropertyService_PropertySetDef':oe_get_interface()), + ?match("IDL:omg.org/CosPropertyService/PropertySetDef:1.0", + 'CosPropertyService_PropertySetDef':typeID()), + check_tc('CosPropertyService_PropertySetDef':oe_get_interface()), + ?match(true, 'CosPropertyService_PropertySetDef':oe_is_a('CosPropertyService_PropertySetDef':typeID())), + ?match(true, 'CosPropertyService_PropertySetDef':oe_is_a('CosPropertyService_PropertySet':typeID())), + ?match(false, 'CosPropertyService_PropertySetDef':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertySetDefFactory' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertySetDefFactory'(doc) -> ["CosPropertyService_PropertySetDefFactory"]; +'CosPropertyService_PropertySetDefFactory'(suite) -> []; +'CosPropertyService_PropertySetDefFactory'(_) -> + ?nomatch(undefined, 'CosPropertyService_PropertySetDefFactory':oe_tc(create_propertysetdef)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDefFactory':oe_tc(create_constrained_propertysetdef)), + ?nomatch(undefined, 'CosPropertyService_PropertySetDefFactory':oe_tc(create_initial_propertysetdef)), + ?match(undefined, 'CosPropertyService_PropertySetDefFactory':oe_tc(undefined)), + ?match([_|_], 'CosPropertyService_PropertySetDefFactory':oe_get_interface()), + ?match("IDL:omg.org/CosPropertyService/PropertySetDefFactory:1.0", + 'CosPropertyService_PropertySetDefFactory':typeID()), + check_tc('CosPropertyService_PropertySetDefFactory':oe_get_interface()), + ?match(true, 'CosPropertyService_PropertySetDefFactory':oe_is_a('CosPropertyService_PropertySetDefFactory':typeID())), + ?match(false, 'CosPropertyService_PropertySetDefFactory':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosPropertyService_PropertySetFactory' +%% Description: +%%----------------------------------------------------------------- +'CosPropertyService_PropertySetFactory'(doc) -> ["CosPropertyService_PropertySetFactory"]; +'CosPropertyService_PropertySetFactory'(suite) -> []; +'CosPropertyService_PropertySetFactory'(_) -> + ?nomatch(undefined, 'CosPropertyService_PropertySetFactory':oe_tc(create_propertyset)), + ?nomatch(undefined, 'CosPropertyService_PropertySetFactory':oe_tc(create_constrained_propertyset)), + ?nomatch(undefined, 'CosPropertyService_PropertySetFactory':oe_tc(create_initial_propertyset)), + ?match(undefined, 'CosPropertyService_PropertySetFactory':oe_tc(undefined)), + ?match([_|_], 'CosPropertyService_PropertySetFactory':oe_get_interface()), + ?match("IDL:omg.org/CosPropertyService/PropertySetFactory:1.0", + 'CosPropertyService_PropertySetFactory':typeID()), + check_tc('CosPropertyService_PropertySetFactory':oe_get_interface()), + ?match(true, 'CosPropertyService_PropertySetFactory':oe_is_a('CosPropertyService_PropertySetFactory':typeID())), + ?match(false, 'CosPropertyService_PropertySetFactory':oe_is_a("wrong")), + ok. + + + +%%----------------------------------------------------------------- +%% MISC functions +%%----------------------------------------------------------------- +check_tc([]) -> + ok; +check_tc([{Op, {RetType, InParameters, OutParameters}}|T]) -> + io:format("checked - ~s~n", [Op]), + lists:all(?checktc(Op), [RetType|InParameters]), + lists:all(?checktc(Op), OutParameters), + check_tc(T). + + diff --git a/lib/cosProperty/test/property_SUITE.erl b/lib/cosProperty/test/property_SUITE.erl new file mode 100644 index 0000000000..8fed3128ef --- /dev/null +++ b/lib/cosProperty/test/property_SUITE.erl @@ -0,0 +1,747 @@ +%%---------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%---------------------------------------------------------------------- +%% File : property_SUITE.erl +%% Description : +%% +%%---------------------------------------------------------------------- +-module(property_SUITE). + + +%%--------------- INCLUDES ----------------------------------- +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("cosProperty/src/cosProperty.hrl"). +-include_lib("cosProperty/include/CosPropertyService.hrl"). + +-include("test_server.hrl"). + +%%--------------- DEFINES ------------------------------------ +-define(default_timeout, ?t:minutes(20)). +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + exit(AcTuAlReS) + end + end()). + +-define(match_inverse(NotExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + NotExpectedRes -> + io:format("###### ERROR ERROR ######~n ~p~n", + [AcTuAlReS]), + exit(AcTuAlReS); + _ -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS + end + end()). + + +-define(val1, #any{typecode=tk_short, value=1}). +-define(val2, #any{typecode=tk_short, value=2}). +-define(val3, #any{typecode=tk_short, value=3}). +-define(val4, #any{typecode=tk_short, value=4}). +-define(val5, #any{typecode=tk_long, value=5}). +-define(badval, #any{typecode=tk_shirt, value=5}). + +-define(id1, "id1"). +-define(id2, "id2"). +-define(id3, "id3"). +-define(id4, "id4"). +-define(id5, "id5"). +-define(badid, ""). + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +%% Fixed exports +-export([all/1, cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2]). +%% Test cases +-export([create_setdef_api/1, create_set_api/1, define_with_mode_api/1, + define_api/1, names_iterator_api/1, properties_iterator_api/1, + app_test/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for the cosProperty interfaces", ""]; +all(suite) -> {req, + [mnesia, orber], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [create_setdef_api, create_set_api, define_with_mode_api, define_api, + names_iterator_api, properties_iterator_api, app_test]. + + + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + orber:jump_start(), + cosProperty:install(), + cosProperty:install_db(), + ?line ?match(ok, application:start(cosProperty)), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + application:stop(cosProperty), + cosProperty:uninstall_db(), + cosProperty:uninstall(), + orber:jump_stop(), + Config. + +%%----------------------------------------------------------------- +%% Tests app file +%%----------------------------------------------------------------- +app_test(doc) -> []; +app_test(suite) -> []; +app_test(_Config) -> + ok=test_server:app_test(cosProperty), + ok. + + +%%----------------------------------------------------------------- +%% CosPropertyService_PropertySetDefFactory API tests +%%----------------------------------------------------------------- +create_setdef_api(doc) -> ["CosPropertyService_PropertySetDefFactory API tests.", + ""]; +create_setdef_api(suite) -> []; +create_setdef_api(_Config) -> + + ValidDefs = [#'CosPropertyService_PropertyDef' + {property_name = ?id1, + property_value = ?val1, + property_mode = normal}, + #'CosPropertyService_PropertyDef' + {property_name = ?id2, + property_value = ?val2, + property_mode = normal}], + InvalidDefs = [#'CosPropertyService_PropertyDef' + {property_name = ?id1, + property_value = ?val1, + property_mode = normal}, + #'CosPropertyService_PropertyDef' + {property_name = ?badid, + property_value = ?badval, + property_mode = normal}], + + Fac = ?match({_,pseudo,_,_,_,_}, cosProperty:start_SetDefFactory()), + + Obj1 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetDefFactory': + create_propertysetdef(Fac)), + 'CosPropertyService_PropertySetDef_impl':dump(), + corba:dispose(Obj1), + + + Obj2 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetDefFactory': + create_constrained_propertysetdef(Fac, [tk_short], ValidDefs)), + 'CosPropertyService_PropertySetDef_impl':dump(), + corba:dispose(Obj2), + + %% Both arguments correct but 'ValidDefs' contain other TC:s than + %% tk_null. + ?match({'EXCEPTION', _}, 'CosPropertyService_PropertySetDefFactory': + create_constrained_propertysetdef(Fac, [tk_null], ValidDefs)), + 'CosPropertyService_PropertySetDef_impl':dump(), + + ?match({'EXCEPTION', _}, 'CosPropertyService_PropertySetDefFactory': + create_constrained_propertysetdef(Fac, [tk_null], InvalidDefs)), + 'CosPropertyService_PropertySetDef_impl':dump(), + + %% The allowed TC not supported. + ?match({'EXCEPTION', _}, 'CosPropertyService_PropertySetDefFactory': + create_constrained_propertysetdef(Fac, [tk_noll], ValidDefs)), + 'CosPropertyService_PropertySetDef_impl':dump(), + + Obj4 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetDefFactory': + create_initial_propertysetdef(Fac, ValidDefs)), + 'CosPropertyService_PropertySetDef_impl':dump(), + corba:dispose(Obj4), + + ?match({'EXCEPTION', _}, 'CosPropertyService_PropertySetDefFactory': + create_initial_propertysetdef(Fac, InvalidDefs)), + + ?match(ok, cosProperty:stop_SetDefFactory(Fac)), + + ok. + + +%%----------------------------------------------------------------- +%% CosPropertyService_PropertySetFactory API tests +%%----------------------------------------------------------------- +create_set_api(doc) -> ["CosPropertyService_PropertySetFactory API tests.", + ""]; +create_set_api(suite) -> []; +create_set_api(_Config) -> + Valid = [#'CosPropertyService_Property' + {property_name = ?id1, + property_value = ?val1}, + #'CosPropertyService_Property' + {property_name = ?id2, + property_value = ?val2}], + Invalid = [#'CosPropertyService_Property' + {property_name = ?id1, + property_value = ?val1}, + #'CosPropertyService_Property' + {property_name = ?badid, + property_value = ?badval}], + + Fac = ?match({_,pseudo,_,_,_,_}, cosProperty:start_SetFactory()), + Obj1 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetFactory': + create_propertyset(Fac)), + 'CosPropertyService_PropertySetDef_impl':dump(), + corba:dispose(Obj1), + + + Obj2 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetFactory': + create_constrained_propertyset(Fac, [tk_short], Valid)), + 'CosPropertyService_PropertySetDef_impl':dump(), + corba:dispose(Obj2), + + %% Both arguments correct but 'Valid' contain other TC:s than + %% tk_null. + ?match({'EXCEPTION', _}, 'CosPropertyService_PropertySetFactory': + create_constrained_propertyset(Fac, [tk_null], Valid)), + 'CosPropertyService_PropertySetDef_impl':dump(), + + ?match({'EXCEPTION', _}, 'CosPropertyService_PropertySetFactory': + create_constrained_propertyset(Fac, [tk_null], Invalid)), + 'CosPropertyService_PropertySetDef_impl':dump(), + + %% The allowed TC not supported. + ?match({'EXCEPTION', _}, 'CosPropertyService_PropertySetFactory': + create_constrained_propertyset(Fac, [tk_noll], Valid)), + 'CosPropertyService_PropertySetDef_impl':dump(), + + Obj4 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetFactory': + create_initial_propertyset(Fac, Valid)), + 'CosPropertyService_PropertySetDef_impl':dump(), + corba:dispose(Obj4), + + ?match({'EXCEPTION', _}, 'CosPropertyService_PropertySetFactory': + create_initial_propertyset(Fac, Invalid)), + ?match(ok, cosProperty:stop_SetFactory(Fac)), + ok. + +%%----------------------------------------------------------------- +%% CosPropertyService_PropertySetDef API tests +%%----------------------------------------------------------------- +define_api(doc) -> ["CosPropertyService_PropertySet API tests.", + ""]; +define_api(suite) -> []; +define_api(_Config) -> + ValidDefs = [#'CosPropertyService_Property' + {property_name = ?id1, + property_value = ?val1}, + #'CosPropertyService_Property' + {property_name = ?id2, + property_value = ?val2}, + #'CosPropertyService_Property' + {property_name = ?id3, + property_value = ?val3}], + + Fac = ?match({_,pseudo,_,_,_,_}, cosProperty:start_SetFactory()), + + io:format("@@@@ Testing PropertySet returned by the factory operation create_propertyset/1 @@@@", []), + Obj = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetFactory': + create_propertyset(Fac)), + ?match(ok, 'CosPropertyService_PropertySet':define_property(Obj, ?id1, ?val1)), + ?match(ok, 'CosPropertyService_PropertySet':define_property(Obj, ?id1, ?val1)), + + ?match(1, 'CosPropertyService_PropertySet':get_number_of_properties(Obj)), + ?match(ok, 'CosPropertyService_PropertySet': + define_properties(Obj, [#'CosPropertyService_Property'{property_name = ?id2, + property_value = ?val2}, + #'CosPropertyService_Property'{property_name = ?id3, + property_value = ?val3}])), + + ?match(3, 'CosPropertyService_PropertySet':get_number_of_properties(Obj)), + + ?match({true, [_]}, 'CosPropertyService_PropertySet':get_properties(Obj, [?id1])), + ?match({true, [_, _, _]}, 'CosPropertyService_PropertySet':get_properties(Obj, [?id1, ?id2, ?id3])), + ?match({false,[_, _, _]}, 'CosPropertyService_PropertySet':get_properties(Obj, [?id1, "wrong", ?id3])), + + ?match(?val2, 'CosPropertyService_PropertySet':get_property_value(Obj, ?id2)), + ?match(ok, 'CosPropertyService_PropertySet':delete_property(Obj, ?id1)), + + ?match(2, 'CosPropertyService_PropertySet':get_number_of_properties(Obj)), + + ?match(ok, 'CosPropertyService_PropertySet':define_property(Obj, ?id1, ?val1)), + ?match(ok, 'CosPropertyService_PropertySet':define_property(Obj, ?id2, ?val2)), + ?match(ok, 'CosPropertyService_PropertySet':define_property(Obj, ?id3, ?val3)), + + ?match(true, 'CosPropertyService_PropertySet':delete_all_properties(Obj)), + ?match(0, 'CosPropertyService_PropertySet':get_number_of_properties(Obj)), + + ?match(ok, 'CosPropertyService_PropertySet': + define_properties(Obj, [#'CosPropertyService_Property'{property_name = ?id1, + property_value = ?val1}, + #'CosPropertyService_Property'{property_name = ?id2, + property_value = ?val2}, + #'CosPropertyService_Property'{property_name = ?id3, + property_value = ?val3}])), + + ?match(3, 'CosPropertyService_PropertySet':get_number_of_properties(Obj)), + ?match(?val2, 'CosPropertyService_PropertySet':get_property_value(Obj, ?id2)), + + ?match({'EXCEPTION',{'CosPropertyService_PropertyNotFound',_}}, + 'CosPropertyService_PropertySet':get_property_value(Obj, "wrongID")), + ?match({'EXCEPTION',{'CosPropertyService_InvalidPropertyName',_}}, + 'CosPropertyService_PropertySet':get_property_value(Obj, "")), + ?match({'EXCEPTION',{'CosPropertyService_InvalidPropertyName',_}}, + 'CosPropertyService_PropertySet':is_property_defined(Obj, "")), + ?match(false, 'CosPropertyService_PropertySet':is_property_defined(Obj, "wrongID")), + ?match(true, 'CosPropertyService_PropertySet':is_property_defined(Obj, ?id1)), + + %% This function is not supported by PropertySet. + ?match({'EXCEPTION',{'NO_IMPLEMENT',_,_,_}}, + 'CosPropertyService_PropertySetDef':get_property_modes(Obj, [?id1, ?id2, ?id3])), + + ?match({'EXCEPTION',{'CosPropertyService_MultipleExceptions',_,_}}, + 'CosPropertyService_PropertySet':delete_properties(Obj, [?id1, ?id2, ?id3, "wrongID"])), + ?match(0, 'CosPropertyService_PropertySet':get_number_of_properties(Obj)), + corba:dispose(Obj), + + io:format("@@@@ Testing PropertySet returned by the factory operation create_constrained_propertyset/3 @@@@", []), + Obj2 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetFactory': + create_constrained_propertyset(Fac, [tk_short], ValidDefs)), + + ?match(0, 'CosPropertyService_PropertySet':get_number_of_properties(Obj2)), + ?match({'EXCEPTION', {'CosPropertyService_UnsupportedProperty',_}}, + 'CosPropertyService_PropertySet':define_property(Obj2, ?id4, ?val4)), + ?match({'EXCEPTION', {'CosPropertyService_UnsupportedTypeCode',_}}, + 'CosPropertyService_PropertySet':define_property(Obj2, ?id1, ?val5)), + ?match(ok, 'CosPropertyService_PropertySet':define_property(Obj2, ?id1, ?val1)), + ?match(1, 'CosPropertyService_PropertySet':get_number_of_properties(Obj2)), + ?match({'EXCEPTION',{'CosPropertyService_MultipleExceptions',_,_}}, + 'CosPropertyService_PropertySet': + define_properties(Obj2, [#'CosPropertyService_Property'{property_name = ?id2, + property_value = ?val2}, + #'CosPropertyService_Property'{property_name = ?id3, + property_value = ?val3}, + #'CosPropertyService_Property'{property_name = "wrongId", + property_value = ?val2}])), + ?match(ok,'CosPropertyService_PropertySet': + define_properties(Obj2, [#'CosPropertyService_Property'{property_name = ?id2, + property_value = ?val2}, + #'CosPropertyService_Property'{property_name = ?id3, + property_value = ?val3}])), + ?match(3, 'CosPropertyService_PropertySet':get_number_of_properties(Obj2)), + ?match({'EXCEPTION',{'CosPropertyService_PropertyNotFound',_}}, + 'CosPropertyService_PropertySet':get_property_value(Obj2, "wrongID")), + ?match(?val2, 'CosPropertyService_PropertySet':get_property_value(Obj2, ?id2)), + ?match({'EXCEPTION',{'CosPropertyService_InvalidPropertyName',_}}, + 'CosPropertyService_PropertySet':get_property_value(Obj2, "")), + ?match({'EXCEPTION',{'CosPropertyService_InvalidPropertyName',_}}, + 'CosPropertyService_PropertySet':is_property_defined(Obj2, "")), + ?match(false, 'CosPropertyService_PropertySet':is_property_defined(Obj2, "wrongID")), + ?match(true, 'CosPropertyService_PropertySet':is_property_defined(Obj2, ?id1)), + + + ?match({'EXCEPTION',{'CosPropertyService_PropertyNotFound',_}}, + 'CosPropertyService_PropertySet':delete_property(Obj2, "wrongID")), + ?match(3, 'CosPropertyService_PropertySet':get_number_of_properties(Obj2)), + ?match(ok, 'CosPropertyService_PropertySet':delete_property(Obj2, ?id1)), + ?match(2, 'CosPropertyService_PropertySet':get_number_of_properties(Obj2)), + + ?match(ok, 'CosPropertyService_PropertySet':delete_properties(Obj2, [?id2])), + ?match(1, 'CosPropertyService_PropertySet':get_number_of_properties(Obj2)), + + ?match({'EXCEPTION',{'CosPropertyService_MultipleExceptions',_,_}}, + 'CosPropertyService_PropertySet':delete_properties(Obj2, [?id3, "wrongID"])), + ?match(0, 'CosPropertyService_PropertySet':get_number_of_properties(Obj2)), + corba:dispose(Obj2), + + io:format("@@@@ Testing PropertySet returned by the factory operation create_initial_propertyset/2 @@@@", []), + Obj3 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetFactory': + create_initial_propertyset(Fac, ValidDefs)), + ?match(3, 'CosPropertyService_PropertySet':get_number_of_properties(Obj3)), + + ?match(ok, 'CosPropertyService_PropertySet':define_property(Obj3, ?id4, ?val4)), + ?match(4, 'CosPropertyService_PropertySet':get_number_of_properties(Obj3)), + + ?match(ok,'CosPropertyService_PropertySet': + define_properties(Obj3, [#'CosPropertyService_Property'{property_name = ?id5, + property_value = ?val5}])), + + ?match(5, 'CosPropertyService_PropertySet':get_number_of_properties(Obj3)), + + ?match({'EXCEPTION',{'CosPropertyService_PropertyNotFound',_}}, + 'CosPropertyService_PropertySet':get_property_value(Obj3, "wrongID")), + ?match(?val2, 'CosPropertyService_PropertySet':get_property_value(Obj3, ?id2)), + ?match({'EXCEPTION',{'CosPropertyService_InvalidPropertyName',_}}, + 'CosPropertyService_PropertySet':get_property_value(Obj3, "")), + ?match({'EXCEPTION',{'CosPropertyService_InvalidPropertyName',_}}, + 'CosPropertyService_PropertySet':is_property_defined(Obj3, "")), + ?match(false, 'CosPropertyService_PropertySet':is_property_defined(Obj3, "wrongID")), + ?match(true, 'CosPropertyService_PropertySet':is_property_defined(Obj3, ?id1)), + + ?match({'EXCEPTION',{'CosPropertyService_PropertyNotFound',_}}, + 'CosPropertyService_PropertySet':delete_property(Obj3, "wrongId")), + ?match(ok, 'CosPropertyService_PropertySet':delete_property(Obj3, ?id5)), + ?match(4, 'CosPropertyService_PropertySet':get_number_of_properties(Obj3)), + + ?match({'EXCEPTION',{'CosPropertyService_MultipleExceptions',_,_}}, + 'CosPropertyService_PropertySet':delete_properties(Obj3, [?id1, ?id2, ?id3, "wrongID"])), + ?match(1, 'CosPropertyService_PropertySet':get_number_of_properties(Obj3)), + + ?match(true, 'CosPropertyService_PropertySet':delete_all_properties(Obj3)), + ?match(0, 'CosPropertyService_PropertySet':get_number_of_properties(Obj3)), + + corba:dispose(Obj3), + ?match(ok, cosProperty:stop_SetFactory(Fac)), + + ok. + +%%----------------------------------------------------------------- +%% CosPropertyService_PropertySetDef API tests +%%----------------------------------------------------------------- +define_with_mode_api(doc) -> ["CosPropertyService_PropertySetDef API tests.", + ""]; +define_with_mode_api(suite) -> []; +define_with_mode_api(_Config) -> + ValidDefs = [#'CosPropertyService_PropertyDef' + {property_name = ?id1, + property_value = ?val1, + property_mode = normal}, + #'CosPropertyService_PropertyDef' + {property_name = ?id2, + property_value = ?val2, + property_mode = normal}, + #'CosPropertyService_PropertyDef' + {property_name = ?id3, + property_value = ?val3, + property_mode = normal}], + + Fac = ?match({_,pseudo,_,_,_,_}, cosProperty:start_SetDefFactory()), + + io:format("@@@@ Testing PropertySetDef returned by the factory operation create_propertysetdef/1 @@@@", []), + Obj = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetDefFactory': + create_propertysetdef(Fac)), + + %% Initally no prop's created and no restrictions at all + ?match(0, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj)), + ?match({ok, []}, 'CosPropertyService_PropertySetDef':get_allowed_property_types(Obj)), + ?match({ok, []}, 'CosPropertyService_PropertySetDef':get_allowed_properties(Obj)), + + %% Add two properties. + ?match(ok, 'CosPropertyService_PropertySetDef':define_property_with_mode(Obj, ?id4, ?val4, read_only)), + ?match(ok, 'CosPropertyService_PropertySetDef':define_property_with_mode(Obj, ?id5, ?val5, normal)), + %% Try to add the same property again (shouldn't add another since using the sam Id). + ?match(ok, 'CosPropertyService_PropertySetDef':define_property_with_mode(Obj, ?id5, ?val5, normal)), + + %% Try to add another identical proprty with wrong TC. + ?match({'EXCEPTION',{'CosPropertyService_ConflictingProperty',_}}, + 'CosPropertyService_PropertySetDef':define_property_with_mode(Obj, ?id5, ?val4, normal)), + + + %% Should be two now. + ?match(2, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj)), + + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj, ?id4)), + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj, ?id5)), + ?match(ok, 'CosPropertyService_PropertySetDef': + define_properties_with_modes(Obj, + [#'CosPropertyService_PropertyDef'{property_name = ?id1, + property_value = ?val1, + property_mode = normal}, + #'CosPropertyService_PropertyDef'{property_name = ?id2, + property_value = ?val2, + property_mode = normal}, + #'CosPropertyService_PropertyDef'{property_name = ?id3, + property_value = ?val3, + property_mode = normal}])), + %% Should be five now. + ?match(5, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj)), + ?match({true, [_,_]}, 'CosPropertyService_PropertySetDef':get_property_modes(Obj, [?id1, ?id3])), + ?match({false, [_,_,_]}, 'CosPropertyService_PropertySetDef':get_property_modes(Obj, [?id1, ?id3, "wrongID"])), + + ?match(ok, 'CosPropertyService_PropertySetDef':set_property_mode(Obj, ?id1, read_only)), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj, ?id1)), + + ?match({'EXCEPTION',{'CosPropertyService_PropertyNotFound',_}}, + 'CosPropertyService_PropertySetDef':set_property_mode(Obj, "wrongID", read_only)), + + ?match({'EXCEPTION',{'CosPropertyService_MultipleExceptions',_,_}}, + 'CosPropertyService_PropertySetDef': + set_property_modes(Obj, + [#'CosPropertyService_PropertyMode'{property_name = ?id2, + property_mode = read_only}, + #'CosPropertyService_PropertyMode'{property_name = ?id3, + property_mode = read_only}, + #'CosPropertyService_PropertyMode'{property_name = "wrongID", + property_mode = read_only}])), + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj, ?id2)), + ?match(ok, + 'CosPropertyService_PropertySetDef': + set_property_modes(Obj, + [#'CosPropertyService_PropertyMode'{property_name = ?id2, + property_mode = read_only}, + #'CosPropertyService_PropertyMode'{property_name = ?id3, + property_mode = read_only}])), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj, ?id2)), + + corba:dispose(Obj), + + + io:format("@@@@ Testing PropertySetDef returned by the factory operation create_constrained_propertysetdef/3 @@@@", []), + Obj2 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetDefFactory': + create_constrained_propertysetdef(Fac, [tk_short], ValidDefs)), + + %% Initally no prop's created and the restrictions that only Properties eq. to ValidDefs + %% may be handled. + ?match(0, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj2)), + ?match({ok, [tk_short]}, 'CosPropertyService_PropertySetDef':get_allowed_property_types(Obj2)), + %% We cannot be sure in which order it's returned. Hmm, that's not really true but it + %% may change in the future. + ?match({ok, [_,_,_]}, 'CosPropertyService_PropertySetDef':get_allowed_properties(Obj2)), + %% Try to add a Property with and Id not eq. to ?id1, ?id2 or ?id3; must fail. + ?match({'EXCEPTION', {'CosPropertyService_UnsupportedProperty',_}}, + 'CosPropertyService_PropertySetDef':define_property_with_mode(Obj2, ?id4, ?val4, read_only)), + %% To be sure that nothing was updated. + ?match(0, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj2)), + %% Add a valid Property. + ?match(ok, 'CosPropertyService_PropertySetDef':define_property_with_mode(Obj2, ?id1, ?val1, normal)), + ?match(1, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj2)), + %% Add a sequence of 1 valid and one invalid Prop's + ?match({'EXCEPTION', {'CosPropertyService_MultipleExceptions',_,_}}, + 'CosPropertyService_PropertySetDef': + define_properties_with_modes(Obj2, + [#'CosPropertyService_PropertyDef'{property_name = ?id2, + property_value = ?val2, + property_mode = normal}, + #'CosPropertyService_PropertyDef'{property_name = "wrongID", + property_value = ?val2, + property_mode = normal}])), + %% One should be added. + ?match(1, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj2)), + ?match(ok, 'CosPropertyService_PropertySetDef': + define_properties_with_modes(Obj2, + [#'CosPropertyService_PropertyDef'{property_name = ?id3, + property_value = ?val3, + property_mode = normal}])), + %% Add a sequence of 1 valid Prop. + ?match(2, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj2)), + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj2, ?id1)), + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj2, ?id3)), + + + ?match({true, [_,_]}, 'CosPropertyService_PropertySetDef':get_property_modes(Obj2, [?id1, ?id3])), + ?match({false, [_,_,_]}, 'CosPropertyService_PropertySetDef':get_property_modes(Obj2, [?id1, ?id3, "wrongID"])), + + ?match(ok, 'CosPropertyService_PropertySetDef':set_property_mode(Obj2, ?id1, read_only)), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj2, ?id1)), + ?match(ok, 'CosPropertyService_PropertySetDef': + set_property_modes(Obj2, + [#'CosPropertyService_PropertyMode'{property_name = ?id1, + property_mode = read_only}, + #'CosPropertyService_PropertyMode'{property_name = ?id3, + property_mode = read_only}])), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj2, ?id1)), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj2, ?id3)), + ?match({'EXCEPTION',{'CosPropertyService_MultipleExceptions',_,_}}, + 'CosPropertyService_PropertySetDef': + set_property_modes(Obj2, + [#'CosPropertyService_PropertyMode'{property_name = ?id1, + property_mode = normal}, + #'CosPropertyService_PropertyMode'{property_name = ?id3, + property_mode = normal}, + #'CosPropertyService_PropertyMode'{property_name = "wrongID", + property_mode = normal}])), + + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj2, ?id1)), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj2, ?id3)), + corba:dispose(Obj2), + + io:format("@@@@ Testing PropertySetDef returned by the factory operation create_initial_propertysetdef/2 @@@@", []), + Obj3 = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetDefFactory': + create_initial_propertysetdef(Fac, ValidDefs)), + + %% Initally the supplied prop's are created and no restrictions. + ?match(3, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj3)), + ?match({ok, []}, 'CosPropertyService_PropertySetDef':get_allowed_property_types(Obj3)), + ?match({ok, []}, 'CosPropertyService_PropertySetDef':get_allowed_properties(Obj3)), + + %% Add a new properties an test if they have been inserted. + ?match(ok, 'CosPropertyService_PropertySetDef':define_property_with_mode(Obj3, ?id4, ?val4, read_only)), + ?match(4, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj3)), + ?match(ok, 'CosPropertyService_PropertySetDef':define_property_with_mode(Obj3, ?id5, ?val5, read_only)), + ?match(5, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj3)), + + %% Lookup each Property's mode. + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id1)), + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id2)), + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id3)), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id4)), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id5)), + + ?match({true, [_,_,_,_,_]}, + 'CosPropertyService_PropertySetDef':get_property_modes(Obj3, [?id1, ?id2, ?id3, ?id4, ?id5])), + ?match({false, [_,_]}, + 'CosPropertyService_PropertySetDef':get_property_modes(Obj3, [?id1, "wrongID"])), + ?match(ok, 'CosPropertyService_PropertySetDef':set_property_mode(Obj3, ?id4, normal)), + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id4)), + + ?match(ok, 'CosPropertyService_PropertySetDef': + set_property_modes(Obj3, + [#'CosPropertyService_PropertyMode'{property_name = ?id1, + property_mode = read_only}, + #'CosPropertyService_PropertyMode'{property_name = ?id2, + property_mode = read_only}])), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id1)), + ?match(read_only, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id2)), + ?match({'EXCEPTION',{'CosPropertyService_MultipleExceptions',_,_}}, + 'CosPropertyService_PropertySetDef': + set_property_modes(Obj3, + [#'CosPropertyService_PropertyMode'{property_name = ?id3, + property_mode = read_only}, + #'CosPropertyService_PropertyMode'{property_name = ?id4, + property_mode = read_only}, + #'CosPropertyService_PropertyMode'{property_name = "wrongID", + property_mode = read_only}])), + + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id3)), + ?match(normal, 'CosPropertyService_PropertySetDef':get_property_mode(Obj3, ?id4)), + + corba:dispose(Obj3), + + ?match(ok, cosProperty:stop_SetDefFactory(Fac)), + + ok. + + + +%%----------------------------------------------------------------- +%% CosPropertyService_PropertyNamesIterator API tests +%%----------------------------------------------------------------- +names_iterator_api(doc) -> ["CosPropertyService_PropertyNamesIterator API tests.", + ""]; +names_iterator_api(suite) -> []; +names_iterator_api(_Config) -> + Fac = ?match({_,pseudo,_,_,_,_}, cosProperty:start_SetFactory()), + Obj = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetFactory': + create_propertyset(Fac)), + ?match(ok, 'CosPropertyService_PropertySet': + define_properties(Obj, [#'CosPropertyService_Property'{property_name = ?id1, + property_value = ?val1}, + #'CosPropertyService_Property'{property_name = ?id2, + property_value = ?val2}, + #'CosPropertyService_Property'{property_name = ?id3, + property_value = ?val3}])), + + ?match(3, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj)), + {_, _,ItObj} = ?match({ok, [], _}, 'CosPropertyService_PropertySetDef':get_all_property_names(Obj, 0)), + ?match({false, [_,_,_]}, 'CosPropertyService_PropertyNamesIterator':next_n(ItObj,3)), + ?match(ok, 'CosPropertyService_PropertyNamesIterator':reset(ItObj)), + ?match({false, [_,_,_]}, 'CosPropertyService_PropertyNamesIterator':next_n(ItObj,4)), + ?match(ok, 'CosPropertyService_PropertyNamesIterator':reset(ItObj)), + ?match({true, [_]}, 'CosPropertyService_PropertyNamesIterator':next_n(ItObj,1)), + ?match({true, _}, 'CosPropertyService_PropertyNamesIterator':next_one(ItObj)), + ?match({true, _}, 'CosPropertyService_PropertyNamesIterator':next_one(ItObj)), + ?match({false, _}, 'CosPropertyService_PropertyNamesIterator':next_one(ItObj)), + ?match(ok, 'CosPropertyService_PropertyNamesIterator':destroy(ItObj)), + + corba:dispose(Obj), + ok. + +%%----------------------------------------------------------------- +%% CosPropertyService_PropertiesIterator API tests +%%----------------------------------------------------------------- +properties_iterator_api(doc) -> ["CosPropertyService_PropertiesIterator API tests.", + ""]; +properties_iterator_api(suite) -> []; +properties_iterator_api(_Config) -> + Fac = ?match({_,pseudo,_,_,_,_}, cosProperty:start_SetFactory()), + Obj = ?match({_,pseudo,_,_,_,_}, 'CosPropertyService_PropertySetFactory': + create_propertyset(Fac)), + + ?match(ok, 'CosPropertyService_PropertySet': + define_properties(Obj, [#'CosPropertyService_Property'{property_name = ?id1, + property_value = ?val1}, + #'CosPropertyService_Property'{property_name = ?id2, + property_value = ?val2}, + #'CosPropertyService_Property'{property_name = ?id3, + property_value = ?val3}])), + + ?match(3, 'CosPropertyService_PropertySetDef':get_number_of_properties(Obj)), + {_, _,ItObj} = ?match({ok, [], _}, + 'CosPropertyService_PropertySetDef':get_all_properties(Obj, 0)), + ?match({false, [_,_,_]}, 'CosPropertyService_PropertiesIterator':next_n(ItObj,3)), + ?match(ok, 'CosPropertyService_PropertiesIterator':reset(ItObj)), + ?match({false, [_,_,_]}, 'CosPropertyService_PropertiesIterator':next_n(ItObj,4)), + ?match(ok, 'CosPropertyService_PropertiesIterator':reset(ItObj)), + ?match({true, [_]}, 'CosPropertyService_PropertiesIterator':next_n(ItObj,1)), + ?match({true, {'CosPropertyService_Property',_,_}}, + 'CosPropertyService_PropertiesIterator':next_one(ItObj)), + ?match({true, {'CosPropertyService_Property',_,_}}, + 'CosPropertyService_PropertiesIterator':next_one(ItObj)), + ?match({false, {'CosPropertyService_Property',_,_}}, + 'CosPropertyService_PropertiesIterator':next_one(ItObj)), + ?match(ok, 'CosPropertyService_PropertiesIterator':destroy(ItObj)), + corba:dispose(Obj), + ok. + + +%%----------------------------------------------------------------- +%% END OF MODULE +%%----------------------------------------------------------------- diff --git a/lib/cosProperty/vsn.mk b/lib/cosProperty/vsn.mk index c221e6fa4a..3d594a8329 100644 --- a/lib/cosProperty/vsn.mk +++ b/lib/cosProperty/vsn.mk @@ -1,6 +1,8 @@ -COSPROPERTY_VSN = 1.1.11 +COSPROPERTY_VSN = 1.1.12 -TICKETS = OTP-8355 +TICKETS = OTP-8543 + +TICKETS_1.1.11 = OTP-8355 TICKETS_1.1.10 = OTP-8201 diff --git a/lib/cosTime/doc/src/notes.xml b/lib/cosTime/doc/src/notes.xml index 9f23a8633c..40ebf42753 100644 --- a/lib/cosTime/doc/src/notes.xml +++ b/lib/cosTime/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>cosTime Release Notes</title> @@ -33,6 +33,22 @@ </header> <section> + <title>cosTime 1.1.9</title> + + <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Test suites published.</p> + <p> + Own Id: OTP-8543 Aux Id:</p> + </item> + </list> + </section> + </section> + + <section> <title>cosTime 1.1.8</title> <section> diff --git a/lib/cosTime/test/Makefile b/lib/cosTime/test/Makefile new file mode 100644 index 0000000000..fde5c4facc --- /dev/null +++ b/lib/cosTime/test/Makefile @@ -0,0 +1,135 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2000-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(COSTIME_VSN) +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/cosTime_test + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +TEST_SPEC_FILE = cosTime.spec + + +IDL_FILES = + +IDLOUTDIR = idl_output + +MODULES = \ + time_SUITE \ + generated_SUITE + +GEN_MODULES = \ + +GEN_HRL_FILES = \ + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = + +GEN_FILES = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +GEN_TARGET_FILES = $(GEN_MODULES:%=$(IDLOUTDIR)/%.$(EMULATOR)) + +SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) + +TARGET_FILES = \ + $(GEN_TARGET_FILES) \ + $(SUITE_TARGET_FILES) + + +# ---------------------------------------------------- +# PROGRAMS +# ---------------------------------------------------- +LOCAL_CLASSPATH = $(ERL_TOP)lib/cosTime/priv:$(ERL_TOP)lib/cosTime/test +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/cosTime/ebin \ + -pa $(ERL_TOP)/lib/cosTime/src \ + -pa $(ERL_TOP)/lib/cosTime/include \ + -pa $(ERL_TOP)/lib/cosNotification/ebin \ + -pa $(ERL_TOP)/lib/orber/ebin \ + -pa $(ERL_TOP)/lib/ic/ebin + +ERL_COMPILE_FLAGS += \ + $(ERL_IDL_FLAGS) \ + -pa $(ERL_TOP)/lib/orber/include \ + -pa $(ERL_TOP)/lib/cosNotification/include \ + -pa $(ERL_TOP)/internal_tools/test_server/ebin \ + -pa $(ERL_TOP)/lib/cosTime/ebin \ + -pa $(ERL_TOP)/lib/cosTime/include \ + -pa $(ERL_TOP)/lib/cosTime/test/idl_output \ + -I$(ERL_TOP)/lib/orber/include \ + -I$(ERL_TOP)/lib/cosNotification/include \ + -I$(ERL_TOP)/lib/cosTime/src \ + -I$(ERL_TOP)/lib/cosTime/include \ + -I$(ERL_TOP)/lib/cosTime \ + -I$(ERL_TOP)/lib/cosTime/test/$(IDLOUTDIR) \ + -I$(ERL_TOP)/lib/test_server/include + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- + + +tests debug opt: $(TARGET_FILES) + +clean: + rm -f idl_output/* + rm -f $(TARGET_FILES) + rm -f errs core *~ + +docs: + +# ---------------------------------------------------- +# Special Targets +# ---------------------------------------------------- + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +# We don't copy generated intermediate erlang and hrl files + +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: + +release_docs_spec: + +release_tests_spec: tests + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(IDL_FILES) $(TEST_SPEC_FILE) \ + $(ERL_FILES) $(RELSYSDIR) + $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR) +# $(INSTALL_DIR) $(RELSYSDIR)/$(IDLOUTDIR) +# $(INSTALL_DATA) $(GEN_TARGET_FILES) $(GEN_FILES) \ +# $(RELSYSDIR)/$(IDLOUTDIR) + diff --git a/lib/cosTime/test/cosTime.spec b/lib/cosTime/test/cosTime.spec new file mode 100644 index 0000000000..3f50946043 --- /dev/null +++ b/lib/cosTime/test/cosTime.spec @@ -0,0 +1,19 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{topcase, {dir, "../cosTime_test"}}. diff --git a/lib/cosTime/test/generated_SUITE.erl b/lib/cosTime/test/generated_SUITE.erl new file mode 100644 index 0000000000..3a2153528f --- /dev/null +++ b/lib/cosTime/test/generated_SUITE.erl @@ -0,0 +1,288 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : generated_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(generated_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + AcTuAlReS + end + end()). + + +-define(checktc(_Op), + fun(TC) -> + case orber_tc:check_tc(TC) of + false -> + io:format("###### ERROR ERROR ######~n~p - ~p~n", [Op, TC]), + ?line exit(TC); + true -> + true + end + end). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing IC generated files"]; +all(suite) -> + ['TimeBase_IntervalT', 'TimeBase_UtcT', 'CosTime_TimeUnavailable', + 'CosTimerEvent_TimerEventT', 'CosTime_TIO', 'CosTime_TimeService', + 'CosTime_UTO', 'CosTimerEvent_TimerEventHandler', + 'CosTimerEvent_TimerEventService']. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'TimeBase_IntervalT' +%% Description: +%%----------------------------------------------------------------- +'TimeBase_IntervalT'(doc) -> ["TimeBase_IntervalT"]; +'TimeBase_IntervalT'(suite) -> []; +'TimeBase_IntervalT'(_) -> + ?match(true, orber_tc:check_tc('TimeBase_IntervalT':tc())), + ?match("IDL:omg.org/TimeBase/IntervalT:1.0", + 'TimeBase_IntervalT':id()), + ?match("TimeBase_IntervalT", + 'TimeBase_IntervalT':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'TimeBase_UtcT' +%% Description: +%%----------------------------------------------------------------- +'TimeBase_UtcT'(doc) -> ["TimeBase_UtcT"]; +'TimeBase_UtcT'(suite) -> []; +'TimeBase_UtcT'(_) -> + ?match(true, orber_tc:check_tc('TimeBase_UtcT':tc())), + ?match("IDL:omg.org/TimeBase/UtcT:1.0", + 'TimeBase_UtcT':id()), + ?match("TimeBase_UtcT", + 'TimeBase_UtcT':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTime_TimeUnavailable' +%% Description: +%%----------------------------------------------------------------- +'CosTime_TimeUnavailable'(doc) -> ["CosTime_TimeUnavailable"]; +'CosTime_TimeUnavailable'(suite) -> []; +'CosTime_TimeUnavailable'(_) -> + ?match(true, orber_tc:check_tc('CosTime_TimeUnavailable':tc())), + ?match("IDL:omg.org/CosTime/TimeUnavailable:1.0", + 'CosTime_TimeUnavailable':id()), + ?match("CosTime_TimeUnavailable", + 'CosTime_TimeUnavailable':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTimerEvent_TimerEventT' +%% Description: +%%----------------------------------------------------------------- +'CosTimerEvent_TimerEventT'(doc) -> ["CosTimerEvent_TimerEventT"]; +'CosTimerEvent_TimerEventT'(suite) -> []; +'CosTimerEvent_TimerEventT'(_) -> + ?match(true, orber_tc:check_tc('CosTimerEvent_TimerEventT':tc())), + ?match("IDL:omg.org/CosTimerEvent/TimerEventT:1.0", + 'CosTimerEvent_TimerEventT':id()), + ?match("CosTimerEvent_TimerEventT", + 'CosTimerEvent_TimerEventT':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTime_TIO' +%% Description: +%%----------------------------------------------------------------- +'CosTime_TIO'(doc) -> ["CosTime_TIO"]; +'CosTime_TIO'(suite) -> []; +'CosTime_TIO'(_) -> + ?nomatch(undefined, 'CosTime_TIO':oe_tc('_get_time_interval')), + ?nomatch(undefined, 'CosTime_TIO':oe_tc(spans)), + ?nomatch(undefined, 'CosTime_TIO':oe_tc(overlaps)), + ?nomatch(undefined, 'CosTime_TIO':oe_tc(time)), + ?match(undefined, 'CosTime_TIO':oe_tc(undefined)), + ?match([_|_], 'CosTime_TIO':oe_get_interface()), + ?match("IDL:omg.org/CosTime/TIO:1.0", 'CosTime_TIO':typeID()), + check_tc('CosTime_TIO':oe_get_interface()), + ?match(true, 'CosTime_TIO':oe_is_a('CosTime_TIO':typeID())), + ?match(false, 'CosTime_TIO':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTime_TimeService' +%% Description: +%%----------------------------------------------------------------- +'CosTime_TimeService'(doc) -> ["CosTime_TimeService"]; +'CosTime_TimeService'(suite) -> []; +'CosTime_TimeService'(_) -> + ?nomatch(undefined, 'CosTime_TimeService':oe_tc(universal_time)), + ?nomatch(undefined, 'CosTime_TimeService':oe_tc(secure_universal_time)), + ?nomatch(undefined, 'CosTime_TimeService':oe_tc(new_universal_time)), + ?nomatch(undefined, 'CosTime_TimeService':oe_tc(uto_from_utc)), + ?nomatch(undefined, 'CosTime_TimeService':oe_tc(new_interval)), + ?match(undefined, 'CosTime_TimeService':oe_tc(undefined)), + ?match([_|_], 'CosTime_TimeService':oe_get_interface()), + ?match("IDL:omg.org/CosTime/TimeService:1.0", + 'CosTime_TimeService':typeID()), + check_tc('CosTime_TimeService':oe_get_interface()), + ?match(true, 'CosTime_TimeService':oe_is_a('CosTime_TimeService':typeID())), + ?match(false, 'CosTime_TimeService':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTime_UTO' +%% Description: +%%----------------------------------------------------------------- +'CosTime_UTO'(doc) -> ["CosTime_UTO"]; +'CosTime_UTO'(suite) -> []; +'CosTime_UTO'(_) -> + ?nomatch(undefined, 'CosTime_UTO':oe_tc('_get_time')), + ?nomatch(undefined, 'CosTime_UTO':oe_tc('_get_inaccuracy')), + ?nomatch(undefined, 'CosTime_UTO':oe_tc('_get_tdf')), + ?nomatch(undefined, 'CosTime_UTO':oe_tc('_get_utc_time')), + ?nomatch(undefined, 'CosTime_UTO':oe_tc(absolute_time)), + ?nomatch(undefined, 'CosTime_UTO':oe_tc(compare_time)), + ?nomatch(undefined, 'CosTime_UTO':oe_tc(time_to_interval)), + ?nomatch(undefined, 'CosTime_UTO':oe_tc(interval)), + ?match(undefined, 'CosTime_UTO':oe_tc(undefined)), + ?match([_|_], 'CosTime_UTO':oe_get_interface()), + ?match("IDL:omg.org/CosTime/UTO:1.0", 'CosTime_UTO':typeID()), + check_tc('CosTime_UTO':oe_get_interface()), + ?match(true, 'CosTime_UTO':oe_is_a('CosTime_UTO':typeID())), + ?match(false, 'CosTime_UTO':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTimerEvent_TimerEventHandler' +%% Description: +%%----------------------------------------------------------------- +'CosTimerEvent_TimerEventHandler'(doc) -> ["CosTimerEvent_TimerEventHandler"]; +'CosTimerEvent_TimerEventHandler'(suite) -> []; +'CosTimerEvent_TimerEventHandler'(_) -> + ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc('_get_status')), + ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(time_set)), + ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(set_timer)), + ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(cancel_timer)), + ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(set_data)), + ?match(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(undefined)), + ?match([_|_], 'CosTimerEvent_TimerEventHandler':oe_get_interface()), + ?match("IDL:omg.org/CosTimerEvent/TimerEventHandler:1.0", + 'CosTimerEvent_TimerEventHandler':typeID()), + check_tc('CosTimerEvent_TimerEventHandler':oe_get_interface()), + ?match(true, 'CosTimerEvent_TimerEventHandler':oe_is_a('CosTimerEvent_TimerEventHandler':typeID())), + ?match(false, 'CosTimerEvent_TimerEventHandler':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTimerEvent_TimerEventService' +%% Description: +%%----------------------------------------------------------------- +'CosTimerEvent_TimerEventService'(doc) -> ["CosTimerEvent_TimerEventService"]; +'CosTimerEvent_TimerEventService'(suite) -> []; +'CosTimerEvent_TimerEventService'(_) -> + ?nomatch(undefined, 'CosTimerEvent_TimerEventService':oe_tc(register)), + ?nomatch(undefined, 'CosTimerEvent_TimerEventService':oe_tc(unregister)), + ?nomatch(undefined, 'CosTimerEvent_TimerEventService':oe_tc(event_time)), + ?match(undefined, 'CosTimerEvent_TimerEventService':oe_tc(undefined)), + ?match([_|_], 'CosTimerEvent_TimerEventService':oe_get_interface()), + ?match("IDL:omg.org/CosTimerEvent/TimerEventService:1.0", + 'CosTimerEvent_TimerEventService':typeID()), + check_tc('CosTimerEvent_TimerEventService':oe_get_interface()), + ?match(true, 'CosTimerEvent_TimerEventService':oe_is_a('CosTimerEvent_TimerEventService':typeID())), + ?match(false, 'CosTimerEvent_TimerEventService':oe_is_a("wrong")), + ok. + + + + +%%----------------------------------------------------------------- +%% MISC functions +%%----------------------------------------------------------------- +check_tc([]) -> + ok; +check_tc([{Op, {RetType, InParameters, OutParameters}}|T]) -> + io:format("checked - ~s~n", [Op]), + lists:all(?checktc(Op), [RetType|InParameters]), + lists:all(?checktc(Op), OutParameters), + check_tc(T). + + diff --git a/lib/cosTime/test/time_SUITE.erl b/lib/cosTime/test/time_SUITE.erl new file mode 100644 index 0000000000..bb00395885 --- /dev/null +++ b/lib/cosTime/test/time_SUITE.erl @@ -0,0 +1,295 @@ +%%-------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%---------------------------------------------------------------------- +%% File : time_SUITE.erl +%% Purpose : +%%---------------------------------------------------------------------- + +-module(time_SUITE). + + +%%--------------- INCLUDES ----------------------------------- +-include("../src/cosTimeApp.hrl"). + +-include("test_server.hrl"). + +%%--------------- DEFINES ------------------------------------ +-define(default_timeout, ?t:minutes(20)). +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + exit(AcTuAlReS) + end + end()). + +-define(match_inverse(NotExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + NotExpectedRes -> + io:format("###### ERROR ERROR ######~n ~p~n", + [AcTuAlReS]), + exit(AcTuAlReS); + _ -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS + end + end()). + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, time_api/1, timerevent_api/1, + init_per_testcase/2, fin_per_testcase/2, + app_test/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for the cosTime interfaces", ""]; +all(suite) -> {req, + [mnesia, orber], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [time_api, timerevent_api, app_test]. + + + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + mnesia:delete_schema([node()]), + mnesia:create_schema([node()]), + orber:install([node()]), + application:start(mnesia), + application:start(orber), + cosNotificationApp:install_event(), + cosNotificationApp:install(), + cosTime:install_time(), + cosTime:install_timerevent(), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + cosTime:uninstall_time(), + cosTime:uninstall_timerevent(), + cosNotificationApp:uninstall(), + cosNotificationApp:uninstall_event(), + application:stop(orber), + application:stop(mnesia), + mnesia:delete_schema([node()]), + Config. + +%%----------------------------------------------------------------- +%% Tests app file +%%----------------------------------------------------------------- +app_test(doc) -> []; +app_test(suite) -> []; +app_test(_Config) -> + ok=test_server:app_test(cosTime), + ok. + +%%----------------------------------------------------------------- +%% CosTime API tests +%%----------------------------------------------------------------- +time_api(doc) -> ["CosTime API tests.", ""]; +time_api(suite) -> []; +time_api(_Config) -> + ?line ?match(ok, application:start(cosTime)), + TS=cosTime:start_time_service(0, 500), + Time=calendar:datetime_to_gregorian_seconds({{1582,1,1},{0,0,0}}), + Inaccuracy = 1000, + Tdf =1, + Utc = #'TimeBase_UtcT'{time=Time, inacclo = ?low_TimeT(Inaccuracy), + inacchi = ?high_TimeT(Inaccuracy), tdf = Tdf}, + ?line UTO1='CosTime_TimeService':new_universal_time(TS, Time, Inaccuracy, Tdf), + ?line UTO2='CosTime_TimeService':uto_from_utc(TS, Utc), + ?line ?match(Time, 'CosTime_UTO':'_get_time'(UTO1)), + ?line ?match(Inaccuracy, 'CosTime_UTO':'_get_inaccuracy'(UTO1)), + ?line ?match(Tdf, 'CosTime_UTO':'_get_tdf'(UTO1)), + ?line ?match(Utc, 'CosTime_UTO':'_get_utc_time'(UTO1)), + + ?line ?match(Time, 'CosTime_UTO':'_get_time'(UTO2)), + ?line ?match(Inaccuracy, 'CosTime_UTO':'_get_inaccuracy'(UTO2)), + ?line ?match(Tdf, 'CosTime_UTO':'_get_tdf'(UTO2)), + ?line ?match(Utc, 'CosTime_UTO':'_get_utc_time'(UTO2)), + + TIO1='CosTime_TimeService':new_interval(TS, 2, 5), + _TIO2='CosTime_TimeService':new_interval(TS, 3, 6), + TIO3='CosTime_TimeService':new_interval(TS, 1, 3), + TIO4='CosTime_TimeService':new_interval(TS, 3, 4), + TIO5='CosTime_TimeService':new_interval(TS, 7, 8), + TIO6='CosTime_TimeService':new_interval(TS, 2, 6), + TIO7='CosTime_TimeService':new_interval(TS, 3, 7), + + ?line {_,TIO8} = ?match({'OTContained', _}, 'CosTime_TIO':overlaps(TIO1, TIO6)), + ?line {_,TIO9} = ?match({'OTContainer', _}, 'CosTime_TIO':overlaps(TIO1, TIO1)), + ?line {_,TIO10} = ?match({'OTContainer', _}, 'CosTime_TIO':overlaps(TIO1, TIO4)), + ?line {_,TIO11} = ?match({'OTOverlap', _}, 'CosTime_TIO':overlaps(TIO1, TIO3)), + ?line {_,TIO12} = ?match({'OTOverlap', _}, 'CosTime_TIO':overlaps(TIO1, TIO7)), + ?line {_,TIO13} = ?match({'OTNoOverlap', _}, 'CosTime_TIO':overlaps(TIO1, TIO5)), + + ?line ?match({'TimeBase_IntervalT',2,5},'CosTime_TIO':'_get_time_interval'(TIO8)), + ?line ?match({'TimeBase_IntervalT',2,5},'CosTime_TIO':'_get_time_interval'(TIO9)), + ?line ?match({'TimeBase_IntervalT',3,4},'CosTime_TIO':'_get_time_interval'(TIO10)), + ?line ?match({'TimeBase_IntervalT',2,3},'CosTime_TIO':'_get_time_interval'(TIO11)), + ?line ?match({'TimeBase_IntervalT',3,5},'CosTime_TIO':'_get_time_interval'(TIO12)), + ?line ?match({'TimeBase_IntervalT',5,7},'CosTime_TIO':'_get_time_interval'(TIO13)), + + ?line UTO3='CosTime_TimeService':new_universal_time(TS, 4, 2, 0), %% 2-6 + ?line UTO4='CosTime_TimeService':new_universal_time(TS, 2, 1, 0), %% 1-3 + ?line UTO5='CosTime_TimeService':new_universal_time(TS, 3, 0, 0), %% 3-3 + ?line UTO6='CosTime_TimeService':new_universal_time(TS, 9, 1, 0), %% 8-10 + ?line UTO7='CosTime_TimeService':new_universal_time(TS, 4, 3, 0), %% 1-7 + ?line UTO8='CosTime_TimeService':new_universal_time(TS, 5, 2, 0), %% 3-7 + + ?line {_,TIO14} = ?match({'OTContained', _}, 'CosTime_TIO':spans(TIO1, UTO7)), + ?line {_,TIO15} = ?match({'OTContainer', _}, 'CosTime_TIO':spans(TIO1, UTO5)), + ?line {_,TIO16} = ?match({'OTOverlap', _}, 'CosTime_TIO':spans(TIO1, UTO4)), + ?line {_,TIO17} = ?match({'OTOverlap', _}, 'CosTime_TIO':spans(TIO1, UTO8)), + ?line {_,TIO18} = ?match({'OTNoOverlap', _}, 'CosTime_TIO':spans(TIO1, UTO6)), + ?line {_,TIO19} = ?match({'OTContained', _}, 'CosTime_TIO':spans(TIO1, UTO3)), + + ?line ?match({'TimeBase_IntervalT',2,5},'CosTime_TIO':'_get_time_interval'(TIO14)), + ?line ?match({'TimeBase_IntervalT',3,3},'CosTime_TIO':'_get_time_interval'(TIO15)), + ?line ?match({'TimeBase_IntervalT',2,3},'CosTime_TIO':'_get_time_interval'(TIO16)), + ?line ?match({'TimeBase_IntervalT',3,5},'CosTime_TIO':'_get_time_interval'(TIO17)), + ?line ?match({'TimeBase_IntervalT',5,8},'CosTime_TIO':'_get_time_interval'(TIO18)), + ?line ?match({'TimeBase_IntervalT',2,5},'CosTime_TIO':'_get_time_interval'(TIO19)), + + + cosTime:stop_time_service(TS), + application:stop(cosTime), + ok. + + +%%----------------------------------------------------------------- +%% CosTimerEvent API tests +%%----------------------------------------------------------------- +timerevent_api(doc) -> ["CosTimerEvent API tests.", ""]; +timerevent_api(suite) -> []; +timerevent_api(_Config) -> + %% Init cosTime apps. + ?line ?match(ok, application:start(cosTime)), + ?line TS=cosTime:start_time_service(0, 500), + ?line TES=cosTime:start_timerevent_service(TS), + + %%----- Initialize the cosNotification application. ----- + ?line cosNotificationApp:start(), + ?line Fac = (catch cosNotificationApp:start_factory([])), + ?line {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, [], [])), + %% Create the Admin objects + ?line {AdminSupplier, _ASID}= ?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'OR_OP')), + ?line {AdminConsumer, _ACID}= ?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'OR_OP')), + + %% Create a push consumer TimerEventService will push events to. + ?line {ProxyPushConsumer,_ID10}= ?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'ANY_EVENT')), + + %% Create a pull suppliers so we can check we actually got the event. + ?line {ProxyPullSupplier,_ID1} = ?match({{_,key,_,_,_,_},_}, + 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'ANY_EVENT')), + + AnyEvent = any:create(orber_tc:long(), 100), + ?line UTO=?match({_,pseudo,_,_,_,_}, 'CosTime_TimeService':new_universal_time(TS, 10*10000000,1,1)), + ?line EH=?match({_,key,_,_,_,_}, 'CosTimerEvent_TimerEventService':register(TES, ProxyPushConsumer, AnyEvent)), + + ?line ?match('ESTimeCleared','CosTimerEvent_TimerEventHandler':'_get_status'(EH)), + ?line ?match({false,_},'CosTimerEvent_TimerEventHandler':time_set(EH)), + ?line ?match(ok,'CosTimerEvent_TimerEventHandler':set_timer(EH, 'TTRelative', UTO)), + ?line ?match({true,_},'CosTimerEvent_TimerEventHandler':time_set(EH)), + ?line ?match('ESTimeSet','CosTimerEvent_TimerEventHandler':'_get_status'(EH)), + + ?line ?match({{any,tk_null,null}, false}, + 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(ProxyPullSupplier)), + + ?line ?match(AnyEvent, 'CosNotifyChannelAdmin_ProxyPullSupplier':pull(ProxyPullSupplier)), + ?line ?match('ESTriggered','CosTimerEvent_TimerEventHandler':'_get_status'(EH)), + + %% It's allowed to send an UTO with time eq. to 0 if the server is TTRelative. + %% When TTAbsolute BAD_PARAM is raised. + ?line UTO2=?match({_,pseudo,_,_,_,_}, 'CosTime_TimeService':new_universal_time(TS, 0,1,1)), + ?line ?match({'EXCEPTION',_},'CosTimerEvent_TimerEventHandler':set_timer(EH, 'TTAbsolute', UTO2)), + ?line ?match(ok,'CosTimerEvent_TimerEventHandler':set_timer(EH, 'TTRelative', UTO2)), + ?line ?match(AnyEvent, 'CosNotifyChannelAdmin_ProxyPullSupplier':pull(ProxyPullSupplier)), + + %% TTPeriodic is defined to be relative, i.e., we can use the tactic as above. + ?line ?match(ok,'CosTimerEvent_TimerEventHandler':set_timer(EH, 'TTPeriodic', UTO2)), + + %% Sleep for UTO*2+4 secs. At this point the Timer should have delivered 2 events. + timer:sleep(24000), + %% Cancel the timer so no more events will be delivered. + ?line ?match(true,'CosTimerEvent_TimerEventHandler':cancel_timer(EH)), + + ?line ?match({AnyEvent, true}, 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(ProxyPullSupplier)), + ?line ?match({AnyEvent, true}, 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(ProxyPullSupplier)), + ?line ?match({{any,tk_null,null}, false}, + 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(ProxyPullSupplier)), + + + + %% Clean up. + cosNotificationApp:stop(), + cosTime:stop_timerevent_service(TES), + cosTime:stop_time_service(TS), + application:stop(cosTime), + ok. + + diff --git a/lib/cosTime/vsn.mk b/lib/cosTime/vsn.mk index db51bf39b9..9d8057e8db 100644 --- a/lib/cosTime/vsn.mk +++ b/lib/cosTime/vsn.mk @@ -1,6 +1,8 @@ -COSTIME_VSN = 1.1.8 +COSTIME_VSN = 1.1.9 -TICKETS = OTP-8355 +TICKETS = OTP-8543 + +TICKETS_1.1.8 = OTP-8355 TICKETS_1.1.7 = OTP-8201 diff --git a/lib/cosTransactions/doc/src/notes.xml b/lib/cosTransactions/doc/src/notes.xml index 77541a9f85..7586e3c13f 100644 --- a/lib/cosTransactions/doc/src/notes.xml +++ b/lib/cosTransactions/doc/src/notes.xml @@ -34,7 +34,17 @@ <section> <title>cosTransactions 1.2.10</title> - + <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Test suites published.</p> + <p> + Own Id: OTP-8543 Aux Id:</p> + </item> + </list> + </section> <section> <title>Fixed Bugs and Malfunctions</title> <list type="bulleted"> diff --git a/lib/cosTransactions/test/Makefile b/lib/cosTransactions/test/Makefile new file mode 100644 index 0000000000..8b1264d404 --- /dev/null +++ b/lib/cosTransactions/test/Makefile @@ -0,0 +1,150 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1999-2009. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +#ifeq ($(TYPE),debug) +#ERL_COMPILE_FLAGS += -Ddebug -W +#endif + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(COSTRANSACTIONS_VSN) +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/cosTransactions_test + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +TEST_SPEC_FILE = cosTransactions.spec + + +IDL_FILES = \ + etrap_test.idl + +IDLOUTDIR = idl_output + +MODULES = \ + transactions_SUITE \ + etrap_test_server_impl \ + etrap_test_lib \ + generated_SUITE + +GEN_MODULES = \ + oe_etrap_test \ + etrap_test_server + +GEN_HRL_FILES = \ + oe_etrap_test.hrl \ + etrap_test_server.hrl + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = \ + etrap_test_lib.hrl + +GEN_FILES = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +GEN_TARGET_FILES = $(GEN_MODULES:%=$(IDLOUTDIR)/%.$(EMULATOR)) + +SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) + +TARGET_FILES = \ + $(GEN_TARGET_FILES) \ + $(SUITE_TARGET_FILES) + + +# ---------------------------------------------------- +# PROGRAMS +# ---------------------------------------------------- +LOCAL_CLASSPATH = $(ERL_TOP)/lib/cosTransactions/priv:$(ERL_TOP)/lib/cosTransactions/test +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/cosTransactions/ebin\ + -pa $(ERL_TOP)/lib/orber/ebin \ + -pa $(ERL_TOP)/lib/ic/ebin + +ERL_COMPILE_FLAGS += \ + $(ERL_IDL_FLAGS) \ + -pa $(ERL_TOP)/lib/orber/include \ + -pa $(ERL_TOP)/lib/test_server/ebin \ + -pa $(ERL_TOP)/lib/cosTransactions/ebin \ + -pa $(ERL_TOP)/lib/cosTransactions/test/idl_output \ + -I$(ERL_TOP)/lib/orber/include \ + -I$(ERL_TOP)/lib/cosTransactions \ + -I$(ERL_TOP)/lib/cosTransactions/test/$(IDLOUTDIR) \ + -I$(ERL_TOP)/lib/test_server/include + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- + + +tests debug opt: $(TARGET_FILES) + +clean: + rm -f idl_output/* + rm -f $(TARGET_FILES) + rm -f errs core *~ + +#debug: +# @${MAKE} TYPE=debug + +docs: + +# ---------------------------------------------------- +# Special Targets +# ---------------------------------------------------- + +TGT_TEST = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +$(TGT_TEST): etrap_test.idl + erlc $(ERL_IDL_FLAGS) -o$(IDLOUTDIR) \ + +'{cfgfile,"etrap_test.cfg"}' etrap_test.idl + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +# We don't copy generated intermediate erlang and hrl files + +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: + +release_docs_spec: + +release_tests_spec: tests + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(IDL_FILES) $(TEST_SPEC_FILE) \ + $(ERL_FILES) $(HRL_FILES) $(RELSYSDIR) + $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR) + $(INSTALL_DIR) $(RELSYSDIR)/$(IDLOUTDIR) + $(INSTALL_DATA) $(GEN_TARGET_FILES) $(GEN_FILES) \ + $(RELSYSDIR)/$(IDLOUTDIR) + diff --git a/lib/cosTransactions/test/cosTransactions.spec b/lib/cosTransactions/test/cosTransactions.spec new file mode 100644 index 0000000000..8ad9259964 --- /dev/null +++ b/lib/cosTransactions/test/cosTransactions.spec @@ -0,0 +1,19 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{topcase, {dir, "../cosTransactions_test"}}. diff --git a/lib/cosTransactions/test/etrap_test.cfg b/lib/cosTransactions/test/etrap_test.cfg new file mode 100644 index 0000000000..4f2b9e125d --- /dev/null +++ b/lib/cosTransactions/test/etrap_test.cfg @@ -0,0 +1,20 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{this, "etrap_test::server"}. +{{handle_info, "etrap_test::server"}, true}. diff --git a/lib/cosTransactions/test/etrap_test.idl b/lib/cosTransactions/test/etrap_test.idl new file mode 100644 index 0000000000..7573cc1a36 --- /dev/null +++ b/lib/cosTransactions/test/etrap_test.idl @@ -0,0 +1,38 @@ +// +// %CopyrightBegin% +// +// Copyright Ericsson AB 1999-2010. All Rights Reserved. +// +// The contents of this file are subject to the Erlang Public License, +// Version 1.1, (the "License"); you may not use this file except in +// compliance with the License. You should have received a copy of the +// Erlang Public License along with this software. If not, it can be +// retrieved online at http://www.erlang.org/. +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +// the License for the specific language governing rights and limitations +// under the License. +// +// %CopyrightEnd% +// + +#ifndef _TEST_IDL +#define _TEST_IDL +#include <../src/CosTransactions.idl> +module etrap_test { + + // interface server + interface server : + CosTransactions::Coordinator, CosTransactions::SubtransactionAwareResource, + CosTransactions::RecoveryCoordinator, CosTransactions::Control { + }; +// interface Server : +// CosTransactions::Coordinator, CosTransactions::SubtransactionAwareResource, +// CosTransactions::RecoveryCoordinator, CosTransactions::Control, +// CosTransactions::Synchronization { +// }; + +}; // End of test Module + +#endif diff --git a/lib/cosTransactions/test/etrap_test_lib.erl b/lib/cosTransactions/test/etrap_test_lib.erl new file mode 100644 index 0000000000..913a94510f --- /dev/null +++ b/lib/cosTransactions/test/etrap_test_lib.erl @@ -0,0 +1,125 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(etrap_test_lib). + +%%--------------- INCLUDES --------------------------------------------- +-include("etrap_test_lib.hrl"). +-include_lib("cosTransactions/src/ETraP_Common.hrl"). + +%%--------------- EXPORTS ---------------------------------------------- +-export([scratch_debug_fun/0, + activate_debug_fun/5, + update_debug_info/1, + deactivate_debug_fun/3, + eval_debug_fun/4, + set_debug_context/4]). + +%%--------------- CONSTANTS/DEFINITIONS -------------------------------- +-define(DEBUG_TAB, etrap_debug). +-record(debug_info, {id, function, type, file, line}). + +%%--------------- DEBUG FUNCTIONS -------------------------------------- +%% Managing conditional debug functions +%% +%% The main idea with the debug_fun's is to allow test programs +%% to control the internal behaviour of CosTransactions. +%% +%% First should calls to ?eval_debug_fun be inserted at well +%% defined places in CosTransaction's code. E.g. in critical situations +%% of startup, transaction commit, backups etc. +%% +%% Then compile CosTransactions with the compiler option 'debug'. +%% +%% In test programs ?activate_debug_fun should be called +%% in order to bind a fun to the debug identifier stated +%% in the call to ?eval_debug_fun. + +scratch_debug_fun() -> + catch ets:delete(?DEBUG_TAB), + ets:new(?DEBUG_TAB, + [set, public, named_table, {keypos, 2}]). + +activate_debug_fun(FunId, Fun, Type, File, Line) -> + io:format("Activiating ~p RETRIES: ~p WAIT: ~p~n", + [FunId, ?tr_max_retries, ?tr_comm_failure_wait]), + Info = #debug_info{id = FunId, + function = Fun, + type = Type, + file = File, + line = Line}, + update_debug_info(Info). + +update_debug_info(Info) -> + case catch ets:insert(?DEBUG_TAB, Info) of + {'EXIT', _} -> + scratch_debug_fun(), + ets:insert(?DEBUG_TAB, Info); + _ -> + ok + end, + ok. + +deactivate_debug_fun(FunId, _File, _Line) -> + catch ets:delete(?DEBUG_TAB, FunId), + ok. + +eval_debug_fun(FunId, Env, File, Line) -> + case catch ets:lookup(?DEBUG_TAB, FunId) of + [] -> + ok; + [Info] -> + Fun = Info#debug_info.function, + case Info#debug_info.type of + transient -> + deactivate_debug_fun(FunId, File, Line); + _-> + ok + end, + io:format("Running debug fun ~p:~p (LINE: ~p)~n", [File, FunId, Line]), + Fun(Env); + {'EXIT', _R} -> + ok + end. + + +set_debug_context([], [], _, _)-> ok; +set_debug_context([], _, _, _)-> + ets:delete(?DEBUG_TAB), + exit("failed transactions_SUITE. Bad configuration."); +set_debug_context(_, [], _, _)-> + ets:delete(?DEBUG_TAB), + exit("failed transactions_SUITE Bad configuration."); +set_debug_context([RHead|RTail], [CHead|CTail], File, Line)-> + write_context(RHead, CHead, File, Line), + set_debug_context(RTail, CTail, File, Line). + +write_context(_Resource, [], _, _)-> ok; +write_context(Resource, [{Func, Fun, Type}|PTail], File, Line)-> + etrap_test_lib:activate_debug_fun({Resource, Func}, + Fun, Type, + File, Line), + write_context(Resource, PTail, File, Line); +write_context(_,_, _, _) -> + ets:delete(?DEBUG_TAB), + exit("failed transactions_SUITE. Bad configuration."). + + +%%--------------- END OF MODULE ---------------------------------------- diff --git a/lib/cosTransactions/test/etrap_test_lib.hrl b/lib/cosTransactions/test/etrap_test_lib.hrl new file mode 100644 index 0000000000..d488bf9d12 --- /dev/null +++ b/lib/cosTransactions/test/etrap_test_lib.hrl @@ -0,0 +1,100 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-ifndef(ETRAP_TEST_LIB_HRL). +-define(ETRAP_TEST_LIB_HRL, true). + +-define(match(ExpectedRes, Expr, Msg), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("~n------ CORRECT RESULT ------~n~p~n~p~n", + [AcTuAlReS, Msg]), + ok; + _ -> + io:format("~n###### ERROR ERROR ######~n~p~n~p~n", + [AcTuAlReS, Msg]), + exit(AcTuAlReS) + end + end()). + +-define(match_inverse(NotExpectedRes, Expr, Msg), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + NotExpectedRes -> + io:format("~n###### ERROR ERROR ######~n ~p~n~p~n", + [AcTuAlReS, Msg]), + exit(AcTuAlReS); + _ -> + io:format("~n------ CORRECT RESULT ------~n~p~n~p~n", + [AcTuAlReS, Msg]), + ok + end + end()). + + +-define(crash_and_recover, fun(_Env)-> exit(crash_and_burn) end). + +-define(crash_no_recovery, fun(Env)-> throw({stop,normal,{Env,state}}) end). + +-define(delay(Time), fun(_Id) -> timer:sleep(Time*1000) end). + +-define(TIMEOUT, 4). +-define(SUP_TEST(Env, Name), + ['etrap_test_server', Env, + [{sup_child, true}, {persistent, true}, + {regname, {global, Name}}]]). + +-define(no_context, [[],[],[], []]). +-define(nop, []). +-define(delay_transient(Tag, Ti), + [{Tag, ?delay(Ti), transient}]). +-define(crash_transient(Tag), + [{Tag, ?crash_and_recover, transient}]). +-define(crash_permanent(Tag), + [{Tag, ?crash_no_recovery, permanent}]). + +%%----------------------------------------------------------- +%% Definition of 'Resource' action. +%% function action reply +%%----------------------------------------------------------- +%% raise #'CosTransactions_HeuristicMixed' {} +-define(rollback_mix, [{rollback, exc, ?tr_mixed}]). +-define(commit_mix, [{commit, exc, ?tr_mixed}]). +-define(prepare_mix, [{prepare, exc, ?tr_mixed}]). +%% raise #'CosTransactions_HeuristicRollback' {} +-define(rollback_rb, [{rollback, exc, ?tr_rollback}]). +-define(commit_rb, [{commit, exc, ?tr_rollback}]). +%% raise #'CosTransactions_HeuristicCommit' {} +-define(rollback_cm, [{rollback, exc, ?tr_commit}]). +-define(commit_cm, [{commit, exc, ?tr_commit}]). +%% delay reply +-define(rollback_delay, [{rollback, delay, ?TIMEOUT*2}]). +-define(commit_delay, [{commit, delay, ?TIMEOUT*2}]). +-define(prepare_delay, [{prepare, delay, ?TIMEOUT*2}]). +%% other reply than default +-define(prepare_commit, [{prepare, reply, 'VoteCommit'}]). +-define(prepare_rollback, [{prepare, stop_reply, 'VoteRollback'}]). + +-endif. + +%%-------------- EOF --------------------------------------------------- diff --git a/lib/cosTransactions/test/etrap_test_server_impl.erl b/lib/cosTransactions/test/etrap_test_server_impl.erl new file mode 100644 index 0000000000..69c823f3ca --- /dev/null +++ b/lib/cosTransactions/test/etrap_test_server_impl.erl @@ -0,0 +1,210 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(etrap_test_server_impl). + +%%--------------- INCLUDES ----------------------------------- +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/include/ifr_types.hrl"). +%% Local +-include_lib("cosTransactions/src/ETraP_Common.hrl"). +-include_lib("cosTransactions/include/CosTransactions.hrl"). +%%--------------- IMPORTS------------------------------------- +%%--------------- EXPORTS------------------------------------- +-export([prepare/2, + rollback/2, + commit/2, + commit_one_phase/2, + forget/2, +% before_completion/2, +% after_completion/3, + commit_subtransaction/3, + rollback_subtransaction/2]). + + +%%--------------- gen_server specific ------------------------ +-export([init/1, terminate/2]). +-export([handle_call/3, handle_cast/2, handle_info/2, code_change/3]). + +%%------------------------------------------------------------ +%% function : init, terminate +%%------------------------------------------------------------ +init(State) -> + process_flag(trap_exit,true), + io:format("etrap_test_server:init ~p~n", [State]), + ?debug_print("STARTING etrap_test_server( ~p )~n", [State]), + {ok, State}. + +terminate(Reason, _State) -> + io:format("etrap_test_server:terminate ~p~n", [Reason]), + ?debug_print("STOPREASON etrap_test_server( ~p )~n", [Reason]), + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. +handle_call(_,_, State) -> + {noreply, State}. +handle_cast(_, State) -> + {noreply, State}. +handle_info(_Info, State) -> + {noreply, State}. + +%%-- Inherit from CosTransactions::SubtransactionAwareResource -- +prepare(_Self, State) -> + case ?is_debug_compiled of + true -> + io:format("etrap_test_server:prepare ~p~n", [State]); + _-> + ok + end, +% ?debug_print("etrap_test_server:prepare ~p~n", [State]), + action(prepare, State, {reply, 'VoteCommit', State}). + +rollback(_Self, State) -> + case ?is_debug_compiled of + true -> + io:format("etrap_test_server:rollback ~p~n", [State]); + _-> + ok + end, +% ?debug_print("etrap_test_server:rollback ~p~n", [State]), + case sync_test(State) of + true -> + action(rollback, State, {reply, ok, State}); + _-> + action(rollback, State, {stop, normal, ok, State}) + end. + +commit(_Self, State) -> + case ?is_debug_compiled of + true -> + io:format("etrap_test_server:commit ~p~n", [State]); + _-> + ok + end, +% ?debug_print("etrap_test_server:commit ~p~n", [State]), + case sync_test(State) of + true -> + action(commit, State, {reply, ok, State}); + _-> + action(commit, State, {stop, normal, ok, State}) + end. + +commit_one_phase(_Self, State) -> + case ?is_debug_compiled of + true -> + io:format("etrap_test_server:commit_one_phase ~p~n", [State]); + _-> + ok + end, +% ?debug_print("etrap_test_server:commit_one_phase ~p~n", [State]), + case sync_test(State) of + true -> + {reply, ok, State}; + _-> + {stop, normal, ok, State} + end. + +forget(_Self, State) -> + case ?is_debug_compiled of + true -> + io:format("etrap_test_server:forget ~p~n", [State]); + _-> + ok + end, +% ?debug_print("etrap_test_server:forget ~p~n", [State]), + case sync_test(State) of + true -> + {reply, ok, State}; + _-> + {stop, normal, ok, State} + end. + +commit_subtransaction(_Self, State, Parent) -> + case ?is_debug_compiled of + true -> + io:format("etrap_test_server:commit_subtransaction( ~p )~n", [Parent]); + _-> + ok + end, +% ?debug_print("etrap_test_server:commit_subtransaction( ~p )~n", [Parent]), + {reply, ok, State}. +rollback_subtransaction(_Self, State) -> + case ?is_debug_compiled of + true -> + io:format("etrap_test_server:rollback_subtransaction()~n", []); + _-> + ok + end, +% ?debug_print("etrap_test_server:rollback_subtransaction()~n", []), + {reply, ok, State}. + +%before_completion(_Self, State) -> +% case ?is_debug_compiled of +% true -> +% io:format("etrap_test_server:before_completion()~n", []); +% _-> +% ok +% end, +%% ?debug_print("etrap_test_server:before_completion()~n", []), +% {reply, ok, State}. +%after_completion(_Self, State, Status) -> +% case ?is_debug_compiled of +% true -> +% io:format("etrap_test_server:after_completion( ~p )~n", [Status]); +% _-> +% ok +% end, +%% ?debug_print("etrap_test_server:after_completion( ~p )~n", [Status]), +% {stop, normal, ok, State}. + +%%--------------- LOCAL FUNCTIONS ---------------------------- +action(Key, State, Default) -> + case catch lists:keysearch(Key, 1, State) of + {value,{Key, stop_reply, R}} -> + case sync_test(State) of + true -> + {reply, R, State}; + _-> + {stop, normal, R, State} + end; + {value,{Key, reply, R}} -> + {reply, R, State}; + {value,{Key, exc, E}} -> + corba:raise(E); + {value,{Key, delay, Time}} -> + timer:sleep(Time*1000), + Default; + {value,{Key,Value}} -> + Value; + _ -> + Default + end. + +sync_test(State) -> + case catch lists:keysearch(sync, 1, State) of + {value,{sync, true}} -> + true; + _ -> + false + end. + + +%%--------------- END OF MODULE ------------------------------ + diff --git a/lib/cosTransactions/test/generated_SUITE.erl b/lib/cosTransactions/test/generated_SUITE.erl new file mode 100644 index 0000000000..cc54eb168e --- /dev/null +++ b/lib/cosTransactions/test/generated_SUITE.erl @@ -0,0 +1,564 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : generated_SUITE.erl +%% Purpose : +%% Created : 27 Jan 2004 +%%----------------------------------------------------------------- + +-module(generated_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + AcTuAlReS + end + end()). + + +-define(checktc(_Op), + fun(TC) -> + case orber_tc:check_tc(TC) of + false -> + io:format("###### ERROR ERROR ######~n~p - ~p~n", [Op, TC]), + ?line exit(TC); + true -> + true + end + end). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing IC generated files"]; +all(suite) -> + ['CosTransactions_Control', 'CosTransactions_Coordinator', + 'CosTransactions_HeuristicCommit', 'CosTransactions_HeuristicHazard', + 'CosTransactions_HeuristicMixed', 'CosTransactions_HeuristicRollback', + 'CosTransactions_Inactive', 'CosTransactions_InvalidControl', + 'CosTransactions_NoTransaction', 'CosTransactions_NotPrepared', + 'CosTransactions_NotSubtransaction', 'CosTransactions_RecoveryCoordinator', + 'CosTransactions_Resource', 'CosTransactions_SubtransactionAwareResource', + 'CosTransactions_SubtransactionsUnavailable', 'CosTransactions_Terminator', + 'CosTransactions_TransactionFactory', 'CosTransactions_Unavailable', + 'CosTransactions_SynchronizationUnavailable', 'CosTransactions_TransIdentity', + 'CosTransactions_PropagationContext', 'CosTransactions_otid_t', + 'CosTransactions_WrongTransaction', 'ETraP_Server']. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_HeuristicCommit' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_HeuristicCommit'(doc) -> ["CosTransactions_HeuristicCommit"]; +'CosTransactions_HeuristicCommit'(suite) -> []; +'CosTransactions_HeuristicCommit'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_HeuristicCommit':tc())), + ?match("IDL:omg.org/CosTransactions/HeuristicCommit:1.0", + 'CosTransactions_HeuristicCommit':id()), + ?match("CosTransactions_HeuristicCommit", + 'CosTransactions_HeuristicCommit':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_HeuristicHazard' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_HeuristicHazard'(doc) -> ["CosTransactions_HeuristicHazard"]; +'CosTransactions_HeuristicHazard'(suite) -> []; +'CosTransactions_HeuristicHazard'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_HeuristicHazard':tc())), + ?match("IDL:omg.org/CosTransactions/HeuristicHazard:1.0", + 'CosTransactions_HeuristicHazard':id()), + ?match("CosTransactions_HeuristicHazard", + 'CosTransactions_HeuristicHazard':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_HeuristicMixed' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_HeuristicMixed'(doc) -> ["CosTransactions_HeuristicMixed"]; +'CosTransactions_HeuristicMixed'(suite) -> []; +'CosTransactions_HeuristicMixed'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_HeuristicMixed':tc())), + ?match("IDL:omg.org/CosTransactions/HeuristicMixed:1.0", + 'CosTransactions_HeuristicMixed':id()), + ?match("CosTransactions_HeuristicMixed", + 'CosTransactions_HeuristicMixed':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_HeuristicRollback' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_HeuristicRollback'(doc) -> ["CosTransactions_HeuristicRollback"]; +'CosTransactions_HeuristicRollback'(suite) -> []; +'CosTransactions_HeuristicRollback'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_HeuristicRollback':tc())), + ?match("IDL:omg.org/CosTransactions/HeuristicRollback:1.0", + 'CosTransactions_HeuristicRollback':id()), + ?match("CosTransactions_HeuristicRollback", + 'CosTransactions_HeuristicRollback':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_Inactive' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_Inactive'(doc) -> ["CosTransactions_Inactive"]; +'CosTransactions_Inactive'(suite) -> []; +'CosTransactions_Inactive'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_Inactive':tc())), + ?match("IDL:omg.org/CosTransactions/Inactive:1.0", + 'CosTransactions_Inactive':id()), + ?match("CosTransactions_Inactive", + 'CosTransactions_Inactive':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_InvalidControl' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_InvalidControl'(doc) -> ["CosTransactions_InvalidControl"]; +'CosTransactions_InvalidControl'(suite) -> []; +'CosTransactions_InvalidControl'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_InvalidControl':tc())), + ?match("IDL:omg.org/CosTransactions/InvalidControl:1.0", + 'CosTransactions_InvalidControl':id()), + ?match("CosTransactions_InvalidControl", + 'CosTransactions_InvalidControl':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_NoTransaction' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_NoTransaction'(doc) -> ["CosTransactions_NoTransaction"]; +'CosTransactions_NoTransaction'(suite) -> []; +'CosTransactions_NoTransaction'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_NoTransaction':tc())), + ?match("IDL:omg.org/CosTransactions/NoTransaction:1.0", + 'CosTransactions_NoTransaction':id()), + ?match("CosTransactions_NoTransaction", + 'CosTransactions_NoTransaction':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_NotPrepared' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_NotPrepared'(doc) -> ["CosTransactions_NotPrepared"]; +'CosTransactions_NotPrepared'(suite) -> []; +'CosTransactions_NotPrepared'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_NotPrepared':tc())), + ?match("IDL:omg.org/CosTransactions/NotPrepared:1.0", + 'CosTransactions_NotPrepared':id()), + ?match("CosTransactions_NotPrepared", + 'CosTransactions_NotPrepared':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_NotSubtransaction' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_NotSubtransaction'(doc) -> ["CosTransactions_NotSubtransaction"]; +'CosTransactions_NotSubtransaction'(suite) -> []; +'CosTransactions_NotSubtransaction'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_NotSubtransaction':tc())), + ?match("IDL:omg.org/CosTransactions/NotSubtransaction:1.0", + 'CosTransactions_NotSubtransaction':id()), + ?match("CosTransactions_NotSubtransaction", + 'CosTransactions_NotSubtransaction':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_SubtransactionsUnavailable' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_SubtransactionsUnavailable'(doc) -> ["CosTransactions_SubtransactionsUnavailable"]; +'CosTransactions_SubtransactionsUnavailable'(suite) -> []; +'CosTransactions_SubtransactionsUnavailable'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_SubtransactionsUnavailable':tc())), + ?match("IDL:omg.org/CosTransactions/SubtransactionsUnavailable:1.0", + 'CosTransactions_SubtransactionsUnavailable':id()), + ?match("CosTransactions_SubtransactionsUnavailable", + 'CosTransactions_SubtransactionsUnavailable':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_Unavailable' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_Unavailable'(doc) -> ["CosTransactions_Unavailable"]; +'CosTransactions_Unavailable'(suite) -> []; +'CosTransactions_Unavailable'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_Unavailable':tc())), + ?match("IDL:omg.org/CosTransactions/Unavailable:1.0", + 'CosTransactions_Unavailable':id()), + ?match("CosTransactions_Unavailable", + 'CosTransactions_Unavailable':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_SynchronizationUnavailable' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_SynchronizationUnavailable'(doc) -> ["CosTransactions_SynchronizationUnavailable"]; +'CosTransactions_SynchronizationUnavailable'(suite) -> []; +'CosTransactions_SynchronizationUnavailable'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_SynchronizationUnavailable':tc())), + ?match("IDL:omg.org/CosTransactions/SynchronizationUnavailable:1.0", + 'CosTransactions_SynchronizationUnavailable':id()), + ?match("CosTransactions_SynchronizationUnavailable", + 'CosTransactions_SynchronizationUnavailable':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_TransIdentity' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_TransIdentity'(doc) -> ["CosTransactions_TransIdentity"]; +'CosTransactions_TransIdentity'(suite) -> []; +'CosTransactions_TransIdentity'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_TransIdentity':tc())), + ?match("IDL:omg.org/CosTransactions/TransIdentity:1.0", + 'CosTransactions_TransIdentity':id()), + ?match("CosTransactions_TransIdentity", + 'CosTransactions_TransIdentity':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_PropagationContext' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_PropagationContext'(doc) -> ["CosTransactions_PropagationContext"]; +'CosTransactions_PropagationContext'(suite) -> []; +'CosTransactions_PropagationContext'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_PropagationContext':tc())), + ?match("IDL:omg.org/CosTransactions/PropagationContext:1.0", + 'CosTransactions_PropagationContext':id()), + ?match("CosTransactions_PropagationContext", + 'CosTransactions_PropagationContext':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_otid_t' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_otid_t'(doc) -> ["CosTransactions_otid_t"]; +'CosTransactions_otid_t'(suite) -> []; +'CosTransactions_otid_t'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_otid_t':tc())), + ?match("IDL:omg.org/CosTransactions/otid_t:1.0", + 'CosTransactions_otid_t':id()), + ?match("CosTransactions_otid_t", + 'CosTransactions_otid_t':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_WrongTransaction' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_WrongTransaction'(doc) -> ["CosTransactions_WrongTransaction"]; +'CosTransactions_WrongTransaction'(suite) -> []; +'CosTransactions_WrongTransaction'(_) -> + ?match(true, orber_tc:check_tc('CosTransactions_WrongTransaction':tc())), + ?match("IDL:omg.org/CosTransactions/WrongTransaction:1.0", + 'CosTransactions_WrongTransaction':id()), + ?match("CosTransactions_WrongTransaction", + 'CosTransactions_WrongTransaction':name()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_Control' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_Control'(doc) -> ["CosTransactions_Control"]; +'CosTransactions_Control'(suite) -> []; +'CosTransactions_Control'(_) -> + ?nomatch(undefined, 'CosTransactions_Control':oe_tc(get_terminator)), + ?nomatch(undefined, 'CosTransactions_Control':oe_tc(get_coordinator)), + ?match(undefined, 'CosTransactions_Control':oe_tc(undefined)), + ?match([_|_], 'CosTransactions_Control':oe_get_interface()), + ?match("IDL:omg.org/CosTransactions/Control:1.0", + 'CosTransactions_Control':typeID()), + check_tc('CosTransactions_Control':oe_get_interface()), + ?match(true, 'CosTransactions_Control':oe_is_a('CosTransactions_Control':typeID())), + ?match(false, 'CosTransactions_Control':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_Coordinator' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_Coordinator'(doc) -> ["CosTransactions_Coordinator"]; +'CosTransactions_Coordinator'(suite) -> []; +'CosTransactions_Coordinator'(_) -> + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_status)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_parent_status)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_top_level_status)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_same_transaction)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_related_transaction)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_ancestor_transaction)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_descendant_transaction)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_top_level_transaction)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(hash_transaction)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(hash_top_level_tran)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(register_resource)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(register_subtran_aware)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(rollback_only)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_transaction_name)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(create_subtransaction)), + ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_txcontext)), + ?match(undefined, 'CosTransactions_Coordinator':oe_tc(undefined)), + ?match([_|_], 'CosTransactions_Coordinator':oe_get_interface()), + ?match("IDL:omg.org/CosTransactions/Coordinator:1.0", + 'CosTransactions_Coordinator':typeID()), + check_tc('CosTransactions_Coordinator':oe_get_interface()), + ?match(true, 'CosTransactions_Coordinator':oe_is_a('CosTransactions_Coordinator':typeID())), + ?match(false, 'CosTransactions_Coordinator':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_RecoveryCoordinator' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_RecoveryCoordinator'(doc) -> ["CosTransactions_RecoveryCoordinator"]; +'CosTransactions_RecoveryCoordinator'(suite) -> []; +'CosTransactions_RecoveryCoordinator'(_) -> + ?nomatch(undefined, 'CosTransactions_RecoveryCoordinator':oe_tc(replay_completion)), + ?match(undefined, 'CosTransactions_RecoveryCoordinator':oe_tc(undefined)), + ?match([_|_], 'CosTransactions_RecoveryCoordinator':oe_get_interface()), + ?match("IDL:omg.org/CosTransactions/RecoveryCoordinator:1.0", + 'CosTransactions_RecoveryCoordinator':typeID()), + check_tc('CosTransactions_RecoveryCoordinator':oe_get_interface()), + ?match(true, 'CosTransactions_RecoveryCoordinator':oe_is_a('CosTransactions_RecoveryCoordinator':typeID())), + ?match(false, 'CosTransactions_RecoveryCoordinator':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_Resource' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_Resource'(doc) -> ["CosTransactions_Resource"]; +'CosTransactions_Resource'(suite) -> []; +'CosTransactions_Resource'(_) -> + ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(prepare)), + ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(rollback)), + ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(commit)), + ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(commit_one_phase)), + ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(forget)), + ?match(undefined, 'CosTransactions_Resource':oe_tc(undefined)), + ?match([_|_], 'CosTransactions_Resource':oe_get_interface()), + ?match("IDL:omg.org/CosTransactions/Resource:1.0", + 'CosTransactions_Resource':typeID()), + check_tc('CosTransactions_Resource':oe_get_interface()), + ?match(true, 'CosTransactions_Resource':oe_is_a('CosTransactions_Resource':typeID())), + ?match(false, 'CosTransactions_Resource':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_SubtransactionAwareResource' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_SubtransactionAwareResource'(doc) -> ["CosTransactions_SubtransactionAwareResource"]; +'CosTransactions_SubtransactionAwareResource'(suite) -> []; +'CosTransactions_SubtransactionAwareResource'(_) -> + ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(commit_subtransaction)), + ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(rollback_subtransaction)), + ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(prepare)), + ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(rollback)), + ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(commit)), + ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(commit_one_phase)), + ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(forget)), + ?match(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(undefined)), + ?match([_|_], 'CosTransactions_SubtransactionAwareResource':oe_get_interface()), + ?match("IDL:omg.org/CosTransactions/SubtransactionAwareResource:1.0", + 'CosTransactions_SubtransactionAwareResource':typeID()), + check_tc('CosTransactions_SubtransactionAwareResource':oe_get_interface()), + ?match(true, 'CosTransactions_SubtransactionAwareResource':oe_is_a('CosTransactions_SubtransactionAwareResource':typeID())), + ?match(true, 'CosTransactions_SubtransactionAwareResource':oe_is_a('CosTransactions_Resource':typeID())), + ?match(false, 'CosTransactions_SubtransactionAwareResource':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_Terminator' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_Terminator'(doc) -> ["CosTransactions_Terminator"]; +'CosTransactions_Terminator'(suite) -> []; +'CosTransactions_Terminator'(_) -> + ?nomatch(undefined, 'CosTransactions_Terminator':oe_tc(commit)), + ?nomatch(undefined, 'CosTransactions_Terminator':oe_tc(rollback)), + ?match(undefined, 'CosTransactions_Terminator':oe_tc(undefined)), + ?match([_|_], 'CosTransactions_Terminator':oe_get_interface()), + ?match("IDL:omg.org/CosTransactions/Terminator:1.0", + 'CosTransactions_Terminator':typeID()), + check_tc('CosTransactions_Terminator':oe_get_interface()), + ?match(true, 'CosTransactions_Terminator':oe_is_a('CosTransactions_Terminator':typeID())), + ?match(false, 'CosTransactions_Terminator':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosTransactions_TransactionFactory' +%% Description: +%%----------------------------------------------------------------- +'CosTransactions_TransactionFactory'(doc) -> ["CosTransactions_TransactionFactory"]; +'CosTransactions_TransactionFactory'(suite) -> []; +'CosTransactions_TransactionFactory'(_) -> + ?nomatch(undefined, 'CosTransactions_TransactionFactory':oe_tc(create)), + ?nomatch(undefined, 'CosTransactions_TransactionFactory':oe_tc(recreate)), + ?match(undefined, 'CosTransactions_TransactionFactory':oe_tc(undefined)), + ?match([_|_], 'CosTransactions_TransactionFactory':oe_get_interface()), + ?match("IDL:omg.org/CosTransactions/TransactionFactory:1.0", + 'CosTransactions_TransactionFactory':typeID()), + check_tc('CosTransactions_TransactionFactory':oe_get_interface()), + ?match(true, 'CosTransactions_TransactionFactory':oe_is_a('CosTransactions_TransactionFactory':typeID())), + ?match(false, 'CosTransactions_TransactionFactory':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'ETraP_Server' +%% Description: +%%----------------------------------------------------------------- +'ETraP_Server'(doc) -> ["ETraP_Server"]; +'ETraP_Server'(suite) -> []; +'ETraP_Server'(_) -> + ?nomatch(undefined, 'ETraP_Server':oe_tc(get_status)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(get_parent_status)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(get_top_level_status)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(is_same_transaction)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(is_related_transaction)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(is_ancestor_transaction)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(is_descendant_transaction)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(is_top_level_transaction)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(hash_transaction)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(hash_top_level_tran)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(register_resource)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(register_subtran_aware)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(rollback_only)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(get_transaction_name)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(create_subtransaction)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(get_txcontext)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(prepare)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(rollback)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(commit)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(commit_one_phase)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(forget)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(replay_completion)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(get_terminator)), + ?nomatch(undefined, 'ETraP_Server':oe_tc(get_coordinator)), + ?match(undefined, 'ETraP_Server':oe_tc(undefined)), + ?match([_|_], 'ETraP_Server':oe_get_interface()), + ?match("IDL:omg.org/ETraP/Server:1.0", + 'ETraP_Server':typeID()), + check_tc('ETraP_Server':oe_get_interface()), + ?match(true, 'ETraP_Server':oe_is_a('ETraP_Server':typeID())), + ?match(true, 'ETraP_Server':oe_is_a('CosTransactions_Coordinator':typeID())), + ?match(true, 'ETraP_Server':oe_is_a('CosTransactions_Resource':typeID())), + ?match(true, 'ETraP_Server':oe_is_a('CosTransactions_RecoveryCoordinator':typeID())), + ?match(true, 'ETraP_Server':oe_is_a('CosTransactions_Control':typeID())), + ?match(false, 'ETraP_Server':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% MISC functions +%%----------------------------------------------------------------- +check_tc([]) -> + ok; +check_tc([{Op, {RetType, InParameters, OutParameters}}|T]) -> + io:format("checked - ~s~n", [Op]), + lists:all(?checktc(Op), [RetType|InParameters]), + lists:all(?checktc(Op), OutParameters), + check_tc(T). + + diff --git a/lib/cosTransactions/test/transactions_SUITE.erl b/lib/cosTransactions/test/transactions_SUITE.erl new file mode 100644 index 0000000000..8385d5a0fb --- /dev/null +++ b/lib/cosTransactions/test/transactions_SUITE.erl @@ -0,0 +1,395 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(transactions_SUITE). + +%%--------------- INCLUDES ----------------------------------- +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/include/ifr_types.hrl"). + +%% Local +-include_lib("cosTransactions/src/ETraP_Common.hrl"). +-include_lib("cosTransactions/include/CosTransactions.hrl"). +-include("etrap_test_lib.hrl"). + +-include("test_server.hrl"). + +-define(default_timeout, ?t:minutes(20)). + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, resource_api/1, etrap_api/1, + init_per_testcase/2, fin_per_testcase/2, app_test/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for the cosTransactions interfaces", ""]; +all(suite) -> {req, + [mnesia, orber], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [etrap_api, resource_api, app_test]. + + + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + 'oe_CosTransactions':'oe_register'(), + 'oe_etrap_test':'oe_register'(), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + 'oe_etrap_test':'oe_unregister'(), + 'oe_CosTransactions':'oe_unregister'(), + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + mnesia:delete_schema([node()]), + mnesia:create_schema([node()]), + orber:install([node()]), + application:start(mnesia), + application:start(orber), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + application:stop(orber), + application:stop(mnesia), + mnesia:delete_schema([node()]), + Config. + +%%----------------------------------------------------------------- +%% Tests app file +%%----------------------------------------------------------------- +app_test(doc) -> []; +app_test(suite) -> []; +app_test(_Config) -> + ok=test_server:app_test(cosTransactions), + ok. + +%%----------------------------------------------------------------- +%% API tests +%%----------------------------------------------------------------- +etrap_api(doc) -> ["ETraP_Server tests", ""]; +etrap_api(suite) -> []; +etrap_api(_Config) -> + ?line ?match(ok, application:start(cosTransactions), + "Starting the cosTransactions application"), + ?line TrFac = cosTransactions:start_factory(), + %% Start a new transaction: + %% RootCoord + %% / \ + %% SubCoord1 SubCoord2 + Control = 'CosTransactions_TransactionFactory':create(TrFac, 0), + Term = 'CosTransactions_Control':get_terminator(Control), + Coord = 'CosTransactions_Control':get_coordinator(Control), + SubCont1 = 'CosTransactions_Coordinator':create_subtransaction(Coord), + SubCont2 = 'CosTransactions_Coordinator':create_subtransaction(Coord), + SubCoord1 = 'CosTransactions_Control':get_coordinator(SubCont1), + SubCoord2 = 'CosTransactions_Control':get_coordinator(SubCont2), + + + %%------ Test CosTransactions::Coordinator ------ + ?line ?match(true, + 'CosTransactions_Coordinator':is_same_transaction(Coord, Coord), + "'CosTransactions_Coordinator':is_same_transaction"), + ?line ?match(false, + 'CosTransactions_Coordinator':is_same_transaction(Coord, SubCoord1), + "'CosTransactions_Coordinator':is_same_transaction"), + ?line ?match(true, + 'CosTransactions_Coordinator':is_descendant_transaction(Coord, Coord), + "'CosTransactions_Coordinator':is_descendant_transaction"), + ?line ?match(false, + 'CosTransactions_Coordinator':is_descendant_transaction(Coord, SubCoord1), + "'CosTransactions_Coordinator':is_descendant_transaction"), + ?line ?match(true, + 'CosTransactions_Coordinator':is_descendant_transaction(SubCoord1, Coord), + "'CosTransactions_Coordinator':is_descendant_transaction"), + ?line ?match(false, + 'CosTransactions_Coordinator':is_descendant_transaction(SubCoord1, SubCoord2), + "'CosTransactions_Coordinator':is_descendant_transaction"), + ?line ?match(true, + 'CosTransactions_Coordinator':is_top_level_transaction(Coord), + "'CosTransactions_Coordinator':is_top_level_transaction"), + ?line ?match(false, + 'CosTransactions_Coordinator':is_top_level_transaction(SubCoord2), + "'CosTransactions_Coordinator':is_top_level_transaction"), + + RootHash = 'CosTransactions_Coordinator':hash_transaction(Coord), + RepeatHash= 'CosTransactions_Coordinator':hash_transaction(Coord), + RootHash2 = 'CosTransactions_Coordinator':hash_top_level_tran(SubCoord1), + RootHash3 = 'CosTransactions_Coordinator':hash_top_level_tran(Coord), + _SubHash = 'CosTransactions_Coordinator':hash_transaction(SubCoord2), + ?line ?match(RootHash, RepeatHash, + "'CosTransactions_Coordinator':hash_transaction"), + ?line ?match(RootHash, RootHash2, + "'CosTransactions_Coordinator':hash_top_level_tran"), + ?line ?match(RootHash, RootHash3, + "'CosTransactions_Coordinator':hash_top_level_tran"), +% ?line ?match_inverse(RootHash, SubHash, +% "'CosTransactions_Coordinator':hash_transaction"), + + ?line ?match('StatusActive', + 'CosTransactions_Coordinator':get_status(Coord), + "'CosTransactions_Coordinator':get_status"), + ?line ?match('StatusActive', + 'CosTransactions_Coordinator':get_status(SubCoord1), + "'CosTransactions_Coordinator':get_status"), + ?line ?match('StatusActive', + 'CosTransactions_Coordinator':get_parent_status(Coord), + "'CosTransactions_Coordinator':get_parent_status"), + ?line ?match('StatusActive', + 'CosTransactions_Coordinator':get_parent_status(SubCoord1), + "'CosTransactions_Coordinator':get_parent_status"), + ?line ?match('StatusActive', + 'CosTransactions_Coordinator':get_top_level_status(Coord), + "'CosTransactions_Coordinator':get_top_level_status"), + ?line ?match('StatusActive', + 'CosTransactions_Coordinator':get_top_level_status(SubCoord1), + "'CosTransactions_Coordinator':get_top_level_status"), + + %% Create a CosTransactions::Resource to experiments with. + %% Start a new transaction: + %% RootCoord + %% / \ + %% SubCoord1 SubCoord2 + %% / + %% Resource + N1 = 'ETraP_Common':create_name("test"), + O1 = etrap_test_server:oe_create(?nop, {global, N1}), + _RC1 = 'CosTransactions_Coordinator':register_resource(SubCoord1, O1), +% 'CosTransactions_Coordinator':register_synchronization(SubCoord1, O1), + + ?line ?match('VoteCommit', + 'CosTransactions_Resource':prepare(SubCoord1), + "'CosTransactions_Coordinator':prepare"), + %% The Transaction are no longer in 'StatusActive' state. No new + %% "members" allowed. + ?line ?match('StatusPrepared', + 'CosTransactions_Coordinator':get_status(SubCoord1), + "'CosTransactions_Coordinator':get_status"), +% ?line ?match({'EXCEPTION', ?tr_inactive}, +% 'CosTransactions_Coordinator':register_synchronization(SubCoord1, O1), +% "'CosTransactions_Coordinator':register_synchronization"), + ?line ?match({'EXCEPTION', ?tr_inactive}, + 'CosTransactions_Coordinator':register_resource(SubCoord1, O1), + "'CosTransactions_Coordinator':register_resource"), + ?line ?match({'EXCEPTION', ?tr_inactive}, + 'CosTransactions_Coordinator':create_subtransaction(SubCoord1), + "'CosTransactions_Coordinator':create_subtransaction"), + + catch corba:dispose(SubCoord1), + catch corba:dispose(SubCoord2), + catch corba:dispose(SubCont1), + catch corba:dispose(SubCont2), + catch corba:dispose(Term), + catch corba:dispose(Control), + catch corba:dispose(Coord), + catch corba:dispose(O1), + + ?line cosTransactions:stop_factory(TrFac), + ?line application:stop(cosTransactions), + ok. + +%%----------------------------------------------------------------- +%% API tests +%%----------------------------------------------------------------- +resource_api(doc) -> ["cosTransactions API tests", ""]; +resource_api(suite) -> []; +resource_api(_Config) -> + ?line ?match(ok, application:start(cosTransactions), + "Starting the cosTransactions application"), + ?line TrFac = cosTransactions:start_factory([{typecheck, true}]), + + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?prepare_rollback}), + "TESTCASE #1: Prepare rollback Resource 4"), + ?line ?match({'EXCEPTION', ?tr_mixed}, + run(TrFac, 0, {?nop, ?nop, ?commit_mix, ?nop}), + "TESTCASE #2: Heuristic Mixed exception Resource 3"), + ?line ?match(ok, + run(TrFac, 0, {?nop, ?nop, ?nop, ?nop}), + "TESTCASE #3: Normal completion. No errors."), + ?line ?match(ok, + run(TrFac, 0, {?nop, ?nop, ?nop, ?commit_cm}), + "TESTCASE #4: Heuristic Commit Exception Resource 4"), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}}, + run(TrFac, 0, {?nop, ?rollback_rb, ?nop, ?prepare_rollback}), + "TESTCASE #5: Heuristic Rollbac Resource 2, Resource 4 reply 'VoteRollback'"), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}}, + run(TrFac, 0, {?nop, ?nop, ?prepare_rollback, ?rollback_rb}), + "TESTCASE #6: Heuristic Rollbac Resource 4, Resource 3 reply 'VoteRollback'"), + ?line ?match(ok, + run(TrFac, 0, {?nop, ?nop, ?commit_delay, ?nop}), + "TESTCASE #7: Resource 3 delay during commit. No timeout."), + ?line ?match(ok, + run(TrFac, 0, {?nop, ?nop, ?prepare_delay, ?nop}), + "TESTCASE #8: Resource 3 delay during prepare. No timeout."), + ?line ?match(ok, + run(TrFac, ?TIMEOUT, {?nop, ?commit_delay, ?nop, ?nop}), + "TESTCASE #9: Resource 3 delay during commit. Timeout."), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}}, + run(TrFac, ?TIMEOUT, {?nop, ?prepare_delay, ?nop, ?nop}), + "TESTCASE #10: Resource 3 delay during prepare. Timeout."), + case ?is_debug_compiled of + true -> + %% Testing the Coordinators (root and sub). + ?line ?match(ok, + run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop,?crash_transient(commit), ?nop]}), + "TESTCASE #11: SubCoord 3 crash transient during commit."), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{}}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop,?crash_transient(send_prepare), ?nop]}), + "TESTCASE #12: SubCoord 3 crash transient during send prepare."), + ?line ?match({'EXCEPTION', ?tr_hazard}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop,?crash_permanent(commit), ?nop]}), + "TESTCASE #13: SubCoord 3 crash permanent during commit."), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{}}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop,?crash_permanent(send_prepare), ?nop]}), + "TESTCASE #14: SubCoord 3 crash permanent during prepare."), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{}}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?crash_transient(send_prepare), ?crash_transient(commit), ?nop]}), + "TESTCASE #15: SubCoord 2 crash transient during prepare. SubCoord 3 crash transient during commit"), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?crash_transient(send_prepare), ?nop, ?nop, ?nop]}), + "TESTCASE #16: RootCoord crash transient during send prepare."), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{}}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?crash_transient(prepare1), ?nop, ?nop]}), + "TESTCASE #17: SubCoord 1 crash transient during prepare1."), + ?line ?match({'EXCEPTION', ?tr_mixed}, + run(TrFac, 0, {?nop, ?prepare_mix, ?nop, ?nop, [?nop, ?nop, ?crash_transient(prepare2), ?nop]}), + "TESTCASE #18: SubCoord 3 crash transient during prepare2. Resource 2 raise Heuristic Mixed during prepare"), + ?line ?match({'EXCEPTION', ?tr_mixed}, + run(TrFac, 0, {?nop, ?commit_mix, ?nop, ?nop, [?nop, ?nop, ?crash_transient(commit2), ?nop]}), + "TESTCASE #19: Resource 2 raise Heurist mixed during commit. SubCoord crash transient commit2"), + ?line ?match({'EXCEPTION', ?tr_mixed}, + run(TrFac, 0, {?nop, ?rollback_cm, ?nop, ?prepare_rollback, [?nop, ?crash_transient(rollback2), ?nop, ?nop]}), + "TESTCASE #20: Resource 2 raise Heuristic Commit during rollback. Resource 4 'VoteRollback'. SubCoord 2 crash transient rollback2."), + ?line ?match({'EXCEPTION', ?tr_mixed}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?commit_mix, [?nop, ?nop, ?crash_transient(send_forget1), ?nop]}), + "TESTCASE #21: Resource 4 raise Heuristic Mixed during commit. SubCoord 2 crash transient send_forget1."), + ?line ?match({'EXCEPTION', ?tr_mixed}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?commit_mix, [?crash_transient(send_forget1), ?nop, ?nop, ?nop]}), + "TESTCASE #22: Resource 4 raise Heuristic Mixed during commit. Root Coord crash transient send_forget1."), + ?line ?match({'EXCEPTION', ?tr_mixed}, + run(TrFac, 0, {?nop, ?nop, ?nop, ?commit_mix, [?crash_transient(send_forget3), ?nop, ?crash_transient(send_forget1), ?nop]}), + "TESTCASE #23: Resource 4 raise Heuristic Mixed during commit. Root Coord crash transient send_forget3. SubCoord 3 crash transient send_forget1."), + ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}}, + run(TrFac, ?TIMEOUT, {?nop, ?nop, ?nop, ?nop, [?delay_transient(root_delay, ?TIMEOUT*2), ?nop, ?nop, ?nop]}), + "TESTCASE #24: Delay RootCoord. Timeout."), + %% Testing the Terminator. + ?line ?match({'EXCEPTION', ?tr_mixed}, + run(TrFac, ?TIMEOUT, {?nop, ?prepare_mix, ?nop, ?nop, [?nop, ?nop, ?nop, ?crash_transient(commit_heuristic1)]}), + "TESTCASE #25: Terminator crash transient after received and logged Heuristic mix."), + ?line ?match(ok, + run(TrFac, ?TIMEOUT, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop, ?nop, ?crash_transient(commit_ok2)]}), + "TESTCASE #26: Terminator crash transient after received and logged 'ok'."); + _ -> + ok + end, + + ?line cosTransactions:stop_factory(TrFac), + ?line application:stop(cosTransactions), + ok. + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- + +run(TrFac, Time, Spec) -> + Control = 'CosTransactions_TransactionFactory':create(TrFac, Time), + Term = 'CosTransactions_Control':get_terminator(Control), + Coord = 'CosTransactions_Control':get_coordinator(Control), + SubCont1 = 'CosTransactions_Coordinator':create_subtransaction(Coord), + SubCont2 = 'CosTransactions_Coordinator':create_subtransaction(Coord), + SubCoord1 = 'CosTransactions_Control':get_coordinator(SubCont1), + SubCoord2 = 'CosTransactions_Control':get_coordinator(SubCont2), + %% Start resources/participants. + {O1, O2, O3, O4, Ctx} = start_resources(Spec), + + %% Get generated names to use for debugging. + CoordN = 'CosTransactions_Coordinator':get_transaction_name(Coord), + SubC1N = 'CosTransactions_Coordinator':get_transaction_name(SubCoord1), + SubC2N = 'CosTransactions_Coordinator':get_transaction_name(SubCoord2), + + ?set_debug_context([CoordN, SubC1N, SubC2N, Term], Ctx), + + %% Register the resources as participants. + _RC1 = 'CosTransactions_Coordinator':register_resource(SubCoord1, O1), + _RC2 = 'CosTransactions_Coordinator':register_resource(SubCoord1, O2), + _RC3 = 'CosTransactions_Coordinator':register_resource(SubCoord2, O3), + _RC4 = 'CosTransactions_Coordinator':register_resource(SubCoord2, O4), + + 'CosTransactions_Coordinator':register_subtran_aware(SubCoord1, O4), +% 'CosTransactions_Coordinator':register_synchronization(SubCoord1, O2), + +% Reply = (catch 'CosTransactions_Terminator':commit(Term, true)), + Reply = (catch 'ETraP_Common':send_stubborn('CosTransactions_Terminator', + commit, [Term, true], + ?tr_max_retries, + ?tr_comm_failure_wait)), + + catch corba:dispose(SubCoord1), + catch corba:dispose(SubCoord2), + catch corba:dispose(SubCont1), + catch corba:dispose(SubCont2), + catch corba:dispose(Term), + catch corba:dispose(Control), + catch corba:dispose(Coord), + catch corba:dispose(O1), + catch corba:dispose(O2), + catch corba:dispose(O3), + catch corba:dispose(O4), + Reply. + + + +start_resources({A1, A2, A3, A4})-> + start_resources({A1, A2, A3, A4, ?no_context}); +start_resources({A1, A2, A3, A4, Ctx})-> + N1 = 'ETraP_Common':create_name("test"), + N2 = 'ETraP_Common':create_name("test"), + N3 = 'ETraP_Common':create_name("test"), + N4 = 'ETraP_Common':create_name("test"), + {_,_,O1} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST(A1, N1)), + {_,_,O2} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST(A2, N2)), +% {_,_,O2} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST([{sync,true}|A2], N2)), + {_,_,O3} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST(A3, N3)), + {_,_,O4} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST(A4, N4)), + {O1, O2, O3, O4, Ctx}. diff --git a/lib/cosTransactions/vsn.mk b/lib/cosTransactions/vsn.mk index b45f192f45..34775be7e4 100644 --- a/lib/cosTransactions/vsn.mk +++ b/lib/cosTransactions/vsn.mk @@ -1,6 +1,7 @@ COSTRANSACTIONS_VSN = 1.2.10 -TICKETS = OTP-8489 +TICKETS = OTP-8489 \ + OTP-8543 TICKETS_1.2.9 = OTP-8355 diff --git a/lib/orber/doc/src/notes.xml b/lib/orber/doc/src/notes.xml index f97d7ac1fa..1013d370e4 100644 --- a/lib/orber/doc/src/notes.xml +++ b/lib/orber/doc/src/notes.xml @@ -35,6 +35,17 @@ <section> <title>Orber 3.6.16</title> <section> + <title>Improvements and New Features</title> + <list type="bulleted"> + <item> + <p> + Test suites published.</p> + <p> + Own Id: OTP-8543 Aux Id:</p> + </item> + </list> + </section> + <section> <title>Fixed Bugs and Malfunctions</title> <list type="bulleted"> <item> diff --git a/lib/orber/test/Makefile b/lib/orber/test/Makefile new file mode 100644 index 0000000000..4601e84d2c --- /dev/null +++ b/lib/orber/test/Makefile @@ -0,0 +1,228 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1997-2010. All Rights Reserved. +# +# The contents of this file are subject to the Erlang Public License, +# Version 1.1, (the "License"); you may not use this file except in +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% +# +# +include $(ERL_TOP)/make/target.mk +include $(ERL_TOP)/make/$(TARGET)/otp.mk + +# ---------------------------------------------------- +# Application version +# ---------------------------------------------------- +include ../vsn.mk +VSN=$(ORBER_VSN) +# ---------------------------------------------------- +# Release directory specification +# ---------------------------------------------------- +RELSYSDIR = $(RELEASE_PATH)/orber_test + +# ---------------------------------------------------- +# Target Specs +# ---------------------------------------------------- +TEST_SPEC_FILE = orber.spec + + +IDL_FILES = \ + orber_test.idl \ + iiop_test.idl \ + orber_test_server.idl + +IDLOUTDIR = idl_output + +MODULES = \ + cdrcoding_11_SUITE \ + cdrcoding_10_SUITE \ + cdrcoding_12_SUITE \ + cdrlib_SUITE \ + corba_SUITE \ + iop_ior_11_SUITE \ + iop_ior_10_SUITE \ + iop_ior_12_SUITE \ + iiop_module_do_test_impl \ + iiop_module_test_impl \ + lname_SUITE \ + naming_context_SUITE \ + orber_SUITE \ + orber_test_server_impl \ + orber_test_timeout_server_impl \ + orber_test_lib \ + csiv2_SUITE \ + multi_ORB_SUITE \ + data_types_SUITE \ + tc_SUITE \ + generated_SUITE \ + orber_web_SUITE \ + interceptors_SUITE \ + orber_acl_SUITE \ + orber_firewall_ipv4_in_SUITE \ + orber_firewall_ipv6_in_SUITE \ + orber_firewall_ipv4_out_SUITE \ + orber_firewall_ipv6_out_SUITE \ + orber_nat_SUITE + +GEN_MOD_ORBER = \ + oe_orber_test \ + Module_Except1 \ + Module_Except2 \ + Module_Except3 \ + Module_Except4 \ + Module_HEADER \ + Module_I1 \ + Module_I2 \ + Module_Struct0 \ + Module_Struct1 \ + Module_Struct2 \ + Module_Union \ + Module_Union1 \ + Module_Union2 + +GEN_HRL_ORBER = \ + oe_orber_test.hrl \ + Module.hrl \ + Module_I1.hrl \ + Module_I2.hrl + +GEN_MOD_IIOP = \ + oe_iiop_test \ + iiop_module_Except1 \ + iiop_module_Struct1 \ + iiop_module_Union1 \ + iiop_module_do_test \ + iiop_module_test \ + iiop_module_test_retval + +GEN_HRL_IIOP = \ + oe_iiop_test.hrl \ + iiop_module.hrl \ + iiop_module_do_test.hrl \ + iiop_module_test.hrl + +GEN_MOD_TEST_SERVER = \ + oe_orber_test_server \ + orber_test_server \ + orber_test_server_ComplexUserDefinedException \ + orber_test_server_UserDefinedException \ + orber_test_server_struc \ + orber_test_server_uni \ + orber_test_server_uni_d \ + orber_test_timeout_server \ + orber_parent_inherrit + +GEN_HRL_TEST_SERVER = \ + oe_orber_test_server.hrl \ + orber_test_server.hrl \ + orber_test_timeout_server.hrl + +GEN_MODULES = $(GEN_MOD_ORBER) $(GEN_MOD_IIOP) \ + $(GEN_MOD_TEST_SERVER) + +ERL_FILES = $(MODULES:%=%.erl) + +HRL_FILES = + +GEN_HRL_FILES = $(GEN_HRL_ORBER) $(GEN_HRL_IIOP) \ + $(GEN_HRL_TEST_SERVER) + +GEN_FILES = \ + $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \ + $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl) + +GEN_TARGET_FILES = $(GEN_MODULES:%=$(IDLOUTDIR)/%.$(EMULATOR)) + +SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) + +TARGET_FILES = \ + $(GEN_TARGET_FILES) \ + $(SUITE_TARGET_FILES) + +# ---------------------------------------------------- +# FLAGS +# ---------------------------------------------------- +ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/orber/ebin -pa $(ERL_TOP)/lib/ic/ebin + +ERL_COMPILE_FLAGS += $(ERL_IDL_FLAGS) \ + -pa $(ERL_TOP)/lib/test_server/ebin \ + -pa $(ERL_TOP)/lib/ic/ebin \ + -pa $(ERL_TOP)/lib/orber/ebin \ + -I$(ERL_TOP)/lib/orber \ + -I$(ERL_TOP)/lib/orber/test/$(IDLOUTDIR) \ + -I$(ERL_TOP)/lib/test_server/include + +# ---------------------------------------------------- +# Targets +# ---------------------------------------------------- +tests debug opt: $(TARGET_FILES) + +clean: + rm -f idl_output/* + rm -f $(TARGET_FILES) + rm -f errs core *~ + + +docs: + +# ---------------------------------------------------- +# Special Targets +# ---------------------------------------------------- + +# +# Each IDL file produces many target files so no pattern +# rule can be used. +# +TGT_ORBER = \ + $(GEN_HRL_ORBER:%=$(IDLOUTDIR)/%) \ + $(GEN_MOD_ORBER:%=$(IDLOUTDIR)/%.erl) +TGT_IIOP = \ + $(GEN_HRL_IIOP:%=$(IDLOUTDIR)/%) \ + $(GEN_MOD_IIOP:%=$(IDLOUTDIR)/%.erl) + +TGT_TEST_SERVER = \ + $(GEN_HRL_TEST_SERVER:%=$(IDLOUTDIR)/%) \ + $(GEN_MOD_TEST_SERVER:%=$(IDLOUTDIR)/%.erl) + +$(TGT_ORBER): orber_test.idl + erlc $(ERL_IDL_FLAGS) -o$(IDLOUTDIR) orber_test.idl + +$(TGT_IIOP): iiop_test.idl + erlc $(ERL_IDL_FLAGS) -o$(IDLOUTDIR) \ + +'{preproc_flags,"-I../COSS/CosNaming"}' iiop_test.idl + +$(TGT_TEST_SERVER): orber_test_server.idl + erlc $(ERL_IDL_FLAGS) -o$(IDLOUTDIR) \ + +'{cfgfile,"orber_test_server.cfg"}' orber_test_server.idl + +# ---------------------------------------------------- +# Release Targets +# ---------------------------------------------------- +# We don't copy generated intermediate erlang and hrl files + +include $(ERL_TOP)/make/otp_release_targets.mk + +release_spec: + +release_docs_spec: + +release_tests_spec: tests + $(INSTALL_DIR) $(RELSYSDIR) + $(INSTALL_DATA) $(IDL_FILES) $(TEST_SPEC_FILE) \ + $(ERL_FILES) $(RELSYSDIR) + $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR) + chmod -f -R u+w $(RELSYSDIR) + $(INSTALL_DIR) $(RELSYSDIR)/$(IDLOUTDIR) + $(INSTALL_DATA) $(GEN_TARGET_FILES) $(GEN_FILES) \ + $(RELSYSDIR)/$(IDLOUTDIR) + diff --git a/lib/orber/test/cdrcoding_10_SUITE.erl b/lib/orber/test/cdrcoding_10_SUITE.erl new file mode 100644 index 0000000000..d5d030538f --- /dev/null +++ b/lib/orber/test/cdrcoding_10_SUITE.erl @@ -0,0 +1,616 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the CDR encode/decode functions +%% +%%----------------------------------------------------------------- +-module(cdrcoding_10_SUITE). + + +-include("idl_output/Module.hrl"). +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(20)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [types, reply, cancel_request, close_connection, message_error]. +%% request, locate_request, locate_reply]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) when is_list(Config) -> + orber:jump_start(0), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) when is_list(Config) -> + orber:jump_stop(), + Config. + +%%----------------------------------------------------------------- +%% Test Case: type encoding tests +%% Description: Just testing the complex types, the others are +%% tested in the cdrlib SUITE. +%%----------------------------------------------------------------- +types(doc) -> ["Description", "more description"]; +types(suite) -> [do_register, null_type, void_type, principal_type, + objref_type, struct_type, union_type, string_type, + array_type, any_type, typecode_type, alias_type, + exception_type, do_unregister]. +%types(Config) when list(Config) -> +% 'oe_orber_test':'oe_register'(), +% null_type(), +% void_type(), +% principal_type(), +% objref_type(), +% struct_type(), +% union_type(), +% string_type(), +% array_type(), +% any_type(), +% typecode_type(), +% alias_type(), +% exception_type(), +% 'oe_orber_test':'oe_unregister'(), +% ok. + +do_register(doc) -> []; +do_register(suite) -> []; +do_register(Config) when is_list(Config) -> + io:format("Pwd: ~p, mod: ~p~n",[c:pwd(), c:m('oe_orber_test')]), + 'oe_orber_test':'oe_register'(), + ok. +do_unregister(doc) -> []; +do_unregister(suite) -> []; +do_unregister(Config) when is_list(Config) -> + 'oe_orber_test':'oe_unregister'(), + ok. +%%----------------------------------------------------------------- +%% Encode/decode test of type: null +%%----------------------------------------------------------------- +null_type(doc) -> []; +null_type(suite) -> []; +null_type(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_null', 'null'), + ?line {'null', <<>>, _} = cdr_decode:dec_type('tk_null', {1, 0}, B, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: void +%%----------------------------------------------------------------- +void_type(doc) -> []; +void_type(suite) -> []; +void_type(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_void', 'ok'), + ?line {'ok', <<>>, _} = cdr_decode:dec_type('tk_void', {1, 0}, B, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: principal +%%----------------------------------------------------------------- +principal_type(doc) -> []; +principal_type(suite) -> []; +principal_type(Config) when is_list(Config) -> + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_Principal', "principal"), + ?line {"principal", <<>>, _} = cdr_decode:dec_type('tk_Principal', {1, 0}, B0, 0, big), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_Principal', ""), + ?line {"", <<>>, _} = cdr_decode:dec_type('tk_Principal', {1, 0}, B1, 0, big), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, 'tk_Principal', "principal"), + ?line {"principal", <<>>, _} = + cdr_decode:dec_type('tk_Principal', {1, 0}, B2, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: object reference +%%----------------------------------------------------------------- +version() -> #'IIOP_Version'{major=1,minor=0}. + +objref(0) -> + PB = #'IIOP_ProfileBody_1_0'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key="ExternalKey: which is an arbitary octet sequence"}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}; +objref(1) -> + K = corba_fake_mk_objkey("IDL:Module/Interface:1.0", key, + list_to_pid("<0.100.0>")), + PB = #'IIOP_ProfileBody_1_0'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key=K}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}; +objref(2) -> + K = corba_fake_mk_objkey("IDL:Module/Interface:1.0", registered, + list_to_atom("orber_nameservice")), + PB = #'IIOP_ProfileBody_1_0'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key=K}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}. + +objref_type(doc) -> []; +objref_type(suite) -> []; +objref_type(Config) when is_list(Config) -> + T = {'tk_objref', "IDL:Module/Interface:1.0", "Interface"}, + Objref0 = objref(0), + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, Objref0), + ?line {Objref0, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B0, 0, big), + Objref1 = objref(1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, Objref1), + ?line {Objref1, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B1, 0, big), + Objref2 = objref(2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, Objref2), + ?line {Objref2, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B2, 0, big), + ok. + + + +%%----------------------------------------------------------------- +%% Encode/decode test of type: struct +%%----------------------------------------------------------------- +struct_type(doc) -> []; +struct_type(suite) -> []; +struct_type(Config) when is_list(Config) -> + T0 = {'tk_struct',"IDL:Module/Struct0:1.0", "Module_Struct0", + [{"long", 'tk_long'}, {"short", 'tk_short'}, {"character", 'tk_char'}]}, + S0 = #'Module_Struct0'{l=-4711, s=17, c=$a}, + ?line B0 = cdr_encode:enc_type({1, 0}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B0, 0, big), + + T1 = {'tk_struct', "IDL:Module/Struct1:1.0", "Module_Struct1", + [{"string", {'tk_string', 0}}, {"ushort", 'tk_ushort'}, {"ulong", 'tk_ulong'}]}, + S1 = #'Module_Struct1'{s="Hi !!!!", us=17, ul=4711}, + ?line B1 = cdr_encode:enc_type({1, 0}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B1, 0, big), + + T2 = {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}, + S2 = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], e=cow, o=$X}, + ?line B2 = cdr_encode:enc_type({1, 0}, T2, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B2, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: union +%%----------------------------------------------------------------- +union_type(doc) -> []; +union_type(suite) -> []; +union_type(Config) when is_list(Config) -> + T0 = {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}, + S0 = #'Module_Union'{label=1, value="Foo Bar !"}, + ?line B0 = cdr_encode:enc_type({1, 0}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B0, 0, big), + S1 = #'Module_Union'{label=0, value=-17}, + ?line B1 = cdr_encode:enc_type({1, 0}, T0, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B1, 0, big), + S2 = #'Module_Union'{label=2, value=$X}, + ?line B2 = cdr_encode:enc_type({1, 0}, T0, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B2, 0, big), + T1 = {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", "apple"]}}]}, + S3 = #'Module_Union1'{label=pig, value=["Foo", "Bar", "!"]}, + ?line B3 = cdr_encode:enc_type({1, 0}, T1, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B3, 0, big), + S4 = #'Module_Union1'{label=cow, value=apple}, + ?line B4 = cdr_encode:enc_type({1, 0}, T1, S4), + ?line {S4, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B4, 0, big), + S5 = #'Module_Union1'{label=horse, value=17}, + ?line B5 = cdr_encode:enc_type({1, 0}, T1, S5), + ?line {S5, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B5, 0, big), + T2 = {'tk_union', "IDL:Module/Union2:1.0", "Union2", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", {'tk_array', 'tk_long', 3}}, + {"pig", "Second", + {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}}, + {"cow", "Third", {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', + {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', + "IDL:Module/Enum1:1.0", + "Module_Enum1", + ["orange", "banana", + "apple"]}}]}}]}, + S6 = #'Module_Union2'{label=pig, value=#'Module_Union'{label=0, value=-17}}, + ?line B6 = cdr_encode:enc_type({1, 0}, T2, S6), + ?line {S6, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B6, 0, big), + S7 = #'Module_Union2'{label=cow, value=#'Module_Union1'{label=pig, + value=["Foo", "Bar", "!"]}}, + ?line B7 = cdr_encode:enc_type({1, 0}, T2, S7), + ?line {S7, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B7, 0, big), + S8 = #'Module_Union2'{label=horse, value={-17, 1234567890, -987654321}}, + ?line B8 = cdr_encode:enc_type({1, 0}, T2, S8), + ?line {S8, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B8, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: string +%%----------------------------------------------------------------- +string_type(doc) -> []; +string_type(suite) -> []; +string_type(Config) when is_list(Config) -> + S0 = "Foo Bar ???", + ?line B0 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B0, 0, big), + S1 = "Yes, Foo Bar !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! more than 5000 characters", + ?line B1 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B1, 0, big), + S2 = "", + ?line B2 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B2, 0, big), + S3 = "\0", + ?line B3 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B3, 0, big), + S4 = "~n", + ?line B4 = cdr_encode:enc_type({1, 0}, {'tk_string', 0}, S4), + ?line {S4, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 0}, B4, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: array +%%----------------------------------------------------------------- +array_type(doc) -> []; +array_type(suite) -> []; +array_type(Config) when is_list(Config) -> + T0 = {'tk_array', 'tk_long', 5}, + S0 = {-100, 0, 30000, -900100900, 123456789}, + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 0}, B0, 0, big), + T1 = {'tk_array', {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}, 2}, + S1 = {pig, cow}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B1, 0, big), + T2 = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", "apple"]}}]}, 2}, + S2 = {#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}}, + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T2, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T2, {1, 0}, B2, 0, big), + T3 = {'tk_array', {'tk_objref', "IDL:Module/Interface:1.0", "Interface"}, 3}, + S3 = {objref(0), objref(1), objref(2)}, + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T3, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type(T3, {1, 0}, B3, 0, big), + ok. +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +any_type(doc) -> []; +any_type(suite) -> []; +any_type(Config) when is_list(Config) -> + T = 'tk_any', + TC = {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}, + S = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], + e=cow, o=$X}, + Any = #any{typecode=TC,value=S}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,Any), + ?line {Any, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B, 0, big), + TC1 = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 1, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]},2}, + S1 = {#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}}, + Any1 = #any{typecode=TC1,value=S1}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,Any1), + ?line {Any1, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B1, 0, big), + ok. + + +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +typecode_type(doc) -> []; +typecode_type(suite) -> []; +typecode_type(Config) when is_list(Config) -> + T = 'tk_TypeCode', + TC = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 1, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]}, 10}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,TC), + ?line {TC, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B, 0, big), + TC1 = {'tk_union', "IDL:Module/Union2:1.0", "Union2", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_long'}, + {"pig", "Second", + {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}}, + {"cow", "Third", {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', + {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', + "IDL:Module/Enum1:1.0", + "Module_Enum1", + ["orange", "banana", + "apple"]}}]}}]}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, TC1), + ?line {TC1, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B1, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +alias_type(doc) -> []; +alias_type(suite) -> []; +alias_type(Config) when is_list(Config) -> + T = {'tk_alias', "IDL:Module/Alias:1.0", "Alias", + {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}}, + S = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], + e=cow, o=$X}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,S), + ?line {S, <<>>, _} = cdr_decode:dec_type(T, {1, 0}, B, 0, big), + T1 = {'tk_alias', "IDL:Module/Alias1:1.0", "Alias1", + {'tk_sequence', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]},0}}, + S1 = [#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}], + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 0}, B1, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: exception +%%----------------------------------------------------------------- +exception_type(doc) -> []; +exception_type(suite) -> []; +exception_type(Config) when is_list(Config) -> + system_exceptions(), + user_exceptions(), + ok. + +system_exceptions() -> + E = #'UNKNOWN'{completion_status=?COMPLETED_YES}, + {system_exception, T, E} = orber_exceptions:get_def(E), + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T,E), + ?line {E, _} = cdr_decode:dec_system_exception({1, 0}, B, 0, big), + E1 = #'INV_OBJREF'{completion_status=?COMPLETED_NO}, + {system_exception, T1, E1} = orber_exceptions:get_def(E1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T1,E1), + ?line {E1, _} = cdr_decode:dec_system_exception({1, 0}, B1, 0, big), + E2 = #'BAD_OPERATION'{completion_status=?COMPLETED_NO}, + {system_exception, T2, E2} = orber_exceptions:get_def(E2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T2,E2), + ?line {E2, _} = cdr_decode:dec_system_exception({1, 0}, B2, 0, big), + E3 = #'INTF_REPOS'{completion_status=?COMPLETED_MAYBE}, + {system_exception, T3, E3} = orber_exceptions:get_def(E3), + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T3,E3), + ?line {E3, _} = cdr_decode:dec_system_exception({1, 0}, B3, 0, big), + ok. + +user_exceptions() -> + E = #'Module_Except1'{rest_of_name=["I","am","testing","exceptions"], why="Error"}, + {user_exception, T, E} = orber_exceptions:get_def(E), + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T, E), + ?line {E, _} = cdr_decode:dec_user_exception({1, 0}, B, 0, big), + E1 = #'Module_Except2'{e=banana, + s=#'Module_Struct2'{long_sequence=[12,-4040, + 1234567898], + e=horse, + o=$a}}, + {user_exception, T1, E1} = orber_exceptions:get_def(E1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T1, E1), + ?line {E1, _} = cdr_decode:dec_user_exception({1, 0}, B1, 0, big), + E2 = #'Module_Except3'{u=#'Module_Union1'{label=pig,value=["high","and","low"]},s=1313, o=objref(0)}, + {user_exception, T2, E2} = orber_exceptions:get_def(E2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T2, E2), + ?line {E2, _} = cdr_decode:dec_user_exception({1, 0}, B2, 0, big), + E3 = #'Module_Except4'{}, + {user_exception, T3, E3} = orber_exceptions:get_def(E3), + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 0}}, T3, E3), + ?line {E3, _} = cdr_decode:dec_user_exception({1, 0}, B3, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Test Case: request encoding test +%% Description: Precondition the stack must be started so the +%% objectkey is valid. +%%----------------------------------------------------------------- +%request(suite) -> []; +%request(_) -> +% exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: reply encoding test +%% Description: +%%----------------------------------------------------------------- +reply(doc) -> ["Description", "more description"]; +reply(suite) -> []; +reply(Config) when is_list(Config) -> + R = #reply_header{service_context=[], request_id=1, + reply_status='no_exception'}, + ?line B = cdr_encode:enc_reply( + #giop_env{version = {1, 0}, request_id = 1, + reply_status = 'no_exception', + tc = {'tk_long', [], [{'tk_sequence', + {'tk_string', 0}, 0}]}, + result = 1200, parameters = [["foo","Bar"]], + ctx = []}), + ?line {R, 1200, [["foo","Bar"]]} = + cdr_decode:dec_message({'tk_long', [], [{'tk_sequence', {'tk_string', 0},0}]}, + B), + ok. + +%%----------------------------------------------------------------- +%% Test Case: cancel_request encoding test +%% Description: +%%----------------------------------------------------------------- +cancel_request(doc) -> ["Description", "more description"]; +cancel_request(suite) -> []; +cancel_request(Config) when is_list(Config) -> + R = #cancel_request_header{request_id=1}, + ?line B = cdr_encode:enc_cancel_request(#giop_env{version = {1, 0}, + request_id = 1}), + ?line R = cdr_decode:dec_message([], B), + ok. + +%%----------------------------------------------------------------- +%% Test Case: locate_request encoding test +%% Description: +%%----------------------------------------------------------------- +locate_request(doc) -> ["Description", "more description"]; +locate_request(suite) -> []; +locate_request(Config) when is_list(Config) -> + io:format("Function not imlpemented yet"), + exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: locate_reply encoding test +%% Description: +%%----------------------------------------------------------------- +locate_reply(doc) -> ["Description", "more description"]; +locate_reply(suite) -> []; +locate_reply(Config) when is_list(Config) -> + io:format("Function not imlpemented yet"), + exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: close_connection encoding test +%% Description: +%%----------------------------------------------------------------- +close_connection(doc) -> ["Description", "more description"]; +close_connection(suite) -> []; +close_connection(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_close_connection(#giop_env{version = {1, 0}}), + ?line 'close_connection' = cdr_decode:dec_message([], B), + ok. + +%%----------------------------------------------------------------- +%% Test Case: message_error encoding test +%% Description: +%%----------------------------------------------------------------- +message_error(doc) -> ["Description", "more description"]; +message_error(suite) -> []; +message_error(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_message_error(#giop_env{version = {1, 0}}), + ?line 'message_error' = cdr_decode:dec_message([], B), + ok. + + + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- +corba_fake_mk_objkey(Id, 'key', Pid) when is_pid(Pid) -> + Key = make_objkey(), + {list_to_binary(Id), 'key', Key, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}; +corba_fake_mk_objkey(Id, 'key', RegName) when is_atom(RegName) -> + Key = term_to_binary(RegName), + {list_to_binary(Id), 'key', Key, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}; +corba_fake_mk_objkey(Id, 'registered', RegName) when is_atom(RegName) -> + {list_to_binary(Id), 'registered', RegName, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}. + +make_objkey() -> + term_to_binary({now(), node()}). diff --git a/lib/orber/test/cdrcoding_11_SUITE.erl b/lib/orber/test/cdrcoding_11_SUITE.erl new file mode 100644 index 0000000000..d62fe6eb3a --- /dev/null +++ b/lib/orber/test/cdrcoding_11_SUITE.erl @@ -0,0 +1,615 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the CDR encode/decode functions +%% +%%----------------------------------------------------------------- +-module(cdrcoding_11_SUITE). + + +-include("idl_output/Module.hrl"). +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(5)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [types, reply, cancel_request, close_connection, message_error]. +%% request, locate_request, locate_reply]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) when is_list(Config) -> + orber:jump_start(0), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) when is_list(Config) -> + orber:jump_stop(), + Config. + +%%----------------------------------------------------------------- +%% Test Case: type encoding tests +%% Description: Just testing the complex types, the others are +%% tested in the cdrlib SUITE. +%%----------------------------------------------------------------- +types(doc) -> ["Description", "more description"]; +types(suite) -> [do_register, null_type, void_type, principal_type, + objref_type, struct_type, union_type, string_type, + array_type, any_type, typecode_type, alias_type, + exception_type, do_unregister]. +%types(Config) when list(Config) -> +% 'oe_orber_test':'oe_register'(), +% null_type(), +% void_type(), +% principal_type(), +% objref_type(), +% struct_type(), +% union_type(), +% string_type(), +% array_type(), +% any_type(), +% typecode_type(), +% alias_type(), +% exception_type(), +% 'oe_orber_test':'oe_unregister'(), +% ok. + +do_register(doc) -> []; +do_register(suite) -> []; +do_register(Config) when is_list(Config) -> + 'oe_orber_test':'oe_register'(), + ok. +do_unregister(doc) -> []; +do_unregister(suite) -> []; +do_unregister(Config) when is_list(Config) -> + 'oe_orber_test':'oe_unregister'(), + ok. +%%----------------------------------------------------------------- +%% Encode/decode test of type: null +%%----------------------------------------------------------------- +null_type(doc) -> []; +null_type(suite) -> []; +null_type(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 1}}, 'tk_null', 'null'), + ?line {'null', <<>>, _} = cdr_decode:dec_type('tk_null', {1, 1}, B, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: void +%%----------------------------------------------------------------- +void_type(doc) -> []; +void_type(suite) -> []; +void_type(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 1}}, 'tk_void', 'ok'), + ?line {'ok', <<>>, _} = cdr_decode:dec_type('tk_void', {1, 1}, B, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: principal +%%----------------------------------------------------------------- +principal_type(doc) -> []; +principal_type(suite) -> []; +principal_type(Config) when is_list(Config) -> + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, 'tk_Principal', "principal"), + ?line {"principal", <<>>, _} = cdr_decode:dec_type('tk_Principal', {1, 1}, B0, 0, big), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, 'tk_Principal', ""), + ?line {"", <<>>, _} = cdr_decode:dec_type('tk_Principal', {1, 1}, B1, 0, big), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, 'tk_Principal', "principal"), + ?line {"principal", <<>>, _} = + cdr_decode:dec_type('tk_Principal', {1, 1}, B2, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: object reference +%%----------------------------------------------------------------- +version() -> #'IIOP_Version'{major=1,minor=1}. + +objref(0) -> + PB = #'IIOP_ProfileBody_1_1'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key="ExternalKey: which is an arbitary octet sequence", + components=[]}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}; +objref(1) -> + K = corba_fake_mk_objkey("IDL:Module/Interface:1.0", key, + list_to_pid("<0.100.0>")), + PB = #'IIOP_ProfileBody_1_1'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key=K, components=[]}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}; +objref(2) -> + K = corba_fake_mk_objkey("IDL:Module/Interface:1.0", registered, + list_to_atom("orber_nameservice")), + PB = #'IIOP_ProfileBody_1_1'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key=K, components=[]}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}. + +objref_type(doc) -> []; +objref_type(suite) -> []; +objref_type(Config) when is_list(Config) -> + T = {'tk_objref', "IDL:Module/Interface:1.0", "Interface"}, + Objref0 = objref(0), + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T, Objref0), + ?line {Objref0, <<>>, _} = cdr_decode:dec_type(T, {1, 1}, B0, 0, big), + Objref1 = objref(1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T, Objref1), + ?line {Objref1, <<>>, _} = cdr_decode:dec_type(T, {1, 1}, B1, 0, big), + Objref2 = objref(2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T, Objref2), + ?line {Objref2, <<>>, _} = cdr_decode:dec_type(T, {1, 1}, B2, 0, big), + ok. + + + +%%----------------------------------------------------------------- +%% Encode/decode test of type: struct +%%----------------------------------------------------------------- +struct_type(doc) -> []; +struct_type(suite) -> []; +struct_type(Config) when is_list(Config) -> + T0 = {'tk_struct',"IDL:Module/Struct0:1.0", "Module_Struct0", + [{"long", 'tk_long'}, {"short", 'tk_short'}, {"character", 'tk_char'}]}, + S0 = #'Module_Struct0'{l=-4711, s=17, c=$a}, + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 1}, B0, 0, big), + + T1 = {'tk_struct', "IDL:Module/Struct1:1.0", "Module_Struct1", + [{"string", {'tk_string', 0}}, {"ushort", 'tk_ushort'}, {"ulong", 'tk_ulong'}]}, + S1 = #'Module_Struct1'{s="Hi !!!!", us=17, ul=4711}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 1}, B1, 0, big), + + T2 = {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}, + S2 = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], e=cow, o=$X}, + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T2, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T2, {1, 1}, B2, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: union +%%----------------------------------------------------------------- +union_type(doc) -> []; +union_type(suite) -> []; +union_type(Config) when is_list(Config) -> + T0 = {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}, + S0 = #'Module_Union'{label=1, value="Foo Bar !"}, + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 1}, B0, 0, big), + S1 = #'Module_Union'{label=0, value=-17}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T0, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T0, {1, 1}, B1, 0, big), + S2 = #'Module_Union'{label=2, value=$X}, + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T0, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T0, {1, 1}, B2, 0, big), + T1 = {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", "apple"]}}]}, + S3 = #'Module_Union1'{label=pig, value=["Foo", "Bar", "!"]}, + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T1, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type(T1, {1, 1}, B3, 0, big), + S4 = #'Module_Union1'{label=cow, value=apple}, + ?line B4 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T1, S4), + ?line {S4, <<>>, _} = cdr_decode:dec_type(T1, {1, 1}, B4, 0, big), + S5 = #'Module_Union1'{label=horse, value=17}, + ?line B5 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T1, S5), + ?line {S5, <<>>, _} = cdr_decode:dec_type(T1, {1, 1}, B5, 0, big), + T2 = {'tk_union', "IDL:Module/Union2:1.0", "Union2", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", {'tk_array', 'tk_long', 3}}, + {"pig", "Second", + {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}}, + {"cow", "Third", {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', + {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', + "IDL:Module/Enum1:1.0", + "Module_Enum1", + ["orange", "banana", + "apple"]}}]}}]}, + S6 = #'Module_Union2'{label=pig, value=#'Module_Union'{label=0, value=-17}}, + ?line B6 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T2, S6), + ?line {S6, <<>>, _} = cdr_decode:dec_type(T2, {1, 1}, B6, 0, big), + S7 = #'Module_Union2'{label=cow, value=#'Module_Union1'{label=pig, + value=["Foo", "Bar", "!"]}}, + ?line B7 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T2, S7), + ?line {S7, <<>>, _} = cdr_decode:dec_type(T2, {1, 1}, B7, 0, big), + S8 = #'Module_Union2'{label=horse, value={-17, 1234567890, -987654321}}, + ?line B8 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T2, S8), + ?line {S8, <<>>, _} = cdr_decode:dec_type(T2, {1, 1}, B8, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: string +%%----------------------------------------------------------------- +string_type(doc) -> []; +string_type(suite) -> []; +string_type(Config) when is_list(Config) -> + S0 = "Foo Bar ???", + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, {'tk_string', 0}, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 1}, B0, 0, big), + S1 = "Yes, Foo Bar !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! more than 5000 characters", + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, {'tk_string', 0}, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 1}, B1, 0, big), + S2 = "", + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, {'tk_string', 0}, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 1}, B2, 0, big), + S3 = "\0", + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, {'tk_string', 0}, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 1}, B3, 0, big), + S4 = "~n", + ?line B4 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, {'tk_string', 0}, S4), + ?line {S4, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 1}, B4, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: array +%%----------------------------------------------------------------- +array_type(doc) -> []; +array_type(suite) -> []; +array_type(Config) when is_list(Config) -> + T0 = {'tk_array', 'tk_long', 5}, + S0 = {-100, 0, 30000, -900100900, 123456789}, + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 1}, B0, 0, big), + T1 = {'tk_array', {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}, 2}, + S1 = {pig, cow}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 1}, B1, 0, big), + T2 = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", "apple"]}}]}, 2}, + S2 = {#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}}, + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T2, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T2, {1, 1}, B2, 0, big), + T3 = {'tk_array', {'tk_objref', "IDL:Module/Interface:1.0", "Interface"}, 3}, + S3 = {objref(0), objref(1), objref(2)}, + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T3, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type(T3, {1, 1}, B3, 0, big), + ok. +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +any_type(doc) -> []; +any_type(suite) -> []; +any_type(Config) when is_list(Config) -> + T = 'tk_any', + TC = {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}, + S = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], + e=cow, o=$X}, + Any = #any{typecode=TC,value=S}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T,Any), + ?line {Any, <<>>, _} = cdr_decode:dec_type(T, {1, 1}, B, 0, big), + TC1 = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 1, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]},2}, + S1 = {#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}}, + Any1 = #any{typecode=TC1,value=S1}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T,Any1), + ?line {Any1, <<>>, _} = cdr_decode:dec_type(T, {1, 1}, B1, 0, big), + ok. + + +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +typecode_type(doc) -> []; +typecode_type(suite) -> []; +typecode_type(Config) when is_list(Config) -> + T = 'tk_TypeCode', + TC = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 1, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]}, 10}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T,TC), + ?line {TC, <<>>, _} = cdr_decode:dec_type(T, {1, 1}, B, 0, big), + TC1 = {'tk_union', "IDL:Module/Union2:1.0", "Union2", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_long'}, + {"pig", "Second", + {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}}, + {"cow", "Third", {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', + {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', + "IDL:Module/Enum1:1.0", + "Module_Enum1", + ["orange", "banana", + "apple"]}}]}}]}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T, TC1), + ?line {TC1, <<>>, _} = cdr_decode:dec_type(T, {1, 1}, B1, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +alias_type(doc) -> []; +alias_type(suite) -> []; +alias_type(Config) when is_list(Config) -> + T = {'tk_alias', "IDL:Module/Alias:1.0", "Alias", + {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}}, + S = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], + e=cow, o=$X}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T,S), + ?line {S, <<>>, _} = cdr_decode:dec_type(T, {1, 1}, B, 0, big), + T1 = {'tk_alias', "IDL:Module/Alias1:1.0", "Alias1", + {'tk_sequence', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]},0}}, + S1 = [#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}], + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 1}, B1, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: exception +%%----------------------------------------------------------------- +exception_type(doc) -> []; +exception_type(suite) -> []; +exception_type(Config) when is_list(Config) -> + system_exceptions(), + user_exceptions(), + ok. + +system_exceptions() -> + E = #'UNKNOWN'{completion_status=?COMPLETED_YES}, + {system_exception, T, E} = orber_exceptions:get_def(E), + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T,E), + ?line {E, _} = cdr_decode:dec_system_exception({1, 1}, B, 0, big), + E1 = #'INV_OBJREF'{completion_status=?COMPLETED_NO}, + {system_exception, T1, E1} = orber_exceptions:get_def(E1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T1,E1), + ?line {E1, _} = cdr_decode:dec_system_exception({1, 1}, B1, 0, big), + E2 = #'BAD_OPERATION'{completion_status=?COMPLETED_NO}, + {system_exception, T2, E2} = orber_exceptions:get_def(E2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T2,E2), + ?line {E2, _} = cdr_decode:dec_system_exception({1, 1}, B2, 0, big), + E3 = #'INTF_REPOS'{completion_status=?COMPLETED_MAYBE}, + {system_exception, T3, E3} = orber_exceptions:get_def(E3), + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T3,E3), + ?line {E3, _} = cdr_decode:dec_system_exception({1, 1}, B3, 0, big), + ok. + +user_exceptions() -> + E = #'Module_Except1'{rest_of_name=["I","am","testing","exceptions"], why="Error"}, + {user_exception, T, E} = orber_exceptions:get_def(E), + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T, E), + ?line {E, _} = cdr_decode:dec_user_exception({1, 1}, B, 0, big), + E1 = #'Module_Except2'{e=banana, + s=#'Module_Struct2'{long_sequence=[12,-4040, + 1234567898], + e=horse, + o=$a}}, + {user_exception, T1, E1} = orber_exceptions:get_def(E1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T1, E1), + ?line {E1, _} = cdr_decode:dec_user_exception({1, 1}, B1, 0, big), + E2 = #'Module_Except3'{u=#'Module_Union1'{label=pig,value=["high","and","low"]},s=1313, o=objref(0)}, + {user_exception, T2, E2} = orber_exceptions:get_def(E2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T2, E2), + ?line {E2, _} = cdr_decode:dec_user_exception({1, 1}, B2, 0, big), + E3 = #'Module_Except4'{}, + {user_exception, T3, E3} = orber_exceptions:get_def(E3), + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 1}}, T3, E3), + ?line {E3, _} = cdr_decode:dec_user_exception({1, 1}, B3, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Test Case: request encoding test +%% Description: Precondition the stack must be started so the +%% objectkey is valid. +%%----------------------------------------------------------------- +%request(suite) -> []; +%request(_) -> +% exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: reply encoding test +%% Description: +%%----------------------------------------------------------------- +reply(doc) -> ["Description", "more description"]; +reply(suite) -> []; +reply(Config) when is_list(Config) -> + R = #reply_header{service_context=[], request_id=1, + reply_status='no_exception'}, + ?line B = cdr_encode:enc_reply(#giop_env{version = {1, 1}, request_id = 1, + reply_status = 'no_exception', + tc = {'tk_long', [], [{'tk_sequence', + {'tk_string', 0}, 0}]}, + result = 1200, parameters = [["foo","Bar"]], + ctx = []}), + ?line {R, 1200, [["foo","Bar"]]} = + cdr_decode:dec_message({'tk_long', [], [{'tk_sequence', {'tk_string', 0},0}]}, + B), + ok. + +%%----------------------------------------------------------------- +%% Test Case: cancel_request encoding test +%% Description: +%%----------------------------------------------------------------- +cancel_request(doc) -> ["Description", "more description"]; +cancel_request(suite) -> []; +cancel_request(Config) when is_list(Config) -> + R = #cancel_request_header{request_id=1}, + ?line B = cdr_encode:enc_cancel_request(#giop_env{version = {1, 1}, + request_id = 1}), + ?line R = cdr_decode:dec_message([], B), + ok. + +%%----------------------------------------------------------------- +%% Test Case: locate_request encoding test +%% Description: +%%----------------------------------------------------------------- +locate_request(doc) -> ["Description", "more description"]; +locate_request(suite) -> []; +locate_request(Config) when is_list(Config) -> + io:format("Function not imlpemented yet"), + exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: locate_reply encoding test +%% Description: +%%----------------------------------------------------------------- +locate_reply(doc) -> ["Description", "more description"]; +locate_reply(suite) -> []; +locate_reply(Config) when is_list(Config) -> + io:format("Function not imlpemented yet"), + exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: close_connection encoding test +%% Description: +%%----------------------------------------------------------------- +close_connection(doc) -> ["Description", "more description"]; +close_connection(suite) -> []; +close_connection(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_close_connection(#giop_env{version = {1, 1}}), + ?line 'close_connection' = cdr_decode:dec_message([], B), + ok. + +%%----------------------------------------------------------------- +%% Test Case: message_error encoding test +%% Description: +%%----------------------------------------------------------------- +message_error(doc) -> ["Description", "more description"]; +message_error(suite) -> []; +message_error(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_message_error(#giop_env{version = {1, 1}}), + ?line 'message_error' = cdr_decode:dec_message([], B), + ok. + + + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- +corba_fake_mk_objkey(Id, 'key', Pid) when is_pid(Pid) -> + Key = make_objkey(), + {list_to_binary(Id), 'key', Key, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}; +corba_fake_mk_objkey(Id, 'key', RegName) when is_atom(RegName) -> + Key = term_to_binary(RegName), + {list_to_binary(Id), 'key', Key, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}; +corba_fake_mk_objkey(Id, 'registered', RegName) when is_atom(RegName) -> + {list_to_binary(Id), 'registered', RegName, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}. + +make_objkey() -> + term_to_binary({now(), node()}). diff --git a/lib/orber/test/cdrcoding_12_SUITE.erl b/lib/orber/test/cdrcoding_12_SUITE.erl new file mode 100644 index 0000000000..18e8eaa08a --- /dev/null +++ b/lib/orber/test/cdrcoding_12_SUITE.erl @@ -0,0 +1,603 @@ +%%---------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the CDR encode/decode functions +%% +%%----------------------------------------------------------------- + +-module(cdrcoding_12_SUITE). + +-include("idl_output/Module.hrl"). +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(5)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [types, reply, cancel_request, close_connection, message_error]. +%% request, locate_request, locate_reply]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) when is_list(Config) -> + orber:jump_start(0), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) when is_list(Config) -> + orber:jump_stop(), + Config. + +%%----------------------------------------------------------------- +%% Test Case: type encoding tests +%% Description: Just testing the complex types, the others are +%% tested in the cdrlib SUITE. +%%----------------------------------------------------------------- +types(doc) -> ["Description", "more description"]; +types(suite) -> [do_register, null_type, void_type, principal_type, + objref_type, struct_type, union_type, string_type, + array_type, any_type, typecode_type, alias_type, + exception_type, do_unregister]. + +do_register(doc) -> []; +do_register(suite) -> []; +do_register(Config) when is_list(Config) -> + 'oe_orber_test':'oe_register'(), + ok. +do_unregister(doc) -> []; +do_unregister(suite) -> []; +do_unregister(Config) when is_list(Config) -> + 'oe_orber_test':'oe_unregister'(), + ok. +%%----------------------------------------------------------------- +%% Encode/decode test of type: null +%%----------------------------------------------------------------- +null_type(doc) -> []; +null_type(suite) -> []; +null_type(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 2}}, 'tk_null', 'null'), + ?line {'null', <<>>, _} = cdr_decode:dec_type('tk_null', {1, 2}, B, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: void +%%----------------------------------------------------------------- +void_type(doc) -> []; +void_type(suite) -> []; +void_type(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 2}}, 'tk_void', 'ok'), + ?line {'ok', <<>>, _} = cdr_decode:dec_type('tk_void', {1, 2}, B, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: principal +%%----------------------------------------------------------------- +principal_type(doc) -> []; +principal_type(suite) -> []; +principal_type(Config) when is_list(Config) -> + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, 'tk_Principal', "principal"), + ?line {"principal", <<>>, _} = cdr_decode:dec_type('tk_Principal', {1, 2}, B0, 0, big), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, 'tk_Principal', ""), + ?line {"", <<>>, _} = cdr_decode:dec_type('tk_Principal', {1, 2}, B1, 0, big), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, 'tk_Principal', "principal"), + ?line {"principal", <<>>, _} = + cdr_decode:dec_type('tk_Principal', {1, 2}, B2, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: object reference +%%----------------------------------------------------------------- +version() -> #'IIOP_Version'{major=1,minor=2}. + +objref(0) -> + PB = #'IIOP_ProfileBody_1_1'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key="ExternalKey: which is an arbitary octet sequence", + components=[]}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}; +objref(1) -> + K = corba_fake_mk_objkey("IDL:Module/Interface:1.0", key, + list_to_pid("<0.100.0>")), + PB = #'IIOP_ProfileBody_1_1'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key=K, components=[]}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}; +objref(2) -> + K = corba_fake_mk_objkey("IDL:Module/Interface:1.0", registered, + list_to_atom("orber_nameservice")), + PB = #'IIOP_ProfileBody_1_1'{iiop_version=version(), + host="my.hostname.org", + port=4040, + object_key=K, components=[]}, + TP = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}, + #'IOP_IOR'{type_id="IDL:Module/Interface:1.0", profiles=[TP]}. + +objref_type(doc) -> []; +objref_type(suite) -> []; +objref_type(Config) when is_list(Config) -> + T = {'tk_objref', "IDL:Module/Interface:1.0", "Interface"}, + Objref0 = objref(0), + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T, Objref0), + ?line {Objref0, <<>>, _} = cdr_decode:dec_type(T, {1, 2}, B0, 0, big), + Objref1 = objref(1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T, Objref1), + ?line {Objref1, <<>>, _} = cdr_decode:dec_type(T, {1, 2}, B1, 0, big), + Objref2 = objref(2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T, Objref2), + ?line {Objref2, <<>>, _} = cdr_decode:dec_type(T, {1, 2}, B2, 0, big), + ok. + + + +%%----------------------------------------------------------------- +%% Encode/decode test of type: struct +%%----------------------------------------------------------------- +struct_type(doc) -> []; +struct_type(suite) -> []; +struct_type(Config) when is_list(Config) -> + T0 = {'tk_struct',"IDL:Module/Struct0:1.0", "Module_Struct0", + [{"long", 'tk_long'}, {"short", 'tk_short'}, {"character", 'tk_char'}]}, + S0 = #'Module_Struct0'{l=-4711, s=17, c=$a}, + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 2}, B0, 0, big), + + T1 = {'tk_struct', "IDL:Module/Struct1:1.0", "Module_Struct1", + [{"string", {'tk_string', 0}}, {"ushort", 'tk_ushort'}, {"ulong", 'tk_ulong'}]}, + S1 = #'Module_Struct1'{s="Hi !!!!", us=17, ul=4711}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 2}, B1, 0, big), + + T2 = {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}, + S2 = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], e=cow, o=$X}, + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T2, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T2, {1, 2}, B2, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: union +%%----------------------------------------------------------------- +union_type(doc) -> []; +union_type(suite) -> []; +union_type(Config) when is_list(Config) -> + T0 = {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}, + S0 = #'Module_Union'{label=1, value="Foo Bar !"}, + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 2}, B0, 0, big), + S1 = #'Module_Union'{label=0, value=-17}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T0, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T0, {1, 2}, B1, 0, big), + S2 = #'Module_Union'{label=2, value=$X}, + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T0, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T0, {1, 2}, B2, 0, big), + T1 = {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", "apple"]}}]}, + S3 = #'Module_Union1'{label=pig, value=["Foo", "Bar", "!"]}, + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T1, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type(T1, {1, 2}, B3, 0, big), + S4 = #'Module_Union1'{label=cow, value=apple}, + ?line B4 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T1, S4), + ?line {S4, <<>>, _} = cdr_decode:dec_type(T1, {1, 2}, B4, 0, big), + S5 = #'Module_Union1'{label=horse, value=17}, + ?line B5 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T1, S5), + ?line {S5, <<>>, _} = cdr_decode:dec_type(T1, {1, 2}, B5, 0, big), + T2 = {'tk_union', "IDL:Module/Union2:1.0", "Union2", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", {'tk_array', 'tk_long', 3}}, + {"pig", "Second", + {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}}, + {"cow", "Third", {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', + {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', + "IDL:Module/Enum1:1.0", + "Module_Enum1", + ["orange", "banana", + "apple"]}}]}}]}, + S6 = #'Module_Union2'{label=pig, value=#'Module_Union'{label=0, value=-17}}, + ?line B6 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T2, S6), + ?line {S6, <<>>, _} = cdr_decode:dec_type(T2, {1, 2}, B6, 0, big), + S7 = #'Module_Union2'{label=cow, value=#'Module_Union1'{label=pig, + value=["Foo", "Bar", "!"]}}, + ?line B7 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T2, S7), + ?line {S7, <<>>, _} = cdr_decode:dec_type(T2, {1, 2}, B7, 0, big), + S8 = #'Module_Union2'{label=horse, value={-17, 1234567890, -987654321}}, + ?line B8 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T2, S8), + ?line {S8, <<>>, _} = cdr_decode:dec_type(T2, {1, 2}, B8, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: string +%%----------------------------------------------------------------- +string_type(doc) -> []; +string_type(suite) -> []; +string_type(Config) when is_list(Config) -> + S0 = "Foo Bar ???", + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, {'tk_string', 0}, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 2}, B0, 0, big), + S1 = "Yes, Foo Bar !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! more than 5000 characters", + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, {'tk_string', 0}, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 2}, B1, 0, big), + S2 = "", + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, {'tk_string', 0}, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 2}, B2, 0, big), + S3 = "\0", + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, {'tk_string', 0}, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 2}, B3, 0, big), + S4 = "~n", + ?line B4 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, {'tk_string', 0}, S4), + ?line {S4, <<>>, _} = cdr_decode:dec_type({'tk_string', 0}, {1, 2}, B4, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: array +%%----------------------------------------------------------------- +array_type(doc) -> []; +array_type(suite) -> []; +array_type(Config) when is_list(Config) -> + T0 = {'tk_array', 'tk_long', 5}, + S0 = {-100, 0, 30000, -900100900, 123456789}, + ?line B0 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T0, S0), + ?line {S0, <<>>, _} = cdr_decode:dec_type(T0, {1, 2}, B0, 0, big), + T1 = {'tk_array', {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}, 2}, + S1 = {pig, cow}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 2}, B1, 0, big), + T2 = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", ["horse", "pig", "cow"]}, "pig", + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", "apple"]}}]}, 2}, + S2 = {#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}}, + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T2, S2), + ?line {S2, <<>>, _} = cdr_decode:dec_type(T2, {1, 2}, B2, 0, big), + T3 = {'tk_array', {'tk_objref', "IDL:Module/Interface:1.0", "Interface"}, 3}, + S3 = {objref(0), objref(1), objref(2)}, + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T3, S3), + ?line {S3, <<>>, _} = cdr_decode:dec_type(T3, {1, 2}, B3, 0, big), + ok. +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +any_type(doc) -> []; +any_type(suite) -> []; +any_type(Config) when is_list(Config) -> + T = 'tk_any', + TC = {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}, + S = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], + e=cow, o=$X}, + Any = #any{typecode=TC,value=S}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T,Any), + ?line {Any, <<>>, _} = cdr_decode:dec_type(T, {1, 2}, B, 0, big), + TC1 = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 1, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]},2}, + S1 = {#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}}, + Any1 = #any{typecode=TC1,value=S1}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T,Any1), + ?line {Any1, <<>>, _} = cdr_decode:dec_type(T, {1, 2}, B1, 0, big), + ok. + + +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +typecode_type(doc) -> []; +typecode_type(suite) -> []; +typecode_type(Config) when is_list(Config) -> + T = 'tk_TypeCode', + TC = {'tk_array', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 1, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]}, 10}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T,TC), + ?line {TC, <<>>, _} = cdr_decode:dec_type(T, {1, 2}, B, 0, big), + TC1 = {'tk_union', "IDL:Module/Union2:1.0", "Union2", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_long'}, + {"pig", "Second", + {'tk_union', "IDL:Module/Union:1.0", "Union", 'tk_short', 2, + [{0, "First", 'tk_short'}, + {1, "Second", {'tk_string', 0}}, + {2, "Third", 'tk_char'}]}}, + {"cow", "Third", {'tk_union', "IDL:Module/Union1:1.0", "Union1", + {'tk_enum', "IDL:Module/Enum:1.0", + "Module_Enum", ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', + {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', + "IDL:Module/Enum1:1.0", + "Module_Enum1", + ["orange", "banana", + "apple"]}}]}}]}, + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T, TC1), + ?line {TC1, <<>>, _} = cdr_decode:dec_type(T, {1, 2}, B1, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: TypeCode +%%----------------------------------------------------------------- +alias_type(doc) -> []; +alias_type(suite) -> []; +alias_type(Config) when is_list(Config) -> + T = {'tk_alias', "IDL:Module/Alias:1.0", "Alias", + {'tk_struct', "IDL:Module/Struct2:1.0", "Module_Struct2", + [{"long_sequence", {'tk_sequence', 'tk_long', 0}}, + {"enum", {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}}, + {"octet", 'tk_octet'}]}}, + S = #'Module_Struct2'{long_sequence=[4711, 350000, 0, -3030, -600000], + e=cow, o=$X}, + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T,S), + ?line {S, <<>>, _} = cdr_decode:dec_type(T, {1, 2}, B, 0, big), + T1 = {'tk_alias', "IDL:Module/Alias1:1.0", "Alias1", + {'tk_sequence', {'tk_union', "IDL:Module/Union:1.0", "Union", + {'tk_enum', "IDL:Module/Enum:1.0", "Module_Enum", + ["horse", "pig", "cow"]}, 2, + [{"horse", "First", 'tk_ushort'}, + {"pig", "Second", {'tk_sequence', {'tk_string', 0}, 0}}, + {"cow", "Third", {'tk_enum', "IDL:Module/Enum1:1.0", + "Module_Enum1", ["orange", "banana", + "apple"]}}]},0}}, + S1 = [#'Module_Union'{label=cow, value=banana}, #'Module_Union'{label=pig, value=["This", "is", "a", "test", ""]}], + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T1, S1), + ?line {S1, <<>>, _} = cdr_decode:dec_type(T1, {1, 2}, B1, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Encode/decode test of type: exception +%%----------------------------------------------------------------- +exception_type(doc) -> []; +exception_type(suite) -> []; +exception_type(Config) when is_list(Config) -> + system_exceptions(), + user_exceptions(), + ok. + +system_exceptions() -> + E = #'UNKNOWN'{completion_status=?COMPLETED_YES}, + {system_exception, T, E} = orber_exceptions:get_def(E), + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T,E), + ?line {E, _} = cdr_decode:dec_system_exception({1, 2}, B, 0, big), + E1 = #'INV_OBJREF'{completion_status=?COMPLETED_NO}, + {system_exception, T1, E1} = orber_exceptions:get_def(E1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T1,E1), + ?line {E1, _} = cdr_decode:dec_system_exception({1, 2}, B1, 0, big), + E2 = #'BAD_OPERATION'{completion_status=?COMPLETED_NO}, + {system_exception, T2, E2} = orber_exceptions:get_def(E2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T2,E2), + ?line {E2, _} = cdr_decode:dec_system_exception({1, 2}, B2, 0, big), + E3 = #'INTF_REPOS'{completion_status=?COMPLETED_MAYBE}, + {system_exception, T3, E3} = orber_exceptions:get_def(E3), + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T3,E3), + ?line {E3, _} = cdr_decode:dec_system_exception({1, 2}, B3, 0, big), + ok. + +user_exceptions() -> + E = #'Module_Except1'{rest_of_name=["I","am","testing","exceptions"], why="Error"}, + {user_exception, T, E} = orber_exceptions:get_def(E), + ?line B = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T, E), + ?line {E, _} = cdr_decode:dec_user_exception({1, 2}, B, 0, big), + E1 = #'Module_Except2'{e=banana, + s=#'Module_Struct2'{long_sequence=[12,-4040, + 1234567898], + e=horse, + o=$a}}, + {user_exception, T1, E1} = orber_exceptions:get_def(E1), + ?line B1 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T1, E1), + ?line {E1, _} = cdr_decode:dec_user_exception({1, 2}, B1, 0, big), + E2 = #'Module_Except3'{u=#'Module_Union1'{label=pig,value=["high","and","low"]},s=1313, o=objref(0)}, + {user_exception, T2, E2} = orber_exceptions:get_def(E2), + ?line B2 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T2, E2), + ?line {E2, _} = cdr_decode:dec_user_exception({1, 2}, B2, 0, big), + E3 = #'Module_Except4'{}, + {user_exception, T3, E3} = orber_exceptions:get_def(E3), + ?line B3 = cdr_encode:enc_type(#giop_env{version = {1, 2}}, T3, E3), + ?line {E3, _} = cdr_decode:dec_user_exception({1, 2}, B3, 0, big), + ok. + +%%----------------------------------------------------------------- +%% Test Case: request encoding test +%% Description: Precondition the stack must be started so the +%% objectkey is valid. +%%----------------------------------------------------------------- +%request(suite) -> []; +%request(_) -> +% exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: reply encoding test +%% Description: +%%----------------------------------------------------------------- +reply(doc) -> ["Description", "more description"]; +reply(suite) -> []; +reply(Config) when is_list(Config) -> + R = #reply_header{service_context=[], request_id=1, + reply_status='no_exception'}, + ?line B = cdr_encode:enc_reply(#giop_env{version = {1, 2}, request_id = 1, + reply_status = 'no_exception', + tc = {'tk_long', [], [{'tk_sequence', + {'tk_string', 0}, 0}]}, + result = 1200, + parameters = [["foo","Bar"]], + ctx = []}), + + ?line {R, 1200, [["foo","Bar"]]} = + cdr_decode:dec_message({'tk_long', [], [{'tk_sequence', {'tk_string', 0},0}]}, + B), + + ok. + +%%----------------------------------------------------------------- +%% Test Case: cancel_request encoding test +%% Description: +%%----------------------------------------------------------------- +cancel_request(doc) -> ["Description", "more description"]; +cancel_request(suite) -> []; +cancel_request(Config) when is_list(Config) -> + R = #cancel_request_header{request_id=1}, + ?line B = cdr_encode:enc_cancel_request(#giop_env{version = {1, 2}, + request_id = 1}), + ?line R = cdr_decode:dec_message([], B), + ok. + +%%----------------------------------------------------------------- +%% Test Case: locate_request encoding test +%% Description: +%%----------------------------------------------------------------- +locate_request(doc) -> ["Description", "more description"]; +locate_request(suite) -> []; +locate_request(Config) when is_list(Config) -> + io:format("Function not imlpemented yet"), + exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: locate_reply encoding test +%% Description: +%%----------------------------------------------------------------- +locate_reply(doc) -> ["Description", "more description"]; +locate_reply(suite) -> []; +locate_reply(Config) when is_list(Config) -> + io:format("Function not imlpemented yet"), + exit(not_implemented). + +%%----------------------------------------------------------------- +%% Test Case: close_connection encoding test +%% Description: +%%----------------------------------------------------------------- +close_connection(doc) -> ["Description", "more description"]; +close_connection(suite) -> []; +close_connection(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_close_connection(#giop_env{version = {1, 2}}), + ?line 'close_connection' = cdr_decode:dec_message([], B), + ok. + +%%----------------------------------------------------------------- +%% Test Case: message_error encoding test +%% Description: +%%----------------------------------------------------------------- +message_error(doc) -> ["Description", "more description"]; +message_error(suite) -> []; +message_error(Config) when is_list(Config) -> + ?line B = cdr_encode:enc_message_error(#giop_env{version = {1, 2}}), + ?line 'message_error' = cdr_decode:dec_message([], B), + ok. + + + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- +corba_fake_mk_objkey(Id, 'key', Pid) when is_pid(Pid) -> + Key = make_objkey(), + {list_to_binary(Id), 'key', Key, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}; +corba_fake_mk_objkey(Id, 'key', RegName) when is_atom(RegName) -> + Key = term_to_binary(RegName), + {list_to_binary(Id), 'key', Key, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}; +corba_fake_mk_objkey(Id, 'registered', RegName) when is_atom(RegName) -> + {list_to_binary(Id), 'registered', RegName, term_to_binary(undefined), + term_to_binary(undefined), term_to_binary(undefined)}. + +make_objkey() -> + term_to_binary({now(), node()}). diff --git a/lib/orber/test/cdrlib_SUITE.erl b/lib/orber/test/cdrlib_SUITE.erl new file mode 100644 index 0000000000..fa2d7f2a30 --- /dev/null +++ b/lib/orber/test/cdrlib_SUITE.erl @@ -0,0 +1,487 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the CDR basic type encode/decode functions +%% +%%----------------------------------------------------------------- +-module(cdrlib_SUITE). + +-include("test_server.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> + [short, ushort, long, ulong, longlong, ulonglong, boolean, character, octet, + float, double, enum]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: short integer test +%% Description: +%%----------------------------------------------------------------- +short(doc) -> ["Description", "more description"]; +short(suite) -> []; +short(_) -> + short_big_loop([-32768, -4040, -1, 0, 4040, 32767]), + short_little_loop([-32768, -4040, -1, 0, 4040, 32767]), + bad_short(). + +short_big_loop([]) -> + ok; +short_big_loop([X |List]) -> + ?line [CodedType] = cdrlib:enc_short(X, []), + ?line {X, <<>>} = cdrlib:dec_short(big, CodedType), + short_big_loop(List), + ok. + +short_little_loop([]) -> + ok; +short_little_loop([X |List]) -> + ?line CodedType = enc_short_little(X, []), + ?line {X, <<>>} = cdrlib:dec_short(little, CodedType), + short_little_loop(List), + ok. + +enc_short_little(X, Message) -> + list_to_binary([(X) band 16#ff, ((X) bsr 8) band 16#ff | Message]). + +bad_short() -> + ?line {'EXCEPTION', _} = (catch cdrlib:enc_short('atom', [])), + ?line [CodedType] = cdrlib:enc_char($a, []), + ?line {'EXIT', _} = (catch cdrlib:dec_short(big, CodedType)), + ok. +%%----------------------------------------------------------------- +%% Test Case: unsigned short integer test +%% Description: +%%----------------------------------------------------------------- +ushort(doc) -> ["Description", "more description"]; +ushort(suite) -> []; +ushort(_) -> + ushort_big_loop([0, 4040, 65535]), + ushort_little_loop([0, 4040, 65535]), + bad_ushort(). + +ushort_big_loop([]) -> + ok; +ushort_big_loop([X |List]) -> + ?line [CodedType] = cdrlib:enc_unsigned_short(X, []), + ?line {X, <<>>} = cdrlib:dec_unsigned_short(big, CodedType), + ushort_big_loop(List), + ok. + +ushort_little_loop([]) -> + ok; +ushort_little_loop([X |List]) -> + ?line CodedType = enc_ushort_little(X, []), + ?line {X, <<>>} = cdrlib:dec_unsigned_short(little, CodedType), + ushort_little_loop(List), + ok. + +enc_ushort_little(X, Message) -> + list_to_binary([(X) band 16#ff, ((X) bsr 8) band 16#ff | Message]). + +bad_ushort() -> + ok. +%%----------------------------------------------------------------- +%% Test Case: long integer test +%% Description: +%%----------------------------------------------------------------- +long(doc) -> ["Description", "more description"]; +long(suite) -> []; +long(_) -> + long_big_loop([-2147483648, -40404040, -32768, -4040, -1, + 0, 4040, 32767, 40404040, 2147483647]), + long_little_loop([-2147483648, -40404040, -32768, -4040, -1, + 0, 4040, 32767, 40404040, 2147483647]), + bad_long(). + + +long_big_loop([]) -> + ok; +long_big_loop([X |List]) -> + ?line [CodedType] = cdrlib:enc_long(X, []), + ?line {X, <<>>} = cdrlib:dec_long(big, CodedType), + long_big_loop(List), + ok. + +long_little_loop([]) -> + ok; +long_little_loop([X |List]) -> + ?line CodedType = enc_long_little(X, []), + ?line {X, <<>>} = cdrlib:dec_long(little, CodedType), + long_little_loop(List), + ok. + +enc_long_little(X, Message) -> + list_to_binary([(X) band 16#ff, ((X) bsr 8) band 16#ff, ((X) bsr 16) band 16#ff, + ((X) bsr 24) band 16#ff | Message]). + +bad_long() -> + ok. + +%%----------------------------------------------------------------- +%% Test Case: unsigned long integer test +%% Description: +%%----------------------------------------------------------------- +ulong(doc) -> ["Description", "more description"]; +ulong(suite) -> []; +ulong(_) -> + ulong_big_loop([0, 4040, 65535, 40404040, 2147483647, 4294967295]), + ulong_little_loop([0, 4040, 65535, 40404040, 2147483647, 4294967295]), + bad_ulong(). + + +ulong_big_loop([]) -> + ok; +ulong_big_loop([X |List]) -> + ?line [CodedType] = cdrlib:enc_unsigned_long(X, []), + ?line {X, <<>>} = cdrlib:dec_unsigned_long(big, CodedType), + ulong_big_loop(List), + ok. + +ulong_little_loop([]) -> + ok; +ulong_little_loop([X |List]) -> + ?line CodedType = enc_ulong_little(X, []), + ?line {X, <<>>} = cdrlib:dec_unsigned_long(little, CodedType), + ulong_little_loop(List), + ok. + +enc_ulong_little(X, Message) -> + list_to_binary([(X) band 16#ff, ((X) bsr 8) band 16#ff, ((X) bsr 16) band 16#ff, + ((X) bsr 24) band 16#ff | Message]). + + +bad_ulong() -> + ok. + +%%----------------------------------------------------------------- +%% Test Case: long integer test +%% Description: +%%----------------------------------------------------------------- +longlong(doc) -> ["Description", "more description"]; +longlong(suite) -> []; +longlong(_) -> + longlong_big_loop([-2147483648, -40404040, -32768, -4040, -1, + 0, 4040, 32767, 40404040, 2147483647]), + longlong_little_loop([-2147483648, -40404040, -32768, -4040, -1, + 0, 4040, 32767, 40404040, 2147483647]), + bad_longlong(). + + +longlong_big_loop([]) -> + ok; +longlong_big_loop([X |List]) -> + ?line [CodedType] = cdrlib:enc_longlong(X, []), + ?line {X, <<>>} = cdrlib:dec_longlong(big, CodedType), + longlong_big_loop(List), + ok. + +longlong_little_loop([]) -> + ok; +longlong_little_loop([X |List]) -> + ?line CodedType = enc_longlong_little(X, []), + ?line {X, <<>>} = cdrlib:dec_longlong(little, CodedType), + longlong_little_loop(List), + ok. + +enc_longlong_little(X, Message) -> + list_to_binary([(X) band 16#ff, ((X) bsr 8) band 16#ff, ((X) bsr 16) band 16#ff, + ((X) bsr 24) band 16#ff, ((X) bsr 32) band 16#ff, ((X) bsr 40) band 16#ff, + ((X) bsr 48) band 16#ff, ((X) bsr 56) band 16#ff | Message]). + +bad_longlong() -> + ok. + +%%----------------------------------------------------------------- +%% Test Case: unsigned long integer test +%% Description: +%%----------------------------------------------------------------- +ulonglong(doc) -> ["Description", "more description"]; +ulonglong(suite) -> []; +ulonglong(_) -> + ulonglong_big_loop([0, 4040, 65535, 40404040, 2147483647, 4294967295]), + ulonglong_little_loop([0, 4040, 65535, 40404040, 2147483647, 4294967295]), + bad_ulonglong(). + + +ulonglong_big_loop([]) -> + ok; +ulonglong_big_loop([X |List]) -> + ?line [CodedType] = cdrlib:enc_unsigned_longlong(X, []), + ?line {X, <<>>} = cdrlib:dec_unsigned_longlong(big, CodedType), + ulonglong_big_loop(List), + ok. + +ulonglong_little_loop([]) -> + ok; +ulonglong_little_loop([X |List]) -> + ?line CodedType = enc_ulonglong_little(X, []), + ?line {X, <<>>} = cdrlib:dec_unsigned_longlong(little, CodedType), + ulonglong_little_loop(List), + ok. + +enc_ulonglong_little(X, Message) -> + list_to_binary([(X) band 16#ff, ((X) bsr 8) band 16#ff, ((X) bsr 16) band 16#ff, + ((X) bsr 24) band 16#ff, ((X) bsr 32) band 16#ff, ((X) bsr 40) band 16#ff, + ((X) bsr 48) band 16#ff, ((X) bsr 56) band 16#ff | Message]). + +bad_ulonglong() -> + ok. + + + +%%----------------------------------------------------------------- +%% Test Case: boolean test +%% Description: +%%----------------------------------------------------------------- +boolean(doc) -> ["Description", "more description"]; +boolean(suite) -> []; +boolean(_) -> + ?line [CodedTrue] = cdrlib:enc_bool('true', []), + ?line {'true', <<>>} = cdrlib:dec_bool(CodedTrue), + ?line [CodedFalse] = cdrlib:enc_bool('false', []), + ?line {'false', <<>>} = cdrlib:dec_bool(CodedFalse), + ok. + +%%----------------------------------------------------------------- +%% Test Case: character test +%% Description: +%%----------------------------------------------------------------- +character(doc) -> ["Description", "more description"]; +character(suite) -> []; +character(_) -> + ?line [Coded_0] = cdrlib:enc_char($0, []), + ?line {$0, <<>>} = cdrlib:dec_char(Coded_0), + ?line [Coded_a] = cdrlib:enc_char($a, []), + ?line {$a, <<>>} = cdrlib:dec_char(Coded_a), + ?line [Coded_Z] = cdrlib:enc_char($Z, []), + ?line {$Z, <<>>} = cdrlib:dec_char(Coded_Z), + ?line [Coded_dollar] = cdrlib:enc_char($$, []), + ?line {$$, <<>>} = cdrlib:dec_char(Coded_dollar), + ok. + +%%----------------------------------------------------------------- +%% Test Case: octet test +%% Description: +%%----------------------------------------------------------------- +octet(doc) -> ["Description", "more description"]; +octet(suite) -> []; +octet(_) -> + ?line [Coded_ff] = cdrlib:enc_octet(16#ff, []), + ?line {16#ff, <<>>} = cdrlib:dec_octet(Coded_ff), + ?line [Coded_00] = cdrlib:enc_octet(16#00, []), + ?line {16#00, <<>>} = cdrlib:dec_octet(Coded_00), + ?line [Coded_5a] = cdrlib:enc_octet(16#5a, []), + ?line {16#5a, <<>>} = cdrlib:dec_octet(Coded_5a), + ?line [Coded_48] = cdrlib:enc_octet(16#48, []), + ?line {16#48, <<>>} = cdrlib:dec_octet(Coded_48), + ok. + + + +%%----------------------------------------------------------------- +%% Test Case: float test +%% Description: +%%----------------------------------------------------------------- +float(doc) -> ["Description", "more description"]; +float(suite) -> []; +float(_) -> + G = 16#7fffff / 16#800000 + 1.0, + H1 = math:pow(2, 127), + H2 = math:pow(2, -126), + float_big_loop([-H1 * G, -H1 * 1.0, -H2 * G, -H2 * 1.0, + -4040.313131, -3.141592, 0.0, 3.141592, 4040.313131, + H1 * G, H1 * 1.0, H2 * G, H2 * 1.0]), + float_little_loop([-H1 * G, -H1 * 1.0, -H2 * G, -H2 * 1.0, + -4040.313131, -3.141592, 0.0, 3.141592, 4040.313131, + H1 * G, H1 * 1.0, H2 * G, H2 * 1.0]), + ok. + +float_big_loop([]) -> + ok; +float_big_loop([X |List]) -> + ?line [CodedType] = cdrlib:enc_float(X, []), + ?line {Y, <<>>} = cdrlib:dec_float(big, CodedType), + ?line float_comp(X,Y), + float_big_loop(List), + ok. + +float_little_loop([]) -> + ok; +float_little_loop([X |List]) -> + ?line [CodedType] = enc_float_little(X, []), + ?line {Y, <<>>} = cdrlib:dec_float(little, CodedType), + ?line float_comp(X,Y), + float_little_loop(List), + ok. + +float_comp(X,Y) when X == 0.0, Y == 0.0 -> + ok; +float_comp(X,Y) -> + Div = abs(Y) / abs(X), + %% io:format("~p~n", [float_to_list(Div)]), + ?line true = (Div < 1.0000001), + ?line true = (Div > 0.9999999), + ok. + +enc_float_little(X, Message) -> + [ <<X:32/little-float>> | Message]. + +%%----------------------------------------------------------------- +%% Test Case: double test +%% Description: +%%----------------------------------------------------------------- +double(doc) -> ["Description", "more description"]; +double(suite) -> []; +double(_) -> + F = 16#0fffffffffffff / 16#10000000000000 + 1.0, + E1 = math:pow(2, 1023), + E2 = math:pow(2, -1022), + G = 16#7fffff / 16#800000 + 1.0, + H1 = math:pow(2, 128), + H2 = math:pow(2, -127), + double_big_loop([-E1 * F, -E1 * 1.0, -E2 * F, -E2 * 1.0, + -H1 * G, -H1 * 1.0, -H2 * G, -H2 * 1.0, + -4040.313131, -3.141592, 0.0, 3.141592, 4040.313131, + H1 * G, H1 * 1.0, H2 * G, H2 * 1.0, + E1 * F, E1 * 1.0, E2 * F, E2 * 1.0]), + double_little_loop([-E1 * F, -E1 * 1.0, -E2 * F, -E2 * 1.0, + -H1 * G, -H1 * 1.0, -H2 * G, -H2 * 1.0, + -4040.313131, -3.141592, 0.0, 3.141592, 4040.313131, + H1 * G, H1 * 1.0, H2 * G, H2 * 1.0, + E1 * F, E1 * 1.0, E2 * F, E2 * 1.0]), + ok. + +double_big_loop([]) -> + ok; +double_big_loop([X |List]) -> + ?line [CodedType] = cdrlib:enc_double(X, []), + ?line {Y, <<>>} = cdrlib:dec_double(big, CodedType), + ?line double_comp(X,Y), + double_big_loop(List), + ok. + +double_little_loop([]) -> + ok; +double_little_loop([X |List]) -> + ?line [CodedType] = enc_double_little(X, []), + ?line {Y, <<>>} = cdrlib:dec_double(little, CodedType), + ?line double_comp(X,Y), + double_little_loop(List), + ok. + +enc_double_little(X, Message) -> + [ <<X:64/little-float>> | Message]. + +double_comp(X,Y) when X == 0.0, Y == 0.0 -> + ok; +double_comp(X,Y) -> + Div = abs(Y) / abs(X), + %% io:format("~p~n", [float_to_list(Div)]), + ?line true = (Div < 1.00000000000001), + ?line true = (Div > 0.99999999999999), + ok. + +double_should_be_ok(doc) -> ["Description", "more description"]; +double_should_be_ok(suite) -> []; +double_should_be_ok(_) -> + F = 16#0fffffffffffff / 16#10000000000000 + 1.0, + E1 = math:pow(2, 1024), % erlang can't handle this. + E2 = math:pow(2, -1023), + double_big_loop([-E1 * F, -E1 * 1.0, -E2 * F, -E2 * 1.0, + E1 * F, E1 * 1.0, E2 * F, E2 * 1.0]), + double_little_loop([-E1 * F, -E1 * 1.0, -E2 * F, -E2 * 1.0, + E1 * F, E1 * 1.0, E2 * F, E2 * 1.0]), + ok. + +%%----------------------------------------------------------------- +%% Test Case: enum test +%% Description: +%%----------------------------------------------------------------- +enum(doc) -> ["Description", "more description"]; +enum(suite) -> []; +enum(_) -> + enum_big(), + enum_little(), + ok. + +enum_big() -> + ?line [Coded_a] = cdrlib:enc_enum(a,[a,b,c],[]), + ?line {a, <<>>} = cdrlib:dec_enum(big, ["a","b","c"], Coded_a), + ?line [Coded_b] = cdrlib:enc_enum(b,[a,b,c],[]), + ?line {b, <<>>} = cdrlib:dec_enum(big, ["a","b","c"], Coded_b), + ?line [Coded_c] = cdrlib:enc_enum(c,[a,b,c],[]), + ?line {c, <<>>} = cdrlib:dec_enum(big, ["a","b","c"], Coded_c), + ok. + +enum_little() -> + ?line Coded_a = enc_r_enum(a,[a,b,c],[]), + ?line {a, <<>>} = cdrlib:dec_enum(little, ["a","b","c"], Coded_a), + ?line Coded_b = enc_r_enum(b,[a,b,c],[]), + ?line {b, <<>>} = cdrlib:dec_enum(little, ["a","b","c"], Coded_b), + ?line Coded_c = enc_r_enum(c,[a,b,c],[]), + ?line {c, <<>>} = cdrlib:dec_enum(little, ["a","b","c"], Coded_c), + ok. + +enc_r_enum(Enum, ElemList, Message) -> + Val = getEnumValue(ElemList,Enum, 0), + enc_r_unsigned_long(Val, Message). + +getEnumValue([Enum |_List], Enum, N) -> + N; +getEnumValue([_ |List], Enum, N) -> + getEnumValue(List, Enum, N + 1). + +enc_r_unsigned_long(X, Message) -> + list_to_binary([(X) band 16#ff, ((X) bsr 8) band 16#ff, + ((X) bsr 16) band 16#ff, ((X) bsr 24) band 16#ff | Message]). diff --git a/lib/orber/test/corba_SUITE.erl b/lib/orber/test/corba_SUITE.erl new file mode 100644 index 0000000000..dae8fcbefc --- /dev/null +++ b/lib/orber/test/corba_SUITE.erl @@ -0,0 +1,909 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for corba/boa/object/orber API functions +%% +%%----------------------------------------------------------------- +-module(corba_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + + +-define(default_timeout, ?t:minutes(5)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([pseudo_calls/2, pseudo_casts/2]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for the CORBA/BOA/Object/orber interfaces", ""]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [exception_info_api, corba_api, object_api, orber_api, + orber_objectkeys_api, orber_pseudo_objects, callback_ok_api, + callback_arity_api, callback_module_api, callback_function_api, + callback_precond_api, callback_postcond_api, callback_exit_api, + callback_badarith_api, callback_case_clause_api, + callback_function_clause_api]. + +%% boa_api, request, locate_request, locate_reply]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + corba:orb_init([{orber_debug_level, 10}, {giop_version, {1,2}}, + {iiop_port, 0}]), + mnesia:delete_schema([node()]), + mnesia:create_schema([node()]), + orber:install([node()]), + application:start(mnesia), + application:start(orber), + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + application:stop(orber), + application:stop(mnesia), + mnesia:delete_schema([node()]), + Config. + +%%----------------------------------------------------------------- +%% API tests for pseudo interface CORBA +%%----------------------------------------------------------------- +corba_api(doc) -> ["CORBA API tests", ""]; +corba_api(suite) -> []; +corba_api(_) -> + NIL = corba:create_nil_objref(), + ?line ok = corba:dispose(NIL), + ?line NS = corba:resolve_initial_references("NameService"), + ?line List = corba:list_initial_services(), + ?line ["NameService"] = List, + ?line NSstring = corba:object_to_string(NS), + ?line NS1 = corba:string_to_object(NSstring), + ?line NSstring = corba:object_to_string(NS1), + ?line true = corba:add_initial_service("MyData", NS), + ?line NS = corba:resolve_initial_references("MyData"), + ?line [_,_] = corba:list_initial_services(), + ?line false = corba:remove_initial_service("Wrong"), + ?line NIL = corba:resolve_initial_references("Wrong"), + ?line NS = corba:string_to_object("corbaloc:rir:/MyData"), + ?line true = corba:remove_initial_service("MyData"), + ?line ["NameService"] = corba:list_initial_services(), + + %% This is a collection of different stringified IOR:s (correct & incorrect) + %% which we use to test IOR encode/decode. + ?line IOR1 = ?match({'IOP_IOR',_,_}, corba:string_to_object("IOR:000303030000000d49444c3a746573743a312e3000030303000000040000000000000100000102010000000a3132372e302e302e31009d610000002dabacab3131303432343836383731005f526f6f74504f4100414c4c5f504f410000cafebabe3e2316570000000003030300000002000000210000007800010202000000010040020200000022000000080003030300000000004000400000000806066781020101010000001b0401000806066781020101010000000b40616469726f6e2e636f6d010400000000000000000000020000000806066781020101010000000b06092a864886f712010202010000000f000000010000002c00030303000100010000000400010020000101090001010005010001000101090000000200010100050100010000000000000184000102010000000a3132372e302e302e310000000000002dabacab3131303432343836383731005f526f6f74504f4100414c4c5f504f410000cafebabe3e231657000000000303030000000300000021000000ec000102020000000200060202000000240000001c0001006600060202000000010000000a3132372e302e302e31009d600000000000000000000000000400000000000000000000020000000806066781020101010000000b06092a864886f712010202010000000f00460202000000240000001c0001006600060202000000010000000a3132372e302e302e31009d62004000400000000806066781020101010000001b0401000806066781020101010000000b40616469726f6e2e636f6d010400000000000000000000020000000806066781020101010000000b06092a864886f712010202010000000f00000014000000080001006600069d5e000000010000002c000303030001000100000004000100200001010900010100050100010001010900000002000101000501000100000000000000dc000102010000000a3132372e302e302e31009d5f0000002dabacab3131303432343836383731005f526f6f74504f4100414c4c5f504f410000cafebabe3e23165700000000030303000000020000002100000054000102020000000100000202000000220000000800030303000000000000000000000000000000000400000000000000000000020000000806066781020101010000000b06092a864886f712010202010000000f000000010000002c00030303000100010000000400010020000101090001010005010001000101090000000200010100050100010000000000000080000102010000000a3132372e302e302e31009d5d0000002dabacab3131303432343836383731005f526f6f74504f4100414c4c5f504f410000cafebabe3e2316570000000003030300000001000000010000002c0003030300010001000000040001002000010109000101000501000100010109000000020001010005010001")), + ?line IOR2 = ?match({'IOP_IOR',_,_}, corba:string_to_object("IOR:000303030000000d49444c3a746573743a312e30000303030000000100000000000000e0000102010000000a3132372e302e302e31009d5f00000034abacab3131303432343836383731005f526f6f74504f410049494f505f43534976325f504f410000cafebabe3e23165700000000000000020000002100000054000102020000000100000202000000220000000800030303000000000000000000000000000000000400000000000000000000020000000806066781020101010000000b06092a864886f712010202010000000f000000010000002c0003030300010001000000040001002000010109000101000501000100010109000000020001010005010001")), + ?line IOR3 = ?match({'IOP_IOR',_,_}, corba:string_to_object("IOR:000303030000000d49444c3a746573743a312e3000030303000000010000000000000108000102010000000a3132372e302e302e31009d6100000037abacab3131303432343836383731005f526f6f74504f410049494f505f43534976325f55505f504f410000cafebabe3e231657000000000100000002000000210000007800010202000000010040020200000022000000080003030300000000004000400000000806066781020101010000001b0401000806066781020101010000000b40616469726f6e2e636f6d010400000000000000000000020000000806066781020101010000000b06092a864886f712010202010000000f000000010000002c0003030300010001000000040001002000010109000101000501000100010109000000020001010005010001")), + ?line IOR4 = ?match({'IOP_IOR',_,_}, corba:string_to_object("IOR:000303030000000d49444c3a746573743a312e3000030303000000010000000000000080000102010000000a3132372e302e302e31009d5d0000002eabacab3131303432343836383731005f526f6f74504f410049494f505f504f410000cafebabe3e23165700000000020200000001000000010000002c0003030300010001000000040001002000010109000101000501000100010109000000020001010005010001")), + ?line IOR5 = ?match({'IOP_IOR',_,_}, corba:string_to_object("IOR:000303030000000d49444c3a746573743a312e30000303030000000100000000000000fc000102010000000a3132372e302e302e3100000000000033abacab3131303432343836383731005f526f6f74504f4100544c535f43534976325f504f410000cafebabe3e231657000000000100000002000000210000007000010202000000010006020200000024000000220001006600060202000000010000000f3132382e3233302e3230382e353500019d6000000000020200000000000000000400000000000000000000020000000806066781020101010000000b06092a864886f712010202010000000f000000010000002c0003030300010001000000040001002000010109000101000501000100010109000000020001010005010001")), + ?line IOR6 = ?match({'IOP_IOR',_,_}, corba:string_to_object("IOR:000303030000000d49444c3a746573743a312e3000030303000000010000000000000124000102010000000a3132372e302e302e3100000000000036abacab3131303432343836383731005f526f6f74504f4100544c535f43534976325f55505f504f410000cafebabe3e23165700000000020200000002000000210000009400010202000000010046020200000024000000220001006600060202000000010000000f3132382e3233302e3230382e353500019d620040004002020000000806066781020101010000001b0401000806066781020101010000000b40616469726f6e2e636f6d010400000000000000000000020000000806066781020101010000000b06092a864886f712010202010000000f000000010000002c0003030300010001000000040001002000010109000101000501000100010109000000020001010005010001")), + ?line IOR7 = ?match({'IOP_IOR',_,_}, corba:string_to_object("IOR:000303030000000d49444c3a746573743a312e3000030303000000010000000000000090000102010000000a3132372e302e302e310000000000002dabacab3131303432343836383731005f526f6f74504f4100544c535f504f410000cafebabe3e231657000000000303030000000200000014000000080001006600069d5e000000010000002c0003030300010001000000040001002000010109000101000501000100010109000000020001010005010001")), + ?line IOR1 = corba:string_to_object(corba:object_to_string(IOR1)), + ?line IOR2 = corba:string_to_object(corba:object_to_string(IOR2)), + ?line IOR3 = corba:string_to_object(corba:object_to_string(IOR3)), + ?line IOR4 = corba:string_to_object(corba:object_to_string(IOR4)), + ?line IOR5 = corba:string_to_object(corba:object_to_string(IOR5)), + ?line IOR6 = corba:string_to_object(corba:object_to_string(IOR6)), + ?line IOR7 = corba:string_to_object(corba:object_to_string(IOR7)), + ?line ?match(ok, corba:print_object(IOR1)), + ?line ?match(ok, corba:print_object(IOR2)), + ?line ?match(ok, corba:print_object(IOR3)), + ?line ?match(ok, corba:print_object(IOR4)), + ?line ?match(ok, corba:print_object(IOR5)), + ?line ?match(ok, corba:print_object(IOR6)), + ?line ?match(ok, corba:print_object(IOR7)), + ?line ?match(ok, corba:print_object("IOR:000303030000000d49444c3a746573743a312e300003030300000002000000000000003000010001000000136d792e686f73742e65726c616e672e6f72670001801a02020000000c424f410a00000a0000070a010000000100000024000303030000000100000001000000140003030300010001000000000001010900000000")), + [IP] = ?match([_], orber:host()), + ?match(#'IOP_IOR'{profiles=[#'IOP_TaggedProfile' + {tag=?TAG_INTERNET_IOP, + profile_data=#'IIOP_ProfileBody_1_1' + {host = IP}}]}, + corba:string_to_object(corba:object_to_string(NS))), + ?match(#'IOP_IOR'{profiles=[#'IOP_TaggedProfile' + {tag=?TAG_INTERNET_IOP, + profile_data=#'IIOP_ProfileBody_1_1' + {host = "127.0.0.1"}}]}, + corba:string_to_object(corba:object_to_string(NS, ["127.0.0.1"]))), + ?match(#'IOP_IOR'{profiles=[#'IOP_TaggedProfile' + {tag=?TAG_INTERNET_IOP, + profile_data=#'IIOP_ProfileBody_1_1' + {host = "127.0.0.1", port = 5468}}]}, + corba:string_to_object(corba:object_to_string(NS, ["127.0.0.1"], + 5468))), + ok. + +%%----------------------------------------------------------------- +%% API tests for interface BOA +%%----------------------------------------------------------------- +boa_api(doc) -> ["BOA API tests", ""]; +boa_api(suite) -> []; +boa_api(_) -> + ok. + +%%----------------------------------------------------------------- +%% API tests for interface OBJECT +%%----------------------------------------------------------------- +object_api(doc) -> ["Object API tests", ""]; +object_api(suite) -> []; +object_api(_) -> + ?line oe_orber_test_server:oe_register(), + ?line EC = orber_test_server:oe_create(), + ?line NS = corba:resolve_initial_references("NameService"), + %% testing corba_object:is_a(Obj, IFRID) locally. + ?line orber_test_lib:corba_object_tests(EC, NS), + + ?line ?match(false, corba_object:non_existent(NS)), + + ?line corba:dispose(EC), + ?line oe_orber_test_server:oe_unregister(), + ok. + +%%----------------------------------------------------------------- +%% API tests for orbers main module +%%----------------------------------------------------------------- +orber_api(doc) -> ["orber API tests", ""]; +orber_api(suite) -> []; +orber_api(_) -> + ?line ok = orber:uninstall(), + ?line orber:install([node()]), + ?line application:start(orber), + ?line NodeList = orber:orber_nodes(), + ?line NL = node(), + ?line [NL] = NodeList, + ok. + +%%----------------------------------------------------------------- +%% API tests for exception mapping +%%----------------------------------------------------------------- +exception_info_api(doc) -> ["orber API tests", ""]; +exception_info_api(suite) -> []; +exception_info_api(_) -> + ?line {ok, S1} = orber:exception_info({'EXCEPTION',{'MARSHAL',[],1163001858,'COMPLETED_NO'}}), + ?line {ok, S2} = orber:exception_info({'EXCEPTION',{'MARSHAL',[],1330446337,'COMPLETED_NO'}}), + ?line {ok, S3} = orber:exception_info({'EXCEPTION',{'MARSHAL',[],1398079490,'COMPLETED_NO'}}), + ?line {ok, S4} = orber:exception_info({'EXCEPTION',{'MARSHAL',[],1347813377,'COMPLETED_NO'}}), + ?line {ok, S5} = orber:exception_info({'EXCEPTION', {'CosNaming_NamingContext_InvalidName',"IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0"}}), + ?line error_logger:info_msg("~s", [S1]), + ?line error_logger:info_msg("~s", [S2]), + ?line error_logger:info_msg("~s", [S3]), + ?line error_logger:info_msg("~s", [S4]), + ?line error_logger:info_msg("~s", [S5]), + ok. + +%%----------------------------------------------------------------- +%% API tests for orbers pseudo objects. +%%----------------------------------------------------------------- +orber_pseudo_objects(doc) -> ["orber_pseudo_objects API tests", ""]; +orber_pseudo_objects(suite) -> []; +orber_pseudo_objects(_) -> + ?line oe_orber_test_server:oe_register(), + Obj1=(catch orber_test_server:oe_create(state,[{pseudo,true}, + {local_typecheck, true}])), + ?line ?match({_,pseudo,orber_test_server_impl, _,_, _}, Obj1), + Obj2=(catch orber_test_server:oe_create([],[{pseudo, truce}])), + ?line ?match({'EXCEPTION',{'BAD_PARAM',[],_,'COMPLETED_NO'}}, Obj2), + spawn(?MODULE, pseudo_calls, [20, Obj1]), + ?line ?match({ok, 10000}, orber_test_server:pseudo_call_delay(Obj1, 10000)), + spawn(?MODULE, pseudo_casts, [20, Obj1]), + ?line ?match(ok, orber_test_server:pseudo_cast_delay(Obj1, 10000)), + + ?line ?match('object_here', corba:locate(Obj1)), + + ?line NS = corba:resolve_initial_references("NameService"), + + ?line orber_test_lib:corba_object_tests(Obj1, NS), + + ?line ?match("IDL:omg.org/orber_test/server:1.0",orber_test_server:typeID()), + + %% Test if exceptions are handled properly. + ?line ?match({'EXCEPTION',{'BAD_QOS',_,_,_}}, + orber_test_server:pseudo_call_raise_exc(Obj1, 1)), + ?line ?match({'EXCEPTION',{'BAD_QOS',_,_,_}}, + orber_test_server:pseudo_call_raise_exc(Obj1, 2)), + + %% Test if exit is handled properly. + ?line ?match({'EXCEPTION',{'TRANSIENT',_,_,_}}, + orber_test_server:stop_brutal(Obj1)), + + orber_test_lib:test_coding(Obj1, true), + + %% possible to use subobject key? + ?line ?match(state, binary_to_term(corba:get_subobject_key(Obj1))), + + ?line ?match({'EXCEPTION',{'INV_OBJREF',[],_,'COMPLETED_NO'}}, + corba:get_pid(Obj1)), + ?line ?match(false, corba_object:non_existent(Obj1)), + + ?line ?match(ok, corba:dispose(Obj1)), + + ?line ?match(false, corba_object:non_existent(Obj1)), + + %% Try if it's possible to stringify and recover the object reference. + IOR_string = (catch corba:object_to_string(Obj1)), + Obj3 =(catch corba:string_to_object(IOR_string)), + ?line ?match(IOR_string, corba:object_to_string(Obj3)), + + Obj4=(catch orber_test_server:oe_create(undefined,[{pseudo,true}])), + ?line ?match(ok, corba:dispose(Obj4)), + ?line oe_orber_test_server:oe_unregister(), + ok. + +%%----------------------------------------------------------------- +%% API tests for orbers objectkeys server. +%%----------------------------------------------------------------- +orber_objectkeys_api(doc) -> ["orber_objectkeys API tests", ""]; +orber_objectkeys_api(suite) -> []; +orber_objectkeys_api(_) -> + Obj0=(catch orber_test_server:oe_create([], [{sup_child, true}])), + Obj1=(catch orber_test_server:oe_create([], [{persistent, true}, + {regname, {local,obj1}}])), + Obj2=(catch orber_test_server:oe_create([], [{persistent, true}, + {regname, {global,{obj2, 12345}}}])), + + %% Obj0 is supposed to be a child started by a supervisor (r6) which + %% handles not only {ok, Pid} but also {ok,Pid, Returnvalue}. In our + %% case the Returnvalue is an ObjectRef. + ?line ?match({ok,_,{_,key,_, _,_, _}}, Obj0), + {ok,_,Obj0Ref} = Obj0, + corba:dispose(Obj0Ref), + + %% Only 'global' servers are at the moment allowed to be persistent. + ?line ?match({'EXCEPTION',{'BAD_PARAM',[],_,'COMPLETED_NO'}}, Obj1), + + %% We created a persistent object successfully. + ?line ?match({_,key,_,_,_, _}, Obj2), + + %% Get key and Pid + {_,_,Key,_,_, _} = Obj2, + PID=(catch orber_objectkeys:get_pid(Key)), + + %% Use the two different ways to look up if the server is persistent. + ?line ?match(true, orber_objectkeys:is_persistent(Key)), + ?line ?match(true, orber_objectkeys:is_persistent(PID)), + + %% Create servers using every possible way. + O1=(catch orber_test_server:oe_create()), + O2=(catch orber_test_server:oe_create_link()), + O3=(catch orber_test_server:oe_create([])), + O4=(catch orber_test_server:oe_create_link([])), + %% NOTE!!! Next four lines requires that we still support RegName instead of + %% only OptionList as the second argument to oe_create*/2. Remove these when that + %% is no longer the case. + O5=(catch orber_test_server:oe_create([], {'local', o5})), + O6=(catch orber_test_server:oe_create([], {'global', {o6, obj}})), + O7=(catch orber_test_server:oe_create_link([], {'local', o7})), + O8=(catch orber_test_server:oe_create_link([], {'global', {o8, obj}})), + + %% Test if all the object references are correct. + ?line ?match({_,key,_,_,_, _}, O1), + ?line ?match({_,key,_,_,_, _}, O2), + ?line ?match({_,key,_,_,_, _}, O3), + ?line ?match({_,key,_,_,_, _}, O4), + ?line ?match({_, registered, o5, _,_, _}, O5), + ?line ?match({_,key,_,_,_, _}, O6), + ?line ?match({_, registered, o7, _,_, _}, O7), + ?line ?match({_,key,_,_,_, _}, O8), + + %% Test if persistent. + {_,_,Key1,_,_, _} = O1, + PID1=(catch orber_objectkeys:get_pid(Key1)), + ?line ?match(false, orber_objectkeys:is_persistent(Key1)), + ?line ?match(false, orber_objectkeys:is_persistent(PID1)), + + %% all the servers are alive(?!). + ?line ?match(false, corba_object:non_existent(O1)), + ?line ?match(false, corba_object:non_existent(O2)), + ?line ?match(false, corba_object:non_existent(O3)), + ?line ?match(false, corba_object:non_existent(O4)), + ?line ?match(false, corba_object:non_existent(O5)), + ?line ?match(false, corba_object:non_existent(O6)), + ?line ?match(false, corba_object:non_existent(O7)), + ?line ?match(false, corba_object:non_existent(O8)), + ?line ?match(false, corba_object:non_existent(Obj2)), + + %% Does locate work? + ?line ?match('object_here', corba:locate(O1)), + ?line ?match('object_here', corba:locate(O2)), + ?line ?match('object_here', corba:locate(O3)), + ?line ?match('object_here', corba:locate(O4)), + ?line ?match('object_here', corba:locate(O5)), + ?line ?match('object_here', corba:locate(O6)), + ?line ?match('object_here', corba:locate(O7)), + ?line ?match('object_here', corba:locate(O8)), + ?line ?match('object_here', corba:locate(Obj2)), + + %% Terminate all servers with reason 'normal'. + catch corba:dispose(O1), + catch corba:dispose(O2), + catch corba:dispose(O3), + catch corba:dispose(O4), + catch corba:dispose(O5), + catch corba:dispose(O6), + catch corba:dispose(O7), + catch corba:dispose(O8), + catch corba:dispose(Obj2), + + + %% To make sure that orber_objectkeys-server is able to + %% clean up we wait. + timer:sleep(2000), + + %% all the servers are dead(?!). If one of these test-cases + %% fails the only error can be that we didn't sleep long enough, i.e., + %% try a longer timeout. If still fails something is wrong. + ?line ?match(true, corba_object:non_existent(O1)), + ?line ?match(true, corba_object:non_existent(O2)), + ?line ?match(true, corba_object:non_existent(O3)), + ?line ?match(true, corba_object:non_existent(O4)), + ?line ?match(true, corba_object:non_existent(O5)), + ?line ?match(true, corba_object:non_existent(O6)), + ?line ?match(true, corba_object:non_existent(O7)), + ?line ?match(true, corba_object:non_existent(O8)), + ?line ?match(true, corba_object:non_existent(Obj2)), + + %% Create a new persistent server. + Obj3=(catch orber_test_server:oe_create([], + [{persistent, true}, + {regname, {global,{obj2, 12345}}}])), + + %% OK?! + ?line ?match({_,key,_,_,_, _}, Obj3), + + %% Try to create a server with the same name (naturally it fails). + ?line ?match({'EXCEPTION',{'INTERNAL',[],_,'COMPLETED_NO'}}, + orber_test_server:oe_create([], + [{persistent, true}, + {regname, {global,{obj2, 12345}}}])), + %% Try to remove all 'dead' servers. No server should be removed. + orber_objectkeys:gc(0), + + %% Kill object brutal, i.e., not with reason 'normal' or 'shutdown'. + P3 = corba:get_pid(Obj3), + exit(P3, kill), + + {_,_,Key3,_,_, _} = Obj3, + + %% Give time to clean up. + timer:sleep(2000), + ?line ?match({'EXCEPTION',{'TRANSIENT',[],_,'COMPLETED_NO'}}, + gen_server:call(orber_objkeyserver, + {get_pid, Key3}, + infinity)), + + ?line ?match(false,corba_object:non_existent(Obj3)), + + %% Run gc wit a "huge" time-limit. Will not erase the dead object. + orber_objectkeys:gc(10000), + ?line ?match(false,corba_object:non_existent(Obj3)), + + %% Run gc with minimum time-limit. Will erase the dead object. + orber_objectkeys:gc(0), + ?line ?match(true,corba_object:non_existent(Obj3)), + + %% Create a new persistent server. + Obj4=(catch orber_test_server:oe_create([], + [{persistent, true}, + {regname, {global,{obj2, 12345}}}])), + + %% OK?! + ?match({_,key,_,_,_, _}, Obj4), + %% Kill object brutal, i.e., not with reason 'normal' or 'shutdown'. + P4 = corba:get_pid(Obj4), + exit(P4, kill), + + %% Give time to clean up. + timer:sleep(2000), +% ?line ?match({'EXCEPTION',{'COMM_FAILURE',[],0,'COMPLETED_NO'}}, + ?line ?match({error, _}, + corba:get_pid(Obj4)), + + ?line ?match(false,corba_object:non_existent(Obj4)), + + %% Restart the object. + Obj5=(catch orber_test_server:oe_create([], + [{persistent, true}, + {regname, {global,{obj2, 12345}}}])), + %% OK?! + ?line ?match({_,key,_,_,_, _}, Obj5), + + %% Run gc with minimum time-limit. + orber_objectkeys:gc(0), + ?line ?match(false,corba_object:non_existent(Obj5)), + corba:dispose(Obj5), + ok. + + +%%----------------------------------------------------------------- +%% API tests for callback functions +%%----------------------------------------------------------------- +-define(DO_EXIT_FLAG, 0). +-define(NO_EXIT_FLAG, 16#10). + +-define(DO_EXIT, {is, 0}). +-define(NO_EXIT, {is, 16#10}). + + + +callback_ok_api(doc) -> ["Successful callbak API tests", ""]; +callback_ok_api(suite) -> []; +callback_ok_api(_) -> + %% Init + ?line ?match({ok, {?DO_EXIT, state}}, corba:handle_init(?MODULE, {?DO_EXIT_FLAG, state})), + %% Terminate + ?line ?match(ok, corba:handle_terminate(?MODULE, "reason", {?DO_EXIT, state})), + %% Handle_call + ?line ?match({reply,ok,{?DO_EXIT,state}}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, state}, [], false, false)), + %% Handle_cast + ?line ?match({noreply, {?DO_EXIT,state}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, state}, [], false)), + %% Handle_call precond/postcond + ?line ?match({reply, ok, {?DO_EXIT, state}}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, state}, [], false, false, {?MODULE, precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_cast precond/postcond + ?line ?match({noreply, {?DO_EXIT, state}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, state}, [], false, {?MODULE, precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_info + ?line ?match({noreply, {?DO_EXIT, state}}, + corba:handle_info(?MODULE, "info", {?DO_EXIT, state})), + ok. + +callback_arity_api(doc) -> ["callbak arity API tests", ""]; +callback_arity_api(suite) -> []; +callback_arity_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', {undef,_}}, + corba:handle_call(?MODULE, foo, [to, many, arguments], + {?DO_EXIT, state}, [], false, false)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}}, _}, + corba:handle_call(?MODULE, foo, [to, many, arguments], + {?NO_EXIT, state}, [], false, false)), + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, arity}, [], false, false)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}}, _}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, arity}, [], false, false)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', {undef,_}}, + corba:handle_cast(?MODULE, foo_1w, [to, many, arguments], + {?DO_EXIT, state}, [], false)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_cast(?MODULE, foo_1w, [to, many, arguments], + {?NO_EXIT, state}, [], false)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, arity}, [], false)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, arity}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, arity}, [], false)), + %% Handle_info - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_info(?MODULE, "info", {?DO_EXIT, arity})), + + %% Handle_info - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, arity}}, + corba:handle_info(?MODULE, "info", {?NO_EXIT, arity})), + ok. + +callback_module_api(doc) -> ["Module callbak API tests", ""]; +callback_module_api(suite) -> []; +callback_module_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', {undef,_}}, + corba:handle_call(wrong_mod, foo, [], + {?DO_EXIT, state}, [], false, false)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}}, _}, + corba:handle_call(wrong_mod, foo, [], + {?NO_EXIT, state}, [], false, false)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', {undef,_}}, + corba:handle_cast(wrong_mod, foo_1w, [], + {?DO_EXIT, state}, [], false)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_cast(wrong_mod, foo_1w, [], + {?NO_EXIT, state}, [], false)), + %% Handle_info - stay-alive == false. + ?line ?match({'EXIT', _}, + corba:handle_info(wrong_mod, "info", {?DO_EXIT, state})), + + %% Handle_info - stay-alive == true. + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_info(wrong_mod, "info", {?NO_EXIT, state})), + ok. + +callback_function_api(doc) -> ["Function callbak API tests", ""]; +callback_function_api(suite) -> []; +callback_function_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', {undef,_}}, + corba:handle_call(?MODULE, bad_function, [], + {?DO_EXIT, state}, [], false, false)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}}, _}, + corba:handle_call(?MODULE, bad_function, [], + {?NO_EXIT, state}, [], false, false)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', {undef,_}}, + corba:handle_cast(?MODULE, bad_function, [], + {?DO_EXIT, state}, [], false)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_cast(?MODULE, bad_function, [], + {?NO_EXIT, state}, [], false)), + %% Handle_info - stay-alive == false. Note, we cannot use ?MODULE here. + ?line ?match({'EXIT', _}, + corba:handle_info(corba, "info", {?DO_EXIT, state})), + + %% Handle_info - stay-alive == true. Note, we cannot use ?MODULE here. + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_info(corba, "info", {?NO_EXIT, state})), + ok. + +callback_precond_api(doc) -> ["Precond callbak API tests", ""]; +callback_precond_api(suite) -> []; +callback_precond_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, state}, [], false, false, {wrong_mod, precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, state}, [], false, false, {?MODULE, bad_precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}},_}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, state}, [], false, false, {wrong_mod, precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}},_}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, state}, [], false, false, {?MODULE, bad_precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, state}, [], false, {wrong_mod, precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, state}, [], false, {?MODULE, bad_precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, state}, [], false, {wrong_mod, precond}, + {?MODULE, postcond}, ?MODULE)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, state}, [], false, {?MODULE, bad_precond}, + {?MODULE, postcond}, ?MODULE)), + ok. + + +callback_postcond_api(doc) -> ["Postcond callbak API tests", ""]; +callback_postcond_api(suite) -> []; +callback_postcond_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, state}, [], false, false, {?MODULE, precond}, + {wrong_mod, postcond}, ?MODULE)), + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, state}, [], false, false, {?MODULE, precond}, + {?MODULE, bad_postcond}, ?MODULE)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}},_}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, state}, [], false, false, {?MODULE, precond}, + {wrong_mod, postcond}, ?MODULE)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}},_}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, state}, [], false, false, {?MODULE, precond}, + {?MODULE, bad_postcond}, ?MODULE)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, state}, [], false, {?MODULE, precond}, + {wrong_mod, postcond}, ?MODULE)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, state}, [], false, {?MODULE, precond}, + {?MODULE, bad_postcond}, ?MODULE)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, state}, [], false, {?MODULE, precond}, + {wrong_mod, postcond}, ?MODULE)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, state}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, state}, [], false, {?MODULE, precond}, + {?MODULE, bad_postcond}, ?MODULE)), + ok. + + +callback_exit_api(doc) -> ["Callbak exit API tests", ""]; +callback_exit_api(suite) -> []; +callback_exit_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, exit}, [], false, false)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}}, _}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, exit}, [], false, false)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, exit}, [], false)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, exit}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, exit}, [], false)), + %% Handle_info - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_info(?MODULE, "info", {?DO_EXIT, exit})), + + %% Handle_info - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, exit}}, + corba:handle_info(?MODULE, "info", {?NO_EXIT, exit})), + ok. + + +callback_badarith_api(doc) -> ["callbak badarith API tests", ""]; +callback_badarith_api(suite) -> []; +callback_badarith_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, badarith}, [], false, false)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}},_}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, badarith}, [], false, false)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, badarith}, [], false)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, badarith}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, badarith}, [], false)), + %% Handle_info - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_info(?MODULE, "info", {?DO_EXIT, badarith})), + + %% Handle_info - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, badarith}}, + corba:handle_info(?MODULE, "info", {?NO_EXIT, badarith})), + ok. + +callback_case_clause_api(doc) -> ["callbak case_clause API tests", ""]; +callback_case_clause_api(suite) -> []; +callback_case_clause_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, case_clause}, [], false, false)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}}, _}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, case_clause}, [], false, false)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, case_clause}, [], false)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, case_clause}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, case_clause}, [], false)), + %% Handle_info - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_info(?MODULE, "info", {?DO_EXIT, case_clause})), + + %% Handle_info - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, case_clause}}, + corba:handle_info(?MODULE, "info", {?NO_EXIT, case_clause})), + ok. + +callback_function_clause_api(doc) -> ["callbak function_clause API tests", ""]; +callback_function_clause_api(suite) -> []; +callback_function_clause_api(_) -> + %% Handle_call - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_call(?MODULE, foo, [], + {?DO_EXIT, function_clause}, [], false, false)), + %% Handle_call - stay-alive == true + ?line ?match({reply, {'EXCEPTION', #'OBJ_ADAPTER'{}}, _}, + corba:handle_call(?MODULE, foo, [], + {?NO_EXIT, function_clause}, [], false, false)), + %% Handle_cast - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_cast(?MODULE, foo_1w, [], + {?DO_EXIT, function_clause}, [], false)), + %% Handle_cast - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, function_clause}}, + corba:handle_cast(?MODULE, foo_1w, [], + {?NO_EXIT, function_clause}, [], false)), + %% Handle_info - stay-alive == false + ?line ?match({'EXIT', _}, + corba:handle_info(?MODULE, "info", {?DO_EXIT, function_clause})), + %% Handle_info - stay-alive == true + ?line ?match({noreply, {?NO_EXIT, function_clause}}, + corba:handle_info(?MODULE, "info", {?NO_EXIT, function_clause})), + ok. + +%% Faked mandatory operations +init(State) -> + evaluate_state(State), + {ok, State}. +terminate(_Reason, State) -> + evaluate_state(State), + ok. + +code_change(_OldVsn, State, _Extra) -> + evaluate_state(State), + {ok, State}. +handle_call(_,_, State) -> + evaluate_state(State), + {noreply, State}. +handle_cast(_, State) -> + evaluate_state(State), + {noreply, State}. +handle_info(_Info, State) -> + evaluate_state(State), + {noreply, State}. + +foo(State) -> + evaluate_state(State), + {reply, ok, State}. +foo(State, _Arg) -> + evaluate_state(State), + {reply, ok, State}. + +foo_1w(State) -> + evaluate_state(State), + {noreply, State}. +foo_1w(State, _Arg) -> + evaluate_state(State), + {noreply, State}. + +precond(_Module, _Function, _Args) -> + ok. + +postcond(_Module, _Function, _Args, _Result) -> + ok. + +evaluate_state(exit) -> + exit("exit on purpose"); +evaluate_state(badarith) -> + 10 * atom; +evaluate_state(case_clause) -> + case 10 of + false -> + ok + end; +evaluate_state(module) -> + non_existing_module:bar(); +evaluate_state(function) -> + ?MODULE:non_existing_function(); +evaluate_state(arity) -> + ?MODULE:foo(to, many, arguments); +evaluate_state(function_clause) -> + evaluate_state(incorrect_state); +evaluate_state(state) -> + ok. + +%%----------------------------------------------------------------- +%% Local functions. +%%----------------------------------------------------------------- + +pseudo_calls(0, _) -> + ok; +pseudo_calls(Times, Obj) -> + orber_test_server:pseudo_call(Obj), + New = Times - 1, + pseudo_calls(New, Obj). +pseudo_casts(0, _) -> + ok; +pseudo_casts(Times, Obj) -> + orber_test_server:pseudo_cast(Obj), + New = Times - 1, + pseudo_casts(New, Obj). diff --git a/lib/orber/test/csiv2_SUITE.erl b/lib/orber/test/csiv2_SUITE.erl new file mode 100644 index 0000000000..8103fd81ac --- /dev/null +++ b/lib/orber/test/csiv2_SUITE.erl @@ -0,0 +1,940 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2005-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(csiv2_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("orber/src/ifr_objects.hrl"). +-include("idl_output/orber_test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContextExt.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContext.hrl"). +%%-include_lib("orber/src/OrberCSIv2.hrl"). + +-define(default_timeout, ?t:minutes(5)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(REQUEST_ID, 0). + +-define(REPLY_FRAG_1, <<71,73,79,80,1,2,2,1,0,0,0,41,0,0,0,?REQUEST_ID,0,0,0,0,0,0,0,1,78,69,79,0,0,0,0,2,0,10,0,0,0,0,0,0,0,0,0,18,0,0,0,0,0,0,0,4,49>>). +%% The fragments are identical for requests and replies. +-define(FRAG_2, <<71,73,79,80,1,2,2,7,0,0,0,5,0,0,0,?REQUEST_ID,50>>). +-define(FRAG_3, <<71,73,79,80,1,2,2,7,0,0,0,5,0,0,0,?REQUEST_ID,51>>). +-define(FRAG_4, <<71,73,79,80,1,2,0,7,0,0,0,5,0,0,0,?REQUEST_ID,0>>). + +%% Should X509 DER generated by, for example, OpenSSL +-define(X509DER, + <<42>>). + +%% Should X509 PEM generated by, for example, OpenSSL +-define(X509PEM, + <<42>>). + +%% IOR exported by VB (CSIv2 activated). +-define(VB_IOR, + #'IOP_IOR' + {type_id = "IDL:omg.org/CosNotifyComm/SequencePushConsumer:1.0", + profiles = + [#'IOP_TaggedProfile' + {tag = ?TAG_INTERNET_IOP, + profile_data = + #'IIOP_ProfileBody_1_1'{ + iiop_version = #'IIOP_Version'{major = 1, + minor = 2}, + host = "127.0.0.1", + port = 0, + object_key = [0,86,66,1,0,0,0,24,47,70,77,65,95,67,73,82,80,77,65,78,95,80,79,65,95,83,69,67,85,82,69,0,0,0,0,4,0,0,4,186,0,0,2,10,81,218,65,185], + components = + [#'IOP_TaggedComponent'{tag = ?TAG_SSL_SEC_TRANS, + component_data = #'SSLIOP_SSL'{ + target_supports = 102, + target_requires = 66, + port = 49934}}, + #'IOP_TaggedComponent'{tag = ?TAG_CSI_SEC_MECH_LIST, + component_data = + #'CSIIOP_CompoundSecMechList'{stateful = true, + mechanism_list = + [#'CSIIOP_CompoundSecMech' + {target_requires = 66, + transport_mech = #'IOP_TaggedComponent'{ + tag = ?TAG_TLS_SEC_TRANS, + component_data = + #'CSIIOP_TLS_SEC_TRANS'{ + target_supports = 102, + target_requires = 66, + addresses = + [#'CSIIOP_TransportAddress' + {host_name = "127.0.0.1", + port = 49934}]}}, + as_context_mech = + #'CSIIOP_AS_ContextSec'{ + target_supports = 0, + target_requires = 0, + client_authentication_mech = [], + target_name = []}, + sas_context_mech = + #'CSIIOP_SAS_ContextSec'{ + target_supports = 1024, + target_requires = 0, + privilege_authorities = + [#'CSIIOP_ServiceConfiguration' + {syntax = 1447174401, + name = "Borland"}], + supported_naming_mechanisms = [[6, + 6, + 103, + 129, + 2, + 1, + 1, + 1]], + supported_identity_types = 15}}]}}, + #'IOP_TaggedComponent' + {tag = ?TAG_CODE_SETS, + component_data = + #'CONV_FRAME_CodeSetComponentInfo'{'ForCharData' = + #'CONV_FRAME_CodeSetComponent'{ + native_code_set = 65537, + conversion_code_sets = [83951617]}, + 'ForWcharData' = + #'CONV_FRAME_CodeSetComponent'{ + native_code_set = 65801, + conversion_code_sets = []}}}, + #'IOP_TaggedComponent'{tag = ?TAG_ORB_TYPE, + component_data = 1447645952}, + #'IOP_TaggedComponent'{tag = 1447645955, + component_data = [0,5,7,1,127]}]}}]}). + +%% Common basic types +-define(OID, {2,23,130,1,1,1}). + +-define(OCTET_STR, [1,2,3,4]). + +-define(BIT_STR, [0,1,0,1,1]). + +-define(BOOLEAN, false). + +-define(ANY, [19,5,111,116,112,67,65]). + +-ifdef(false). +%% PKIX1Explicit88 +-define(AlgorithmIdentifier, + #'AlgorithmIdentifier'{algorithm = ?OID, + parameters = ?ANY}). + +-define(Validity, #'Validity'{notBefore = {utcTime, "19820102070533.8"}, + notAfter = {generalTime, "19820102070533.8"}}). + +-define(SubjectPublicKeyInfo, + #'SubjectPublicKeyInfo'{algorithm = ?AlgorithmIdentifier, + subjectPublicKey = ?BIT_STR}). + +-define(AttributeTypeAndValue, + #'AttributeTypeAndValue'{type = ?OID, + value = <<19,11,69,114,105,99,115,115,111,110,32,65,66>>}). + +-define(RelativeDistinguishedName, [?AttributeTypeAndValue]). + +-define(RDNSequence, [?RelativeDistinguishedName]). + +-define(Name, {rdnSequence, ?RDNSequence}). + +-define(Version, v3). + +-define(CertificateSerialNumber, 1). + +-define(UniqueIdentifier, ?BIT_STR). + +-define(Extension, #'Extension'{extnID = ?OID, + critical = ?BOOLEAN, + extnValue = ?OCTET_STR}). + +-define(Extensions, [?Extension]). + +-define(TBSCertificate, + #'TBSCertificate'{version = ?Version, + serialNumber = ?CertificateSerialNumber, + signature = ?AlgorithmIdentifier, + issuer = ?Name, + validity = ?Validity, + subject = ?Name, + subjectPublicKeyInfo = ?SubjectPublicKeyInfo, + issuerUniqueID = ?UniqueIdentifier, + subjectUniqueID = ?UniqueIdentifier, + extensions = ?Extensions}). + +-define(Certificate, #'Certificate'{tbsCertificate = ?TBSCertificate, + signatureAlgorithm = ?AlgorithmIdentifier, + signature = ?BIT_STR}). + +%% PKIX1Implicit88 + +-define(GeneralName, {registeredID, ?OID}). + +-define(GeneralNames, [?GeneralName]). + +%% PKIXAttributeCertificate +-define(AttCertValidityPeriod, + #'AttCertValidityPeriod'{notBeforeTime = "19820102070533.8", + notAfterTime = "19820102070533.8"}). + + +-define(Attribute, #'Attribute'{type = ?OID, + values = []}). + +-define(Attributes, [?Attribute]). + +-define(IssuerSerial, #'IssuerSerial'{issuer = ?GeneralNames, + serial = ?CertificateSerialNumber, + issuerUID = ?UniqueIdentifier}). + +-define(DigestedObjectType, publicKey). %% Enum + +-define(ObjectDigestInfo, + #'ObjectDigestInfo'{digestedObjectType = ?DigestedObjectType, + otherObjectTypeID = ?OID, + digestAlgorithm = ?AlgorithmIdentifier, + objectDigest = ?BIT_STR}). + +-define(V2Form, #'V2Form'{issuerName = ?GeneralNames, + baseCertificateID = ?IssuerSerial, + objectDigestInfo = ?ObjectDigestInfo}). + +-define(AttCertVersion, v2). + +-define(Holder, #'Holder'{baseCertificateID = ?IssuerSerial, + entityName = ?GeneralNames, + objectDigestInfo = ?ObjectDigestInfo}). + +-define(AttCertIssuer, {v2Form, ?V2Form}). + +-define(AttributeCertificateInfo, + #'AttributeCertificateInfo'{version = ?AttCertVersion, + holder = ?Holder, + issuer = ?AttCertIssuer, + signature = ?AlgorithmIdentifier, + serialNumber = ?CertificateSerialNumber, + attrCertValidityPeriod = ?AttCertValidityPeriod, + attributes = ?Attributes, + issuerUniqueID = ?UniqueIdentifier, + extensions = ?Extensions}). + +-define(AttributeCertificate, + #'AttributeCertificate'{acinfo = ?AttributeCertificateInfo, + signatureAlgorithm = ?AlgorithmIdentifier, + signatureValue = ?BIT_STR}). + + +%% OrberCSIv2 +-define(AttributeCertChain, + #'AttributeCertChain'{attributeCert = ?AttributeCertificate, + certificateChain = ?CertificateChain}). + +-define(CertificateChain, [?Certificate]). + +-define(VerifyingCertChain, [?Certificate]). + +-endif. + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2, +% code_CertificateChain_api/1, +% code_AttributeCertChain_api/1, +% code_VerifyingCertChain_api/1, +% code_AttributeCertificate_api/1, +% code_Certificate_api/1, +% code_TBSCertificate_api/1, +% code_CertificateSerialNumber_api/1, +% code_Version_api/1, +% code_AlgorithmIdentifier_api/1, +% code_Name_api/1, +% code_RDNSequence_api/1, +% code_RelativeDistinguishedName_api/1, +% code_AttributeTypeAndValue_api/1, +% code_Attribute_api/1, +% code_Validity_api/1, +% code_SubjectPublicKeyInfo_api/1, +% code_UniqueIdentifier_api/1, +% code_Extensions_api/1, +% code_Extension_api/1, +% code_AttributeCertificateInfo_api/1, +% code_AttCertVersion_api/1, +% code_Holder_api/1, +% code_AttCertIssuer_api/1, +% code_AttCertValidityPeriod_api/1, +% code_V2Form_api/1, +% code_IssuerSerial_api/1, +% code_ObjectDigestInfo_api/1, +% code_OpenSSL509_api/1, + ssl_server_peercert_api/1, + ssl_client_peercert_api/1]). + + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([fake_server_ORB/5]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for multi orber interfaces using CSIv2"]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +%% NOTE - the fragment test cases must bu first since we explicitly set a request +%% id. Otherwise, the request-id counter would be increased and we cannot know +%% what it is. +cases() -> + [ +% code_CertificateChain_api, +% code_AttributeCertChain_api, +% code_VerifyingCertChain_api, +% code_AttributeCertificate_api, +% code_Certificate_api, +% code_TBSCertificate_api, +% code_CertificateSerialNumber_api, +% code_Version_api, +% code_AlgorithmIdentifier_api, +% code_Name_api, +% code_RDNSequence_api, +% code_RelativeDistinguishedName_api, +% code_AttributeTypeAndValue_api, +% code_Attribute_api, +% code_Validity_api, +% code_SubjectPublicKeyInfo_api, +% code_UniqueIdentifier_api, +% code_Extensions_api, +% code_Extension_api, +% code_AttributeCertificateInfo_api, +% code_AttCertVersion_api, +% code_Holder_api, +% code_AttCertIssuer_api, +% code_AttCertValidityPeriod_api, +% code_V2Form_api, +% code_IssuerSerial_api, +% code_ObjectDigestInfo_api, +% code_OpenSSL509_api, + ssl_server_peercert_api, + ssl_client_peercert_api]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + Dog=test_server:timetrap(?default_timeout), + orber:jump_start(0), + oe_orber_test_server:oe_register(), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + oe_orber_test_server:oe_unregister(), + orber:jump_stop(), + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + Config. + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, no security +%%----------------------------------------------------------------- + + +%%----------------------------------------------------------------- +%% Encode and decode ASN.1 X509 +%%----------------------------------------------------------------- + +-ifdef(false). +%% OrberCSIv2 +code_CertificateChain_api(doc) -> ["Code CertificateChain"]; +code_CertificateChain_api(suite) -> []; +code_CertificateChain_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('CertificateChain', ?CertificateChain)), + ?match({ok, [#'Certificate'{}]}, + 'OrberCSIv2':decode('CertificateChain', list_to_binary(Enc))), + ok. + +code_AttributeCertChain_api(doc) -> ["Code AttributeCertChain"]; +code_AttributeCertChain_api(suite) -> []; +code_AttributeCertChain_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('AttributeCertChain', ?AttributeCertChain)), + ?match({ok, #'AttributeCertChain'{}}, + 'OrberCSIv2':decode('AttributeCertChain', list_to_binary(Enc))), + ok. + +code_VerifyingCertChain_api(doc) -> ["Code VerifyingCertChain"]; +code_VerifyingCertChain_api(suite) -> []; +code_VerifyingCertChain_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('VerifyingCertChain', ?VerifyingCertChain)), + ?match({ok, [#'Certificate'{}]}, + 'OrberCSIv2':decode('VerifyingCertChain', list_to_binary(Enc))), + ok. + +%% PKIXAttributeCertificate +code_AttributeCertificate_api(doc) -> ["Code AttributeCertificate"]; +code_AttributeCertificate_api(suite) -> []; +code_AttributeCertificate_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('AttributeCertificate', ?AttributeCertificate)), + ?match({ok, #'AttributeCertificate'{}}, + 'OrberCSIv2':decode('AttributeCertificate', list_to_binary(Enc))), + ok. + +code_AttributeCertificateInfo_api(doc) -> ["Code AttributeCertificateInfo"]; +code_AttributeCertificateInfo_api(suite) -> []; +code_AttributeCertificateInfo_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('AttributeCertificateInfo', ?AttributeCertificateInfo)), + ?match({ok, #'AttributeCertificateInfo'{}}, + 'OrberCSIv2':decode('AttributeCertificateInfo', list_to_binary(Enc))), + ok. + +code_AttCertVersion_api(doc) -> ["Code AttCertVersion"]; +code_AttCertVersion_api(suite) -> []; +code_AttCertVersion_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('AttCertVersion', ?AttCertVersion)), + ?match({ok, ?AttCertVersion}, + 'OrberCSIv2':decode('AttCertVersion', list_to_binary(Enc))), + ok. + +code_Holder_api(doc) -> ["Code Holder"]; +code_Holder_api(suite) -> []; +code_Holder_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('Holder', ?Holder)), + ?match({ok, #'Holder'{}}, + 'OrberCSIv2':decode('Holder', list_to_binary(Enc))), + ok. + +code_AttCertIssuer_api(doc) -> ["Code AttCertIssuer"]; +code_AttCertIssuer_api(suite) -> []; +code_AttCertIssuer_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('AttCertIssuer', ?AttCertIssuer)), + ?match({ok, {v2Form, _}}, + 'OrberCSIv2':decode('AttCertIssuer', list_to_binary(Enc))), + ok. + +code_AttCertValidityPeriod_api(doc) -> ["Code AttCertValidityPeriod"]; +code_AttCertValidityPeriod_api(suite) -> []; +code_AttCertValidityPeriod_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('AttCertValidityPeriod', ?AttCertValidityPeriod)), + ?match({ok, #'AttCertValidityPeriod'{}}, + 'OrberCSIv2':decode('AttCertValidityPeriod', list_to_binary(Enc))), + ok. + +code_V2Form_api(doc) -> ["Code V2Form"]; +code_V2Form_api(suite) -> []; +code_V2Form_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('V2Form', ?V2Form)), + ?match({ok, #'V2Form'{}}, + 'OrberCSIv2':decode('V2Form', list_to_binary(Enc))), + ok. + +code_IssuerSerial_api(doc) -> ["Code IssuerSerial"]; +code_IssuerSerial_api(suite) -> []; +code_IssuerSerial_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('IssuerSerial', ?IssuerSerial)), + ?match({ok, #'IssuerSerial'{}}, + 'OrberCSIv2':decode('IssuerSerial', list_to_binary(Enc))), + ok. + +code_ObjectDigestInfo_api(doc) -> ["Code ObjectDigestInfo"]; +code_ObjectDigestInfo_api(suite) -> []; +code_ObjectDigestInfo_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('ObjectDigestInfo', ?ObjectDigestInfo)), + ?match({ok, #'ObjectDigestInfo'{}}, + 'OrberCSIv2':decode('ObjectDigestInfo', list_to_binary(Enc))), + ok. + +%% PKIX1Explicit88 +code_Certificate_api(doc) -> ["Code Certificate"]; +code_Certificate_api(suite) -> []; +code_Certificate_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('Certificate', ?Certificate)), + ?match({ok, #'Certificate'{}}, + 'OrberCSIv2':decode('Certificate', list_to_binary(Enc))), + ok. + +code_TBSCertificate_api(doc) -> ["Code TBSCertificate"]; +code_TBSCertificate_api(suite) -> []; +code_TBSCertificate_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('TBSCertificate', ?TBSCertificate)), + ?match({ok, #'TBSCertificate'{}}, + 'OrberCSIv2':decode('TBSCertificate', list_to_binary(Enc))), + ok. + +code_CertificateSerialNumber_api(doc) -> ["Code CertificateSerialNumber"]; +code_CertificateSerialNumber_api(suite) -> []; +code_CertificateSerialNumber_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, + 'OrberCSIv2':encode('CertificateSerialNumber', ?CertificateSerialNumber)), + ?match({ok, ?CertificateSerialNumber}, + 'OrberCSIv2':decode('CertificateSerialNumber', list_to_binary(Enc))), + ok. + +code_Version_api(doc) -> ["Code Version"]; +code_Version_api(suite) -> []; +code_Version_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('Version', ?Version)), + ?match({ok, ?Version}, 'OrberCSIv2':decode('Version', list_to_binary(Enc))), + ok. + +code_AlgorithmIdentifier_api(doc) -> ["Code AlgorithmIdentifier"]; +code_AlgorithmIdentifier_api(suite) -> []; +code_AlgorithmIdentifier_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('AlgorithmIdentifier', ?AlgorithmIdentifier)), + ?match({ok, #'AlgorithmIdentifier'{}}, + 'OrberCSIv2':decode('AlgorithmIdentifier', list_to_binary(Enc))), + ok. + +code_Name_api(doc) -> ["Code Name"]; +code_Name_api(suite) -> []; +code_Name_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('Name', ?Name)), + ?match({ok, {rdnSequence,_}}, + 'OrberCSIv2':decode('Name', list_to_binary(Enc))), + ok. + +code_RDNSequence_api(doc) -> ["Code RDNSequence"]; +code_RDNSequence_api(suite) -> []; +code_RDNSequence_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('RDNSequence', ?RDNSequence)), + ?match({ok, [[#'AttributeTypeAndValue'{}]]}, + 'OrberCSIv2':decode('RDNSequence', list_to_binary(Enc))), + ok. + +code_RelativeDistinguishedName_api(doc) -> ["Code RelativeDistinguishedName"]; +code_RelativeDistinguishedName_api(suite) -> []; +code_RelativeDistinguishedName_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('RelativeDistinguishedName', ?RelativeDistinguishedName)), + ?match({ok, [#'AttributeTypeAndValue'{}]}, + 'OrberCSIv2':decode('RelativeDistinguishedName', list_to_binary(Enc))), + ok. + +code_AttributeTypeAndValue_api(doc) -> ["Code AttributeTypeAndValue"]; +code_AttributeTypeAndValue_api(suite) -> []; +code_AttributeTypeAndValue_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('AttributeTypeAndValue', ?AttributeTypeAndValue)), + ?match({ok, #'AttributeTypeAndValue'{}}, + 'OrberCSIv2':decode('AttributeTypeAndValue', list_to_binary(Enc))), + ok. + +code_Attribute_api(doc) -> ["Code Attribute"]; +code_Attribute_api(suite) -> []; +code_Attribute_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('Attribute', ?Attribute)), + ?match({ok, #'Attribute'{}}, + 'OrberCSIv2':decode('Attribute', list_to_binary(Enc))), + ok. + +code_Validity_api(doc) -> ["Code Validity"]; +code_Validity_api(suite) -> []; +code_Validity_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('Validity', ?Validity)), + ?match({ok, #'Validity'{}}, + 'OrberCSIv2':decode('Validity', list_to_binary(Enc))), + ok. + +code_SubjectPublicKeyInfo_api(doc) -> ["Code SubjectPublicKeyInfo"]; +code_SubjectPublicKeyInfo_api(suite) -> []; +code_SubjectPublicKeyInfo_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('SubjectPublicKeyInfo', ?SubjectPublicKeyInfo)), + ?match({ok, #'SubjectPublicKeyInfo'{}}, + 'OrberCSIv2':decode('SubjectPublicKeyInfo', list_to_binary(Enc))), + ok. + +code_UniqueIdentifier_api(doc) -> ["Code UniqueIdentifier"]; +code_UniqueIdentifier_api(suite) -> []; +code_UniqueIdentifier_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('UniqueIdentifier', ?UniqueIdentifier)), + ?match({ok, _}, 'OrberCSIv2':decode('UniqueIdentifier', list_to_binary(Enc))), + ok. + +code_Extensions_api(doc) -> ["Code Extensions"]; +code_Extensions_api(suite) -> []; +code_Extensions_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('Extensions', ?Extensions)), + ?match({ok, [#'Extension'{}]}, + 'OrberCSIv2':decode('Extensions', list_to_binary(Enc))), + ok. + +code_Extension_api(doc) -> ["Code Extension"]; +code_Extension_api(suite) -> []; +code_Extension_api(_Config) -> + {ok, Enc} = + ?match({ok, _}, 'OrberCSIv2':encode('Extension', ?Extension)), + ?match({ok, #'Extension'{}}, + 'OrberCSIv2':decode('Extension', list_to_binary(Enc))), + ok. + +%% OpenSSL generated x509 Certificate +code_OpenSSL509_api(doc) -> ["Code OpenSSL generated x509 Certificate"]; +code_OpenSSL509_api(suite) -> []; +code_OpenSSL509_api(_Config) -> + {ok, Cert} = + ?match({ok, #'Certificate'{}}, + 'OrberCSIv2':decode('Certificate', ?X509DER)), + AttrCertChain = #'AttributeCertChain'{attributeCert = ?AttributeCertificate, + certificateChain = [Cert]}, + {ok, EAttrCertChain} = + ?match({ok, _}, 'OrberCSIv2':encode('AttributeCertChain', AttrCertChain)), + ?match({ok, #'AttributeCertChain'{}}, + 'OrberCSIv2':decode('AttributeCertChain', list_to_binary(EAttrCertChain))), + ok. + +-endif. + +%%----------------------------------------------------------------- +%% Test ssl:peercert +%%----------------------------------------------------------------- +ssl_server_peercert_api(doc) -> ["Test ssl:peercert (server side)"]; +ssl_server_peercert_api(suite) -> []; +ssl_server_peercert_api(_Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + Options = orber_test_lib:get_options(iiop_ssl, server, + 2, [{iiop_ssl_port, 0}]), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node(Options)), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_ssl_port, []), + SSLOptions = orber_test_lib:get_options(ssl, client), + {ok, Socket} = + ?match({ok, _}, fake_client_ORB(ssl, ServerHost, ServerPort, SSLOptions)), + {ok, _PeerCert} = ?match({ok, _}, orber_socket:peercert(ssl, Socket)), + ?match({ok, {rdnSequence, _}}, orber_socket:peercert(ssl, Socket, [pkix, subject])), + ?match({ok, {rdnSequence, _}}, orber_socket:peercert(ssl, Socket, [ssl, subject])), +% ?match({ok, #'Certificate'{}}, +% 'OrberCSIv2':decode('Certificate', PeerCert)), + destroy_fake_ORB(ssl, Socket), + ok + end. + +ssl_client_peercert_api(doc) -> ["Test ssl:peercert (client side)"]; +ssl_client_peercert_api(suite) -> []; +ssl_client_peercert_api(_Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + Options = orber_test_lib:get_options(iiop_ssl, client, + 2, [{iiop_ssl_port, 0}]), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node(Options)), + crypto:start(), + ssl:start(), + ssl:seed("testing"), + SSLOptions = orber_test_lib:get_options(ssl, server), + {ok, LSock} = ?match({ok, _}, ssl:listen(0, SSLOptions)), + {ok, {_Address, LPort}} = ?match({ok, {_, _}}, ssl:sockname(LSock)), + IOR = ?match({'IOP_IOR',_,_}, + iop_ior:create_external({1, 2}, "IDL:FAKE:1.0", + "localhost", 6004, "FAKE", + [#'IOP_TaggedComponent' + {tag=?TAG_SSL_SEC_TRANS, + component_data=#'SSLIOP_SSL' + {target_supports = 2, + target_requires = 2, + port = LPort}}])), + spawn(orber_test_lib, remote_apply, + [ClientNode, corba_object, non_existent, [IOR]]), + {ok, Socket} = ?match({ok, _}, ssl:transport_accept(LSock)), + ?match(ok, ssl:ssl_accept(Socket)), + + {ok, _PeerCert} = ?match({ok, _}, orber_socket:peercert(ssl, Socket)), + ?match({ok, {rdnSequence, _}}, orber_socket:peercert(ssl, Socket, [pkix, subject])), + ?match({ok, {rdnSequence, _}}, orber_socket:peercert(ssl, Socket, [ssl, subject])), +% ?match({ok, #'Certificate'{}}, +% 'OrberCSIv2':decode('Certificate', PeerCert)), + ssl:close(Socket), + ssl:close(LSock), + ssl:stop(), + ok + end. + +%%----------------------------------------------------------------- +%% Local functions. +%%----------------------------------------------------------------- +-ifdef(false). +%% Not used yet. +context_test(Obj) -> + IDToken1 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTAbsent, + value = true}, + IDToken2 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTAnonymous, + value = false}, + IDToken3 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTPrincipalName, + value = [0,255]}, + IDToken4 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTX509CertChain, + value = [1,255]}, + IDToken5 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTDistinguishedName, + value = [2,255]}, + IDToken6 = #'CSI_IdentityToken'{label = ?ULONGMAX, + value = [3,255]}, + + MTEstablishContext1 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken1, + client_authentication_token = [1, 255]}}, + MTEstablishContext2 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken2, + client_authentication_token = [1, 255]}}, + MTEstablishContext3 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken3, + client_authentication_token = [1, 255]}}, + MTEstablishContext4 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken4, + client_authentication_token = [1, 255]}}, + MTEstablishContext5 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken5, + client_authentication_token = [1, 255]}}, + MTEstablishContext6 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken6, + client_authentication_token = [1, 255]}}, + MTCompleteEstablishContext = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTCompleteEstablishContext, + value = #'CSI_CompleteEstablishContext'{client_context_id = ?ULONGLONGMAX, + context_stateful = false, + final_context_token = [1, 255]}}, + MTContextError = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTContextError, + value = #'CSI_ContextError'{client_context_id = ?ULONGLONGMAX, + major_status = 1, + minor_status = 2, + error_token = [2,255]}}, + MTMessageInContext = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTMessageInContext, + value = #'CSI_MessageInContext'{client_context_id = ?ULONGLONGMAX, + discard_context = true}}, + Ctx = [#'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext1}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext2}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext3}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext4}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext5}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext6}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTCompleteEstablishContext}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTContextError}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTMessageInContext}], + ?line ?match(ok, orber_test_server:testing_iiop_context(Obj, [{context, Ctx}])). + + +fake_server_ORB(Type, Port, Options) -> + start_ssl(Type), + {ok, ListenSocket, NewPort} = + orber_socket:listen(Type, Port, + [{active, false}|Options]), + Socket = orber_socket:accept(Type, ListenSocket), + orber_socket:post_accept(Type, Socket), + {ok, Socket, NewPort}. + +-endif. + +fake_server_ORB(Type, Port, Options, Action, Data) -> + start_ssl(Type), + {ok, ListenSocket, _NewPort} = + orber_socket:listen(Type, Port, [{active, false}|Options]), + Socket = orber_socket:accept(Type, ListenSocket), + orber_socket:post_accept(Type, Socket), + do_server_action(Type, Socket, Action, Data), + orber_socket:close(Type, Socket), + ok. + +start_ssl(ssl) -> + crypto:start(), + ssl:start(), + ssl:seed("testing"); +start_ssl(_) -> + ok. + + +destroy_fake_ORB(ssl, Socket) -> + orber_socket:close(ssl, Socket), + ssl:stop(); +destroy_fake_ORB(Type, Socket) -> + orber_socket:close(Type, Socket). + +fake_client_ORB(Type, Host, Port, Options) -> + start_ssl(Type), + Socket = orber_socket:connect(Type, Host, Port, [{active, false}|Options]), + {ok, Socket}. + +-ifdef(false). +%% Not used yet. + +fake_client_ORB(Type, Host, Port, Options, Action, Data) -> + start_ssl(Type), + Socket = orber_socket:connect(Type, Host, Port, [{active, false}|Options]), + Result = do_client_action(Type, Socket, Action, Data), + orber_socket:close(Type, Socket), + Result. + +do_client_action(Type, Socket, fragments, FragList) -> + ok = send_data(Type, Socket, FragList), + {ok, Bytes} = gen_tcp:recv(Socket, 0), + {#reply_header{request_id = ?REQUEST_ID, reply_status = no_exception}, ok, [Par]} = + cdr_decode:dec_message({tk_void,[tk_any],[tk_any]}, Bytes), + Par; +do_client_action(Type, Socket, fragments_max, FragList) -> + ok = send_data(Type, Socket, FragList), + {ok, Bytes} = gen_tcp:recv(Socket, 0), + {#reply_header{request_id = ?REQUEST_ID, reply_status = system_exception}, Exc, []} = + cdr_decode:dec_message({tk_void,[tk_any],[tk_any]}, Bytes), + Exc; +do_client_action(Type, Socket, message_error, Data) -> + ok = send_data(Type, Socket, Data), + {ok,Bytes} = gen_tcp:recv(Socket, 0), + 'message_error' = cdr_decode:dec_message({tk_void,[tk_any],[tk_any]}, Bytes), + ok; +do_client_action(_Type, _Socket, _Action, _Data) -> + ok. + +-endif. + +do_server_action(Type, Socket, fragments, FragList) -> + {ok, _B} = gen_tcp:recv(Socket, 0), + ok = send_data(Type, Socket, FragList); +do_server_action(_Type, _Socket, _Action, _Data) -> + ok. + + +send_data(_Type, _Socket, []) -> + ok; +send_data(Type, Socket, [H|T]) -> + orber_socket:write(Type, Socket, H), + send_data(Type, Socket, T). + diff --git a/lib/orber/test/data_types_SUITE.erl b/lib/orber/test/data_types_SUITE.erl new file mode 100644 index 0000000000..1feb0b3b58 --- /dev/null +++ b/lib/orber/test/data_types_SUITE.erl @@ -0,0 +1,173 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2002-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : data_types_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(data_types_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing more or less complex data types"]; +all(suite) -> + [fixed_type, any_type]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: name component handling tests +%% Description: +%%----------------------------------------------------------------- +fixed_type(doc) -> ["Test the Fixed Point Datatype."]; +fixed_type(suite) -> []; +fixed_type(_) -> + Val1 = ?match({fixed,3,2,314}, orber_test_server:val1()), + _Val2 = ?match({fixed,3,2,314}, orber_test_server:val2()), + _Val3 = ?match({fixed,3,2,314}, orber_test_server:val3()), + Val4 = ?match({fixed,3,2,314}, orber_test_server:val4()), + Val5 = ?match({fixed,2,2,14}, orber_test_server:val5()), + _Val6 = ?match({fixed,1,0,3}, orber_test_server:val6()), + Val7 = ?match({fixed,2,2,-14}, orber_test_server:val7()), + _Val8 = ?match({fixed,1,0,-3}, orber_test_server:val8()), + Val9 = ?match({fixed,3,2,328}, orber_test_server:val9()), + Val10 = ?match({fixed,4,4,4396}, orber_test_server:val10()), + Val11 = ?match({fixed,31,29,2242857142857142857142857142857}, orber_test_server:val11()), + Val12 = ?match({fixed,9,6,123140001}, orber_test_server:val12()), + Val13 = ?match({fixed,9,1,123140001}, orber_test_server:val13()), + Val14 = ?match({fixed,14,6,-12313876959999}, orber_test_server:val14()), + Val15 = ?match({fixed,14,6,12314123240001}, orber_test_server:val15()), + Val16 = ?match({fixed,17,7,15163459846280001}, orber_test_server:val16()), + _Val17 = ?match({fixed,3,2,402}, orber_test_server:val17()), + _Val18 = ?match({fixed,5,4,40401}, orber_test_server:val18()), + _Val19 = ?match({fixed,3,0,200}, orber_test_server:val19()), + Val20 = ?match({fixed,31,0,1999999999999999999999999999999}, orber_test_server:val20()), + Val21 = ?match({fixed,1,0,0}, orber_test_server:val21()), + Val22 = ?match({fixed,31,0,9999999999999999999999999999998}, orber_test_server:val22()), + Val23 = ?match({fixed,1,0,1}, orber_test_server:val23()), + _Val24 = ?match({fixed,5,0,19998}, orber_test_server:val24()), + _Val25 = ?match({fixed,2,0,40}, orber_test_server:val25()), + Val26 = ?match({fixed,31,0,9999999999999999999999999999999}, orber_test_server:val26()), + + ?match(Val1, fixed:create(3,2,314)), + Val27 = ?match({fixed,6,2,314}, fixed:create(6,2,314)), + + ?match({tk_fixed,3,2}, fixed:get_typecode(Val1)), + ?match({tk_fixed,6,2}, fixed:get_typecode(Val27)), + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, fixed:create(3,2,3140)), + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, fixed:create(5,6,314)), + ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, fixed:create(32,2,314)), + ?match(Val10, fixed:multiply(Val4, Val5)), + ?match(Val16, fixed:multiply(Val12, Val13)), + ?match(Val22, fixed:multiply(Val26, Val26)), + + ?match(Val9, fixed:add(Val4, Val5)), + ?match(Val15, fixed:add(Val12, Val13)), + ?match(Val20, fixed:add(Val26, Val26)), + + ?match(Val11, fixed:divide(Val4, Val5)), + ?match(Val23, fixed:divide(Val26, Val26)), + + ?match(Val14, fixed:subtract(Val12, Val13)), + ?match(Val21, fixed:subtract(Val26, Val26)), + + ?match(Val7, fixed:unary_minus(Val5)), + ?match(Val5, fixed:unary_minus(Val7)), + + + + ok. + +%%----------------------------------------------------------------- +%% Test Case: any type +%% Description: +%%----------------------------------------------------------------- +any_type(doc) -> ["Test the Any Datatype."]; +any_type(suite) -> []; +any_type(_) -> + ?match(#any{typecode=undefined, value=undefined}, + any:create()), + ?match(#any{typecode=tk_short, value=undefined}, + any:set_typecode(any:create(), tk_short)), + ?match({'EXCEPTION', #'BAD_TYPECODE'{}}, + any:set_typecode(any:create(), "wrong")), + ?match({'EXCEPTION', #'BAD_TYPECODE'{}}, + any:create("wrong", 1)), + ?match(#any{typecode=tk_short, value = 1}, + any:create(tk_short, 1)), + ?match(tk_short, + any:get_typecode(any:create(tk_short, 1))), + ?match(1, + any:get_value(any:create(tk_short, 1))), + ?match(#any{typecode=tk_short, value=2}, + any:set_value(any:create(tk_short, 1), 2)), + + ok. diff --git a/lib/orber/test/generated_SUITE.erl b/lib/orber/test/generated_SUITE.erl new file mode 100644 index 0000000000..1cd1674fc4 --- /dev/null +++ b/lib/orber/test/generated_SUITE.erl @@ -0,0 +1,385 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : generated_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(generated_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + AcTuAlReS + end + end()). + + +-define(checktc(_Op), + fun(TC) -> + case orber_tc:check_tc(TC) of + false -> + io:format("###### ERROR ERROR ######~n~p - ~p~n", [Op, TC]), + ?line exit(TC); + true -> + true + end + end). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing IC generated files"]; +all(suite) -> + ['OrberApp_IFR', + erlang_binary, erlang_pid, erlang_port, erlang_ref, + 'CosNaming_Binding', 'CosNaming_BindingList', 'CosNaming_Name', + 'CosNaming_NameComponent', 'CosNaming_NamingContextExt_InvalidAddress', + 'CosNaming_NamingContext_AlreadyBound', 'CosNaming_NamingContext_CannotProceed', + 'CosNaming_NamingContext_InvalidName', 'CosNaming_NamingContext_NotEmpty', + 'CosNaming_NamingContext_NotFound', 'CosNaming_BindingIterator', + 'CosNaming_NamingContext', 'CosNaming_NamingContextExt']. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case:'OrberApp_IFR' +%% Description: +%%----------------------------------------------------------------- +'OrberApp_IFR'(doc) -> [""]; +'OrberApp_IFR'(suite) -> []; +'OrberApp_IFR'(_) -> + ?nomatch(undefined, 'OrberApp_IFR':oe_tc(get_absolute_name)), + ?nomatch(undefined, 'OrberApp_IFR':oe_tc(get_user_exception_type)), + ?match(undefined, 'OrberApp_IFR':oe_tc(undefined)), + ?match([_|_], 'OrberApp_IFR':oe_get_interface()), + ?match("IDL:OrberApp/IFR:1.0", 'OrberApp_IFR':typeID()), + check_tc('OrberApp_IFR':oe_get_interface()), + ?match(true, 'OrberApp_IFR':oe_is_a('OrberApp_IFR':typeID())), + ?match(false, 'OrberApp_IFR':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: erlang_binary +%% Description: +%%----------------------------------------------------------------- +erlang_binary(doc) -> [""]; +erlang_binary(suite) -> []; +erlang_binary(_) -> + ?match(true, orber_tc:check_tc(erlang_binary:tc())), + ?match("IDL:erlang/binary:1.0", erlang_binary:id()), + ?match("erlang_binary", erlang_binary:name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: erlang_pid +%% Description: +%%----------------------------------------------------------------- +erlang_pid(doc) -> [""]; +erlang_pid(suite) -> []; +erlang_pid(_) -> + ?match(true, orber_tc:check_tc(erlang_pid:tc())), + ?match("IDL:erlang/pid:1.0", erlang_pid:id()), + ?match("erlang_pid", erlang_pid:name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: erlang_port +%% Description: +%%----------------------------------------------------------------- +erlang_port(doc) -> [""]; +erlang_port(suite) -> []; +erlang_port(_) -> + ?match(true, orber_tc:check_tc(erlang_port:tc())), + ?match("IDL:erlang/port:1.0", erlang_port:id()), + ?match("erlang_port", erlang_port:name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: erlang_ref +%% Description: +%%----------------------------------------------------------------- +erlang_ref(doc) -> [""]; +erlang_ref(suite) -> []; +erlang_ref(_) -> + ?match(true, orber_tc:check_tc(erlang_ref:tc())), + ?match("IDL:erlang/ref:1.0", erlang_ref:id()), + ?match("erlang_ref", erlang_ref:name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_Binding' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_Binding'(doc) -> [""]; +'CosNaming_Binding'(suite) -> []; +'CosNaming_Binding'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_Binding':tc())), + ?match("IDL:omg.org/CosNaming/Binding:1.0", 'CosNaming_Binding':id()), + ?match("CosNaming_Binding", 'CosNaming_Binding':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_BindingList' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_BindingList'(doc) -> [""]; +'CosNaming_BindingList'(suite) -> []; +'CosNaming_BindingList'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_BindingList':tc())), + ?match("IDL:omg.org/CosNaming/BindingList:1.0", 'CosNaming_BindingList':id()), + ?match("CosNaming_BindingList", 'CosNaming_BindingList':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_Name' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_Name'(doc) -> [""]; +'CosNaming_Name'(suite) -> []; +'CosNaming_Name'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_Name':tc())), + ?match("IDL:omg.org/CosNaming/Name:1.0", 'CosNaming_Name':id()), + ?match("CosNaming_Name", 'CosNaming_Name':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NameComponent' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NameComponent'(doc) -> [""]; +'CosNaming_NameComponent'(suite) -> []; +'CosNaming_NameComponent'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_NameComponent':tc())), + ?match("IDL:omg.org/CosNaming/NameComponent:1.0", 'CosNaming_NameComponent':id()), + ?match("CosNaming_NameComponent", 'CosNaming_NameComponent':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NamingContextExt_InvalidAddress' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NamingContextExt_InvalidAddress'(doc) -> [""]; +'CosNaming_NamingContextExt_InvalidAddress'(suite) -> []; +'CosNaming_NamingContextExt_InvalidAddress'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_NamingContextExt_InvalidAddress':tc())), + ?match("IDL:omg.org/CosNaming/NamingContextExt/InvalidAddress:1.0", 'CosNaming_NamingContextExt_InvalidAddress':id()), + ?match("CosNaming_NamingContextExt_InvalidAddress", 'CosNaming_NamingContextExt_InvalidAddress':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NamingContext_AlreadyBound' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NamingContext_AlreadyBound'(doc) -> [""]; +'CosNaming_NamingContext_AlreadyBound'(suite) -> []; +'CosNaming_NamingContext_AlreadyBound'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_NamingContext_AlreadyBound':tc())), + ?match("IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0", 'CosNaming_NamingContext_AlreadyBound':id()), + ?match("CosNaming_NamingContext_AlreadyBound", 'CosNaming_NamingContext_AlreadyBound':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NamingContext_CannotProceed' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NamingContext_CannotProceed'(doc) -> [""]; +'CosNaming_NamingContext_CannotProceed'(suite) -> []; +'CosNaming_NamingContext_CannotProceed'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_NamingContext_CannotProceed':tc())), + ?match("IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0", 'CosNaming_NamingContext_CannotProceed':id()), + ?match("CosNaming_NamingContext_CannotProceed", 'CosNaming_NamingContext_CannotProceed':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NamingContext_InvalidName' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NamingContext_InvalidName'(doc) -> [""]; +'CosNaming_NamingContext_InvalidName'(suite) -> []; +'CosNaming_NamingContext_InvalidName'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_NamingContext_InvalidName':tc())), + ?match("IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0", 'CosNaming_NamingContext_InvalidName':id()), + ?match("CosNaming_NamingContext_InvalidName", 'CosNaming_NamingContext_InvalidName':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NamingContext_NotEmpty' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NamingContext_NotEmpty'(doc) -> [""]; +'CosNaming_NamingContext_NotEmpty'(suite) -> []; +'CosNaming_NamingContext_NotEmpty'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_NamingContext_NotEmpty':tc())), + ?match("IDL:omg.org/CosNaming/NamingContext/NotEmpty:1.0", 'CosNaming_NamingContext_NotEmpty':id()), + ?match("CosNaming_NamingContext_NotEmpty", 'CosNaming_NamingContext_NotEmpty':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NamingContext_NotFound' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NamingContext_NotFound'(doc) -> [""]; +'CosNaming_NamingContext_NotFound'(suite) -> []; +'CosNaming_NamingContext_NotFound'(_) -> + ?match(true, orber_tc:check_tc('CosNaming_NamingContext_NotFound':tc())), + ?match("IDL:omg.org/CosNaming/NamingContext/NotFound:1.0", 'CosNaming_NamingContext_NotFound':id()), + ?match("CosNaming_NamingContext_NotFound", 'CosNaming_NamingContext_NotFound':name()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_BindingIterator' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_BindingIterator'(doc) -> [""]; +'CosNaming_BindingIterator'(suite) -> []; +'CosNaming_BindingIterator'(_) -> + ?nomatch(undefined, 'CosNaming_BindingIterator':oe_tc(next_one)), + ?nomatch(undefined, 'CosNaming_BindingIterator':oe_tc(next_n)), + ?nomatch(undefined, 'CosNaming_BindingIterator':oe_tc(destroy)), + ?match(undefined, 'CosNaming_BindingIterator':oe_tc(undefined)), + ?match([_|_], 'CosNaming_BindingIterator':oe_get_interface()), + ?match("IDL:omg.org/CosNaming/BindingIterator:1.0", + 'CosNaming_BindingIterator':typeID()), + check_tc('CosNaming_BindingIterator':oe_get_interface()), + ?match(true, 'CosNaming_BindingIterator':oe_is_a('CosNaming_BindingIterator':typeID())), + ?match(false, 'CosNaming_BindingIterator':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NamingContext' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NamingContext'(doc) -> [""]; +'CosNaming_NamingContext'(suite) -> []; +'CosNaming_NamingContext'(_) -> + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(bind)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(rebind)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(bind_context)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(rebind_context)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(resolve)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(unbind)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(new_context)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(bind_new_context)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(destroy)), + ?nomatch(undefined, 'CosNaming_NamingContext':oe_tc(list)), + ?match(undefined, 'CosNaming_NamingContext':oe_tc(undefined)), + ?match([_|_], 'CosNaming_NamingContext':oe_get_interface()), + ?match("IDL:omg.org/CosNaming/NamingContext:1.0", + 'CosNaming_NamingContext':typeID()), + check_tc('CosNaming_NamingContext':oe_get_interface()), + ?match(true, 'CosNaming_NamingContext':oe_is_a('CosNaming_NamingContext':typeID())), + ?match(false, 'CosNaming_NamingContext':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: 'CosNaming_NamingContexExt' +%% Description: +%%----------------------------------------------------------------- +'CosNaming_NamingContextExt'(doc) -> [""]; +'CosNaming_NamingContextExt'(suite) -> []; +'CosNaming_NamingContextExt'(_) -> + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(to_string)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(to_name)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(to_url)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(resolve_str)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(bind)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(rebind)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(bind_context)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(rebind_context)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(new_context)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(bind_new_context)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(destroy)), + ?nomatch(undefined, 'CosNaming_NamingContextExt':oe_tc(list)), + ?match(undefined, 'CosNaming_NamingContextExt':oe_tc(undefined)), + ?match([_|_], 'CosNaming_NamingContextExt':oe_get_interface()), + ?match("IDL:omg.org/CosNaming/NamingContextExt:1.0", + 'CosNaming_NamingContextExt':typeID()), + check_tc('CosNaming_NamingContextExt':oe_get_interface()), + ?match(true, 'CosNaming_NamingContextExt':oe_is_a('CosNaming_NamingContextExt':typeID())), + ?match(true, 'CosNaming_NamingContextExt':oe_is_a('CosNaming_NamingContext':typeID())), + ?match(false, 'CosNaming_NamingContextExt':oe_is_a("wrong")), + ok. + + +%%----------------------------------------------------------------- +%% MISC functions +%%----------------------------------------------------------------- +check_tc([]) -> + ok; +check_tc([{Op, {RetType, InParameters, OutParameters}}|T]) -> + io:format("checked - ~s~n", [Op]), + lists:all(?checktc(Op), [RetType|InParameters]), + lists:all(?checktc(Op), OutParameters), + check_tc(T). + + diff --git a/lib/orber/test/idl_output/.gitignore b/lib/orber/test/idl_output/.gitignore new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/lib/orber/test/idl_output/.gitignore diff --git a/lib/orber/test/iiop_module_do_test_impl.erl b/lib/orber/test/iiop_module_do_test_impl.erl new file mode 100644 index 0000000000..bf171a3097 --- /dev/null +++ b/lib/orber/test/iiop_module_do_test_impl.erl @@ -0,0 +1,112 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1998-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(iiop_module_do_test_impl). + + +-export([run_all/3, run_userexception/2, run_systemexception/2]). +-export([createTestContext/0]). + +-export([start/0, stop/0]). +-export([init/1, terminate/2]). + + +init(_) -> + {ok, []}. + +terminate(Reason, _State) -> + io:format("~p terminating with reason ~p~n", [?MODULE, Reason]), + ok. + +createTestContext() -> + NS = corba:resolve_initial_references("NameService"), + NC = lname_component:set_id(lname_component:create(), "iiop_test"), + N = lname:insert_component(lname:create(), 1, NC), + 'CosNaming_NamingContext':bind_new_context(NS, N). + +start() -> + SFok = corba:create('iiop_module_do_test', "IDL:iiop_module/do_test:1.0"), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "iiop_test"), + NC2 = lname_component:set_id(lname_component:create(), "erl_dotest"), + N = lname:insert_component(lname:create(), 1, NC1), + N1 = lname:insert_component(N, 2, NC2), + 'CosNaming_NamingContext':bind(NS, N1, SFok), + SFok. + +stop() -> + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "iiop_test"), + NC2 = lname_component:set_id(lname_component:create(), "erl_dotest"), + N = lname:insert_component(lname:create(), 1, NC1), + N1 = lname:insert_component(N, 2, NC2), + 'CosNaming_NamingContext':unbind(NS, N1). + +run_all(S, X, TL) -> + ok = iiop_module_test:send_void(X), + {tk_short, P1} = lists:nth(1, TL), + {R1, IO1, O1} = iiop_module_test:send_short(X, P1, P1), + RL1= [{tk_short, R1}], + IOL1= [{tk_short, IO1}], + OL1= [{tk_short, O1}], + {tk_ushort, P2} = lists:nth(2, TL), + {R2, IO2, O2} = iiop_module_test:send_ushort(X, P2, P2), + RL2= [{tk_ushort, R2}|RL1], + IOL2= [{tk_ushort, IO2}|IOL1], + OL2= [{tk_ushort, O2}|OL1], + {tk_long, P3} = lists:nth(3, TL), + {R3, IO3, O3} = iiop_module_test:send_long(X, P3, P3), + RL3= [{tk_long, R3}|RL2], + IOL3= [{tk_long, IO3}|IOL2], + OL3= [{tk_long, O3}|OL2], + {tk_ulong, P4} = lists:nth(4, TL), + {R4, IO4, O4} = iiop_module_test:send_ulong(X, P4, P4), + RL4= [{tk_ulong, R4}|RL3], + IOL4= [{tk_ulong, IO4}|IOL3], + OL4= [{tk_ulong, O4}|OL3], + {tk_float, P5} = lists:nth(5, TL), + {R5, IO5, O5} = iiop_module_test:send_float(X, P5, P5), + RL5= [{tk_float, R5}|RL4], + IOL5= [{tk_float, IO5}|IOL4], + OL5= [{tk_float, O5}|OL4], + {tk_double, P6} = lists:nth(6, TL), + {R6, IO6, O6} = iiop_module_test:send_double(X, P6, P6), + RL6= [{tk_double, R6}|RL5], + IOL6= [{tk_double, IO6}|IOL5], + OL6= [{tk_double, O6}|OL5], + {tk_boolean, P7} = lists:nth(7, TL), + {R7, IO7, O7} = iiop_module_test:send_boolean(X, P7, P7), + RL7= [{tk_boolean, R7}|RL6], + IOL7= [{tk_boolean, IO7}|IOL6], + OL7= [{tk_boolean, O7}|OL6], + {tk_char, P8} = lists:nth(8, TL), + {R8, IO8, O8} = iiop_module_test:send_char(X, P8, P8), + RL= [{tk_char, R8} |RL7], + IOL= [{tk_char, IO8} |IOL7], + OL= [{tk_char, O8} |OL7], + {{lists:reverse(RL),lists:reverse(IOL),lists:reverse(OL)}, S}. + +run_systemexception(S, X) -> + iiop_module_test:ret_systemexception(X), + {ok, S}. + +run_userexception(S, X) -> + iiop_module_test:ret_userexception(X), + {ok, S}. diff --git a/lib/orber/test/iiop_module_test_impl.erl b/lib/orber/test/iiop_module_test_impl.erl new file mode 100644 index 0000000000..fe334e1b26 --- /dev/null +++ b/lib/orber/test/iiop_module_test_impl.erl @@ -0,0 +1,128 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1998-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(iiop_module_test_impl). +-include_lib("orber/include/corba.hrl"). +-include("idl_output/iiop_module.hrl"). + + +-export([send_void/1, send_short/3, send_ushort/3]). +-export([send_long/3, send_ulong/3, send_float/3]). +-export([send_double/3, send_boolean/3, send_char/3]). +-export([send_octet/3, send_any/3, send_object/3]). +-export([send_struct1/3, send_union1/3, send_enum1/3]). +-export([send_string/3, send_sequence1/3, send_array1/3]). +-export([ret_systemexception/1, ret_userexception/1]). + + + +-export([start/0, stop/0]). +-export([init/1, terminate/2]). + + +init(_) -> + {ok, []}. + +terminate(Reason, _State) -> + io:format("~p terminating with reason ~p~n", [?MODULE, Reason]), + ok. + + +start() -> + SFok = corba:create('iiop_module_test', "IDL:iiop_module/test:1.0"), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "iiop_test"), + NC2 = lname_component:set_id(lname_component:create(), "erl_test"), + N = lname:insert_component(lname:create(), 1, NC1), + N1 = lname:insert_component(N, 2, NC2), + 'CosNaming_NamingContext':bind(NS, N1, SFok), + SFok. + +stop() -> + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "iiop_test"), + NC2 = lname_component:set_id(lname_component:create(), "erl_test"), + N = lname:insert_component(lname:create(), 1, NC1), + N1 = lname:insert_component(N, 2, NC2), + 'CosNaming_NamingContext':unbind(NS, N1). + + + +send_void(S) -> + {ok, S}. + +send_short(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_ushort(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_long(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_ulong(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_float(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_double(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_boolean(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_char(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_octet(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_any(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_object(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_struct1(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_union1(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_enum1(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_string(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_sequence1(S, P1, P2) -> + {{P1, P1, P2}, S}. + +send_array1(S, P1, P2) -> + {{P1, P1, P2}, S}. + +ret_systemexception(S) -> + throw(#'BAD_PARAM'{}), + {ok, S}. + +ret_userexception(S) -> + throw(#iiop_module_Except1{why="not readable",rest_of_name=["foo", "bar"]}), + {ok, S}. diff --git a/lib/orber/test/iiop_test.idl b/lib/orber/test/iiop_test.idl new file mode 100644 index 0000000000..339678106e --- /dev/null +++ b/lib/orber/test/iiop_test.idl @@ -0,0 +1,111 @@ +// +// %CopyrightBegin% +// +// Copyright Ericsson AB 1997-2010. All Rights Reserved. +// +// The contents of this file are subject to the Erlang Public License, +// Version 1.1, (the "License"); you may not use this file except in +// compliance with the License. You should have received a copy of the +// Erlang Public License along with this software. If not, it can be +// retrieved online at http://www.erlang.org/. +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +// the License for the specific language governing rights and limitations +// under the License. +// +// %CopyrightEnd% +// +#include "cos_naming.idl" + +module iiop_module +{ + + typedef long Array1[10]; + + enum Enum1 {horse, pig, cow}; + + typedef sequence<long> Sequence1; + + typedef Sequence1 Sequence2; + + struct Struct1 { + string s; + unsigned short us; + unsigned long ul; + }; + + union Union1 switch (short) { + case 0: short First; + case 1: string Second; + case 2: char Third; + }; + + exception Except1 { + string why; + sequence <string> rest_of_name; + }; + + typedef sequence<any> test_values; + struct test_retval { + test_values R; + test_values InOut; + test_values Out; + }; + + interface test; + + interface do_test { + void run_systemexception(in test x) + raises(CosNaming::NamingContext::NotFound, + CosNaming::NamingContext::CannotProceed, + CosNaming::NamingContext::InvalidName); + void run_userexception(in test x) + raises(iiop_module::Except1, + CosNaming::NamingContext::NotFound, + CosNaming::NamingContext::CannotProceed, + CosNaming::NamingContext::InvalidName); + test_retval run_all(in test x, in test_values tlist) + raises(iiop_module::Except1, + CosNaming::NamingContext::NotFound, + CosNaming::NamingContext::CannotProceed, + CosNaming::NamingContext::InvalidName); + }; + + interface test { + // Function to run all tests from java to erlang + // and return the answers + // Primitive types + void send_void(); + short send_short(in short p1, inout short p2, out short p3); + unsigned short send_ushort(in unsigned short p1, inout unsigned short p2, + out unsigned short p3); + long send_long(in long p1, inout long p2, out long p3); + unsigned long send_ulong(in unsigned long p1, inout unsigned long p2, + out unsigned long p3); + float send_float(in float p1, inout float p2, out float p3); + double send_double(in double p1, inout double p2, out double p3); + boolean send_boolean(in boolean p1, inout boolean p2, out boolean p3); + char send_char(in char p1, inout char p2, out char p3); + octet send_octet(in octet p1, inout octet p2, out octet p3); + any send_any(in any p1, inout any p2, out any p3); + Object send_object(in Object p1, inout Object p2, out Object p3); + // TypeCode send_typecode(in TypeCode p1, inout TypeCode p2, out TypeCode p3); + // Principal send_principal(in Principal p); //tested in every request + + // Complex types + Struct1 send_struct1(in Struct1 p1, inout Struct1 p2, out Struct1 p3); + Union1 send_union1(in Union1 p1, inout Union1 p2, out Union1 p3); + Enum1 send_enum1(in Enum1 p1, inout Enum1 p2, out Enum1 p3); + string send_string(in string p1, inout string p2, out string p3); + Sequence1 send_sequence1(in Sequence1 p1, inout Sequence1 p2, + out Sequence1 p3); + Array1 send_array1(in Array1 p1, inout Array1 p2, out Array1 p3); + + void ret_systemexception(); + void ret_userexception() raises(iiop_module::Except1); + + + }; + +}; diff --git a/lib/orber/test/iiop_test_impl.erl b/lib/orber/test/iiop_test_impl.erl new file mode 100644 index 0000000000..fd92109c09 --- /dev/null +++ b/lib/orber/test/iiop_test_impl.erl @@ -0,0 +1,34 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1998-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(iiop_test_impl). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/test/iiop_test.hrl"). +-export([]). + + +init(Env) -> + {ok, []}. + +terminate(From, Reason) -> + ok. + +send_void(State) -> + {ok, State}. + diff --git a/lib/orber/test/interceptors_SUITE.erl b/lib/orber/test/interceptors_SUITE.erl new file mode 100644 index 0000000000..27e23a9433 --- /dev/null +++ b/lib/orber/test/interceptors_SUITE.erl @@ -0,0 +1,338 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : interceptors_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(interceptors_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS + end + end()). + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([in_reply/6, out_request/6]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing Orber Interceptors"]; +all(suite) -> + [local_pseudo, local_default, local_local, local_global]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + corba:orb_init([{flags, (?ORB_ENV_USE_PI bor ?ORB_ENV_LOCAL_TYPECHECKING)}, + {local_interceptors, {native, [?MODULE]}}]), + orber:jump_start(2945), + oe_orber_test_server:oe_register(), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + oe_orber_test_server:oe_unregister(), + orber:jump_stop(), + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: local_pseudo +%% Description: +%%----------------------------------------------------------------- +local_pseudo(doc) -> [""]; +local_pseudo(suite) -> []; +local_pseudo(_) -> + ?match({native, [?MODULE]}, orber:get_local_interceptors()), + %% Global settings + Obj1 = orber_test_server:oe_create(state,[{pseudo,true}]), + Result11 = orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX), + ?match([?USHORTMAX], put(out_request, undefined)), + ?match(Result11, put(in_reply, undefined)), + + Result12 = ?match({'EXCEPTION',_}, + orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX+1)), + ?match([(?USHORTMAX+1)], put(out_request, undefined)), + ?nomatch(Result12, put(in_reply, undefined)), + + Result13 = orber_test_server:testing_iiop_oneway_delay(Obj1, 0), + ?match([0], put(out_request, undefined)), + ?nomatch(Result13, put(in_reply, undefined)), + + Result14 = ?match({'EXCEPTION', _}, + orber_test_server:raise_local_exception(Obj1)), + ?match([], put(out_request, undefined)), + ?match(Result14, put(in_reply, undefined)), + + Result15 = ?match({'EXCEPTION',_}, orber_test_server:stop_brutal(Obj1)), + ?match([], put(out_request, undefined)), + ?match(Result15, put(in_reply, undefined)), + + %% Per-object + Obj2 = orber_test_server:oe_create(state,[{pseudo,true}, + {local_interceptors, false}]), + + Result21 = orber_test_server:testing_iiop_ushort(Obj2, ?USHORTMAX), + ?nomatch([?USHORTMAX], put(out_request, undefined)), + ?nomatch(Result21, put(in_reply, undefined)), + + Obj3 = orber_test_server:oe_create(state,[{pseudo,true}, + {local_interceptors, true}]), + + Result31 = orber_test_server:testing_iiop_ushort(Obj3, ?USHORTMAX), + ?match([?USHORTMAX], put(out_request, undefined)), + ?match(Result31, put(in_reply, undefined)), + + ok. + +%%----------------------------------------------------------------- +%% Test Case: local_default +%% Description: +%%----------------------------------------------------------------- +local_default(doc) -> [""]; +local_default(suite) -> []; +local_default(_) -> + ?match({native, [?MODULE]}, orber:get_local_interceptors()), + %% Global settings + Obj1 = orber_test_server:oe_create(state, []), + Result11 = orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX), + ?match([?USHORTMAX], put(out_request, undefined)), + ?match(Result11, put(in_reply, undefined)), + + Result12 = ?match({'EXCEPTION',_}, + orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX+1)), + ?match([(?USHORTMAX+1)], put(out_request, undefined)), + ?nomatch(Result12, put(in_reply, undefined)), + + Result13 = orber_test_server:testing_iiop_oneway_delay(Obj1, 0), + ?match([0], put(out_request, undefined)), + ?nomatch(Result13, put(in_reply, undefined)), + + Result14 = ?match({'EXCEPTION', _}, + orber_test_server:raise_local_exception(Obj1)), + ?match([], put(out_request, undefined)), + ?match(Result14, put(in_reply, undefined)), + + Result15 = ?match({'EXCEPTION',_}, orber_test_server:stop_brutal(Obj1)), + ?match([], put(out_request, undefined)), + ?match(Result15, put(in_reply, undefined)), + + + %% Per-object + Obj2 = orber_test_server:oe_create(state,[{local_interceptors, false}]), + + Result21 = orber_test_server:testing_iiop_ushort(Obj2, ?USHORTMAX), + ?nomatch([?USHORTMAX], put(out_request, undefined)), + ?nomatch(Result21, put(in_reply, undefined)), + corba:dispose(Obj2), + + Obj3 = orber_test_server:oe_create(state,[{local_interceptors, true}]), + + Result31 = orber_test_server:testing_iiop_ushort(Obj3, ?USHORTMAX), + ?match([?USHORTMAX], put(out_request, undefined)), + ?match(Result31, put(in_reply, undefined)), + corba:dispose(Obj3), + ok. + +%%----------------------------------------------------------------- +%% Test Case: local_local +%% Description: +%%----------------------------------------------------------------- +local_local(doc) -> [""]; +local_local(suite) -> []; +local_local(_) -> + ?match({native, [?MODULE]}, orber:get_local_interceptors()), + %% Global settings + Obj1 = orber_test_server:oe_create(state, [{regname, {local, regname}}]), + Result11 = orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX), + ?match([?USHORTMAX], put(out_request, undefined)), + ?match(Result11, put(in_reply, undefined)), + + Result12 = ?match({'EXCEPTION',_}, + orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX+1)), + ?match([(?USHORTMAX+1)], put(out_request, undefined)), + ?nomatch(Result12, put(in_reply, undefined)), + + Result13 = orber_test_server:testing_iiop_oneway_delay(Obj1, 0), + ?match([0], put(out_request, undefined)), + ?nomatch(Result13, put(in_reply, undefined)), + + Result14 = ?match({'EXCEPTION', _}, + orber_test_server:raise_local_exception(Obj1)), + ?match([], put(out_request, undefined)), + ?match(Result14, put(in_reply, undefined)), + + Result15 = ?match({'EXCEPTION',_}, orber_test_server:stop_brutal(Obj1)), + ?match([], put(out_request, undefined)), + ?match(Result15, put(in_reply, undefined)), + + %% Per-object + Obj2 = orber_test_server:oe_create(state,[{regname, {local, regname}}, + {local_interceptors, false}]), + + Result21 = orber_test_server:testing_iiop_ushort(Obj2, ?USHORTMAX), + ?nomatch([?USHORTMAX], put(out_request, undefined)), + ?nomatch(Result21, put(in_reply, undefined)), + corba:dispose(Obj2), + + Obj3 = orber_test_server:oe_create(state,[{regname, {local, regname}}, + {local_interceptors, true}]), + + Result31 = orber_test_server:testing_iiop_ushort(Obj3, ?USHORTMAX), + ?match([?USHORTMAX], put(out_request, undefined)), + ?match(Result31, put(in_reply, undefined)), + corba:dispose(Obj3), + ok. + +%%----------------------------------------------------------------- +%% Test Case: local_global +%% Description: +%%----------------------------------------------------------------- +local_global(doc) -> [""]; +local_global(suite) -> []; +local_global(_) -> + ?match({native, [?MODULE]}, orber:get_local_interceptors()), + %% Global settings + Obj1 = orber_test_server:oe_create(state, [{regname, {global, regname}}]), + Result11 = orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX), + ?match([?USHORTMAX], put(out_request, undefined)), + ?match(Result11, put(in_reply, undefined)), + + Result12 = ?match({'EXCEPTION',_}, + orber_test_server:testing_iiop_ushort(Obj1, ?USHORTMAX+1)), + ?match([(?USHORTMAX+1)], put(out_request, undefined)), + ?nomatch(Result12, put(in_reply, undefined)), + + Result13 = orber_test_server:testing_iiop_oneway_delay(Obj1, 0), + ?match([0], put(out_request, undefined)), + ?nomatch(Result13, put(in_reply, undefined)), + + Result14 = ?match({'EXCEPTION', _}, + orber_test_server:raise_local_exception(Obj1)), + ?match([], put(out_request, undefined)), + ?match(Result14, put(in_reply, undefined)), + + Result15 = ?match({'EXCEPTION',_}, orber_test_server:stop_brutal(Obj1)), + ?match([], put(out_request, undefined)), + ?match(Result15, put(in_reply, undefined)), + + %% Per-object + Obj2 = orber_test_server:oe_create(state,[{regname, {global, regname}}, + {local_interceptors, false}]), + + Result21 = orber_test_server:testing_iiop_ushort(Obj2, ?USHORTMAX), + ?nomatch([?USHORTMAX], put(out_request, undefined)), + ?nomatch(Result21, put(in_reply, undefined)), + corba:dispose(Obj2), + + Obj3 = orber_test_server:oe_create(state,[{regname, {global, regname}}, + {local_interceptors, true}]), + + Result31 = orber_test_server:testing_iiop_ushort(Obj3, ?USHORTMAX), + ?match([?USHORTMAX], put(out_request, undefined)), + ?match(Result31, put(in_reply, undefined)), + corba:dispose(Obj3), + ok. + + + + +%%----------------------------------------------------------------- +%% Local functions +%%----------------------------------------------------------------- +%%----------------------------------------------------------------- +%% function : in_reply +%%----------------------------------------------------------------- +in_reply(Ref, _ObjKey, Ctx, Op, Reply, _Args) -> + error_logger:info_msg("=============== in_reply ================= +Connection: ~p +Operation : ~p +Reply : ~p +Context : ~p +==========================================~n", + [Ref, Op, Reply, Ctx]), + put(in_reply, Reply), + {Reply, "NewArgs"}. + +%%----------------------------------------------------------------- +%% function : out_request +%%----------------------------------------------------------------- +out_request(Ref, _ObjKey, Ctx, Op, Params, _Args) -> + error_logger:info_msg("=============== out_request ============== +Connection: ~p +Operation : ~p +Parameters: ~p +Context : ~p +==========================================~n", + [Ref, Op, Params, Ctx]), + put(out_request, Params), + {Params, "NewArgs"}. diff --git a/lib/orber/test/iop_ior_10_SUITE.erl b/lib/orber/test/iop_ior_10_SUITE.erl new file mode 100644 index 0000000000..1000c7f113 --- /dev/null +++ b/lib/orber/test/iop_ior_10_SUITE.erl @@ -0,0 +1,167 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the IOR functions +%% +%%----------------------------------------------------------------- +-module(iop_ior_10_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> + [encoding, create_and_get_ops]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: IOR encoding test +%% Description: Just testing the string_encoding function because the +%% other encodings is called from them. +%%----------------------------------------------------------------- +encoding(doc) -> ["Description", "more description"]; +encoding(suite) -> []; +encoding(_) -> + V = #'IIOP_Version'{major=1,minor=0}, + M0 = 'Module_Interface', + T0 = "IDL:Module/Interface:1.0", + H0 = "my.hostname.org", + P0 = 4040, + N0 = 'name', + ?line O0 = corba_fake_mk_objkey(M0, registered, N0), + PB0 = #'IIOP_ProfileBody_1_0'{iiop_version=V, host=H0, port=P0, object_key=O0}, + TP0 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB0}, + S0 = #'IOP_IOR'{type_id=T0, profiles=[TP0]}, + N1 = list_to_pid("<0.100.0>"), + ?line O1 = corba_fake_mk_objkey(M0, key, N1), + PB1 = #'IIOP_ProfileBody_1_0'{iiop_version=V, host=H0, port=P0, object_key=O1}, + TP1 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB1}, + S1 = #'IOP_IOR'{type_id=T0, profiles=[TP1]}, + O2 = "This is an external objectkey", + PB2 = #'IIOP_ProfileBody_1_0'{iiop_version=V, host=H0, port=P0, object_key=O2}, + TP2 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB2}, + S2 = #'IOP_IOR'{type_id=T0, profiles=[TP2]}, + ?line C0 = iop_ior:string_code(S0), + ?line {S0, <<>>, _} = iop_ior:string_decode(C0), + ?line C1 = iop_ior:string_code(S1), + ?line {S1, <<>>, _} = iop_ior:string_decode(C1), + ?line C2 = iop_ior:string_code(S2), + ?line {S2, <<>>, _} = iop_ior:string_decode(C2), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: IOR creation test +%% Description: +%%----------------------------------------------------------------- +create_and_get_ops(doc) -> ["Description", "more description"]; +create_and_get_ops(suite) -> []; +create_and_get_ops(_) -> + V = #'IIOP_Version'{major=1,minor=0}, + M0 = 'Module_Interface', + T0 = "IDL:Module/Interface:1.0", + H0 = "my.hostname.org", + P0 = 4040, + N0 = 'name', + ?line O0 = corba_fake_mk_objkey(M0, registered, N0), + PB0 = #'IIOP_ProfileBody_1_0'{iiop_version=V, host=H0, port=P0, object_key=O0}, + TP0 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB0}, + S0 = #'IOP_IOR'{type_id=T0, profiles=[TP0]}, + ?line S0 = iop_ior:create({1, 0}, T0, [H0], P0, -1, O0, [], 0, 0), + N1 = list_to_pid("<0.100.0>"), + ?line O1 = corba_fake_mk_objkey(M0, key, N1), + {_,_,K1,_,_,_} = O1, + PB1 = #'IIOP_ProfileBody_1_0'{iiop_version=V, host=H0, port=P0, object_key=O1}, + TP1 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB1}, + S1 = #'IOP_IOR'{type_id=T0, profiles=[TP1]}, + ?line S1 = iop_ior:create({1, 0}, T0, [H0], P0, -1, O1, [], 0, 0), + O2 = "This is an external objectkey", + PB2 = #'IIOP_ProfileBody_1_0'{iiop_version=V, host=H0, port=P0, object_key=O2}, + TP2 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB2}, + S2 = #'IOP_IOR'{type_id=T0, profiles=[TP2]}, + ?line {'internal_registered', N0, _, _, M0} = iop_ior:get_key(S0), + ?line {'internal', K1, _, _, M0} = iop_ior:get_key(S1), + ?line {'external', {H0, P0, O2, _,_, + #host_data{protocol = normal, + ssl_data = undefined, + version = {1,0}, + csiv2_mech = undefined, + csiv2_statefull = false, + charset = 65537, + wcharset = 65801, + ft_heartbeat = false, + ft_primary = false, + ft_group = undefined, + csiv2_addresses = []}}} + = iop_ior:get_key(S2), + ?line T0 = iop_ior:get_typeID(S0), + ?line O0 = iop_ior:get_objkey(S0), + ?line O1 = iop_ior:get_objkey(S1), + ?line O2 = iop_ior:get_objkey(S2), + ok. + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- +corba_fake_mk_objkey(Id, 'key', Pid) when is_pid(Pid) -> + Key = make_objkey(), + {Id, 'key', Key, term_to_binary(undefined), 0, 0}; +corba_fake_mk_objkey(Id, 'key', RegName) when is_atom(RegName) -> + Key = term_to_binary(RegName), + {Id, 'key', Key, term_to_binary(undefined), 0, 0}; +corba_fake_mk_objkey(Id, 'registered', RegName) when is_atom(RegName) -> + {Id, 'registered', RegName, term_to_binary(undefined), 0, 0}. + + +make_objkey() -> + term_to_binary({now(), node()}). diff --git a/lib/orber/test/iop_ior_11_SUITE.erl b/lib/orber/test/iop_ior_11_SUITE.erl new file mode 100644 index 0000000000..35d01789ee --- /dev/null +++ b/lib/orber/test/iop_ior_11_SUITE.erl @@ -0,0 +1,186 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the IOR functions +%% +%%----------------------------------------------------------------- +-module(iop_ior_11_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> + [encoding, create_and_get_ops]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: IOR encoding test +%% Description: Just testing the string_encoding function because the +%% other encodings is called from them. +%%----------------------------------------------------------------- +encoding(doc) -> ["Description", "more description"]; +encoding(suite) -> []; +encoding(_) -> + V = #'IIOP_Version'{major=1,minor=1}, + M0 = 'Module_Interface', + T0 = "IDL:Module/Interface:1.0", + H0 = "my.hostname.org", + P0 = 4040, + N0 = 'name', + Components = case orber:iiop_ssl_port() of + -1 -> + []; + SSLPort -> + [#'IOP_TaggedComponent'{tag=?TAG_SSL_SEC_TRANS, + component_data=[0 | + cdrlib:enc_unsigned_short(2, + cdrlib:enc_unsigned_short(2, + cdrlib:enc_unsigned_short(SSLPort, [])))]}] + end, + ?line O0 = corba_fake_mk_objkey(M0, registered, N0), + PB0 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O0, + components=Components}, + TP0 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB0}, + S0 = #'IOP_IOR'{type_id=T0, profiles=[TP0]}, + N1 = list_to_pid("<0.100.0>"), + ?line O1 = corba_fake_mk_objkey(M0, key, N1), + PB1 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O1, + components=[]}, + TP1 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB1}, + S1 = #'IOP_IOR'{type_id=T0, profiles=[TP1]}, + O2 = "This is an external objectkey", + PB2 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O2, + components=[]}, + TP2 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB2}, + S2 = #'IOP_IOR'{type_id=T0, profiles=[TP2]}, + ?line C0 = iop_ior:string_code(S0), + ?line {S0, <<>>, _} = iop_ior:string_decode(C0), + ?line C1 = iop_ior:string_code(S1), + ?line {S1, <<>>, _} = iop_ior:string_decode(C1), + ?line C2 = iop_ior:string_code(S2), + ?line {S2, <<>>, _} = iop_ior:string_decode(C2), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: IOR creation test +%% Description: +%%----------------------------------------------------------------- +create_and_get_ops(doc) -> ["Description", "more description"]; +create_and_get_ops(suite) -> []; +create_and_get_ops(_) -> + V = #'IIOP_Version'{major=1,minor=1}, + CSC = #'IOP_TaggedComponent'{tag=?TAG_CODE_SETS, + component_data=?DEFAULT_CODESETS}, + M0 = 'Module_Interface', + T0 = "IDL:Module/Interface:1.0", + H0 = "my.hostname.org", + P0 = 4040, + N0 = 'name', + ?line O0 = corba_fake_mk_objkey(M0, registered, N0), + PB0 = #'IIOP_ProfileBody_1_1' + {iiop_version=V, host=H0, port=P0, object_key=O0, + components=[CSC]}, + TP0 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB0}, + S0 = #'IOP_IOR'{type_id=T0, profiles=[TP0]}, + ?line S0 = iop_ior:create({1, 1}, T0, [H0], P0, -1, O0, [CSC], 0, 0), + N1 = list_to_pid("<0.100.0>"), + ?line O1 = corba_fake_mk_objkey(M0, key, N1), + {_,_,K1,_,_,_} = O1, + PB1 = #'IIOP_ProfileBody_1_1' + {iiop_version=V, host=H0, port=P0, object_key=O1, + components=[CSC]}, + TP1 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB1}, + S1 = #'IOP_IOR'{type_id=T0, profiles=[TP1]}, + ?line S1 = iop_ior:create({1, 1}, T0, [H0], P0, -1, O1, [CSC], 0, 0), + O2 = "This is an external objectkey", + PB2 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O2, + components=[]}, + TP2 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB2}, + S2 = #'IOP_IOR'{type_id=T0, profiles=[TP2]}, + ?line {'internal_registered', N0, _, _, M0} = iop_ior:get_key(S0), + ?line {'internal', K1, _, _, M0} = iop_ior:get_key(S1), + ?line {'external', {H0, P0, O2, _,_, + #host_data{protocol = normal, + ssl_data = undefined, + version = {1,1}, + csiv2_mech = undefined, + csiv2_statefull = false, + charset = 65537, + wcharset = 65801, + ft_heartbeat = false, + ft_primary = false, + ft_group = undefined, + csiv2_addresses = []}}} = + iop_ior:get_key(S2), + ?line T0 = iop_ior:get_typeID(S0), + ?line O0 = iop_ior:get_objkey(S0), + ?line O1 = iop_ior:get_objkey(S1), + ?line O2 = iop_ior:get_objkey(S2), + ok. + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- +corba_fake_mk_objkey(Id, 'key', Pid) when is_pid(Pid) -> + Key = make_objkey(), + {Id, 'key', Key, term_to_binary(undefined), 0, 0}; +corba_fake_mk_objkey(Id, 'key', RegName) when is_atom(RegName) -> + Key = term_to_binary(RegName), + {Id, 'key', Key, term_to_binary(undefined), 0, 0}; +corba_fake_mk_objkey(Id, 'registered', RegName) when is_atom(RegName) -> + {Id, 'registered', RegName, term_to_binary(undefined), 0, 0}. + +make_objkey() -> + term_to_binary({now(), node()}). diff --git a/lib/orber/test/iop_ior_12_SUITE.erl b/lib/orber/test/iop_ior_12_SUITE.erl new file mode 100644 index 0000000000..42db130e54 --- /dev/null +++ b/lib/orber/test/iop_ior_12_SUITE.erl @@ -0,0 +1,187 @@ +%%---------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : iop_ior_12_SUITE.erl +%% Description : Test suite for the IOR functions +%% +%%---------------------------------------------------------------------- +-module(iop_ior_12_SUITE). + + +-include("test_server.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> + [encoding, create_and_get_ops]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: IOR encoding test +%% Description: Just testing the string_encoding function because the +%% other encodings is called from them. +%%----------------------------------------------------------------- +encoding(doc) -> ["Description", "more description"]; +encoding(suite) -> []; +encoding(_) -> + V = #'IIOP_Version'{major=1,minor=2}, + M0 = 'Module_Interface', + T0 = "IDL:Module/Interface:1.0", + H0 = "my.hostname.org", + P0 = 4040, + N0 = 'name', + Components = case orber:iiop_ssl_port() of + -1 -> + []; + SSLPort -> + [#'IOP_TaggedComponent'{tag=?TAG_SSL_SEC_TRANS, + component_data=[0 | + cdrlib:enc_unsigned_short(2, + cdrlib:enc_unsigned_short(2, + cdrlib:enc_unsigned_short(SSLPort, [])))]}] + end, + ?line O0 = corba_fake_mk_objkey(M0, registered, N0), + PB0 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O0, + components=Components}, + TP0 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB0}, + S0 = #'IOP_IOR'{type_id=T0, profiles=[TP0]}, + N1 = list_to_pid("<0.100.0>"), + ?line O1 = corba_fake_mk_objkey(M0, key, N1), + PB1 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O1, + components=[]}, + TP1 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB1}, + S1 = #'IOP_IOR'{type_id=T0, profiles=[TP1]}, + O2 = "This is an external objectkey", + PB2 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O2, + components=[]}, + TP2 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB2}, + S2 = #'IOP_IOR'{type_id=T0, profiles=[TP2]}, + ?line C0 = iop_ior:string_code(S0), + ?line {S0, <<>>, _} = iop_ior:string_decode(C0), + ?line C1 = iop_ior:string_code(S1), + ?line {S1, <<>>, _} = iop_ior:string_decode(C1), + ?line C2 = iop_ior:string_code(S2), + ?line {S2, <<>>, _} = iop_ior:string_decode(C2), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: IOR creation test +%% Description: +%%----------------------------------------------------------------- +create_and_get_ops(doc) -> ["Description", "more description"]; +create_and_get_ops(suite) -> []; +create_and_get_ops(_) -> + V = #'IIOP_Version'{major=1,minor=2}, + CSC = #'IOP_TaggedComponent'{tag=?TAG_CODE_SETS, + component_data=?DEFAULT_CODESETS}, + M0 = 'Module_Interface', + T0 = "IDL:Module/Interface:1.0", + H0 = "my.hostname.org", + P0 = 4040, + N0 = 'name', + ?line O0 = corba_fake_mk_objkey(M0, registered, N0), + PB0 = #'IIOP_ProfileBody_1_1' + {iiop_version=V, host=H0, port=P0, object_key=O0, + components=[CSC]}, + TP0 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB0}, + S0 = #'IOP_IOR'{type_id=T0, profiles=[TP0]}, + ?line S0 = iop_ior:create({1, 2}, T0, [H0], P0, -1, O0, [CSC], 0, 0), + N1 = list_to_pid("<0.100.0>"), + ?line O1 = corba_fake_mk_objkey(M0, key, N1), + {_,_,K1,_,_,_} = O1, + PB1 = #'IIOP_ProfileBody_1_1' + {iiop_version=V, host=H0, port=P0, object_key=O1, + components=[CSC]}, + TP1 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB1}, + S1 = #'IOP_IOR'{type_id=T0, profiles=[TP1]}, + ?line S1 = iop_ior:create({1, 2}, T0, [H0], P0, -1, O1, [CSC], 0, 0), + O2 = "This is an external objectkey", + PB2 = #'IIOP_ProfileBody_1_1'{iiop_version=V, host=H0, port=P0, object_key=O2, + components=[]}, + TP2 = #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB2}, + S2 = #'IOP_IOR'{type_id=T0, profiles=[TP2]}, + ?line {'internal_registered', N0, _, _, M0} = iop_ior:get_key(S0), + ?line {'internal', K1, _, _, M0} = iop_ior:get_key(S1), + ?line {'external', {H0, P0, O2,_,_, + #host_data{protocol = normal, + ssl_data = undefined, + version = {1,2}, + csiv2_mech = undefined, + csiv2_statefull = false, + charset = 65537, + wcharset = 65801, + ft_heartbeat = false, + ft_primary = false, + ft_group = undefined, + csiv2_addresses = []}}} + = iop_ior:get_key(S2), + ?line T0 = iop_ior:get_typeID(S0), + ?line O0 = iop_ior:get_objkey(S0), + ?line O1 = iop_ior:get_objkey(S1), + ?line O2 = iop_ior:get_objkey(S2), + ok. + +%%----------------------------------------------------------------- +%% Internal functions +%%----------------------------------------------------------------- +corba_fake_mk_objkey(Id, 'key', Pid) when is_pid(Pid) -> + Key = make_objkey(), + {Id, 'key', Key, term_to_binary(undefined), 0, 0}; +corba_fake_mk_objkey(Id, 'key', RegName) when is_atom(RegName) -> + Key = term_to_binary(RegName), + {Id, 'key', Key, term_to_binary(undefined), 0, 0}; +corba_fake_mk_objkey(Id, 'registered', RegName) when is_atom(RegName) -> + {Id, 'registered', RegName, term_to_binary(undefined), 0, 0}. + +make_objkey() -> + term_to_binary({now(), node()}). diff --git a/lib/orber/test/lname_SUITE.erl b/lib/orber/test/lname_SUITE.erl new file mode 100644 index 0000000000..d1f0e7cf0e --- /dev/null +++ b/lib/orber/test/lname_SUITE.erl @@ -0,0 +1,198 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the Names Library module +%% +%%----------------------------------------------------------------- +-module(lname_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/COSS/CosNaming/lname.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> + [lname_component, lname]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: name component handling tests +%% Description: +%%----------------------------------------------------------------- +lname_component(doc) -> ["Description", "more description"]; +lname_component(suite) -> []; +lname_component(_) -> + create_test(), + get_tests(), + set_tests(). + +create_test() -> + ?line #'CosNaming_NameComponent'{} = lname_component:create(), + ok. + +get_tests() -> + NC = #'CosNaming_NameComponent'{id="first", kind="apple"}, + NC1 = #'CosNaming_NameComponent'{id="", kind="apple"}, + NC2 = #'CosNaming_NameComponent'{id="first", kind=""}, + ?line "first" = lname_component:get_id(NC), + ?line "apple" = lname_component:get_kind(NC), + ?line {'EXCEPTION', #'LNameComponent_NotSet'{}} = + (catch lname_component:get_id(NC1)), + ?line {'EXCEPTION', #'LNameComponent_NotSet'{}} = + (catch lname_component:get_kind(NC2)), + ok. + +set_tests() -> + NC = #'CosNaming_NameComponent'{id="first", kind="apple"}, + ?line #'CosNaming_NameComponent'{id="second", kind="apple"} = + lname_component:set_id(NC, "second"), + ?line #'CosNaming_NameComponent'{id="first", kind="pear"} = + lname_component:set_kind(NC, "pear"), + ok. + +%%----------------------------------------------------------------- +%% Test Case: name handling tests +%% Description: +%%----------------------------------------------------------------- +lname(doc) -> ["Description", "more description"]; +lname(suite) -> []; +lname(_) -> + Name = [#'CosNaming_NameComponent'{id="first", kind="apple"}, + #'CosNaming_NameComponent'{id="last", kind="peach"}, + #'CosNaming_NameComponent'{id="and", kind="plum"}, + #'CosNaming_NameComponent'{id="always", kind="orange"}], + insert_tests(Name), + get_tests(Name), + delete_tests(Name), + comparision_tests(Name), + convertion_tests(Name). + +insert_tests(Name) -> + NC = #'CosNaming_NameComponent'{id="new", kind="pear"}, + ?line [NC, #'CosNaming_NameComponent'{id="first", kind="apple"}, + #'CosNaming_NameComponent'{id="last", kind="peach"}, + #'CosNaming_NameComponent'{id="and", kind="plum"}, + #'CosNaming_NameComponent'{id="always", kind="orange"}] = + lname:insert_component(Name, 1, NC), + ?line [#'CosNaming_NameComponent'{id="first", kind="apple"}, + #'CosNaming_NameComponent'{id="last", kind="peach"}, + #'CosNaming_NameComponent'{id="and", kind="plum"}, + #'CosNaming_NameComponent'{id="always", kind="orange"}, NC] = + lname:insert_component(Name, 5, NC), + ?line [#'CosNaming_NameComponent'{id="first", kind="apple"}, + #'CosNaming_NameComponent'{id="last", kind="peach"}, + #'CosNaming_NameComponent'{id="and", kind="plum"}, NC, + #'CosNaming_NameComponent'{id="always", kind="orange"}] = + lname:insert_component(Name, 4, NC), + ?line [#'CosNaming_NameComponent'{id="first", kind="apple"}, + #'CosNaming_NameComponent'{id="last", kind="peach"}, NC, + #'CosNaming_NameComponent'{id="and", kind="plum"}, + #'CosNaming_NameComponent'{id="always", kind="orange"}] = + lname:insert_component(Name, 3, NC), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:insert_component(Name, 6, NC)), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:insert_component(Name, 0, NC)), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:insert_component(Name, -2, NC)), + ok. + +get_tests(Name) -> + ?line #'CosNaming_NameComponent'{id="first", kind="apple"} = + lname:get_component(Name, 1), + ?line #'CosNaming_NameComponent'{id="always", kind="orange"} = + lname:get_component(Name, 4), + ?line #'CosNaming_NameComponent'{id="and", kind="plum"} = + lname:get_component(Name, 3), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:get_component(Name, 5)), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:get_component(Name, 0)), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:get_component(Name, -2)), + ok. + +delete_tests(Name) -> + ?line [#'CosNaming_NameComponent'{id="last", kind="peach"}, + #'CosNaming_NameComponent'{id="and", kind="plum"}, + #'CosNaming_NameComponent'{id="always", kind="orange"}] = + lname:delete_component(Name, 1), + ?line [#'CosNaming_NameComponent'{id="first", kind="apple"}, + #'CosNaming_NameComponent'{id="last", kind="peach"}, + #'CosNaming_NameComponent'{id="and", kind="plum"}] = + lname:delete_component(Name, 4), + ?line [#'CosNaming_NameComponent'{id="first", kind="apple"}, + #'CosNaming_NameComponent'{id="last", kind="peach"}, + #'CosNaming_NameComponent'{id="always", kind="orange"}] = + lname:delete_component(Name, 3), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:delete_component(Name, 6)), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:delete_component(Name, 0)), + ?line {'EXCEPTION', #'LName_NoComponent'{}} = + (catch lname:delete_component(Name, -2)), + ok. + +comparision_tests(Name) -> + ?line true = lname:equal(Name, Name), + ?line false = lname:equal(Name, lname:delete_component(Name, 2)), + ?line true = lname:less_than(lname:delete_component(Name, 2), Name), + ?line false = lname:less_than(Name, Name), + ?line false = lname:less_than(Name, lname:delete_component(Name, 2)), + ok. + +convertion_tests(Name) -> + ?line Name = lname:from_idl_form(Name), + ?line Name = lname:to_idl_form(Name), + ok. diff --git a/lib/orber/test/multi_ORB_SUITE.erl b/lib/orber/test/multi_ORB_SUITE.erl new file mode 100644 index 0000000000..d1931f5393 --- /dev/null +++ b/lib/orber/test/multi_ORB_SUITE.erl @@ -0,0 +1,2352 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(multi_ORB_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("orber/src/ifr_objects.hrl"). +-include("idl_output/orber_test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContextExt.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContext.hrl"). + + +-define(default_timeout, ?t:minutes(15)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, basic_PI_api/1, multi_orber_api/1, + init_per_testcase/2, fin_per_testcase/2, multi_pseudo_orber_api/1, + light_orber_api/1, light_orber2_api/1, + ssl_1_multi_orber_api/1, ssl_2_multi_orber_api/1, ssl_reconfigure_api/1, + iiop_timeout_api/1, iiop_timeout_added_api/1, setup_connection_timeout_api/1, + setup_multi_connection_timeout_api/1, setup_multi_connection_timeout_random_api/1, + setup_multi_connection_timeout_attempts_api/1, + fragments_server_api/1, fragments_max_server_api/1, + fragments_max_server_added_api/1, fragments_client_api/1, + light_ifr_api/1, max_requests_api/1, max_requests_added_api/1, + max_connections_api/1, max_packet_size_exceeded_api/1, + max_packet_size_ok_api/1, proxy_interface_api/1, proxy_interface_ipv6_api/1, + multiple_accept_api/1, implicit_context_api/1, + pseudo_implicit_context_api/1, pseudo_two_implicit_context_api/1, + oneway_implicit_context_api/1, implicit_context_roundtrip_api/1, + oneway_pseudo_implicit_context_api/1, flags_added_api/1, + oneway_pseudo_two_implicit_context_api/1, + local_interface_api/1, local_interface_ctx_override_api/1, + local_interface_acl_override_api/1, bad_giop_header_api/1, + bad_fragment_id_client_api/1, bad_id_cancel_request_api/1, + close_connections_api/1, close_connections_local_interface_api/1, + close_connections_local_interface_ctx_override_api/1, ssl_reconfigure_generation_3_api/1, + ssl_1_multi_orber_generation_3_api/1, ssl_2_multi_orber_generation_3_api/1, + close_connections_alt_iiop_addr_api/1, close_connections_multiple_profiles_api/1]). + + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([pseudo_calls/2, pseudo_casts/2, create_fake_server_ORB/5, do_connect/3]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for multi orber interfaces", + "This suite test intra-ORB communication. There are three scenarios:", + "* No security at all (multi_orber_api)", + "* Two secure orbs using ssl (ssl_multi_orb_api)", + "* One secure and one orb with no security. (ssl_multi_orb_api)"]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +%% NOTE - the fragment test cases must be first since we explicitly set a request +%% id. Otherwise, the request-id counter would be increased and we cannot know +%% what it is. +cases() -> + [fragments_server_api, + fragments_max_server_api, + fragments_max_server_added_api, + fragments_client_api, + flags_added_api, + bad_fragment_id_client_api, + bad_giop_header_api, + bad_id_cancel_request_api, + implicit_context_api, + pseudo_implicit_context_api, + pseudo_two_implicit_context_api, + implicit_context_roundtrip_api, + oneway_implicit_context_api, + oneway_pseudo_implicit_context_api, + oneway_pseudo_two_implicit_context_api, + proxy_interface_api, + proxy_interface_ipv6_api, + local_interface_api, + local_interface_ctx_override_api, + local_interface_acl_override_api, + close_connections_api, + close_connections_local_interface_api, + close_connections_local_interface_ctx_override_api, + close_connections_alt_iiop_addr_api, + close_connections_multiple_profiles_api, + multiple_accept_api, + max_requests_api, + max_requests_added_api, + max_connections_api, + max_packet_size_exceeded_api, + max_packet_size_ok_api, + light_ifr_api, + multi_pseudo_orber_api, + multi_orber_api, + light_orber_api, + light_orber2_api, + basic_PI_api, + iiop_timeout_api, + iiop_timeout_added_api, + setup_connection_timeout_api, + setup_multi_connection_timeout_api, + setup_multi_connection_timeout_attempts_api, + setup_multi_connection_timeout_random_api, + ssl_1_multi_orber_api, + ssl_1_multi_orber_generation_3_api, + ssl_2_multi_orber_api, + ssl_2_multi_orber_generation_3_api, + ssl_reconfigure_generation_3_api, + ssl_reconfigure_api + ]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + Dog=test_server:timetrap(?default_timeout), + orber:jump_start(0), + oe_orber_test_server:oe_register(), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + oe_orber_test_server:oe_unregister(), + orber:jump_stop(), + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + Config. + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, no security +%%----------------------------------------------------------------- + +implicit_context_api(doc) -> ["IIOP Implicit Contex tests"]; +implicit_context_api(suite) -> []; +implicit_context_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + %% Create a remote server + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaname::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService#mamba")), + + Relay = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([])), + ?match(ok, + orber_test_server: + relay_call(Relay, + [{context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + Loopback}}]}], + IOR)), + + ?match([_,_], orber:iiop_connections(out)), + Conns = ?match([_,_], + orber_test_lib:remote_apply(ServerNode, orber, iiop_connections, [in])), + ?match(true, lists:keymember(Loopback, 1, Conns)), + ok. + +implicit_context_roundtrip_api(doc) -> + ["IIOP Implicit Contex roundtrip tests"]; +implicit_context_roundtrip_api(suite) -> []; +implicit_context_roundtrip_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + %% Create a remote server + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + Relay = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaname::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService#mamba")), + + IOR = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([], [])), + ?match(ok, + orber_test_server: + relay_call(Relay, + [{context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + Loopback}}]}], + IOR)), + ?match([_,_], orber:iiop_connections(out)), + Conns = ?match([_,_], + orber_test_lib:remote_apply(ServerNode, orber, iiop_connections, [in])), + ?match(true, lists:keymember(Loopback, 1, Conns)), + ok. + + + +oneway_implicit_context_api(doc) -> ["IIOP Implicit Contex oneway tests"]; +oneway_implicit_context_api(suite) -> []; +oneway_implicit_context_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + %% Create a remote server + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaname::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService#mamba")), + + Relay = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([])), + ?match(ok, + orber_test_server: + relay_cast(Relay, + [{context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + Loopback}}]}], + IOR)), + + %% We must wait for a few seconds for the client to be able to set up the + %% connection (since it's a oneway operation). + timer:sleep(5000), + ?match([_,_], orber:iiop_connections(out)), + Conns = ?match([_,_], + orber_test_lib:remote_apply(ServerNode, orber, iiop_connections, [in])), + ?match(true, lists:keymember(Loopback, 1, Conns)), + ok. + + +pseudo_implicit_context_api(doc) -> ["IIOP Implicit Contex tests (via pseudo object)"]; +pseudo_implicit_context_api(suite) -> []; +pseudo_implicit_context_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + %% Create a remote server + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaname::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService#mamba")), + + Relay = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([], [{pseudo,true}])), + ?match(ok, + orber_test_server: + relay_call(Relay, + [{context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + Loopback}}]}], + IOR)), + ?match([_,_], orber:iiop_connections(out)), + Conns = ?match([_,_], + orber_test_lib:remote_apply(ServerNode, orber, iiop_connections, [in])), + ?match(true, lists:keymember(Loopback, 1, Conns)), + ok. + +pseudo_two_implicit_context_api(doc) -> + ["IIOP two Implicit Contex tests (via pseudo object)"]; +pseudo_two_implicit_context_api(suite) -> []; +pseudo_two_implicit_context_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + %% Create a remote server + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaname::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService#mamba")), + + Relay = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([], [{pseudo,true}])), + put(oe_server_in_context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + IP}}]), + ?match(ok, + orber_test_server: + relay_call(Relay, + [{context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + Loopback}}]}], + IOR)), + ?match([_,_], orber:iiop_connections(out)), + Conns = ?match([_,_], + orber_test_lib:remote_apply(ServerNode, orber, iiop_connections, [in])), + ?match(true, lists:keymember(Loopback, 1, Conns)), + ok. + +oneway_pseudo_implicit_context_api(doc) -> ["IIOP Implicit Contex tests (via pseudo object oneway)"]; +oneway_pseudo_implicit_context_api(suite) -> []; +oneway_pseudo_implicit_context_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + %% Create a remote server + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaname::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService#mamba")), + + Relay = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([], [{pseudo,true}])), + ?match(ok, + orber_test_server: + relay_cast(Relay, + [{context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + Loopback}}]}], + IOR)), + ?match([_,_], orber:iiop_connections(out)), + Conns = ?match([_,_], + orber_test_lib:remote_apply(ServerNode, orber, iiop_connections, [in])), + ?match(true, lists:keymember(Loopback, 1, Conns)), + ok. + +oneway_pseudo_two_implicit_context_api(doc) -> + ["IIOP two Implicit Contex tests (via pseudo object oneway)"]; +oneway_pseudo_two_implicit_context_api(suite) -> []; +oneway_pseudo_two_implicit_context_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + %% Create a remote server + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaname::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService#mamba")), + + Relay = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([], [{pseudo,true}])), + %% Add incoming implicit context which must be removed. + put(oe_server_in_context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + IP}}]), + ?match(ok, + orber_test_server: + relay_cast(Relay, + [{context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + Loopback}}]}], + IOR)), + ?match([_,_], orber:iiop_connections(out)), + Conns = ?match([_,_], + orber_test_lib:remote_apply(ServerNode, orber, iiop_connections, [in])), + ?match(true, lists:keymember(Loopback, 1, Conns)), + ok. + + + +multiple_accept_api(doc) -> ["IIOP Multiple Accept tests"]; +multiple_accept_api(suite) -> []; +multiple_accept_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + %% The server ORB doesn't listen to 127.0.0.1 + ?match({'EXCEPTION',_}, + corba:string_to_object("corbaloc::1.2@" ++Loopback++":"++integer_to_list(ServerPort)++"/NameService")), + ?match([], orber:iiop_connections(out)), + + IOR1 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {IP, ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR1)), + ?match([_], orber:iiop_connections(out)), + + {ok, Ref1} = ?match({ok, _}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [Loopback, normal])), + + IOR2 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++Loopback++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {Loopback, ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR2)), + ?match([_,_], orber:iiop_connections(out)), + + {ok, Ref2} = ?match({ok, _}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [Loopback, normal, 9543])), + ?match({error, eaddrinuse}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [Loopback, normal, 9543])), + + IOR3 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++Loopback++":9543/NameService")), + ?match({'external', {Loopback, 9543, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR3)), + ?match([_,_,_], orber:iiop_connections(out)), + + ?match(ok, + orber_test_lib:remote_apply(ServerNode, orber, + remove_listen_interface, [Ref1])), + %% Wait a few seconds to be sure that the connections really has been removed. + timer:sleep(4000), + ?match([_,_], orber:iiop_connections(out)), + + ?match(ok, + orber_test_lib:remote_apply(ServerNode, orber, + remove_listen_interface, [Ref2])), + %% Wait a few seconds to be sure that the connections really has been removed. + timer:sleep(4000), + ?match([_], orber:iiop_connections(out)), + + ?match({'EXCEPTION',_}, + corba:string_to_object("corbaloc::1.2@"++Loopback++":9543/NameService")), + ?match({'EXCEPTION',_}, + corba:string_to_object("corbaloc::1.2@"++Loopback++":"++integer_to_list(ServerPort)++"/NameService")), + + IOR4 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {IP, ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR4)), + + ok. + + +proxy_interface_api(doc) -> ["IIOP Proxy Interface tests", + "This case test if the server ORB use the correct", + "interface when exporting IOR:s"]; +proxy_interface_api(suite) -> []; +proxy_interface_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_LOCAL_INTERFACE}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR1 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {IP, ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR1)), + IOR2 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++Loopback++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {Loopback, ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR2)), + ok. + +proxy_interface_ipv6_api(doc) -> ["IIOP Proxy Interface tests", + "This case test if the server ORB use the correct", + "IPv6 interface when exporting IOR:s"]; +proxy_interface_ipv6_api(suite) -> []; +proxy_interface_ipv6_api(_Config) -> + case orber_test_lib:version_ok() of + true -> + proxy_interface_ipv6_api2(); + Reason -> + Reason + end. + +proxy_interface_ipv6_api2() -> + Loopback = orber_test_lib:get_loopback_interface(inet6), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_LOCAL_INTERFACE)}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_IPV6}])), + + IP = orber_test_lib:remote_apply(ClientNode, orber_test_lib, get_host, []), + + IOR1 = ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match({'external', {IP, ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + orber_test_lib:remote_apply(ClientNode, iop_ior, get_key, [IOR1])), + IOR2 = ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++Loopback++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match({'external', {Loopback, ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + orber_test_lib:remote_apply(ClientNode, iop_ior, get_key, [IOR2])), + ok. + +local_interface_api(doc) -> ["IIOP Local Interface tests", + "This case test if the server ORB use the correct", + "local interface when connecting to another ORB"]; +local_interface_api(suite) -> []; +local_interface_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address_local, Loopback}])), + Port = orber:iiop_port(), + ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService"])), + [{Loopback, RemotePort}] = + ?match([{Loopback,_RemotePort}], orber:iiop_connections(in)), + + ?match([{IP, Port}], + orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + ?match([{IP, Port}], orber:find_sockname_by_peername(Loopback,RemotePort)), + ?match([{Loopback, RemotePort}], orber:find_peername_by_sockname(IP, Port)), + + ?match([{Loopback, RemotePort}], + orber_test_lib:remote_apply(ClientNode, orber, + find_sockname_by_peername, + [IP, Port])), + ?match([{IP, Port}], + orber_test_lib:remote_apply(ClientNode, orber, + find_peername_by_sockname, + [Loopback,RemotePort])), + + + ok. + +local_interface_ctx_override_api(doc) -> + ["IIOP Local Interface tests", + "This case test if the server ORB use the correct", + "local interface when connecting to another ORB"]; +local_interface_ctx_override_api(suite) -> []; +local_interface_ctx_override_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address_local, IP}])), + Port = orber:iiop_port(), + ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService", + [#'IOP_ServiceContext' + {context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, Loopback}}]])), + [{Loopback, RemotePort}] = + ?match([{Loopback,_RemotePort}], orber:iiop_connections(in)), + + ?match([{IP, Port, Loopback}], + orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + ?match([{IP, Port}], orber:find_sockname_by_peername(Loopback,RemotePort)), + ?match([{Loopback, RemotePort}], orber:find_peername_by_sockname(IP, Port)), + + ?match([{Loopback, RemotePort}], + orber_test_lib:remote_apply(ClientNode, orber, + find_sockname_by_peername, + [IP, Port])), + ?match([{IP, Port}], + orber_test_lib:remote_apply(ClientNode, orber, + find_peername_by_sockname, + [Loopback,RemotePort])), + + ok. + +local_interface_acl_override_api(doc) -> + ["IIOP Local Interface tests", + "This case test if the server ORB use the correct", + "local interface when connecting to another ORB"]; +local_interface_acl_override_api(suite) -> []; +local_interface_acl_override_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + ACL = [{tcp_out, IP ++ "/18", [Loopback]}], + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address_local, IP}, + {iiop_acl, ACL}, + {flags, ?ORB_ENV_USE_ACL_OUTGOING}])), + Port = orber:iiop_port(), + ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService", + [#'IOP_ServiceContext' + {context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, IP}}]])), + ?match([{Loopback,_RemotePort}], orber:iiop_connections(in)), + ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService"])), + + [{Loopback, RemotePort}] = + ?match([{Loopback,_RemotePort}], orber:iiop_connections(in)), + ?match([{IP, Port, IP}], orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + ?match([{IP, Port}], orber:find_sockname_by_peername(Loopback,RemotePort)), + ?match([{Loopback, RemotePort}], orber:find_peername_by_sockname(IP, Port)), + + ?match([{Loopback, RemotePort}], + orber_test_lib:remote_apply(ClientNode, orber, + find_sockname_by_peername, + [IP, Port])), + ?match([{IP, Port}], + orber_test_lib:remote_apply(ClientNode, orber, + find_peername_by_sockname, + [Loopback,RemotePort])), + + ok. + + +iiop_timeout_api(doc) -> ["IIOP TIMEOUT API tests", + "This case test if timeout configuration behaves correctly"]; +iiop_timeout_api(suite) -> []; +iiop_timeout_api(_Config) -> + + %% Install two secure orber. + {ok, ClientNode, ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_timeout, 6}, + {iiop_connection_timeout, 3}, + {iiop_in_connection_timeout, 3}])), + ClientPort = orber_test_lib:remote_apply(ClientNode, orber, iiop_port, []), + + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_timeout, 6}, + {iiop_connection_timeout, 3}, + {iiop_in_connection_timeout, 12}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [timeout])), + + %% Tell client_orb to interoperate with server_orb. + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_lib, + lookup, + [ServerHost, ServerPort])), + %% Interop worked fine, perform delay tests. + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_lib, + timeouts, + [ServerHost, ServerPort, 6000])), + + %% Create a connection to the "client_orb", which will now act as server. + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++ClientHost++":"++integer_to_list(ClientPort)++"/NameService")), + %% Check that the connection is established. + ?match([{_, ClientPort}], orber:iiop_connections(out)), + %% Wait >3 seconds (i.e. iiop_in_connection_timeout) and check if the connection + %% have been closed. + timer:sleep(8000), + ?match([], orber:iiop_connections(out)), + + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + uninstall_test_data, + [timeout])), + ok. + +iiop_timeout_added_api(doc) -> ["IIOP TIMEOUT API tests", + "This case test if timeout configuration behaves correctly"]; +iiop_timeout_added_api(suite) -> []; +iiop_timeout_added_api(_Config) -> + IP = orber_test_lib:get_host(), + {ok, Node, _Host} = ?match({ok,_,_}, orber_test_lib:js_node([])), + Port = 1 + orber_test_lib:remote_apply(Node, orber, iiop_port, []), + ?match({ok, _}, + orber_test_lib:remote_apply(Node, orber, + add_listen_interface, + [IP, normal, + [{iiop_in_connection_timeout, 3}, + {flags, ?ORB_ENV_LOCAL_INTERFACE}, + {iiop_port, Port}]])), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [timeout])), + + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService")), + %% Check that the connection is established. + ?match([{_, Port}], orber:iiop_connections(out)), + %% Wait >3 seconds (i.e. iiop_in_connection_timeout) and check if the connection + %% have been closed. + timer:sleep(8000), + ?match([], orber:iiop_connections(out)), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + uninstall_test_data, + [timeout])), + ok. + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB using pseudo call/cast, no security +%%----------------------------------------------------------------- + +multi_pseudo_orber_api(doc) -> + ["MULTI ORB PSEUDO API tests", + "This case test if data encode/decode (IIOP) for pseudo objects", + "produce the correct result, i.e., the test_server echos", + "the input parameter or an exception is raised (MARSHAL)."]; +multi_pseudo_orber_api(suite) -> []; +multi_pseudo_orber_api(_Config) -> + %% --- Create a slave-node --- + {ok, Node, Host} = + ?match({ok,_,_}, orber_test_lib:js_node()), + Port = orber_test_lib:remote_apply(Node, orber, iiop_port, []), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [pseudo])), + + NSR = ?match({'IOP_IOR',"IDL:omg.org/CosNaming/NamingContextExt:1.0",_}, + corba:string_to_object("corbaloc::1.1@"++Host++":"++ + integer_to_list(Port)++"/NameService")), + Obj = + ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + 'CosNaming_NamingContext':resolve(NSR, lname:new(["mamba"]))), + orber_test_lib:corba_object_tests(Obj, NSR), + + %% Can we even contact the object? + ?match(ok, orber_test_server:print(Obj)), + + %% Invoke one blocking call followed by several invokations. + spawn(?MODULE, pseudo_calls, [5, Obj]), + ?match({ok, 10000}, orber_test_server:pseudo_call_delay(Obj, 10000)), + spawn(?MODULE, pseudo_casts, [5, Obj]), + ?match(ok, orber_test_server:pseudo_cast_delay(Obj, 10000)), + + %%--- Testing code and decode arguments --- + orber_test_lib:test_coding(Obj), + + %% Test if exit is handled properly. + ?match({'EXCEPTION',{'TRANSIENT',_,_,_}}, + orber_test_server:stop_brutal(Obj)), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + uninstall_test_data, + [pseudo])), + ok. + + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB with local flags definition set. +%%----------------------------------------------------------------- +flags_added_api(doc) -> + ["MULTI ORB PSEUDO with local flags definition set"]; +flags_added_api(suite) -> []; +flags_added_api(_Config) -> + %% --- Create a slave-node --- + IP = orber_test_lib:get_host(), + {ok, Node, _Host} = + ?match({ok,_,_}, orber_test_lib:js_node([])), + Port = 1 + orber_test_lib:remote_apply(Node, orber, iiop_port, []), + ?match({ok, _}, + orber_test_lib:remote_apply(Node, orber, + add_listen_interface, + [IP, normal, + [{flags, (?ORB_ENV_LOCAL_INTERFACE bor + ?ORB_ENV_EXCLUDE_CODESET_COMPONENT)}, + {iiop_port, Port}]])), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [pseudo])), + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.1@"++IP++":"++ + integer_to_list(Port)++"/NameService#mamba")), + ?match({'external', {IP, Port, _ObjectKey, _Counter, + #'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, + profile_data= + #'IIOP_ProfileBody_1_1'{components=[]}}, + _NewHD}}, + iop_ior:get_key(Obj)), + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + uninstall_test_data, + [pseudo])), + + ok. + + + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB with limited concurrent requests +%%----------------------------------------------------------------- +max_requests_api(doc) -> + ["MULTI ORB PSEUDO with limited concurrent requests tests"]; +max_requests_api(suite) -> []; +max_requests_api(_Config) -> + %% --- Create a slave-node --- + {ok, Node, Host} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_max_in_requests, 1}])), + Port = orber_test_lib:remote_apply(Node, orber, iiop_port, []), + max_requests(Node, Host, Port). + +max_requests_added_api(doc) -> + ["MULTI ORB PSEUDO with limited concurrent requests tests"]; +max_requests_added_api(suite) -> []; +max_requests_added_api(_Config) -> + %% --- Create a slave-node --- + [IP] = ?match([_], orber:host()), + {ok, Node, _Host} = + ?match({ok,_,_}, orber_test_lib:js_node([])), + Port = 1 + orber_test_lib:remote_apply(Node, orber, iiop_port, []), + ?match({ok, _}, + orber_test_lib:remote_apply(Node, orber, + add_listen_interface, + [IP, normal, + [{iiop_max_in_requests, 1}, + {flags, ?ORB_ENV_LOCAL_INTERFACE}, + {iiop_port, Port}]])), + max_requests(Node, IP, Port). + +max_requests(Node, Host, Port) -> + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [pseudo])), + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.1@"++Host++":"++ + integer_to_list(Port)++"/NameService#mamba")), + + %% Can we even contact the object? + ?match(ok, orber_test_server:print(Obj)), + + %% Invoke one blocking call followed by several invokations. + spawn(orber_test_server, pseudo_call_delay, [Obj, 15000]), + %% Wait for a second to be sure that the previous request has been sent + timer:sleep(1000), + {MegaSecsB, Before, _} = now(), + pseudo_calls(5, Obj), + {MegaSecsA, After, _} = now(), + %% Normally we we can perform hundreds of pseudo-calls per second. Hence, + %% if we add 8 seconds to 'Before' it should still be less since we only + %% allow one request at a time to the target ORB. + ?match(true, (MegaSecsB + (Before+8)*1000000) < (MegaSecsA + After*1000000)), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + uninstall_test_data, + [pseudo])), + + ok. + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB with limited concurrent connections +%%----------------------------------------------------------------- +max_connections_api(doc) -> + ["MULTI ORB PSEUDO with limited concurrent connections tests"]; +max_connections_api(suite) -> []; +max_connections_api(_Config) -> + %% --- Create a slave-node --- + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_backlog, 0}, + {iiop_max_in_connections, 2}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + + %% Claim connection 1 & 2 + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.2@"++ServerHost++":"++ + integer_to_list(ServerPort)++"/NameService#mamba")), + %% Claim backlog + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node()), + + spawn(ClientNode, orber_test_server, print, [Obj]), + timer:sleep(5000), + ?match([_], orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [])), + + %% Try to connect. Should fail. Due to the behavior of different TCP stacks, backlog 1 + %% might not be the precise value. Hence, we also need to define the iiop_timeout. Otherwise + %% this test case will fail. For the same reason we must GC this connection. + {ok, ClientNodeII, _ClientHostII} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_setup_connection_timeout, 5}, + {iiop_timeout, 5}, + {iiop_connection_timeout, 8}])), + + ?match({'EXCEPTION', _}, + orber_test_lib:remote_apply(ClientNodeII, orber_test_server, + testing_iiop_string, [Obj, "Fail"])), + + %% Remove 2 connections. We need to wait a moment so that both sides has detected it. + timer:sleep(5000), + ?match([_,_], orber:iiop_connections()), + ?match(ok, orber_iiop_pm:close_connection([{ServerHost, ServerPort}])), + timer:sleep(5000), + [{Host, Port}] = ?match([_], orber:iiop_connections()), + ?match(ok, orber_iiop_pm:close_connection([{Host, Port}])), + timer:sleep(5000), + ?match([], orber:iiop_connections()), + + ?match([_], orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [])), + + ?match([], orber_test_lib:remote_apply(ClientNodeII, orber, + iiop_connections, [])), + + ?match({ok, "OK"}, + orber_test_lib:remote_apply(ClientNodeII, orber_test_server, + testing_iiop_string, [Obj, "OK"])), + + timer:sleep(4000), + ?match([_], orber_test_lib:remote_apply(ClientNodeII, orber, + iiop_connections, [])), + + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + uninstall_test_data, + [pseudo])), + + ok. + + +%%----------------------------------------------------------------- +%% API tests for terminating connection by using an IOR. +%%----------------------------------------------------------------- +close_connections_api(doc) -> + ["Close outgoing connection "]; +close_connections_api(suite) -> []; +close_connections_api(_Config) -> + %% --- Create a slave-node --- + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IP = orber_test_lib:get_host(), + + %% Create a connection + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.2@"++IP++":"++ + integer_to_list(ServerPort)++"/NameService#mamba")), + %% Check that it's up. + ?match([{IP, ServerPort}], orber:iiop_connections(out)), + %% Try to close using the wronge interface. + ?match(ok, orber:close_connection(Obj, Loopback)), + %% Should still be up. + ?match([{IP, ServerPort}], orber:iiop_connections(out)), + %% Try to close it properly + ?match(ok, orber:close_connection(Obj)), + %% Wait a moment so that both sides has detected it. + timer:sleep(5000), + %% Worked? + ?match([], orber:iiop_connections(out)), + ok. + + +close_connections_local_interface_api(doc) -> + ["IIOP Local Interface disconnect tests", + "This case test if the server ORB use the correct", + "local interface when connecting to another ORB"]; +close_connections_local_interface_api(suite) -> []; +close_connections_local_interface_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address_local, Loopback}])), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address, IP}])), + Port = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService"])), + + %% Check that the connnection is up and running using the default interface + ?match([{Loopback,_RemotePort}], orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + ?match([{IP, Port}], + orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + %% Try to close the connection + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber, + close_connection, [IOR])), + %% Wait a moment so that both sides has detected it. + timer:sleep(5000), + %% Now the connection shall be gone. + ?match([], orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + ?match([], orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + + ok. + +close_connections_local_interface_ctx_override_api(doc) -> + ["IIOP Local Interface disconnect tests", + "This case test if the server ORB use the correct", + "local interface when connecting to another ORB"]; +close_connections_local_interface_ctx_override_api(suite) -> []; +close_connections_local_interface_ctx_override_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address_local, IP}, + {ip_address, IP}])), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address, IP}])), + Port = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService", + [#'IOP_ServiceContext' + {context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, Loopback}}]])), + + timer:sleep(2000), + %% Check that the connnection is up and running using the default interface + ?match([{Loopback,_RemotePort}], orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + + ?match([{IP, Port, Loopback}], + orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + %% Try to close not supplying the interface. + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber, + close_connection, [IOR])), + + timer:sleep(2000), + %% The connection shall still be up and running + ?match([{Loopback,_RemotePort}], orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + ?match([{IP, Port, Loopback}], + orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + %% Try to close not supplying the interface. + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber, + close_connection, [IOR, IP])), + + timer:sleep(2000), + %% The connection shall still be up and running + ?match([{Loopback,_RemotePort}], orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + ?match([{IP, Port, Loopback}], + orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + + %% Try to close supplying the correct interface. + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber, + close_connection, [IOR, Loopback])), + %% Wait a moment so that both sides has detected it. + timer:sleep(5000), + %% Now the connection shall be gone. + ?match([], orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + ?match([], orber_test_lib:remote_apply(ClientNode, orber, + iiop_connections, [out])), + ok. + +close_connections_alt_iiop_addr_api(doc) -> + ["IIOP alternate address disconnect tests", + "This case test if the server ORB use the correct", + "local interface when connecting to another ORB"]; +close_connections_alt_iiop_addr_api(suite) -> []; +close_connections_alt_iiop_addr_api(_Config) -> + %% --- Create a slave-node --- + Loopback = orber_test_lib:get_loopback_interface(), + IP = orber_test_lib:get_host(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{giop_version, {1, 2}}, + {ip_address, {multiple, [IP, Loopback]}}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [{nameservice, Loopback, ServerPort}])), + %% Create two connections + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.2@"++IP++":"++ + integer_to_list(ServerPort)++"/NameService#mamba")), + ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.2@"++Loopback++":"++ + integer_to_list(ServerPort)++"/NameService#mamba")), + timer:sleep(2000), + %% The connection shall still be up and running + ?match([{_,_}, {_,_}], orber:iiop_connections(out)), + ?match([{_,_}, {_,_}], + orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + + %% Try to close the connection + ?match(ok, orber:close_connection(Obj)), + %% Wait a moment so that both sides has detected it. + timer:sleep(5000), + %% Now the connections shall be gone. + ?match([], orber:iiop_connections(out)), + ?match([], orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + ok. + +close_connections_multiple_profiles_api(doc) -> + ["IIOP alternate address disconnect tests", + "This case test if the server ORB use the correct", + "local interface when connecting to another ORB"]; +close_connections_multiple_profiles_api(suite) -> []; +close_connections_multiple_profiles_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + %% --- Create a slave-node --- + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{ip_address, + {multiple, [Loopback, IP]}}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, [nameservice])), + %% Create two connections + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.2@"++IP++":"++ + integer_to_list(ServerPort)++"/NameService#mamba")), + ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.2@"++Loopback++":"++ + integer_to_list(ServerPort)++"/NameService#mamba")), + %% The connection shall still be up and running + ?match([{_,_}, {_,_}], orber:iiop_connections(out)), + ?match([{_,_}, {_,_}], + orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + + %% Try to close the connection + ?match(ok, orber:close_connection(Obj)), + %% Wait a moment so that both sides has detected it. + timer:sleep(5000), + %% Now the connections shall be gone. + ?match([], orber:iiop_connections(out)), + ?match([], orber_test_lib:remote_apply(ServerNode, orber, + iiop_connections, [in])), + ok. + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB with iiop_packet_size set +%%----------------------------------------------------------------- +max_packet_size_exceeded_api(doc) -> + ["Exceed the maximum request size"]; +max_packet_size_exceeded_api(suite) -> []; +max_packet_size_exceeded_api(_Config) -> + case catch gen_tcp:listen(0, [{packet,cdr}, {packet_size, 14}]) of + {'EXIT',badarg} -> + {skipped, "The inet option {packet_size, Max} not supported"}; + {ok, LS} -> + (catch gen_tcp:close(LS)), + %% --- Create a slave-node --- + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_packet_size, 1}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, + iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService")), + ok + end. + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB with iiop_packet_size set +%%----------------------------------------------------------------- +max_packet_size_ok_api(doc) -> + ["Not exceed the maximum request size"]; +max_packet_size_ok_api(suite) -> []; +max_packet_size_ok_api(_Config) -> + case catch gen_tcp:listen(0, [{packet,cdr}, {packet_size, 14}]) of + {'EXIT',badarg} -> + {skipped, "The inet option {packet_size, Max} not supported"}; + {ok, LS} -> + (catch gen_tcp:close(LS)), + %% --- Create a slave-node --- + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_packet_size, 5000}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, + iiop_port, []), + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService")), + ok + end. + + + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, no security +%%----------------------------------------------------------------- + +light_ifr_api(doc) -> ["LIGHT IFR ORB API tests"]; +light_ifr_api(suite) -> []; +light_ifr_api(_Config) -> + + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, 128}])), + + ?match([_,_,_,_], orber_test_lib:remote_apply(ClientNode, orber, get_tables, [])), + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_lib, + install_test_data, + [nameservice])), + + + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, 128}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + ?match([_,_,_,_], orber_test_lib:remote_apply(ServerNode, orber, get_tables, [])), + + Obj = ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaname::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService#mamba")), + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_lib, test_coding, [Obj])), + + ?match(0, orber_test_lib:remote_apply(ClientNode, orber_diagnostics, missing_modules, [])), + + ?match(ok, orber_test_lib:remote_apply(ClientNode, mnesia, dirty_write, + [#orber_light_ifr{id = "FakeId1", + module=non_existing, + type=?IFR_StructDef}])), + ?match(ok, orber_test_lib:remote_apply(ClientNode, mnesia, dirty_write, + [#orber_light_ifr{id = "FakeId2", + module=non_existing, + type=?IFR_UnionDef}])), + ?match(ok, orber_test_lib:remote_apply(ClientNode, mnesia, dirty_write, + [#orber_light_ifr{id = "FakeId3", + module=non_existing, + type=?IFR_ExceptionDef}])), + ?match(ok, orber_test_lib:remote_apply(ClientNode, mnesia, dirty_write, + [#orber_light_ifr{id = "FakeId4", + module=non_existing, + type=?IFR_InterfaceDef}])), + ?match(ok, orber_test_lib:remote_apply(ClientNode, mnesia, dirty_write, + [#orber_light_ifr{id = "FakeId5", + module=orber_test_lib, + type=?IFR_InterfaceDef}])), + ?match(5, orber_test_lib:remote_apply(ClientNode, orber_diagnostics, missing_modules, [])), + + + ?match(ok, mnesia:dirty_write(#ir_UnionDef{ir_Internal_ID = "FakedIId1", + absolute_name="::Module::NonExisting"})), + ?match(ok, mnesia:dirty_write(#ir_StructDef{ir_Internal_ID = "FakedIId2", + absolute_name="::Module::NonExisting"})), + ?match(ok, mnesia:dirty_write(#ir_ExceptionDef{ir_Internal_ID = "FakedIId3", + absolute_name="::Module::NonExisting"})), + ?match(ok, mnesia:dirty_write(#ir_InterfaceDef{ir_Internal_ID = "FakedIId4", + absolute_name="::Module::NonExisting"})), + ?match(ok, mnesia:dirty_write(#ir_InterfaceDef{ir_Internal_ID = "FakedIId5", + absolute_name="::orber::test::lib"})), + + ?match(5, orber_diagnostics:missing_modules()), + + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + uninstall_test_data, + [nameservice])), + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_lib, + uninstall_test_data, + [nameservice])), + ok. + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, no security +%%----------------------------------------------------------------- + +light_orber_api(doc) -> ["LIGHT ORB API tests", + "This case test if a light Orber can communicate correctly", + "with an fully installed Orber."]; +light_orber_api(suite) -> []; +light_orber_api(_Config) -> + %% --- Create a slave-node --- + LocalHost = net_adm:localhost(), + {ok, Node, _Host} = + ?match({ok,_,_}, orber_test_lib:js_node([{lightweight, ["iiop://"++LocalHost++":"++integer_to_list(orber:iiop_port())]}], + lightweight)), + ?match(ok, orber:info(io)), + ?match([_], orber_test_lib:remote_apply(Node, orber_env, get_lightweight_nodes,[])), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [light])), + + Obj1=(catch orber_test_server:oe_create(state,[{pseudo,true}])), + ?match({_,pseudo,orber_test_server_impl, _,_, _}, Obj1), + Obj2=(catch orber_test_server:oe_create(state,[])), + ?match({_,key,_, _,_, _}, Obj2), + + NS = corba:resolve_initial_references("NameService"), + 'CosNaming_NamingContext':bind(NS, lname:new(["mamba"]), Obj1), + 'CosNaming_NamingContext':bind(NS, lname:new(["viper"]), Obj2), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + light_tests, + [LocalHost, + orber:iiop_port(), "viper"])), + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + light_tests, + [LocalHost, + orber:iiop_port(), "mamba"])), + + %% Clean up. + + catch corba:dispose(Obj1), + catch corba:dispose(Obj2), + catch 'CosNaming_NamingContext':destroy(NS), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + uninstall_test_data, + [light])), + ok. +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, no security +%%----------------------------------------------------------------- + +light_orber2_api(doc) -> ["LIGHT ORB API tests", + "This case test if a light Orber can communicate correctly", + "with an fully installed Orber. This case test if we can", + "start as lightweight without first setting the environment", + "variable"]; +light_orber2_api(suite) -> []; +light_orber2_api(_Config) -> + %% --- Create a slave-node --- + LocalHost = net_adm:localhost(), + {ok, Node, _Host} = + ?match({ok,_,_}, orber_test_lib:js_node([], + {lightweigth, ["iiop://"++LocalHost++":"++integer_to_list(orber:iiop_port())]})), + ?match(ok, orber:info(io)), + ?match([_], orber_test_lib:remote_apply(Node, orber_env, get_lightweight_nodes,[])), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [light])), + + Obj1=(catch orber_test_server:oe_create(state,[{pseudo,true}])), + ?match({_,pseudo,orber_test_server_impl, _,_, _}, Obj1), + Obj2=(catch orber_test_server:oe_create(state,[])), + ?match({_,key,_, _,_, _}, Obj2), + + NS = corba:resolve_initial_references("NameService"), + 'CosNaming_NamingContext':bind(NS, lname:new(["mamba"]), Obj1), + 'CosNaming_NamingContext':bind(NS, lname:new(["viper"]), Obj2), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + light_tests, + [LocalHost, + orber:iiop_port(), "viper"])), + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + light_tests, + [LocalHost, + orber:iiop_port(), "mamba"])), + + %% Clean up. + + catch corba:dispose(Obj1), + catch corba:dispose(Obj2), + catch 'CosNaming_NamingContext':destroy(NS), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + uninstall_test_data, + [light])), + ok. + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, no security +%%----------------------------------------------------------------- + +multi_orber_api(doc) -> ["MULTI ORB API tests", + "This case test if data encode/decode (IIOP)", + "produce the correct result, i.e., the test_server echos", + "the input parameter or an exception is raised (MARSHAL)."]; +multi_orber_api(suite) -> []; +multi_orber_api(_Config) -> + + NewICObj1 = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([])), + NewICObj2 = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([], [{regname, {local, newic2}}])), + NewICObj3 = ?match({_,_,_,_,_,_}, orber_test_server:oe_create([], [{regname, {global, newic3}}])), + ?match(ok, orber_test_server:print(NewICObj1)), + ?match(ok, orber_test_server:print(NewICObj2)), + ?match(ok, orber_test_server:print(NewICObj3)), + catch corba:dispose(NewICObj1), + catch corba:dispose(NewICObj2), + catch corba:dispose(NewICObj3), + + %% --- Create a slave-node --- + {ok, Node, Host} = + ?match({ok,_,_}, orber_test_lib:js_node()), + Port = orber_test_lib:remote_apply(Node, orber, iiop_port, []), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [nameservice])), + + NSR = ?match({'IOP_IOR',"IDL:omg.org/CosNaming/NamingContextExt:1.0",_}, + corba:string_to_object("corbaloc::1.2@"++Host++":"++ + integer_to_list(Port)++"/NameService")), + + ?match({'EXCEPTION',{'CosNaming_NamingContext_NotFound',_,_,_}}, + 'CosNaming_NamingContext':resolve(NSR, lname:new(["not_exist"]))), + + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + 'CosNaming_NamingContext':resolve(NSR, lname:new(["mamba"]))), + ?match(ok, orber_test_server:print(Obj)), + + Obj12B = ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++Host++":"++integer_to_list(Port)++"/Mamba")), + + Obj11B = ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.1@"++Host++":"++integer_to_list(Port)++"/Mamba")), + + Obj10B = ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.0@"++Host++":"++integer_to_list(Port)++"/Mamba")), + + context_test(Obj12B), + context_test(Obj11B), + + ?match(ok, orber_test_server:print(Obj12B)), + ?match(ok, orber_test_server:print(Obj11B)), + ?match(ok, orber_test_server:print(Obj10B)), + ?match({'EXCEPTION',{'CosNaming_NamingContextExt_InvalidAddress',_}}, + corba:string_to_object("corbaloc::1.0@"++Host++":"++integer_to_list(Port)++"/Wrong")), + + ?match(ok, orber_test_lib:corba_object_tests(Obj12B, NSR)), + ?match(ok, orber_test_lib:corba_object_tests(Obj11B, NSR)), + ?match(ok, orber_test_lib:corba_object_tests(Obj10B, NSR)), + + %%--- Testing code and decode arguments --- + orber_test_lib:test_coding(Obj), + + ?match({'EXCEPTION',#'BAD_CONTEXT'{}}, + orber_test_server: + print(Obj12B, + [{context, + [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, + {127,0,0,1}}}]}])), + + ?match({'EXCEPTION',{'TRANSIENT',_,_,_}}, + orber_test_server:stop_brutal(Obj12B)), + ?match({'EXCEPTION',{'TRANSIENT',_,_,_}}, + orber_test_server:print(Obj12B)), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + uninstall_test_data, + [nameservice])), + ok. + + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, no security, using basic interceptors +%%----------------------------------------------------------------- +basic_PI_api(doc) -> ["MULTI ORB API tests", + "This case test if data encode/decode (IIOP)", + "produce the correct result when using basic interceptors,", + "i.e., the test_server echos", + "the input parameter or an exception is raised (MARSHAL)."]; +basic_PI_api(suite) -> []; +basic_PI_api(_Config) -> + %% Change configuration to use Basic Interceptors. + orber:configure_override(interceptors, {native, [orber_test_lib]}), + %% --- Create a slave-node --- + {ok, Node, Host} = + ?match({ok,_,_}, orber_test_lib:js_node([{interceptors, {native, [orber_test_lib]}}])), + Port = orber_test_lib:remote_apply(Node, orber, iiop_port, []), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [nameservice])), + + Obj12 = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.2@"++Host++":"++integer_to_list(Port)++"/NameService#mamba")), + + Obj11 = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.1@"++Host++":"++integer_to_list(Port)++"/NameService#mamba")), + + Obj10 = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.0@"++Host++":"++integer_to_list(Port)++"/NameService#mamba")), + + ?match(ok, corba:print_object(Obj12)), + ?match(ok, corba:print_object(Obj11, error_report)), + ?match(ok, corba:print_object(Obj10, {error_report, "Reason"})), + + ?match(ok, orber_test_server:print(Obj12)), + ?match(ok, orber_test_server:print(Obj11)), + ?match(ok, orber_test_server:print(Obj10)), + + + Obj12B = ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++Host++":"++integer_to_list(Port)++"/Mamba")), + + Obj11B = ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.1@"++Host++":"++integer_to_list(Port)++"/Mamba")), + + Obj10B = ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.0@"++Host++":"++integer_to_list(Port)++"/Mamba")), + + ?match(ok, corba:print_object(Obj12B, info_msg)), + ?match(ok, corba:print_object(Obj11B, {info_msg, "Comment"})), + ?match([_|_], corba:print_object(Obj10B, string)), + + ?match(ok, orber_test_server:print(Obj12B)), + ?match(ok, orber_test_server:print(Obj11B)), + ?match(ok, orber_test_server:print(Obj10B)), + ?match({'EXCEPTION',{'CosNaming_NamingContextExt_InvalidAddress',_}}, + corba:string_to_object("corbaloc::1.0@"++Host++":"++integer_to_list(Port)++"/Wrong")), + + ?match(ok, orber_test_lib:alternate_iiop_address(Host, Port)), + + context_test(Obj12B), + context_test(Obj11B), + + %%--- Testing code and decode arguments --- + orber_test_lib:test_coding(Obj12), + orber_test_lib:test_coding(Obj11), + orber_test_lib:test_coding(Obj10), + + application:set_env(orber, interceptors, false), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + uninstall_test_data, + [nameservice])), + ok. + + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, ssl security depth 1 +%%----------------------------------------------------------------- + +ssl_1_multi_orber_api(doc) -> ["SECURE MULTI ORB API tests (SSL depth 1)", + "This case set up two secure orbs and test if they can", + "communicate. The case also test to access one of the", + "secure orbs which must raise a NO_PERMISSION exception."]; +ssl_1_multi_orber_api(suite) -> []; +ssl_1_multi_orber_api(_Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + ServerOptions = orber_test_lib:get_options(iiop_ssl, server, + 1, [{iiop_ssl_port, 0}]), + ClientOptions = orber_test_lib:get_options(iiop_ssl, client, + 1, [{iiop_ssl_port, 0}]), + ssl_suite(ServerOptions, ClientOptions), + ok + end. + +ssl_1_multi_orber_generation_3_api(doc) -> ["SECURE MULTI ORB API tests (SSL depth 1)", + "This case set up two secure orbs and test if they can", + "communicate. The case also test to access one of the", + "secure orbs which must raise a NO_PERMISSION exception."]; +ssl_1_multi_orber_generation_3_api(suite) -> []; +ssl_1_multi_orber_generation_3_api(_Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + case orber_test_lib:ssl_version() of + 3 -> + ServerOptions = orber_test_lib:get_options(iiop_ssl, server, + 1, [{ssl_generation, 3}, + {iiop_ssl_port, 0}]), + ClientOptions = orber_test_lib:get_options(iiop_ssl, client, + 1, [{ssl_generation, 3}, + {iiop_ssl_port, 0}]), + ssl_suite(ServerOptions, ClientOptions), + ok; + _ -> + {skipped, "Required SSL generation not available"} + end + end. + + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, ssl security depth 2 +%%----------------------------------------------------------------- + +ssl_2_multi_orber_api(doc) -> ["SECURE MULTI ORB API tests (SSL depth 2)", + "This case set up two secure orbs and test if they can", + "communicate. The case also test to access one of the", + "secure orbs which must raise a NO_PERMISSION exception."]; +ssl_2_multi_orber_api(suite) -> []; +ssl_2_multi_orber_api(_Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + ServerOptions = orber_test_lib:get_options(iiop_ssl, server, + 2, [{iiop_ssl_port, 0}]), + ClientOptions = orber_test_lib:get_options(iiop_ssl, client, + 2, [{iiop_ssl_port, 0}]), + ssl_suite(ServerOptions, ClientOptions), + ok + end. + +ssl_2_multi_orber_generation_3_api(doc) -> ["SECURE MULTI ORB API tests (SSL depth 2)", + "This case set up two secure orbs and test if they can", + "communicate. The case also test to access one of the", + "secure orbs which must raise a NO_PERMISSION exception."]; +ssl_2_multi_orber_generation_3_api(suite) -> []; +ssl_2_multi_orber_generation_3_api(_Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + case orber_test_lib:ssl_version() of + 3 -> + ServerOptions = orber_test_lib:get_options(iiop_ssl, server, + 2, [{ssl_generation, 3}, + {iiop_ssl_port, 0}]), + ClientOptions = orber_test_lib:get_options(iiop_ssl, client, + 2, [{ssl_generation, 3}, + {iiop_ssl_port, 0}]), + ssl_suite(ServerOptions, ClientOptions), + ok; + _ -> + {skipped, "Required SSL generation not available"} + end + end. +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, ssl security depth 2 +%%----------------------------------------------------------------- + +ssl_reconfigure_api(doc) -> ["SECURE MULTI ORB API tests (SSL depth 2)", + "This case set up two secure orbs and test if they can", + "communicate. The case also test to access one of the", + "secure orbs which must raise a NO_PERMISSION exception."]; +ssl_reconfigure_api(suite) -> []; +ssl_reconfigure_api(_Config) -> + ssl_reconfigure([]). + +ssl_reconfigure_generation_3_api(doc) -> ["SECURE MULTI ORB API tests (SSL depth 2)", + "This case set up two secure orbs and test if they can", + "communicate. The case also test to access one of the", + "secure orbs which must raise a NO_PERMISSION exception."]; +ssl_reconfigure_generation_3_api(suite) -> []; +ssl_reconfigure_generation_3_api(_Config) -> + case orber_test_lib:ssl_version() of + 3 -> + ssl_reconfigure([{ssl_generation, 3}]); + + _ -> + {skipped, "Required SSL generation not available"} + end. + +ssl_reconfigure(ExtraSSLOptions) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, + orber_test_lib:js_node([{iiop_port, 0}, + {flags, ?ORB_ENV_LOCAL_INTERFACE}, + {ip_address, IP}|ExtraSSLOptions])), + orber_test_lib:remote_apply(ServerNode, ssl, start, []), + orber_test_lib:remote_apply(ServerNode, crypto, start, []), + orber_test_lib:remote_apply(ServerNode, ssl, seed, ["testing"]), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [ssl])), + ?match({ok, _}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [Loopback, normal, [{iiop_port, 5648}, + {iiop_ssl_port, 5649}, + {interceptors, {native, [orber_iiop_tracer_silent]}}|ExtraSSLOptions]])), + ServerOptions = orber_test_lib:get_options(iiop_ssl, server, + 2, [{flags, ?ORB_ENV_LOCAL_INTERFACE}, + {iiop_port, 5648}, + {iiop_ssl_port, 5649}, + {interceptors, {native, [orber_iiop_tracer_silent]}}|ExtraSSLOptions]), + ?match({ok, _}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [Loopback, ssl, ServerOptions])), + + ClientOptions = orber_test_lib:get_options(iiop_ssl, client, + 2, [{iiop_ssl_port, 0}|ExtraSSLOptions]), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node(ClientOptions)), + + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_lib, + install_test_data, + [ssl])), + orber_test_lib:remote_apply(ClientNode, ssl, start, []), + orber_test_lib:remote_apply(ServerNode, crypto, start, []), + orber_test_lib:remote_apply(ClientNode, ssl, seed, ["testing"]), + Obj = ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, + string_to_object, ["corbaname:iiop:1.1@"++Loopback++":5648/NameService#mamba", + [{context, [#'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {configuration, ClientOptions}}]}]])), + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_server, + print, [Obj])), + + ok + end. + + + +%%----------------------------------------------------------------- +%% API tests for Orber to Java ORB, no security +%%----------------------------------------------------------------- + +%orber_java_api(doc) -> ["ERLANG-ORB <-> JAVA-ORB API tests", +% "This case test if data encode/decode (IIOP)", +% "produce the correct result, i.e., the test_server echos", +% "the input parameter or an exception is raised (MARSHAL)."]; +%orber_java_api(suite) -> []; +%orber_java_api(Config) -> +% ok. + +%%------------------------------------------------------------ +%% function : ssl_suite +%% Arguments: Config +%% Depth +%% Returns : ok +%% Effect : +%%------------------------------------------------------------ + +ssl_suite(ServerOptions, ClientOptions) -> + + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node(ServerOptions)), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + SSLServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_ssl_port, []), + + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node(ClientOptions)), + + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [ssl])), + %% Tell the client to interoperate with the server. The purpose of this + %% operation is to look up, using NameService, an object reference and + %% use it to contact the object. + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_lib, + lookup, + [ServerHost, ServerPort])), + + ?match(ok, orber_test_lib:remote_apply(ClientNode, orber_test_lib, + alternate_ssl_iiop_address, + [ServerHost, ServerPort, SSLServerPort])), + + %% 'This' node is not secure. Contact the server. Must refuse connection. + NSR = ?match({'IOP_IOR',"IDL:omg.org/CosNaming/NamingContextExt:1.0",_}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++ + integer_to_list(ServerPort)++"/NameService")), + + %% Should be 'NO_PERMISSION'?? + ?match({'EXCEPTION',{'COMM_FAILURE',_,_,_}}, + 'CosNaming_NamingContext':resolve(NSR, lname:new(["not_exist"]))), + + %% Should be 'NO_PERMISSION'?? + ?match({'EXCEPTION',{'COMM_FAILURE',_,_,_}}, + 'CosNaming_NamingContext':resolve(NSR, lname:new(["mamba"]))), + + %% Uninstall. + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + uninstall_test_data, + [ssl])), + ok. + +%%----------------------------------------------------------------- +%% iiop_setup_connection_timeout API tests for ORB to ORB. +%%----------------------------------------------------------------- +setup_connection_timeout_api(doc) -> ["iiop_setup_connection_timeout API tests for ORB to ORB."]; +setup_connection_timeout_api(suite) -> []; +setup_connection_timeout_api(_Config) -> + ?match(ok, application:set_env(orber, iiop_backlog, 0)), + %% Wait to be sure that the configuration has kicked in. + timer:sleep(2000), + {ok, Ref, Port} = create_fake_server_ORB(normal, 0, [], listen, []), + ?match(ok, orber:configure(iiop_setup_connection_timeout, 5)), + ?match(ok, orber:info(io)), + IP = orber_test_lib:get_host(), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + timer:sleep(2000), + Corbaloc = "corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService", + ?match({'EXCEPTION', _E}, corba:string_to_object(Corbaloc)), + destroy_fake_ORB(Ref), + ?match(ok, application:set_env(orber, iiop_backlog, 5)), + ok. + +%%----------------------------------------------------------------- +%% iiop_setup_connection_timeout API tests for ORB to ORB. +%%----------------------------------------------------------------- +setup_multi_connection_timeout_api(doc) -> + ["iiop_multi_setup_connection_timeout API tests for ORB to ORB."]; +setup_multi_connection_timeout_api(suite) -> []; +setup_multi_connection_timeout_api(_Config) -> + ?match(ok, application:set_env(orber, iiop_backlog, 0)), + %% Wait to be sure that the configuration has kicked in. + timer:sleep(2000), + {ok, Ref, Port} = create_fake_server_ORB(normal, 0, [], listen, []), + ?match(ok, application:set_env(orber, iiop_out_ports, {6042, 6234})), + ?match(ok, orber:configure(iiop_setup_connection_timeout, 5)), + ?match(ok, orber:info(io)), + IP = orber_test_lib:get_host(), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + Corbaloc = "corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService", + timer:sleep(2000), + ?match({'EXCEPTION', _E}, corba:string_to_object(Corbaloc)), + destroy_fake_ORB(Ref), + ?match(ok, application:set_env(orber, iiop_backlog, 5)), + ?match(ok, application:set_env(orber, iiop_out_ports, undefined)), + ok. + +setup_multi_connection_timeout_attempts_api(doc) -> + ["iiop_multi_setup_connection_timeout API tests for ORB to ORB."]; +setup_multi_connection_timeout_attempts_api(suite) -> []; +setup_multi_connection_timeout_attempts_api(_Config) -> + ?match(ok, application:set_env(orber, iiop_backlog, 0)), + %% Wait to be sure that the configuration has kicked in. + timer:sleep(2000), + {ok, Ref, Port} = create_fake_server_ORB(normal, 0, [], listen, []), + ?match(ok, application:set_env(orber, iiop_out_ports, {6042, 6234})), + ?match(ok, application:set_env(orber, iiop_out_ports_attempts, 1)), + ?match(ok, orber:configure(iiop_setup_connection_timeout, 5)), + ?match(ok, orber:info(io)), + IP = orber_test_lib:get_host(), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + Corbaloc = "corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService", + timer:sleep(2000), + ?match({'EXCEPTION', _E}, corba:string_to_object(Corbaloc)), + destroy_fake_ORB(Ref), + ?match(ok, application:set_env(orber, iiop_backlog, 5)), + ?match(ok, application:set_env(orber, iiop_out_ports, undefined)), + ok. + +setup_multi_connection_timeout_random_api(doc) -> + ["iiop_multi_setup_connection_timeout API tests for ORB to ORB."]; +setup_multi_connection_timeout_random_api(suite) -> []; +setup_multi_connection_timeout_random_api(_Config) -> + ?match(ok, application:set_env(orber, iiop_backlog, 0)), + %% Wait to be sure that the configuration has kicked in. + timer:sleep(2000), + {ok, Ref, Port} = create_fake_server_ORB(normal, 0, [], listen, []), + ?match(ok, application:set_env(orber, iiop_out_ports, {6042, 6234})), + ?match(ok, application:set_env(orber, iiop_out_ports_random, true)), + ?match(ok, orber:configure(iiop_setup_connection_timeout, 5)), + ?match(ok, orber:info(io)), + IP = orber_test_lib:get_host(), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + spawn(?MODULE, do_connect, [IP, Port, [{active, false}]]), + Corbaloc = "corbaloc::1.2@"++IP++":"++integer_to_list(Port)++"/NameService", + timer:sleep(2000), + ?match({'EXCEPTION', _E}, corba:string_to_object(Corbaloc)), + destroy_fake_ORB(Ref), + ?match(ok, application:set_env(orber, iiop_backlog, 5)), + ?match(ok, application:set_env(orber, iiop_out_ports, undefined)), + ok. + +%%----------------------------------------------------------------- +%% Sending an incorrect header to the server-side ORB. +%%----------------------------------------------------------------- +bad_giop_header_api(doc) -> ["Sending an incorrect header to the server-side ORB."]; +bad_giop_header_api(suite) -> []; +bad_giop_header_api(_Config) -> + orber:configure_override(interceptors, {native,[orber_iiop_tracer]}), + orber:configure(orber_debug_level, 10), + ?match(ok, orber:info(io)), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node()), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + Req = <<"GIOP",1,2,0,100,0,0,0,5,0,0,0,10,50>> , + ?match(ok, fake_client_ORB(normal, ServerHost, ServerPort, [], + message_error, [Req])), + + application:set_env(orber, interceptors, false), + orber:configure(orber_debug_level, 0), + ok. + + +%%----------------------------------------------------------------- +%% Fragmented IIOP tests (Server-side). +%%----------------------------------------------------------------- +-define(REQUEST_ID, 0). + +-define(REPLY_FRAG_1, <<71,73,79,80,1,2,2,1,0,0,0,41,0,0,0,?REQUEST_ID,0,0,0,0,0,0,0,1,78,69,79,0,0,0,0,2,0,10,0,0,0,0,0,0,0,0,0,18,0,0,0,0,0,0,0,4,49>>). +%% The fragments are identical for requests and replies. +-define(FRAG_2, <<71,73,79,80,1,2,2,7,0,0,0,5,0,0,0,?REQUEST_ID,50>>). +-define(FRAG_3, <<71,73,79,80,1,2,2,7,0,0,0,5,0,0,0,?REQUEST_ID,51>>). +-define(FRAG_4, <<71,73,79,80,1,2,0,7,0,0,0,5,0,0,0,?REQUEST_ID,0>>). + + +fragments_server_api(doc) -> ["fragments API tests for server-side ORB."]; +fragments_server_api(suite) -> []; +fragments_server_api(_Config) -> + %% --- Create a slave-node --- + {ok, Node, Host} = + ?match({ok,_,_}, orber_test_lib:js_node()), + Port = orber_test_lib:remote_apply(Node, orber, iiop_port, []), + + ?match(ok, orber_test_lib:remote_apply(Node, orber_test_lib, + install_test_data, + [nameservice])), + + NSR = ?match({'IOP_IOR',"IDL:omg.org/CosNaming/NamingContextExt:1.0",_}, + corba:string_to_object("corbaloc::1.2@"++Host++":"++ + integer_to_list(Port)++"/NameService")), + + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + 'CosNaming_NamingContext':resolve(NSR, lname:new(["mamba"]))), + + Any = #any{typecode = {tk_string,0}, + value = "123"}, + Target = #'GIOP_TargetAddress'{label = ?GIOP_KeyAddr, + value = iop_ior:get_objkey(Obj)}, + %% Fix a request header. + {Hdr, Body, HdrLen, _What, _Flags} = + cdr_encode:enc_request_split( + #giop_env{version = {1,2}, objkey = Target, + request_id = ?REQUEST_ID, + response_expected = true, + op = testing_iiop_any, + parameters = [49], ctx = [], + tc = {tk_void,[tk_char],[]}, + host = [orber_test_lib:get_host()], + iiop_port = orber:iiop_port(), + iiop_ssl_port = orber:iiop_ssl_port(), + domain = orber:domain(), + partial_security = orber:partial_security()}), + NewBody = + case size(Body) of + 1 -> + <<0,0,0,18,0,0,0,0,0,0,0,4,49>> ; + Size -> + Aligned = Size -1, + <<AligmnetData:Aligned/binary,49>> = Body, + list_to_binary([AligmnetData, <<0,0,0,18,0,0,0,0,0,0,0,4,49>> ]) + end, + + MessSize = HdrLen+size(NewBody), + ReqFrag = list_to_binary([ <<"GIOP",1:8,2:8,2:8,0:8, + MessSize:32/big-unsigned-integer>> , Hdr |NewBody]), + ?match(Any, fake_client_ORB(normal, Host, Port, [], fragments, + [ReqFrag, ?FRAG_2, ?FRAG_3, ?FRAG_4])), + + ok. + +%%----------------------------------------------------------------- +%% Fragmented IIOP tests (Server-side). Exceeding Maximum. +%%----------------------------------------------------------------- +fragments_max_server_api(doc) -> ["Maximum fragments API tests for server-side ORB."]; +fragments_max_server_api(suite) -> []; +fragments_max_server_api(_Config) -> + %% --- Create a slave-node --- + IP = orber_test_lib:get_host(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_max_fragments, 2}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + fragments_max_server(ServerNode, IP, ServerPort). + +fragments_max_server_added_api(doc) -> ["Maximum fragments API tests for server-side ORB."]; +fragments_max_server_added_api(suite) -> []; +fragments_max_server_added_api(_Config) -> + %% --- Create a slave-node --- + IP = orber_test_lib:get_host(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([])), + ServerPort = 1 + orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({ok, _}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [IP, normal, + [{iiop_max_fragments, 2}, + {flags, ?ORB_ENV_LOCAL_INTERFACE}, + {iiop_port, ServerPort}]])), + fragments_max_server(ServerNode, IP, ServerPort). + +fragments_max_server(ServerNode, ServerHost, ServerPort) -> + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [nameservice])), + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname::1.2@"++ServerHost++":"++ + integer_to_list(ServerPort)++"/NameService#mamba")), + Target = #'GIOP_TargetAddress'{label = ?GIOP_KeyAddr, + value = iop_ior:get_objkey(Obj)}, + %% Fix a request header. + {Hdr, Body, HdrLen, _What, _Flags} = + cdr_encode:enc_request_split( + #giop_env{version = {1,2}, + objkey = Target, + request_id = ?REQUEST_ID, + response_expected = true, + op = testing_iiop_any, + parameters = [49], ctx = [], + tc = {tk_void,[tk_char],[]}, + host = [orber_test_lib:get_host()], + iiop_port = orber:iiop_port(), + iiop_ssl_port = orber:iiop_ssl_port(), + domain = orber:domain(), + partial_security = orber:partial_security()}), + NewBody = + case size(Body) of + 1 -> + <<0,0,0,18,0,0,0,0,0,0,0,4,49>> ; + Size -> + Aligned = Size -1, + <<AligmnetData:Aligned/binary,49>> = Body, + list_to_binary([AligmnetData, <<0,0,0,18,0,0,0,0,0,0,0,4,49>> ]) + end, + + MessSize = HdrLen+size(NewBody), + ReqFrag = list_to_binary([ <<"GIOP",1:8,2:8,2:8,0:8, + MessSize:32/big-unsigned-integer>> , Hdr |NewBody]), + ?match(#'IMP_LIMIT'{}, + fake_client_ORB(normal, ServerHost, ServerPort, [], fragments_max, + [ReqFrag, ?FRAG_2, ?FRAG_3, ?FRAG_4])), + + ok. + +%%----------------------------------------------------------------- +%% Fragmented IIOP tests (Client-side). +%%----------------------------------------------------------------- +fragments_client_api(doc) -> ["fragments API tests for client-side ORB."]; +fragments_client_api(suite) -> []; +fragments_client_api(_Config) -> + Any = #any{typecode = {tk_string,0}, + value = "123"}, + application:set_env(orber, interceptors, {native,[orber_iiop_tracer]}), + orber:configure(orber_debug_level, 10), + orber:info(), + IOR = ?match({'IOP_IOR',_,_}, + iop_ior:create_external({1, 2}, "IDL:FAKE:1.0", + "localhost", 6004, "FAKE", [])), + spawn(?MODULE, create_fake_server_ORB, [normal, 6004, [], fragments, + [?REPLY_FRAG_1, ?FRAG_2, + ?FRAG_3, ?FRAG_4]]), + ?match({ok, Any}, orber_test_server:testing_iiop_any(IOR, Any)), + application:set_env(orber, interceptors, false), + orber:configure(orber_debug_level, 0), + ok. + +%%----------------------------------------------------------------- +%% Fragmented IIOP tests (Client-side). +%%----------------------------------------------------------------- +bad_fragment_id_client_api(doc) -> ["fragments API tests for client-side ORB."]; +bad_fragment_id_client_api(suite) -> []; +bad_fragment_id_client_api(_Config) -> + application:set_env(orber, interceptors, {native,[orber_iiop_tracer]}), + orber:configure(orber_debug_level, 10), + orber:info(), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node()), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + Req = <<71,73,79,80,1,2,2,7,0,0,0,5,0,0,0,100,50>> , + ?match(ok, fake_client_ORB(normal, ServerHost, ServerPort, [], + message_error, [Req])), + + application:set_env(orber, interceptors, false), + orber:configure(orber_debug_level, 0), + + ok. + +%%----------------------------------------------------------------- +%% Non-existing request id +%%----------------------------------------------------------------- +bad_id_cancel_request_api(doc) -> ["Description", "more description"]; +bad_id_cancel_request_api(suite) -> []; +bad_id_cancel_request_api(Config) when is_list(Config) -> + Req10 = cdr_encode:enc_cancel_request(#giop_env{version = {1, 0}, + request_id = 556}), + Req11 = cdr_encode:enc_cancel_request(#giop_env{version = {1, 1}, + request_id = 556}), + Req12 = cdr_encode:enc_cancel_request(#giop_env{version = {1, 2}, + request_id = 556}), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node()), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match(ok, fake_client_ORB(normal, ServerHost, ServerPort, [], + message_error, [Req10])), + ?match(ok, fake_client_ORB(normal, ServerHost, ServerPort, [], + message_error, [Req11])), + ?match(ok, fake_client_ORB(normal, ServerHost, ServerPort, [], + message_error, [Req12])), + ok. + +%%----------------------------------------------------------------- +%% Local functions. +%%----------------------------------------------------------------- + +do_connect(Host, Port, Options) -> + gen_tcp:connect(Host, Port, Options), + timer:sleep(20000). + +pseudo_calls(0, _) -> + ok; +pseudo_calls(Times, Obj) -> + orber_test_server:pseudo_call(Obj), + New = Times - 1, + pseudo_calls(New, Obj). +pseudo_casts(0, _) -> + ok; +pseudo_casts(Times, Obj) -> + orber_test_server:pseudo_cast(Obj), + New = Times - 1, + pseudo_casts(New, Obj). + +context_test(Obj) -> + CodeSetCtx = #'CONV_FRAME_CodeSetContext'{char_data = 65537, + wchar_data = 65801}, + FTGrp = #'FT_FTGroupVersionServiceContext'{object_group_ref_version = ?ULONGMAX}, + FTReq = #'FT_FTRequestServiceContext'{client_id = "ClientId", + retention_id = ?LONGMAX, + expiration_time = ?ULONGLONGMAX}, + + IDToken1 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTAbsent, + value = true}, + IDToken2 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTAnonymous, + value = false}, + IDToken3 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTPrincipalName, + value = [0,255]}, + IDToken4 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTX509CertChain, + value = [1,255]}, + IDToken5 = #'CSI_IdentityToken'{label = ?CSI_IdentityTokenType_ITTDistinguishedName, + value = [2,255]}, + IDToken6 = #'CSI_IdentityToken'{label = ?ULONGMAX, + value = [3,255]}, + + MTEstablishContext1 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken1, + client_authentication_token = [1, 255]}}, + MTEstablishContext2 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken2, + client_authentication_token = [1, 255]}}, + MTEstablishContext3 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken3, + client_authentication_token = [1, 255]}}, + MTEstablishContext4 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken4, + client_authentication_token = [1, 255]}}, + MTEstablishContext5 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken5, + client_authentication_token = [1, 255]}}, + MTEstablishContext6 = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTEstablishContext, + value = #'CSI_EstablishContext'{client_context_id = ?ULONGLONGMAX, + authorization_token = + [#'CSI_AuthorizationElement' + {the_type = ?ULONGMAX, + the_element = [0,255]}], + identity_token = IDToken6, + client_authentication_token = [1, 255]}}, + MTCompleteEstablishContext = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTCompleteEstablishContext, + value = #'CSI_CompleteEstablishContext'{client_context_id = ?ULONGLONGMAX, + context_stateful = false, + final_context_token = [1, 255]}}, + MTContextError = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTContextError, + value = #'CSI_ContextError'{client_context_id = ?ULONGLONGMAX, + major_status = 1, + minor_status = 2, + error_token = [2,255]}}, + MTMessageInContext = #'CSI_SASContextBody' + {label = ?CSI_MsgType_MTMessageInContext, + value = #'CSI_MessageInContext'{client_context_id = ?ULONGLONGMAX, + discard_context = true}}, + Ctx = [#'IOP_ServiceContext'{context_id=?IOP_CodeSets, + context_data = CodeSetCtx}, + #'IOP_ServiceContext'{context_id=?IOP_FT_GROUP_VERSION, + context_data = FTGrp}, + #'IOP_ServiceContext'{context_id=?IOP_FT_REQUEST, + context_data = FTReq}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext1}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext2}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext3}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext4}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext5}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTEstablishContext6}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTCompleteEstablishContext}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTContextError}, + #'IOP_ServiceContext'{context_id=?IOP_SecurityAttributeService, + context_data = MTMessageInContext}, + #'IOP_ServiceContext'{context_id=?ORBER_GENERIC_CTX_ID, + context_data = {any_kind_of_data, {127,0,0,1}, 4001}}], + ?match(ok, orber_test_server:testing_iiop_context(Obj, [{context, Ctx}])). + + +create_fake_server_ORB(Type, Port, Options, listen, _Data) -> + {ok, _ListenSocket, NewPort} = + orber_socket:listen(Type, Port, + [{backlog, 0}, {active, false}|Options]), + Socket = orber_socket:connect(Type, 'localhost', NewPort, [{active, false}|Options]), + {ok, {Type, Socket}, NewPort}; +create_fake_server_ORB(Type, Port, Options, Action, Data) -> + {ok, ListenSocket, _NewPort} = + orber_socket:listen(Type, Port, [{active, false}|Options]), + Socket = orber_socket:accept(Type, ListenSocket), + do_server_action(Type, Socket, Action, Data), + orber_socket:close(Type, Socket), + ok. + +destroy_fake_ORB({Type, Socket}) -> + orber_socket:close(Type, Socket); +destroy_fake_ORB(_) -> + ok. + +fake_client_ORB(Type, Host, Port, Options, connect, _Data) -> + Socket = orber_socket:connect(Type, Host, Port, [{active, false}|Options]), + {Type, Socket}; +fake_client_ORB(Type, Host, Port, Options, Action, Data) -> + Socket = orber_socket:connect(Type, Host, Port, [{active, false}|Options]), + Result = do_client_action(Type, Socket, Action, Data), + orber_socket:close(Type, Socket), + Result. + + + +do_server_action(Type, Socket, fragments, FragList) -> + timer:sleep(3000), + {ok, _B} = gen_tcp:recv(Socket, 0), + ok = send_data(Type, Socket, FragList); +do_server_action(_Type, _Socket, _Action, _Data) -> + ok. + +do_client_action(Type, Socket, fragments, FragList) -> + ok = send_data(Type, Socket, FragList), + timer:sleep(3000), + {ok, Bytes} = gen_tcp:recv(Socket, 0), + {#reply_header{request_id = ?REQUEST_ID, reply_status = no_exception}, ok, [Par]} = + cdr_decode:dec_message({tk_void,[tk_any],[tk_any]}, Bytes), + Par; +do_client_action(Type, Socket, fragments_max, FragList) -> + ok = send_data(Type, Socket, FragList), + timer:sleep(3000), + {ok, Bytes} = gen_tcp:recv(Socket, 0), + {#reply_header{request_id = ?REQUEST_ID, reply_status = system_exception}, Exc, []} = + cdr_decode:dec_message({tk_void,[tk_any],[tk_any]}, Bytes), + Exc; +do_client_action(Type, Socket, message_error, Data) -> + ok = send_data(Type, Socket, Data), + timer:sleep(3000), + {ok,Bytes} = gen_tcp:recv(Socket, 0), + 'message_error' = cdr_decode:dec_message({tk_void,[tk_any],[tk_any]}, Bytes), + ok; +do_client_action(_Type, _Socket, _Action, _Data) -> + ok. + +send_data(_Type, _Socket, []) -> + ok; +send_data(Type, Socket, [H|T]) -> + orber_socket:write(Type, Socket, H), + send_data(Type, Socket, T). + diff --git a/lib/orber/test/naming_context_SUITE.erl b/lib/orber/test/naming_context_SUITE.erl new file mode 100644 index 0000000000..4406e01d5a --- /dev/null +++ b/lib/orber/test/naming_context_SUITE.erl @@ -0,0 +1,385 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for Name service +%% +%%----------------------------------------------------------------- +-module(naming_context_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("orber/include/corba.hrl"). + +-define(default_timeout, ?t:minutes(5)). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- + +-export([name_context/1, check_list/1, name_context_ext/1]). + +-export([init_all/1, finish_all/1, init_per_testcase/2, fin_per_testcase/2]). + + +%%----------------------------------------------------------------- +%% Macros +%%----------------------------------------------------------------- +-define(REMAP_EXCEPT(F), case catch F of + {'EXCEPTION', E} -> exit(E); + {'EXIT', E} -> exit(E); + R -> R + end). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [name_context, check_list, name_context_ext]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + ?line Dog=test_server:timetrap(?default_timeout), + orber:jump_start(0), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + orber:jump_stop(), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + Config. + +finish_all(Config) -> + Config. + +%%----------------------------------------------------------------- +%% Test Case: name handling tests +%% Description: +%%----------------------------------------------------------------- +name_context(doc) -> ["Description", "more description"]; +name_context(suite) -> []; +name_context(_) -> + ?REMAP_EXCEPT(name_context_run()). + +name_context_run() -> + ?line Ns = corba:resolve_initial_references("NameService"), + + ?match({'EXCEPTION', #'NO_PERMISSION'{}}, + 'CosNaming_NamingContextExt':destroy(Ns)), + + %% Create a test context. + ?line Tc = 'CosNaming_NamingContext':bind_new_context(Ns, + [#'CosNaming_NameComponent'{id="testcontext", + kind=""}]), + %% Start testing + ?line 'CosNaming_NamingContext':bind(Tc, [#'CosNaming_NameComponent' + {id="hej", + kind=""}], Ns), + ?line Ns = 'CosNaming_NamingContext':resolve(Tc, + [#'CosNaming_NameComponent'{id="hej", + kind=""}]), + ?line Nc = 'CosNaming_NamingContext':new_context(Tc), + ?line 'CosNaming_NamingContext':bind(Tc, [#'CosNaming_NameComponent' + {id="stop", + kind=""}], Nc), + ?line Nc = 'CosNaming_NamingContext':resolve(Tc, + [#'CosNaming_NameComponent'{id="stop", + kind=""}]), + ?line {'EXCEPTION', E0} = + (catch 'CosNaming_NamingContext':bind(Tc, + [#'CosNaming_NameComponent'{id="stop", + kind=""}], Ns)), + ?line ok = 'CosNaming_NamingContext':rebind(Tc, + [#'CosNaming_NameComponent'{id="stop", + kind=""}], Ns), + ?line {'CosNaming_NamingContext_AlreadyBound', _} = E0, + ?line 'CosNaming_NamingContext':bind_context(Tc, + [#'CosNaming_NameComponent'{id="evaluate", + kind=""}], Nc), + ?line Nc = + 'CosNaming_NamingContext':resolve(Tc, + [#'CosNaming_NameComponent'{id="evaluate", + kind=""}]), + ?line 'CosNaming_NamingContext':bind(Tc, + [#'CosNaming_NameComponent'{id="evaluate", + kind=""}, + #'CosNaming_NameComponent'{id="hej", + kind=""}], Ns), + ?line ok = 'CosNaming_NamingContext':rebind(Tc, + [#'CosNaming_NameComponent'{id="evaluate", + kind=""}, + #'CosNaming_NameComponent'{id="hej", + kind=""}], Ns), + ?line Ns = 'CosNaming_NamingContext':resolve(Tc, + [#'CosNaming_NameComponent'{id="evaluate", + kind=""}, + #'CosNaming_NameComponent'{id="hej", + kind=""}]), + ?line {'EXCEPTION', E1} = + (catch 'CosNaming_NamingContext':resolve(Tc, + [#'CosNaming_NameComponent'{id="stop", + kind=""}, + #'CosNaming_NameComponent'{id="hej", + kind=""}])), + ?line ?match(ok, orber_diagnostics:nameservice()), + + ?line {'CosNaming_NamingContext_CannotProceed', _,_,_} = E1, + ?line {'EXCEPTION', E2} = (catch 'CosNaming_NamingContext':destroy(Nc)), + ?line {'CosNaming_NamingContext_NotEmpty', _} = E2, + ?line ok = 'CosNaming_NamingContext':unbind(Tc, + [#'CosNaming_NameComponent'{id="evaluate", + kind=""}, + #'CosNaming_NameComponent'{id="hej", + kind=""}]), + ?line ok = 'CosNaming_NamingContext':destroy(Nc), + ?line ok = 'CosNaming_NamingContext':unbind(Tc, + [#'CosNaming_NameComponent'{id="evaluate", + kind=""}]), + ?line ok = 'CosNaming_NamingContext':unbind(Tc, + [#'CosNaming_NameComponent'{id="stop", + kind=""}]), + ?line ok = 'CosNaming_NamingContext':unbind(Tc, + [#'CosNaming_NameComponent'{id="hej", + kind=""}]), + ?line case 'CosNaming_NamingContext':list(Tc, 3) of + {ok, [], ?ORBER_NIL_OBJREF} -> + ok; + _ -> + exit(not_empty) + end, + ?line ok = 'CosNaming_NamingContext':unbind(Ns, + [#'CosNaming_NameComponent'{id="testcontext", + kind=""}]), + ?line ok = 'CosNaming_NamingContext':destroy(Tc), + ok. + + + +check_list(doc) -> + ["Check that the CosNaming::NamingContext::list()", + "returns ok.", + "Own Id: OTP-2023"]; +check_list(suite) -> []; +check_list(Config) when is_list(Config) -> + ?REMAP_EXCEPT(check_list_run(Config)). + +check_list_run(_Config) -> + create_default_contexts(), + ?line Ns = corba:resolve_initial_references("NameService"), + ?line {_, BL, _} = ?match({ok, _, ?ORBER_NIL_OBJREF}, + 'CosNaming_NamingContext':list(Ns, 256)), + + FF = fun(X) -> XX = hd(X#'CosNaming_Binding'.binding_name), + XX#'CosNaming_NameComponent'.id end, + + L = lists:sort(lists:map(FF, BL)), + ?line ["host", "workgroup"] = L, + + %% Test next_n/2 + ?line {_, _, BI} = ?match({ok, [], _BI}, 'CosNaming_NamingContext':list(Ns, 0)), + ?line ?match({true, []}, 'CosNaming_BindingIterator':next_n(BI, 0)), + ?line ?match({true, [_]}, 'CosNaming_BindingIterator':next_n(BI, 1)), + ?line ?match({false, [_]}, 'CosNaming_BindingIterator':next_n(BI, 1)), + ?line ?match({false, []}, 'CosNaming_BindingIterator':next_n(BI, 1)), + ?line ?match(ok, 'CosNaming_BindingIterator':destroy(BI)), + + ?line {_, _, BI2} = ?match({ok, [], _BI2}, 'CosNaming_NamingContext':list(Ns, 0)), + ?line ?match({true, _}, 'CosNaming_BindingIterator':next_one(BI2)), + ?line ?match({true, _}, 'CosNaming_BindingIterator':next_one(BI2)), + ?line ?match({false, _}, 'CosNaming_BindingIterator':next_one(BI2)), + ?line ?match(ok, 'CosNaming_BindingIterator':destroy(BI2)), + ?line ?match(ok, orber_diagnostics:nameservice()), + ok. + +create_default_contexts() -> + HostComponent = lname_component:set_id(lname_component:create(), + "host"), + HostsComponent = lname_component:set_id(lname_component:create(), + "hosts"), + ResourcesComponent = lname_component:set_id(lname_component:create(), + "resources"), + DevelopmentComponent = lname_component:set_id(lname_component:create(), + "development"), + FactoriesComponent = lname_component:set_id(lname_component:create(), + "factories"), + WGComponent = lname_component:set_id(lname_component:create(), + "workgroup"), + %% Creation of Naming Context host and it's subcontexts + NS = corba:resolve_initial_references("NameService"), + H = 'CosNaming_NamingContext':bind_new_context(NS, + lname:insert_component(lname:create(), 1, HostComponent)), + HR = 'CosNaming_NamingContext':bind_new_context(H, + lname:insert_component(lname:create(), 1, ResourcesComponent)), + 'CosNaming_NamingContext':bind_new_context(HR, + lname:insert_component(lname:create(), 1, FactoriesComponent)), + HD = 'CosNaming_NamingContext':bind_new_context(H, + lname:insert_component(lname:create(), 1, DevelopmentComponent)), + HDR = 'CosNaming_NamingContext':bind_new_context(HD, + lname:insert_component(lname:create(), 1, ResourcesComponent)), + 'CosNaming_NamingContext':bind_new_context(HDR, + lname:insert_component(lname:create(), 1, FactoriesComponent)), + %% Creation of Naming Context workgroup and it's subcontexts + W = 'CosNaming_NamingContext':bind_new_context(NS, + lname:insert_component(lname:create(), 1, WGComponent)), + 'CosNaming_NamingContext':bind_new_context(W, + lname:insert_component(lname:create(), 1, HostsComponent)), + WR = 'CosNaming_NamingContext':bind_new_context(W, + lname:insert_component(lname:create(), 1, ResourcesComponent)), + 'CosNaming_NamingContext':bind_new_context(WR, + lname:insert_component(lname:create(), 1, FactoriesComponent)), + WD = 'CosNaming_NamingContext':bind_new_context(W, + lname:insert_component(lname:create(), 1, DevelopmentComponent)), + WDR = 'CosNaming_NamingContext':bind_new_context(WD, + lname:insert_component(lname:create(), 1, ResourcesComponent)), + 'CosNaming_NamingContext':bind_new_context(WDR, + lname:insert_component(lname:create(), 1, FactoriesComponent)), + ok. + +%%----------------------------------------------------------------- +%% Test Case: +%% Description: +%%----------------------------------------------------------------- +name_context_ext(doc) -> ["Description", "more description"]; +name_context_ext(suite) -> []; +name_context_ext(_Config) -> + ?REMAP_EXCEPT(name_context_ext_run()). + +name_context_ext_run() -> + ?line NS = ?match({_,pseudo,_, _,_, _}, + corba:resolve_initial_references("NameService")), + + Name1 = [#'CosNaming_NameComponent'{id="\\<id1\\>", kind="kind1"}, + #'CosNaming_NameComponent'{id="id2", kind="kind2"}], + String1 = "\\<id1\\>.kind1/id2.kind2", + Name2 = [#'CosNaming_NameComponent'{id="id1", kind=""}, + #'CosNaming_NameComponent'{id="id2", kind=""}, + #'CosNaming_NameComponent'{id="id3", kind=""}], + String2 = "id1/id2/id3", + Name3 = [#'CosNaming_NameComponent'{id="id1", kind="kind1"}, + #'CosNaming_NameComponent'{id="", kind=""}, + #'CosNaming_NameComponent'{id="id3", kind="kind3"}], + String3 = "id1.kind1/./id3.kind3", + Name4 = [#'CosNaming_NameComponent'{id="id1", kind="kind1"}, + #'CosNaming_NameComponent'{id="i.d.2", kind="kind2"}, + #'CosNaming_NameComponent'{id="id3", kind="kind3"}], + String4 = "id1.kind1/i\\.d\\.2.kind2/id3.kind3", + Name5 = [#'CosNaming_NameComponent'{id="id1", kind=""}, + #'CosNaming_NameComponent'{id="i/d/2", kind="kind2"}, + #'CosNaming_NameComponent'{id="id3", kind=""}], + String5 = "id1/i\\/d\\/2.kind2/id3", + + BadString1 = "id1./id2/id3", + BadString2 = "id1//id3", + + ?match(String1, 'CosNaming_NamingContextExt':to_string(NS, Name1)), + ?match(String2, 'CosNaming_NamingContextExt':to_string(NS, Name2)), + ?match(String3, 'CosNaming_NamingContextExt':to_string(NS, Name3)), + ?match(String4, 'CosNaming_NamingContextExt':to_string(NS, Name4)), + ?match(String5, 'CosNaming_NamingContextExt':to_string(NS, Name5)), + ?match(Name1, 'CosNaming_NamingContextExt':to_name(NS, String1)), + ?match(Name2, 'CosNaming_NamingContextExt':to_name(NS, String2)), + ?match(Name3, 'CosNaming_NamingContextExt':to_name(NS, String3)), + ?match(Name4, 'CosNaming_NamingContextExt':to_name(NS, String4)), + ?match(Name5, 'CosNaming_NamingContextExt':to_name(NS, String5)), + + ?match({'EXCEPTION', {'CosNaming_NamingContext_InvalidName',_}}, + 'CosNaming_NamingContextExt':to_name(NS, BadString1)), + ?match({'EXCEPTION', {'CosNaming_NamingContext_InvalidName',_}}, + 'CosNaming_NamingContextExt':to_name(NS, BadString2)), + + %% Create a test context. + ?line Tc = ?match({_,pseudo,_, _,_, _}, + 'CosNaming_NamingContext':bind_new_context(NS, + [#'CosNaming_NameComponent'{id="testcontext", + kind=""}])), + ?match(ok, 'CosNaming_NamingContext':bind(Tc, [#'CosNaming_NameComponent' + {id="hej", + kind=""}], NS)), + + ?match(NS, 'CosNaming_NamingContextExt':resolve_str(Tc, "hej")), + + ?match("corbaloc:rir:", 'CosNaming_NamingContextExt':to_url(Tc, "rir:", "")), + ?match("corbaname:rir:/NameService#org/erlang/", + 'CosNaming_NamingContextExt':to_url(Tc, "rir:/NameService", "org/erlang/")), + ?match("corbaloc::1.1@555%3cxyz.com:9999/Dev/NameService", + 'CosNaming_NamingContextExt':to_url(Tc, ":1.1@555\\<xyz.com:9999/Dev/NameService", "")), + + %% Bad port + ?match({'EXCEPTION', {'CosNaming_NamingContextExt_InvalidAddress',_}}, + 'CosNaming_NamingContextExt':to_url(Tc, ":1.1@555xyz.com:99a9/", "")), + %% BAd IIOP-version + ?match({'EXCEPTION', {'CosNaming_NamingContextExt_InvalidAddress',_}}, + 'CosNaming_NamingContextExt':to_url(Tc, ":1@555xyz.com:99a9/", "")), + %% Bad IIOP-version + ?match({'EXCEPTION', {'CosNaming_NamingContextExt_InvalidAddress',_}}, + 'CosNaming_NamingContextExt':to_url(Tc, ":@555xyz.com:99a9/", "")), + %% Bad protocol + ?match({'EXCEPTION', {'CosNaming_NamingContextExt_InvalidAddress',_}}, + 'CosNaming_NamingContextExt':to_url(Tc, "iop:@555xyz.com:99a9/", "")), + %% Unsupported protocol + ?match({'EXCEPTION', {'CosNaming_NamingContextExt_InvalidAddress',_}}, + 'CosNaming_NamingContextExt':to_url(Tc, "atm:@555xyz.com:9999/", "")), + %% Bad Name + ?match({'EXCEPTION', {'CosNaming_NamingContext_InvalidName',_}}, + 'CosNaming_NamingContextExt':to_url(Tc, ":555xyz.com:9999/", "id1./id2.kind2")), + + ok. + + diff --git a/lib/orber/test/orber.spec b/lib/orber/test/orber.spec new file mode 100644 index 0000000000..9d19ea7fc1 --- /dev/null +++ b/lib/orber/test/orber.spec @@ -0,0 +1,19 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{topcase, {dir, "../orber_test"}}. diff --git a/lib/orber/test/orber_SUITE.erl b/lib/orber/test/orber_SUITE.erl new file mode 100644 index 0000000000..f54da02c0e --- /dev/null +++ b/lib/orber/test/orber_SUITE.erl @@ -0,0 +1,179 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +-module(orber_SUITE). +-include("test_server.hrl"). + + +-define(default_timeout, ?t:minutes(15)). +-define(application, orber). + +% Test server specific exports +-export([all/1]). +-export([init_per_testcase/2, fin_per_testcase/2]). + +% Test cases must be exported. +-export([app_test/1, undefined_functions/1, install_load_order/1, + install_local_content/1]). + +%% +%% all/1 +%% +all(doc) -> + []; +all(suite) -> + [app_test, undefined_functions, + install_load_order, install_local_content]. + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + +fin_per_testcase(_Case, Config) -> + Dog=?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +% +% Test cases starts here. +% +app_test(doc) -> []; +app_test(suite) -> []; +app_test(_Config) -> + ?line ok=?t:app_test(orber), + ok. + +%% Install Orber using the load_order option. +install_load_order(suite) -> + []; +install_load_order(doc) -> + []; +install_load_order(_Config) -> + orber:jump_stop(), + case catch install_load_order2() of + ok -> + orber:jump_stop(); + What -> + orber:jump_stop(), + exit(What) + end. + +install_load_order2() -> + application:load(orber), + mnesia:start(), + corba:orb_init([{iiop_port, 0}]), + orber:install([node()], [{ifr_storage_type, ram_copies}, + {load_order, 10}]), + orber:start(), + [H|_] = orber:get_tables(), + 10 = mnesia:table_info(H, load_order), + ok. + +%% Install Orber using the local_content option. +install_local_content(suite) -> + []; +install_local_content(doc) -> + []; +install_local_content(_Config) -> + orber:jump_stop(), + case catch install_local_content2() of + ok -> + orber:jump_stop(); + What -> + orber:jump_stop(), + exit(What) + end. + +install_local_content2() -> + application:load(orber), + mnesia:start(), + corba:orb_init([{iiop_port, 0}]), + orber:install([node()], [{ifr_storage_type, ram_copies}, + {local_content, true}]), + orber:start(), + [H|_] = orber:get_tables(), + true = mnesia:table_info(H, local_content), + ok. + + + +%% Check for undefined functions +undefined_functions(suite) -> + []; +undefined_functions(doc) -> + []; +undefined_functions(_Config) -> + App = orber, + Root = code:root_dir(), + LibDir = code:lib_dir(App), + EbinDir = filename:join([LibDir,"ebin"]), + AppFilePath = filename:join([LibDir,"ebin", "orber.app"]), + {ok, [{application,orber,AppFile}]} = file:consult(AppFilePath), + io:format("Using ~p~n~p~n", [AppFilePath, AppFile]), + Mods = key1search(modules, AppFile), + XRefTestName = undef_funcs_make_name(App, xref_test_name), + {ok, XRef} = xref:start(XRefTestName), + ok = xref:set_default(XRef, + [{verbose,false},{warnings,false}]), + XRefName = undef_funcs_make_name(App, xref_name), + {ok, XRefName} = xref:add_release(XRef, Root, {name,XRefName}), + {ok, App} = xref:replace_application(XRef, App, EbinDir), + {ok, Undefs} = xref:analyze(XRef, undefined_function_calls), + xref:stop(XRef), + analyze_undefined_function_calls(Undefs, Mods, []). + +analyze_undefined_function_calls([], _, []) -> + ok; +analyze_undefined_function_calls([], _, AppUndefs) -> + exit({suite_failed, {undefined_function_calls, AppUndefs}}); +analyze_undefined_function_calls([{{Mod, _F, _A}, _C} = AppUndef|Undefs], + AppModules, AppUndefs) -> + %% Check that this module is our's + case lists:member(Mod,AppModules) of + true -> + {Calling,Called} = AppUndef, + {Mod1,Func1,Ar1} = Calling, + {Mod2,Func2,Ar2} = Called, + io:format("undefined function call: " + "~n ~w:~w/~w calls ~w:~w/~w~n", + [Mod1,Func1,Ar1,Mod2,Func2,Ar2]), + analyze_undefined_function_calls(Undefs, AppModules, + [AppUndef|AppUndefs]); + false -> + io:format("dropping ~p~n", [Mod]), + analyze_undefined_function_calls(Undefs, AppModules, AppUndefs) + end. + +%% This function is used simply to avoid cut-and-paste errors later... +undef_funcs_make_name(App, PostFix) -> + list_to_atom(atom_to_list(App) ++ "_" ++ atom_to_list(PostFix)). + +key1search(Key, L) -> + case lists:keysearch(Key, 1, L) of + false -> + fail({not_found, Key, L}); + {value, {Key, Value}} -> + Value + end. + +fail(Reason) -> + exit({suite_failed, Reason}). + + + diff --git a/lib/orber/test/orber_acl_SUITE.erl b/lib/orber/test/orber_acl_SUITE.erl new file mode 100644 index 0000000000..2c2a768af2 --- /dev/null +++ b/lib/orber/test/orber_acl_SUITE.erl @@ -0,0 +1,303 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the ACL functions +%% +%%----------------------------------------------------------------- +-module(orber_acl_SUITE). + +-include("test_server.hrl"). + +-define(default_timeout, ?t:minutes(5)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Testing API for ACL (Access Control List)"]; +all(suite) -> + [ipv4_verify, ipv4_range, ipv4_interfaces, ipv4_bm, + ipv6_verify, ipv6_range, ipv6_interfaces, ipv6_bm]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_all(Config) -> + if + list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + Config. + + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case : +%% Description: +%%----------------------------------------------------------------- +ipv4_verify(doc) -> ["Testing IPv4 Verify Operation."]; +ipv4_verify(suite) -> []; +ipv4_verify(_) -> + ?match(true, orber_acl:verify("192.168.64.148", "192.168.64.0/17", inet)), + ?match({false,"192.168.128.0","192.168.255.255"}, + orber_acl:verify("192.168.64.148", "192.168.255.0/17", inet)), + ?match(true, orber_acl:verify("192.168.255.148", "192.168.128.0/17", inet)), + ?match(true, orber_acl:verify("192.168.128.148", "192.168.128.0/17", inet)), + ?match(true, orber_acl:verify("192.168.255.255", "192.168.128.0/16", inet)), + ?match({false,"192.168.0.0","192.168.255.255"}, + orber_acl:verify("192.169.255.255", "192.168.128.0/16", inet)), + ?match(true, orber_acl:verify("192.168.128.255", "192.168.128.0/24", inet)), + ?match({false,"192.168.128.0","192.168.128.255"}, + orber_acl:verify("192.168.255.255", "192.168.128.0/24", inet)), + ?match({false,"192.168.128.0","192.168.128.127"}, + orber_acl:verify("192.168.128.255", "192.168.128.0/25", inet)), + ?match(true, orber_acl:verify("192.168.128.255", "192.168.128.128/25", inet)), + ?match(true, orber_acl:verify("192.168.128.128", "192.168.128.128/32", inet)), + ?match({false,"192.168.128.128.","192.168.128.128."}, + orber_acl:verify("192.168.128.255", "192.168.128.128/32", inet)), + ?match(true, orber_acl:verify("192.168.128.128", "192.168.128.128", inet)), + ?match({false,"192.168.128.128.","192.168.128.128."}, + orber_acl:verify("192.168.128.255", "192.168.128.128", inet)), + ?match(true, orber_acl:verify("192.168.128.255", "192.168.128.128/7", inet)), + ok. + +%%----------------------------------------------------------------- +%% Test Case : +%% Description: +%%----------------------------------------------------------------- +ipv4_range(doc) -> ["Testing IPv4 Range Operation."]; +ipv4_range(suite) -> []; +ipv4_range(_) -> + ?match({ok,"192.168.0.0", "192.168.127.255"}, + orber_acl:range("192.168.64.0/17")), + ?match({ok, "192.168.128.0", "192.168.255.255"}, + orber_acl:range("192.168.255.0/17")), + ?match({ok,"192.168.128.0","192.168.255.255"}, + orber_acl:range("192.168.128.0/17")), + ?match({ok,"192.168.0.0","192.168.255.255"}, + orber_acl:range("192.168.128.0/16")), + ?match({ok,"192.168.128.0","192.168.128.255"}, + orber_acl:range("192.168.128.0/24")), + ?match({ok,"192.168.128.0","192.168.128.127"}, + orber_acl:range("192.168.128.0/25")), + ?match({ok,"192.168.128.128","192.168.128.255"}, + orber_acl:range("192.168.128.128/25")), + ?match({ok,"192.168.128.128.","192.168.128.128."}, + orber_acl:range("192.168.128.128/32")), + ?match({ok,"192.168.128.128.","192.168.128.128."}, + orber_acl:range("192.168.128.128")), + ?match({ok,"192.0.0.0","193.255.255.255"}, + orber_acl:range("192.168.128.128/7")), + ok. + +%%----------------------------------------------------------------- +%% Test Case : +%% Description: +%%----------------------------------------------------------------- +ipv4_interfaces(doc) -> ["Testing IPv4 Interfaces Operation."]; +ipv4_interfaces(suite) -> []; +ipv4_interfaces(_) -> + ?match({ok, _}, + orber_acl:init_acl([{tcp_in, "192.168.128.0/18", ["10.1.1.1"]}, + {tcp_in, "192.167.64.0/18#4001/5001", ["10.1.1.2"]}, + {tcp_in, "192.166.192.0/18"}], inet)), + {ok, IPTuple1} = ?match({ok, _}, inet:getaddr("192.168.128.0", inet)), + ?match({true, ["10.1.1.1"], 0}, orber_acl:match(IPTuple1, tcp_in, true)), + ?match({false, [], 0}, orber_acl:match(IPTuple1, tcp_out, true)), + {ok, IPTuple2} = ?match({ok, _}, inet:getaddr("192.167.64.0", inet)), + ?match({true, ["10.1.1.2"], {4001,5001}}, orber_acl:match(IPTuple2, tcp_in, true)), + ?match({false, [], 0}, orber_acl:match(IPTuple2, tcp_out, true)), + {ok, IPTuple3} = ?match({ok, _}, inet:getaddr("192.166.192.0", inet)), + ?match({true, [], 0}, orber_acl:match(IPTuple3, tcp_in, true)), + ?match(false, orber_acl:match(IPTuple3, tcp_out)), + ?match(ok, orber_acl:clear_acl()), + ok. + +%%----------------------------------------------------------------- +%% Test Case : +%% Description: +%%----------------------------------------------------------------- +ipv4_bm(doc) -> ["Benchmarking runtime critical IPv4 Operations."]; +ipv4_bm(suite) -> []; +ipv4_bm(_) -> + ?match({ok, _, _, _}, bm2([{tcp_in, "192.168.64.0/17"}], inet, "192.168.64.148")), + ok. +%%----------------------------------------------------------------- +%% Test Case : +%% Description: +%%----------------------------------------------------------------- +ipv6_verify(doc) -> ["Testing IPv6 Verify Operation."]; +ipv6_verify(suite) -> []; +ipv6_verify(_) -> + case orber_test_lib:version_ok() of + true -> + ?match(true, orber_acl:verify("2002:C0A8:0:0:0:0:0:0", "2002:C0A8::/48", inet6)), + ?match(true, orber_acl:verify("2002:C0A8:0:FFFF:FFFF:FFFF:FFFF:FFFF", "2002:C0A8::/48", inet6)), + ?match({false,"2002:C0A8:0:0:0:0:0:0", "2002:C0A8:0:FFFF:FFFF:FFFF:FFFF:FFFF"}, + orber_acl:verify("2002:C0A8:1:FFFF:FFFF:FFFF:FFFF:FFFF", "2002:C0A8::/48", inet6)), + ?match(true, orber_acl:verify("2002:C0A8:1:FFFF:FFFF:FFFF:FFFF:FFFF", "2002:C0A8::/47", inet6)), + ?match({false,"2002:C0A8:0:0:0:0:0:0", "2002:C0A8:1:FFFF:FFFF:FFFF:FFFF:FFFF"}, + orber_acl:verify("2002:C0A8:2:FFFF:FFFF:FFFF:FFFF:FFFF", "2002:C0A8::/47", inet6)), + ok; + Reason -> + Reason + end. + +%%----------------------------------------------------------------- +%% Test Case : +%% Description: +%%----------------------------------------------------------------- +ipv6_range(doc) -> ["Testing IPv6 Range Operation."]; +ipv6_range(suite) -> []; +ipv6_range(_) -> + case orber_test_lib:version_ok() of + true -> + ?match({ok,"2002:C0A8:0:0:0:0:0:0", "2002:C0A8:0:FFFF:FFFF:FFFF:FFFF:FFFF"}, + orber_acl:range("2002:C0A8::/48", inet6)), + ?match({ok,"2002:C0A8:0:0:0:0:0:0", "2002:C0A8:1:FFFF:FFFF:FFFF:FFFF:FFFF"}, + orber_acl:range("2002:C0A8::/47", inet6)), + ok; + Reason -> + Reason + end. + +%%----------------------------------------------------------------- +%% Test Case : +%% Description: +%%----------------------------------------------------------------- +ipv6_interfaces(doc) -> ["Testing IPv6 Interfaces Operation."]; +ipv6_interfaces(suite) -> []; +ipv6_interfaces(_) -> + case orber_test_lib:version_ok() of + true -> + ?match({ok, _}, orber_acl:init_acl([{tcp_in, "2002:C0A8::/49", ["0:0:0:0:0:0:10.1.1.1"]}], inet6)), + {ok, IPTuple1} = ?match({ok, _}, inet:getaddr("2002:C0A8:0:7FFF:FFFF:FFFF:FFFF:FFFF", inet6)), + ?match({true, ["0:0:0:0:0:0:10.1.1.1"], 0}, orber_acl:match(IPTuple1, tcp_in, true)), + ?match(false, orber_acl:match(IPTuple1, tcp_out)), + ?match(ok, orber_acl:clear_acl()), + ok; + Reason -> + Reason + end. + +%%----------------------------------------------------------------- +%% Test Case : +%% Description: +%%----------------------------------------------------------------- +ipv6_bm(doc) -> ["Benchmarking runtime critical IPv6 Operations."]; +ipv6_bm(suite) -> []; +ipv6_bm(_) -> + case orber_test_lib:version_ok() of + true -> + ?match({ok, _, _, _}, bm2([{tcp_in, "2002:C0A8::/48"}], inet6, "2002:C0A8:0:0:0:0:0:0")), + ok; + Reason -> + Reason + end. + +%%----------------------------------------------------------------- +%% Local Functions +%%----------------------------------------------------------------- +-define(NO_OF_TIMES, 1000). + +bm2(Filters, Family, Ip) -> + {ok, IPTuple} = inet:getaddr(Ip, Family), + orber_acl:init_acl(Filters, Family), + TimeBefore1 = erlang:now(), + bm_loop(IPTuple, ?NO_OF_TIMES), + TimeAfter1 = erlang:now(), + orber_acl:clear_acl(), + Time1 = computeTime(TimeBefore1, TimeAfter1), + orber_acl:init_acl(Filters, Family), + TimeBefore2 = erlang:now(), + bm_loop2(Ip, ?NO_OF_TIMES, Family), + TimeAfter2 = erlang:now(), + orber_acl:clear_acl(), + Time2 = computeTime(TimeBefore2, TimeAfter2), + orber_acl:init_acl(Filters, Family), + TimeBefore3 = erlang:now(), + bm_loop2(IPTuple, ?NO_OF_TIMES, Family), + TimeAfter3 = erlang:now(), + orber_acl:clear_acl(), + Time3 = computeTime(TimeBefore3, TimeAfter3), + {ok, round(?NO_OF_TIMES/Time1), round(?NO_OF_TIMES/Time2), round(?NO_OF_TIMES/Time3)}. + + +bm_loop(_Ip, 0) -> + ok; +bm_loop(Ip, N) -> + true = orber_acl:match(Ip, tcp_in), + bm_loop(Ip, N-1). + +bm_loop2(_Ip, 0, _Family) -> + ok; +bm_loop2(Ip, N, Family) -> + {ok, IPTuple} = inet:getaddr(Ip, Family), + true = orber_acl:match(IPTuple, tcp_in), + bm_loop2(Ip, N-1, Family). + +computeTime({_MegaSecb, Secb, MicroSecb}, {_MegaSeca, Seca, MicroSeca}) -> + (Seca - Secb) + ((MicroSeca - MicroSecb) / 1000000). + + +%%----------------------------------------------------------------- +%% END OF MODULE +%%----------------------------------------------------------------- diff --git a/lib/orber/test/orber_firewall_ipv4_in_SUITE.erl b/lib/orber/test/orber_firewall_ipv4_in_SUITE.erl new file mode 100644 index 0000000000..3ac0cb7921 --- /dev/null +++ b/lib/orber/test/orber_firewall_ipv4_in_SUITE.erl @@ -0,0 +1,280 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(orber_firewall_ipv4_in_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("orber/src/ifr_objects.hrl"). +-include("idl_output/orber_test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContextExt.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContext.hrl"). + +-define(default_timeout, ?t:minutes(15)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2, + deny_port_api/1, deny_port_range_api/1, deny_host_api/1, + deny_peerhost_api/1, allow_port_range_api/1, + allow_host_api/1, allow_peerhost_api/1, check_address_api/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for orber's firewall functionallity."]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +%% NOTE - the fragment test cases must bu first since we explicitly set a request +%% id. Otherwise, the request-id counter would be increased and we cannot know +%% what it is. +cases() -> + [deny_port_api, deny_port_range_api, deny_host_api, deny_peerhost_api, + allow_port_range_api, allow_host_api, allow_peerhost_api, check_address_api]. + + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + if + is_list(Config) -> + orber:jump_start([{iiop_port, 0}, + {iiop_out_ports, {5980, 6000}}]), + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + orber:jump_stop(), + Config. + +%%----------------------------------------------------------------- +%% Incomming connections - Deny +%%----------------------------------------------------------------- +deny_port_api(doc) -> ["Deny Access due to invalid local port"]; +deny_port_api(suite) -> []; +deny_port_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_INCOMING}, + {iiop_acl, [{tcp_in, IP++"/32#7000"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +deny_port_range_api(doc) -> ["Deny Access due to invalid local port range"]; +deny_port_range_api(suite) -> []; +deny_port_range_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_INCOMING}, + {iiop_acl, [{tcp_in, IP++"/32#7000/8000"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + + +deny_host_api(doc) -> ["Deny Access due to invalid host"]; +deny_host_api(suite) -> []; +deny_host_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_INCOMING}, + {iiop_acl, [{tcp_in, "123.123.123.123/32"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +deny_peerhost_api(doc) -> ["Deny Access due to invalid peerhost"]; +deny_peerhost_api(suite) -> []; +deny_peerhost_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_INCOMING}, + {iiop_acl, [{tcp_in, IP++"/32", ["123.123.123.123"]}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +%%----------------------------------------------------------------- +%% Incomming connections - Allow +%%----------------------------------------------------------------- +allow_port_range_api(doc) -> ["Allow Access due to valid local port range"]; +allow_port_range_api(suite) -> []; +allow_port_range_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_INCOMING}, + {iiop_acl, [{tcp_in, IP++"/32#5980/6000"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match(false, corba_object:not_existent(IOR)), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + + +allow_host_api(doc) -> ["Allow Access due to valid host"]; +allow_host_api(suite) -> []; +allow_host_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_INCOMING}, + {iiop_acl, [{tcp_in, IP++"/32"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match(false, corba_object:not_existent(IOR)), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +allow_peerhost_api(doc) -> ["Allow Access due to valid peerhost"]; +allow_peerhost_api(suite) -> []; +allow_peerhost_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_INCOMING}, + {iiop_acl, [{tcp_in, IP++"/32", [IP]}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService", + [#'IOP_ServiceContext' + {context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, IP}}])), + ?match(false, corba_object:not_existent(IOR, + [#'IOP_ServiceContext' + {context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, IP}}])), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +%%----------------------------------------------------------------- +%% Test corbaloc strings +%%----------------------------------------------------------------- +check_address_api(doc) -> ["Test corbaloc strings"]; +check_address_api(suite) -> []; +check_address_api(_Config) -> + ?match({[[iiop,{1,0},"10.0.0.1",2809]],"NameService"}, + orber_cosnaming_utils:addresses(":10.0.0.1/NameService")), + ?match({[[iiop,{1,0},"10.0.0.1",2809]],[]}, + orber_cosnaming_utils:addresses(":10.0.0.1")), + ?match({[[iiop,{1,2},"10.0.0.1",2809]],"NameService"}, + orber_cosnaming_utils:addresses(":1.2@10.0.0.1/NameService")), + ?match({[[iiop,{1,0},"10.0.0.1",4001]],"NameService"}, + orber_cosnaming_utils:addresses(":10.0.0.1:4001/NameService")), + ?match({[[iiop,{1,1},"10.0.0.1",4001]],"NameService"}, + orber_cosnaming_utils:addresses(":1.1@10.0.0.1:4001/NameService")), + ?match({[[iiop,{1,1},"10.0.0.1",4001]],[]}, + orber_cosnaming_utils:addresses(":1.1@10.0.0.1:4001")), + ?match({[[iiop,{1,1},"10.0.0.1",4001]],[]}, + orber_cosnaming_utils:addresses("iiop:1.1@10.0.0.1:4001")), + ?match({[[iiop,{1,1},"10.0.0.1",4001]],[]}, + orber_cosnaming_utils:addresses("iiop:1.1@10.0.0.1:4001/")), + + ?match({[[iiop,{1,1},"myhost",4001]],[]}, + orber_cosnaming_utils:addresses("iiop:1.1@myhost:4001")), + ?match({[[iiop,{1,1},"myhost.full.name",4001]],"NameService"}, + orber_cosnaming_utils:addresses("iiop:1.1@myhost.full.name:4001/NameService")), + ?match({[[iiop,{1,1},"myhost",4001], + [iiop,{1,1},"myhost.full.name",2809]],"NameService"}, + orber_cosnaming_utils:addresses("iiop:1.1@myhost:4001,iiop:1.1@myhost.full.name/NameService")), + + ?match({[[iiop,{1,1},"123.12.23.2",4001], + [iiop,{1,1},"10.0.0.1",4001]], "NameService"}, + orber_cosnaming_utils:addresses(":1.1@123.12.23.2:4001,:1.1@10.0.0.1:4001/NameService")), + ?match({[[iiop,{1,1},"123.12.23.2",4001], + [iiop,{1,1},"10.0.0.1",4001]], []}, + orber_cosnaming_utils:addresses(":1.1@123.12.23.2:4001,:1.1@10.0.0.1:4001")), + ?match({[[iiop,{1,0},"123.12.23.2",4001], + [iiop,{1,1},"10.0.0.1",4001]], "NameService"}, + orber_cosnaming_utils:addresses(":123.12.23.2:4001,:1.1@10.0.0.1:4001/NameService")), + ?match({[[iiop,{1,1},"123.12.23.2",4001], + [iiop,{1,0},"10.0.0.1",4001]], "NameService"}, + orber_cosnaming_utils:addresses(":1.1@123.12.23.2:4001,:10.0.0.1:4001/NameService")), + ?match({[[iiop,{1,1},"123.12.23.2",2809], + [iiop,{1,1},"10.0.0.1",4001]], "NameService"}, + orber_cosnaming_utils:addresses(":1.1@123.12.23.2,:1.1@10.0.0.1:4001/NameService")), + ?match({[[iiop,{1,1},"123.12.23.2",4001], + [iiop,{1,1},"10.0.0.1",2809]], "NameService"}, + orber_cosnaming_utils:addresses(":1.1@123.12.23.2:4001,:1.1@10.0.0.1/NameService")), + ?match({[[iiop,{1,0},"123.12.23.2",2809], + [iiop,{1,0},"10.0.0.1",2809]], "NameService"}, + orber_cosnaming_utils:addresses(":123.12.23.2,:10.0.0.1/NameService")), + ?match({[[iiop,{1,0},"123.12.23.2",2809], + [iiop,{1,0},"10.0.0.1",2809]], []}, + orber_cosnaming_utils:addresses(":123.12.23.2,:10.0.0.1/")), + ?match({[[iiop,{1,0},"123.12.23.2",2809], + [iiop,{1,0},"10.0.0.1",2809]], []}, + orber_cosnaming_utils:addresses("iiop:123.12.23.2,:10.0.0.1/")), + + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_INCOMING}, + {iiop_acl, [{tcp_in, IP++"/32"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + + ok. + diff --git a/lib/orber/test/orber_firewall_ipv4_out_SUITE.erl b/lib/orber/test/orber_firewall_ipv4_out_SUITE.erl new file mode 100644 index 0000000000..193fc72f7c --- /dev/null +++ b/lib/orber/test/orber_firewall_ipv4_out_SUITE.erl @@ -0,0 +1,224 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(orber_firewall_ipv4_out_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("orber/src/ifr_objects.hrl"). +-include("idl_output/orber_test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContextExt.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContext.hrl"). + +-define(default_timeout, ?t:minutes(15)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2, + deny_port_api/1, deny_port_range_api/1, deny_host_api/1, + allow_port_api/1, allow_port_range_api/1, allow_host_api/1, + local_interface_api/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for orber's firewall functionallity."]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +%% NOTE - the fragment test cases must bu first since we explicitly set a request +%% id. Otherwise, the request-id counter would be increased and we cannot know +%% what it is. +cases() -> + [deny_port_api, deny_port_range_api, deny_host_api, + allow_port_api, allow_port_range_api, allow_host_api, + local_interface_api]. + + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + if + is_list(Config) -> + orber:jump_start([{iiop_port, 0}, + {iiop_out_ports, {5980, 6000}}]), + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + orber:jump_stop(), + Config. + +%%----------------------------------------------------------------- +%% Incomming connections - Deny +%%----------------------------------------------------------------- +deny_port_api(doc) -> ["Deny Access due to invalid local port"]; +deny_port_api(suite) -> []; +deny_port_api(_Config) -> + [IP] = ?match([_], orber:host()), + ServerPort = orber:iiop_port(), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_OUTGOING}, + {iiop_acl, [{tcp_out, IP++"/32#" ++ integer_to_list(ServerPort+10)}]}])), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService"])), +% ?line catch orber_test_lib:destroy_node(ClientNode, timeout), + ok. + +deny_port_range_api(doc) -> ["Deny Access due to invalid local port range"]; +deny_port_range_api(suite) -> []; +deny_port_range_api(_Config) -> + [IP] = ?match([_], orber:host()), + ServerPort = orber:iiop_port(), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_OUTGOING}, + {iiop_acl, [{tcp_out, IP++"/32#"++integer_to_list(ServerPort+100)++ "/" ++ integer_to_list(ServerPort+120)}]}])), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService"])), +% ?line catch orber_test_lib:destroy_node(ClientNode, timeout), + ok. + + +deny_host_api(doc) -> ["Deny Access due to invalid host"]; +deny_host_api(suite) -> []; +deny_host_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_OUTGOING}, + {iiop_acl, [{tcp_out, "123.123.123.123/32"}]}])), + ServerPort = orber:iiop_port(), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService"])), +% ?line catch orber_test_lib:destroy_node(ClientNode, timeout), + ok. + +%%----------------------------------------------------------------- +%% Incomming connections - Allow +%%----------------------------------------------------------------- +allow_port_api(doc) -> ["Allow Access due to valid local port range"]; +allow_port_api(suite) -> []; +allow_port_api(_Config) -> + [IP] = ?match([_], orber:host()), + ServerPort = orber:iiop_port(), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_OUTGOING}, + {iiop_acl, [{tcp_out, IP++"/32#"++integer_to_list(ServerPort)}]}])), + IOR = + ?match({'IOP_IOR',_,_}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match(false, + orber_test_lib:remote_apply(ClientNode, corba_object, not_existent, [IOR])), +% ?line catch orber_test_lib:destroy_node(ClientNode, timeout), + ok. + +allow_port_range_api(doc) -> ["Allow Access due to valid local port range"]; +allow_port_range_api(suite) -> []; +allow_port_range_api(_Config) -> + [IP] = ?match([_], orber:host()), + ServerPort = orber:iiop_port(), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_OUTGOING}, + {iiop_acl, [{tcp_out, IP++"/32#" ++ integer_to_list(ServerPort-10) ++ "/" ++ integer_to_list(ServerPort+10)}]}])), + IOR = + ?match({'IOP_IOR',_,_}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match(false, + orber_test_lib:remote_apply(ClientNode, corba_object, not_existent, [IOR])), +% ?line catch orber_test_lib:destroy_node(ClientNode, timeout), + ok. + + +allow_host_api(doc) -> ["Allow Access due to valid host"]; +allow_host_api(suite) -> []; +allow_host_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_OUTGOING}, + {iiop_acl, [{tcp_out, IP++"/32"}]}])), + ServerPort = orber:iiop_port(), + IOR = + ?match({'IOP_IOR',_,_}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match(false, + orber_test_lib:remote_apply(ClientNode, corba_object, not_existent, [IOR])), +% ?line catch orber_test_lib:destroy_node(ClientNode, timeout), + ok. + +local_interface_api(doc) -> ["Allow Access due to valid host via a spcific interface"]; +local_interface_api(suite) -> []; +local_interface_api(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{iiop_port, 0}, + {iiop_out_ports, {5980, 6000}}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_USE_ACL_OUTGOING}, + {iiop_acl, [{tcp_out, IP, [Loopback]}]}])), + IOR = + ?match({'IOP_IOR',_,_}, + orber_test_lib:remote_apply(ClientNode, corba, string_to_object, + ["corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match(false, + orber_test_lib:remote_apply(ClientNode, corba_object, not_existent, [IOR])), +% ?line catch orber_test_lib:destroy_node(ClientNode, timeout), + ok. + diff --git a/lib/orber/test/orber_firewall_ipv6_in_SUITE.erl b/lib/orber/test/orber_firewall_ipv6_in_SUITE.erl new file mode 100644 index 0000000000..83f48cba0c --- /dev/null +++ b/lib/orber/test/orber_firewall_ipv6_in_SUITE.erl @@ -0,0 +1,311 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(orber_firewall_ipv6_in_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("orber/src/ifr_objects.hrl"). +-include("idl_output/orber_test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContextExt.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContext.hrl"). + +-define(default_timeout, ?t:minutes(15)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2, + deny_port_api/1, deny_port_range_api/1, deny_host_api/1, + deny_peerhost_api/1, allow_port_range_api/1, + allow_host_api/1, allow_peerhost_api/1, check_address_api/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for orber's firewall functionallity."]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +%% NOTE - the fragment test cases must bu first since we explicitly set a request +%% id. Otherwise, the request-id counter would be increased and we cannot know +%% what it is. +cases() -> + [deny_port_api, deny_port_range_api, deny_host_api, deny_peerhost_api, + allow_port_range_api, allow_host_api, allow_peerhost_api, + check_address_api]. + + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + orber:jump_start([{iiop_port, 0}, + {iiop_out_ports, {5980, 6000}}, + {flags, ?ORB_ENV_USE_IPV6}]), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + orber:jump_stop(), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + case orber_test_lib:version_ok() of + true -> + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end; + Reason -> + Reason + end. + +finish_all(Config) -> + Config. + + +%%----------------------------------------------------------------- +%% Incomming connections - Deny +%%----------------------------------------------------------------- +deny_port_api(doc) -> ["Deny Access due to invalid local port"]; +deny_port_api(suite) -> []; +deny_port_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_INCOMING)}, + {iiop_acl, [{tcp_in, IP++"/128#7000"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService")), + % ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +deny_port_range_api(doc) -> ["Deny Access due to invalid local port range"]; +deny_port_range_api(suite) -> []; +deny_port_range_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_INCOMING)}, + {iiop_acl, [{tcp_in, IP++"/128#7000/8000"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + + +deny_host_api(doc) -> ["Deny Access due to invalid host"]; +deny_host_api(suite) -> []; +deny_host_api(_Config) -> + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_INCOMING)}, + {iiop_acl, [{tcp_in, "0:0:0:0:0:0:10.1.1.1/128"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +deny_peerhost_api(doc) -> ["Deny Access due to invalid peer host"]; +deny_peerhost_api(suite) -> []; +deny_peerhost_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, + orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_INCOMING)}, + {iiop_acl, [{tcp_in, IP++"/128", ["0:0:0:0:0:0:10.1.1.1"]}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +%%----------------------------------------------------------------- +%% Incomming connections - Allow +%%----------------------------------------------------------------- +allow_port_range_api(doc) -> ["Allow Access due to valid local port range"]; +allow_port_range_api(suite) -> []; +allow_port_range_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_INCOMING)}, + {iiop_acl, [{tcp_in, IP++"/128#5980/6000"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService")), + ?match(false, corba_object:not_existent(IOR)), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + + +allow_host_api(doc) -> ["Allow Access due to valid host"]; +allow_host_api(suite) -> []; +allow_host_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_INCOMING)}, + {iiop_acl, [{tcp_in, IP++"/128"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService")), + ?match(false, corba_object:not_existent(IOR)), + +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +allow_peerhost_api(doc) -> ["Allow Access due to valid host"]; +allow_peerhost_api(suite) -> []; +allow_peerhost_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_INCOMING)}, + {iiop_acl, [{tcp_in, IP++"/128", [IP]}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService", + [#'IOP_ServiceContext' + {context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, IP}}])), + ?match(false, corba_object:not_existent(IOR, + [#'IOP_ServiceContext' + {context_id=?ORBER_GENERIC_CTX_ID, + context_data = {interface, IP}}])), + +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +%%----------------------------------------------------------------- +%% Test corbaloc strings +%%----------------------------------------------------------------- +check_address_api(doc) -> ["Test corbaloc strings"]; +check_address_api(suite) -> []; +check_address_api(_Config) -> + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:C02A:2A2A",2809]],"NameService"}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:C02A:2A2A/NameService")), + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:C02A:2A2A",2809]],[]}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:C02A:2A2A")), + ?match({[[iiop,{1,2},"0:0:0:0:0:FFFF:C02A:2A2A",2809]],"NameService"}, + orber_cosnaming_utils:addresses(":1.2@0:0:0:0:0:FFFF:C02A:2A2A/NameService")), + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:C02A:2A2A",4001]],"NameService"}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:C02A:2A2A:4001/NameService")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:C02A:2A2A",4001]],"NameService"}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:C02A:2A2A:4001/NameService")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:C02A:2A2A",4001]],[]}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:C02A:2A2A:4001")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:C02A:2A2A",4001]],[]}, + orber_cosnaming_utils:addresses("iiop:1.1@0:0:0:0:0:FFFF:C02A:2A2A:4001")), + + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:10.11.11.11",2809]],"NameService"}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:10.11.11.11/NameService")), + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:10.11.11.11",2809]],[]}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:10.11.11.11")), + ?match({[[iiop,{1,2},"0:0:0:0:0:FFFF:10.11.11.11",2809]],"NameService"}, + orber_cosnaming_utils:addresses(":1.2@0:0:0:0:0:FFFF:10.11.11.11/NameService")), + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:10.11.11.11",4001]],"NameService"}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:10.11.11.11:4001/NameService")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:10.11.11.11",4001]],"NameService"}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:10.11.11.11:4001/NameService")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:10.11.11.11",4001]],[]}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:10.11.11.11:4001/")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:10.11.11.11",4001]],[]}, + orber_cosnaming_utils:addresses("iiop:1.1@0:0:0:0:0:FFFF:10.11.11.11:4001/")), + + ?match({[[iiop,{1,1},"myhost",4001]],[]}, + orber_cosnaming_utils:addresses("iiop:1.1@myhost:4001")), + ?match({[[iiop,{1,1},"myhost.full.name",4001]],"NameService"}, + orber_cosnaming_utils:addresses("iiop:1.1@myhost.full.name:4001/NameService")), + ?match({[[iiop,{1,1},"myhost",4001], + [iiop,{1,1},"myhost.full.name",2809]],"NameService"}, + orber_cosnaming_utils:addresses("iiop:1.1@myhost:4001,iiop:1.1@myhost.full.name/NameService")), + + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:10.11.11.11",4001], + [iiop,{1,1},"0:0:0:0:0:FFFF:C02A:2A2A",4001]], "NameService"}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:10.11.11.11:4001,:1.1@0:0:0:0:0:FFFF:C02A:2A2A:4001/NameService")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:10.11.11.11",4001], + [iiop,{1,1},"0:0:0:0:0:FFFF:C02A:2A2A",4001]], []}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:10.11.11.11:4001,:1.1@0:0:0:0:0:FFFF:C02A:2A2A:4001")), + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:10.11.11.11",4001], + [iiop,{1,1},"0:0:0:0:0:FFFF:C02A:2A2A",4001]], "NameService"}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:10.11.11.11:4001,:1.1@0:0:0:0:0:FFFF:C02A:2A2A:4001/NameService")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:10.11.11.11",4001], + [iiop,{1,0},"0:0:0:0:0:FFFF:C02A:2A2A",4001]], "NameService"}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:10.11.11.11:4001,:0:0:0:0:0:FFFF:C02A:2A2A:4001/NameService")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:10.11.11.11",2809], + [iiop,{1,1},"0:0:0:0:0:FFFF:C02A:2A2A",4001]], "NameService"}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:10.11.11.11,:1.1@0:0:0:0:0:FFFF:C02A:2A2A:4001/NameService")), + ?match({[[iiop,{1,1},"0:0:0:0:0:FFFF:10.11.11.11",4001], + [iiop,{1,1},"0:0:0:0:0:FFFF:C02A:2A2A",2809]], "NameService"}, + orber_cosnaming_utils:addresses(":1.1@0:0:0:0:0:FFFF:10.11.11.11:4001,:1.1@0:0:0:0:0:FFFF:C02A:2A2A/NameService")), + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:10.11.11.11",2809], + [iiop,{1,0},"0:0:0:0:0:FFFF:C02A:2A2A",2809]], "NameService"}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:10.11.11.11,:0:0:0:0:0:FFFF:C02A:2A2A/NameService")), + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:10.11.11.11",2809], + [iiop,{1,0},"0:0:0:0:0:FFFF:C02A:2A2A",2809]], []}, + orber_cosnaming_utils:addresses(":0:0:0:0:0:FFFF:10.11.11.11,:0:0:0:0:0:FFFF:C02A:2A2A/")), + ?match({[[iiop,{1,0},"0:0:0:0:0:FFFF:10.11.11.11",2809], + [iiop,{1,0},"0:0:0:0:0:FFFF:C02A:2A2A",2809]], []}, + orber_cosnaming_utils:addresses("iiop:0:0:0:0:0:FFFF:10.11.11.11,:0:0:0:0:0:FFFF:C02A:2A2A/")), + + [IP] = ?match([_], orber:host()), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_INCOMING)}, + {iiop_acl, [{tcp_in, IP++"/128"}]}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + ?match({'IOP_IOR',_,_}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + + diff --git a/lib/orber/test/orber_firewall_ipv6_out_SUITE.erl b/lib/orber/test/orber_firewall_ipv6_out_SUITE.erl new file mode 100644 index 0000000000..e1856b9a47 --- /dev/null +++ b/lib/orber/test/orber_firewall_ipv6_out_SUITE.erl @@ -0,0 +1,231 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(orber_firewall_ipv6_out_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("orber/src/ifr_objects.hrl"). +-include("idl_output/orber_test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContextExt.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContext.hrl"). + +-define(default_timeout, ?t:minutes(15)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2, + deny_port_api/1, deny_port_range_api/1, deny_host_api/1, + allow_port_api/1, allow_port_range_api/1, allow_host_api/1, + local_interface_api/1]). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for orber's firewall functionallity."]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +%% NOTE - the fragment test cases must bu first since we explicitly set a request +%% id. Otherwise, the request-id counter would be increased and we cannot know +%% what it is. +cases() -> + [deny_port_api, deny_port_range_api, deny_host_api, + allow_port_api, allow_port_range_api, allow_host_api, + local_interface_api]. + + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + orber:jump_start([{iiop_port, 0}, + {iiop_out_ports, {5980, 6000}}, + {flags, ?ORB_ENV_USE_IPV6}]), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + orber:jump_stop(), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + case orber_test_lib:version_ok() of + true -> + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end; + Reason -> + Reason + end. + +finish_all(Config) -> + Config. + + +%%----------------------------------------------------------------- +%% Incomming connections - Deny +%%----------------------------------------------------------------- +deny_port_api(doc) -> ["Deny Access due to invalid local port"]; +deny_port_api(suite) -> []; +deny_port_api(_Config) -> + [IP] = ?match([_], orber:host()), + ServerPort = orber:iiop_port(), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_OUTGOING)}, + {iiop_acl, [{tcp_out, IP++"/128#" ++ integer_to_list(ServerPort+10)}]}])), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + orber_test_lib:remote_apply(ServerNode, corba, string_to_object, + ["corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService"])), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +deny_port_range_api(doc) -> ["Deny Access due to invalid local port range"]; +deny_port_range_api(suite) -> []; +deny_port_range_api(_Config) -> + [IP] = ?match([_], orber:host()), + ServerPort = orber:iiop_port(), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_OUTGOING)}, + {iiop_acl, [{tcp_out, IP++"/128#"++integer_to_list(ServerPort+100)++ "/" ++ integer_to_list(ServerPort+120)}]}])), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + orber_test_lib:remote_apply(ServerNode, corba, string_to_object, + ["corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService"])), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + + +deny_host_api(doc) -> ["Deny Access due to invalid host"]; +deny_host_api(suite) -> []; +deny_host_api(_Config) -> + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_OUTGOING)}, + {iiop_acl, [{tcp_out, "0:0:0:0:0:0:10.1.1.1/128"}]}])), + ServerPort = orber:iiop_port(), + ?match({'EXCEPTION', #'CosNaming_NamingContextExt_InvalidAddress'{}}, + orber_test_lib:remote_apply(ServerNode, corba, string_to_object, + ["corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService"])), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +%%----------------------------------------------------------------- +%% Incomming connections - Allow +%%----------------------------------------------------------------- +allow_port_api(doc) -> ["Allow Access due to valid local port"]; +allow_port_api(suite) -> []; +allow_port_api(_Config) -> + [IP] = ?match([_], orber:host()), + ServerPort = orber:iiop_port(), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_OUTGOING)}, + {iiop_acl, [{tcp_out, IP++"/128#" ++ integer_to_list(ServerPort)}]}])), + IOR = + ?match({'IOP_IOR',_,_}, + orber_test_lib:remote_apply(ServerNode, corba, string_to_object, + ["corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match(false, + orber_test_lib:remote_apply(ServerNode, corba_object, not_existent, [IOR])), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +allow_port_range_api(doc) -> ["Allow Access due to valid local port range"]; +allow_port_range_api(suite) -> []; +allow_port_range_api(_Config) -> + [IP] = ?match([_], orber:host()), + ServerPort = orber:iiop_port(), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_OUTGOING)}, + {iiop_acl, [{tcp_out, IP++"/128#" ++ integer_to_list(ServerPort-10) ++ "/" ++ integer_to_list(ServerPort+10)}]}])), + IOR = + ?match({'IOP_IOR',_,_}, + orber_test_lib:remote_apply(ServerNode, corba, string_to_object, + ["corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match(false, + orber_test_lib:remote_apply(ServerNode, corba_object, not_existent, [IOR])), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + + +allow_host_api(doc) -> ["Allow Access due to valid host"]; +allow_host_api(suite) -> []; +allow_host_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_OUTGOING)}, + {iiop_acl, [{tcp_out, IP}]}])), + ServerPort = orber:iiop_port(), + IOR = + ?match({'IOP_IOR',_,_}, + orber_test_lib:remote_apply(ServerNode, corba, string_to_object, + ["corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match(false, + orber_test_lib:remote_apply(ServerNode, corba_object, not_existent, [IOR])), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + +local_interface_api(doc) -> ["Allow Access due to valid host via a spcific interface"]; +local_interface_api(suite) -> []; +local_interface_api(_Config) -> + [IP] = ?match([_], orber:host()), + {ok, ServerNode, ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, (?ORB_ENV_USE_IPV6 bor + ?ORB_ENV_USE_ACL_OUTGOING)}, + {iiop_acl, [{tcp_out, IP, [IP]}]}])), + ServerPort = orber:iiop_port(), + IOR = + ?match({'IOP_IOR',_,_}, + orber_test_lib:remote_apply(ServerNode, corba, string_to_object, + ["corbaloc::1.2@"++ServerHost++":"++integer_to_list(ServerPort)++"/NameService"])), + ?match(false, + orber_test_lib:remote_apply(ServerNode, corba_object, not_existent, [IOR])), +% ?line catch orber_test_lib:destroy_node(ServerNode, timeout), + ok. + diff --git a/lib/orber/test/orber_nat_SUITE.erl b/lib/orber/test/orber_nat_SUITE.erl new file mode 100644 index 0000000000..5b295dd1aa --- /dev/null +++ b/lib/orber/test/orber_nat_SUITE.erl @@ -0,0 +1,372 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2006-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(orber_nat_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include_lib("orber/src/ifr_objects.hrl"). +-include("idl_output/orber_test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContextExt.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming_NamingContext.hrl"). + + +-define(default_timeout, ?t:minutes(15)). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1, cases/0, init_all/1, finish_all/1, + init_per_testcase/2, fin_per_testcase/2, + nat_ip_address/1, nat_ip_address_multiple/1, + nat_ip_address_local/1, nat_ip_address_local_local/1, + nat_iiop_port/1, nat_iiop_port_local/1, + nat_iiop_port_local_local/1, nat_iiop_ssl_port/1, + nat_iiop_ssl_port_local/1]). + + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["API tests for multi orber interfaces", + "This suite test intra-ORB communication. There are three scenarios:", + "* No security at all (multi_orber_api)", + "* Two secure orbs using ssl (ssl_multi_orb_api)", + "* One secure and one orb with no security. (ssl_multi_orb_api)"]; +all(suite) -> {req, + [mnesia], + {conf, init_all, cases(), finish_all}}. + +cases() -> + [ + nat_ip_address, + nat_ip_address_multiple, + nat_ip_address_local, + nat_iiop_port, + nat_iiop_port_local, + nat_ip_address_local_local, + nat_iiop_port_local_local, + nat_iiop_ssl_port, + nat_iiop_ssl_port_local + ]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + Dog=test_server:timetrap(?default_timeout), + orber:jump_start([{iiop_port, 0}, + {flags, 0}]), + oe_orber_test_server:oe_register(), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + oe_orber_test_server:oe_unregister(), + orber:jump_stop(), + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_all(Config) -> + if + is_list(Config) -> + Config; + true -> + exit("Config not a list") + end. + +finish_all(Config) -> + Config. + +%%----------------------------------------------------------------- +%% API tests for NAT +%%----------------------------------------------------------------- + +nat_ip_address(doc) -> ["This case test if the server ORB use the correct", + "interface when exporting IOR:s"]; +nat_ip_address(suite) -> []; +nat_ip_address(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_ENABLE_NAT}, + {nat_ip_address, Loopback}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {Loopback, ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR)), + ok. + +nat_ip_address_multiple(doc) -> ["This case test if the server ORB use the correct", + "interface when exporting IOR:s"]; +nat_ip_address_multiple(suite) -> []; +nat_ip_address_multiple(_Config) -> + IP = orber_test_lib:get_host(), + + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_ENABLE_NAT}, + {nat_ip_address, {multiple, ["10.0.0.1"]}}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {"10.0.0.1", ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR)), + ok. + +nat_ip_address_local(doc) -> ["This case test if the server ORB use the correct", + "interface when exporting IOR:s"]; +nat_ip_address_local(suite) -> []; +nat_ip_address_local(_Config) -> + IP = orber_test_lib:get_host(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_ENABLE_NAT}, + {nat_ip_address, {local, "10.0.0.1", [{IP, "127.0.0.1"}]}}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {"10.0.0.1", ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR)), + ok. + +nat_ip_address_local_local(doc) -> ["This case test if the server ORB use the correct", + "interface when exporting IOR:s"]; +nat_ip_address_local_local(suite) -> []; +nat_ip_address_local_local(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, + (?ORB_ENV_LOCAL_INTERFACE bor + ?ORB_ENV_ENABLE_NAT)}, + {nat_ip_address, {local, "10.0.0.1", [{IP, "10.0.0.2"}]}}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR1 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {"10.0.0.2", ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR1)), + IOR2 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++Loopback++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {"10.0.0.1", ServerPort, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR2)), + ok. + +nat_iiop_port(doc) -> ["This case test if the server ORB use the correct", + "port when exporting IOR:s"]; +nat_iiop_port(suite) -> []; +nat_iiop_port(_Config) -> + IP = orber_test_lib:get_host(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_ENABLE_NAT}, + {nat_iiop_port, 42}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {_IP, 42, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR)), + ok. + +nat_iiop_port_local(doc) -> ["This case test if the server ORB use the correct", + "port when exporting IOR:s"]; +nat_iiop_port_local(suite) -> []; +nat_iiop_port_local(_Config) -> + IP = orber_test_lib:get_host(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, ?ORB_ENV_ENABLE_NAT}, + {nat_iiop_port, {local, 42, [{4001, 43}]}}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + IOR = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {_IP, 42, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR)), + ok. + +nat_iiop_port_local_local(doc) -> ["This case test if the server ORB use the correct", + "port when exporting IOR:s"]; +nat_iiop_port_local_local(suite) -> []; +nat_iiop_port_local_local(_Config) -> + IP = orber_test_lib:get_host(), + Loopback = orber_test_lib:get_loopback_interface(), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node([{flags, + (?ORB_ENV_LOCAL_INTERFACE bor + ?ORB_ENV_ENABLE_NAT)}, + {ip_address, IP}])), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + orber_test_lib:remote_apply(ServerNode, orber_env, configure_override, [nat_iiop_port, {local, 42, [{ServerPort, 43}]}]), + IOR1 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++IP++":"++integer_to_list(ServerPort)++"/NameService")), + ?match({'external', {IP, 43, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR1)), + {ok, Ref} = ?match({ok, _}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [Loopback, normal, 10088])), + IOR2 = ?match(#'IOP_IOR'{}, + corba:string_to_object("corbaloc::1.2@"++Loopback++":10088/NameService")), + ?match({'external', {IP, 42, _ObjectKey, _Counter, _TP, _NewHD}}, + iop_ior:get_key(IOR2)), + ?match(ok, + orber_test_lib:remote_apply(ServerNode, orber, + remove_listen_interface, [Ref])), + ok. + + +%%----------------------------------------------------------------- +%% API tests for ORB to ORB, ssl security depth 1 +%%----------------------------------------------------------------- + +nat_iiop_ssl_port(doc) -> ["SECURE MULTI ORB API tests (SSL depth 1)", + "Make sure NAT works for SSL"]; +nat_iiop_ssl_port(suite) -> []; +nat_iiop_ssl_port(_Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + IP = orber_test_lib:get_host(), + ServerOptions = orber_test_lib:get_options(iiop_ssl, server, + 1, [{iiop_ssl_port, 0}, + {flags, ?ORB_ENV_ENABLE_NAT}, + {ip_address, IP}]), + ClientOptions = orber_test_lib:get_options(iiop_ssl, client, + 1, [{iiop_ssl_port, 0}]), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node(ServerOptions)), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + SSLServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_ssl_port, []), + NATSSLServerPort = SSLServerPort+1, + {ok, Ref} = ?match({ok, _}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [IP, ssl, NATSSLServerPort])), + orber_test_lib:remote_apply(ServerNode, orber_env, configure_override, + [nat_iiop_ssl_port, + {local, NATSSLServerPort, [{4001, 43}]}]), + + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node(ClientOptions)), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [ssl])), + + IOR1 = ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, + string_to_object, + ["corbaname::1.2@"++IP++":"++ + integer_to_list(ServerPort)++"/NameService#mamba"])), + + ?match({'external', {_IP, _Port, _ObjectKey, _Counter, _TP, + #host_data{protocol = ssl, + ssl_data = #'SSLIOP_SSL'{port = NATSSLServerPort}}}}, + iop_ior:get_key(IOR1)), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + uninstall_test_data, + [ssl])), + ?match(ok, + orber_test_lib:remote_apply(ServerNode, orber, + remove_listen_interface, [Ref])), + ok + end. + +nat_iiop_ssl_port_local(doc) -> ["SECURE MULTI ORB API tests (SSL depth 1)", + "Make sure NAT works for SSL"]; +nat_iiop_ssl_port_local(suite) -> []; +nat_iiop_ssl_port_local(_Config) -> + case os:type() of + vxworks -> + {skipped, "No SSL-support for VxWorks."}; + _ -> + IP = orber_test_lib:get_host(), + ServerOptions = orber_test_lib:get_options(iiop_ssl, server, + 1, [{iiop_ssl_port, 0}, + {flags, + (?ORB_ENV_LOCAL_INTERFACE bor + ?ORB_ENV_ENABLE_NAT)}, + {ip_address, IP}]), + ClientOptions = orber_test_lib:get_options(iiop_ssl, client, + 1, [{iiop_ssl_port, 0}]), + {ok, ServerNode, _ServerHost} = + ?match({ok,_,_}, orber_test_lib:js_node(ServerOptions)), + ServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_port, []), + SSLServerPort = orber_test_lib:remote_apply(ServerNode, orber, iiop_ssl_port, []), + NATSSLServerPort = SSLServerPort+1, + {ok, Ref} = ?match({ok, _}, + orber_test_lib:remote_apply(ServerNode, orber, + add_listen_interface, + [IP, ssl, NATSSLServerPort])), + orber_test_lib:remote_apply(ServerNode, orber_env, configure_override, + [nat_iiop_ssl_port, + {local, NATSSLServerPort, [{NATSSLServerPort, NATSSLServerPort}]}]), + + {ok, ClientNode, _ClientHost} = + ?match({ok,_,_}, orber_test_lib:js_node(ClientOptions)), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + install_test_data, + [ssl])), + + IOR1 = ?match(#'IOP_IOR'{}, + orber_test_lib:remote_apply(ClientNode, corba, + string_to_object, + ["corbaname::1.2@"++IP++":"++ + integer_to_list(ServerPort)++"/NameService#mamba"])), + + ?match({'external', {_IP, _Port, _ObjectKey, _Counter, _TP, + #host_data{protocol = ssl, + ssl_data = #'SSLIOP_SSL'{port = NATSSLServerPort}}}}, + iop_ior:get_key(IOR1)), + ?match(ok, orber_test_lib:remote_apply(ServerNode, orber_test_lib, + uninstall_test_data, + [ssl])), + ?match(ok, + orber_test_lib:remote_apply(ServerNode, orber, + remove_listen_interface, [Ref])), + ok + end. + diff --git a/lib/orber/test/orber_test.idl b/lib/orber/test/orber_test.idl new file mode 100644 index 0000000000..3d943f2d18 --- /dev/null +++ b/lib/orber/test/orber_test.idl @@ -0,0 +1,95 @@ +// +// %CopyrightBegin% +// +// Copyright Ericsson AB 1997-2010. All Rights Reserved. +// +// The contents of this file are subject to the Erlang Public License, +// Version 1.1, (the "License"); you may not use this file except in +// compliance with the License. You should have received a copy of the +// Erlang Public License along with this software. If not, it can be +// retrieved online at http://www.erlang.org/. +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +// the License for the specific language governing rights and limitations +// under the License. +// +// %CopyrightEnd% +// +module Module +{ + + enum Enum {horse, pig, cow}; + + struct Struct0 { + long l; + short s; + char c; + }; + + struct Struct1 { + string s; + unsigned short us; + unsigned long ul; + }; + + struct Struct2 { + sequence <long> long_sequence; + Enum e; + octet o; + }; + + struct HEADER { + short EID; + short NDW; + short SSID; + }; + + enum Enum1 {orange,banana, apple}; + + union Union switch (short) { + case 0: short First; + case 1: string Second; + case 2: char Third; + }; + + union Union1 switch (Enum){ + case horse: short horse; + case pig: sequence <string> Second; + case cow: Enum1 Third; + }; + + union Union2 switch (Enum){ + case horse: long a[10]; + case pig: Union u; + case cow: Union1 u1; + }; + + exception Except1 { + string why; + sequence <string> rest_of_name; + }; + + exception Except2 { + Enum1 e; + Struct2 s; + }; + + exception Except3 { + Union1 u; + unsigned short s; + Object o ; + }; + + exception Except4 {}; + + interface I1 { + void a(); + }; + + interface I2 { + void a(); + }; + +}; + diff --git a/lib/orber/test/orber_test_lib.erl b/lib/orber/test/orber_test_lib.erl new file mode 100644 index 0000000000..a694dc58c4 --- /dev/null +++ b/lib/orber/test/orber_test_lib.erl @@ -0,0 +1,1498 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(orber_test_lib). +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/include/ifr_types.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). +-include("idl_output/orber_test_server.hrl"). +-include_lib("orber/COSS/CosNaming/CosNaming.hrl"). + +-define(match(ExpectedRes,Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-export([js_node/2, + js_node/1, + js_node/0, + slave_sup/0, + remote_apply/4, + install_test_data/1, + light_tests/3, + uninstall_test_data/1, + destroy_node/2, + lookup/2, + alternate_iiop_address/2, + create_alternate_iiop_address/2, + alternate_ssl_iiop_address/3, + create_alternate_ssl_iiop_address/3, + test_coding/1, + test_coding/2, + corba_object_tests/2, + timeouts/3, + precond/3, + postcond/4, + oe_get_interface/0, + create_components_IOR/1, + get_options/2, + get_options/3, + get_options/4, + version_ok/0, + ssl_version/0, + get_loopback_interface/0, + get_loopback_interface/1, + get_host/0, + get_host/1]). + +%% Interceptor functions. +-export([new_out_connection/3, + new_in_connection/3, + closed_in_connection/1, + closed_out_connection/1, + in_request_encoded/6, + in_reply_encoded/6, + out_reply_encoded/6, + out_request_encoded/6, + in_request/6, + in_reply/6, + out_reply/6, + out_request/6]). + +%%------------------------------------------------------------ +%% function : ssl_version +%% Arguments: +%% Returns : integer() +%% Effect : +%% +%%------------------------------------------------------------ +ssl_version() -> + case catch erlang:system_info(otp_release) of + Version when is_list(Version) -> + if + "R12B" < Version -> + 3; + true -> + 2 + end; + _ -> + 2 + end. + +%%------------------------------------------------------------ +%% function : version_ok +%% Arguments: +%% Returns : true | {skipped, Reason} +%% Effect : +%% +%%------------------------------------------------------------ +version_ok() -> + {ok, Hostname} = inet:gethostname(), + case inet:getaddr(Hostname, inet6) of + {error,nxdomain} -> + {skipped, "Inet cannot handle IPv6"}; + _ -> + case inet:getaddr("0:0:0:0:0:FFFF:127.0.0.1", inet6) of + {error,nxdomain} -> + {skipped, "Inet cannot handle IPv6"}; + _ -> + case gen_tcp:listen(0, [{reuseaddr, true}, inet6]) of + {ok, LSock} -> + gen_tcp:close(LSock), + true; + {error, _} -> + {skipped, "Inet cannot handle IPv6"} + end + end + end. +%%------------------------------------------------------------ +%% function : get_host +%% Arguments: Family - inet | inet6 +%% Returns : string() +%% Effect : +%% +%%------------------------------------------------------------ +get_host() -> + get_host(inet). +get_host(Family) -> + case os:type() of + {win32, _} -> + case os:version() of + {6, _, _} when Family == inet -> + "127.0.0.1"; + {6, _, _} -> + "0:0:0:0:0:FFFF:7F00:0001"; + _ -> + [IP] = ?match([_], orber:host()), + IP + end; + _ -> + [IP] = ?match([_], orber:host()), + IP + end. + +%%------------------------------------------------------------ +%% function : get_loopback_interface +%% Arguments: Family - inet | inet6 +%% Returns : string() +%% Effect : +%% +%%------------------------------------------------------------ +get_loopback_interface() -> + get_loopback_interface(inet). +get_loopback_interface(Family) -> + case os:type() of + {win32, _} -> + case os:version() of + {6, _, _} when Family == inet -> + "127.0.0.2"; + {6, _, _} -> + "0:0:0:0:0:FFFF:7F00:0002"; + _ when Family == inet -> + "127.0.0.1"; + _ -> + "0:0:0:0:0:FFFF:7F00:0001" + end; + _ when Family == inet -> + "127.0.0.1"; + _ -> + "0:0:0:0:0:FFFF:7F00:0001" + end. + +%%------------------------------------------------------------ +%% function : js_node/4 +%% Arguments: Port - which iiop_port (integer()) +%% InitOptions - [{Key, Value}] +%% {Type, StartOptions} - {lightweight, [{Key, Value}]} +%% Returns : {ok, Node} | {error, _} +%% Effect : Starts a new slave-node with given (optinally) +%% extra arguments. If fails it retries 'Retries' times. +%%------------------------------------------------------------ +js_node() -> + js_node([], []). + +js_node(InitOptions) when is_list(InitOptions) -> + js_node(InitOptions, []). + +js_node(InitOptions, StartOptions) when is_list(InitOptions) -> + {A,B,C} = erlang:now(), + [_, Host] = string:tokens(atom_to_list(node()), [$@]), + _NewInitOptions = check_options(InitOptions), + js_node_helper(Host, 0, lists:concat([A,'_',B,'_',C]), + InitOptions, 10, StartOptions). + +js_node_helper(Host, Port, Name, Options, Retries, StartOptions) -> + case starter(Host, Name, create_paths()) of + {ok, NewNode} -> + case net_adm:ping(NewNode) of + pong -> + start_ssl(lists:member({secure, ssl}, Options), NewNode), + {ok, Cwd} = file:get_cwd(), + Path = code:get_path(), + ok = rpc:call(NewNode, file, set_cwd, [Cwd]), + true = rpc:call(NewNode, code, set_path, [Path]), + rpc:call(NewNode, application, load, [orber]), + ok = rpc:call(NewNode, corba, orb_init, + [[{iiop_port, Port}, + {orber_debug_level, 10}|Options]]), + start_orber(StartOptions, NewNode), + spawn_link(NewNode, ?MODULE, slave_sup, []), + rpc:multicall([node() | nodes()], global, sync, []), + ok = rpc:call(NewNode, orber, info, [io]), + {ok, NewNode, Host}; + _ -> + {error, "net_adm:ping(Node) failed"} + end; + {error, Reason} when Retries == 0 -> + {error, Reason}; + {error, Reason} -> + io:format("Could not start slavenode ~p:~p due to: ~p~n", + [Host, Port, Reason]), + timer:sleep(500), + js_node_helper(Host, Port, Name, Options, Retries-1, StartOptions) + end. + +check_options(Options) -> + case {os:type(), os:version()} of + {{win32, _}, {6, _, _}} -> + %% Vista, need to run additional checks. + case {orber_tb:keysearch(ip_address, Options), + orber_tb:keysearch(flags, Options, 0)} of + {undefined, Flags} -> + case ?ORB_FLAG_TEST(Flags, ?ORB_ENV_USE_IPV6) of + true -> + [{ip_address, get_host(inet6)}|Options]; + false -> + [{ip_address, get_host(inet)}|Options] + end; + _ -> + Options + end; + _ -> + Options + end. + +starter(Host, Name, Args) -> + case os:type() of + vxworks -> + test_server:start_node(Name, slave, [{args,Args}]); + _ -> + slave:start_link(Host, Name, Args) + end. + +slave_sup() -> + process_flag(trap_exit, true), + receive + {'EXIT', _, _} -> + case os:type() of + vxworks -> + erlang:halt(); + _ -> + ignore + end + end. + +start_ssl(true, Node) -> + rpc:call(Node, ssl, start, []), + rpc:call(Node, crypto, start, []), + rpc:call(Node, ssl, seed, ["testing"]); +start_ssl(_, _) -> + ok. + +start_orber({lightweigth, Options}, Node) -> + ok = rpc:call(Node, orber, start_lightweight, [Options]); +start_orber(lightweight, Node) -> + ok = rpc:call(Node, orber, start_lightweight, []); +start_orber(_, Node) -> + ok = rpc:call(Node, orber, jump_start, []). + + +%%----------------------------------------------------------------- +%% Type - ssl | iiop_ssl +%% Role - 'server' | 'client' +%% Options - [{Key, Value}] +%%----------------------------------------------------------------- +get_options(Type, Role) -> + get_options(Type, Role, 2, []). + +get_options(ssl, Role, Level) -> + get_options(ssl, Role, Level, []). + +get_options(ssl, Role, 2, Options) -> + Dir = filename:join([code:lib_dir(ssl), "examples", "certs", "etc"]), + [{depth, 2}, + {verify, 2}, + {keyfile, filename:join([Dir, Role, "key.pem"])}, + {cacertfile, filename:join([Dir, Role, "cacerts.pem"])}, + {certfile, filename:join([Dir, Role, "cert.pem"])}|Options]; +get_options(iiop_ssl, _Role, 2, Options) -> + Dir = filename:join([code:lib_dir(ssl), "examples", "certs", "etc"]), + [{ssl_server_depth, 2}, + {ssl_server_verify, 2}, + {ssl_server_certfile, filename:join([Dir, "server", "cert.pem"])}, + {ssl_server_cacertfile, filename:join([Dir, "server", "cacerts.pem"])}, + {ssl_server_keyfile, filename:join([Dir, "server", "key.pem"])}, + {ssl_client_depth, 2}, + {ssl_client_verify, 2}, + {ssl_client_certfile, filename:join([Dir, "client", "cert.pem"])}, + {ssl_client_cacertfile, filename:join([Dir, "client", "cacerts.pem"])}, + {ssl_client_keyfile, filename:join([Dir, "client", "key.pem"])}, + {secure, ssl}|Options]; +get_options(iiop_ssl, _Role, 1, Options) -> + Dir = filename:join([code:lib_dir(ssl), "examples", "certs", "etc"]), + [{ssl_server_depth, 1}, + {ssl_server_verify, 0}, + {ssl_server_certfile, filename:join([Dir, "server", "cert.pem"])}, + {ssl_server_cacertfile, filename:join([Dir, "server", "cacerts.pem"])}, + {ssl_server_keyfile, filename:join([Dir, "server", "key.pem"])}, + {ssl_client_depth, 1}, + {ssl_client_verify, 0}, + {ssl_client_certfile, filename:join([Dir, "client", "cert.pem"])}, + {ssl_client_cacertfile, filename:join([Dir, "client", "cacerts.pem"])}, + {ssl_client_keyfile, filename:join([Dir, "client", "key.pem"])}, + {secure, ssl}|Options]. + + +create_paths() -> + Path = filename:dirname(code:which(?MODULE)), + " -pa " ++ Path ++ " -pa " ++ + filename:join(Path, "idl_output") ++ + " -pa " ++ + filename:join(Path, "all_SUITE_data") ++ + " -pa " ++ + filename:dirname(code:which(orber)). + +%%------------------------------------------------------------ +%% function : destroy_node +%% Arguments: Node - which node to destroy. +%% Type - normal | ssl +%% Returns : +%% Effect : +%%------------------------------------------------------------ + +destroy_node(Node, Type) -> + stopper(Node, Type). + +stopper(Node, _Type) -> + case os:type() of + vxworks -> + test_server:stop_node(Node); + _ -> + slave:stop(Node) + end. + + +%%------------------------------------------------------------ +%% function : remote_apply +%% Arguments: N - Node, M - Module, +%% F - Function, A - Arguments (list) +%% Returns : +%% Effect : +%%------------------------------------------------------------ +remote_apply(N, M,F,A) -> + case rpc:call(N, M, F, A) of + {badrpc, Reason} -> + exit(Reason); + Other -> + Other + end. + + + +%%------------------------------------------------------------ +%% function : install_test_data +%% Arguments: WhichSuite +%% Returns : ok +%% Effect : Installs test data associated with 'WhichSuite' +%%------------------------------------------------------------ + +install_test_data(nameservice) -> + oe_orber_test_server:oe_register(), + Mamba = orber_test_server:oe_create([], [{regname, {local, mamba}}]), + true = corba:add_initial_service("Mamba", Mamba), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N = lname:insert_component(lname:create(), 1, NC1), + 'CosNaming_NamingContext':bind(NS, N,Mamba); + +install_test_data({nameservice, AltAddr, AltPort}) -> + oe_orber_test_server:oe_register(), + Obj = orber_test_server:oe_create([], [{regname, {local, mamba}}]), + Mamba = corba:add_alternate_iiop_address(Obj, AltAddr, AltPort), + true = corba:add_initial_service("Mamba", Mamba), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N = lname:insert_component(lname:create(), 1, NC1), + 'CosNaming_NamingContext':bind(NS, N,Mamba); + +install_test_data(timeout) -> + oe_orber_test_server:oe_register(), + Mamba = orber_test_server:oe_create([], {local, mamba}), + Viper = orber_test_timeout_server:oe_create([], {local, viper}), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N1 = lname:insert_component(lname:create(), 1, NC1), + NC2 = lname_component:set_id(lname_component:create(), "viper"), + N2 = lname:insert_component(lname:create(), 1, NC2), + 'CosNaming_NamingContext':bind(NS, N1, Mamba), + 'CosNaming_NamingContext':bind(NS, N2, Viper); + +install_test_data(pseudo) -> + oe_orber_test_server:oe_register(), + Mamba = orber_test_server:oe_create([], [{pseudo,true}]), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N = lname:insert_component(lname:create(), 1, NC1), + 'CosNaming_NamingContext':bind(NS, N,Mamba); + +install_test_data(ssl) -> + oe_orber_test_server:oe_register(), + Mamba = orber_test_server:oe_create([], [{regname, {local, mamba}}]), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N = lname:insert_component(lname:create(), 1, NC1), + 'CosNaming_NamingContext':bind(NS, N,Mamba); + +install_test_data(ssl_simple) -> + oe_orber_test_server:oe_register(); + +install_test_data(light) -> + %% Nothing to do at the moment but we might in the future + ok; + +install_test_data(_) -> + {error, "no_implement"}. + + +%%------------------------------------------------------------ +%% function : uninstall_test_data +%% Arguments: WhichSuite +%% Returns : ok +%% Effect : Uninstalls test data associated with 'WhichSuite' +%%------------------------------------------------------------ + +uninstall_test_data(pseudo) -> + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N = lname:insert_component(lname:create(), 1, NC1), + _Obj = (catch 'CosNaming_NamingContext':resolve(NS, N)), + catch 'CosNaming_NamingContext':destroy(NS), + oe_orber_test_server:oe_unregister(); + +uninstall_test_data(timeout) -> + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N1 = lname:insert_component(lname:create(), 1, NC1), + + NC2 = lname_component:set_id(lname_component:create(), "viper"), + N2 = lname:insert_component(lname:create(), 1, NC2), + Mamba = (catch 'CosNaming_NamingContext':resolve(NS, N1)), + Viper = (catch 'CosNaming_NamingContext':resolve(NS, N2)), + catch corba:dispose(Mamba), + catch corba:dispose(Viper), + catch 'CosNaming_NamingContext':destroy(NS), + oe_orber_test_server:oe_unregister(); + +uninstall_test_data(nameservice) -> + true = corba:remove_initial_service("Mamba"), + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N = lname:insert_component(lname:create(), 1, NC1), + Obj = (catch 'CosNaming_NamingContext':resolve(NS, N)), + catch corba:dispose(Obj), + catch 'CosNaming_NamingContext':destroy(NS), + oe_orber_test_server:oe_unregister(); + +uninstall_test_data(ssl) -> + NS = corba:resolve_initial_references("NameService"), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N = lname:insert_component(lname:create(), 1, NC1), + Obj = (catch 'CosNaming_NamingContext':resolve(NS, N)), + catch corba:dispose(Obj), + catch 'CosNaming_NamingContext':destroy(NS), + oe_orber_test_server:oe_unregister(); + +uninstall_test_data(ssl_simple) -> + oe_orber_test_server:oe_unregister(); + +uninstall_test_data(light) -> + %% Nothing to do at the moment but we might in the future + ok; + +uninstall_test_data(_) -> + {error, "no_implement"}. + +%%------------------------------------------------------------ +%% function : corba_object_tests +%% Arguments: TestServerObj a orber_test_server ref +%% OtherObj - any other Orber object. +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ + +corba_object_tests(TestServerObj, OtherObj) -> + ?match(false, + corba_object:is_a(TestServerObj, "IDL:orber_parent/inherrit:1.0")), + ?match(true, + corba_object:is_a(TestServerObj, "IDL:omg.org/orber_parent/inherrit:1.0")), + ?match(true, + corba_object:is_a(TestServerObj, "IDL:omg.org/orber_test/server:1.0")), + ?match(false, + corba_object:is_a(TestServerObj, "IDL:orber_test/server:1.0")), + ?match(false, + corba_object:is_a(TestServerObj, "IDL:omg.org/orber_parent/inherrit:1.1")), + ?match(false, + corba_object:is_a(TestServerObj, "NotValidIFRID")), + ?match(false, + corba_object:is_nil(TestServerObj)), + ?match(false, + corba_object:is_equivalent(OtherObj,TestServerObj)), + ?match(true, + corba_object:is_equivalent(TestServerObj,TestServerObj)), + ?match(false, corba_object:non_existent(TestServerObj)), + ?match(false, corba_object:not_existent(TestServerObj)), + ?match(#fullinterfacedescription{}, corba_object:get_interface(TestServerObj)), + + ok. + +%%------------------------------------------------------------ +%% function : lookup +%% Arguments: Port - which port the other orb uses. +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ + +lookup(Host, Port) -> + Key = Host++":"++integer_to_list(Port), + NSR = corba:resolve_initial_references_remote("NameService", + ["iiop://"++Key]), + + NC1 = lname_component:set_id(lname_component:create(), "not_exist"), + N1 = lname:insert_component(lname:create(), 1, NC1), + ?match({'EXCEPTION',{'CosNaming_NamingContext_NotFound',_,_,_}}, + 'CosNaming_NamingContext':resolve(NSR, N1)), + + NC2 = lname_component:set_id(lname_component:create(), "mamba"), + N2 = lname:insert_component(lname:create(), 1, NC2), + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + 'CosNaming_NamingContext':resolve(NSR, N2)), + orber_test_server:print(Obj), + Obj2 = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + corba:string_to_object("corbaname:iiop:1.1@"++Key++"/NameService#mamba")), + + orber_test_server:print(Obj2), + + NSR2 = ?match({'IOP_IOR',"IDL:omg.org/CosNaming/NamingContextExt:1.0",_}, + corba:string_to_object("corbaloc:iiop:1.1@"++Key++"/NameService")), + Obj3 = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + 'CosNaming_NamingContext':resolve(NSR2, N2)), + orber_test_server:print(Obj3). + +%%------------------------------------------------------------ +%% function : alternate_iiop_address +%% Arguments: Port - which port the other orb uses. +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ +alternate_iiop_address(Host, Port) -> + IOR = create_alternate_iiop_address(Host, Port), + + ?match(false, corba_object:non_existent(IOR)), + ?match({'object_forward',_}, corba:locate(IOR)), + ?match({'object_forward',_}, corba:locate(IOR, 10000)), + ok. + +%%------------------------------------------------------------ +%% function : create_alternate_iiop_address +%% Arguments: Port - which port the other orb uses. +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ +create_alternate_iiop_address(Host, Port) -> + MC = [#'IOP_TaggedComponent'{tag = ?TAG_ORB_TYPE, + component_data = ?ORBER_ORB_TYPE_1}, + #'IOP_TaggedComponent'{tag = ?TAG_CODE_SETS, + component_data = ?DEFAULT_CODESETS}, + #'IOP_TaggedComponent'{tag = ?TAG_ALTERNATE_IIOP_ADDRESS, + component_data = #'ALTERNATE_IIOP_ADDRESS'{ + 'HostID' = Host, + 'Port' = Port}}, + #'IOP_TaggedComponent'{tag = ?TAG_ALTERNATE_IIOP_ADDRESS, + component_data = #'ALTERNATE_IIOP_ADDRESS'{ + 'HostID' = Host, + 'Port' = 8000}}, + #'IOP_TaggedComponent'{tag = ?TAG_ALTERNATE_IIOP_ADDRESS, + component_data = #'ALTERNATE_IIOP_ADDRESS'{ + 'HostID' = Host, + 'Port' = 8000}}], + #'IOP_IOR'{type_id=TypeID, + profiles=P1} = _IORA = iop_ior:create({1,2}, + "IDL:omg.org/CosNaming/NamingContextExt:1.0", + [Host], 8000, -1, + "NameService", MC, 0, 0), + #'IOP_IOR'{profiles=P2} = _IORB = iop_ior:create({1,1}, + "IDL:omg.org/CosNaming/NamingContextExt:1.0", + [Host], 8000, -1, + "NameService", [], 0, 0), + #'IOP_IOR'{type_id=TypeID, profiles=P2++P1}. + + +%%------------------------------------------------------------ +%% function : create_components_IOR +%% Arguments: +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ +create_components_IOR(Version) -> + MC = [#'IOP_TaggedComponent'{tag = ?TAG_ORB_TYPE, + component_data = ?ORBER_ORB_TYPE_1}, + #'IOP_TaggedComponent'{tag = ?TAG_CODE_SETS, + component_data = ?DEFAULT_CODESETS}, + #'IOP_TaggedComponent'{tag = ?TAG_ALTERNATE_IIOP_ADDRESS, + component_data = #'ALTERNATE_IIOP_ADDRESS'{ + 'HostID' = "127.0.0.1", + 'Port' = 4001}}, + #'IOP_TaggedComponent'{tag = ?TAG_SSL_SEC_TRANS, + component_data = #'SSLIOP_SSL'{target_supports = 0, + target_requires = 1, + port = 2}}, + #'IOP_TaggedComponent'{tag = ?TAG_FT_GROUP, + component_data = + #'FT_TagFTGroupTaggedComponent' + {version = #'GIOP_Version'{major = 1, + minor = 2}, + ft_domain_id = "FT_FTDomainId", + object_group_id = ?ULONGLONGMAX, + object_group_ref_version = ?LONGMAX}}, + #'IOP_TaggedComponent'{tag = ?TAG_FT_PRIMARY, + component_data = + #'FT_TagFTPrimaryTaggedComponent'{primary = true}}, + #'IOP_TaggedComponent'{tag = ?TAG_FT_HEARTBEAT_ENABLED, + component_data = + #'FT_TagFTHeartbeatEnabledTaggedComponent'{heartbeat_enabled = true}}, + #'IOP_TaggedComponent'{tag = ?TAG_CSI_SEC_MECH_LIST, + component_data = + #'CSIIOP_CompoundSecMechList' + {stateful = false, + mechanism_list = + [#'CSIIOP_CompoundSecMech' + {target_requires = 6, + transport_mech = + #'IOP_TaggedComponent' + {tag=?TAG_TLS_SEC_TRANS, + component_data=#'CSIIOP_TLS_SEC_TRANS' + {target_supports = 7, + target_requires = 8, + addresses = + [#'CSIIOP_TransportAddress'{host_name = "127.0.0.1", + port = 6001}]}}, + as_context_mech = + #'CSIIOP_AS_ContextSec' + {target_supports = 9, target_requires = 10, + client_authentication_mech = [1, 255], + target_name = [2,255]}, + sas_context_mech = + #'CSIIOP_SAS_ContextSec' + {target_supports = 11, target_requires = 12, + privilege_authorities = + [#'CSIIOP_ServiceConfiguration' + {syntax = ?ULONGMAX, + name = [3,255]}], + supported_naming_mechanisms = [[4,255],[5,255]], + supported_identity_types = ?ULONGMAX}}, + #'CSIIOP_CompoundSecMech' + {target_requires = 6, + transport_mech = + #'IOP_TaggedComponent' + {tag=?TAG_NULL_TAG, + component_data=[]}, + as_context_mech = + #'CSIIOP_AS_ContextSec' + {target_supports = 9, target_requires = 10, + client_authentication_mech = [1, 255], + target_name = [2,255]}, + sas_context_mech = + #'CSIIOP_SAS_ContextSec' + {target_supports = 11, target_requires = 12, + privilege_authorities = + [#'CSIIOP_ServiceConfiguration' + {syntax = ?ULONGMAX, + name = [3,255]}], + supported_naming_mechanisms = [[4,255],[5,255]], + supported_identity_types = ?ULONGMAX}}, + #'CSIIOP_CompoundSecMech' + {target_requires = 6, + transport_mech = + #'IOP_TaggedComponent' + {tag=?TAG_SECIOP_SEC_TRANS, + component_data=#'CSIIOP_SECIOP_SEC_TRANS' + {target_supports = 7, + target_requires = 8, + mech_oid = [0,255], + target_name = [0,255], + addresses = + [#'CSIIOP_TransportAddress'{host_name = "127.0.0.1", + port = 6001}]}}, + as_context_mech = + #'CSIIOP_AS_ContextSec' + {target_supports = 9, target_requires = 10, + client_authentication_mech = [1, 255], + target_name = [2,255]}, + sas_context_mech = + #'CSIIOP_SAS_ContextSec' + {target_supports = 11, target_requires = 12, + privilege_authorities = + [#'CSIIOP_ServiceConfiguration' + {syntax = ?ULONGMAX, + name = [3,255]}], + supported_naming_mechanisms = [[4,255],[5,255]], + supported_identity_types = ?ULONGMAX}}]}}], + iop_ior:create(Version, "IDL:omg.org/CosNaming/NamingContextExt:1.0", + ["127.0.0.1"], 5001, -1, + "NameService", MC, 0, 0). + + +%%------------------------------------------------------------ +%% function : alternate_ssl_iiop_address +%% Arguments: Port - which port the other orb uses. +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ +alternate_ssl_iiop_address(Host, Port, SSLPort) -> + IOR = create_alternate_ssl_iiop_address(Host, Port, SSLPort), + + ?match(false, corba_object:non_existent(IOR)), + ?match({'object_forward',_}, corba:locate(IOR)), + ?match({'object_forward',_}, corba:locate(IOR, 10000)), + ok. + + +%%------------------------------------------------------------ +%% function : create_alternate_ssl_iiop_address +%% Arguments: Port - which port the other orb uses. +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ +create_alternate_ssl_iiop_address(Host, Port, SSLPort) -> + MC = [#'IOP_TaggedComponent'{tag = ?TAG_ORB_TYPE, + component_data = ?ORBER_ORB_TYPE_1}, + #'IOP_TaggedComponent'{tag = ?TAG_CODE_SETS, + component_data = ?DEFAULT_CODESETS}, + #'IOP_TaggedComponent'{tag = ?TAG_ALTERNATE_IIOP_ADDRESS, + component_data = #'ALTERNATE_IIOP_ADDRESS'{ + 'HostID' = Host, + 'Port' = Port}}, + #'IOP_TaggedComponent'{tag = ?TAG_ALTERNATE_IIOP_ADDRESS, + component_data = #'ALTERNATE_IIOP_ADDRESS'{ + 'HostID' = Host, + 'Port' = 8000}}, + #'IOP_TaggedComponent'{tag = ?TAG_ALTERNATE_IIOP_ADDRESS, + component_data = #'ALTERNATE_IIOP_ADDRESS'{ + 'HostID' = Host, + 'Port' = 8000}}, + #'IOP_TaggedComponent'{tag=?TAG_SSL_SEC_TRANS, + component_data=#'SSLIOP_SSL'{target_supports = 2, + target_requires = 2, + port = SSLPort}}], + #'IOP_IOR'{type_id=TypeID, + profiles=P1} = _IORA = iop_ior:create_external({1,2}, + "IDL:omg.org/CosNaming/NamingContextExt:1.0", + Host, 8000, + "NameService", MC), + #'IOP_IOR'{profiles=P2} = _IORB = iop_ior:create_external({1,1}, + "IDL:omg.org/CosNaming/NamingContextExt:1.0", + Host, 8000, + "NameService", []), + #'IOP_IOR'{type_id=TypeID, profiles=P2++P1}. + + +%%------------------------------------------------------------ +%% function : timeouts +%% Arguments: Port - which port the other orb uses. +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ + +timeouts(Host, Port, ReqT) -> + NSR = corba:resolve_initial_references_remote("NameService", + ["iiop://"++Host++":"++integer_to_list(Port)]), + NC1 = lname_component:set_id(lname_component:create(), "mamba"), + N1 = lname:insert_component(lname:create(), 1, NC1), + NC2 = lname_component:set_id(lname_component:create(), "viper"), + N2 = lname:insert_component(lname:create(), 1, NC2), + Mamba = 'CosNaming_NamingContext':resolve(NSR, N1), + Viper = 'CosNaming_NamingContext':resolve(NSR, N2), + + ?match({'EXCEPTION',{'TIMEOUT',_,_,_}}, + orber_test_timeout_server:twoway_function(Viper, ReqT, ReqT*2)), + ?match(ok, orber_test_timeout_server:oneway_function(Viper, ReqT*2)), + + ?match({'EXCEPTION',{'TIMEOUT',_,_,_}}, + orber_test_server:testing_iiop_twoway_delay(Mamba, ReqT)), + ?match(ok, orber_test_server:testing_iiop_oneway_delay(Mamba, ReqT)), + + %% Since the objects are stalled we must wait until they are available again + %% to be able to run any more tests and get the correct results. + timer:sleep(ReqT*4), + + ?match(ok, orber_test_timeout_server:twoway_function(Viper, ReqT*2, ReqT)), + ?match(ok, orber_test_timeout_server:oneway_function(Viper, ReqT*2)), + + ?match(ok, orber_test_server:testing_iiop_twoway_delay(Mamba, 0)), + ?match(ok, orber_test_server:testing_iiop_oneway_delay(Mamba, 0)), + + timer:sleep(ReqT*4), + ok. + +%%------------------------------------------------------------ +%% function : light_tests +%% Arguments: Host - which node to contact. +%% Port - which port the other orb uses. +%% Returns : term() +%% Effect : +%%------------------------------------------------------------ + +light_tests(Host, Port, ObjName) -> + NSR = corba:resolve_initial_references_remote("NameService", + ["iiop://"++Host++":"++integer_to_list(Port)]), + NC1 = lname_component:set_id(lname_component:create(), "not_exist"), + N1 = lname:insert_component(lname:create(), 1, NC1), + %% We cannot handle any unknown replies (besides those found in stub). + ?match({'EXCEPTION', + {'CosNaming_NamingContext_NotFound', + "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0",_,_}}, + 'CosNaming_NamingContext':resolve(NSR, N1)), + NC2 = lname_component:set_id(lname_component:create(), ObjName), + N2 = lname:insert_component(lname:create(), 1, NC2), + Obj = ?match({'IOP_IOR',"IDL:omg.org/orber_test/server:1.0",_}, + 'CosNaming_NamingContext':resolve(NSR, N2)), + Nodes = orber:get_lightweight_nodes(), + io:format("Light Nodes: ~p~n", [Nodes]), + orber_test_server:print(Obj), + test_coding(Obj), + ok. + + +%%------------------------------------------------------------ +%% function : test_coding_simple +%% Arguments: ObjReference +%% Returns : term() +%% Effect : test encode/decode for all simple datatypes. +%%------------------------------------------------------------ + +test_coding(Obj) -> + test_coding(Obj, false). + +test_coding(Obj, Local) -> + %%--- Testing code and decode arguments --- + ?match({ok, 1.5}, orber_test_server:testing_iiop_float(Obj, 1.5)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_float(Obj, atom)), + + ?match({ok,1.0}, orber_test_server:testing_iiop_double(Obj, 1.0)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_double(Obj, "wrong")), + + ?match({ok,0}, orber_test_server:testing_iiop_short(Obj, 0)), + ?match({ok,?SHORTMAX}, orber_test_server:testing_iiop_short(Obj, ?SHORTMAX)), + ?match({ok,?SHORTMIN}, orber_test_server:testing_iiop_short(Obj, ?SHORTMIN)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_short(Obj, atomic)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_short(Obj, ?SHORTMAX+1)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_short(Obj, ?SHORTMIN-1)), + + ?match({ok,0}, orber_test_server:testing_iiop_ushort(Obj, 0)), + ?match({ok,?USHORTMAX}, orber_test_server:testing_iiop_ushort(Obj, ?USHORTMAX)), + ?match({ok,?USHORTMIN}, orber_test_server:testing_iiop_ushort(Obj, ?USHORTMIN)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_ushort(Obj, ?USHORTMAX+1)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_ushort(Obj, ?USHORTMIN-1)), + + ?match({ok,0}, orber_test_server:testing_iiop_long(Obj, 0)), + ?match({ok,?LONGMAX}, orber_test_server:testing_iiop_long(Obj, ?LONGMAX)), + ?match({ok,?LONGMIN}, orber_test_server:testing_iiop_long(Obj, ?LONGMIN)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_long(Obj, "wrong")), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_long(Obj, ?LONGMAX+1)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_long(Obj, ?LONGMIN-1)), + + ?match({ok,0}, orber_test_server:testing_iiop_longlong(Obj, 0)), + ?match({ok,?LONGLONGMAX}, orber_test_server:testing_iiop_longlong(Obj, ?LONGLONGMAX)), + ?match({ok,?LONGLONGMIN}, orber_test_server:testing_iiop_longlong(Obj, ?LONGLONGMIN)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_longlong(Obj, "wrong")), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_longlong(Obj, ?LONGLONGMAX+1)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_longlong(Obj, ?LONGLONGMIN-1)), + + ?match({ok,0}, orber_test_server:testing_iiop_ulong(Obj, 0)), + ?match({ok,?ULONGMAX}, orber_test_server:testing_iiop_ulong(Obj, ?ULONGMAX)), + ?match({ok,?ULONGMIN}, orber_test_server:testing_iiop_ulong(Obj, ?ULONGMIN)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_ulong(Obj, ?ULONGMAX+1)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_ulong(Obj, ?ULONGMIN-1)), + + ?match({ok,0}, orber_test_server:testing_iiop_ulonglong(Obj, 0)), + ?match({ok,?ULONGLONGMAX}, orber_test_server:testing_iiop_ulonglong(Obj, ?ULONGLONGMAX)), + ?match({ok,?ULONGLONGMIN}, orber_test_server:testing_iiop_ulonglong(Obj, ?ULONGLONGMIN)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_ulonglong(Obj, ?ULONGLONGMAX+1)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_ulonglong(Obj, ?ULONGLONGMIN-1)), + + ?match({ok,98}, orber_test_server:testing_iiop_char(Obj, 98)), + ?match({ok,$b}, orber_test_server:testing_iiop_char(Obj, $b)), + + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_char(Obj, atomic)), + + ?match({ok,65535}, orber_test_server:testing_iiop_wchar(Obj, 65535)), + ?match({ok,$b}, orber_test_server:testing_iiop_wchar(Obj, $b)), + + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_wchar(Obj, atomic)), + + ?match({ok,true}, orber_test_server:testing_iiop_bool(Obj, true)), + ?match({ok,false}, orber_test_server:testing_iiop_bool(Obj, false)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_bool(Obj, atom)), + + ?match({ok,1}, orber_test_server:testing_iiop_octet(Obj, 1)), +% No real guards for this case. +% ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, +% orber_test_server:testing_iiop_octet(Obj, 1.5)), + IOR12 = create_components_IOR({1,2}), + ?match({ok,Obj}, orber_test_server:testing_iiop_obj(Obj, Obj)), + ?match({ok,IOR12}, orber_test_server:testing_iiop_obj(Obj, IOR12)), + PObj = orber_test_server:oe_create([], [{pseudo,true}]), + ?match({ok, _}, orber_test_server:testing_iiop_obj(Obj, PObj)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_obj(Obj, "no_object")), + ?match({ok,"string"}, orber_test_server:testing_iiop_string(Obj, "string")), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_string(Obj, "ToLongString")), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_string(Obj, atomic)), + + ?match({ok,[65535]}, orber_test_server:testing_iiop_wstring(Obj, [65535])), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_wstring(Obj, "ToLongWstring")), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_wstring(Obj, atomic)), + + ?match({ok, one}, + orber_test_server:testing_iiop_enum(Obj, one)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_enum(Obj, three)), + ?match({ok,[1,2,3]}, + orber_test_server:testing_iiop_seq(Obj, [1,2,3])), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_seq(Obj, [1,2,3,4])), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_seq(Obj, false)), + + + ?match({ok,[#orber_test_server_struc{a=1, b=2}]}, + orber_test_server:testing_iiop_struc_seq(Obj, + [#orber_test_server_struc{a=1, b=2}])), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_struc_seq(Obj, false)), + + ?match({ok,[#orber_test_server_uni{label=1, value=66}]}, + orber_test_server:testing_iiop_uni_seq(Obj, + [#orber_test_server_uni{label=1, value=66}])), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_uni_seq(Obj, false)), + + ?match({ok,{"one", "two"}}, + orber_test_server:testing_iiop_array(Obj, {"one", "two"})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_array(Obj, {"one", "two", "three"})), + ?match({ok,#orber_test_server_struc{a=1, b=2}}, + orber_test_server:testing_iiop_struct(Obj, + #orber_test_server_struc{a=1, b=2})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_struct(Obj, + #orber_test_server_struc{a="WRONG", b=2})), + ?match({ok,#orber_test_server_uni{label=1, value=66}}, + orber_test_server:testing_iiop_union(Obj, + #orber_test_server_uni{label=1, value=66})), + + ?match({ok,#orber_test_server_uni_d{label=1, value=66}}, + orber_test_server:testing_iiop_union_d(Obj, + #orber_test_server_uni_d{label=1, value=66})), + + ?match({ok,#orber_test_server_uni_d{label=2, value=true}}, + orber_test_server:testing_iiop_union_d(Obj, + #orber_test_server_uni_d{label=2, value=true})), + + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_union_d(Obj, + #orber_test_server_uni_d{label=2, value=66})), + + case Local of + true -> + ?match({ok,#orber_test_server_uni{label=2, value=66}}, + orber_test_server:testing_iiop_union(Obj, + #orber_test_server_uni{label=2, value=66})); + false -> + ?match({ok,#orber_test_server_uni{label=2, value=undefined}}, + orber_test_server:testing_iiop_union(Obj, + #orber_test_server_uni{label=2, value=66})) + end, + + C1 = orber_test_server:fixed52const1(), + C2 = orber_test_server:fixed52const2(), + C3 = orber_test_server:fixed52const3(), + + C4 = orber_test_server:fixed52negconst1(), + C5 = orber_test_server:fixed52negconst2(), + C6 = orber_test_server:fixed52negconst3(), + + ?match({ok,C1}, orber_test_server:testing_iiop_fixed(Obj, C1)), + ?match({ok,C2}, orber_test_server:testing_iiop_fixed(Obj, C2)), + ?match({ok,C3}, orber_test_server:testing_iiop_fixed(Obj, C3)), + ?match({ok,C4}, orber_test_server:testing_iiop_fixed(Obj, C4)), + ?match({ok,C5}, orber_test_server:testing_iiop_fixed(Obj, C5)), + ?match({ok,C6}, orber_test_server:testing_iiop_fixed(Obj, C6)), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_fixed(Obj, #fixed{digits = 5, + scale = 2, + value = 123450})), + + ?match(ok, orber_test_server:testing_iiop_void(Obj)), + + ?match({'EXCEPTION',{'BAD_QOS',_,_,_}}, + orber_test_server:pseudo_call_raise_exc(Obj, 1)), + ?match({'EXCEPTION',{'BAD_QOS',_,_,_}}, + orber_test_server:pseudo_call_raise_exc(Obj, 2)), + ?match({'EXCEPTION',{'orber_test_server_UserDefinedException',_}}, + orber_test_server:raise_local_exception(Obj)), + ?match({'EXCEPTION',{'orber_test_server_ComplexUserDefinedException',_, + [#orber_test_server_struc{a=1, b=2}]}}, + orber_test_server:raise_complex_local_exception(Obj)), + %% Test all TypeCodes + ?match({ok, #any{typecode = tk_long, value = 1}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_long, + value = 1})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_long, + value = "wrong"})), + ?match({ok, #any{typecode = tk_float, value = 1.5}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_float, + value = 1.5})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_long, + value = "wrong"})), + ?match({ok, #any{typecode = tk_double}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_double, + value = 1.0})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_double, + value = "wrong"})), + ?match({ok, #any{typecode = tk_short, value = -1}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_short, + value = -1})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_short, + value = atomic})), + ?match({ok, #any{typecode = tk_ushort, value = 1}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_ushort, + value = 1})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_ushort, + value = -1})), + ?match({ok, #any{typecode = tk_long, value = 1}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_long, + value = 1})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_long, + value = "wrong"})), + ?match({ok, #any{typecode = tk_longlong, value = 1}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_longlong, + value = 1})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_longlong, + value = "wrong"})), + ?match({ok, #any{typecode = tk_ulong, value = 1}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_ulong, + value = 1})), + ?match({ok, #any{typecode = tk_ulong, value = 4294967295}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_ulong, + value = 4294967295})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_ulong, + value = 4294967296})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_ulong, + value = -1})), + ?match({ok, #any{typecode = tk_ulonglong, value = 1}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_ulonglong, + value = 1})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_ulonglong, + value = -1})), + ?match({ok, #any{typecode = tk_char, value = 98}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_char, + value = 98})), + ?match({ok, #any{typecode = tk_char, value = $b}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_char, + value = $b})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_char, + value = atomic})), + ?match({ok, #any{typecode = tk_wchar, value = 65535}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_wchar, + value = 65535})), + ?match({ok, #any{typecode = tk_wchar, value = $b}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_wchar, + value = $b})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_wchar, + value = atomic})), + ?match({ok, #any{typecode = tk_boolean, value = true}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_boolean, + value = true})), + ?match({ok, #any{typecode = tk_boolean, value = false}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_boolean, + value = false})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_boolean, + value = 1})), + ?match({ok, #any{typecode = tk_octet, value = 1}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_octet, + value = 1})), + ?match({ok, #any{typecode = {tk_objref, "IDL:omg.org/orber_test/server:1.0", "server"}, value = Obj}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_objref, "IDL:omg.org/orber_test/server:1.0", "server"}, + value = Obj})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_objref, "IDL:omg.org/orber_test/server:1.0", "server"}, + value = "No Object"})), + ?match({ok, #any{typecode = {tk_string, 6}, value = "string"}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_string, 6}, + value = "string"})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = tk_string, + value = atomic})), + ?match({ok, #any{typecode = {tk_wstring, 1}, value = [65535]}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_wstring, 1}, + value = [65535]})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_wstring, 1}, + value = atomic})), + ?match({ok, #any{typecode = {tk_enum, "IDL:omg.org/orber_test/server/enumerant:1.0", "enumerant", ["one","two"]}, + value = two}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_enum, "IDL:omg.org/orber_test/server/enumerant:1.0", "enumerant", ["one","two"]}, + value = two})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_enum, "IDL:omg.org/orber_test/server/enumerant:1.0", "enumerant", ["one","two"]}, + value = three})), + + + ?match({ok, #any{typecode = {tk_sequence, tk_long, 3}, + value = [1,2,3]}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_sequence, tk_long, 3}, + value = [1,2,3]})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_sequence, tk_long, 3}, + value = false})), + + + + ?match({ok, #any{typecode = {tk_array,{tk_string,0},2}, + value = {"one", "two"}}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_array,{tk_string,0},2}, + value = {"one", "two"}})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_array,{tk_string,0},2}, + value = {"one", "two", "three"}})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_array,{tk_string,0},2}, + value = {1, 2}})), + ?match({ok, #any{typecode = {tk_struct,"IDL:omg.org/orber_test/server/struc:1.0", + "struc", + [{"a",tk_long},{"b",tk_short}]}, + value = #orber_test_server_struc{a=1, b=2}}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_struct,"IDL:omg.org/orber_test/server/struc:1.0", + "struc", + [{"a",tk_long},{"b",tk_short}]}, + value = #orber_test_server_struc{a=1, b=2}})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_struct,"IDL:omg.org/orber_test/server/struc:1.0", + "struc", + [{"a",tk_long},{"b",tk_short}]}, + value = #orber_test_server_struc{a=1, b="string"}})), + ?match({ok, #any{typecode = + {tk_union,"IDL:omg.org/orber_test/server/uni:1.0", + "uni", tk_long, -1, [{1,"a",tk_long}]}, + value = #orber_test_server_uni{label=1, value=66}}}, + orber_test_server: + testing_iiop_any(Obj, + #any{typecode = + {tk_union,"IDL:omg.org/orber_test/server/uni:1.0", + "uni", tk_long, -1, [{1,"a",tk_long}]}, + value = #orber_test_server_uni{label=1, value=66}})), + case Local of + true -> + ?match({ok, #any{typecode = + {tk_union,"IDL:omg.org/orber_test/server/uni:1.0", + "uni", tk_long, -1, [{1,"a",tk_long}]}, + value = #orber_test_server_uni{label=2, value=66}}}, + orber_test_server: + testing_iiop_any(Obj, + #any{typecode = + {tk_union,"IDL:omg.org/orber_test/server/uni:1.0", + "uni", tk_long, -1, [{1,"a",tk_long}]}, + value = #orber_test_server_uni{label=2, value=66}})); + false -> + ?match({ok, #any{typecode = + {tk_union,"IDL:omg.org/orber_test/server/uni:1.0", + "uni", tk_long, -1, [{1,"a",tk_long}]}, + value = #orber_test_server_uni{label=2, value=undefined}}}, + orber_test_server: + testing_iiop_any(Obj, + #any{typecode = + {tk_union,"IDL:omg.org/orber_test/server/uni:1.0", + "uni", tk_long, -1, [{1,"a",tk_long}]}, + value = #orber_test_server_uni{label=2, value=66}})) + end, + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server: + testing_iiop_any(Obj, + #any{typecode = + {tk_union,"IDL:omg.org/orber_test/server/uni:1.0", + "uni", tk_long, -1, [{1,"a",tk_long}]}, + value = #orber_test_server_uni{label=1, value="string"}})), + + ?match({ok, #any{typecode = {tk_fixed,5,2}, + value = #fixed{digits = 5, scale = 2, value = 12345}}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_fixed,5,2}, + value = #fixed{digits = 5, + scale = 2, + value = 12345}})), + ?match({ok, #any{typecode = {tk_fixed,10,2}, + value = #fixed{digits = 10, scale = 2, value = 1234567890}}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_fixed,10,2}, + value = #fixed{digits = 10, + scale = 2, + value = 1234567890}})), + ?match({ok, #any{typecode = {tk_fixed,6,2}, + value = #fixed{digits = 6, scale = 2, value = 300000}}}, + orber_test_server:testing_iiop_any(Obj, #any{typecode = {tk_fixed,6,2}, + value = #fixed{digits = 6, + scale = 2, + value = 300000}})), + ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, + orber_test_server: + testing_iiop_server_marshal(Obj, "string")), + ok. + +%%--------------- Testing Post- & Pre-cond ------------------- +precond(Module, Function, Args) -> + error_logger:info_msg("=============== pre-condition ============ +Module : ~p +Function : ~p +Arguments : ~p +==========================================~n", [Module, Function, Args]), + ok. + +postcond(Module, Function, Args, Result) -> + error_logger:info_msg("=============== post-condition =========== +Module : ~p +Function : ~p +Arguments : ~p +Result : ~p +==========================================~n", [Module, Function, Args, Result]), + ok. + +%%--------------- Testing Missing Module --------------------- +oe_get_interface() -> + non_existing_module:tc(foo). + +%%--------------- INTERCEPTOR FUNCTIONS ---------------------- +%%------------------------------------------------------------ +%% function : new_in_connection +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +new_in_connection(Arg, CHost, Port) -> + Host = node(), + [{SHost, SPort}] = orber:find_sockname_by_peername(CHost, Port), + Peers = orber:find_peername_by_sockname(SHost, SPort), + error_logger:info_msg("=============== new_in_connection ======== +Node : ~p +From Host : ~p +From Port : ~p +To Host : ~p +To Port : ~p +Peers : ~p +Arg : ~p +==========================================~n", + [Host, CHost, Port, SHost, SPort, Peers, Arg]), + {Host}. + +%%------------------------------------------------------------ +%% function : new_out_connection +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +new_out_connection(Arg, SHost, Port) -> + Host = node(), + error_logger:info_msg("=============== new_out_connection ======= +Node : ~p +To Host : ~p +To Port : ~p +Arg : ~p +==========================================~n", + [Host, SHost, Port, Arg]), + {Host}. + +%%------------------------------------------------------------ +%% function : closed_in_connection +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +closed_in_connection(Arg) -> + error_logger:info_msg("=============== closed_in_connection ===== +Node : ~p +Connection: ~p +==========================================~n", + [node(), Arg]), + Arg. + +%%------------------------------------------------------------ +%% function : closed_out_connection +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +closed_out_connection(Arg) -> + error_logger:info_msg("=============== closed_out_connection ==== +Node : ~p +Connection: ~p +==========================================~n", + [node(), Arg]), + Arg. + +%%------------------------------------------------------------ +%% function : in_request_encoded +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +in_request_encoded(Ref, _ObjKey, Ctx, Op, + <<100:8,101:8,102:8,103:8,104:8,105:8,106:8,107:8,108:8,109:8,110:8,T/binary>>, _Args) -> + error_logger:info_msg("=============== in_request_encoded ======= +Connection: ~p +Operation : ~p +Body : ~p +Context : ~p +==========================================~n", + [Ref, Op, T, Ctx]), + {T, "NewArgs"}. + +%%------------------------------------------------------------ +%% function : in_reply_encoded +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +in_reply_encoded(Ref, _ObjKey, Ctx, Op, + <<100:8,101:8,102:8,103:8,104:8,105:8,106:8,107:8,108:8,109:8,110:8,T/binary>>, + _Args) -> + error_logger:info_msg("============== in_reply_encoded ========== +Connection: ~p +Operation : ~p +Body : ~p +Context : ~p +==========================================~n", + [Ref, Op, T, Ctx]), + {T, "NewArgs"}. + +%%------------------------------------------------------------ +%% function : out_reply_encoded +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +out_reply_encoded(Ref, _ObjKey, Ctx, Op, List, _Args) -> + error_logger:info_msg("============== out_reply_encoded ========= +Connection: ~p +Operation : ~p +Body : ~p +Context : ~p +==========================================~n", + [Ref, Op, List, Ctx]), + {list_to_binary([<<100:8,101:8,102:8,103:8,104:8,105:8,106:8,107:8,108:8,109:8,110:8>>|List]), "NewArgs"}. + +%%------------------------------------------------------------ +%% function : out_request_encoded +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +out_request_encoded(Ref, _ObjKey, Ctx, Op, List, _Args) -> + error_logger:info_msg("============== out_request_encoded ======= +Connection: ~p +Operation : ~p +Body : ~p +Context : ~p +==========================================~n", + [Ref, Op, List, Ctx]), + {list_to_binary([<<100:8,101:8,102:8,103:8,104:8,105:8,106:8,107:8,108:8,109:8,110:8>>|List]), "NewArgs"}. + +%%------------------------------------------------------------ +%% function : in_request +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +in_request(Ref, _ObjKey, Ctx, Op, Params, _Args) -> + error_logger:info_msg("=============== in_request =============== +Connection: ~p +Operation : ~p +Parameters: ~p +Context : ~p +==========================================~n", + [Ref, Op, Params, Ctx]), + {Params, "NewArgs"}. + +%%------------------------------------------------------------ +%% function : in_reply +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +in_reply(Ref, _ObjKey, Ctx, Op, Reply, _Args) -> + error_logger:info_msg("=============== in_reply ================= +Connection: ~p +Operation : ~p +Reply : ~p +Context : ~p +==========================================~n", + [Ref, Op, Reply, Ctx]), + {Reply, "NewArgs"}. + +%%------------------------------------------------------------ +%% function : postinvoke +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +out_reply(Ref, _ObjKey, Ctx, Op, Reply, _Args) -> + error_logger:info_msg("=============== out_reply ================ +Connection: ~p +Operation : ~p +Reply : ~p +Context : ~p +==========================================~n", + [Ref, Op, Reply, Ctx]), + {Reply, "NewArgs"}. + +%%------------------------------------------------------------ +%% function : postinvoke +%% Arguments: +%% Returns : +%%------------------------------------------------------------ +out_request(Ref, _ObjKey, Ctx, Op, Params, _Args) -> + error_logger:info_msg("=============== out_request ============== +Connection: ~p +Operation : ~p +Parameters: ~p +Context : ~p +==========================================~n", + [Ref, Op, Params, Ctx]), + {Params, "NewArgs"}. + + +%%--------------- END OF MODULE ------------------------------ + + + diff --git a/lib/orber/test/orber_test_server.cfg b/lib/orber/test/orber_test_server.cfg new file mode 100644 index 0000000000..84c671f795 --- /dev/null +++ b/lib/orber/test/orber_test_server.cfg @@ -0,0 +1,27 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2010. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +{timeout, "orber_test::timeout_server"}. +{this, "orber_test::timeout_server"}. +{{handle_info, "orber_test::timeout_server"}, true}. +{this, "orber_test::server"}. +{{handle_info, "orber_test::server"}, true}. +{{postcond, "orber_test::server::testing_iiop_union_d"}, {orber_test_lib, postcond}}. +{{postcond, "orber_test::server::testing_iiop_array"}, {orber_test_lib, postcond}}. +{{precond, "orber_test::server::testing_iiop_array"}, {orber_test_lib, precond}}. +{{precond, "orber_test::server::testing_iiop_enum"}, {orber_test_lib, precond}}. diff --git a/lib/orber/test/orber_test_server.idl b/lib/orber/test/orber_test_server.idl new file mode 100644 index 0000000000..a88211c941 --- /dev/null +++ b/lib/orber/test/orber_test_server.idl @@ -0,0 +1,153 @@ +// +// %CopyrightBegin% +// +// Copyright Ericsson AB 1999-2010. All Rights Reserved. +// +// The contents of this file are subject to the Erlang Public License, +// Version 1.1, (the "License"); you may not use this file except in +// compliance with the License. You should have received a copy of the +// Erlang Public License along with this software. If not, it can be +// retrieved online at http://www.erlang.org/. +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +// the License for the specific language governing rights and limitations +// under the License. +// +// %CopyrightEnd% +// + +#ifndef _ORBER_TEST_SERVER_IDL +#define _ORBER_TEST_SERVER_IDL +#pragma prefix "omg.org" + +module orber_parent { + interface inherrit { + void print(); + }; +}; + +module orber_test { + + // interface server + interface server : orber_parent::inherrit { + typedef string array[2]; + typedef sequence <long, 3> seq; + typedef wstring<6> WstrLength6; + typedef string<6> StrLength6; + + struct struc {long a; short b;}; + union uni switch(long) { + case 1: long a;}; + + union uni_d switch(long) { + case 1: long a; + default: boolean b; + }; + enum enumerant {one, two}; + + exception UserDefinedException {}; + + typedef sequence<struc> StrucSeq; + typedef sequence<uni> UniSeq; + exception ComplexUserDefinedException { StrucSeq strseq; }; + + // Testing fixed + const fixed val1 = 3.14D; + const fixed val2 = 003.14D; + const fixed val3 = 003.1400D; + const fixed val4 = 3.1400D; + const fixed val5 = .1400D; + const fixed val6 = 3.D; + const fixed val7 = -.1400D; + const fixed val8 = -3.D; + const fixed val9 = val4+val5; + const fixed val10 = val4*val5; + const fixed val11 = val4/val5; + const fixed val12 = 123.140001D; + const fixed val13 = 12314000.1D; + const fixed val14 = val12-val13; + const fixed val15 = val12+val13; + const fixed val16 = val12*val13; + const fixed val17 = 2.01D+2.01D; + const fixed val18 = 2.01D*2.01D; + const fixed val19 = 200D; + const fixed val20 = 9999999999999999999999999999999D+9999999999999999999999999999999D; + const fixed val21 = 9999999999999999999999999999999D-9999999999999999999999999999999D; + const fixed val22 = 9999999999999999999999999999999D*9999999999999999999999999999999D; + const fixed val23 = 9999999999999999999999999999999D/9999999999999999999999999999999D; + const fixed val24 = 9999D+9999D; + const fixed val25 = 400D/10D; + const fixed val26 = 9999999999999999999999999999999D; + + + typedef fixed<5,2> fixed52; + const fixed52 fixed52const1 = 123.45d; + const fixed52 fixed52const2 = 123.00d; + const fixed52 fixed52const3 = 023.00d; + const fixed52 fixed52negconst1 = -123.45d; + const fixed52 fixed52negconst2 = -123.00d; + const fixed52 fixed52negconst3 = -023.00d; + + void stop_normal(); + + void stop_brutal(); + + // Testing encode and decode + void testing_iiop_float(inout float Fl); + void testing_iiop_double(inout double Do); + void testing_iiop_short(inout short Sh); + void testing_iiop_ushort(inout unsigned short Us); + void testing_iiop_long(inout long Lo); + void testing_iiop_longlong(inout long long LLo); + void testing_iiop_ulong(inout unsigned long Ulo); + void testing_iiop_ulonglong(inout unsigned long long LLo); + void testing_iiop_char(inout char Ch); + void testing_iiop_wchar(inout wchar WCh); + void testing_iiop_bool(inout boolean Bool); + void testing_iiop_octet(inout octet Oct); + void testing_iiop_any(inout any AnyType); + void testing_iiop_obj(inout Object Obj); + void testing_iiop_string(inout StrLength6 Str); + void testing_iiop_wstring(inout WstrLength6 WStr); + void testing_iiop_struct(inout struc Stru); + void testing_iiop_union(inout uni Uni); + void testing_iiop_union_d(inout uni_d Uni); + void testing_iiop_enum(inout enumerant Enumerant); + void testing_iiop_seq(inout seq Seq); + void testing_iiop_uni_seq(inout UniSeq USeq); + void testing_iiop_struc_seq(inout StrucSeq SSeq); + void testing_iiop_array(inout array Arr); + void testing_iiop_fixed(inout fixed52 MyFixed); + void testing_iiop_void(); + void testing_iiop_context(); + void testing_iiop_server_marshal(inout StrLength6 Str); + + oneway void testing_iiop_oneway_delay(in long Time); + void testing_iiop_twoway_delay(in long Time); + + // Testing relay calls/casts to, for example, test that sending implicit + // Contexts works. + void relay_call(in Object Target); + oneway void relay_cast(in Object Target); + + // Testing pseudo calls/casts + void pseudo_call(); + oneway void pseudo_cast(); + void pseudo_call_delay(inout long Lo); + oneway void pseudo_cast_delay(in long Lo); + void pseudo_call_raise_exc(in long Lo); + void raise_local_exception() + raises(UserDefinedException); + void raise_complex_local_exception() + raises(ComplexUserDefinedException); + }; + + interface timeout_server { + oneway void oneway_function(in long time); + void twoway_function(in long time); + }; + +}; + +#endif diff --git a/lib/orber/test/orber_test_server_impl.erl b/lib/orber/test/orber_test_server_impl.erl new file mode 100644 index 0000000000..35296cb619 --- /dev/null +++ b/lib/orber/test/orber_test_server_impl.erl @@ -0,0 +1,262 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% + +-module(orber_test_server_impl). +-include_lib("orber/include/corba.hrl"). +-include("idl_output/orber_test_server.hrl"). + +%%--------------- specified functions ------------------------ +-export([stop_normal/2, + stop_brutal/2, + print/2, + %% Testing code and decode arguments + testing_iiop_float/3, + testing_iiop_double/3, + testing_iiop_short/3, + testing_iiop_ushort/3, + testing_iiop_long/3, + testing_iiop_longlong/3, + testing_iiop_ulong/3, + testing_iiop_ulonglong/3, + testing_iiop_char/3, + testing_iiop_wchar/3, + testing_iiop_bool/3, + testing_iiop_octet/3, + testing_iiop_any/3, + testing_iiop_obj/3, + testing_iiop_string/3, + testing_iiop_wstring/3, + testing_iiop_struct/3, + testing_iiop_union/3, + testing_iiop_union_d/3, + testing_iiop_enum/3, + testing_iiop_seq/3, + testing_iiop_uni_seq/3, + testing_iiop_struc_seq/3, + testing_iiop_array/3, + testing_iiop_fixed/3, + testing_iiop_void/2, + testing_iiop_context/2, + testing_iiop_server_marshal/3, + relay_call/3, + relay_cast/3, + %% Testing pseudo calls. + pseudo_call/2, + pseudo_cast/2, + pseudo_call_delay/3, + pseudo_cast_delay/3, + pseudo_call_raise_exc/3, + %% Testing raise locally defined exception. + raise_local_exception/2, + raise_complex_local_exception/2, + %% Test timeout functionality + testing_iiop_oneway_delay/3, + testing_iiop_twoway_delay/3]). + + +%%--------------- gen_server specific ------------------------ +-export([init/1, terminate/2]). +-export([handle_call/3, handle_cast/2, handle_info/2, code_change/3]). + +%%--------------- LOCAL DATA --------------------------------- + +%%------------------------------------------------------------ +%% function : init, terminate +%%------------------------------------------------------------ +init(State) -> + process_flag(trap_exit,true), + {ok, State}. + +terminate(Reason, State) -> + io:format("orber_test_server:terminate(~p ~p)~n",[Reason, State]), + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. +handle_call(_,_, State) -> + {noreply, State}. +handle_cast(_, State) -> + {noreply, State}. +handle_info(_Info, State) -> + {noreply, State}. + +%%--------------- SERVER FUNCTIONS --------------------------- + +print(Self, State) -> + io:format("orber_test_server:print(~p ~p)~n",[Self, State]), + {reply, ok, State}. + +stop_normal(_Self, State) -> + {stop, normal, ok, State}. + +stop_brutal(_Self, _State) -> + exit("killed_brutal"). + + +%% Testing code and decode arguments +testing_iiop_float(_Self, State, Float) -> + {reply, {ok, Float}, State}. + +testing_iiop_double(_Self, State, Double) -> + {reply, {ok, Double}, State}. + +testing_iiop_short(_Self, State, Short) -> + {reply, {ok, Short}, State}. + +testing_iiop_ushort(_Self, State, Ushort) -> + {reply, {ok, Ushort}, State}. + +testing_iiop_long(_Self, State, Long) -> + {reply, {ok, Long}, State}. + +testing_iiop_longlong(_Self, State, LLong) -> + {reply, {ok, LLong}, State}. + +testing_iiop_ulong(_Self, State, Ulong) -> + {reply, {ok, Ulong}, State}. + +testing_iiop_ulonglong(_Self, State, ULlong) -> + {reply, {ok, ULlong}, State}. + +testing_iiop_char(_Self, State, Char) -> + {reply, {ok, Char}, State}. + +testing_iiop_wchar(_Self, State, WChar) -> + {reply, {ok, WChar}, State}. + +testing_iiop_bool(_Self, State, Boolean) -> + {reply, {ok, Boolean}, State}. + +testing_iiop_octet(_Self, State, Octet) -> + {reply, {ok, Octet}, State}. + +testing_iiop_any(_Self, State, Any) -> + {reply, {ok, Any}, State}. + +testing_iiop_obj(_Self, State, Obj) -> + {reply, {ok, Obj}, State}. + +testing_iiop_string(_Self, State, String) -> + {reply, {ok, String}, State}. + +testing_iiop_wstring(_Self, State, WString) -> + {reply, {ok, WString}, State}. + +testing_iiop_struct(_Self, State, Struct) -> + {reply, {ok, Struct}, State}. + +testing_iiop_union(_Self, State, Union) -> + {reply, {ok, Union}, State}. + +testing_iiop_union_d(_Self, State, Union) -> + {reply, {ok, Union}, State}. + +testing_iiop_enum(_Self, State, Enum) -> + {reply, {ok, Enum}, State}. + +testing_iiop_seq(_Self, State, Sequence) -> + {reply, {ok, Sequence}, State}. + +testing_iiop_uni_seq(_Self, State, Sequence) -> + {reply, {ok, Sequence}, State}. + +testing_iiop_struc_seq(_Self, State, Sequence) -> + {reply, {ok, Sequence}, State}. + +testing_iiop_array(_Self, State, Array) -> + {reply, {ok, Array}, State}. + +testing_iiop_fixed(_Self, State, Fixed) -> + {reply, {ok, Fixed}, State}. + +testing_iiop_void(_Self, State) -> + {reply, ok, State}. + +testing_iiop_context(_Self, State) -> + Ctx = get(oe_server_in_context), + io:format("orber_test_server:testing_iiop_context( ~p )~n", [Ctx]), + {reply, ok, State}. + +testing_iiop_server_marshal(_Self, State, _String) -> + {reply, {ok, false}, State}. + +testing_iiop_oneway_delay(_Self, State, Time) -> + timer:sleep(Time), + {noreply, State}. + +testing_iiop_twoway_delay(_Self, State, Time) -> + timer:sleep(Time), + {reply, ok, State}. + +raise_local_exception(_Self, State) -> + corba:raise(#'orber_test_server_UserDefinedException'{}), + {reply, ok, State}. + +raise_complex_local_exception(_Self, State) -> + corba:raise(#'orber_test_server_ComplexUserDefinedException'{strseq= + [#orber_test_server_struc{a=1, b=2}]}), + {reply, ok, State}. + +%% Testing relay calls/casts to, for example, test that sending implicit +%% Contexts works. +relay_call(_Self, State, Target) -> + io:format("orber_test_server:relay_call( ~p ) Pre~n", [get(oe_server_in_context)]), + orber_test_server:testing_iiop_context(Target), + io:format("orber_test_server:relay_call( ~p ) Post~n", [get(oe_server_in_context)]), + {reply, ok, State}. + +relay_cast(_Self, State, Target) -> + io:format("orber_test_server:relay_cast( ~p ) Pre~n", [get(oe_server_in_context)]), + orber_test_server:testing_iiop_context(Target), + io:format("orber_test_server:relay_cast( ~p ) Post~n", [get(oe_server_in_context)]), + {noreply, State}. + +%% Testing pseudo calls. +pseudo_call(_Self, State) -> + io:format("orber_test_server:pseudo_call( ~p )~n", [now()]), + {reply, ok, State}. + +pseudo_cast(_Self, State) -> + io:format("orber_test_server:pseudo_cast( ~p )~n", [now()]), + {noreply, State}. +pseudo_call_delay(_Self, State, Time) -> + io:format("orber_test_server:pseudo_call_delay( ~p )~n", [now()]), + timer:sleep(Time), + io:format("orber_test_server:pseudo_call_delay( ~p )~n", [now()]), + {reply, {ok, Time}, State}. + +pseudo_cast_delay(_Self, State, Time) -> + io:format("orber_test_server:pseudo_cast_delay( ~p )~n", [now()]), + timer:sleep(Time), + io:format("orber_test_server:pseudo_cast_delay( ~p )~n", [now()]), + {noreply, State}. + +pseudo_call_raise_exc(_Self, State, 1) -> + io:format("orber_test_server:pseudo_call_raise_exc( ~p )~n",[1]), + {reply, {'EXCEPTION', #'BAD_QOS'{completion_status=?COMPLETED_NO}}, State}; +pseudo_call_raise_exc(_Self, State, 2) -> + io:format("orber_test_server:pseudo_call_raise_exc( ~p )~n",[2]), + corba:raise(#'BAD_QOS'{completion_status=?COMPLETED_NO}), + {reply, ok, State}. + +%%--------------- LOCAL FUNCTIONS ---------------------------- + +%%--------------- END OF MODULE ------------------------------ + diff --git a/lib/orber/test/orber_test_timeout_server_impl.erl b/lib/orber/test/orber_test_timeout_server_impl.erl new file mode 100644 index 0000000000..138eb51d92 --- /dev/null +++ b/lib/orber/test/orber_test_timeout_server_impl.erl @@ -0,0 +1,65 @@ +%%-------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%---------------------------------------------------------------------- +%% File : orber_test_timeout_server_impl.erl +%% Purpose : +%%---------------------------------------------------------------------- + +-module(orber_test_timeout_server_impl). + +-export([oneway_function/3, twoway_function/3]). + + +%%--------------- gen_server specific ------------------------ +-export([init/1, terminate/2, code_change/3, handle_info/2]). + +%%------------------------------------------------------------ +%% function : server specific +%%------------------------------------------------------------ +init(State) -> + %% 'trap_exit' optional + process_flag(trap_exit,true), + {ok, State}. + +terminate(_Reason, _State) -> + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +%% If use IC option {{handle_info, "Module::Interface"}, true} +handle_info(_Info, State) -> + %% Await the next invocation. + {noreply, State}. + +%%--- two-way ------------------------------------------------ +twoway_function(_OE_THIS, State, Time) -> + timer:sleep(Time), + {reply, ok, State}. + + +%%--- one-way ------------------------------------------------ +oneway_function(_OE_THIS, State, Time) -> + timer:sleep(Time), + {noreply, State}. + +%%--------------- END OF MODULE ------------------------------ + diff --git a/lib/orber/test/orber_web_SUITE.erl b/lib/orber/test/orber_web_SUITE.erl new file mode 100644 index 0000000000..ffa7468853 --- /dev/null +++ b/lib/orber/test/orber_web_SUITE.erl @@ -0,0 +1,443 @@ +%%----------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% File : orber_web_SUITE.erl +%% Purpose : +%%----------------------------------------------------------------- + +-module(orber_web_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/include/corba.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(ExpectedRes, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + ExpectedRes -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS; + _ -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS) + end + end()). + +-define(nomatch(Not, Expr), + fun() -> + AcTuAlReS = (catch (Expr)), + case AcTuAlReS of + Not -> + io:format("###### ERROR ERROR ######~n~p~n", + [AcTuAlReS]), + ?line exit(AcTuAlReS); + _ -> + io:format("------ CORRECT RESULT ------~n~p~n", + [AcTuAlReS]), + AcTuAlReS + end + end()). + + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["This suite is for testing the Orber Web API"]; +all(suite) -> + [menu, configure, info, nameservice, ifr_select, ifr_data, + create, delete_ctx, add_ctx, delete_obj, server]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + Path = code:which(?MODULE), + code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), + orber:jump_start(2875), + oe_orber_test_server:oe_register(), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + oe_orber_test_server:oe_unregister(), + orber:jump_stop(), + Path = code:which(?MODULE), + code:del_path(filename:join(filename:dirname(Path), "idl_output")), + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: menu +%% Description: +%%----------------------------------------------------------------- +menu(doc) -> [""]; +menu(suite) -> []; +menu(_) -> + Node = atom_to_list(node()), + OK = orber_web:menu(env, [{"node", Node}]), + ?match(OK, orber_web:menu(env, [])), + ?match(OK, orber_web:menu(env, [42, {"node", Node}, "wrong"])), + ?match({'EXIT', _E}, orber_web:menu(env, [{"node", localhost}])), + ok. + +%%----------------------------------------------------------------- +%% Test Case: configure +%% Description: +%%----------------------------------------------------------------- +configure(doc) -> [""]; +configure(suite) -> []; +configure(_) -> + Node = atom_to_list(node()), + ?match({'EXIT', _}, orber_web:configure(env, [])), + ?match({'EXIT', _}, orber_web:configure(env, [{"node", localhost}, + {"data", atom}])), + ?match([_H|_T], orber_web:configure(env, [{"node", Node}, {"data", ""}])), + ?match([_H|_T], orber_web:configure(env, [{"node", Node}, + {"data", "[{orber_debug_level, 9}]"}])), + ?match({ok, 9}, application:get_env(orber, orber_debug_level)), + ?match([_H|_T], orber_web:configure(env, [{"node", "bad_node"}, + {"data", "[{orber_debug_level, 9}]"}])), + ?match({error, _}, orber_web:configure(env, [{"node", Node}, + {"data", "{orber_debug_level 9}"}])), + ok. + +%%----------------------------------------------------------------- +%% Test Case: info +%% Description: +%%----------------------------------------------------------------- +info(doc) -> [""]; +info(suite) -> []; +info(_) -> + ?match({'EXIT', _}, orber_web:info(env, [])), + ?match({'EXIT', _}, orber_web:info(env, [{"node", localhost}])), + ?match([_H|_T], orber_web:info(env, [{"node", atom_to_list(node())}])), + ok. + +%%----------------------------------------------------------------- +%% Test Case: nameservice +%% Description: +%%----------------------------------------------------------------- +nameservice(doc) -> [""]; +nameservice(suite) -> []; +nameservice(_) -> + NodeStr = atom_to_list(node()), + ?match({'EXIT', _}, orber_web:nameservice(env, [{"node", localhost}, + {"context", "root"}])), + ?match({'EXIT', _}, orber_web:nameservice(env, [{"node", localhost}, + {"context", "id1"}])), + ?match([_H|_T], orber_web:nameservice(env, [{"node", "bad_node"}, + {"context", "root"}])), + ?match([_,_,_,NodeStr|_], orber_web:nameservice(env, [{"node", NodeStr}, + {"context", "root"}])), + ?match({ok,_}, orber_web:nameservice(env, [{"node", NodeStr}, + {"context", "id1"}])), + ?match([_H|_T], orber_web:add_ctx(env, [{"node", NodeStr}, + {"context", "root"}, + {"id", "id1"}])), + ?match([_H|_T], orber_web:add_ctx(env, [{"node", NodeStr}, + {"context", "id1"}, + {"id", "id2"}])), + [_,_,_,IOR] = + ?match([_,_,_,_], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[{pseudo, true}]"}, + {"namestr", "id1/id2/id3"}, + {"bind", "rebind"}])), + ?match(#'IOP_IOR'{}, corba:string_to_object(IOR)), + + ?match([_,"id1"|_], orber_web:nameservice(env, [{"node", NodeStr}, + {"context", "id1"}])), + ?nomatch({error, _}, orber_web:nameservice(env, [{"node", NodeStr}, + {"context", "id1/id2"}, + {"object", "id3"}])), + + ok. + +%%----------------------------------------------------------------- +%% Test Case: ifr_select +%% Description: +%%----------------------------------------------------------------- +ifr_select(doc) -> [""]; +ifr_select(suite) -> []; +ifr_select(_) -> + ?match({'EXIT', _}, orber_web:ifr_select(env, [])), + ?match({'EXIT', _}, orber_web:ifr_select(env, [{"node", localhost}])), + ?match([_H|_T], orber_web:ifr_select(env, [{"node", "bad_node"}])), + ?match([_H|_T], orber_web:ifr_select(env, [{"node", atom_to_list(node())}])), + ok. + +%%----------------------------------------------------------------- +%% Test Case: ifr_data +%% Description: +%%----------------------------------------------------------------- +ifr_data(doc) -> [""]; +ifr_data(suite) -> []; +ifr_data(_) -> + ?match({'EXIT', _}, orber_web:ifr_data(env, [])), + ?match({'EXIT', _}, orber_web:ifr_data(env, [{"node", localhost}, + {"table", "ir_ModuleDef"}])), + ?match({error, _}, orber_web:ifr_data(env, [{"node", "bad_host"}, + {"table", "ir_ModuleDef"}])), + ?match({'EXIT', _}, orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "bad_table"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_ModuleDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_InterfaceDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_StructDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_ExceptionDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_ConstantDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_EnumDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_AliasDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_AttributeDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_OperationDef"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_Contained"}])), + ?match([_H|_T], orber_web:ifr_data(env, [{"node", atom_to_list(node())}, + {"table", "ir_TypedefDef"}])), + ok. + +%%----------------------------------------------------------------- +%% Test Case: create +%% Description: +%%----------------------------------------------------------------- +create(doc) -> [""]; +create(suite) -> []; +create(_) -> + NodeStr = atom_to_list(node()), + ?match({'EXIT', _}, orber_web:create(env, [])), + ?match({'EXIT', _}, orber_web:create(env, [{"node", localhost}])), + ?match({error, _}, orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[bad_option 42]"}, + {"namestr", "[]"}, + {"bind", "rebind"}])), + ?match({error, _}, orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[bad_argument 42]"}, + {"options", "[]"}, + {"namestr", "[]"}, + {"bind", "rebind"}])), + + ?match([_, NodeStr|_T], orber_web:create(env, [{"node", NodeStr}])), + + [_,IOR] = ?match([_,_], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[]"}, + {"namestr", ""}, + {"bind", "rebind"}])), + ?match(#'IOP_IOR'{}, corba:string_to_object(IOR)), + + [_,_,_,_,_,IOR2] = + ?match([_,_,_,_,_,_], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[]"}, + {"namestr", "id1"}, + {"bind", "rebind"}])), + ?match(#'IOP_IOR'{}, corba:string_to_object(IOR2)), + + [_,_,_,IOR3] = + ?match([_,_,_,_], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[{pseudo, true}]"}, + {"namestr", "id2"}, + {"bind", "rebind"}])), + ?match(#'IOP_IOR'{}, corba:string_to_object(IOR3)), + + [_,IOR4] =?match([_,_], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[{pseudo, true}]"}, + {"namestr", ""}, + {"bind", "rebind"}])), + ?match(#'IOP_IOR'{}, corba:string_to_object(IOR4)), + + ?match([_], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[{unknown, option}]"}, + {"namestr", "id1"}, + {"bind", "rebind"}])), + + ?match([_, "id1"], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[]"}, + {"namestr", "id1"}, + {"bind", "bind"}])), + + ?match([_, "id2"], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[{pseudo, true}]"}, + {"namestr", "id2"}, + {"bind", "bind"}])), + ok. + +%%----------------------------------------------------------------- +%% Test Case: delete_ctx +%% Description: +%%----------------------------------------------------------------- +delete_ctx(doc) -> [""]; +delete_ctx(suite) -> []; +delete_ctx(_) -> + ?match({ok, _}, orber_web:delete_ctx(env, [{"node", atom_to_list(node())}, + {"context", "id1"}])), + ?match([_H|_T], orber_web:add_ctx(env, [{"node", atom_to_list(node())}, + {"context", "root"}, + {"id", "id1"}])), + ?match([_H|_T], orber_web:delete_ctx(env, [{"node", atom_to_list(node())}, + {"context", "id1"}])), + ok. + +%%----------------------------------------------------------------- +%% Test Case: add_ctx +%% Description: +%%----------------------------------------------------------------- +add_ctx(doc) -> [""]; +add_ctx(suite) -> []; +add_ctx(_) -> + ?match({error, _}, orber_web:add_ctx(env, [{"node", "bad_node"}, + {"context", "root"}, + {"id", "id1"}])), + ?match([_H|_T], orber_web:add_ctx(env, [{"node", atom_to_list(node())}, + {"context", "root"}, + {"id", ""}])), + ?match([_H|_T], orber_web:add_ctx(env, [{"node", atom_to_list(node())}, + {"context", "root"}, + {"id", "id1"}])), + ?match([_H|_T], orber_web:add_ctx(env, [{"node", atom_to_list(node())}, + {"context", "id1"}, + {"id", "id2"}])), + ok. + +%%----------------------------------------------------------------- +%% Test Case: delete_obj +%% Description: +%%----------------------------------------------------------------- +delete_obj(doc) -> [""]; +delete_obj(suite) -> []; +delete_obj(_) -> + NodeStr = atom_to_list(node()), + ?match({error, _}, orber_web:delete_obj(env, [{"node", "bad_node"}, + {"context", "id1"}, + {"action", "unbind"}])), + ?match({error, _}, orber_web:delete_obj(env, [{"node", "bad_node"}, + {"context", "id1"}, + {"action", "both"}])), + ?match({'EXIT', _}, orber_web:delete_obj(env, [{"node", bad_node}, + {"context", "id1"}, + {"action", "both"}])), + ?match({error, _}, orber_web:delete_obj(env, [{"node", NodeStr}, + {"context", "non/existing"}, + {"action", "unbind"}])), + [_,_,_,_,_,IOR2] = + ?match([_,_,_,_,_,_], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[]"}, + {"namestr", "id1"}, + {"bind", "rebind"}])), + ?match(#'IOP_IOR'{}, corba:string_to_object(IOR2)), + + ?match({error, _}, orber_web:delete_obj(env, [{"node", NodeStr}, + {"context", "bad/INS./id"}, + {"action", "unbind"}])), + + [_,_,_,IOR3] = + ?match([_,_,_,_], orber_web:create(env, [{"node", NodeStr}, + {"module", "orber_test_server"}, + {"arguments", "[]"}, + {"options", "[{pseudo, true}]"}, + {"namestr", "id2"}, + {"bind", "rebind"}])), + ?match(#'IOP_IOR'{}, corba:string_to_object(IOR3)), + + ?match([_, "id1"|_], orber_web:delete_obj(env, [{"node", NodeStr}, + {"context", "id1"}, + {"action", "unbind"}])), + ?match([_, "id2"|_], orber_web:delete_obj(env, [{"node", NodeStr}, + {"context", "id2"}, + {"action", "unbind"}])), + + + ok. + +%%----------------------------------------------------------------- +%% Test Case: server +%% Description: +%%----------------------------------------------------------------- +server(doc) -> [""]; +server(suite) -> []; +server(_) -> + NodeStr = "node=" ++ atom_to_list(node()), + {ok, Pid} = ?match({ok,_}, orber_web_server:start()), + ?match({error,{already_started, Pid}}, orber_web_server:start_link()), + ?match({error,{already_started,Pid}}, orber_web_server:start()), + ?match({orber, _}, orber_web_server:config_data()), + ?match([_H|_T], orber_web_server:ifr_select(env, "node=badnode")), + ?match([_H|_T], orber_web_server:ifr_select(env, "node=" ++ NodeStr)), + ?match([_H|_T], orber_web_server:menu(env, NodeStr)), + ?match([_H|_T], orber_web_server:configure(env, NodeStr ++ "&data=[{orber_debug_level, 9}]")), + ?match([_H|_T], orber_web_server:nameservice(env, NodeStr ++ "&context=root")), + ?match([_H|_T], orber_web_server:info(env, NodeStr)), + ?match([_H|_T], orber_web_server:ifr_data(env, NodeStr ++ "&table=ir_ModuleDef")), + ?match([_H|_T], orber_web_server:create(env, NodeStr)), + ?match([_H|_T], orber_web_server:add_ctx(env, NodeStr ++ "&context=root&id=id1")), + ?match([_H|_T], orber_web_server:delete_ctx(env, NodeStr++"&context=id1")), + ?match([_H|_T], orber_web_server:delete_obj(env, NodeStr++"&context=id1&action=unbind")), + ?match([_H|_T], orber_web_server:default_selection(env, NodeStr)), + ?match(ok, orber_web_server:stop()), + ok. + + diff --git a/lib/orber/test/tc_SUITE.erl b/lib/orber/test/tc_SUITE.erl new file mode 100644 index 0000000000..807a663219 --- /dev/null +++ b/lib/orber/test/tc_SUITE.erl @@ -0,0 +1,661 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%----------------------------------------------------------------- +%% +%% Description: +%% Test suite for the basic typecode functions +%% +%%----------------------------------------------------------------- +-module(tc_SUITE). + +-include("test_server.hrl"). +-include_lib("orber/src/orber_iiop.hrl"). + +-define(default_timeout, ?t:minutes(3)). + +-define(match(Expr), + fun() -> + case (catch (Expr)) of + AcTuAlReS when is_binary(AcTuAlReS)-> + io:format("###### ERROR ERROR ######~nRESULT: ~p~n", + [AcTuAlReS]), + exit(AcTuAlReS); + _ -> + ok + end + end()). +-define(SUB_ELIST, [{"null", orber_tc:null()}, + {"void", orber_tc:void()}, + {"short", orber_tc:short()}, + {"unsigned_short", orber_tc:unsigned_short()}, + {"long", orber_tc:long()}, + {"unsigned_long", orber_tc:unsigned_long()}, + {"long_long", orber_tc:long_long()}, + {"unsigned_long_long", orber_tc:unsigned_long_long()}, + {"float", orber_tc:'float'()}, + {"double", orber_tc:double()}, + {"longdouble", orber_tc:longdouble()}, + {"boolean", orber_tc:boolean()}, + {"char", orber_tc:char()}, + {"wchar", orber_tc:wchar()}, + {"octet", orber_tc:octet()}, + {"any", orber_tc:any()}, + {"typecode", orber_tc:typecode()}, + {"principal", orber_tc:principal()}, + {"object_reference", orber_tc:object_reference("Id", "Name")}]). + +-define(ELIST, [{"null", orber_tc:null()}, + {"void", orber_tc:void()}, + {"short", orber_tc:short()}, + {"unsigned_short", orber_tc:unsigned_short()}, + {"long", orber_tc:long()}, + {"unsigned_long", orber_tc:unsigned_long()}, + {"long_long", orber_tc:long_long()}, + {"unsigned_long_long", orber_tc:unsigned_long_long()}, + {"float", orber_tc:'float'()}, + {"double", orber_tc:double()}, + {"longdouble", orber_tc:longdouble()}, + {"boolean", orber_tc:boolean()}, + {"char", orber_tc:char()}, + {"wchar", orber_tc:wchar()}, + {"octet", orber_tc:octet()}, + {"any", orber_tc:any()}, + {"typecode", orber_tc:typecode()}, + {"principal", orber_tc:principal()}, + {"object_reference", orber_tc:object_reference("Id", "Name")}, + {"struct", orber_tc:struct("Id", "Name", ?SUB_ELIST)}, + {"enum", orber_tc:enum("Id", "Name", ["E1", "E2"])}, + {"string", orber_tc:string(1)}, + {"wstring", orber_tc:wstring(0)}, + {"sequence", orber_tc:sequence(orber_tc:enum("Id", "Name", + ["E1", "E2"]), 0)}, + {"array", orber_tc:array(orber_tc:enum("Id", "Name", + ["E1", "E2"]), 2)}, + {"alias", orber_tc:alias("id", "name", + orber_tc:enum("Id", "Name", + ["E1", "E2"]))}, + {"exception", orber_tc:exception("Id", "Name", ?SUB_ELIST)}]). + +-define(VELIST, [{"null", orber_tc:null(), 42}, + {"void", orber_tc:void(), 42}, + {"short", orber_tc:short(), 42}, + {"unsigned_short", orber_tc:unsigned_short(), 42}, + {"long", orber_tc:long(), 42}, + {"unsigned_long", orber_tc:unsigned_long(), 42}, + {"long_long", orber_tc:long_long(), 42}, + {"unsigned_long_long", orber_tc:unsigned_long_long(), 42}, + {"float", orber_tc:'float'(), 42}, + {"double", orber_tc:double(), 42}, + {"longdouble", orber_tc:longdouble(), 42}, + {"boolean", orber_tc:boolean(), 42}, + {"char", orber_tc:char(), 42}, + {"wchar", orber_tc:wchar(), 42}, + {"octet", orber_tc:octet(), 42}, + {"any", orber_tc:any(), 42}, + {"typecode", orber_tc:typecode(), 42}, + {"principal", orber_tc:principal(), 42}, + {"object_reference", orber_tc:object_reference("Id", "Name"), 42}, + {"struct", orber_tc:struct("Id", "Name", ?SUB_ELIST), 42}, + {"enum", orber_tc:enum("Id", "Name", ["E1", "E2"]), 42}, + {"string", orber_tc:string(1), 42}, + {"wstring", orber_tc:wstring(0), 42}, + {"sequence", orber_tc:sequence(orber_tc:enum("Id", "Name", + ["E1", "E2"]), 0), 42}, + {"array", orber_tc:array(orber_tc:enum("Id", "Name", + ["E1", "E2"]), 2), 42}, + {"alias", orber_tc:alias("id", "name", + orber_tc:enum("Id", "Name", + ["E1", "E2"])), 42}, + {"exception", orber_tc:exception("Id", "Name", ?SUB_ELIST), 42}]). + +%%----------------------------------------------------------------- +%% External exports +%%----------------------------------------------------------------- +-export([all/1]). + +%%----------------------------------------------------------------- +%% Internal exports +%%----------------------------------------------------------------- +-export([]). +-compile(export_all). + +%%----------------------------------------------------------------- +%% Func: all/1 +%% Args: +%% Returns: +%%----------------------------------------------------------------- +all(doc) -> ["Description", "more description"]; +all(suite) -> + [null, void, + short, ushort, + long, ulong, + longlong, ulonglong, + boolean, char, wchar, octet, + float, double, longdouble, + any, typecode, principal, object_reference, + struct, union, enum, string, wstring, sequence, array, + alias, exception, fixed, value, value_box, native, + abstract_interface, indirection, get_tc]. + +%%----------------------------------------------------------------- +%% Init and cleanup functions. +%%----------------------------------------------------------------- + +init_per_testcase(_Case, Config) -> + ?line Dog=test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + + +fin_per_testcase(_Case, Config) -> + Dog = ?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +%%----------------------------------------------------------------- +%% Test Case: null test +%% Description: +%%----------------------------------------------------------------- +null(doc) -> []; +null(suite) -> []; +null(_) -> + ?line true = orber_tc:check_tc(orber_tc:null()), + ?line code(orber_tc:null()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: void test +%% Description: +%%----------------------------------------------------------------- +void(doc) -> []; +void(suite) -> []; +void(_) -> + ?line true = orber_tc:check_tc(orber_tc:void()), + ?line code(orber_tc:void()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: short integer test +%% Description: +%%----------------------------------------------------------------- +short(doc) -> []; +short(suite) -> []; +short(_) -> + ?line true = orber_tc:check_tc(orber_tc:short()), + ?line code(orber_tc:short()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: unsigned short integer test +%% Description: +%%----------------------------------------------------------------- +ushort(doc) -> []; +ushort(suite) -> []; +ushort(_) -> + ?line true = orber_tc:check_tc(orber_tc:unsigned_short()), + ?line code(orber_tc:unsigned_short()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: long integer test +%% Description: +%%----------------------------------------------------------------- +long(doc) -> []; +long(suite) -> []; +long(_) -> + ?line true = orber_tc:check_tc(orber_tc:long()), + ?line code(orber_tc:long()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: unsigned long integer test +%% Description: +%%----------------------------------------------------------------- +ulong(doc) -> []; +ulong(suite) -> []; +ulong(_) -> + ?line true = orber_tc:check_tc(orber_tc:unsigned_long()), + ?line code(orber_tc:unsigned_long()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: long integer test +%% Description: +%%----------------------------------------------------------------- +longlong(doc) -> []; +longlong(suite) -> []; +longlong(_) -> + ?line true = orber_tc:check_tc(orber_tc:long_long()), + ?line code(orber_tc:long_long()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: unsigned long integer test +%% Description: +%%----------------------------------------------------------------- +ulonglong(doc) -> []; +ulonglong(suite) -> []; +ulonglong(_) -> + ?line true = orber_tc:check_tc(orber_tc:unsigned_long_long()), + ?line code(orber_tc:unsigned_long_long()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: float test +%% Description: +%%----------------------------------------------------------------- +float(doc) -> []; +float(suite) -> []; +float(_) -> + ?line true = orber_tc:check_tc(orber_tc:'float'()), + ?line code(orber_tc:'float'()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: double test +%% Description: +%%----------------------------------------------------------------- +double(doc) -> []; +double(suite) -> []; +double(_) -> + ?line true = orber_tc:check_tc(orber_tc:double()), + ?line code(orber_tc:double()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: longdouble test +%% Description: +%%----------------------------------------------------------------- +longdouble(doc) -> []; +longdouble(suite) -> []; +longdouble(_) -> + ?line true = orber_tc:check_tc(orber_tc:longdouble()), + ?line code(orber_tc:longdouble()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: boolean test +%% Description: +%%----------------------------------------------------------------- +boolean(doc) -> []; +boolean(suite) -> []; +boolean(_) -> + ?line true = orber_tc:check_tc(orber_tc:boolean()), + ?line code(orber_tc:boolean()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: character test +%% Description: +%%----------------------------------------------------------------- +char(doc) -> []; +char(suite) -> []; +char(_) -> + ?line true = orber_tc:check_tc(orber_tc:char()), + ?line code(orber_tc:char()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: character test +%% Description: +%%----------------------------------------------------------------- +wchar(doc) -> []; +wchar(suite) -> []; +wchar(_) -> + ?line true = orber_tc:check_tc(orber_tc:wchar()), + ?line code(orber_tc:wchar()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: octet test +%% Description: +%%----------------------------------------------------------------- +octet(doc) -> []; +octet(suite) -> []; +octet(_) -> + ?line true = orber_tc:check_tc(orber_tc:octet()), + ?line code(orber_tc:octet()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: any test +%% Description: +%%----------------------------------------------------------------- +any(doc) -> []; +any(suite) -> []; +any(_) -> + ?line true = orber_tc:check_tc(orber_tc:any()), + ?line code(orber_tc:any()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: typecode test +%% Description: +%%----------------------------------------------------------------- +typecode(doc) -> []; +typecode(suite) -> []; +typecode(_) -> + ?line true = orber_tc:check_tc(orber_tc:typecode()), + ?line code(orber_tc:typecode()), + ok. + +%%----------------------------------------------------------------- +%% Test Case: principal test +%% Description: +%%----------------------------------------------------------------- +principal(doc) -> []; +principal(suite) -> []; +principal(_) -> + ?line true = orber_tc:check_tc(orber_tc:principal()), + ?line code(orber_tc:principal()), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: object_reference test +%% Description: +%%----------------------------------------------------------------- +object_reference(doc) -> []; +object_reference(suite) -> []; +object_reference(_) -> + ?line true = orber_tc:check_tc(orber_tc:object_reference("Id", "Name")), + ?line false = orber_tc:check_tc(orber_tc:object_reference(42, "Name")), + ?line false = orber_tc:check_tc(orber_tc:object_reference("Id", 42)), + ?line code(orber_tc:object_reference("Id", "Name")), + ?line ?match(code(orber_tc:object_reference(42, "Name"))), + ?line ?match(code(orber_tc:object_reference("Id", 42))), + ok. + +%%----------------------------------------------------------------- +%% Test Case: struct +%% Description: +%%----------------------------------------------------------------- +struct(doc) -> []; +struct(suite) -> []; +struct(_) -> + ?line true = orber_tc:check_tc(orber_tc:struct("Id", "Name", ?ELIST)), + ?line false = orber_tc:check_tc(orber_tc:struct(42, "Name", ?ELIST)), + ?line false = orber_tc:check_tc(orber_tc:struct("Id", false, ?ELIST)), + ?line false = orber_tc:check_tc(orber_tc:struct("Id", "Name", ?VELIST)), + ?line false = orber_tc:check_tc(orber_tc:struct("Id", "Name", "wrong")), + ?line code(orber_tc:struct("Id", "Name", ?ELIST)), + ?line ?match(code(orber_tc:struct(42, "Name", ?ELIST))), + ?line ?match(code(orber_tc:struct("Id", false, ?ELIST))), + ?line ?match(code(orber_tc:struct("Id", "Name", ?VELIST))), + ?line ?match(code(orber_tc:struct("Id", "Name", "wrong"))), + ok. + +%%----------------------------------------------------------------- +%% Test Case: union +%% Description: +%%----------------------------------------------------------------- +union(doc) -> []; +union(suite) -> []; +union(_) -> + ?line true = orber_tc:check_tc(orber_tc:union("Id", "Name", orber_tc:long(), + -1, [{1, "long", orber_tc:long()}, + {2, "longlong", orber_tc:long()}])), + ?line false = orber_tc:check_tc(orber_tc:union("Id", "Name", orber_tc:long(), + -1, ?ELIST)), + ?line false = orber_tc:check_tc(orber_tc:union(42, "Name", orber_tc:long(), + -1, [{1, "long", orber_tc:long()}, + {2, "longlong", orber_tc:long()}])), + ?line false = orber_tc:check_tc(orber_tc:union("Id", false, orber_tc:long(), + -1, [{1, "long", orber_tc:long()}, + {2, "longlong", orber_tc:long()}])), + ?line false = orber_tc:check_tc(orber_tc:union("Id", "Name", bad_tc, + -1, [{1, "long", orber_tc:long()}, + {2, "longlong", orber_tc:long()}])), + ?line false = orber_tc:check_tc(orber_tc:union("Id", "Name", orber_tc:long(), + "wrong", [{1, "long", orber_tc:long()}, + {2, "longlong", orber_tc:long()}])), + + ?line code(orber_tc:union("Id", "Name", orber_tc:long(), + -1, [{1, "long", orber_tc:long()}, + {2, "longlong", orber_tc:long()}])), + ok. + + +%%----------------------------------------------------------------- +%% Test Case: enum test +%% Description: +%%----------------------------------------------------------------- +enum(doc) -> []; +enum(suite) -> []; +enum(_) -> + ?line true = orber_tc:check_tc(orber_tc:enum("Id", "Name", + ["E1", "E2", "E3"])), + ?line false = orber_tc:check_tc(orber_tc:enum(42, "Name", + ["E1", "E2", "E3"])), + ?line false = orber_tc:check_tc(orber_tc:enum("Id", false, + ["E1", "E2", "E3"])), + ?line false = orber_tc:check_tc(orber_tc:enum("Id", "Name", + ["E1", false, "E3"])), + ?line code(orber_tc:enum("Id", "Name", ["E1", "E2", "E3"])), + ?line ?match(code(orber_tc:enum(false, "Name", ["E1", "E2", "E3"]))), + ?line ?match(code(orber_tc:enum("Id", 42, ["E1", "E2", "E3"]))), + ?line ?match(code(orber_tc:enum("Id", "Name", ["E1", false, "E3"]))), + ok. + +%%----------------------------------------------------------------- +%% Test Case: string +%% Description: +%%----------------------------------------------------------------- +string(doc) -> []; +string(suite) -> []; +string(_) -> + ?line true = orber_tc:check_tc(orber_tc:string(0)), + ?line true = orber_tc:check_tc(orber_tc:string(1)), + ?line false = orber_tc:check_tc(orber_tc:string("wrong")), + ?line code(orber_tc:string(0)), + ?line code(orber_tc:string(1)), + ?line ?match(code(orber_tc:string(-1))), + ?line ?match(code(orber_tc:string(?ULONGMAX+1))), + ?line ?match(code(orber_tc:string("wrong"))), + ok. + +%%----------------------------------------------------------------- +%% Test Case: wstring +%% Description: +%%----------------------------------------------------------------- +wstring(doc) -> []; +wstring(suite) -> []; +wstring(_) -> + ?line true = orber_tc:check_tc(orber_tc:wstring(0)), + ?line true = orber_tc:check_tc(orber_tc:wstring(1)), + ?line false = orber_tc:check_tc(orber_tc:wstring("wrong")), + ?line code(orber_tc:wstring(0)), + ?line code(orber_tc:wstring(1)), + ?line ?match(code(orber_tc:wstring(-1))), + ?line ?match(code(orber_tc:wstring(?ULONGMAX+1))), + ?line ?match(code(orber_tc:wstring(false))), + ok. + +%%----------------------------------------------------------------- +%% Test Case: sequence +%% Description: +%%----------------------------------------------------------------- +sequence(doc) -> []; +sequence(suite) -> []; +sequence(_) -> + ?line true = orber_tc:check_tc(orber_tc:sequence(orber_tc:struct("Id", "Name", ?ELIST), 0)), + ?line code(orber_tc:sequence(orber_tc:struct("Id", "Name", ?ELIST), 0)), + ok. + +%%----------------------------------------------------------------- +%% Test Case: array +%% Description: +%%----------------------------------------------------------------- +array(doc) -> []; +array(suite) -> []; +array(_) -> + ?line true = orber_tc:check_tc(orber_tc:array(orber_tc:struct("Id", "Name", ?ELIST), 1)), + ?line code(orber_tc:array(orber_tc:struct("Id", "Name", ?ELIST), 1)), + ok. + +%%----------------------------------------------------------------- +%% Test Case: alias +%% Description: +%%----------------------------------------------------------------- +alias(doc) -> []; +alias(suite) -> []; +alias(_) -> + ?line true = orber_tc:check_tc(orber_tc:alias("Id", "Name", orber_tc:struct("Id", "Name", ?ELIST))), + ?line false = orber_tc:check_tc(orber_tc:alias(false, "Name", orber_tc:struct("Id", "Name", ?ELIST))), + ?line false = orber_tc:check_tc(orber_tc:alias("Id", 42, orber_tc:struct("Id", "Name", ?ELIST))), + ?line false = orber_tc:check_tc(orber_tc:alias("Id", "Name", "wrong")), + ?line code(orber_tc:alias("Id", "Name", orber_tc:struct("Id", "Name", ?ELIST))), + ?line ?match(code(orber_tc:alias("Id", "Name", orber_tc:struct("Id", "Name", ?VELIST)))), + ok. + +%%----------------------------------------------------------------- +%% Test Case: exception +%% Description: +%%----------------------------------------------------------------- +exception(doc) -> []; +exception(suite) -> []; +exception(_) -> + ?line true = orber_tc:check_tc(orber_tc:exception("Id", "Name", ?ELIST)), + ?line false = orber_tc:check_tc(orber_tc:exception(42, "Name", ?ELIST)), + ?line false = orber_tc:check_tc(orber_tc:exception("Id", false, ?ELIST)), + ?line false = orber_tc:check_tc(orber_tc:exception("Id", "Name", "wrong")), + ?line code(orber_tc:exception("Id", "Name", ?ELIST)), + ?line ?match(code(orber_tc:exception(42, "Name", ?ELIST))), + ?line ?match(code(orber_tc:exception("Id", false, ?ELIST))), + ?line ?match(code(orber_tc:exception("Id", "Name", "wrong"))), + + ok. + +%%----------------------------------------------------------------- +%% Test Case: fixed +%% Description: +%%----------------------------------------------------------------- +fixed(doc) -> []; +fixed(suite) -> []; +fixed(_) -> + ?line true = orber_tc:check_tc(orber_tc:fixed(25, 2)), + ?line code(orber_tc:fixed(25, 2)), + ok. + +%%----------------------------------------------------------------- +%% Test Case: value +%% Description: +%%----------------------------------------------------------------- +value(doc) -> []; +value(suite) -> []; +value(_) -> + ?line true = orber_tc:check_tc(orber_tc:value("Id", "Name", 42, + orber_tc:fixed(25, 2), ?VELIST)), + ?line false = orber_tc:check_tc(orber_tc:value(42, "Name", 42, + orber_tc:fixed(25, 2), ?VELIST)), + ?line false = orber_tc:check_tc(orber_tc:value("Id", 42, 42, + orber_tc:fixed(25, 2), ?VELIST)), + ?line false = orber_tc:check_tc(orber_tc:value("Id", "Name", "wrong", + orber_tc:fixed(25, 2), ?VELIST)), + ?line false = orber_tc:check_tc(orber_tc:value("Id", "Name", "42", + orber_tc:fixed(25, 2), ?VELIST)), + ?line false = orber_tc:check_tc(orber_tc:value("Id", "Name", "42", + ?VELIST, ?VELIST)), + ?line false = orber_tc:check_tc(orber_tc:value("Id", "Name", "42", + orber_tc:fixed(25, 2), false)), + + ?line code(orber_tc:value("Id", "Name", 42, orber_tc:long(), ?VELIST)), + ok. + +%%----------------------------------------------------------------- +%% Test Case: value_box +%% Description: +%%----------------------------------------------------------------- +value_box(doc) -> []; +value_box(suite) -> []; +value_box(_) -> + ?line true = orber_tc:check_tc(orber_tc:value_box("Id", "Name", + orber_tc:fixed(25, 2))), + ?line false = orber_tc:check_tc(orber_tc:value_box(42, "Name", + orber_tc:fixed(25, 2))), + ?line false = orber_tc:check_tc(orber_tc:value_box("Id", 42, + orber_tc:fixed(25, 2))), + ?line false = orber_tc:check_tc(orber_tc:value_box("Id", "Name", "wrong")), + ?line code(orber_tc:value_box("Id", "Name", orber_tc:long())), + ?line ?match(code(orber_tc:value_box(42, "Name", orber_tc:short()))), + ?line ?match(code(orber_tc:value_box("Id", 42, orber_tc:char()))), + ?line ?match(code(orber_tc:value_box("Id", "Name", false))), + ok. + +%%----------------------------------------------------------------- +%% Test Case: native +%% Description: +%%----------------------------------------------------------------- +native(doc) -> []; +native(suite) -> []; +native(_) -> + ?line true = orber_tc:check_tc(orber_tc:native("Id", "Name")), + ?line false = orber_tc:check_tc(orber_tc:native(42, "Name")), + ?line false = orber_tc:check_tc(orber_tc:native("Id", 42)), + ?line code(orber_tc:native("Id", "Name")), + ?line ?match(code(orber_tc:native(42, "Name"))), + ?line ?match(code(orber_tc:native("Id", 42))), + ok. + +%%----------------------------------------------------------------- +%% Test Case: abstract_interface +%% Description: +%%----------------------------------------------------------------- +abstract_interface(doc) -> []; +abstract_interface(suite) -> []; +abstract_interface(_) -> + ?line true = orber_tc:check_tc(orber_tc:abstract_interface("RepId", "Name")), + ?line false = orber_tc:check_tc(orber_tc:abstract_interface(false, "Name")), + ?line false = orber_tc:check_tc(orber_tc:abstract_interface("RepId", 42)), + ?line code(orber_tc:abstract_interface("RepId", "Name")), + ?line ?match(code(orber_tc:abstract_interface(42, "Name"))), + ?line ?match(code(orber_tc:abstract_interface("Id", 42))), + ok. + + + +%%----------------------------------------------------------------- +%% Test Case: indirection +%% Description: +%%----------------------------------------------------------------- +indirection(doc) -> []; +indirection(suite) -> []; +indirection(_) -> + ?line true = orber_tc:check_tc({'none', 42}), + ok. + +%%----------------------------------------------------------------- +%% Test Case: get_tc +%% Description: +%%----------------------------------------------------------------- +get_tc(doc) -> []; +get_tc(suite) -> []; +get_tc(_) -> + TC = 'CosNaming_Binding':tc(), + ?line TC = orber_tc:get_tc({'CosNaming_Binding', 42}), + ?line ?match(orber_tc:get_tc({'none', 42})), + ok. + +%%----------------------------------------------------------------- +%% MISC Operations +%%----------------------------------------------------------------- +code(Value) -> + cdr_encode:enc_type({1,2}, tk_TypeCode, Value). diff --git a/lib/orber/vsn.mk b/lib/orber/vsn.mk index 79847451d2..ec349ee189 100644 --- a/lib/orber/vsn.mk +++ b/lib/orber/vsn.mk @@ -1,7 +1,8 @@ ORBER_VSN = 3.6.16 -TICKETS = OTP-8489 +TICKETS = OTP-8489 \ + OTP-8543 TICKETS_3.6.15 = OTP-8353 \ OTP-8354 \ |