2 //=============================================================================
8 * @author Aniruddha Gokhale
10 //=============================================================================
17 #include "ace/Get_Opt.h"
19 // This function runs the test (main program)
21 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
23 // get an instance of the driver object
28 // initialize the driver
29 if (drv
.init (argc
, argv
) == -1)
30 ACE_ERROR_RETURN ((LM_ERROR
,
31 "(%N:%l) driver.cpp - "
32 "Driver initialization failed\n"),
37 ACE_ERROR_RETURN ((LM_ERROR
,
38 "(%N:%l) driver.cpp - "
42 catch (const CORBA::Exception
& ex
)
44 ex
._tao_print_exception ("Caught unexpected CORBA exception:");
60 // initialize the driver
62 Driver::init (int argc
, ACE_TCHAR
**argv
)
64 // environment to track exceptions
66 // retrieve the instance of Options
67 Options
*opt
= OPTIONS::instance ();
69 char exception_string
[256];
73 ACE_OS::strcpy (exception_string
, "ORB Initialization");
75 // Retrieve the underlying ORB
76 this->orb_
= CORBA::ORB_init (argc
,
80 // Parse command line and verify parameters.
81 if (opt
->parse_args (argc
, argv
) == -1)
82 ACE_ERROR_RETURN ((LM_ERROR
,
83 "(%N:%l) driver.cpp - "
84 "parse_args failed\n"),
86 // Retrieve a Param_Test object reference
87 ACE_OS::strcpy (exception_string
,"ORB::string_to_object() failed.");
89 CORBA::Object_var temp
=
90 this->orb_
->string_to_object (opt
->param_test_ior ());
93 if (CORBA::is_nil (temp
.in()))
94 ACE_ERROR_RETURN ((LM_ERROR
,
95 "ORB::string_to_object() returned null object for IOR <%s>\n",
96 opt
->param_test_ior ()),
99 // Get the object reference
100 ACE_OS::strcpy (exception_string
,"Param_Test::_narrow () failed.");
102 this->objref_
= Param_Test::_narrow (temp
.in());
104 catch (const CORBA::Exception
& ex
)
106 ex
._tao_print_exception (exception_string
);
116 // serves as a factory of Param_Client objects. It is also responsible to
119 Options
*opt
= OPTIONS::instance (); // get the options object
122 switch (opt
->test_type ())
124 case Options::TEST_SHORT
:
126 Param_Test_Client
<Test_Short
> *client
= new
127 Param_Test_Client
<Test_Short
> (this->orb_
.in (),
130 if (opt
->invoke_type () == Options::SII
)
131 retstatus
= client
->run_sii_test ();
133 retstatus
= client
->run_dii_test ();
137 case Options::TEST_ULONGLONG
:
139 Param_Test_Client
<Test_ULongLong
> *client
= new
140 Param_Test_Client
<Test_ULongLong
> (this->orb_
.in (),
143 if (opt
->invoke_type () == Options::SII
)
144 retstatus
= client
->run_sii_test ();
146 retstatus
= client
->run_dii_test ();
150 case Options::TEST_UB_STRING
:
152 Param_Test_Client
<Test_Unbounded_String
> *client
= new
153 Param_Test_Client
<Test_Unbounded_String
> (this->orb_
.in (),
155 new Test_Unbounded_String
);
156 if (opt
->invoke_type () == Options::SII
)
157 retstatus
= client
->run_sii_test ();
159 retstatus
= client
->run_dii_test ();
163 case Options::TEST_BD_STRING
:
165 Param_Test_Client
<Test_Bounded_String
> *client
= new
166 Param_Test_Client
<Test_Bounded_String
> (this->orb_
.in (),
168 new Test_Bounded_String
);
169 if (opt
->invoke_type () == Options::SII
)
170 retstatus
= client
->run_sii_test ();
172 retstatus
= client
->run_dii_test ();
176 case Options::TEST_UB_WSTRING
:
178 Param_Test_Client
<Test_Unbounded_WString
> *client
= new
179 Param_Test_Client
<Test_Unbounded_WString
> (this->orb_
.in (),
181 new Test_Unbounded_WString
);
182 if (opt
->invoke_type () == Options::SII
)
183 retstatus
= client
->run_sii_test ();
185 retstatus
= client
->run_dii_test ();
189 case Options::TEST_BD_WSTRING
:
191 Param_Test_Client
<Test_Bounded_WString
> *client
= new
192 Param_Test_Client
<Test_Bounded_WString
> (this->orb_
.in (),
194 new Test_Bounded_WString
);
195 if (opt
->invoke_type () == Options::SII
)
196 retstatus
= client
->run_sii_test ();
198 retstatus
= client
->run_dii_test ();
202 case Options::TEST_FIXED_STRUCT
:
204 Param_Test_Client
<Test_Fixed_Struct
> *client
= new
205 Param_Test_Client
<Test_Fixed_Struct
> (this->orb_
.in (),
207 new Test_Fixed_Struct
);
208 if (opt
->invoke_type () == Options::SII
)
209 retstatus
= client
->run_sii_test ();
211 retstatus
= client
->run_dii_test ();
215 case Options::TEST_UB_STRING_SEQUENCE
:
217 Param_Test_Client
<Test_String_Sequence
> *client
= new
218 Param_Test_Client
<Test_String_Sequence
> (this->orb_
.in (),
220 new Test_String_Sequence
);
221 if (opt
->invoke_type () == Options::SII
)
222 retstatus
= client
->run_sii_test ();
224 retstatus
= client
->run_dii_test ();
228 case Options::TEST_BD_STRING_SEQUENCE
:
230 Param_Test_Client
<Test_Bounded_String_Sequence
> *client
= new
231 Param_Test_Client
<Test_Bounded_String_Sequence
> (this->orb_
.in (),
233 new Test_Bounded_String_Sequence
);
234 if (opt
->invoke_type () == Options::SII
)
235 retstatus
= client
->run_sii_test ();
237 retstatus
= client
->run_dii_test ();
241 case Options::TEST_UB_WSTRING_SEQUENCE
:
243 Param_Test_Client
<Test_WString_Sequence
> *client
= new
244 Param_Test_Client
<Test_WString_Sequence
> (this->orb_
.in (),
246 new Test_WString_Sequence
);
247 if (opt
->invoke_type () == Options::SII
)
248 retstatus
= client
->run_sii_test ();
250 retstatus
= client
->run_dii_test ();
254 case Options::TEST_BD_WSTRING_SEQUENCE
:
256 Param_Test_Client
<Test_Bounded_WString_Sequence
> *client
= new
257 Param_Test_Client
<Test_Bounded_WString_Sequence
> (this->orb_
.in (),
259 new Test_Bounded_WString_Sequence
);
260 if (opt
->invoke_type () == Options::SII
)
261 retstatus
= client
->run_sii_test ();
263 retstatus
= client
->run_dii_test ();
267 case Options::TEST_VAR_STRUCT
:
269 Param_Test_Client
<Test_Var_Struct
> *client
= new
270 Param_Test_Client
<Test_Var_Struct
> (this->orb_
.in (),
272 new Test_Var_Struct
);
273 if (opt
->invoke_type () == Options::SII
)
274 retstatus
= client
->run_sii_test ();
276 retstatus
= client
->run_dii_test ();
280 case Options::TEST_NESTED_STRUCT
:
282 Param_Test_Client
<Test_Nested_Struct
> *client
= new
283 Param_Test_Client
<Test_Nested_Struct
> (this->orb_
.in (),
285 new Test_Nested_Struct
);
286 if (opt
->invoke_type () == Options::SII
)
287 retstatus
= client
->run_sii_test ();
289 retstatus
= client
->run_dii_test ();
293 case Options::TEST_RECURSIVE_STRUCT
:
295 Param_Test_Client
<Test_Recursive_Struct
> *client
= new
296 Param_Test_Client
<Test_Recursive_Struct
> (this->orb_
.in (),
298 new Test_Recursive_Struct
);
299 if (opt
->invoke_type () == Options::SII
)
300 retstatus
= client
->run_sii_test ();
302 retstatus
= client
->run_dii_test ();
306 case Options::TEST_OBJREF_STRUCT
:
308 Param_Test_Client
<Test_Objref_Struct
> *client
= new
309 Param_Test_Client
<Test_Objref_Struct
> (this->orb_
.in (),
311 new Test_Objref_Struct
);
312 if (opt
->invoke_type () == Options::SII
)
313 retstatus
= client
->run_sii_test ();
315 retstatus
= client
->run_dii_test ();
319 case Options::TEST_UB_STRUCT_SEQUENCE
:
321 Param_Test_Client
<Test_Struct_Sequence
> *client
= new
322 Param_Test_Client
<Test_Struct_Sequence
> (this->orb_
.in (),
324 new Test_Struct_Sequence
);
325 if (opt
->invoke_type () == Options::SII
)
326 retstatus
= client
->run_sii_test ();
328 retstatus
= client
->run_dii_test ();
331 Param_Test_Client
<Test_Unbounded_Struct_Sequence
> *client2
= new
332 Param_Test_Client
<Test_Unbounded_Struct_Sequence
>
335 new Test_Unbounded_Struct_Sequence
);
337 if (opt
->invoke_type () == Options::SII
)
338 retstatus
= client2
->run_sii_test ();
340 retstatus
= client2
->run_dii_test ();
344 case Options::TEST_BD_STRUCT_SEQUENCE
:
346 Param_Test_Client
<Test_Bounded_Struct_Sequence
> *client
= new
347 Param_Test_Client
<Test_Bounded_Struct_Sequence
> (this->orb_
.in (),
349 new Test_Bounded_Struct_Sequence
);
350 if (opt
->invoke_type () == Options::SII
)
351 retstatus
= client
->run_sii_test ();
353 retstatus
= client
->run_dii_test ();
357 case Options::TEST_UB_ARRAY_SEQUENCE
:
359 Param_Test_Client
<Test_Array_Sequence
> *client
= new
360 Param_Test_Client
<Test_Array_Sequence
> (this->orb_
.in (),
362 new Test_Array_Sequence
);
363 if (opt
->invoke_type () == Options::SII
)
364 retstatus
= client
->run_sii_test ();
366 retstatus
= client
->run_dii_test ();
370 case Options::TEST_BD_ARRAY_SEQUENCE
:
372 Param_Test_Client
<Test_Bounded_Array_Sequence
> *client
= new
373 Param_Test_Client
<Test_Bounded_Array_Sequence
> (this->orb_
.in (),
375 new Test_Bounded_Array_Sequence
);
376 if (opt
->invoke_type () == Options::SII
)
377 retstatus
= client
->run_sii_test ();
379 retstatus
= client
->run_dii_test ();
383 case Options::TEST_OBJREF
:
385 Param_Test_Client
<Test_ObjRef
> *client
= new
386 Param_Test_Client
<Test_ObjRef
> (this->orb_
.in (),
389 if (opt
->invoke_type () == Options::SII
)
390 retstatus
= client
->run_sii_test ();
392 retstatus
= client
->run_dii_test ();
396 case Options::TEST_TYPECODE
:
398 Param_Test_Client
<Test_TypeCode
> *client
= new
399 Param_Test_Client
<Test_TypeCode
> (this->orb_
.in (),
402 if (opt
->invoke_type () == Options::SII
)
403 retstatus
= client
->run_sii_test ();
405 retstatus
= client
->run_dii_test ();
409 case Options::TEST_ANY
:
411 Param_Test_Client
<Test_Any
> *client
= new
412 Param_Test_Client
<Test_Any
> (this->orb_
.in (),
415 if (opt
->invoke_type () == Options::SII
)
416 retstatus
= client
->run_sii_test ();
418 retstatus
= client
->run_dii_test ();
422 case Options::TEST_OBJREF_SEQUENCE
:
424 Param_Test_Client
<Test_ObjRef_Sequence
> *client
= new
425 Param_Test_Client
<Test_ObjRef_Sequence
> (this->orb_
.in (),
427 new Test_ObjRef_Sequence
);
428 if (opt
->invoke_type () == Options::SII
)
429 retstatus
= client
->run_sii_test ();
431 retstatus
= client
->run_dii_test ();
435 case Options::TEST_ANYSEQ
:
437 Param_Test_Client
<Test_AnySeq
> *client
= new
438 Param_Test_Client
<Test_AnySeq
> (this->orb_
.in (),
441 if (opt
->invoke_type () == Options::SII
)
442 retstatus
= client
->run_sii_test ();
444 retstatus
= client
->run_dii_test ();
448 case Options::TEST_UB_SHORTSEQ
:
450 Param_Test_Client
<Test_Short_Sequence
> *client
= new
451 Param_Test_Client
<Test_Short_Sequence
> (this->orb_
.in (),
453 new Test_Short_Sequence
);
454 if (opt
->invoke_type () == Options::SII
)
455 retstatus
= client
->run_sii_test ();
457 retstatus
= client
->run_dii_test ();
461 case Options::TEST_BD_SHORTSEQ
:
463 Param_Test_Client
<Test_Bounded_Short_Sequence
> *client
= new
464 Param_Test_Client
<Test_Bounded_Short_Sequence
> (this->orb_
.in (),
466 new Test_Bounded_Short_Sequence
);
467 if (opt
->invoke_type () == Options::SII
)
468 retstatus
= client
->run_sii_test ();
470 retstatus
= client
->run_dii_test ();
474 case Options::TEST_UB_LONGSEQ
:
476 Param_Test_Client
<Test_Long_Sequence
> *client
= new
477 Param_Test_Client
<Test_Long_Sequence
> (this->orb_
.in (),
479 new Test_Long_Sequence
);
480 if (opt
->invoke_type () == Options::SII
)
481 retstatus
= client
->run_sii_test ();
483 retstatus
= client
->run_dii_test ();
487 case Options::TEST_BD_LONGSEQ
:
489 Param_Test_Client
<Test_Bounded_Long_Sequence
> *client
= new
490 Param_Test_Client
<Test_Bounded_Long_Sequence
> (this->orb_
.in (),
492 new Test_Bounded_Long_Sequence
);
493 if (opt
->invoke_type () == Options::SII
)
494 retstatus
= client
->run_sii_test ();
496 retstatus
= client
->run_dii_test ();
500 case Options::TEST_FIXED_ARRAY
:
502 Param_Test_Client
<Test_Fixed_Array
> *client
= new
503 Param_Test_Client
<Test_Fixed_Array
> (this->orb_
.in (),
505 new Test_Fixed_Array
);
506 if (opt
->invoke_type () == Options::SII
)
507 retstatus
= client
->run_sii_test ();
509 retstatus
= client
->run_dii_test ();
513 case Options::TEST_VAR_ARRAY
:
515 Param_Test_Client
<Test_Var_Array
> *client
= new
516 Param_Test_Client
<Test_Var_Array
> (this->orb_
.in (),
519 if (opt
->invoke_type () == Options::SII
)
520 retstatus
= client
->run_sii_test ();
522 retstatus
= client
->run_dii_test ();
526 case Options::TEST_EXCEPTION
:
528 Param_Test_Client
<Test_Exception
> *client
= new
529 Param_Test_Client
<Test_Exception
> (this->orb_
.in (),
532 if (opt
->invoke_type () == Options::SII
)
533 retstatus
= client
->run_sii_test ();
535 retstatus
= client
->run_dii_test ();
539 case Options::TEST_BIG_UNION
:
541 Param_Test_Client
<Test_Big_Union
> *client
= new
542 Param_Test_Client
<Test_Big_Union
> (this->orb_
.in (),
545 if (opt
->invoke_type () == Options::SII
)
546 retstatus
= client
->run_sii_test ();
548 retstatus
= client
->run_dii_test ();
552 case Options::TEST_SMALL_UNION
:
554 Param_Test_Client
<Test_Small_Union
> *client
= new
555 Param_Test_Client
<Test_Small_Union
> (this->orb_
.in (),
557 new Test_Small_Union
);
558 if (opt
->invoke_type () == Options::SII
)
559 retstatus
= client
->run_sii_test ();
561 retstatus
= client
->run_dii_test ();
565 case Options::TEST_RECURSIVE_UNION
:
567 Param_Test_Client
<Test_Recursive_Union
> *client
= new
568 Param_Test_Client
<Test_Recursive_Union
> (this->orb_
.in (),
570 new Test_Recursive_Union
);
571 if (opt
->invoke_type () == Options::SII
)
572 retstatus
= client
->run_sii_test ();
574 retstatus
= client
->run_dii_test ();
578 case Options::TEST_COMPLEX_ANY
:
580 Param_Test_Client
<Test_Complex_Any
> *client
= new
581 Param_Test_Client
<Test_Complex_Any
> (this->orb_
.in (),
583 new Test_Complex_Any
);
584 if (opt
->invoke_type () == Options::SII
)
585 retstatus
= client
->run_sii_test ();
587 retstatus
= client
->run_dii_test ();
591 case Options::TEST_MULTDIM_ARRAY
:
593 Param_Test_Client
<Test_Multdim_Array
> *client
= new
594 Param_Test_Client
<Test_Multdim_Array
> (this->orb_
.in (),
596 new Test_Multdim_Array
);
597 if (opt
->invoke_type () == Options::SII
)
598 retstatus
= client
->run_sii_test ();
600 retstatus
= client
->run_dii_test ();
608 // Get in a new environment variable
611 if (opt
->shutdown ())
613 this->objref_
->shutdown ();
616 this->objref_
= Param_Test::_nil ();
617 this->orb_
->destroy ();
619 catch (const CORBA::Exception
& ex
)
621 ex
._tao_print_exception ("during shutdown");