1 #include "ace/Get_Opt.h"
2 #include "ace/OS_NS_unistd.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
10 int do_self_shutdown
= 0;
15 parse_args (int argc
, ACE_TCHAR
*argv
[])
17 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("acszxk:i:"));
20 while ((c
= get_opts ()) != -1)
44 ior
= get_opts
.opt_arg ();
48 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
53 ACE_ERROR_RETURN ((LM_ERROR
,
55 "[-a] [-c] [-x] [-s] [-z] "
62 // Indicates successful parsing of the command line
67 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
72 CORBA::ORB_init (argc
, argv
);
74 CORBA::Object_var poa_object
=
75 orb
->resolve_initial_references("RootPOA");
77 if (CORBA::is_nil (poa_object
.in ()))
78 ACE_ERROR_RETURN ((LM_ERROR
,
79 " (%P|%t) Unable to initialize the POA.\n"),
82 PortableServer::POA_var root_poa
=
83 PortableServer::POA::_narrow (poa_object
.in ());
85 PortableServer::POAManager_var poa_manager
=
86 root_poa
->the_POAManager ();
88 poa_manager
->activate ();
90 if (parse_args (argc
, argv
) != 0)
93 CORBA::Object_var object
=
94 orb
->string_to_object (ior
);
96 Simple_Server_var server
=
97 Simple_Server::_narrow (object
.in ());
99 if (CORBA::is_nil (server
.in ()))
101 ACE_ERROR_RETURN ((LM_ERROR
,
102 "Object reference <%s> is nil.\n",
107 Callback_i
callback_impl (orb
.in ());
109 PortableServer::ObjectId_var id
=
110 root_poa
->activate_object (&callback_impl
);
112 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
114 Callback_var callback
=
115 Callback::_narrow (object_act
.in ());
117 for (int i
= 0; i
!= niterations
; ++i
)
120 server
->test_method (0, 0, callback
.in ());
124 ACE_DEBUG ((LM_DEBUG
,
125 "(%P|%t) unexpected result = %d for %d",
134 server
->shutdown_now (0);
136 catch (const CORBA::COMM_FAILURE
&)
138 // Expected exception, continue....
145 server
->shutdown_now (1);
147 catch (const CORBA::COMM_FAILURE
&)
149 // Expected exception, continue....
154 (void) server
->test_method (1, 0, callback
.in ());
155 // The shutdown callback could arrive after this twoway invocation
156 // returned. Wait for it shutdown callback and abort,
157 // otherwise it will timeout (in run_test.pl).
160 else if (do_self_shutdown
)
162 (void) server
->test_method (1, 1, callback
.in ());
170 root_poa
->destroy (true, true);
172 catch (const CORBA::COMM_FAILURE
& x
)
174 // For other case this is expected.
175 if (do_self_shutdown
== 0)
177 x
._tao_print_exception ("ERROR: Unexpected exception\n");
180 catch (const CORBA::Exception
& ex
)
182 ex
._tao_print_exception ("Exception caught in client:");