Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Bug_1676_Regression / client.cpp
blobec66b9af10eac378c8b40d32a739a6f4d0cb15f5
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-k <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
32 void get_stringList2(Test::Hello_var hello);
34 int
35 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
37 try
39 CORBA::ORB_var orb =
40 CORBA::ORB_init (argc, argv);
42 if (parse_args (argc, argv) != 0)
43 return 1;
45 CORBA::Object_var tmp =
46 orb->string_to_object(ior);
48 Test::Hello_var hello =
49 Test::Hello::_narrow(tmp.in ());
51 if (CORBA::is_nil (hello.in ()))
53 ACE_ERROR_RETURN ((LM_DEBUG,
54 "Nil Test::Hello reference <%s>\n",
55 ior),
56 1);
59 ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - get_stringList\n"));
61 Test::StringList_var seq =
62 hello->get_stringList ();
64 for (CORBA::ULong i = 0; i<seq->length(); i++)
66 CORBA::String_var the_string = CORBA::string_dup ((*seq)[i]);
67 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
68 the_string.in ()));
71 ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - get_stringList2 with initialization\n"));
73 Test::StringList_var seq2;
74 hello->get_stringList2(true, seq2.out());
76 for (CORBA::ULong i = 0; i<seq2->length(); i++)
78 CORBA::String_var the_string = seq2.in()[i].in();
79 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
80 the_string.in ()));
83 ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - get_stringList2 without initialization\n"));
85 get_stringList2(hello);
87 ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - mod_stringList\n"));
89 hello->mod_stringList(seq.inout());
91 for (CORBA::ULong i = 0; i<seq->length(); i++)
93 CORBA::String_var the_string = CORBA::string_dup ((*seq)[i]);
94 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
95 the_string.in ()));
98 hello->shutdown ();
100 orb->destroy ();
102 catch (const CORBA::Exception& ex)
104 ex._tao_print_exception ("Exception caught:");
105 return 1;
108 return 0;
111 void get_stringList2(Test::Hello_var hello)
113 Test::StringList_var seq2;
117 // Shutdown the ORB and block until the shutdown is complete.
118 hello->get_stringList2(false, seq2.out());
120 for (CORBA::ULong i = 0; i<seq2->length(); i++)
122 CORBA::String_var the_string = seq2.in()[i].in ();
123 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
124 the_string.in ()));
127 catch (const CORBA::BAD_PARAM& )
129 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - caught expected exception BAD_PARAM\n"));
131 catch (const CORBA::Exception& ex)
133 ex._tao_print_exception ("get_stringList2");
135 return;