Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Bug_3746_Regression / client.cpp
blob10215aab92b49bd4f440d4f1828974b78fe0fcc2
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 -k <ior> \n",
23 argv [0]),
24 -1);
26 // Indicates successful parsing of the command line
27 return 0;
30 int
31 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
33 int error= 0;
34 try
36 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
38 if (parse_args (argc, argv) != 0)
39 return 1;
41 CORBA::Object_var tmp = orb->string_to_object(ior);
43 Test::BoundSequences_var TestThis =
44 Test::BoundSequences::_narrow(tmp.in ());
46 if (CORBA::is_nil (TestThis.in ()))
48 ACE_ERROR_RETURN ((LM_DEBUG,
49 "Nil Test::BoundSequences reference <%s>\n",
50 ior),
51 1);
54 ////////////////////////////////////////////
55 ::Test::BoundSequences::SequenceOf10Long Seq;
56 ACE_DEBUG ((LM_DEBUG, "Client - Attempting to set length(11)\n"));
57 try
59 Seq.length (11);
60 ACE_DEBUG ((LM_DEBUG,
61 "Client - **FAILED** Incorrectly set length to %u\n",
62 Seq.length ()));
63 error= 1;
65 catch (const ::CORBA::BAD_PARAM &)
67 ACE_DEBUG ((LM_DEBUG, "Client - Correctly threw bad_param\n"));
69 catch (const ::CORBA::Exception &ex)
71 ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
72 error= 1;
74 catch (...)
76 ACE_DEBUG ((LM_DEBUG,
77 "Client - **FAILED** Incorrectly threw something else\n"));
78 error= 1;
81 ////////////////////////////////////////////
82 ACE_DEBUG ((LM_DEBUG, "Client - Attempting to set length(10)\n"));
83 try
85 Seq.length (10);
86 ACE_DEBUG ((LM_DEBUG, "Client - %Correctly set length to %u\n",
87 ((10 == Seq.length ()) ? "C" : "**** Inc"),
88 Seq.length ()));
89 if (10 != Seq.length ())
90 error= 1;
92 catch (const ::CORBA::Exception &ex)
94 ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
95 error= 1;
97 catch (...)
99 ACE_DEBUG ((LM_DEBUG,
100 "Client - **FAILED** Incorrectly threw something else\n"));
101 error= 1;
104 //////////////////////////////////////////
105 ACE_DEBUG ((LM_DEBUG, "Client - Accessing [0]\n"));
108 // Just to read access Seq[0] without optimizing away
109 ACE_DEBUG ((LM_DEBUG, "", Seq[0]));
110 ACE_DEBUG ((LM_DEBUG, "Client - Correctly allowed access to [0]\n"));
112 catch (const ::CORBA::Exception &ex)
114 ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
115 error= 1;
117 catch (...)
119 ACE_DEBUG ((LM_DEBUG,
120 "Client - **FAILED** Incorrectly threw something else\n"));
121 error= 1;
124 ////////////////////////////////////////////
125 ACE_DEBUG ((LM_DEBUG, "Client - Accessing [10]\n"));
128 // Just to read access Seq[10] without optimizing away
129 ACE_DEBUG ((LM_DEBUG, "", Seq[10]));
130 #if defined (TAO_CHECKED_SEQUENCE_INDEXING) && (TAO_CHECKED_SEQUENCE_INDEXING == 1)
131 ACE_DEBUG ((LM_DEBUG,
132 "Client - **** Incorrectly allowed access to [10]\n"));
133 error= 1;
135 catch (const ::CORBA::BAD_PARAM &)
137 ACE_DEBUG ((LM_DEBUG, "Client - Correctly threw bad_param\n"));
138 #else
139 ACE_DEBUG ((LM_DEBUG, "Client - Correctly allowed access to [10]\n"));
140 #endif // TAO_CHECKED_SEQUENCE_INDEXING
142 catch (const ::CORBA::Exception &ex)
144 ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
145 error= 1;
147 catch (...)
149 ACE_DEBUG ((LM_DEBUG,
150 "Client - **FAILED** Incorrectly threw something else\n"));
151 error= 1;
154 ////////////////////////////////////////////
155 ACE_DEBUG ((LM_DEBUG, "Client - Sending Seq\n"));
156 ::CORBA::ULong result;
159 result= TestThis->SendSequenceOf10Long (Seq.length (), Seq);
160 if (result != Seq.length())
162 ACE_DEBUG ((LM_DEBUG,
163 "Client - **FAILED** Sent %u longs but "
164 "server received %u longs\n",
165 Seq.length(), result));
166 error= 1;
168 else
169 ACE_DEBUG ((LM_DEBUG,
170 "Client - **SUCCESS** Sent and Server got %u longs\n",
171 result));
173 catch (const ::CORBA::Exception &ex)
175 ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
176 error= 1;
178 catch (...)
180 ACE_DEBUG ((LM_DEBUG,
181 "Client - **FAILED** Incorrectly threw something else\n"));
182 error= 1;
185 ////////////////////////////////////////////
186 ACE_DEBUG ((LM_DEBUG, "Client - Shutting down Server\n"));
187 TestThis->shutdown ();
189 ACE_DEBUG ((LM_DEBUG, "Client - Finishing\n"));
190 orb->destroy ();
192 catch (const CORBA::Exception& ex)
194 ex._tao_print_exception ("Client - Exception caught:");
195 error= 1;
198 return error;