2 #include "ace/Get_Opt.h"
5 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
8 static const ACE_TCHAR corbaloc_prefix
[] = ACE_TEXT("corbaloc:");
9 bool expected_object_not_exist
= false;
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("xk:e:"));
17 while ((c
= get_opts ()) != -1)
26 ior
= get_opts
.opt_arg ();
30 expected_object_not_exist
= ACE_OS::atoi (get_opts
.opt_arg ());
35 ACE_ERROR_RETURN ((LM_ERROR
,
38 "-e <expected_object_not_exist> "
45 if (ACE_OS::strncmp (ior
,
47 ACE_OS::strlen (corbaloc_prefix
)) != 0)
50 // Indicates successful parsing of the command line
54 class Worker
: public ACE_Task_Base
58 Worker (CORBA::ORB_ptr orb
);
60 /// The actual implementation of the test
61 virtual void run_test ();
65 /// Caught OBJECT_NOT_EXIST exception ?
66 bool got_object_not_exist () const;
71 bool got_object_not_exist_
;
75 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
80 CORBA::ORB_init (argc
, argv
);
82 if (parse_args (argc
, argv
) != 0)
85 Worker
worker (orb
.in ());
87 if (worker
.activate (THR_NEW_LWP
| THR_JOINABLE
,
89 ACE_ERROR_RETURN ((LM_ERROR
,
90 "(%P|%t) Cannot activate worker threads\n"),
95 while (now
< timeout
&& worker
.got_object_not_exist () != expected_object_not_exist
)
98 ACE_Time_Value
tv (5, 0);
104 CORBA::Object_var object
=
105 orb
->string_to_object (ior
);
107 Simple_Server_var server
=
108 Simple_Server::_narrow (object
.in ());
115 worker
.thr_mgr ()->wait ();
119 if (worker
.got_object_not_exist () != expected_object_not_exist
)
121 ACE_ERROR_RETURN ((LM_ERROR
,
122 "(%P|%t)client: test failed.\n"),
127 ACE_DEBUG ((LM_DEBUG
, "(%P|%t)client: test passed.\n"));
130 catch (const CORBA::Exception
& ex
)
132 ex
._tao_print_exception ("Exception caught in main:");
139 // ****************************************************************
141 Worker::Worker (CORBA::ORB_ptr orb
)
142 : orb_ (CORBA::ORB::_duplicate (orb
)),
143 got_object_not_exist_ (false)
154 catch (const CORBA::OBJECT_NOT_EXIST
&)
156 got_object_not_exist_
= true;
168 CORBA::Object_var object
=
169 this->orb_
->string_to_object (ior
);
171 Simple_Server_var server
=
172 Simple_Server::_narrow (object
.in ());
174 if (CORBA::is_nil (server
.in ()))
176 ACE_ERROR ((LM_ERROR
,
177 "Object reference <%s> is nil.\n",
183 server
->test_is_a ("IDL:Foo:1.0");
186 ACE_DEBUG ((LM_DEBUG
,
187 "(%P|%t) unexpected result = %d\n",
192 Worker::got_object_not_exist () const
194 return got_object_not_exist_
;