3 #include "ace/Get_Opt.h"
5 const ACE_TCHAR
*ior_input_file
= ACE_TEXT ("file://test.ior");
16 test_select which_test
= TEST_ALL
;
19 parse_args (int argc
, ACE_TCHAR
*argv
[])
21 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:dsoe"));
24 while ((c
= get_opts ()) != -1)
28 ior_input_file
= get_opts
.optarg
;
34 which_test
= TEST_STATE
;
37 which_test
= TEST_OPERATION
;
40 which_test
= TEST_EXCEPTION
;
44 ACE_ERROR_RETURN ((LM_ERROR
,
51 // Indicates successful parsing of the command line
56 dump_node (BaseNode
* bn
, int indent
)
63 StringNode
* sn
= StringNode::_downcast (bn
);
67 // This is ugly I know
69 for (; i
!= 0; --i
) ACE_DEBUG ((LM_DEBUG
, " "));
73 ACE_DEBUG ((LM_DEBUG
, "%x <StringNode> %C\n",
85 dump_node (bn
->left (),
87 dump_node (bn
->right (),
92 dump_tree (TreeController
*tc
)
97 "(%P|%t) start tree dump <%x>\n",
101 dump_node (tc
->root (),
106 ACE_DEBUG ((LM_DEBUG
,
107 "(%P|%t) end tree dump <%x>\n",
113 test_state (base_ptr abs
)
115 CORBA::ValueBase_var vbase
= abs
->_to_value ();
116 TreeController
*tc
= TreeController::_downcast (vbase
.in ());
121 test_operation (base_ptr abs
)
123 CORBA::String_var retval
= abs
->base_op ("base_op");
127 ACE_DEBUG ((LM_DEBUG
,
132 CORBA::Object_var obj
= abs
->_to_object ();
134 foo_var concrete
= foo::_narrow (obj
.in ());
136 retval
= concrete
->foo_op ("foo_op");
140 ACE_DEBUG ((LM_DEBUG
,
145 retval
= concrete
->base_op ("base_op");
149 ACE_DEBUG ((LM_DEBUG
,
156 test_exception (base_ptr abs
)
160 CORBA::String_var retval
= abs
->base_op ("bad_name");
164 ACE_DEBUG ((LM_DEBUG
,
169 catch (const BadInput
& ex
)
173 ACE_DEBUG ((LM_DEBUG
,
181 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
183 CORBA::String_var retval
;
187 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
189 if (parse_args (argc
, argv
) != 0)
194 CORBA::Object_var obj
=
195 orb
->string_to_object (ior_input_file
);
197 if (CORBA::is_nil (obj
.in ()))
199 ACE_ERROR_RETURN ((LM_ERROR
,
200 "string_to_object failed.\n"),
204 passer_var objref
= passer::_narrow (obj
.in ());
206 if (CORBA::is_nil (objref
.in ()))
208 ACE_ERROR_RETURN ((LM_ERROR
,
209 "_narrow failed.\n"),
213 base_var package
= base::_nil ();
215 if (which_test
== TEST_STATE
|| which_test
== TEST_ALL
)
217 // Create and register factory for BaseNode.
218 BaseNode_init
*bn_factory
= 0;
219 ACE_NEW_RETURN (bn_factory
,
223 orb
->register_value_factory (bn_factory
->tao_repository_id (),
225 bn_factory
->_remove_ref (); // release ownership
227 // Create and register factory for TreeController.
228 TreeController_init
*tc_factory
= 0;
229 ACE_NEW_RETURN (tc_factory
,
233 orb
->register_value_factory (tc_factory
->tao_repository_id (),
235 tc_factory
->_remove_ref (); // release ownership
237 // Create and register factory for StringNode.
238 StringNode_init
*sn_factory
= 0;
239 ACE_NEW_RETURN (sn_factory
,
243 orb
->register_value_factory (sn_factory
->tao_repository_id (),
245 sn_factory
->_remove_ref (); // release ownership
247 objref
->pass_state (package
.out ());
249 if (CORBA::is_nil (package
.in ()))
251 ACE_ERROR_RETURN ((LM_ERROR
,
252 "pass_state() returned null OUT arg\n"),
256 test_state (package
.in ());
259 if (which_test
!= TEST_STATE
)
261 objref
->pass_ops (package
.out ());
263 if (CORBA::is_nil (package
.in ()))
265 ACE_ERROR_RETURN ((LM_ERROR
,
266 "pass_ops() returned null OUT arg\n"),
271 if (which_test
== TEST_OPERATION
|| which_test
== TEST_ALL
)
273 test_operation (package
.in ());
276 if (which_test
== TEST_EXCEPTION
|| which_test
== TEST_ALL
)
278 test_exception (package
.in ());
281 if (which_test
== TEST_ALL
)
283 objref
->pass_nil (package
.out ());
285 if (!CORBA::is_nil (package
.in ()))
287 ACE_ERROR_RETURN ((LM_ERROR
,
288 "pass_nil() did NOT return null OUT arg\n"),
297 catch (const CORBA::Exception
& ex
)
299 ex
._tao_print_exception ("Client: exception caught - ");