1 #include "ace/Get_Opt.h"
3 #include "tao/RTPortableServer/RTPortableServer.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_string.h"
7 #include "../check_supported_priorities.cpp"
13 test_i (CORBA::ORB_ptr orb
,
14 PortableServer::POA_ptr poa
);
18 //FUZZ: disable check_for_lack_ACE_OS
20 //FUZZ: enable check_for_lack_ACE_OS
22 PortableServer::POA_ptr
_default_POA ();
26 PortableServer::POA_var poa_
;
29 test_i::test_i (CORBA::ORB_ptr orb
,
30 PortableServer::POA_ptr poa
)
31 : orb_ (CORBA::ORB::_duplicate (orb
)),
32 poa_ (PortableServer::POA::_duplicate (poa
))
47 "test_i::shutdown\n"));
49 this->orb_
->shutdown (false);
52 PortableServer::POA_ptr
53 test_i::_default_POA ()
55 return PortableServer::POA::_duplicate (this->poa_
.in ());
58 static const ACE_TCHAR
*persistent_ior
= ACE_TEXT ("persistent_ior");
59 static const ACE_TCHAR
*transient_ior
= ACE_TEXT ("transient_ior");
60 static const ACE_TCHAR
*tp_persistent_ior
= ACE_TEXT ("tp_persistent_ior");
63 static CORBA::ULong stacksize
= 0;
64 static CORBA::ULong static_threads
= 2;
65 static CORBA::ULong dynamic_threads
= 0;
66 static RTCORBA::Priority default_thread_priority
;
67 static CORBA::Boolean allow_request_buffering
= 0;
68 static CORBA::ULong max_buffered_requests
= 0;
69 static CORBA::ULong max_request_buffer_size
= 0;
72 parse_args (int argc
, ACE_TCHAR
*argv
[])
74 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("a:p:t:d:"));
77 while ((c
= get_opts ()) != -1)
81 tp_persistent_ior
= get_opts
.opt_arg ();
85 persistent_ior
= get_opts
.opt_arg ();
89 transient_ior
= get_opts
.opt_arg ();
93 debug
= ACE_OS::atoi (get_opts
.opt_arg ());
98 ACE_ERROR_RETURN ((LM_ERROR
,
100 "-a <tp persistent ior file> "
101 "-p <persistent ior file> "
102 "-t <transient ior file> "
109 // Indicates successful parsing of the command line
114 write_iors_to_file (CORBA::Object_ptr object
,
116 const ACE_TCHAR
*filename
)
119 ACE_OS::fopen (filename
, "w");
120 ACE_ASSERT (file
!= 0);
122 CORBA::String_var ior
=
123 orb
->object_to_string (object
);
126 ACE_DEBUG ((LM_DEBUG
,
133 ACE_OS::fprintf (file
,
137 ACE_ASSERT (result
== ACE_OS::strlen (ior
.in ()));
138 ACE_UNUSED_ARG (result
);
140 ACE_OS::fclose (file
);
144 create_poa_and_servant_with_persistent_policy (CORBA::ORB_ptr orb
,
145 PortableServer::POA_ptr root_poa
,
146 PortableServer::POAManager_ptr poa_manager
)
148 CORBA::PolicyList policies
;
150 CORBA::Policy_var implicit_activation_policy
=
151 root_poa
->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION
);
153 CORBA::Policy_var lifespan_policy
=
154 root_poa
->create_lifespan_policy (PortableServer::PERSISTENT
);
156 policies
.length (policies
.length () + 1);
157 policies
[policies
.length () - 1] =
158 implicit_activation_policy
;
160 policies
.length (policies
.length () + 1);
161 policies
[policies
.length () - 1] =
164 PortableServer::POA_var poa
=
165 root_poa
->create_POA ("persistent_child",
170 ACE_NEW_THROW_EX (servant
,
173 CORBA::NO_MEMORY ());
175 PortableServer::ServantBase_var
safe_servant (servant
);
180 write_iors_to_file (test
.in (),
186 create_poa_and_servant_with_tp_policy (CORBA::ORB_ptr orb
,
187 RTCORBA::RTORB_ptr rt_orb
,
188 PortableServer::POA_ptr root_poa
,
189 PortableServer::POAManager_ptr poa_manager
)
191 RTCORBA::ThreadpoolId threadpool_id
=
192 rt_orb
->create_threadpool (stacksize
,
195 default_thread_priority
,
196 allow_request_buffering
,
197 max_buffered_requests
,
198 max_request_buffer_size
);
200 CORBA::Policy_var threadpool_policy
=
201 rt_orb
->create_threadpool_policy (threadpool_id
);
203 CORBA::Policy_var implicit_activation_policy
=
204 root_poa
->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION
);
206 CORBA::PolicyList policies
;
208 policies
.length (policies
.length () + 1);
209 policies
[policies
.length () - 1] =
210 implicit_activation_policy
;
212 policies
.length (policies
.length () + 1);
213 policies
[policies
.length () - 1] =
216 PortableServer::POA_var poa
=
217 root_poa
->create_POA ("tp_child",
222 ACE_NEW_THROW_EX (servant
,
225 CORBA::NO_MEMORY ());
227 PortableServer::ServantBase_var
safe_servant (servant
);
232 write_iors_to_file (test
.in (),
238 create_poa_with_tp_and_persistent_policy (CORBA::ORB_ptr orb
,
239 RTCORBA::RTORB_ptr rt_orb
,
240 PortableServer::POA_ptr root_poa
,
241 PortableServer::POAManager_ptr poa_manager
)
243 RTCORBA::ThreadpoolId threadpool_id
=
244 rt_orb
->create_threadpool (stacksize
,
247 default_thread_priority
,
248 allow_request_buffering
,
249 max_buffered_requests
,
250 max_request_buffer_size
);
252 CORBA::Policy_var threadpool_policy
=
253 rt_orb
->create_threadpool_policy (threadpool_id
);
255 CORBA::Policy_var implicit_activation_policy
=
256 root_poa
->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION
);
258 CORBA::Policy_var lifespan_policy
=
259 root_poa
->create_lifespan_policy (PortableServer::PERSISTENT
);
261 CORBA::PolicyList policies
;
263 policies
.length (policies
.length () + 1);
264 policies
[policies
.length () - 1] =
265 implicit_activation_policy
;
267 policies
.length (policies
.length () + 1);
268 policies
[policies
.length () - 1] =
271 policies
.length (policies
.length () + 1);
272 policies
[policies
.length () - 1] =
275 PortableServer::POA_var poa
=
276 root_poa
->create_POA ("tp_persistent_child",
281 ACE_NEW_THROW_EX (servant
,
284 CORBA::NO_MEMORY ());
286 PortableServer::ServantBase_var
safe_servant (servant
);
291 write_iors_to_file (test
.in (),
297 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
302 CORBA::ORB_init (argc
, argv
);
305 parse_args (argc
, argv
);
309 CORBA::Object_var object
=
310 orb
->resolve_initial_references ("RTORB");
312 RTCORBA::RTORB_var rt_orb
=
313 RTCORBA::RTORB::_narrow (object
.in ());
316 orb
->resolve_initial_references ("RTCurrent");
318 RTCORBA::Current_var current
=
319 RTCORBA::Current::_narrow (object
.in ());
321 default_thread_priority
=
322 get_implicit_thread_CORBA_priority (orb
.in ());
325 orb
->resolve_initial_references ("RootPOA");
327 PortableServer::POA_var root_poa
=
328 PortableServer::POA::_narrow (object
.in ());
330 PortableServer::POAManager_var poa_manager
=
331 root_poa
->the_POAManager ();
333 create_poa_and_servant_with_tp_policy (orb
.in (),
338 create_poa_and_servant_with_persistent_policy (orb
.in (),
342 create_poa_with_tp_and_persistent_policy (orb
.in (),
347 poa_manager
->activate ();
353 catch (const CORBA::INTERNAL
& ex
)
355 if ((ex
.minor() & 0x1F) == 9) {
356 ACE_DEBUG ((LM_DEBUG
, "You must be superuser to run "
357 "this test on this platform.\n"));
361 ex
._tao_print_exception ("Exception caught");
365 catch (const CORBA::Exception
& ex
)
367 ex
._tao_print_exception ("Exception caught");