1 #include "Counting_Supplier.h"
2 #include "Counting_Consumer.h"
4 #include "orbsvcs/Time_Utilities.h"
5 #include "orbsvcs/CosEvent/CEC_EventChannel.h"
6 #include "orbsvcs/CosEvent/CEC_Default_Factory.h"
8 static void run_test (PortableServer::POA_ptr poa
,
12 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
14 TAO_CEC_Default_Factory::init_svcs ();
18 // ORB initialization boiler plate...
20 CORBA::ORB_init (argc
, argv
);
22 CORBA::Object_var object
=
23 orb
->resolve_initial_references ("RootPOA");
24 PortableServer::POA_var poa
=
25 PortableServer::POA::_narrow (object
.in ());
26 PortableServer::POAManager_var poa_manager
=
27 poa
->the_POAManager ();
28 poa_manager
->activate ();
30 // ****************************************************************
32 run_test (poa
.in (), 0);
34 run_test (poa
.in (), 1);
36 // ****************************************************************
38 poa
->destroy (true, true);
42 catch (const CORBA::Exception
& ex
)
44 ex
._tao_print_exception ("Service");
50 // ****************************************************************
53 deactivate_servant (PortableServer::Servant servant
)
55 PortableServer::POA_var poa
=
56 servant
->_default_POA ();
57 PortableServer::ObjectId_var id
=
58 poa
->servant_to_id (servant
);
59 poa
->deactivate_object (id
.in ());
63 run_test (PortableServer::POA_ptr poa
,
66 TAO_CEC_EventChannel_Attributes
attributes (poa
, poa
);
67 attributes
.disconnect_callbacks
= use_callbacks
;
69 TAO_CEC_EventChannel
ec_impl (attributes
);
72 CosEventChannelAdmin::EventChannel_var event_channel
=
75 // ****************************************************************
77 // Obtain the consumer admin..
78 CosEventChannelAdmin::ConsumerAdmin_var consumer_admin
=
79 event_channel
->for_consumers ();
81 // and the supplier admin..
82 CosEventChannelAdmin::SupplierAdmin_var supplier_admin
=
83 event_channel
->for_suppliers ();
85 // ****************************************************************
89 CEC_Counting_Supplier supplier_0
;
90 CEC_Counting_Supplier supplier_1
;
91 CEC_Counting_Consumer
consumer_0 ("Consumer/0");
92 CEC_Counting_Consumer
consumer_1 ("Consumer/1");
94 for (int i
= 0; i
!= iterations
; ++i
)
96 supplier_0
.connect (supplier_admin
.in ());
97 consumer_0
.connect (consumer_admin
.in ());
100 supplier_1
.connect (supplier_admin
.in ());
101 consumer_1
.connect (consumer_admin
.in ());
103 supplier_0
.disconnect ();
104 consumer_0
.disconnect ();
107 consumer_1
.disconnect ();
108 supplier_1
.disconnect ();
112 supplier_0
.connect (supplier_admin
.in ());
113 consumer_0
.connect (consumer_admin
.in ());
115 event_channel
->destroy ();
117 deactivate_servant (&supplier_0
);
119 deactivate_servant (&consumer_0
);
121 deactivate_servant (&ec_impl
);
123 CORBA::ULong count_0
= 1;
124 CORBA::ULong count_1
= 0;
127 count_0
+= iterations
;
128 count_1
+= iterations
/ 2;
131 if (consumer_0
.disconnect_count
!= count_0
)
132 ACE_ERROR ((LM_ERROR
,
133 "ERROR: incorrect number of disconnect calls (%d/%d) for "
135 consumer_0
.disconnect_count
, count_0
,
137 if (supplier_0
.disconnect_count
!= count_0
)
138 ACE_ERROR ((LM_ERROR
,
139 "ERROR: incorrect number of disconnect calls (%d/%d) for "
141 supplier_0
.disconnect_count
, count_0
,
144 if (consumer_1
.disconnect_count
!= count_1
)
145 ACE_ERROR ((LM_ERROR
,
146 "ERROR: incorrect number of disconnect calls (%d/%d) for "
148 consumer_1
.disconnect_count
, count_1
,
150 if (supplier_1
.disconnect_count
!= count_1
)
151 ACE_ERROR ((LM_ERROR
,
152 "ERROR: incorrect number of disconnect calls (%d/%d) for "
154 supplier_1
.disconnect_count
, count_1
,