1%%-------------------------------------------------------------------- 2%% 3%% %CopyrightBegin% 4%% 5%% Copyright Ericsson AB 1999-2016. All Rights Reserved. 6%% 7%% Licensed under the Apache License, Version 2.0 (the "License"); 8%% you may not use this file except in compliance with the License. 9%% You may obtain a copy of the License at 10%% 11%% http://www.apache.org/licenses/LICENSE-2.0 12%% 13%% Unless required by applicable law or agreed to in writing, software 14%% distributed under the License is distributed on an "AS IS" BASIS, 15%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16%% See the License for the specific language governing permissions and 17%% limitations under the License. 18%% 19%% %CopyrightEnd% 20%% 21%% 22%%-------------------------------------------------------------------- 23%% File : notification_SUITE.erl 24%% Purpose : 25%%-------------------------------------------------------------------- 26 27-module(notification_SUITE). 28 29%%--------------- INCLUDES ----------------------------------- 30-include_lib("orber/include/corba.hrl"). 31-include_lib("orber/include/ifr_types.hrl"). 32%% cosEvent files. 33-include_lib("cosEvent/include/CosEventChannelAdmin.hrl"). 34%% Application files 35-include_lib("cosNotification/include/CosNotification.hrl"). 36-include_lib("cosNotification/include/CosNotifyChannelAdmin.hrl"). 37-include_lib("cosNotification/include/CosNotifyComm.hrl"). 38-include_lib("cosNotification/include/CosNotifyFilter.hrl"). 39 40-include_lib("cosNotification/src/CosNotification_Definitions.hrl"). 41 42-include("idl_output/notify_test.hrl"). 43 44-include_lib("common_test/include/ct.hrl"). 45 46%%--------------- DEFINES ------------------------------------ 47-define(default_timeout, test_server:minutes(20)). 48-define(match(ExpectedRes, Expr), 49 fun() -> 50 AcTuAlReS = (catch (Expr)), 51 case AcTuAlReS of 52 ExpectedRes -> 53 io:format("------ CORRECT RESULT ------~n~p~n", 54 [AcTuAlReS]), 55 AcTuAlReS; 56 _ -> 57 io:format("###### ERROR ERROR ######~n~p~n", 58 [AcTuAlReS]), 59 exit(AcTuAlReS) 60 end 61 end()). 62 63-define(defaultQoS, 64 [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), 65 value=any:create(orber_tc:long(), 100)}, 66 #'CosNotification_Property'{name='CosNotification':'PacingInterval'(), 67 value=any:create(orber_tc:unsigned_long_long(), 68 20000000)}, 69 #'CosNotification_Property'{name='CosNotification':'OrderPolicy'(), 70 value=any:create(orber_tc:short(), 71 'CosNotification':'AnyOrder'())}, 72 #'CosNotification_Property'{name='CosNotification':'EventReliability'(), 73 value=any:create(orber_tc:short(), 74 'CosNotification':'BestEffort'())}, 75 #'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), 76 value=any:create(orber_tc:short(), 77 'CosNotification':'BestEffort'())}, 78 #'CosNotification_Property'{name='CosNotification':'DiscardPolicy'(), 79 value=any:create(orber_tc:short(), 80 'CosNotification':'AnyOrder'())}, 81 #'CosNotification_Property'{name='CosNotification':'StartTimeSupported'(), 82 value=any:create(orber_tc:boolean(), false)}, 83 #'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), 84 value=any:create(orber_tc:boolean(), false)}, 85 #'CosNotification_Property'{name='CosNotification':'Priority'(), 86 value=any:create(orber_tc:short(), 87 'CosNotification':'DefaultPriority'())}]). 88-define(defaultQoS2, 89 [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), 90 value=any:create(orber_tc:long(), 1)}, 91 #'CosNotification_Property'{name='CosNotification':'PacingInterval'(), 92 value=any:create(orber_tc:unsigned_long_long(), 93 0)}, 94 #'CosNotification_Property'{name='CosNotification':'OrderPolicy'(), 95 value=any:create(orber_tc:short(), 96 'CosNotification':'AnyOrder'())}, 97 #'CosNotification_Property'{name='CosNotification':'EventReliability'(), 98 value=any:create(orber_tc:short(), 99 'CosNotification':'BestEffort'())}, 100 #'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), 101 value=any:create(orber_tc:short(), 102 'CosNotification':'BestEffort'())}, 103 #'CosNotification_Property'{name='CosNotification':'DiscardPolicy'(), 104 value=any:create(orber_tc:short(), 105 'CosNotification':'AnyOrder'())}, 106 #'CosNotification_Property'{name='CosNotification':'StartTimeSupported'(), 107 value=any:create(orber_tc:boolean(), false)}, 108 #'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), 109 value=any:create(orber_tc:boolean(), false)}, 110 #'CosNotification_Property'{name='CosNotification':'Priority'(), 111 value=any:create(orber_tc:short(), 112 'CosNotification':'DefaultPriority'())}]). 113-define(defaultAdm, 114 [#'CosNotification_Property'{name='CosNotification':'MaxQueueLength'(), 115 value=any:create(orber_tc:long(), 100)}, 116 #'CosNotification_Property'{name='CosNotification':'MaxConsumers'(), 117 value=any:create(orber_tc:long(), 100)}, 118 #'CosNotification_Property'{name='CosNotification':'MaxSuppliers'(), 119 value=any:create(orber_tc:long(), 100)}]). 120 121-define(FAC_OPT, []). 122 123 124%%----------------------------------------------------------------- 125%% External exports 126%%----------------------------------------------------------------- 127-export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, cases/0, 128 init_per_suite/1, end_per_suite/1, qos_api/1, adm_api/1, 129 cosevent_api/1, filter_adm_api/1, events_api/1, events2_api/1, 130 event_qos_api/1, filter_api/1, mapping_filter_api/1, subscription_api/1, 131 init_per_testcase/2, end_per_testcase/2, persistent_max_events_api/1, 132 persistent_timeout_events_api/1, persistent_recover_events_api/1, 133 app_test/1]). 134 135-export([terminated/1]). 136 137%%----------------------------------------------------------------- 138%% Func: all/1 139%% Args: 140%% Returns: 141%%----------------------------------------------------------------- 142suite() -> [{ct_hooks,[ts_install_cth]}]. 143 144all() -> 145 cases(). 146 147groups() -> 148 []. 149 150init_per_group(_GroupName, Config) -> 151 Config. 152 153end_per_group(_GroupName, Config) -> 154 Config. 155 156cases() -> 157 [persistent_max_events_api, 158 persistent_timeout_events_api, 159 persistent_recover_events_api, mapping_filter_api, 160 filter_api, filter_adm_api, event_qos_api, qos_api, 161 adm_api, cosevent_api, subscription_api, events_api, 162 events2_api, app_test]. 163 164%%----------------------------------------------------------------- 165%% Init and cleanup functions. 166%%----------------------------------------------------------------- 167init_per_testcase(_Case, Config) -> 168 Path = code:which(?MODULE), 169 code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), 170 Dog=test_server:timetrap(?default_timeout), 171 [{watchdog, Dog}|Config]. 172 173end_per_testcase(_Case, Config) -> 174 Path = code:which(?MODULE), 175 code:del_path(filename:join(filename:dirname(Path), "idl_output")), 176 Dog = proplists:get_value(watchdog, Config), 177 test_server:timetrap_cancel(Dog), 178 ok. 179 180init_per_suite(Config) -> 181 Path = code:which(?MODULE), 182 code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), 183 ok = corba:orb_init([{flags, 16#02}, {orber_debug_level, 10}]), 184 orber:jump_start(), 185 cosNotificationApp:install_event(), 186 cosNotificationApp:install(), 187 'oe_notify_test_server':'oe_register'(), 188 cosNotificationApp:start(), 189 if 190 is_list(Config) -> 191 Config; 192 true -> 193 exit("Config not a list") 194 end. 195 196end_per_suite(Config) -> 197 cosNotificationApp:stop(), 198 Path = code:which(?MODULE), 199 code:del_path(filename:join(filename:dirname(Path), "idl_output")), 200 'oe_notify_test_server':'oe_unregister'(), 201 cosNotificationApp:uninstall(), 202 cosNotificationApp:uninstall_event(), 203 orber:jump_stop(), 204 Config. 205 206 207%%----------------------------------------------------------------- 208%% Tests app file 209%%----------------------------------------------------------------- 210app_test(_Config) -> 211 ok=test_server:app_test(cosNotification), 212 ok. 213 214 215%%----------------------------------------------------------------- 216%% Persistent events max limit 217%%----------------------------------------------------------------- 218persistent_max_events_api(_Config) -> 219 QoSPersistent = 220 [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), 221 value=any:create(orber_tc:short(), 222 'CosNotification':'Persistent'())}], 223 QoSEventPersistent = 224 [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), 225 value=any:create(orber_tc:short(), 226 'CosNotification':'Persistent'())}], 227 application:set_env(cosNotification, notify, ?MODULE), 228 application:set_env(cosNotification, max_events, 2), 229 application:set_env(cosNotification, timeout_events, 300000), 230 application:set_env(cosNotification, interval_events, 10000), 231 %% Initialize the application. 232 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 233 ?match({_,key,_,_,_,_}, Fac), 234 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS2, ?defaultAdm)), 235 ?match({_,key,_,_,_,_}, Ch), 236 237 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), 238 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), 239 240 %% Create the Admin objects 241 {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, 242 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'AND_OP')), 243 {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, 244 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'AND_OP')), 245 246 %% Create Proxies and clients 247 {SequenceProxyPushSupplier,_ID}=?match({{_,key,_,_,_,_},_}, 248 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'SEQUENCE_EVENT')), 249 PushSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',SequenceProxyPushSupplier], 250 [{local_typecheck, false}])), 251 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(SequenceProxyPushSupplier, PushSeqC)), 252 253 {SequenceProxyPushConsumer,_ID}=?match({{_,key,_,_,_,_},_}, 254 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'SEQUENCE_EVENT')), 255 PushSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',SequenceProxyPushConsumer], 256 [{local_typecheck, false}])), 257 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(SequenceProxyPushConsumer, PushSeqS)), 258 259 %% Create a couple of Events to test with. 260 Event = ?not_CreateSE("DomainName","CommunicationsAlarm", 261 "lost_packet", 262 [#'CosNotification_Property'{name="priority", 263 value=any:create(orber_tc:short(), 1)}], 264 [], any:create(orber_tc:null(), null)), 265 266 ?match(ok, 'notify_test_SeqPushC':doAction(PushSeqC, {action, action})), 267 268 %% Push and check the state. 269 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), 270 ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 271 ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), 272 273 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), 274 ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 275 ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), 276 %% Now we've reached the limit. This call will terminate the proxy. 277 %% We cannot check for data at this point since the broken connection 278 %% will result in that the client terminates. 279 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), 280 timer:sleep(5000), 281 ?match(true, corba_object:non_existent(SequenceProxyPushSupplier)), 282 ?match(true, corba_object:non_existent(PushSeqC)), 283 284 285 catch corba:dispose(SequenceProxyPushConsumer), 286 catch corba:dispose(SequenceProxyPushSupplier), 287 catch corba:dispose(AdminConsumer), 288 catch corba:dispose(AdminSupplier), 289 catch corba:dispose(Ch), 290 catch cosNotificationApp:stop_factory(Fac), 291 catch corba:dispose(PushSeqS), 292 catch corba:dispose(PushSeqC), 293 application:set_env(cosNotification, notify, undefined), 294 application:set_env(cosNotification, max_events, undefined), 295 application:set_env(cosNotification, timeout_events, undefined), 296 application:set_env(cosNotification, interval_events, undefined), 297 ok. 298 299terminated(Items) -> 300 io:format("Proxy terminated due to: ~p~n", [Items]). 301 302%%----------------------------------------------------------------- 303%% Persistent events timeout 304%%----------------------------------------------------------------- 305persistent_timeout_events_api(_Config) -> 306 QoSPersistent = 307 [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), 308 value=any:create(orber_tc:short(), 309 'CosNotification':'Persistent'())}], 310 QoSEventPersistent = 311 [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), 312 value=any:create(orber_tc:short(), 313 'CosNotification':'Persistent'())}], 314 application:set_env(cosNotification, notify, ?MODULE), 315 application:set_env(cosNotification, max_events, 1000), 316 application:set_env(cosNotification, timeout_events, 4000), 317 application:set_env(cosNotification, interval_events, 1000), 318 %% Initialize the application. 319 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 320 ?match({_,key,_,_,_,_}, Fac), 321 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS2, ?defaultAdm)), 322 ?match({_,key,_,_,_,_}, Ch), 323 324 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), 325 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), 326 327 %% Create the Admin objects 328 {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, 329 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'AND_OP')), 330 {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, 331 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'AND_OP')), 332 333 %% Create Proxies and clients 334 {SequenceProxyPushSupplier,_ID}=?match({{_,key,_,_,_,_},_}, 335 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'SEQUENCE_EVENT')), 336 PushSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',SequenceProxyPushSupplier], 337 [{local_typecheck, false}])), 338 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(SequenceProxyPushSupplier, PushSeqC)), 339 340 {SequenceProxyPushConsumer,_ID}=?match({{_,key,_,_,_,_},_}, 341 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'SEQUENCE_EVENT')), 342 PushSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',SequenceProxyPushConsumer], 343 [{local_typecheck, false}])), 344 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(SequenceProxyPushConsumer, PushSeqS)), 345 346 %% Create a couple of Events to test with. 347 Event = ?not_CreateSE("DomainName","CommunicationsAlarm", 348 "lost_packet", 349 [#'CosNotification_Property'{name="priority", 350 value=any:create(orber_tc:short(), 1)}], 351 [], any:create(orber_tc:null(), null)), 352 353 ?match(ok, 'notify_test_SeqPushC':doAction(PushSeqC, {action, action})), 354 355 %% Push and check the state. 356 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), 357 ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 358 ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), 359 360 %% Now we've reached the limit. This call will terminate the proxy. 361 %% We cannot check for data at this point since the broken connection 362 %% will result in that the client terminates. 363 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), 364 timer:sleep(10000), 365 ?match(true, corba_object:non_existent(SequenceProxyPushSupplier)), 366 ?match(true, corba_object:non_existent(PushSeqC)), 367 368 369 catch corba:dispose(SequenceProxyPushConsumer), 370 catch corba:dispose(SequenceProxyPushSupplier), 371 catch corba:dispose(AdminConsumer), 372 catch corba:dispose(AdminSupplier), 373 catch corba:dispose(Ch), 374 catch cosNotificationApp:stop_factory(Fac), 375 catch corba:dispose(PushSeqS), 376 catch corba:dispose(PushSeqC), 377 application:set_env(cosNotification, notify, undefined), 378 application:set_env(cosNotification, max_events, undefined), 379 application:set_env(cosNotification, timeout_events, undefined), 380 application:set_env(cosNotification, interval_events, undefined), 381 ok. 382 383%%----------------------------------------------------------------- 384%% Persistent events max limit 385%%----------------------------------------------------------------- 386persistent_recover_events_api(_Config) -> 387 QoSPersistent = 388 [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), 389 value=any:create(orber_tc:short(), 390 'CosNotification':'Persistent'())}], 391 QoSEventPersistent = 392 [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), 393 value=any:create(orber_tc:short(), 394 'CosNotification':'Persistent'())}], 395 application:set_env(cosNotification, notify, ?MODULE), 396 application:set_env(cosNotification, max_events, 1000), 397 application:set_env(cosNotification, timeout_events, 100000), 398 application:set_env(cosNotification, interval_events, 1000), 399 %% Initialize the application. 400 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 401 ?match({_,key,_,_,_,_}, Fac), 402 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS2, ?defaultAdm)), 403 ?match({_,key,_,_,_,_}, Ch), 404 405 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), 406 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), 407 408 %% Create the Admin objects 409 {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, 410 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'AND_OP')), 411 {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, 412 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'AND_OP')), 413 414 %% Create Proxies and clients 415 {SequenceProxyPushSupplier,_ID}=?match({{_,key,_,_,_,_},_}, 416 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'SEQUENCE_EVENT')), 417 PushSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',SequenceProxyPushSupplier], 418 [{local_typecheck, false}])), 419 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(SequenceProxyPushSupplier, PushSeqC)), 420 421 {SequenceProxyPushConsumer,_ID}=?match({{_,key,_,_,_,_},_}, 422 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'SEQUENCE_EVENT')), 423 PushSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',SequenceProxyPushConsumer], 424 [{local_typecheck, false}])), 425 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(SequenceProxyPushConsumer, PushSeqS)), 426 427 %% Create a couple of Events to test with. 428 Event = ?not_CreateSE("DomainName","CommunicationsAlarm", 429 "lost_packet", 430 [#'CosNotification_Property'{name="priority", 431 value=any:create(orber_tc:short(), 1)}], 432 [], any:create(orber_tc:null(), null)), 433 434 ?match(ok, 'notify_test_SeqPushC':doAction(PushSeqC, {action, action})), 435 436 %% Push and check the state. 437 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), 438 ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 439 ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), 440 %% Allow the proxy to try a few times and then change the client behavior 441 timer:sleep(4000), 442 ?match(ok, 'notify_test_SeqPushC':doAction(PushSeqC, {action, undefined})), 443 %% Wait some time so that the proxy timeout has kicked in. 444 timer:sleep(4000), 445 446 %% Now the communication should work again. 447 ?match([Event], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 448 ?match(false, corba_object:non_existent(SequenceProxyPushSupplier)), 449 450 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, [Event])), 451 timer:sleep(4000), 452 ?match([Event], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 453 454 catch corba:dispose(SequenceProxyPushConsumer), 455 catch corba:dispose(SequenceProxyPushSupplier), 456 catch corba:dispose(AdminConsumer), 457 catch corba:dispose(AdminSupplier), 458 catch corba:dispose(Ch), 459 catch cosNotificationApp:stop_factory(Fac), 460 catch corba:dispose(PushSeqS), 461 catch corba:dispose(PushSeqC), 462 application:set_env(cosNotification, notify, undefined), 463 application:set_env(cosNotification, max_events, undefined), 464 application:set_env(cosNotification, timeout_events, undefined), 465 application:set_env(cosNotification, interval_events, undefined), 466 ok. 467 468 469%%----------------------------------------------------------------- 470%% CosNotifyFilter::Filter API tests 471%%----------------------------------------------------------------- 472mapping_filter_api(_Config) -> 473 FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), 474 ?match({_,key,_,_,_,_}, FiFac), 475 476 Filter = 'CosNotifyFilter_FilterFactory':create_mapping_filter(FiFac, 477 "EXTENDED_TCL", 478 any:create(orber_tc:short(), 10)), 479 ?match({_,key,_,_,_,_}, Filter), 480 481 ?match("EXTENDED_TCL", 'CosNotifyFilter_MappingFilter':'_get_constraint_grammar'(Filter)), 482 483 %% Test before we add any constarints. 484 ?match([], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), 485 ?match({'EXCEPTION', {'CosNotifyFilter_ConstraintNotFound', _, 1}}, 486 'CosNotifyFilter_MappingFilter':get_mapping_constraints(Filter, [1])), 487 ?match(ok, 'CosNotifyFilter_MappingFilter':remove_all_mapping_constraints(Filter)), 488 489 %% Try adding an incorrect constraint_expr 490 ?match({'EXCEPTION',{'CosNotifyFilter_InvalidConstraint',_,_}}, 491 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 492 [#'CosNotifyFilter_MappingConstraintPair' 493 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 494 {event_types = [#'CosNotification_EventType' 495 {domain_name = "name", 496 type_name = "type"}], 497 constraint_expr = "2==2 and 3<"}, 498 result_to_set = any:create(orber_tc:short(), 10)}])), 499 %% Try adding two correct constraint_expr 500 [{_,_,CID1,_},{_,_,CID2,_}]= 501 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}, {'CosNotifyFilter_MappingConstraintInfo',_,_,_}], 502 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 503 [#'CosNotifyFilter_MappingConstraintPair' 504 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 505 {event_types = [#'CosNotification_EventType' 506 {domain_name = "name", 507 type_name = "type"}], 508 constraint_expr = "2==2 and 3<4"}, 509 result_to_set = any:create(orber_tc:short(), 10)}, 510 #'CosNotifyFilter_MappingConstraintPair' 511 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 512 {event_types = [#'CosNotification_EventType' 513 {domain_name = "name2", 514 type_name = "type2"}], 515 constraint_expr = "$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80"}, 516 result_to_set = any:create(orber_tc:short(), 10)}])), 517 518 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,CID2,_}, {'CosNotifyFilter_MappingConstraintInfo',_,CID1,_}], 519 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), 520 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,CID1,_}], 521 'CosNotifyFilter_MappingFilter':get_mapping_constraints(Filter, [CID1])), 522 ?match(ok, 'CosNotifyFilter_MappingFilter':remove_all_mapping_constraints(Filter)), 523 ?match([], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), 524 525 %% Try adding a constraint_expr with using invalid value, i.e., not short. 526 ?match({'EXCEPTION',{'CosNotifyFilter_InvalidValue',_,_,_}}, 527 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 528 [#'CosNotifyFilter_MappingConstraintPair' 529 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 530 {event_types = [#'CosNotification_EventType' 531 {domain_name = "name", 532 type_name = "type"}], 533 constraint_expr = "2==2 and 3<8"}, 534 result_to_set = any:create(orber_tc:long(), 10)}])), 535 536 %% Try adding one correct and one incorrect constraint_expr 537 ?match({'EXCEPTION',{'CosNotifyFilter_InvalidConstraint',_,_}}, 538 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 539 [#'CosNotifyFilter_MappingConstraintPair' 540 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 541 {event_types = [#'CosNotification_EventType' 542 {domain_name = "name", 543 type_name = "type"}], 544 constraint_expr = "2==2 and 3<"}, 545 result_to_set = any:create(orber_tc:short(), 10)}, 546 #'CosNotifyFilter_MappingConstraintPair' 547 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 548 {event_types = [#'CosNotification_EventType' 549 {domain_name = "name2", 550 type_name = "type2"}], 551 constraint_expr = "$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80"}, 552 result_to_set = any:create(orber_tc:short(), 10)}])), 553 554 %% Following testcases test different domain_name and type_name, e.g., 555 %% wildcards etc. 556 [{_,ConInfoData,CID3,_}] = 557 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], 558 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 559 [#'CosNotifyFilter_MappingConstraintPair' 560 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 561 {event_types = [#'CosNotification_EventType' 562 {domain_name = "domain", 563 type_name = ""}, 564 #'CosNotification_EventType' 565 {domain_name = "*", 566 type_name = "type"}], 567 constraint_expr = "2==2 and 3<4"}, 568 result_to_set = any:create(orber_tc:short(), 10)}])), 569 570 %% Try removing a constraint 571 ?match(ok, 'CosNotifyFilter_MappingFilter':modify_mapping_constraints(Filter,[CID3],[])), 572 ?match([], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), 573 574 %% Add e new constraint 575 [{_,_,CID4,_}] = 576 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], 577 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 578 [#'CosNotifyFilter_MappingConstraintPair' 579 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 580 {event_types = [#'CosNotification_EventType' 581 {domain_name = "domain1", 582 type_name = ""}, 583 #'CosNotification_EventType' 584 {domain_name = "domain2", 585 type_name = "*"}], 586 constraint_expr = "2==2 and 3<4"}, 587 result_to_set = any:create(orber_tc:short(), 10)}])), 588 589 %% Try to update the constraint associated with CID4 to equal CID3. 590 ?match(ok, 'CosNotifyFilter_MappingFilter':modify_mapping_constraints(Filter,[], 591 [#'CosNotifyFilter_MappingConstraintInfo' 592 {constraint_expression= 593 #'CosNotifyFilter_ConstraintExp' 594 {event_types =[#'CosNotification_EventType' 595 {domain_name = "domain", 596 type_name = ""}, 597 #'CosNotification_EventType' 598 {domain_name = "*", 599 type_name = "type"}], 600 constraint_expr = "2==2 and 3<4"}, 601 constraint_id=CID4, 602 value = any:create(orber_tc:short(), 10)}])), 603 604 ?match([{_,ConInfoData,CID4,_}], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), 605 606 ?match({'EXCEPTION', {'CosNotifyFilter_ConstraintNotFound', _, CID3}}, 607 'CosNotifyFilter_MappingFilter':get_mapping_constraints(Filter, [CID3])), 608 ?match(ok, 'CosNotifyFilter_MappingFilter':remove_all_mapping_constraints(Filter)), 609 ?match([], 'CosNotifyFilter_MappingFilter':get_all_mapping_constraints(Filter)), 610 611 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], 612 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 613 [#'CosNotifyFilter_MappingConstraintPair' 614 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 615 {event_types = [#'CosNotification_EventType' 616 {domain_name = "", 617 type_name = "type1"}, 618 #'CosNotification_EventType' 619 {domain_name = "*", 620 type_name = "type2"}], 621 constraint_expr = "2==2 and 3<4"}, 622 result_to_set = any:create(orber_tc:short(), 10)}])), 623 624 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], 625 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 626 [#'CosNotifyFilter_MappingConstraintPair' 627 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 628 {event_types = [#'CosNotification_EventType' 629 {domain_name = "domain1", 630 type_name = "type1"}, 631 #'CosNotification_EventType' 632 {domain_name = "domain2", 633 type_name = "type2"}], 634 constraint_expr = "2==2 and 3<4"}, 635 result_to_set = any:create(orber_tc:short(), 10)}])), 636 637 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], 638 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 639 [#'CosNotifyFilter_MappingConstraintPair' 640 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 641 {event_types = [#'CosNotification_EventType' 642 {domain_name = "dom*", 643 type_name = "type1"}, 644 #'CosNotification_EventType' 645 {domain_name = "domain2", 646 type_name = "typ*"}], 647 constraint_expr = "2==2 and 3<4"}, 648 result_to_set = any:create(orber_tc:short(), 10)}])), 649 650 ?match([{'CosNotifyFilter_MappingConstraintInfo',_,_,_}], 651 'CosNotifyFilter_MappingFilter':add_mapping_constraints(Filter, 652 [#'CosNotifyFilter_MappingConstraintPair' 653 {constraint_expression = #'CosNotifyFilter_ConstraintExp' 654 {event_types = [#'CosNotification_EventType' 655 {domain_name = "dom*1", 656 type_name = "type1"}, 657 #'CosNotification_EventType' 658 {domain_name = "domain2", 659 type_name = "typ*2"}], 660 constraint_expr = "2==2 and 3<4"}, 661 result_to_set = any:create(orber_tc:short(), 10)}])), 662 663 catch corba:dispose(FiFac), 664 catch corba:dispose(Filter), 665 ok. 666 667 668%%----------------------------------------------------------------- 669%% CosNotifyFilter::Filter API tests 670%%----------------------------------------------------------------- 671filter_api(_Config) -> 672 Fac = cosNotificationApp:start_global_factory(?FAC_OPT), 673 ?match({_,key,_,_,_,_}, Fac), 674 {Ch, _Id1} = 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm), 675 AC= 'CosNotifyChannelAdmin_EventChannel':for_consumers(Ch), 676 677 FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), 678 ?match({_,key,_,_,_,_}, FiFac), 679 680 Filter = 'CosNotifyFilter_FilterFactory':create_filter(FiFac,"EXTENDED_TCL"), 681 ?match({_,key,_,_,_,_}, Filter), 682 683 ?match("EXTENDED_TCL", 'CosNotifyFilter_Filter':'_get_constraint_grammar'(Filter)), 684 685 %% Test Callback management. 686 ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, 687 'CosNotifyFilter_Filter':attach_callback(Filter, Ch)), 688 ?match([], 'CosNotifyFilter_Filter':get_callbacks(Filter)), 689 ?match({'EXCEPTION',{'CosNotifyFilter_CallbackNotFound',_}}, 690 'CosNotifyFilter_Filter':detach_callback(Filter, 0)), 691 ID='CosNotifyFilter_Filter':attach_callback(Filter, AC), 692 ?match([ID], 'CosNotifyFilter_Filter':get_callbacks(Filter)), 693 ?match(ok, 'CosNotifyFilter_Filter':detach_callback(Filter, ID)), 694 ?match([], 'CosNotifyFilter_Filter':get_callbacks(Filter)), 695 696 %% This callback is just attached so we can test that we can call notify_subscribe. 697 _ID2='CosNotifyFilter_Filter':attach_callback(Filter, AC), 698 699 %% Test before we add any constarints. 700 ?match([], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), 701 ?match({'EXCEPTION', {'CosNotifyFilter_ConstraintNotFound', _, 1}}, 702 'CosNotifyFilter_Filter':get_constraints(Filter, [1])), 703 ?match(ok, 'CosNotifyFilter_Filter':remove_all_constraints(Filter)), 704 705 %% Try adding an incorrect constraint_expr 706 ?match({'EXCEPTION',{'CosNotifyFilter_InvalidConstraint',_,_}}, 707 'CosNotifyFilter_Filter':add_constraints(Filter, 708 [#'CosNotifyFilter_ConstraintExp'{event_types = 709 [#'CosNotification_EventType'{ 710 domain_name = "name", 711 type_name = "type"}], 712 constraint_expr = "2==2 and 3<"}])), 713 %% Try adding two correct constraint_expr 714 [{_,_,CID1},{_,_,CID2}]= 715 ?match([{'CosNotifyFilter_ConstraintInfo',_,_}, {'CosNotifyFilter_ConstraintInfo',_,_}], 716 'CosNotifyFilter_Filter':add_constraints(Filter, 717 [#'CosNotifyFilter_ConstraintExp'{event_types = 718 [#'CosNotification_EventType'{ 719 domain_name = "name", 720 type_name = "type"}], 721 constraint_expr = "2==2 and 3<4"}, 722 #'CosNotifyFilter_ConstraintExp'{event_types = 723 [#'CosNotification_EventType'{ 724 domain_name = "name2", 725 type_name = "type2"}], 726 constraint_expr = "$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80"}])), 727 728 ?match([{'CosNotifyFilter_ConstraintInfo',_,CID2}, {'CosNotifyFilter_ConstraintInfo',_,CID1}], 729 'CosNotifyFilter_Filter':get_all_constraints(Filter)), 730 ?match([{'CosNotifyFilter_ConstraintInfo',_,CID1}], 731 'CosNotifyFilter_Filter':get_constraints(Filter, [CID1])), 732 ?match(ok, 'CosNotifyFilter_Filter':remove_all_constraints(Filter)), 733 ?match([], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), 734 735 %% Try adding one correct and one incorrect constraint_expr 736 ?match({'EXCEPTION',{'CosNotifyFilter_InvalidConstraint',_,_}}, 737 'CosNotifyFilter_Filter':add_constraints(Filter, 738 [#'CosNotifyFilter_ConstraintExp'{event_types = 739 [#'CosNotification_EventType'{ 740 domain_name = "name", 741 type_name = "type"}], 742 constraint_expr = "2==2 and 3<"}, 743 #'CosNotifyFilter_ConstraintExp'{event_types = 744 [#'CosNotification_EventType'{ 745 domain_name = "name2", 746 type_name = "type2"}], 747 constraint_expr = "$.test._length == 3 and ($.test[0].score + $.test[1].score + $.test[2].score)/3 >=80"}])), 748 749 %% Following testcases test different domain_name and type_name, e.g., 750 %% wildcards etc. 751 [{_,ConInfoData,CID3}] = 752 ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], 753 'CosNotifyFilter_Filter':add_constraints(Filter, 754 [#'CosNotifyFilter_ConstraintExp'{event_types = 755 [#'CosNotification_EventType'{ 756 domain_name = "domain", 757 type_name = ""}, 758 #'CosNotification_EventType'{ 759 domain_name = "*", 760 type_name = "type"}], 761 constraint_expr = "2==2 and 3<4"}])), 762 763 %% Try removing a constraint 764 ?match(ok, 'CosNotifyFilter_Filter':modify_constraints(Filter,[CID3],[])), 765 ?match([], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), 766 767 %% Add e new constraint 768 [{_,_,CID4}] = 769 ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], 770 'CosNotifyFilter_Filter':add_constraints(Filter, 771 [#'CosNotifyFilter_ConstraintExp'{event_types = 772 [#'CosNotification_EventType'{ 773 domain_name = "domain1", 774 type_name = ""}, 775 #'CosNotification_EventType'{ 776 domain_name = "domain2", 777 type_name = "*"}], 778 constraint_expr = "2==2 and 3<4"}])), 779 780 %% Try to update the constraint associated with CID4 to equal CID3. 781 ?match(ok, 'CosNotifyFilter_Filter':modify_constraints(Filter,[], 782 [#'CosNotifyFilter_ConstraintInfo'{constraint_expression= 783 #'CosNotifyFilter_ConstraintExp'{event_types = 784 [#'CosNotification_EventType'{ 785 domain_name = "domain", 786 type_name = ""}, 787 #'CosNotification_EventType'{ 788 domain_name = "*", 789 type_name = "type"}], 790 constraint_expr = "2==2 and 3<4"}, 791 constraint_id=CID4}])), 792 793 ?match([{_,ConInfoData,CID4}], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), 794 795 ?match({'EXCEPTION', {'CosNotifyFilter_ConstraintNotFound', _, CID3}}, 796 'CosNotifyFilter_Filter':get_constraints(Filter, [CID3])), 797 ?match(ok, 'CosNotifyFilter_Filter':remove_all_constraints(Filter)), 798 ?match([], 'CosNotifyFilter_Filter':get_all_constraints(Filter)), 799 800 ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], 801 'CosNotifyFilter_Filter':add_constraints(Filter, 802 [#'CosNotifyFilter_ConstraintExp'{event_types = 803 [#'CosNotification_EventType'{ 804 domain_name = "", 805 type_name = "type1"}, 806 #'CosNotification_EventType'{ 807 domain_name = "*", 808 type_name = "type2"}], 809 constraint_expr = "2==2 and 3<4"}])), 810 811 ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], 812 'CosNotifyFilter_Filter':add_constraints(Filter, 813 [#'CosNotifyFilter_ConstraintExp'{event_types = 814 [#'CosNotification_EventType'{ 815 domain_name = "domain1", 816 type_name = "type1"}, 817 #'CosNotification_EventType'{ 818 domain_name = "domain2", 819 type_name = "type2"}], 820 constraint_expr = "2==2 and 3<4"}])), 821 822 ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], 823 'CosNotifyFilter_Filter':add_constraints(Filter, 824 [#'CosNotifyFilter_ConstraintExp'{event_types = 825 [#'CosNotification_EventType'{ 826 domain_name = "dom*", 827 type_name = "type1"}, 828 #'CosNotification_EventType'{ 829 domain_name = "domain2", 830 type_name = "typ*"}], 831 constraint_expr = "2==2 and 3<4"}])), 832 833 ?match([{'CosNotifyFilter_ConstraintInfo',_,_}], 834 'CosNotifyFilter_Filter':add_constraints(Filter, 835 [#'CosNotifyFilter_ConstraintExp'{event_types = 836 [#'CosNotification_EventType'{ 837 domain_name = "dom*1", 838 type_name = "type1"}, 839 #'CosNotification_EventType'{ 840 domain_name = "domain2", 841 type_name = "typ*2"}], 842 constraint_expr = "2==2 and 3<4"}])), 843 844 catch corba:dispose(FiFac), 845 catch corba:dispose(Filter), 846 catch corba:dispose(AC), 847 catch corba:dispose(Ch), 848 catch corba:dispose(Fac), 849 ok. 850 851%%----------------------------------------------------------------- 852%% Subscription handling API tests 853%%----------------------------------------------------------------- 854subscription_api(_Config) -> 855 %% Initialize the application. 856 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 857 ?match({_,key,_,_,_,_}, Fac), 858 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), 859 ?match({_,key,_,_,_,_}, Ch), 860 861 %% Create the Admin objects 862 {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, 863 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'OR_OP')), 864 {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, 865 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'OR_OP')), 866 867 %% Create Suppliers Proxies 868 {StructuredProxyPullSupplier,_}=?match({{_,key,_,_,_,_},_}, 869 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'STRUCTURED_EVENT')), 870 {StructuredProxyPushSupplier,_}=?match({{_,key,_,_,_,_},_}, 871 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'STRUCTURED_EVENT')), 872 873 %% Now we must create a Client for each proxy and connect them. 874 PushStrC=?match({_,key,_,_,_,_}, 'notify_test_StrPushC':oe_create(['PUSH_STRUCTURED',StructuredProxyPushSupplier], 875 [{local_typecheck, false}])), 876 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':connect_structured_push_consumer(StructuredProxyPushSupplier, PushStrC)), 877 PullStrC=?match({_,key,_,_,_,_}, 'notify_test_StrPullC':oe_create(['PULL_STRUCTURED',StructuredProxyPullSupplier], 878 [{local_typecheck, false}])), 879 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':connect_structured_pull_consumer(StructuredProxyPullSupplier, PullStrC)), 880 881 %% Create Consumers Proxies 882 {StructuredProxyPullConsumer,_}=?match({{_,key,_,_,_,_},_}, 883 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(AdminSupplier, 'STRUCTURED_EVENT')), 884 {StructuredProxyPushConsumer,_}=?match({{_,key,_,_,_,_},_}, 885 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'STRUCTURED_EVENT')), 886 887 %% Now we must create a Client for each proxy and connect them. 888 PushStrS=?match({_,key,_,_,_,_}, 'notify_test_StrPushS':oe_create(['PUSH_STRUCTURED',StructuredProxyPushConsumer], 889 [{local_typecheck, false}])), 890 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':connect_structured_push_supplier(StructuredProxyPushConsumer, PushStrS)), 891 892 PullStrS=?match({_,key,_,_,_,_}, 'notify_test_StrPullS':oe_create(['PULL_STRUCTURED',StructuredProxyPullConsumer], 893 [{local_typecheck, false}])), 894 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':connect_structured_pull_supplier(StructuredProxyPullConsumer, PullStrS)), 895 896 ES1=[#'CosNotification_EventType'{domain_name = "name1", type_name = "type1"}, 897 #'CosNotification_EventType'{domain_name = "name2", type_name = "type2"}], 898 ES2=[#'CosNotification_EventType'{domain_name = "name3", type_name = "type3"}, 899 #'CosNotification_EventType'{domain_name = "name4", type_name = "type4"}], 900 901 %% Initially it should have no associated types. Test that and set that 902 %% all updates should be forwarded to client. 903 ?match([], 'CosNotifyChannelAdmin_StructuredProxyPushConsumer': 904 obtain_subscription_types(StructuredProxyPushConsumer, 905 'ALL_NOW_UPDATES_ON')), 906 ?match([], 'CosNotifyChannelAdmin_StructuredProxyPullConsumer': 907 obtain_subscription_types(StructuredProxyPullConsumer, 908 'ALL_NOW_UPDATES_ON')), 909 910 %% Update the offered types. 911 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer': 912 offer_change(StructuredProxyPushConsumer, ES1, [])), 913 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer': 914 offer_change(StructuredProxyPullConsumer, ES1, [])), 915 916 %% To be sure, wait a couple of seconds. 917 timer:sleep(5000), 918 ?match([{'CosNotification_EventType',_,_}, 919 {'CosNotification_EventType',_,_}], 920 'notify_test_StrPushC':doAction(PushStrS, return_data)), 921 ?match([{'CosNotification_EventType',_,_}, 922 {'CosNotification_EventType',_,_}], 923 'notify_test_StrPullC':doAction(PullStrS, return_data)), 924 925 %% Update the offered types. Remove ES1 and add ES2. 926 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer': 927 offer_change(StructuredProxyPushConsumer, ES2, ES1)), 928 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer': 929 offer_change(StructuredProxyPullConsumer, ES2, ES1)), 930 931 %% To be sure, wait a couple of seconds. 932 timer:sleep(5000), 933 ?match([{'CosNotification_EventType',_,_}, 934 {'CosNotification_EventType',_,_}], 935 'notify_test_StrPushC':doAction(PushStrS, return_data)), 936 ?match([{'CosNotification_EventType',_,_}, 937 {'CosNotification_EventType',_,_}], 938 'notify_test_StrPullC':doAction(PullStrS, return_data)), 939 940 %% Now, the objects should only contain 'ES2'. Test it. 941 ?match([{'CosNotification_EventType',_,_}, 942 {'CosNotification_EventType',_,_}], 943 'CosNotifyChannelAdmin_StructuredProxyPushConsumer': 944 obtain_subscription_types(StructuredProxyPushConsumer, 945 'ALL_NOW_UPDATES_ON')), 946 ?match([{'CosNotification_EventType',_,_}, 947 {'CosNotification_EventType',_,_}], 948 'CosNotifyChannelAdmin_StructuredProxyPullConsumer': 949 obtain_subscription_types(StructuredProxyPullConsumer, 950 'ALL_NOW_UPDATES_ON')), 951 952 %% Now we will use wildcards, empty strings and test if they really 953 %% are ignored if so requested. 954 ES3=[#'CosNotification_EventType'{domain_name = "name1", type_name = "*"}, 955 #'CosNotification_EventType'{domain_name = "*", type_name = "type2"}], 956 ES4=[#'CosNotification_EventType'{domain_name = "name1", type_name = "*"}, 957 #'CosNotification_EventType'{domain_name = "name2", type_name = ""}], 958 ES5=[#'CosNotification_EventType'{domain_name = "na*", type_name = "type1"}], 959 ES6=[#'CosNotification_EventType'{domain_name = "n*1", type_name = "type1"}], 960 ES7=[#'CosNotification_EventType'{domain_name = "*1", type_name = "type1"}], 961 ES8=[#'CosNotification_EventType'{domain_name = "n*m*1", type_name = "type1"}], 962 ES9=[#'CosNotification_EventType'{domain_name = "n**1", type_name = "type1"}], 963 ES10=[#'CosNotification_EventType'{domain_name = "nam*1", type_name = "type1"}], 964 965 Event1 = ?not_CreateSE("name1","type1", 966 "event_name", 967 [#'CosNotification_Property'{name="property_name", 968 value=any:create(orber_tc:short(), 1)}], 969 [], any:create(orber_tc:null(), null)), 970 Event2 = ?not_CreateSE("name2","type1", 971 "event_name", 972 [#'CosNotification_Property'{name="property_name", 973 value=any:create(orber_tc:short(), 1)}], 974 [], any:create(orber_tc:null(), null)), 975 Event3 = ?not_CreateSE("mame1","type1", 976 "event_name", 977 [#'CosNotification_Property'{name="property_name", 978 value=any:create(orber_tc:short(), 1)}], 979 [], any:create(orber_tc:null(), null)), 980 Event4 = ?not_CreateSE("naame1","type1", 981 "event_name", 982 [#'CosNotification_Property'{name="property_name", 983 value=any:create(orber_tc:short(), 1)}], 984 [], any:create(orber_tc:null(), null)), 985 Event5 = ?not_CreateSE("nname1","type1", 986 "event_name", 987 [#'CosNotification_Property'{name="property_name", 988 value=any:create(orber_tc:short(), 1)}], 989 [], any:create(orber_tc:null(), null)), 990 Event6 = ?not_CreateSE("name12","type1", 991 "event_name", 992 [#'CosNotification_Property'{name="property_name", 993 value=any:create(orber_tc:short(), 1)}], 994 [], any:create(orber_tc:null(), null)), 995 996 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': 997 subscription_change(StructuredProxyPullSupplier, ES3, [])), 998 999 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), 1000 1001 ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1002 1003 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': 1004 subscription_change(StructuredProxyPullSupplier, ES4, ES3)), 1005 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), 1006 ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1007 1008 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': 1009 subscription_change(StructuredProxyPullSupplier, ES5, ES4)), 1010 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), 1011 ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1012 1013 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': 1014 subscription_change(StructuredProxyPullSupplier, ES6, ES5)), 1015 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), 1016 ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1017 1018 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': 1019 subscription_change(StructuredProxyPullSupplier, ES7, ES6)), 1020 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), 1021 ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1022 1023 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': 1024 subscription_change(StructuredProxyPullSupplier, ES8, ES7)), 1025 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), 1026 ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1027 1028 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': 1029 subscription_change(StructuredProxyPullSupplier, ES9, ES8)), 1030 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), 1031 ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1032 1033 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event2)), 1034 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event3)), 1035 1036 timer:sleep(5000), 1037 ?match({_NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), 1038 1039 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier': 1040 subscription_change(StructuredProxyPullSupplier, ES10, ES9)), 1041 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event1)), 1042 ?match(Event1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1043 1044 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event4)), 1045 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event5)), 1046 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event6)), 1047 1048 timer:sleep(5000), 1049 ?match({_NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), 1050 1051 1052 catch corba:dispose(StructuredProxyPushConsumer), 1053 catch corba:dispose(StructuredProxyPullConsumer), 1054 catch corba:dispose(StructuredProxyPushSupplier), 1055 catch corba:dispose(StructuredProxyPullSupplier), 1056 catch corba:dispose(AdminConsumer), 1057 catch corba:dispose(AdminSupplier), 1058 catch corba:dispose(Ch), 1059 catch cosNotificationApp:stop_factory(Fac), 1060 1061 timer:sleep(5000), 1062 ?match(true, corba_object:non_existent(PullStrS)), 1063 ?match(true, corba_object:non_existent(PushStrS)), 1064 ?match(true, corba_object:non_existent(PullStrC)), 1065 ?match(true, corba_object:non_existent(PushStrC)), 1066 1067 ok. 1068 1069%%----------------------------------------------------------------- 1070%% Filter admin API tests 1071%%----------------------------------------------------------------- 1072filter_adm_api(_Config) -> 1073 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 1074 ?match({_,key,_,_,_,_}, Fac), 1075 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), 1076 ?match({_,key,_,_,_,_}, Ch), 1077 1078 FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), 1079 ?match({_,key,_,_,_,_}, FiFac), 1080 1081 Filter = 'CosNotifyFilter_FilterFactory':create_filter(FiFac,"EXTENDED_TCL"), 1082 ?match({_,key,_,_,_,_}, Filter), 1083 1084 AC=?match({_,key,_,_,_,_}, 1085 'CosNotifyChannelAdmin_EventChannel':for_consumers(Ch)), 1086 filter_tests('CosNotifyChannelAdmin_ConsumerAdmin', AC, Filter, Ch), 1087 1088 AS=?match({_,key,_,_,_,_}, 1089 'CosNotifyChannelAdmin_EventChannel':for_suppliers(Ch)), 1090 filter_tests('CosNotifyChannelAdmin_SupplierAdmin', AS, Filter, Ch), 1091 1092 PushS=?match({_,key,_,_,_,_}, 1093 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_push_supplier(AC)), 1094 filter_tests('CosNotifyChannelAdmin_ProxyPushSupplier', PushS, Filter, Ch), 1095 1096 PullS=?match({_,key,_,_,_,_}, 1097 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_pull_supplier(AC)), 1098 filter_tests('CosNotifyChannelAdmin_ProxyPullSupplier', PullS, Filter, Ch), 1099 1100 PushC=?match({_,key,_,_,_,_}, 1101 'CosNotifyChannelAdmin_SupplierAdmin':obtain_push_consumer(AS)), 1102 filter_tests('CosNotifyChannelAdmin_ProxyPushConsumer', PushC, Filter, Ch), 1103 1104 PullC=?match({_,key,_,_,_,_}, 1105 'CosNotifyChannelAdmin_SupplierAdmin':obtain_pull_consumer(AS)), 1106 filter_tests('CosNotifyChannelAdmin_ProxyPullConsumer', PullC, Filter, Ch), 1107 1108 catch corba:dispose(FiFac), 1109 catch corba:dispose(Filter), 1110 catch corba:dispose(PushS), 1111 catch corba:dispose(PullS), 1112 catch corba:dispose(PushC), 1113 catch corba:dispose(PullC), 1114 catch corba:dispose(AC), 1115 catch corba:dispose(AS), 1116 catch corba:dispose(Ch), 1117 catch cosNotificationApp:stop_factory(Fac), 1118 ok. 1119 1120filter_tests(Mod, Obj, Filter, Ch) -> 1121 io:format("############ TESTING MODULE ~p FILTER ############~n", [Mod]), 1122 %% No filter added. 1123 ?match([], Mod:get_all_filters(Obj)), 1124 ?match(ok, Mod:remove_all_filters(Obj)), 1125 ?match({'EXCEPTION',{'CosNotifyFilter_FilterNotFound',_}}, 1126 Mod:get_filter(Obj, 0)), 1127 %% Try add a Filter which is not a filter. 1128 ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, Mod:add_filter(Obj, Ch)), 1129 %% Try to remove a single filter. 1130 ?match({'EXCEPTION',{'CosNotifyFilter_FilterNotFound',_}}, 1131 Mod:remove_filter(Obj, 0)), 1132 ID = Mod:add_filter(Obj, Filter), 1133 ?match([ID], Mod:get_all_filters(Obj)), 1134 ?match(Filter, Mod:get_filter(Obj, ID)), 1135 ?match(ok, Mod:remove_filter(Obj, ID)), 1136 ?match([], Mod:get_all_filters(Obj)), 1137 ID2 = Mod:add_filter(Obj, Filter), 1138 ?match([ID2], Mod:get_all_filters(Obj)), 1139 ?match(ok, Mod:remove_all_filters(Obj)), 1140 ?match([], Mod:get_all_filters(Obj)), 1141 ok. 1142 1143%%----------------------------------------------------------------- 1144%% Creating different event pushing and pulling API tests 1145%%----------------------------------------------------------------- 1146events_api(_Config) -> 1147 %% Initialize the application. 1148 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 1149 ?match({_,key,_,_,_,_}, Fac), 1150 {Ch, Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), 1151 ?match({_,key,_,_,_,_}, Ch), 1152 events_api_helper(Fac, Ch, Id1). 1153 1154events2_api(doc) -> ["CosNotification event pushing and pulling tests II", ""]; 1155events2_api(suite) -> []; 1156events2_api(_Config) -> 1157 %% Initialize the application. 1158 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 1159 ?match({_,key,_,_,_,_}, Fac), 1160 {Ch, Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS2, ?defaultAdm)), 1161 ?match({_,key,_,_,_,_}, Ch), 1162 events_api_helper(Fac, Ch, Id1). 1163 1164events_api_helper(Fac, Ch, _Id1) -> 1165 %% Now we will set up a test environment, with the following structure: 1166 %% 1167 %% Channel 1168 %% / \ 1169 %% Supplier Adm Consumer Adm 1170 %% / \ 1171 %% 1 proxy of each possible type 1172 %% To each proxy we will connect a test client 1173 %% The events will flow in ===>> direction. 1174 %% 1175 %% For the supplier Admins this include: 1176 %% - ProxyPushConsumer 1177 %% - SequenceProxyPushConsumer 1178 %% - StructuredProxyPushConsumer 1179 %% - ProxyPullConsumer 1180 %% - SequenceProxyPullConsumer 1181 %% - StructuredProxyPullConsumer 1182 %% 1183 %% For the consumer Admins this include: 1184 %% - ProxyPushSupplier 1185 %% - SequenceProxyPushSupplier 1186 %% - StructuredProxyPushSupplier 1187 %% - ProxyPullSupplier 1188 %% - SequenceProxyPullSupplier 1189 %% - StructuredProxyPullSupplier 1190 %% 1191 %% 1192 %% We will not use any Filters to begin with, just want to make sure we can 1193 %% deliver events from all start- to end-points. 1194 1195 %% Create the Admin objects 1196 {AdminSupplier, _ASID}=?match({{_,key,_,_,_,_},_}, 1197 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'AND_OP')), 1198 {AdminConsumer, _ACID}=?match({{_,key,_,_,_,_},_}, 1199 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'AND_OP')), 1200 1201 %% Create Suppliers Proxies 1202 {ProxyPullSupplier,_ID1}=?match({{_,key,_,_,_,_},_}, 1203 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'ANY_EVENT')), 1204 {StructuredProxyPullSupplier,_ID2}=?match({{_,key,_,_,_,_},_}, 1205 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'STRUCTURED_EVENT')), 1206 {SequenceProxyPullSupplier,_ID3}=?match({{_,key,_,_,_,_},_}, 1207 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'SEQUENCE_EVENT')), 1208 1209 {ProxyPushSupplier,_I4D}=?match({{_,key,_,_,_,_},_}, 1210 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'ANY_EVENT')), 1211 {StructuredProxyPushSupplier,_ID5}=?match({{_,key,_,_,_,_},_}, 1212 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'STRUCTURED_EVENT')), 1213 {SequenceProxyPushSupplier,_ID6}=?match({{_,key,_,_,_,_},_}, 1214 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(AdminConsumer, 'SEQUENCE_EVENT')), 1215 1216 %% Now we must create a Client for each proxy and connect them. 1217 PushAnyC=?match({_,key,_,_,_,_}, 'notify_test_AnyPushC':oe_create(['PUSH_ANY', ProxyPushSupplier], 1218 [{local_typecheck, false}])), 1219 ?match(ok, 'CosNotifyChannelAdmin_ProxyPushSupplier':connect_any_push_consumer(ProxyPushSupplier, PushAnyC)), 1220 1221 PushStrC=?match({_,key,_,_,_,_}, 'notify_test_StrPushC':oe_create(['PUSH_STRUCTURED',StructuredProxyPushSupplier], 1222 [{local_typecheck, false}])), 1223 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':connect_structured_push_consumer(StructuredProxyPushSupplier, PushStrC)), 1224 1225 PushSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',SequenceProxyPushSupplier], 1226 [{local_typecheck, false}])), 1227 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(SequenceProxyPushSupplier, PushSeqC)), 1228 1229 PullAnyC=?match({_,key,_,_,_,_}, 'notify_test_AnyPullC':oe_create(['PULL_ANY', ProxyPullSupplier], 1230 [{local_typecheck, false}])), 1231 ?match(ok, 'CosNotifyChannelAdmin_ProxyPullSupplier':connect_any_pull_consumer(ProxyPullSupplier, PullAnyC)), 1232 1233 PullStrC=?match({_,key,_,_,_,_}, 'notify_test_StrPullC':oe_create(['PULL_STRUCTURED',StructuredProxyPullSupplier], 1234 [{local_typecheck, false}])), 1235 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':connect_structured_pull_consumer(StructuredProxyPullSupplier, PullStrC)), 1236 1237 PullSeqC=?match({_,key,_,_,_,_}, 'notify_test_SeqPullC':oe_create(['PULL_SEQUENCE',SequenceProxyPullSupplier], 1238 [{local_typecheck, false}])), 1239 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':connect_sequence_pull_consumer(SequenceProxyPullSupplier, PullSeqC)), 1240 1241 1242 %% Create Consumers Proxies 1243 {ProxyPullConsumer,_ID7}=?match({{_,key,_,_,_,_},_}, 1244 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(AdminSupplier, 'ANY_EVENT')), 1245 {StructuredProxyPullConsumer,_ID8}=?match({{_,key,_,_,_,_},_}, 1246 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(AdminSupplier, 'STRUCTURED_EVENT')), 1247 {SequenceProxyPullConsumer,_ID9}=?match({{_,key,_,_,_,_},_}, 1248 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(AdminSupplier, 'SEQUENCE_EVENT')), 1249 1250 {ProxyPushConsumer,_ID10}=?match({{_,key,_,_,_,_},_}, 1251 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'ANY_EVENT')), 1252 {StructuredProxyPushConsumer,_ID11}=?match({{_,key,_,_,_,_},_}, 1253 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'STRUCTURED_EVENT')), 1254 {SequenceProxyPushConsumer,_ID12}=?match({{_,key,_,_,_,_},_}, 1255 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'SEQUENCE_EVENT')), 1256 1257 %% Now we must create a Client for each proxy and connect them. 1258 PushAnyS=?match({_,key,_,_,_,_}, 'notify_test_AnyPushS':oe_create(['PUSH_ANY', ProxyPushConsumer], 1259 [{local_typecheck, false}])), 1260 ?match(ok, 'CosNotifyChannelAdmin_ProxyPushConsumer':connect_any_push_supplier(ProxyPushConsumer, PushAnyS)), 1261 1262 PushStrS=?match({_,key,_,_,_,_}, 'notify_test_StrPushS':oe_create(['PUSH_STRUCTURED',StructuredProxyPushConsumer], 1263 [{local_typecheck, false}])), 1264 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':connect_structured_push_supplier(StructuredProxyPushConsumer, PushStrS)), 1265 1266 PushSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',SequenceProxyPushConsumer], 1267 [{local_typecheck, false}])), 1268 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(SequenceProxyPushConsumer, PushSeqS)), 1269 1270 PullAnyS=?match({_,key,_,_,_,_}, 'notify_test_AnyPullS':oe_create(['PULL_ANY', ProxyPullConsumer], 1271 [{local_typecheck, false}])), 1272 ?match(ok, 'CosNotifyChannelAdmin_ProxyPullConsumer':connect_any_pull_supplier(ProxyPullConsumer, PullAnyS)), 1273 1274 PullStrS=?match({_,key,_,_,_,_}, 'notify_test_StrPullS':oe_create(['PULL_STRUCTURED',StructuredProxyPullConsumer], 1275 [{local_typecheck, false}])), 1276 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':connect_structured_pull_supplier(StructuredProxyPullConsumer, PullStrS)), 1277 1278 PullSeqS=?match({_,key,_,_,_,_}, 'notify_test_SeqPullS':oe_create(['PULL_SEQUENCE',SequenceProxyPullConsumer], 1279 [{local_typecheck, false}])), 1280 ?match(ok, 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':connect_sequence_pull_supplier(SequenceProxyPullConsumer, PullSeqS)), 1281 1282 1283 %% Create a couple of Events to test with. 1284 Event = ?not_CreateSE("DomainName","CommunicationsAlarm", 1285 "lost_packet", 1286 [#'CosNotification_Property'{name="priority", 1287 value=any:create(orber_tc:short(), 1)}], 1288 [], any:create(orber_tc:null(), null)), 1289 1290 Event2 = ?not_CreateSE("DomainName","TemperatureAlarm", 1291 "over_heated", 1292 [#'CosNotification_Property'{name="priority", 1293 value=any:create(orber_tc:short(), 10)}], 1294 [], any:create(orber_tc:null(), null)), 1295 1296 1297 AnyEvent = any:create(orber_tc:long(), 100), 1298 1299 StrEvent = ?not_CreateSE("","%ANY","",[],[],AnyEvent), 1300 NilAnyEvent = any:create(orber_tc:null(), null), 1301 NilStrEvent = ?not_CreateSE("","","",[],[],NilAnyEvent), 1302 1303 ConvertedStr = any:create('CosNotification_StructuredEvent':tc(), Event), 1304 1305 io:format("###################### PUSH STRUCTURED ########################"), 1306 1307 %% Test with pushing a structured event. 1308 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, Event)), 1309 1310 %% Wait for a while so we are sure that all events have been delivered as far 1311 %% as the Notification service can automatically. 1312 timer:sleep(5000), 1313 1314 %% Check if the Clients have received and stored the events. 1315 ?match([{any,_,Event}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1316 ?match([Event], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1317 ?match([Event], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1318 1319 %% Instruct the Clients to pull the events and check if they match. 1320 ?match({any,_,Event}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1321 ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1322 ?match([Event], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), 1323 1324 io:format("###################### PUSH SEQUENCE ########################"), 1325 1326 %% Create an Event Sequence and push it. 1327 EventSeq = [Event, Event2], 1328 1329 %% Test with pushing a event sequence. 1330 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, EventSeq)), 1331 1332 %% Wait for a while so we are sure that all events have been delivered as far 1333 %% as the Notification service can automatically. 1334 timer:sleep(5000), 1335 1336 %% Instruct the Clients to pull the events and check if they match. 1337 ?match({any,_,Event}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1338 ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1339 ?match([Event,Event2], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,2})), 1340 ?match({any,_,Event2}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1341 ?match(Event2, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1342 1343 %% Check if the Push Clients have received and stored the events. 1344 ?match([{any,_,Event}, {any,_,Event2}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1345 ?match([Event, Event2], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1346 ?match([Event, Event2], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1347 1348 io:format("###################### PUSH ANY ########################"), 1349 1350 %% Test with pushing an any event. 1351 ?match(ok,'CosEventChannelAdmin_ProxyPushConsumer':push(ProxyPushConsumer, AnyEvent)), 1352 1353 %% Wait for a while so we are sure that all events have been delivered as far 1354 %% as the Notification service can automatically. 1355 timer:sleep(5000), 1356 1357 %% Check if the Clients have received and stored the events. 1358 ?match([AnyEvent], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1359 ?match([StrEvent], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1360 ?match([StrEvent], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1361 1362 %% Instruct the Clients to pull the events and check if they match. 1363 ?match(AnyEvent, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1364 ?match(StrEvent, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1365 ?match([StrEvent], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,10})), 1366 1367 1368 1369 io:format("###################### PUSH CONVERTED ANY #############"), 1370 1371 %% Test with pushing a structured event. 1372 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, StrEvent)), 1373 1374 %% Wait for a while so we are sure that all events have been delivered as far 1375 %% as the Notification service can automatically. 1376 timer:sleep(5000), 1377 1378 %% Check if the Clients have received and stored the events. 1379 ?match([AnyEvent], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1380 ?match([StrEvent], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1381 ?match([StrEvent], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1382 1383 %% Instruct the Clients to pull the events and check if they match. 1384 ?match(AnyEvent, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1385 ?match(StrEvent, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1386 ?match([StrEvent], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), 1387 1388 1389 io:format("###################### PUSH CONVERTED STRUCTURED ########"), 1390 1391 %% Test with pushing an any event. 1392 ?match(ok,'CosEventChannelAdmin_ProxyPushConsumer':push(ProxyPushConsumer, ConvertedStr)), 1393 1394 %% Wait for a while so we are sure that all events have been delivered as far 1395 %% as the Notification service can automatically. 1396 timer:sleep(5000), 1397 1398 %% Check if the Clients have received and stored the events. 1399 ?match([ConvertedStr], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1400 ?match([Event], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1401 ?match([Event], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1402 1403 %% Instruct the Clients to pull the events and check if they match. 1404 ?match(ConvertedStr, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1405 ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1406 ?match([Event], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,10})), 1407 1408 1409 io:format("###################### TRY PULL ########################"), 1410 1411 %% Now we will push an any event after a delay. This means that try_pull-functions, 1412 %% since it's not blocking, will return, [], NilAny or NilStructured events and 1413 %% the Boolean false. 1414 spawn(notify_test_impl, delay, [ProxyPushConsumer, AnyEvent, 20000, 1415 'CosEventChannelAdmin_ProxyPushConsumer',push]), 1416 ?match([], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1417 ?match([], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1418 ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1419 1420 %% Instruct the Clients to pull the events and check if they match. 1421 ?match({NilAnyEvent,false}, 'notify_test_AnyPullC':doAction(PullAnyC, try_pull_any)), 1422 ?match({NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), 1423 ?match({[],false}, 'notify_test_SeqPullC':doAction(PullSeqC, {try_pull_seq,10})), 1424 1425 1426 %% Instruct the Clients to pull the events and check if they match. 1427 %% Pull is blocking so in the print-out we should see that nothing 1428 %% is returned until the pushed event reaches the end proxies. 1429 ?match(AnyEvent, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1430 ?match(StrEvent, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1431 ?match([StrEvent], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), 1432 1433 %% To make sure there are no other circumstanses which lead to a delay we 1434 %% hold for some time. 1435 timer:sleep(5000), 1436 %% Check if the Clients have received and stored the events. 1437 ?match([AnyEvent], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1438 ?match([StrEvent], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1439 ?match([StrEvent], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1440 1441 %% Test with pushing a event sequence but only pull sequences of length 1. 1442 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, EventSeq)), 1443 1444 %% Wait for a while so we are sure that all events have been delivered as far 1445 %% as the Notification service can automatically. 1446 timer:sleep(5000), 1447 %% Pull 1 event at a time. 1448 ?match([Event], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), 1449 ?match([Event2], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), 1450 1451 %% Following cases already tested; done for clean up. 1452 ?match({any,_,Event}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1453 ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1454 ?match({any,_,Event2}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1455 ?match(Event2, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1456 ?match([{any,_,Event}, {any,_,Event2}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1457 ?match([Event, Event2], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1458 ?match([Event, Event2], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1459 %% clean up done 1460 1461 1462 io:format("###################### PROXY PULLER ########################"), 1463 1464 %% Now we will just add Events to a cleint and wait for the Notification service 1465 %% to pull the events and forward them to the consumer clients. 1466 ?match(ok, 'notify_test_SeqPushC':doAction(PullAnyS, {set_data, [AnyEvent]})), 1467 1468 1469 %% Instruct the Clients to pull the events and check if they match. 1470 %% Pull is blocking so in the print-out we should see that nothing 1471 %% is returned until the pushed event reaches the end proxies. 1472 ?match(AnyEvent, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1473 ?match(StrEvent, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1474 ?match([StrEvent], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,10})), 1475 1476 %% To make sure there are no other circumstanses which lead to a delay we 1477 %% hold for some time. 1478 timer:sleep(5000), 1479 %% Check if the Clients have received and stored the events. 1480 ?match([AnyEvent], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1481 ?match([StrEvent], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1482 ?match([StrEvent], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1483 1484 io:format("###################### SUSPENDED CONNECTION ################"), 1485 1486 1487 %% Suspend the connections 1488 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushSupplier':suspend_connection(SequenceProxyPushSupplier)), 1489 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushSupplier':suspend_connection(StructuredProxyPushSupplier)), 1490 1491 %% Test with pushing a event sequence. 1492 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushConsumer':push_structured_events(SequenceProxyPushConsumer, EventSeq)), 1493 1494 %% Wait for a while so we are sure that all events have been delivered as far 1495 %% as the Notification service can automatically. 1496 timer:sleep(5000), 1497 1498 %% Instruct the Clients to pull the events and check if they match. 1499 ?match({any,_,Event}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1500 ?match(Event, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1501 ?match([Event,Event2], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,2})), 1502 ?match({any,_,Event2}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1503 ?match(Event2, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1504 1505 %% Check if the Any Client have received and stored the events. 1506 ?match([{any,_,Event}, {any,_,Event2}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1507 1508 %% Check if the other Clients have received any events. Error if have. 1509 ?match([], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1510 ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1511 1512 ?match(ok,'CosNotifyChannelAdmin_SequenceProxyPushSupplier':resume_connection(SequenceProxyPushSupplier)), 1513 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushSupplier':resume_connection(StructuredProxyPushSupplier)), 1514 1515 %% To be sure the test case don't fail due to time-race, sleep. 1516 timer:sleep(5000), 1517 1518 ?match([Event, Event2], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1519 ?match([Event, Event2], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1520 1521 1522 io:format("###################### FILTER EVENTS #######################"), 1523 1524 %% Now we will add filters and see if the system behaves correctly. 1525 FiFac = 'CosNotifyFilter_FilterFactory':oe_create(), 1526 Filter = 'CosNotifyFilter_FilterFactory':create_filter(FiFac,"EXTENDED_TCL"), 1527 %% Add constraints to the Filter 1528 [{_,_,CID1},{_,_,CID2}]= 1529 ?match([{'CosNotifyFilter_ConstraintInfo',_,_}, {'CosNotifyFilter_ConstraintInfo',_,_}], 1530 'CosNotifyFilter_Filter':add_constraints(Filter, 1531 [#'CosNotifyFilter_ConstraintExp'{event_types = 1532 [#'CosNotification_EventType'{ 1533 domain_name = "Spare*", 1534 type_name = "MOVIE"}], 1535 constraint_expr = "$type_name == 'MOVIE' and (('groucho' in $starlist) + ('chico' in $starlist) + ('harpo' in $starlist) + ('zeppo' in $starlist) + ('gummo' in $starlist)) > 2"}, 1536 #'CosNotifyFilter_ConstraintExp'{event_types = 1537 [#'CosNotification_EventType'{ 1538 domain_name = "*", 1539 type_name = "TestResults"}], 1540 constraint_expr = "$test._length == 3 and ($test[0].score + $test[1].score + $test[2].score)/3 >=80"}])), 1541 1542 ?match([{'CosNotifyFilter_ConstraintInfo',_,CID2}, {'CosNotifyFilter_ConstraintInfo',_,CID1}], 1543 'CosNotifyFilter_Filter':get_all_constraints(Filter)), 1544 ?match([{'CosNotifyFilter_ConstraintInfo',_,CID1}], 1545 'CosNotifyFilter_Filter':get_constraints(Filter, [CID1])), 1546 1547 %% Associate the Filter with different objects. 1548 %% Since we use the same filter for both objects the events will never reach the admin. 1549 _FilterID = 'CosNotifyChannelAdmin_ConsumerAdmin':add_filter(AdminConsumer, Filter), 1550 1551 _FilterID2 = 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':add_filter(StructuredProxyPushConsumer, Filter), 1552 event_filtering(FiFac, Filter, AdminConsumer, StructuredProxyPushConsumer, PushAnyC, 1553 PushStrC, PushSeqC, PullAnyC, PullStrC, PullSeqC), 1554 %% Remove the proxy filter so we can check if the events are filtered correctly by the admin. 1555 ?match(ok, 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':remove_all_filters(StructuredProxyPushConsumer)), 1556 event_filtering(FiFac, Filter, AdminConsumer, StructuredProxyPushConsumer, PushAnyC, 1557 PushStrC, PushSeqC, PullAnyC, PullStrC, PullSeqC), 1558 1559 1560 catch corba:dispose(Filter), 1561 catch corba:dispose(FiFac), 1562 catch corba:dispose(SequenceProxyPushConsumer), 1563 catch corba:dispose(StructuredProxyPushConsumer), 1564 catch corba:dispose(ProxyPushConsumer), 1565 catch corba:dispose(SequenceProxyPullConsumer), 1566 catch corba:dispose(StructuredProxyPullConsumer), 1567 catch corba:dispose(ProxyPullConsumer), 1568 catch corba:dispose(SequenceProxyPushSupplier), 1569 catch corba:dispose(StructuredProxyPushSupplier), 1570 catch corba:dispose(ProxyPushSupplier), 1571 catch corba:dispose(SequenceProxyPullSupplier), 1572 catch corba:dispose(StructuredProxyPullSupplier), 1573 catch corba:dispose(ProxyPullSupplier), 1574 catch corba:dispose(AdminConsumer), 1575 catch corba:dispose(AdminSupplier), 1576 catch corba:dispose(Ch), 1577 catch cosNotificationApp:stop_factory(Fac), 1578 %% The Clients should have terminated by now. Check if it is so. 1579 timer:sleep(5000), 1580 ?match(true, corba_object:non_existent(PullSeqS)), 1581 ?match(true, corba_object:non_existent(PullStrS)), 1582 ?match(true, corba_object:non_existent(PullAnyS)), 1583 ?match(true, corba_object:non_existent(PushSeqS)), 1584 ?match(true, corba_object:non_existent(PushStrS)), 1585 ?match(true, corba_object:non_existent(PushAnyS)), 1586 ?match(true, corba_object:non_existent(PullSeqC)), 1587 ?match(true, corba_object:non_existent(PullStrC)), 1588 ?match(true, corba_object:non_existent(PullAnyC)), 1589 ?match(true, corba_object:non_existent(PushSeqC)), 1590 ?match(true, corba_object:non_existent(PushStrC)), 1591 ?match(true, corba_object:non_existent(PushAnyC)), 1592 ok. 1593 1594event_filtering(_FiFac, _Filter, _AdminConsumer, StructuredProxyPushConsumer, PushAnyC, PushStrC, PushSeqC, PullAnyC, PullStrC, PullSeqC) -> 1595 NilAnyEvent = any:create(orber_tc:null(), null), 1596 NilStrEvent = ?not_CreateSE("","","",[],[],NilAnyEvent), 1597 1598 TrueEvent1 = ?not_CreateSE("SpareTime","MOVIE", 1599 "EventName", 1600 [#'CosNotification_Property'{name="starlist", 1601 value=any:create(orber_tc:sequence(orber_tc:string(0),0), 1602 ["groucho", "harpo", "sam", "gummo"])}], 1603 [], any:create(orber_tc:null(), null)), 1604 TrueEvent2 = ?not_CreateSE("Studies","TestResults", 1605 "EventName", [], 1606 [#'CosNotification_Property'{name="test", 1607 value=any:create(orber_tc:array(notify_test_data:tc(),3), 1608 {#notify_test_data{score=75, 1609 name="name"}, 1610 #notify_test_data{score=80, 1611 name="name"}, 1612 #notify_test_data{score=85, 1613 name="name"}})}], 1614 any:create(orber_tc:null(), null)), 1615 1616 FalseEvent1 = ?not_CreateSE("SpareTime","MOVIE", 1617 "EventName", 1618 [#'CosNotification_Property'{name="starlist", 1619 value=any:create(orber_tc:sequence(orber_tc:string(0),0), 1620 ["frodo", "bilbo", "sam", "gummo"])}], 1621 [], any:create(orber_tc:null(), null)), 1622 FalseEvent2 = ?not_CreateSE("Studies","TestResults", 1623 "EventName", [], 1624 [#'CosNotification_Property'{name="test", 1625 value=any:create(orber_tc:array(notify_test_data:tc(),3), 1626 {#notify_test_data{score=75, 1627 name="name"}, 1628 #notify_test_data{score=80, 1629 name="name"}, 1630 #notify_test_data{score=80, 1631 name="name"}})}], 1632 any:create(orber_tc:null(), null)), 1633 %% Test with pushing the first structured event that should not be filtered away. 1634 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, TrueEvent1)), 1635 1636 %% Wait for a while so we are sure that all events have been delivered as far 1637 %% as the Notification service can automatically. 1638 timer:sleep(5000), 1639 1640 %% Check if the Clients have received and stored the events. 1641 ?match([{any,_,TrueEvent1}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1642 ?match([TrueEvent1], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1643 ?match([TrueEvent1], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1644 1645 %% Instruct the Clients to pull the events and check if they match. 1646 ?match({any,_,TrueEvent1}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1647 ?match(TrueEvent1, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1648 ?match([TrueEvent1], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), 1649 1650 %% Test with pushing the second structured event that should not be filtered away. 1651 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, TrueEvent2)), 1652 1653 %% Wait for a while so we are sure that all events have been delivered as far 1654 %% as the Notification service can automatically. 1655 timer:sleep(5000), 1656 1657 %% Check if the Clients have received and stored the events. 1658 ?match([{any,_,TrueEvent2}], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1659 ?match([TrueEvent2], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1660 ?match([TrueEvent2], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1661 1662 %% Instruct the Clients to pull the events and check if they match. 1663 ?match({any,_,TrueEvent2}, 'notify_test_AnyPullC':doAction(PullAnyC, pull_any)), 1664 ?match(TrueEvent2, 'notify_test_StrPullC':doAction(PullStrC, pull_str)), 1665 ?match([TrueEvent2], 'notify_test_SeqPullC':doAction(PullSeqC, {pull_seq,1})), 1666 1667 %% Test with pushing the first structured event that should be filtered away. 1668 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, FalseEvent1)), 1669 1670 %% Wait for a while so we are sure that all events have been delivered as far 1671 %% as the Notification service can automatically. 1672 timer:sleep(5000), 1673 1674 %% Check if the Clients have received and stored the events. 1675 ?match([], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1676 ?match([], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1677 ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1678 1679 %% Instruct the Clients to pull the events and check if they match. 1680 ?match({NilAnyEvent,false}, 'notify_test_AnyPullC':doAction(PullAnyC, try_pull_any)), 1681 ?match({NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), 1682 ?match({[],false}, 'notify_test_SeqPullC':doAction(PullSeqC, {try_pull_seq,10})), 1683 1684 %% Test with pushing the second structured event that should be filtered away. 1685 ?match(ok,'CosNotifyChannelAdmin_StructuredProxyPushConsumer':push_structured_event(StructuredProxyPushConsumer, FalseEvent2)), 1686 1687 %% Wait for a while so we are sure that all events have been delivered as far 1688 %% as the Notification service can automatically. 1689 timer:sleep(5000), 1690 1691 %% Check if the Clients have received and stored the events. 1692 ?match([], 'notify_test_AnyPushC':doAction(PushAnyC, return_data)), 1693 ?match([], 'notify_test_StrPushC':doAction(PushStrC, return_data)), 1694 ?match([], 'notify_test_SeqPushC':doAction(PushSeqC, return_data)), 1695 1696 %% Instruct the Clients to pull the events and check if they match. 1697 ?match({NilAnyEvent,false}, 'notify_test_AnyPullC':doAction(PullAnyC, try_pull_any)), 1698 ?match({NilStrEvent,false}, 'notify_test_StrPullC':doAction(PullStrC, try_pull_str)), 1699 ?match({[],false}, 'notify_test_SeqPullC':doAction(PullSeqC, {try_pull_seq,10})). 1700 1701 1702 1703%%----------------------------------------------------------------- 1704%% Creating different cosEvent API tests 1705%%----------------------------------------------------------------- 1706cosevent_api(_Config) -> 1707 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 1708 ?match({_,key,_,_,_,_}, Fac), 1709 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), 1710 ?match({_,key,_,_,_,_}, Ch), 1711 AC=?match({_,key,_,_,_,_}, 1712 'CosEventChannelAdmin_EventChannel':for_consumers(Ch)), 1713 AS=?match({_,key,_,_,_,_}, 1714 'CosEventChannelAdmin_EventChannel':for_suppliers(Ch)), 1715 1716 PushS=?match({_,key,_,_,_,_}, 1717 'CosEventChannelAdmin_ConsumerAdmin':obtain_push_supplier(AC)), 1718 PullS=?match({_,key,_,_,_,_}, 1719 'CosEventChannelAdmin_ConsumerAdmin':obtain_pull_supplier(AC)), 1720 1721 PushC=?match({_,key,_,_,_,_}, 1722 'CosEventChannelAdmin_SupplierAdmin':obtain_push_consumer(AS)), 1723 PullC=?match({_,key,_,_,_,_}, 1724 'CosEventChannelAdmin_SupplierAdmin':obtain_pull_consumer(AS)), 1725 1726 PushAnyC=?match({_,key,_,_,_,_}, 1727 'notify_test_AnyPushC':oe_create(['PUSH_ANY', PushC], 1728 [{local_typecheck, false}])), 1729 PushStrC=?match({_,key,_,_,_,_}, 1730 'notify_test_StrPushC':oe_create(['PUSH_STRUCTURED',false], 1731 [{local_typecheck, false}])), 1732 PushSeqC=?match({_,key,_,_,_,_}, 1733 'notify_test_SeqPushC':oe_create(['PUSH_SEQUENCE',false], 1734 [{local_typecheck, false}])), 1735 1736 PullAnyC=?match({_,key,_,_,_,_}, 1737 'notify_test_AnyPullC':oe_create(['PULL_ANY', PullC], 1738 [{local_typecheck, false}])), 1739 PullStrC=?match({_,key,_,_,_,_}, 1740 'notify_test_StrPullC':oe_create(['PULL_STRUCTURED',false], 1741 [{local_typecheck, false}])), 1742 PullSeqC=?match({_,key,_,_,_,_}, 1743 'notify_test_SeqPullC':oe_create(['PULL_SEQUENCE',false], 1744 [{local_typecheck, false}])), 1745 1746 PushAnyS=?match({_,key,_,_,_,_}, 1747 'notify_test_AnyPushS':oe_create(['PUSH_ANY', PushC], 1748 [{local_typecheck, false}])), 1749 PushStrS=?match({_,key,_,_,_,_}, 1750 'notify_test_StrPushS':oe_create(['PUSH_STRUCTURED',false], 1751 [{local_typecheck, false}])), 1752 PushSeqS=?match({_,key,_,_,_,_}, 1753 'notify_test_SeqPushS':oe_create(['PUSH_SEQUENCE',false], 1754 [{local_typecheck, false}])), 1755 1756 PullAnyS=?match({_,key,_,_,_,_}, 1757 'notify_test_AnyPullS':oe_create(['PULL_ANY', PullS], 1758 [{local_typecheck, false}])), 1759 PullStrS=?match({_,key,_,_,_,_}, 1760 'notify_test_StrPullS':oe_create(['PULL_STRUCTURED',false], 1761 [{local_typecheck, false}])), 1762 PullSeqS=?match({_,key,_,_,_,_}, 1763 'notify_test_SeqPullS':oe_create(['PULL_SEQUENCE',false], 1764 [{local_typecheck, false}])), 1765 1766 %% In the OMG specification Proxies do not inherrit from CosEvent. Must use 1767 %% Notify interface. 1768 ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, 1769 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PullC, PushStrS)), 1770 1771 ?match(ok, 1772 'CosEventChannelAdmin_ProxyPushSupplier':connect_push_consumer(PushS, PushAnyC)), 1773 ?match(ok, 1774 'CosEventChannelAdmin_ProxyPullSupplier':connect_pull_consumer(PullS, PullAnyC)), 1775 1776 ?match(ok, 1777 'CosEventChannelAdmin_ProxyPushConsumer':connect_push_supplier(PushC, PushAnyS)), 1778 ?match(ok, 1779 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PullC, PullAnyS)), 1780 1781 ?match({'EXCEPTION',{'CosEventChannelAdmin_AlreadyConnected',_}}, 1782 'CosEventChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PullC, PullAnyS)), 1783 1784 ?match({'EXCEPTION',{'CosEventChannelAdmin_AlreadyConnected',_}}, 1785 'CosNotifyChannelAdmin_ProxyPullConsumer':connect_pull_supplier(PullC, PullAnyS)), 1786 1787 ?match(true, corba_object:is_a(PushS, "IDL:omg.org/CosNotifyChannelAdmin/ProxyPushSupplier:1.0")), 1788 ?match(true, corba_object:is_a(PushS, "IDL:omg.org/CosEventChannelAdmin/ProxyPushSupplier:1.0")), 1789 1790 catch corba:dispose(PushStrC), 1791 catch corba:dispose(PushSeqC), 1792 catch corba:dispose(PullStrC), 1793 catch corba:dispose(PullSeqC), 1794 catch corba:dispose(PushStrS), 1795 catch corba:dispose(PushSeqS), 1796 catch corba:dispose(PullStrS), 1797 catch corba:dispose(PullSeqS), 1798 catch corba:dispose(PushS), 1799 catch corba:dispose(PullS), 1800 catch corba:dispose(PushC), 1801 catch corba:dispose(PullC), 1802 catch corba:dispose(AC), 1803 catch corba:dispose(AS), 1804 catch corba:dispose(Ch), 1805 catch cosNotificationApp:stop_factory(Fac), 1806 1807 %% The Clients should have terminated by now. Check if it is so. 1808 timer:sleep(5000), 1809 ?match(true, corba_object:non_existent(PullAnyS)), 1810 ?match(true, corba_object:non_existent(PushAnyS)), 1811 ?match(true, corba_object:non_existent(PullAnyC)), 1812 ?match(true, corba_object:non_existent(PushAnyC)), 1813 1814 1815 ok. 1816 1817%%----------------------------------------------------------------- 1818%% AdminPropertiesAdmin API tests 1819%%----------------------------------------------------------------- 1820adm_api(_Config) -> 1821 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 1822 ?match({_,key,_,_,_,_}, Fac), 1823 1824 %% We need a few AdminProp:s to "play" with. 1825 MQ0 = [#'CosNotification_Property'{name='CosNotification':'MaxQueueLength'(), 1826 value=any:create(orber_tc:long(), 0)}], 1827 MC0 = [#'CosNotification_Property'{name='CosNotification':'MaxConsumers'(), 1828 value=any:create(orber_tc:long(), 0)}], 1829 MS0 = [#'CosNotification_Property'{name='CosNotification':'MaxSuppliers'(), 1830 value=any:create(orber_tc:long(), 0)}], 1831 MQError1 = [#'CosNotification_Property'{name='CosNotification':'MaxQueueLength'(), 1832 value=any:create(orber_tc:'float'(), 1.5)}], 1833 MQError2 = [#'CosNotification_Property'{name='CosNotification':'MaxQueueLength'(), 1834 value=any:create(orber_tc:long(), -1)}], 1835 1836 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), 1837 ?match({_,key,_,_,_,_}, Ch), 1838 1839 %% Set new admin 1840 ?match(ok, 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MQ0)), 1841 %% It should be a list of three items. If we support more admin:s this 1842 %% must be updated. 1843 ?match([_,_,_], 'CosNotification_AdminPropertiesAdmin':get_admin(Ch)), 1844 1845 %% Try to set admin with an uncorrect value, i.e., not integer >= 0. 1846 ?match({'EXCEPTION',{'CosNotification_UnsupportedAdmin',_,_}}, 1847 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MQError1)), 1848 ?match({'EXCEPTION',{'CosNotification_UnsupportedAdmin',_,_}}, 1849 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MQError2)), 1850 1851 %% Try setting the other two admins and chech if the value is correct. 1852 ?match(ok, 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MC0)), 1853 ?match([_,_,_], 'CosNotification_AdminPropertiesAdmin':get_admin(Ch)), 1854 1855 ?match(ok, 'CosNotification_AdminPropertiesAdmin':set_admin(Ch, MS0)), 1856 ?match([_,_,_], 'CosNotification_AdminPropertiesAdmin':get_admin(Ch)), 1857 1858 catch corba:dispose(Ch), 1859 catch cosNotificationApp:stop_factory(Fac), 1860 ok. 1861 1862 1863%%----------------------------------------------------------------- 1864%% QoSAdm API tests 1865%%----------------------------------------------------------------- 1866qos_api(_Config) -> 1867 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 1868 ?match({_,key,_,_,_,_}, Fac), 1869 1870 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), 1871 ?match({_,key,_,_,_,_}, Ch), 1872 1873 1874 QoSPersistent = [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), 1875 value=any:create(orber_tc:short(), 1876 'CosNotification':'Persistent'())}], 1877 QoSBestEffort = [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), 1878 value=any:create(orber_tc:short(), 1879 'CosNotification':'BestEffort'())}], 1880 1881 QoSEventPersistent = [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), 1882 value=any:create(orber_tc:short(), 1883 'CosNotification':'Persistent'())}], 1884 QoSEventBestEffort = [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), 1885 value=any:create(orber_tc:short(), 1886 'CosNotification':'BestEffort'())}], 1887 1888 QoSOKMaxBatchSize = [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), 1889 value=any:create(orber_tc:long(), 200)}], 1890 QoSToHighMaxBatchSize = [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), 1891 value=any:create(orber_tc:long(), 100000000)}], 1892 1893 QoSToLowMaxBatchSize = [#'CosNotification_Property'{name='CosNotification':'MaximumBatchSize'(), 1894 value=any:create(orber_tc:long(), -1)}], 1895 1896 QoSOKStopTimeSupp = [#'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), 1897 value=any:create(orber_tc:boolean(), true)}], 1898 QoSWrongStopTimeSupp = [#'CosNotification_Property'{name="StopTimeSupp", 1899 value=any:create(orber_tc:boolean(), true)}], 1900 1901 QoSOKStartTimeSupp = [#'CosNotification_Property'{name='CosNotification':'StartTimeSupported'(), 1902 value=any:create(orber_tc:boolean(), true)}], 1903 QoSWrongStartTimeSupp = [#'CosNotification_Property'{name="StartTimeSupp", 1904 value=any:create(orber_tc:boolean(), true)}], 1905 QoSOKTimout = [#'CosNotification_Property'{name='CosNotification':'Timeout'(), 1906 value=any:create(orber_tc:unsigned_long_long(), 100)}], 1907 1908 1909 %% The most complex QoS to set is ConnectionReliability, and the reason for this 1910 %% is that we cannot set the Channel to offer best effort while its children 1911 %% offer persistent. A child may only offer Persistent if its parent do, which 1912 %% is why we must check the following: 1913 %% 1914 %% # Persistent Change to Best Effort 1915 %% _____ 1916 %% | | (1) -> Check if children BE 1917 %% |Chann| (2) ok <- 1918 %% ----- 1919 %% | 1920 %% _____ 1921 %% | | (3) -> Check if children BE 1922 %% |Admin| (4) Check if parent Pers. <- 1923 %% ----- 1924 %% | 1925 %% _____ 1926 %% | | (5) -> ok 1927 %% |Proxy| (6) Check if parent Pers. <- 1928 %% ----- 1929 %% NOTE: a parent always exists but we may change the QoS before creating any 1930 %% childrens. The cases (2) and (5) is always ok, i.e., no need to confirm 1931 %% with parent or children. 1932 1933 %% We only have a channel. At the moment we can set ConnectionReliability 1934 %% without asking anyone. 1935 Q1='CosNotification_QoSAdmin':get_qos(Ch), 1936 ?match({ok, _}, 'CosNotification_QoSAdmin':validate_qos(Ch, QoSBestEffort)), 1937 1938 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), 1939 %% Match if no problems occur if we try to set QoS as is. 1940 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), 1941 1942 %% Check validate. 1943 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), 1944 ?match({ok, _}, 'CosNotification_QoSAdmin':validate_qos(Ch, QoSOKTimout)), 1945 ?match({ok, _}, 'CosNotification_QoSAdmin':validate_qos(Ch, QoSEventBestEffort)), 1946 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventBestEffort)), 1947 ?match({ok, _}, 'CosNotification_QoSAdmin':validate_qos(Ch, QoSOKTimout)), 1948 1949 Q2='CosNotification_QoSAdmin':get_qos(Ch), 1950 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), 1951 ?match(Q1, 'CosNotification_QoSAdmin':get_qos(Ch)), 1952 1953 %% Now we add an Admin object. An Admin object cannot switch ConnectionReliability 1954 %% to BestEffort without checking with its children or Persistent without 1955 %% confirming this with its Parent. At the moment, however, we only have a parent. 1956 {CAdm, Id2} = 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch, 'AND_OP'), 1957 ?match(Q1,'CosNotification_QoSAdmin':get_qos(CAdm)), 1958 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 1959 'CosNotification_QoSAdmin':set_qos(CAdm, QoSPersistent)), 1960 ?match(Q1, 'CosNotification_QoSAdmin':get_qos(CAdm)), 1961 ?match(ok, 'CosNotification_QoSAdmin':set_qos(CAdm, QoSBestEffort)), 1962 ?match(Q1, 'CosNotification_QoSAdmin':get_qos(CAdm)), 1963 1964 %% Check if we can extract the Admin from the channel correctly. 1965 ?match([0,Id2],'CosNotifyChannelAdmin_EventChannel':get_all_consumeradmins(Ch)), 1966 ?match(CAdm,'CosNotifyChannelAdmin_EventChannel':get_consumeradmin(Ch, Id2)), 1967 ?match(Ch, 'CosNotifyChannelAdmin_ConsumerAdmin':'_get_MyChannel'(CAdm)), 1968 ?match(Id2, 'CosNotifyChannelAdmin_ConsumerAdmin':'_get_MyID'(CAdm)), 1969 1970 %% Change the channel to provide Persistent service. Now we can set the 1971 %% Admin service to Persistent to. (4) 1972 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), 1973 ?match(ok, 'CosNotification_QoSAdmin':set_qos(CAdm, QoSPersistent)), 1974 ?match(Q2, 'CosNotification_QoSAdmin':get_qos(CAdm)), 1975 1976 %% Since the Admin object now provide Persistent the Channel cannot switch 1977 %% to BestEffort. (1) 1978 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 1979 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), 1980 %% Should still match Persistent. 1981 ?match(Q2, 'CosNotification_QoSAdmin':get_qos(Ch)), 1982 {PSup, _Id3} = 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(CAdm, 'ANY_EVENT'), 1983 ?match(Q2, 'CosNotification_QoSAdmin':get_qos(CAdm)), 1984 ?match('PUSH_ANY', 'CosNotifyChannelAdmin_ProxyPushConsumer':'_get_MyType'(PSup)), 1985 ?match(CAdm, 'CosNotifyChannelAdmin_ProxyPushConsumer':'_get_MyAdmin'(PSup)), 1986 ?match(Q2, 'CosNotification_QoSAdmin':get_qos(PSup)), 1987 1988 %% At this point they all offer persistent connection, which means we have 1989 %% to start with the proxy if we want to change to Best Effort. Hence, 1990 %% the following two cases will fail. 1991 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 1992 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), 1993 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 1994 'CosNotification_QoSAdmin':set_qos(CAdm, QoSBestEffort)), 1995 ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, QoSBestEffort)), 1996 %% Still not possible to change channel to Best Effort. 1997 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 1998 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), 1999 ?match(ok, 'CosNotification_QoSAdmin':set_qos(CAdm, QoSBestEffort)), 2000 %% Now we change the channel to Best Effort. 2001 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSBestEffort)), 2002 2003 %% Test if really are Best Effort 2004 ?match(Q1, 'CosNotification_QoSAdmin':get_qos(Ch)), 2005 ?match(Q1, 'CosNotification_QoSAdmin':get_qos(CAdm)), 2006 ?match(Q1, 'CosNotification_QoSAdmin':get_qos(PSup)), 2007 2008 %% Testing MaximumBatchSize (The highest value is defined in 2009 %% CosNotification_Common.erl 2010 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSOKMaxBatchSize)), 2011 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2012 'CosNotification_QoSAdmin':set_qos(Ch, QoSToHighMaxBatchSize)), 2013 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2014 'CosNotification_QoSAdmin':set_qos(Ch, QoSToLowMaxBatchSize)), 2015 2016 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSOKStartTimeSupp)), 2017 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSOKStopTimeSupp)), 2018 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2019 'CosNotification_QoSAdmin':set_qos(Ch, QoSWrongStartTimeSupp)), 2020 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2021 'CosNotification_QoSAdmin':set_qos(Ch, QoSWrongStopTimeSupp)), 2022 2023 catch corba:dispose(CAdm), 2024 catch corba:dispose(PSup), 2025 catch corba:dispose(Ch), 2026 cosNotificationApp:stop_factory(Fac), 2027 ok. 2028 2029%%----------------------------------------------------------------- 2030%% QoSAdm API tests 2031%%----------------------------------------------------------------- 2032event_qos_api(_Config) -> 2033 Fac = (catch cosNotificationApp:start_global_factory(?FAC_OPT)), 2034 ?match({_,key,_,_,_,_}, Fac), 2035 2036 %% Create some objects to test with. We start with default settings. 2037 {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, ?defaultQoS, ?defaultAdm)), 2038 {CAdm, _Id2} = 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch, 'AND_OP'), 2039 {PSup, _Id3} = 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(CAdm, 'ANY_EVENT'), 2040 2041 %% Try setting an unsupported QoS. 2042 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2043 'CosNotifyChannelAdmin_ProxyConsumer': 2044 validate_event_qos(PSup, 2045 [#'CosNotification_Property'{name="Unsupported QoS", 2046 value=any:create(orber_tc:short(), 1)}])), 2047 %% Try setting min and max priority. 2048 ?match({ok, _}, 'CosNotifyChannelAdmin_ProxyConsumer': 2049 validate_event_qos(PSup, 2050 [#'CosNotification_Property'{name=?not_Priority, 2051 value=any:create(orber_tc:short(), 2052 ?not_LowestPriority)}, 2053 #'CosNotification_Property'{name=?not_Priority, 2054 value=any:create(orber_tc:short(), 2055 ?not_HighestPriority)}])), 2056 %% Try setting priority values which are 1 to high and 1 to low respectively. 2057 ?match({'EXCEPTION',{'MARSHAL',_,_,_}}, 2058 'CosNotifyChannelAdmin_ProxyConsumer': 2059 validate_event_qos(PSup, 2060 [#'CosNotification_Property'{name=?not_Priority, 2061 value=any:create(orber_tc:short(), 2062 ?not_LowestPriority-1)}, 2063 #'CosNotification_Property'{name=?not_Priority, 2064 value=any:create(orber_tc:short(), 2065 ?not_HighestPriority+1)}])), 2066 %% Try setting start- and stop-time (false default). Note the value associated 2067 %% with this property is not really a short but that is not what we are testing 2068 %% here so... 2069 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2070 'CosNotifyChannelAdmin_ProxyConsumer': 2071 validate_event_qos(PSup, 2072 [#'CosNotification_Property'{name=?not_StartTime, 2073 value=any:create(orber_tc:short(), 0)}])), 2074 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2075 'CosNotifyChannelAdmin_ProxyConsumer': 2076 validate_event_qos(PSup, 2077 [#'CosNotification_Property'{name=?not_StopTime, 2078 value=any:create(orber_tc:short(), 0)}])), 2079 %% Allow StopTime 2080 ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, [#'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), 2081 value=any:create(orber_tc:boolean(), true)}])), 2082 ?match({ok,_}, 2083 'CosNotifyChannelAdmin_ProxyConsumer': 2084 validate_event_qos(PSup, 2085 [#'CosNotification_Property'{name=?not_StopTime, 2086 value=any:create(orber_tc:short(), 0)}])), 2087 %% Allow StartTime 2088 ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, [#'CosNotification_Property'{name='CosNotification':'StartTimeSupported'(), 2089 value=any:create(orber_tc:boolean(), true)}])), 2090 ?match({ok,_}, 2091 'CosNotifyChannelAdmin_ProxyConsumer': 2092 validate_event_qos(PSup, 2093 [#'CosNotification_Property'{name=?not_StopTime, 2094 value=any:create(orber_tc:short(), 0)}, 2095 #'CosNotification_Property'{name=?not_StartTime, 2096 value=any:create(orber_tc:short(), 0)}])), 2097 2098 %% We must reset StopTime since we cannot guarantee that an event will be delivered 2099 %% if risk beeing discarded due to a delay. 2100 ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, [#'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), 2101 value=any:create(orber_tc:boolean(), false)}])), 2102 %% Does it accept Best Effort EventReliability? Must always be true. 2103 ?match({ok,_}, 2104 'CosNotifyChannelAdmin_ProxyConsumer': 2105 validate_event_qos(PSup, 2106 [#'CosNotification_Property'{name=?not_EventReliability, 2107 value=any:create(orber_tc:short(), ?not_BestEffort)}])), 2108 %% Default is Best Effort; test if we can set Persistent EventReliability. 2109 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2110 'CosNotifyChannelAdmin_ProxyConsumer': 2111 validate_event_qos(PSup, 2112 [#'CosNotification_Property'{name=?not_EventReliability, 2113 value=any:create(orber_tc:short(), ?not_Persistent)}])), 2114 2115 %% Set Persistent 2116 QoSPersistent = [#'CosNotification_Property'{name='CosNotification':'ConnectionReliability'(), 2117 value=any:create(orber_tc:short(), 2118 'CosNotification':'Persistent'())}], 2119 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSPersistent)), 2120 ?match(ok, 'CosNotification_QoSAdmin':set_qos(CAdm, QoSPersistent)), 2121 ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, QoSPersistent)), 2122 2123 %% Does it accept Best Effort EventReliability? Must always be true. 2124 ?match({ok, _}, 2125 'CosNotifyChannelAdmin_ProxyConsumer': 2126 validate_event_qos(PSup, 2127 [#'CosNotification_Property'{name=?not_EventReliability, 2128 value=any:create(orber_tc:short(), ?not_BestEffort)}])), 2129 %% Test if we can use Persistent EventReliability. 2130 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2131 'CosNotifyChannelAdmin_ProxyConsumer': 2132 validate_event_qos(PSup, 2133 [#'CosNotification_Property'{name=?not_EventReliability, 2134 value=any:create(orber_tc:short(), ?not_Persistent)}])), 2135 QoSEventPersistent = [#'CosNotification_Property'{name='CosNotification':'EventReliability'(), 2136 value=any:create(orber_tc:short(), 2137 'CosNotification':'Persistent'())}], 2138 ?match(ok, 'CosNotification_QoSAdmin':set_qos(Ch, QoSEventPersistent)), 2139 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2140 'CosNotification_QoSAdmin':set_qos(CAdm, QoSEventPersistent)), 2141 ?match({'EXCEPTION',{'CosNotification_UnsupportedQoS',_,_}}, 2142 'CosNotification_QoSAdmin':set_qos(PSup, QoSEventPersistent)), 2143 2144 ?match(ok, 'CosNotification_QoSAdmin':set_qos(PSup, [#'CosNotification_Property'{name='CosNotification':'StopTimeSupported'(), 2145 value=any:create(orber_tc:boolean(), true)}])), 2146 ?match({ok,_}, 2147 'CosNotifyChannelAdmin_ProxyConsumer': 2148 validate_event_qos(PSup, 2149 [#'CosNotification_Property'{name=?not_StopTime, 2150 value=any:create(orber_tc:short(), 0)}, 2151 #'CosNotification_Property'{name=?not_StartTime, 2152 value=any:create(orber_tc:short(), 0)}])), 2153 catch corba:dispose(CAdm), 2154 catch corba:dispose(PSup), 2155 catch corba:dispose(Ch), 2156 cosNotificationApp:stop_factory(Fac), 2157 ok. 2158 2159%%----------------------------------------------------------------- 2160%% Internal functions 2161%%----------------------------------------------------------------- 2162 2163%%-------------------- End of Module ------------------------------ 2164