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:");
56 Driver::~Driver (void)
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());
105 catch (const CORBA::Exception
& ex
)
107 ex
._tao_print_exception (exception_string
);
117 // serves as a factory of Param_Client objects. It is also responsible to
120 Options
*opt
= OPTIONS::instance (); // get the options object
123 switch (opt
->test_type ())
125 case Options::TEST_SHORT
:
127 Param_Test_Client
<Test_Short
> *client
= new
128 Param_Test_Client
<Test_Short
> (this->orb_
.in (),
131 if (opt
->invoke_type () == Options::SII
)
132 retstatus
= client
->run_sii_test ();
134 retstatus
= client
->run_dii_test ();
138 case Options::TEST_ULONGLONG
:
140 Param_Test_Client
<Test_ULongLong
> *client
= new
141 Param_Test_Client
<Test_ULongLong
> (this->orb_
.in (),
144 if (opt
->invoke_type () == Options::SII
)
145 retstatus
= client
->run_sii_test ();
147 retstatus
= client
->run_dii_test ();
151 case Options::TEST_UB_STRING
:
153 Param_Test_Client
<Test_Unbounded_String
> *client
= new
154 Param_Test_Client
<Test_Unbounded_String
> (this->orb_
.in (),
156 new Test_Unbounded_String
);
157 if (opt
->invoke_type () == Options::SII
)
158 retstatus
= client
->run_sii_test ();
160 retstatus
= client
->run_dii_test ();
164 case Options::TEST_BD_STRING
:
166 Param_Test_Client
<Test_Bounded_String
> *client
= new
167 Param_Test_Client
<Test_Bounded_String
> (this->orb_
.in (),
169 new Test_Bounded_String
);
170 if (opt
->invoke_type () == Options::SII
)
171 retstatus
= client
->run_sii_test ();
173 retstatus
= client
->run_dii_test ();
177 case Options::TEST_UB_WSTRING
:
179 Param_Test_Client
<Test_Unbounded_WString
> *client
= new
180 Param_Test_Client
<Test_Unbounded_WString
> (this->orb_
.in (),
182 new Test_Unbounded_WString
);
183 if (opt
->invoke_type () == Options::SII
)
184 retstatus
= client
->run_sii_test ();
186 retstatus
= client
->run_dii_test ();
190 case Options::TEST_BD_WSTRING
:
192 Param_Test_Client
<Test_Bounded_WString
> *client
= new
193 Param_Test_Client
<Test_Bounded_WString
> (this->orb_
.in (),
195 new Test_Bounded_WString
);
196 if (opt
->invoke_type () == Options::SII
)
197 retstatus
= client
->run_sii_test ();
199 retstatus
= client
->run_dii_test ();
203 case Options::TEST_FIXED_STRUCT
:
205 Param_Test_Client
<Test_Fixed_Struct
> *client
= new
206 Param_Test_Client
<Test_Fixed_Struct
> (this->orb_
.in (),
208 new Test_Fixed_Struct
);
209 if (opt
->invoke_type () == Options::SII
)
210 retstatus
= client
->run_sii_test ();
212 retstatus
= client
->run_dii_test ();
216 case Options::TEST_UB_STRING_SEQUENCE
:
218 Param_Test_Client
<Test_String_Sequence
> *client
= new
219 Param_Test_Client
<Test_String_Sequence
> (this->orb_
.in (),
221 new Test_String_Sequence
);
222 if (opt
->invoke_type () == Options::SII
)
223 retstatus
= client
->run_sii_test ();
225 retstatus
= client
->run_dii_test ();
229 case Options::TEST_BD_STRING_SEQUENCE
:
231 Param_Test_Client
<Test_Bounded_String_Sequence
> *client
= new
232 Param_Test_Client
<Test_Bounded_String_Sequence
> (this->orb_
.in (),
234 new Test_Bounded_String_Sequence
);
235 if (opt
->invoke_type () == Options::SII
)
236 retstatus
= client
->run_sii_test ();
238 retstatus
= client
->run_dii_test ();
242 case Options::TEST_UB_WSTRING_SEQUENCE
:
244 Param_Test_Client
<Test_WString_Sequence
> *client
= new
245 Param_Test_Client
<Test_WString_Sequence
> (this->orb_
.in (),
247 new Test_WString_Sequence
);
248 if (opt
->invoke_type () == Options::SII
)
249 retstatus
= client
->run_sii_test ();
251 retstatus
= client
->run_dii_test ();
255 case Options::TEST_BD_WSTRING_SEQUENCE
:
257 Param_Test_Client
<Test_Bounded_WString_Sequence
> *client
= new
258 Param_Test_Client
<Test_Bounded_WString_Sequence
> (this->orb_
.in (),
260 new Test_Bounded_WString_Sequence
);
261 if (opt
->invoke_type () == Options::SII
)
262 retstatus
= client
->run_sii_test ();
264 retstatus
= client
->run_dii_test ();
268 case Options::TEST_VAR_STRUCT
:
270 Param_Test_Client
<Test_Var_Struct
> *client
= new
271 Param_Test_Client
<Test_Var_Struct
> (this->orb_
.in (),
273 new Test_Var_Struct
);
274 if (opt
->invoke_type () == Options::SII
)
275 retstatus
= client
->run_sii_test ();
277 retstatus
= client
->run_dii_test ();
281 case Options::TEST_NESTED_STRUCT
:
283 Param_Test_Client
<Test_Nested_Struct
> *client
= new
284 Param_Test_Client
<Test_Nested_Struct
> (this->orb_
.in (),
286 new Test_Nested_Struct
);
287 if (opt
->invoke_type () == Options::SII
)
288 retstatus
= client
->run_sii_test ();
290 retstatus
= client
->run_dii_test ();
294 case Options::TEST_RECURSIVE_STRUCT
:
296 Param_Test_Client
<Test_Recursive_Struct
> *client
= new
297 Param_Test_Client
<Test_Recursive_Struct
> (this->orb_
.in (),
299 new Test_Recursive_Struct
);
300 if (opt
->invoke_type () == Options::SII
)
301 retstatus
= client
->run_sii_test ();
303 retstatus
= client
->run_dii_test ();
307 case Options::TEST_OBJREF_STRUCT
:
309 Param_Test_Client
<Test_Objref_Struct
> *client
= new
310 Param_Test_Client
<Test_Objref_Struct
> (this->orb_
.in (),
312 new Test_Objref_Struct
);
313 if (opt
->invoke_type () == Options::SII
)
314 retstatus
= client
->run_sii_test ();
316 retstatus
= client
->run_dii_test ();
320 case Options::TEST_UB_STRUCT_SEQUENCE
:
322 Param_Test_Client
<Test_Struct_Sequence
> *client
= new
323 Param_Test_Client
<Test_Struct_Sequence
> (this->orb_
.in (),
325 new Test_Struct_Sequence
);
326 if (opt
->invoke_type () == Options::SII
)
327 retstatus
= client
->run_sii_test ();
329 retstatus
= client
->run_dii_test ();
332 Param_Test_Client
<Test_Unbounded_Struct_Sequence
> *client2
= new
333 Param_Test_Client
<Test_Unbounded_Struct_Sequence
>
336 new Test_Unbounded_Struct_Sequence
);
338 if (opt
->invoke_type () == Options::SII
)
339 retstatus
= client2
->run_sii_test ();
341 retstatus
= client2
->run_dii_test ();
345 case Options::TEST_BD_STRUCT_SEQUENCE
:
347 Param_Test_Client
<Test_Bounded_Struct_Sequence
> *client
= new
348 Param_Test_Client
<Test_Bounded_Struct_Sequence
> (this->orb_
.in (),
350 new Test_Bounded_Struct_Sequence
);
351 if (opt
->invoke_type () == Options::SII
)
352 retstatus
= client
->run_sii_test ();
354 retstatus
= client
->run_dii_test ();
358 case Options::TEST_UB_ARRAY_SEQUENCE
:
360 Param_Test_Client
<Test_Array_Sequence
> *client
= new
361 Param_Test_Client
<Test_Array_Sequence
> (this->orb_
.in (),
363 new Test_Array_Sequence
);
364 if (opt
->invoke_type () == Options::SII
)
365 retstatus
= client
->run_sii_test ();
367 retstatus
= client
->run_dii_test ();
371 case Options::TEST_BD_ARRAY_SEQUENCE
:
373 Param_Test_Client
<Test_Bounded_Array_Sequence
> *client
= new
374 Param_Test_Client
<Test_Bounded_Array_Sequence
> (this->orb_
.in (),
376 new Test_Bounded_Array_Sequence
);
377 if (opt
->invoke_type () == Options::SII
)
378 retstatus
= client
->run_sii_test ();
380 retstatus
= client
->run_dii_test ();
384 case Options::TEST_OBJREF
:
386 Param_Test_Client
<Test_ObjRef
> *client
= new
387 Param_Test_Client
<Test_ObjRef
> (this->orb_
.in (),
390 if (opt
->invoke_type () == Options::SII
)
391 retstatus
= client
->run_sii_test ();
393 retstatus
= client
->run_dii_test ();
397 case Options::TEST_TYPECODE
:
399 Param_Test_Client
<Test_TypeCode
> *client
= new
400 Param_Test_Client
<Test_TypeCode
> (this->orb_
.in (),
403 if (opt
->invoke_type () == Options::SII
)
404 retstatus
= client
->run_sii_test ();
406 retstatus
= client
->run_dii_test ();
410 case Options::TEST_ANY
:
412 Param_Test_Client
<Test_Any
> *client
= new
413 Param_Test_Client
<Test_Any
> (this->orb_
.in (),
416 if (opt
->invoke_type () == Options::SII
)
417 retstatus
= client
->run_sii_test ();
419 retstatus
= client
->run_dii_test ();
423 case Options::TEST_OBJREF_SEQUENCE
:
425 Param_Test_Client
<Test_ObjRef_Sequence
> *client
= new
426 Param_Test_Client
<Test_ObjRef_Sequence
> (this->orb_
.in (),
428 new Test_ObjRef_Sequence
);
429 if (opt
->invoke_type () == Options::SII
)
430 retstatus
= client
->run_sii_test ();
432 retstatus
= client
->run_dii_test ();
436 case Options::TEST_ANYSEQ
:
438 Param_Test_Client
<Test_AnySeq
> *client
= new
439 Param_Test_Client
<Test_AnySeq
> (this->orb_
.in (),
442 if (opt
->invoke_type () == Options::SII
)
443 retstatus
= client
->run_sii_test ();
445 retstatus
= client
->run_dii_test ();
449 case Options::TEST_UB_SHORTSEQ
:
451 Param_Test_Client
<Test_Short_Sequence
> *client
= new
452 Param_Test_Client
<Test_Short_Sequence
> (this->orb_
.in (),
454 new Test_Short_Sequence
);
455 if (opt
->invoke_type () == Options::SII
)
456 retstatus
= client
->run_sii_test ();
458 retstatus
= client
->run_dii_test ();
462 case Options::TEST_BD_SHORTSEQ
:
464 Param_Test_Client
<Test_Bounded_Short_Sequence
> *client
= new
465 Param_Test_Client
<Test_Bounded_Short_Sequence
> (this->orb_
.in (),
467 new Test_Bounded_Short_Sequence
);
468 if (opt
->invoke_type () == Options::SII
)
469 retstatus
= client
->run_sii_test ();
471 retstatus
= client
->run_dii_test ();
475 case Options::TEST_UB_LONGSEQ
:
477 Param_Test_Client
<Test_Long_Sequence
> *client
= new
478 Param_Test_Client
<Test_Long_Sequence
> (this->orb_
.in (),
480 new Test_Long_Sequence
);
481 if (opt
->invoke_type () == Options::SII
)
482 retstatus
= client
->run_sii_test ();
484 retstatus
= client
->run_dii_test ();
488 case Options::TEST_BD_LONGSEQ
:
490 Param_Test_Client
<Test_Bounded_Long_Sequence
> *client
= new
491 Param_Test_Client
<Test_Bounded_Long_Sequence
> (this->orb_
.in (),
493 new Test_Bounded_Long_Sequence
);
494 if (opt
->invoke_type () == Options::SII
)
495 retstatus
= client
->run_sii_test ();
497 retstatus
= client
->run_dii_test ();
501 case Options::TEST_FIXED_ARRAY
:
503 Param_Test_Client
<Test_Fixed_Array
> *client
= new
504 Param_Test_Client
<Test_Fixed_Array
> (this->orb_
.in (),
506 new Test_Fixed_Array
);
507 if (opt
->invoke_type () == Options::SII
)
508 retstatus
= client
->run_sii_test ();
510 retstatus
= client
->run_dii_test ();
514 case Options::TEST_VAR_ARRAY
:
516 Param_Test_Client
<Test_Var_Array
> *client
= new
517 Param_Test_Client
<Test_Var_Array
> (this->orb_
.in (),
520 if (opt
->invoke_type () == Options::SII
)
521 retstatus
= client
->run_sii_test ();
523 retstatus
= client
->run_dii_test ();
527 case Options::TEST_EXCEPTION
:
529 Param_Test_Client
<Test_Exception
> *client
= new
530 Param_Test_Client
<Test_Exception
> (this->orb_
.in (),
533 if (opt
->invoke_type () == Options::SII
)
534 retstatus
= client
->run_sii_test ();
536 retstatus
= client
->run_dii_test ();
540 case Options::TEST_BIG_UNION
:
542 Param_Test_Client
<Test_Big_Union
> *client
= new
543 Param_Test_Client
<Test_Big_Union
> (this->orb_
.in (),
546 if (opt
->invoke_type () == Options::SII
)
547 retstatus
= client
->run_sii_test ();
549 retstatus
= client
->run_dii_test ();
553 case Options::TEST_SMALL_UNION
:
555 Param_Test_Client
<Test_Small_Union
> *client
= new
556 Param_Test_Client
<Test_Small_Union
> (this->orb_
.in (),
558 new Test_Small_Union
);
559 if (opt
->invoke_type () == Options::SII
)
560 retstatus
= client
->run_sii_test ();
562 retstatus
= client
->run_dii_test ();
566 case Options::TEST_RECURSIVE_UNION
:
568 Param_Test_Client
<Test_Recursive_Union
> *client
= new
569 Param_Test_Client
<Test_Recursive_Union
> (this->orb_
.in (),
571 new Test_Recursive_Union
);
572 if (opt
->invoke_type () == Options::SII
)
573 retstatus
= client
->run_sii_test ();
575 retstatus
= client
->run_dii_test ();
579 case Options::TEST_COMPLEX_ANY
:
581 Param_Test_Client
<Test_Complex_Any
> *client
= new
582 Param_Test_Client
<Test_Complex_Any
> (this->orb_
.in (),
584 new Test_Complex_Any
);
585 if (opt
->invoke_type () == Options::SII
)
586 retstatus
= client
->run_sii_test ();
588 retstatus
= client
->run_dii_test ();
592 case Options::TEST_MULTDIM_ARRAY
:
594 Param_Test_Client
<Test_Multdim_Array
> *client
= new
595 Param_Test_Client
<Test_Multdim_Array
> (this->orb_
.in (),
597 new Test_Multdim_Array
);
598 if (opt
->invoke_type () == Options::SII
)
599 retstatus
= client
->run_sii_test ();
601 retstatus
= client
->run_dii_test ();
609 // Get in a new environment variable
612 if (opt
->shutdown ())
614 this->objref_
->shutdown ();
617 this->objref_
= Param_Test::_nil ();
618 this->orb_
->destroy ();
621 catch (const CORBA::Exception
& ex
)
623 ex
._tao_print_exception ("during shutdown");