Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Bug_3524_Regression / client.cpp
blob25fba9db7f77a4bf6ccb96e340674db4a5879fce
1 // -*- C++ -*-
2 #include "ace/Get_Opt.h"
3 #include "ace/Synch.h"
4 #include "testC.h"
6 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
8 int
9 parse_args (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("k:"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'k':
18 ior = get_opts.opt_arg ();
19 break;
20 case '?':
21 default:
22 ACE_ERROR_RETURN ((LM_ERROR,
23 ACE_TEXT ("usage: %s ")
24 ACE_TEXT ("-v ")
25 ACE_TEXT ("\n"),
26 argv [0]),
27 -1);
29 return 0;
32 int
33 call_method (::Test::A_ptr server,
34 ::Test::A::FailOn where,
35 const char * arg1,
36 ::CORBA::String_out & arg2,
37 char *& arg3,
38 const char * error_message)
40 try
42 CORBA::String_var res = server->method (where,
43 arg1,
44 arg2,
45 arg3);
47 ACE_ERROR ((LM_ERROR,
48 "ERROR: No %C",
49 error_message));
50 return 1;
52 catch (const CORBA::BAD_PARAM &)
54 // it's ok
56 catch (const CORBA::Exception &)
58 ACE_ERROR ((LM_ERROR,
59 "ERROR: Wrong %C",
60 error_message));
61 return 1;
64 return 0;
67 int
68 call_method_s (::Test::A_ptr server,
69 ::Test::A::FailOn where,
70 const char * arg1,
71 ::CORBA::String_out & arg2,
72 char *& arg3,
73 const char * error_message)
75 try
77 CORBA::String_var res = server->method_s (where,
78 arg1,
79 arg2,
80 arg3);
82 ACE_ERROR ((LM_ERROR,
83 "ERROR: No %C",
84 error_message));
85 return 1;
87 catch (const CORBA::BAD_PARAM &)
89 // it's ok
91 catch (const CORBA::Exception &)
93 ACE_ERROR ((LM_ERROR,
94 "ERROR: Wrong %C",
95 error_message));
96 return 1;
99 return 0;
103 call_seq_method (::Test::A_ptr server,
104 ::Test::A::FailOn where,
105 const ::Test::seq_bd_str & arg1,
106 ::Test::seq_bd_str_out & arg2,
107 ::Test::seq_bd_str & arg3,
108 const char * error_message)
112 ::Test::seq_bd_str_var res =
113 server->seq_method (where,
114 arg1,
115 arg2,
116 arg3);
118 ACE_ERROR ((LM_ERROR,
119 "ERROR: No %C",
120 error_message));
121 return 1;
123 catch (const CORBA::BAD_PARAM &)
125 // it's ok
127 catch (const CORBA::Exception &)
129 ACE_ERROR ((LM_ERROR,
130 "ERROR: Wrong %C",
131 error_message));
132 return 1;
135 return 0;
139 call_seq_method_s (::Test::A_ptr server,
140 ::Test::A::FailOn where,
141 const ::Test::seq_bds_str & arg1,
142 ::Test::seq_bds_str_out & arg2,
143 ::Test::seq_bds_str & arg3,
144 const char * error_message)
148 ::Test::seq_bds_str_var res =
149 server->seq_method_s (where,
150 arg1,
151 arg2,
152 arg3);
154 ACE_ERROR ((LM_ERROR,
155 "ERROR: No %C",
156 error_message));
157 return 1;
159 catch (const CORBA::BAD_PARAM &)
161 // it's ok
163 catch (const CORBA::Exception &)
165 ACE_ERROR ((LM_ERROR,
166 "ERROR: Wrong %C",
167 error_message));
168 return 1;
171 return 0;
175 call_arr_method (::Test::A_ptr server,
176 ::Test::A::FailOn where,
177 const ::Test::arr_bd_str & arg1,
178 ::Test::arr_bd_str_out & arg2,
179 ::Test::arr_bd_str & arg3,
180 const char * error_message)
184 ::Test::arr_bd_str_var res =
185 server->arr_method (where,
186 arg1,
187 arg2,
188 arg3);
190 ACE_ERROR ((LM_ERROR,
191 "ERROR: No %C",
192 error_message));
193 return 1;
195 catch (const CORBA::BAD_PARAM &)
197 // it's ok
199 catch (const CORBA::Exception &)
201 ACE_ERROR ((LM_ERROR,
202 "ERROR: Wrong %C",
203 error_message));
204 return 1;
207 return 0;
211 call_arr_method_s (::Test::A_ptr server,
212 ::Test::A::FailOn where,
213 const ::Test::arr_bds_str & arg1,
214 ::Test::arr_bds_str_out & arg2,
215 ::Test::arr_bds_str & arg3,
216 const char * error_message)
220 ::Test::arr_bds_str_var res =
221 server->arr_method_s (where,
222 arg1,
223 arg2,
224 arg3);
226 ACE_ERROR ((LM_ERROR,
227 "ERROR: No %C",
228 error_message));
229 return 1;
231 catch (const CORBA::BAD_PARAM &)
233 // it's ok
235 catch (const CORBA::Exception &)
237 ACE_ERROR ((LM_ERROR,
238 "ERROR: Wrong %C",
239 error_message));
240 return 1;
243 return 0;
247 call_sct_method (::Test::A_ptr server,
248 ::Test::A::FailOn where,
249 const ::Test::sct & arg1,
250 ::Test::sct_out & arg2,
251 ::Test::sct & arg3,
252 const char * error_message)
256 ::Test::sct_var res =
257 server->sct_method (where,
258 arg1,
259 arg2,
260 arg3);
262 ACE_ERROR ((LM_ERROR,
263 "ERROR: No %C",
264 error_message));
265 return 1;
267 catch (const CORBA::BAD_PARAM &)
269 // it's ok
271 catch (const CORBA::Exception &)
273 ACE_ERROR ((LM_ERROR,
274 "ERROR: Wrong %C",
275 error_message));
276 return 1;
279 return 0;
283 call_unn_method (::Test::A_ptr server,
284 ::Test::A::FailOn where,
285 const ::Test::unn & arg1,
286 ::Test::unn_out & arg2,
287 ::Test::unn & arg3,
288 const char * error_message)
292 ::Test::unn_var res =
293 server->unn_method (where,
294 arg1,
295 arg2,
296 arg3);
298 ACE_ERROR ((LM_ERROR,
299 "ERROR: No %C",
300 error_message));
301 return 1;
303 catch (const CORBA::BAD_PARAM &)
305 // it's ok
307 catch (const CORBA::Exception &)
309 ACE_ERROR ((LM_ERROR,
310 "ERROR: Wrong %C",
311 error_message));
312 return 1;
315 return 0;
319 call_vbx_method (::Test::A_ptr server,
320 ::Test::A::FailOn where,
321 ::Test::val_bd_str * arg1,
322 ::Test::val_bd_str_out arg2,
323 ::Test::val_bd_str *& arg3,
324 const char * error_message)
328 ::Test::val_bd_str_var res =
329 server->vbx_method (where,
330 arg1,
331 arg2,
332 arg3);
334 ACE_ERROR ((LM_ERROR,
335 "ERROR: No %C",
336 error_message));
337 return 1;
339 catch (const CORBA::BAD_PARAM &)
341 // it's ok
343 catch (const CORBA::Exception &)
345 ACE_ERROR ((LM_ERROR,
346 "ERROR: Wrong %C",
347 error_message));
348 return 1;
351 return 0;
355 call_vbx_method_s (::Test::A_ptr server,
356 ::Test::A::FailOn where,
357 ::Test::val_bds_str * arg1,
358 ::Test::val_bds_str_out arg2,
359 ::Test::val_bds_str *& arg3,
360 const char * error_message)
364 ::Test::val_bds_str_var res =
365 server->vbx_method_s (where,
366 arg1,
367 arg2,
368 arg3);
370 ACE_ERROR ((LM_ERROR,
371 "ERROR: No %C",
372 error_message));
373 return 1;
375 catch (const CORBA::BAD_PARAM &)
377 // it's ok
379 catch (const CORBA::Exception &)
381 ACE_ERROR ((LM_ERROR,
382 "ERROR: Wrong %C",
383 error_message));
384 return 1;
387 return 0;
391 call_vtp_method (::Test::A_ptr server,
392 ::Test::A::FailOn where,
393 ::Test::vtp * arg1,
394 ::Test::vtp_out arg2,
395 ::Test::vtp *& arg3,
396 const char * error_message)
400 ::Test::vtp_var res =
401 server->vtp_method (where,
402 arg1,
403 arg2,
404 arg3);
406 ACE_ERROR ((LM_ERROR,
407 "ERROR: No %C",
408 error_message));
409 return 1;
411 catch (const CORBA::BAD_PARAM &)
413 // it's ok
415 catch (const CORBA::Exception &)
417 ACE_ERROR ((LM_ERROR,
418 "ERROR: Wrong %C",
419 error_message));
420 return 1;
423 return 0;
426 int test_strings (::Test::A_ptr server)
428 int status = 0;
431 CORBA::String_var arg2, arg3;
432 CORBA::String_out arg2_out = arg2.out ();
433 status |=
434 call_method (server,
435 ::Test::A::ARG1,
436 ::Test::FailStr,
437 arg2_out,
438 arg3,
439 "exception is thrown in a call "
440 "for `in bounded_string`.\n");
441 status |=
442 call_method_s (server,
443 ::Test::A::ARG1,
444 ::Test::FailStr,
445 arg2_out,
446 arg3,
447 "exception is thrown in a call "
448 "for `in string<BOUND>`.\n");
452 CORBA::String_var arg2, arg3;
453 CORBA::String_out arg2_out = arg2.out ();
454 status |=
455 call_method (server,
456 ::Test::A::ARG2,
458 arg2_out,
459 arg3,
460 "exception is thrown in a call "
461 "for `out bounded_string`.\n");
462 status |=
463 call_method_s (server,
464 ::Test::A::ARG2,
466 arg2_out,
467 arg3,
468 "exception is thrown in a call "
469 "for `out string<BOUND>`.\n");
473 CORBA::String_var arg2, arg3;
474 CORBA::String_out arg2_out = arg2.out ();
475 status |=
476 call_method (server,
477 ::Test::A::ARG3,
479 arg2_out,
480 arg3,
481 "exception is thrown in a call "
482 "for `inout bounded_string` (server side).\n");
483 status |=
484 call_method_s (server,
485 ::Test::A::ARG3,
487 arg2_out,
488 arg3,
489 "exception is thrown in a call "
490 "for `inout string<BOUND>` (server side).\n");
494 CORBA::String_var arg2;
495 CORBA::String_var arg3 = CORBA::string_dup (::Test::FailStr);
496 CORBA::String_out arg2_out = arg2.out ();
497 status |=
498 call_method (server,
499 ::Test::A::ARG3,
501 arg2_out,
502 arg3,
503 "exception is thrown in a call "
504 "for `inout bounded_string`.\n");
505 status |=
506 call_method_s (server,
507 ::Test::A::ARG3,
509 arg2_out,
510 arg3,
511 "exception is thrown in a call "
512 "for `inout string<BOUND>`.\n");
516 CORBA::String_var arg2, arg3;
517 CORBA::String_out arg2_out = arg2.out ();
518 status |=
519 call_method (server,
520 ::Test::A::RETN,
522 arg2_out,
523 arg3,
524 "exception is thrown in a call "
525 "when server returns `bounded_string`.\n");
526 status |=
527 call_method_s (server,
528 ::Test::A::RETN,
530 arg2_out,
531 arg3,
532 "exception is thrown in a call "
533 "when server returns `string<BOUND>`.\n");
536 return status;
539 int test_sequences (::Test::A_ptr server)
541 int status = 0;
544 ::Test::seq_bd_str arg1;
545 arg1.length (1);
546 arg1[0] = CORBA::string_dup (::Test::FailStr);
547 ::Test::seq_bd_str_var arg2;
548 ::Test::seq_bd_str_out arg2_out = arg2.out ();
549 ::Test::seq_bd_str arg3;
550 status |=
551 call_seq_method (server,
552 ::Test::A::ARG1,
553 arg1,
554 arg2_out,
555 arg3,
556 "exception is thrown in a call "
557 "for `in sequence<bounded_string>`.\n");
561 ::Test::seq_bds_str arg1;
562 arg1.length (1);
563 arg1[0] = CORBA::string_dup (::Test::FailStr);
564 ::Test::seq_bds_str_var arg2;
565 ::Test::seq_bds_str_out arg2_out = arg2.out ();
566 ::Test::seq_bds_str arg3;
567 arg3.length (1);
568 status |=
569 call_seq_method_s (server,
570 ::Test::A::ARG1,
571 arg1,
572 arg2_out,
573 arg3,
574 "exception is thrown in a call "
575 "for `in sequence<string<BOUND>>`.\n");
579 ::Test::seq_bd_str arg1;
580 arg1.length (1);
581 ::Test::seq_bd_str_var arg2;
582 ::Test::seq_bd_str_out arg2_out = arg2.out ();
583 ::Test::seq_bd_str arg3;
584 arg3.length (1);
585 status |=
586 call_seq_method (server,
587 ::Test::A::ARG2,
588 arg1,
589 arg2_out,
590 arg3,
591 "exception is thrown in a call "
592 "for `out sequence<bounded_string>`.\n");
596 ::Test::seq_bds_str arg1;
597 arg1.length (1);
598 ::Test::seq_bds_str_var arg2;
599 ::Test::seq_bds_str_out arg2_out = arg2.out ();
600 ::Test::seq_bds_str arg3;
601 arg3.length (1);
602 status |=
603 call_seq_method_s (server,
604 ::Test::A::ARG2,
605 arg1,
606 arg2_out,
607 arg3,
608 "exception is thrown in a call "
609 "for `out sequence<string<BOUND>>`.\n");
613 ::Test::seq_bd_str arg1;
614 arg1.length (1);
615 ::Test::seq_bd_str_var arg2;
616 ::Test::seq_bd_str_out arg2_out = arg2.out ();
617 ::Test::seq_bd_str arg3;
618 arg3.length (1);
619 status |=
620 call_seq_method (server,
621 ::Test::A::ARG3,
622 arg1,
623 arg2_out,
624 arg3,
625 "exception is thrown in a call "
626 "for `inout sequence<bounded_string>` (server side).\n");
630 ::Test::seq_bds_str arg1;
631 arg1.length (1);
632 ::Test::seq_bds_str_var arg2;
633 ::Test::seq_bds_str_out arg2_out = arg2.out ();
634 ::Test::seq_bds_str arg3;
635 arg3.length (1);
636 status |=
637 call_seq_method_s (server,
638 ::Test::A::ARG3,
639 arg1,
640 arg2_out,
641 arg3,
642 "exception is thrown in a call "
643 "for `inout sequence<string<BOUND>>` (server side).\n");
647 ::Test::seq_bd_str arg1;
648 arg1.length (1);
649 ::Test::seq_bd_str_var arg2;
650 ::Test::seq_bd_str_out arg2_out = arg2.out ();
651 ::Test::seq_bd_str arg3;
652 arg3.length (1);
653 arg3[0] = CORBA::string_dup (::Test::FailStr);
654 status |=
655 call_seq_method (server,
656 ::Test::A::ARG3,
657 arg1,
658 arg2_out,
659 arg3,
660 "exception is thrown in a call "
661 "for `inout sequence<bounded_string>`.\n");
665 ::Test::seq_bds_str arg1;
666 arg1.length (1);
667 ::Test::seq_bds_str_var arg2;
668 ::Test::seq_bds_str_out arg2_out = arg2.out ();
669 ::Test::seq_bds_str arg3;
670 arg3.length (1);
671 arg3[0] = CORBA::string_dup (::Test::FailStr);
672 status |=
673 call_seq_method_s (server,
674 ::Test::A::ARG3,
675 arg1,
676 arg2_out,
677 arg3,
678 "exception is thrown in a call "
679 "for `inout sequence<string<BOUND>>`.\n");
683 ::Test::seq_bd_str arg1;
684 arg1.length (1);
685 ::Test::seq_bd_str_var arg2;
686 ::Test::seq_bd_str_out arg2_out = arg2.out ();
687 ::Test::seq_bd_str arg3;
688 arg3.length (1);
689 status |=
690 call_seq_method (server,
691 ::Test::A::RETN,
692 arg1,
693 arg2_out,
694 arg3,
695 "exception is thrown in a call "
696 "when server returns `sequence<bounded_string>`.\n");
700 ::Test::seq_bds_str arg1;
701 arg1.length (1);
702 ::Test::seq_bds_str_var arg2;
703 ::Test::seq_bds_str_out arg2_out = arg2.out ();
704 ::Test::seq_bds_str arg3;
705 arg3.length (1);
706 status |=
707 call_seq_method_s (server,
708 ::Test::A::RETN,
709 arg1,
710 arg2_out,
711 arg3,
712 "exception is thrown in a call "
713 "when server returns `sequence<string<BOUND>>`.\n");
716 return status;
719 int test_arrays (::Test::A_ptr server)
721 int status = 0;
724 ::Test::arr_bd_str arg1;
725 arg1[0] = CORBA::string_dup (::Test::FailStr);
726 ::Test::arr_bd_str_var arg2;
727 ::Test::arr_bd_str_out arg2_out = arg2.out ();
728 ::Test::arr_bd_str arg3;
729 status |=
730 call_arr_method (server,
731 ::Test::A::ARG1,
732 arg1,
733 arg2_out,
734 arg3,
735 "exception is thrown in a call "
736 "for `in bounded_string array[]`.\n");
740 ::Test::arr_bds_str arg1;
741 arg1[0] = CORBA::string_dup (::Test::FailStr);
742 ::Test::arr_bds_str_var arg2;
743 ::Test::arr_bds_str_out arg2_out = arg2.out ();
744 ::Test::arr_bds_str arg3;
745 status |=
746 call_arr_method_s (server,
747 ::Test::A::ARG1,
748 arg1,
749 arg2_out,
750 arg3,
751 "exception is thrown in a call "
752 "for `in string<BOUND> array[]`.\n");
756 ::Test::arr_bd_str arg1;
757 ::Test::arr_bd_str_var arg2;
758 ::Test::arr_bd_str_out arg2_out = arg2.out ();
759 ::Test::arr_bd_str arg3;
760 status |=
761 call_arr_method (server,
762 ::Test::A::ARG2,
763 arg1,
764 arg2_out,
765 arg3,
766 "exception is thrown in a call "
767 "for `out bounded_string array[]`.\n");
771 ::Test::arr_bds_str arg1;
772 ::Test::arr_bds_str_var arg2;
773 ::Test::arr_bds_str_out arg2_out = arg2.out ();
774 ::Test::arr_bds_str arg3;
775 status |=
776 call_arr_method_s (server,
777 ::Test::A::ARG2,
778 arg1,
779 arg2_out,
780 arg3,
781 "exception is thrown in a call "
782 "for `out string<BOUND> array[]`.\n");
786 ::Test::arr_bd_str arg1;
787 ::Test::arr_bd_str_var arg2;
788 ::Test::arr_bd_str_out arg2_out = arg2.out ();
789 ::Test::arr_bd_str arg3;
790 status |=
791 call_arr_method (server,
792 ::Test::A::ARG3,
793 arg1,
794 arg2_out,
795 arg3,
796 "exception is thrown in a call "
797 "for `inout bounded_string array[]` (server side).\n");
801 ::Test::arr_bds_str arg1;
802 ::Test::arr_bds_str_var arg2;
803 ::Test::arr_bds_str_out arg2_out = arg2.out ();
804 ::Test::arr_bds_str arg3;
805 status |=
806 call_arr_method_s (server,
807 ::Test::A::ARG3,
808 arg1,
809 arg2_out,
810 arg3,
811 "exception is thrown in a call "
812 "for `inout string<BOUND> array[]` (server side).\n");
816 ::Test::arr_bd_str arg1;
817 ::Test::arr_bd_str_var arg2;
818 ::Test::arr_bd_str_out arg2_out = arg2.out ();
819 ::Test::arr_bd_str arg3;
820 arg3[0] = CORBA::string_dup (::Test::FailStr);
821 status |=
822 call_arr_method (server,
823 ::Test::A::ARG3,
824 arg1,
825 arg2_out,
826 arg3,
827 "exception is thrown in a call "
828 "for `inout bounded_string array[]`.\n");
832 ::Test::arr_bds_str arg1;
833 ::Test::arr_bds_str_var arg2;
834 ::Test::arr_bds_str_out arg2_out = arg2.out ();
835 ::Test::arr_bds_str arg3;
836 arg3[0] = CORBA::string_dup (::Test::FailStr);
837 status |=
838 call_arr_method_s (server,
839 ::Test::A::ARG3,
840 arg1,
841 arg2_out,
842 arg3,
843 "exception is thrown in a call "
844 "for `inout string<BOUND> array[]`.\n");
848 ::Test::arr_bd_str arg1;
849 ::Test::arr_bd_str_var arg2;
850 ::Test::arr_bd_str_out arg2_out = arg2.out ();
851 ::Test::arr_bd_str arg3;
852 status |=
853 call_arr_method (server,
854 ::Test::A::RETN,
855 arg1,
856 arg2_out,
857 arg3,
858 "exception is thrown in a call "
859 "when server returns `bounded_string array[]`.\n");
863 ::Test::arr_bds_str arg1;
864 ::Test::arr_bds_str_var arg2;
865 ::Test::arr_bds_str_out arg2_out = arg2.out ();
866 ::Test::arr_bds_str arg3;
867 status |=
868 call_arr_method_s (server,
869 ::Test::A::RETN,
870 arg1,
871 arg2_out,
872 arg3,
873 "exception is thrown in a call "
874 "when server returns `string<BOUND> array[]`.\n");
877 return status;
880 int test_structs (::Test::A_ptr server)
882 int status = 0;
885 ::Test::sct arg1;
886 arg1.b = CORBA::string_dup (::Test::FailStr);
887 arg1.c = CORBA::string_dup (::Test::FailStr);
888 ::Test::sct_var arg2;
889 ::Test::sct_out arg2_out = arg2.out ();
890 ::Test::sct arg3;
891 status |=
892 call_sct_method (server,
893 ::Test::A::ARG1,
894 arg1,
895 arg2_out,
896 arg3,
897 "exception is thrown in a call "
898 "for `in struct {}`.\n");
902 ::Test::sct arg1;
903 ::Test::sct_var arg2;
904 ::Test::sct_out arg2_out = arg2.out ();
905 ::Test::sct arg3;
906 status |=
907 call_sct_method (server,
908 ::Test::A::ARG2,
909 arg1,
910 arg2_out,
911 arg3,
912 "exception is thrown in a call "
913 "for `out struct {}`.\n");
917 ::Test::sct arg1;
918 ::Test::sct_var arg2;
919 ::Test::sct_out arg2_out = arg2.out ();
920 ::Test::sct arg3;
921 status |=
922 call_sct_method (server,
923 ::Test::A::ARG3,
924 arg1,
925 arg2_out,
926 arg3,
927 "exception is thrown in a call "
928 "for `inout struct {}` (server side).\n");
932 ::Test::sct arg1;
933 ::Test::sct_var arg2;
934 ::Test::sct_out arg2_out = arg2.out ();
935 ::Test::sct arg3;
936 arg3.b = CORBA::string_dup (::Test::FailStr);
937 arg3.c = CORBA::string_dup (::Test::FailStr);
938 status |=
939 call_sct_method (server,
940 ::Test::A::ARG3,
941 arg1,
942 arg2_out,
943 arg3,
944 "exception is thrown in a call "
945 "for `inout struct {}`.\n");
949 ::Test::sct arg1;
950 ::Test::sct_var arg2;
951 ::Test::sct_out arg2_out = arg2.out ();
952 ::Test::sct arg3;
953 status |=
954 call_sct_method (server,
955 ::Test::A::RETN,
956 arg1,
957 arg2_out,
958 arg3,
959 "exception is thrown in a call "
960 "when server returns `struct {}`.\n");
963 return status;
966 int test_unions (::Test::A_ptr server)
968 int status = 0;
971 ::Test::unn arg1;
972 arg1.b (CORBA::string_dup (::Test::FailStr));
973 arg1.c (CORBA::string_dup (::Test::FailStr));
974 ::Test::unn_var arg2;
975 ::Test::unn_out arg2_out = arg2.out ();
976 ::Test::unn arg3;
977 status |=
978 call_unn_method (server,
979 ::Test::A::ARG1,
980 arg1,
981 arg2_out,
982 arg3,
983 "exception is thrown in a call "
984 "for `in union {}`.\n");
988 ::Test::unn arg1;
989 ::Test::unn_var arg2;
990 ::Test::unn_out arg2_out = arg2.out ();
991 ::Test::unn arg3;
992 status |=
993 call_unn_method (server,
994 ::Test::A::ARG2,
995 arg1,
996 arg2_out,
997 arg3,
998 "exception is thrown in a call "
999 "for `out union {}`.\n");
1003 ::Test::unn arg1;
1004 ::Test::unn_var arg2;
1005 ::Test::unn_out arg2_out = arg2.out ();
1006 ::Test::unn arg3;
1007 status |=
1008 call_unn_method (server,
1009 ::Test::A::ARG3,
1010 arg1,
1011 arg2_out,
1012 arg3,
1013 "exception is thrown in a call "
1014 "for `inout union {}` (server side).\n");
1018 ::Test::unn arg1;
1019 ::Test::unn_var arg2;
1020 ::Test::unn_out arg2_out = arg2.out ();
1021 ::Test::unn arg3;
1022 arg3.b (CORBA::string_dup (::Test::FailStr));
1023 arg3.c (CORBA::string_dup (::Test::FailStr));
1024 status |=
1025 call_unn_method (server,
1026 ::Test::A::ARG3,
1027 arg1,
1028 arg2_out,
1029 arg3,
1030 "exception is thrown in a call "
1031 "for `inout union {}`.\n");
1035 ::Test::unn arg1;
1036 ::Test::unn_var arg2;
1037 ::Test::unn_out arg2_out = arg2.out ();
1038 ::Test::unn arg3;
1039 status |=
1040 call_unn_method (server,
1041 ::Test::A::RETN,
1042 arg1,
1043 arg2_out,
1044 arg3,
1045 "exception is thrown in a call when "
1046 "when server returns `union {}`.\n");
1049 return status;
1052 int test_valueboxes (::Test::A_ptr server)
1054 int status = 0;
1057 ::Test::val_bd_str_var arg1;
1058 ACE_NEW_THROW_EX (arg1.inout (),
1059 ::Test::val_bd_str (::Test::FailStr),
1060 CORBA::NO_MEMORY ());
1061 ::Test::val_bd_str_var arg2;
1062 ::Test::val_bd_str_out arg2_out = arg2;
1063 ::Test::val_bd_str_var arg3;
1064 status |=
1065 call_vbx_method (server,
1066 ::Test::A::ARG1,
1067 arg1.in (),
1068 arg2_out,
1069 arg3.inout (),
1070 "exception is thrown in a call "
1071 "for `in valuebox {bounded_string}`.\n");
1075 ::Test::val_bds_str_var arg1;
1076 ACE_NEW_THROW_EX (arg1.inout (),
1077 ::Test::val_bds_str (::Test::FailStr),
1078 CORBA::NO_MEMORY ());
1079 ::Test::val_bds_str_var arg2;
1080 ::Test::val_bds_str_out arg2_out = arg2;
1081 ::Test::val_bds_str_var arg3;
1082 status |=
1083 call_vbx_method_s (server,
1084 ::Test::A::ARG1,
1085 arg1.in (),
1086 arg2_out,
1087 arg3.inout (),
1088 "exception is thrown in a call "
1089 "for `in valuebox {string<BOUND>}`.\n");
1093 ::Test::val_bd_str_var arg1;
1094 ::Test::val_bd_str_var arg2;
1095 ::Test::val_bd_str_out arg2_out = arg2;
1096 ::Test::val_bd_str_var arg3;
1097 status |=
1098 call_vbx_method (server,
1099 ::Test::A::ARG2,
1100 arg1.in (),
1101 arg2_out,
1102 arg3.inout (),
1103 "exception is thrown in a call "
1104 "for `out valuebox {bounded_string}`.\n");
1108 ::Test::val_bds_str_var arg1;
1109 ::Test::val_bds_str_var arg2;
1110 ::Test::val_bds_str_out arg2_out = arg2;
1111 ::Test::val_bds_str_var arg3;
1112 status |=
1113 call_vbx_method_s (server,
1114 ::Test::A::ARG2,
1115 arg1.in (),
1116 arg2_out,
1117 arg3.inout (),
1118 "exception is thrown in a call "
1119 "for `out valuebox {string<BOUND>}`.\n");
1123 ::Test::val_bd_str_var arg1;
1124 ::Test::val_bd_str_var arg2;
1125 ::Test::val_bd_str_out arg2_out = arg2;
1126 ::Test::val_bd_str_var arg3;
1127 status |=
1128 call_vbx_method (server,
1129 ::Test::A::ARG3,
1130 arg1.in (),
1131 arg2_out,
1132 arg3.inout (),
1133 "exception is thrown in a call "
1134 "for `inout valuebox {bounded_string}` (server side).\n");
1138 ::Test::val_bds_str_var arg1;
1139 ::Test::val_bds_str_var arg2;
1140 ::Test::val_bds_str_out arg2_out = arg2;
1141 ::Test::val_bds_str_var arg3;
1142 status |=
1143 call_vbx_method_s (server,
1144 ::Test::A::ARG3,
1145 arg1.in (),
1146 arg2_out,
1147 arg3.inout (),
1148 "exception is thrown in a call "
1149 "for `inout valuebox {string<BOUND>}` (server side).\n");
1153 ::Test::val_bd_str_var arg1;
1154 ::Test::val_bd_str_var arg2;
1155 ::Test::val_bd_str_out arg2_out = arg2;
1156 ::Test::val_bd_str_var arg3;
1157 ACE_NEW_THROW_EX (arg3.inout (),
1158 ::Test::val_bd_str (::Test::FailStr),
1159 CORBA::NO_MEMORY ());
1160 status |=
1161 call_vbx_method (server,
1162 ::Test::A::ARG3,
1163 arg1.in (),
1164 arg2_out,
1165 arg3.inout (),
1166 "exception is thrown in a call "
1167 "for `inout valuebox {bounded_string}`.\n");
1171 ::Test::val_bds_str_var arg1;
1172 ::Test::val_bds_str_var arg2;
1173 ::Test::val_bds_str_out arg2_out = arg2;
1174 ::Test::val_bds_str_var arg3;
1175 ACE_NEW_THROW_EX (arg3.inout (),
1176 ::Test::val_bds_str (::Test::FailStr),
1177 CORBA::NO_MEMORY ());
1178 status |=
1179 call_vbx_method_s (server,
1180 ::Test::A::ARG3,
1181 arg1.in (),
1182 arg2_out,
1183 arg3.inout (),
1184 "exception is thrown in a call "
1185 "for `inout valuebox {string<BOUND>}`.\n");
1189 ::Test::val_bd_str_var arg1;
1190 ::Test::val_bd_str_var arg2;
1191 ::Test::val_bd_str_out arg2_out = arg2;
1192 ::Test::val_bd_str_var arg3;
1193 status |=
1194 call_vbx_method (server,
1195 ::Test::A::RETN,
1196 arg1.in (),
1197 arg2_out,
1198 arg3.inout (),
1199 "exception is thrown in a call "
1200 "when server returns `valuebox {bounded_string}`.\n");
1204 ::Test::val_bds_str_var arg1;
1205 ::Test::val_bds_str_var arg2;
1206 ::Test::val_bds_str_out arg2_out = arg2;
1207 ::Test::val_bds_str_var arg3;
1208 status |=
1209 call_vbx_method_s (server,
1210 ::Test::A::RETN,
1211 arg1.in (),
1212 arg2_out,
1213 arg3.inout (),
1214 "exception is thrown in a call "
1215 "when server returns `valuebox {string<BOUND>}`.\n");
1218 return status;
1221 int test_valuetypes (::Test::A_ptr server, ::Test::vtp_init *vtp_factory)
1223 int status = 0;
1226 ::Test::vtp_var arg1 =
1227 ::Test::vtp::_downcast (vtp_factory->create_for_unmarshal ());
1228 arg1->b (CORBA::string_dup (::Test::FailStr));
1229 arg1->c (CORBA::string_dup (::Test::FailStr));
1230 ::Test::vtp_var arg2;
1231 ::Test::vtp_out arg2_out = arg2;
1232 ::Test::vtp_var arg3 =
1233 ::Test::vtp::_downcast (vtp_factory->create_for_unmarshal ());
1234 status |=
1235 call_vtp_method (server,
1236 ::Test::A::ARG1,
1237 arg1.in (),
1238 arg2_out,
1239 arg3.inout (),
1240 "exception is thrown in a call "
1241 "for `in valuetype {}`.\n");
1245 ::Test::vtp_var arg1;
1246 ::Test::vtp_var arg2;
1247 ::Test::vtp_out arg2_out = arg2;
1248 ::Test::vtp_var arg3;
1249 status |=
1250 call_vtp_method (server,
1251 ::Test::A::ARG2,
1252 arg1.in (),
1253 arg2_out,
1254 arg3.inout (),
1255 "exception is thrown in a call "
1256 "for `out valuetype {}`.\n");
1260 ::Test::vtp_var arg1;
1261 ::Test::vtp_var arg2;
1262 ::Test::vtp_out arg2_out = arg2;
1263 ::Test::vtp_var arg3;
1264 status |=
1265 call_vtp_method (server,
1266 ::Test::A::ARG3,
1267 arg1.in (),
1268 arg2_out,
1269 arg3.inout (),
1270 "exception is thrown in a call "
1271 "for `inout valuetype {}` (server side).\n");
1275 ::Test::vtp_var arg1;
1276 ::Test::vtp_var arg2;
1277 ::Test::vtp_out arg2_out = arg2;
1278 ::Test::vtp_var arg3 =
1279 ::Test::vtp::_downcast (vtp_factory->create_for_unmarshal ());
1280 arg3->b (CORBA::string_dup (::Test::FailStr));
1281 arg3->c (CORBA::string_dup (::Test::FailStr));
1282 status |=
1283 call_vtp_method (server,
1284 ::Test::A::ARG3,
1285 arg1.in (),
1286 arg2_out,
1287 arg3.inout (),
1288 "exception is thrown in a call "
1289 "for `inout valuetype {}`.\n");
1293 ::Test::vtp_var arg1;
1294 ::Test::vtp_var arg2;
1295 ::Test::vtp_out arg2_out = arg2;
1296 ::Test::vtp_var arg3;
1297 status |=
1298 call_vtp_method (server,
1299 ::Test::A::RETN,
1300 arg1.in (),
1301 arg2_out,
1302 arg3.inout (),
1303 "exception is thrown in a call "
1304 "when server returns `valuetype {}`.\n");
1307 return status;
1310 int test_exceptions (::Test::A_ptr server)
1312 int status = 0;
1314 ::Test::string_field all[] = {
1315 ::Test::BOUNDED,
1316 ::Test::TYPEDEFED
1319 for (unsigned int i = 0;
1320 i < sizeof (all) / sizeof (::Test::string_field);
1321 ++i)
1325 server->exc_method (all[i]);
1327 catch (const ::Test::exc &)
1329 status |= 1;
1330 ACE_ERROR ((LM_ERROR,
1331 "ERROR: Illegal exception is thrown.\n"));
1333 catch (const CORBA::BAD_PARAM &)
1335 // it's ok
1337 catch (const CORBA::Exception &)
1339 status |= 1;
1340 ACE_ERROR ((LM_ERROR,
1341 "ERROR: Wrong exception is thrown.\n"));
1345 return status;
1349 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
1351 int status = 0;
1355 CORBA::ORB_var orb =
1356 CORBA::ORB_init (argc, argv);
1358 ::Test::vtp_init *vtp_factory = 0;
1359 ACE_NEW_THROW_EX (vtp_factory,
1360 ::Test::vtp_init,
1361 CORBA::NO_MEMORY ());
1362 CORBA::ValueFactoryBase_var vtp_factory_owner = vtp_factory;
1364 orb->register_value_factory (vtp_factory->tao_repository_id (),
1365 vtp_factory);
1367 if (parse_args (argc, argv) != 0)
1368 return 1;
1370 CORBA::Object_var object =
1371 orb->string_to_object (ior);
1373 Test::A_var server =
1374 Test::A::_narrow (object.in ());
1376 if (CORBA::is_nil (server.in ()))
1378 ACE_ERROR_RETURN ((LM_ERROR,
1379 ACE_TEXT ("Object reference <%s> is nil\n"),
1380 ior),
1384 status |= test_strings (server.in ());
1386 status |= test_sequences (server.in ());
1388 status |= test_arrays (server.in ());
1390 status |= test_structs (server.in ());
1392 status |= test_unions (server.in ());
1394 status |= test_valueboxes (server.in ());
1396 status |= test_valuetypes (server.in (), vtp_factory);
1398 status |= test_exceptions (server.in ());
1400 server->shutdown ();
1402 orb->destroy ();
1404 catch (const CORBA::Exception& ex)
1406 ex._tao_print_exception ("Caught exception in client:");
1407 return 1;
1410 return status;