1 #include "ace/Get_Opt.h"
3 #include "tao/PortableServer/Root_POA.h"
4 #include "ace/OS_NS_stdio.h"
6 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("ior");
19 test_i (CORBA::ORB_ptr orb
);
21 void normal_method ();
23 void unknown_exception_in_method ();
25 void unknown_exception_during_deactivation ();
35 test_i::test_i (CORBA::ORB_ptr orb
)
36 : orb_ (CORBA::ORB::_duplicate (orb
)),
42 test_i::normal_method ()
45 "test_i::normal_method() called\n"));
49 test_i::unknown_exception_in_method ()
52 "test_i::unknown_exception_in_method() called\n"));
55 "Unknown exception being generated: should be propagated to the client\n"));
61 test_i::unknown_exception_during_deactivation ()
64 "test_i::unknown_exception_during_deactivation() called\n"));
66 PortableServer::POA_var poa
=
67 this->_default_POA ();
69 PortableServer::ObjectId_var id
=
70 poa
->servant_to_id (this);
72 poa
->deactivate_object (id
.in ());
79 "test_i::_add_ref() called; current refcount = %d\n",
80 this->reference_count_
++));
84 test_i::_remove_ref ()
87 "test_i::_remove_ref() called; current refcount = %d\n",
88 this->reference_count_
--));
90 if (this->reference_count_
== 0)
95 "Unknown exception being generated: should be gobbled up by the POA\n"));
101 //FUZZ: disable check_for_lack_ACE_OS
102 class test_factory_i
:
103 public POA_test_factory
106 test_factory_i (CORBA::ORB_ptr orb
);
108 test_ptr
create_test ();
114 //FUZZ: enable check_for_lack_ACE_OS
116 test_factory_i::test_factory_i (CORBA::ORB_ptr orb
)
117 : orb_ (CORBA::ORB::_duplicate (orb
))
122 test_factory_i::create_test ()
125 new test_i (this->orb_
.in ());
127 PortableServer::ServantBase_var
safe_servant (servant
);
128 ACE_UNUSED_ARG (safe_servant
);
130 CORBA::Object_var poa_object
=
131 this->orb_
->resolve_initial_references("RootPOA");
133 PortableServer::POA_var root_poa
=
134 PortableServer::POA::_narrow (poa_object
.in ());
136 PortableServer::ObjectId_var id_act
=
137 root_poa
->activate_object (servant
);
139 CORBA::Object_var object
= root_poa
->id_to_reference (id_act
.in ());
142 test::_narrow (object
.in ());
144 return test
._retn ();
148 test_factory_i::shutdown ()
150 ACE_DEBUG ((LM_DEBUG
,
151 "factory_i::shutdown() called\n"));
154 this->orb_
->shutdown (false);
158 parse_args (int argc
, ACE_TCHAR
*argv
[])
160 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
163 while ((c
= get_opts ()) != -1)
167 ior_output_file
= get_opts
.opt_arg ();
171 ACE_ERROR_RETURN ((LM_ERROR
,
173 "\t-o <ior output file> [defaults to %s]\n"
184 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
189 CORBA::ORB_init (argc
,argv
);
191 CORBA::Object_var poa_object
=
192 orb
->resolve_initial_references ("RootPOA");
194 PortableServer::POA_var root_poa
=
195 PortableServer::POA::_narrow (poa_object
.in ());
197 PortableServer::POAManager_var poa_manager
=
198 root_poa
->the_POAManager ();
200 if (parse_args (argc
, argv
) != 0)
204 test_factory_i
*servant
=
205 new test_factory_i (orb
.in ());
207 PortableServer::ServantBase_var
safe_servant (servant
);
208 ACE_UNUSED_ARG (safe_servant
);
210 PortableServer::ObjectId_var id_act
=
211 root_poa
->activate_object (servant
);
213 CORBA::Object_var object
= root_poa
->id_to_reference (id_act
.in ());
215 test_factory_var test_factory
=
216 test_factory::_narrow (object
.in ());
218 CORBA::String_var ior
=
219 orb
->object_to_string (test_factory
.in ());
221 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
222 if (output_file
== 0)
223 ACE_ERROR_RETURN ((LM_ERROR
,
224 "Cannot open output file for writing IOR: %s",
227 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
228 ACE_OS::fclose (output_file
);
231 poa_manager
->activate ();
233 TAO_Root_POA
*tao_poa
= dynamic_cast <TAO_Root_POA
*> (root_poa
.in ());
237 CORBA::ULong outstanding_requests
=
238 tao_poa
->outstanding_requests ();
240 ACE_DEBUG ((LM_DEBUG
,
241 "Number of outstanding requests before ORB::perform_work(): %d\n",
242 outstanding_requests
));
244 ACE_ASSERT (outstanding_requests
== 0);
246 orb
->perform_work ();
248 // On some systems this loop must yield or else the other threads
249 // will not get a chance to run.
250 ACE_OS::thr_yield ();
255 ACE_ERROR_RETURN ((LM_ERROR
,
256 "Failure: Unexpected exception caught\n"),