1 // Regression test Bug 2234
3 // The bug manifests itself in the server.
6 #include "ace/Get_Opt.h"
7 #include "ace/OS_NS_string.h"
9 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
26 ACE_ERROR_RETURN ((LM_ERROR
,
33 // Indicates successful parsing of the command line
42 CORBA::Boolean testFailed
= 0;
43 ACE_DEBUG( (LM_INFO
, "Regression test for Bug 2234 (Interceptor arg list with var len out params)\n"));
47 orb
= CORBA::ORB_init (argc
, argv
);
49 if (parse_args (argc
, argv
) != 0)
53 object
= orb
->string_to_object(ior
);
55 foo
= Test::Foo::_narrow( object
.in());
57 //-----------------------------------------------------------------------
63 ACE_DEBUG( (LM_INFO
, ". Long() "));
64 rL
= foo
->TestLong( aL
, bL
, cL
);
65 ACE_DEBUG( (LM_INFO
, "a is %d, b is %d, c is %d, r is %d: ", aL
, bL
, cL
, rL
));
66 if (static_cast<CORBA::Long
>(1) != aL
) {
67 ACE_DEBUG( (LM_ERROR
, "a is wrong\n")); testFailed
= 1;}
68 else if (static_cast<CORBA::Long
>(2) != bL
) {
69 ACE_DEBUG( (LM_ERROR
, "b is wrong\n")); testFailed
= 1;}
70 else if (static_cast<CORBA::Long
>(4) != cL
) {
71 ACE_DEBUG( (LM_ERROR
, "c is wrong\n")); testFailed
= 1;}
72 else if (static_cast<CORBA::Long
>(7) != rL
) {
73 ACE_DEBUG( (LM_ERROR
, "r is wrong\n")); testFailed
= 1;}
75 ACE_DEBUG( (LM_INFO
, "OK\n"));
77 //-----------------------------------------------------------------------
79 aS
= CORBA::string_dup("1"),
81 cS
= CORBA::string_dup("3"),
83 ACE_DEBUG( (LM_INFO
, ". String() "));
84 rS
= foo
->TestString( aS
.in(), bS
.out(), cS
.inout());
85 ACE_DEBUG( (LM_INFO
, "a is %C, b is %C, c is %C, r is %C: ", aS
.in (), bS
.in (), cS
.in (), rS
.in ()));
86 if ((0 != *aS
.in()) && (0 != ACE_OS::strcmp(aS
.in(), "1"))) {
87 ACE_DEBUG( (LM_ERROR
, "a is wrong\n")); testFailed
= 1;}
88 else if ((0 != *aS
.in()) && (0 != ACE_OS::strcmp(bS
.in(), "2"))) {
89 ACE_DEBUG( (LM_ERROR
, "b is wrong\n")); testFailed
= 1;}
90 else if ((0 != *aS
.in()) && (0 != ACE_OS::strcmp(cS
.in(), "4"))) {
91 ACE_DEBUG( (LM_ERROR
, "c is wrong\n")); testFailed
= 1;}
92 else if ((0 != *aS
.in()) && (0 != ACE_OS::strcmp(rS
.in(), "7"))) {
93 ACE_DEBUG( (LM_ERROR
, "r is wrong\n")); testFailed
= 1;}
95 ACE_DEBUG( (LM_INFO
, "OK\n"));
97 //-----------------------------------------------------------------------
98 Test::MyNonVarStruct_var
99 aFS
= new Test::MyNonVarStruct(),
100 bFS
= new Test::MyNonVarStruct(),
101 cFS
= new Test::MyNonVarStruct(),
105 ACE_DEBUG( (LM_INFO
, ". MyNonVarStruct() "));
106 rFS
= foo
->TestNonVarStruct( aFS
.in(), bFS
.out(), cFS
.inout());
107 ACE_DEBUG( (LM_INFO
, "a is %d, b is %d, c is %d, r is %d: ", aFS
.in().val
, bFS
.in().val
, cFS
.in().val
, rFS
.in().val
));
108 if (static_cast<CORBA::Long
>(1) != aFS
->val
) {
109 ACE_DEBUG( (LM_ERROR
, "a is wrong\n")); testFailed
= 1;}
110 else if (static_cast<CORBA::Long
>(2) != bFS
->val
) {
111 ACE_DEBUG( (LM_ERROR
, "b is wrong\n")); testFailed
= 1;}
112 else if (static_cast<CORBA::Long
>(4) != cFS
->val
) {
113 ACE_DEBUG( (LM_ERROR
, "c is wrong\n")); testFailed
= 1;}
114 else if (static_cast<CORBA::Long
>(7) != rFS
->val
) {
115 ACE_DEBUG( (LM_ERROR
, "r is wrong\n")); testFailed
= 1;}
117 ACE_DEBUG( (LM_INFO
, "OK\n"));
119 //-----------------------------------------------------------------------
120 Test::MyVarStruct_var
121 aVS
= new Test::MyVarStruct(),
123 cVS
= new Test::MyVarStruct(),
125 aVS
->val
= CORBA::string_dup("1");
126 cVS
->val
= CORBA::string_dup("3");
127 ACE_DEBUG( (LM_INFO
, ". MyVarStruct() "));
128 rVS
= foo
->TestVarStruct( aVS
.in(), bVS
.out(), cVS
.inout());
129 ACE_DEBUG( (LM_INFO
, "a is %C, b is %C, c is %C, r is %C: ", aVS
->val
.in(), bVS
->val
.in (), cVS
->val
.in (), rVS
->val
.in ()));
130 if ((0 != *aVS
->val
) && (0 != ACE_OS::strcmp(aVS
->val
, "1"))) {
131 ACE_DEBUG( (LM_ERROR
, "a is wrong\n")); testFailed
= 1;}
132 else if ((0 != *bVS
->val
) && (0 != ACE_OS::strcmp(bVS
->val
, "2"))) {
133 ACE_DEBUG( (LM_ERROR
, "b is wrong\n")); testFailed
= 1;}
134 else if ((0 != *cVS
->val
) && (0 != ACE_OS::strcmp(cVS
->val
, "4"))) {
135 ACE_DEBUG( (LM_ERROR
, "c is wrong\n")); testFailed
= 1;}
136 else if ((0 != *rVS
->val
) && (0 != ACE_OS::strcmp(rVS
->val
, "7"))) {
137 ACE_DEBUG( (LM_ERROR
, "r is wrong\n")); testFailed
= 1;}
139 ACE_DEBUG( (LM_INFO
, "OK\n"));
141 //-----------------------------------------------------------------------
142 Test::MyNonVarUnion_var
143 aFU
= new Test::MyNonVarUnion(),
144 bFU
= new Test::MyNonVarUnion(),
145 cFU
= new Test::MyNonVarUnion(),
147 aFU
->valLong( static_cast<CORBA::Long
>(1));
148 cFU
->valLong( static_cast<CORBA::Long
>(3));
149 ACE_DEBUG( (LM_INFO
, ". MyNonVarUnion() "));
150 rFU
= foo
->TestNonVarUnion( aFU
.in(), bFU
.out(), cFU
.inout());
151 ACE_DEBUG( (LM_INFO
, "a is "));
152 if (static_cast<CORBA::Short
>(1) != aFU
->_d())
153 ACE_DEBUG( (LM_INFO
, "?"));
155 ACE_DEBUG( (LM_INFO
, "%d", aFU
->valLong()));
156 ACE_DEBUG( (LM_INFO
, ", b is "));
157 if (static_cast<CORBA::Short
>(1) != bFU
->_d())
158 ACE_DEBUG( (LM_INFO
, "?"));
160 ACE_DEBUG( (LM_INFO
, "%d", bFU
->valLong()));
161 ACE_DEBUG( (LM_INFO
, ", c is "));
162 if (static_cast<CORBA::Short
>(1) != cFU
->_d())
163 ACE_DEBUG( (LM_INFO
, "?"));
165 ACE_DEBUG( (LM_INFO
, "%d", cFU
->valLong()));
166 ACE_DEBUG( (LM_INFO
, ", r is "));
167 if (static_cast<CORBA::Short
>(1) != rFU
->_d())
168 ACE_DEBUG( (LM_INFO
, "?"));
170 ACE_DEBUG( (LM_INFO
, "%d", rFU
->valLong()));
171 ACE_DEBUG( (LM_INFO
, ": "));
172 if ((static_cast<CORBA::Short
>(1) != aFU
->_d()) || (static_cast<CORBA::Long
>(1) != aFU
->valLong())) {
173 ACE_DEBUG( (LM_ERROR
, "a is wrong\n")); testFailed
= 1;}
174 else if ((static_cast<CORBA::Short
>(1) != bFU
->_d()) || (static_cast<CORBA::Long
>(2) != bFU
->valLong())) {
175 ACE_DEBUG( (LM_ERROR
, "b is wrong\n")); testFailed
= 1;}
176 else if ((static_cast<CORBA::Short
>(1) != cFU
->_d()) || (static_cast<CORBA::Long
>(4) != cFU
->valLong())) {
177 ACE_DEBUG( (LM_ERROR
, "c is wrong\n")); testFailed
= 1;}
178 else if ((static_cast<CORBA::Short
>(1) != rFU
->_d()) || (static_cast<CORBA::Long
>(7) != rFU
->valLong())) {
179 ACE_DEBUG( (LM_ERROR
, "r is wrong\n")); testFailed
= 1;}
181 ACE_DEBUG( (LM_INFO
, "OK\n"));
183 //-----------------------------------------------------------------------
185 aVU
= new Test::MyVarUnion(),
187 cVU
= new Test::MyVarUnion(),
189 aVU
->valLong( static_cast<CORBA::Long
>(1));
190 cVU
->valLong( static_cast<CORBA::Long
>(3));
191 ACE_DEBUG( (LM_INFO
, ". MyVarUnion() "));
192 rVU
= foo
->TestVarUnion( aVU
.in(), bVU
.out(), cVU
.inout());
193 ACE_DEBUG( (LM_INFO
, "a is "));
194 if (static_cast<CORBA::Short
>(1) != aVU
->_d())
195 ACE_DEBUG( (LM_INFO
, "?"));
197 ACE_DEBUG( (LM_INFO
, "%d", aVU
->valLong()));
198 ACE_DEBUG( (LM_INFO
, ", b is "));
199 if (static_cast<CORBA::Short
>(1) != bVU
->_d())
200 ACE_DEBUG( (LM_INFO
, "?"));
202 ACE_DEBUG( (LM_INFO
, "%d", bVU
->valLong()));
203 ACE_DEBUG( (LM_INFO
, ", c is "));
204 if (static_cast<CORBA::Short
>(1) != cVU
->_d())
205 ACE_DEBUG( (LM_INFO
, "?"));
207 ACE_DEBUG( (LM_INFO
, "%d", cVU
->valLong()));
208 ACE_DEBUG( (LM_INFO
, ", r is "));
209 if (static_cast<CORBA::Short
>(1) != rVU
->_d())
210 ACE_DEBUG( (LM_INFO
, "?"));
212 ACE_DEBUG( (LM_INFO
, "%d", rVU
->valLong()));
213 ACE_DEBUG( (LM_INFO
, ": "));
214 if ((static_cast<CORBA::Short
>(1) != aVU
->_d()) || (static_cast<CORBA::Long
>(1) != aVU
->valLong())) {
215 ACE_DEBUG( (LM_ERROR
, "a is wrong\n")); testFailed
= 1;}
216 else if ((static_cast<CORBA::Short
>(1) != bVU
->_d()) || (static_cast<CORBA::Long
>(2) != bVU
->valLong())) {
217 ACE_DEBUG( (LM_ERROR
, "b is wrong\n")); testFailed
= 1;}
218 else if ((static_cast<CORBA::Short
>(1) != cVU
->_d()) || (static_cast<CORBA::Long
>(4) != cVU
->valLong())) {
219 ACE_DEBUG( (LM_ERROR
, "c is wrong\n")); testFailed
= 1;}
220 else if ((static_cast<CORBA::Short
>(1) != rVU
->_d()) || (static_cast<CORBA::Long
>(7) != rVU
->valLong())) {
221 ACE_DEBUG( (LM_ERROR
, "r is wrong\n")); testFailed
= 1;}
223 ACE_DEBUG( (LM_INFO
, "OK\n"));
225 //-----------------------------------------------------------------------
226 Test::MySeqOfLong_var
227 aSL
= new Test::MySeqOfLong(1),
229 cSL
= new Test::MySeqOfLong(1),
232 aSL
[0]= static_cast<CORBA::Long
>(1);
234 cSL
[0]= static_cast<CORBA::Long
>(3);
235 ACE_DEBUG( (LM_INFO
, ". MySeqOfLong() "));
236 rSL
= foo
->TestSeqOfLong( aSL
.in(), bSL
.out(), cSL
.inout());
237 ACE_DEBUG( (LM_INFO
, "a is "));
238 if (1u != aSL
->length())
239 ACE_DEBUG( (LM_INFO
, "?"));
241 ACE_DEBUG( (LM_INFO
, "%d", aSL
[0]));
242 ACE_DEBUG( (LM_INFO
, ", b is "));
243 if (1u != bSL
->length())
244 ACE_DEBUG( (LM_INFO
, "?"));
246 ACE_DEBUG( (LM_INFO
, "%d", bSL
[0]));
247 ACE_DEBUG( (LM_INFO
, ", c is "));
248 if (1u != cSL
->length())
249 ACE_DEBUG( (LM_INFO
, "?"));
251 ACE_DEBUG( (LM_INFO
, "%d", cSL
[0]));
252 ACE_DEBUG( (LM_INFO
, ", r is "));
253 if (1u != rSL
->length())
254 ACE_DEBUG( (LM_INFO
, "?"));
256 ACE_DEBUG( (LM_INFO
, "%d", rSL
[0]));
257 ACE_DEBUG( (LM_INFO
, ": "));
258 if ((1u != aSL
->length()) || (static_cast<CORBA::Long
>(1) != aSL
[0])) {
259 ACE_DEBUG( (LM_ERROR
, "a is wrong\n")); testFailed
= 1;}
260 else if ((1u != bSL
->length()) || (static_cast<CORBA::Long
>(2) != bSL
[0])) {
261 ACE_DEBUG( (LM_ERROR
, "b is wrong\n")); testFailed
= 1;}
262 else if ((1u != cSL
->length()) || (static_cast<CORBA::Long
>(4) != cSL
[0])) {
263 ACE_DEBUG( (LM_ERROR
, "c is wrong\n")); testFailed
= 1;}
264 else if ((1u != rSL
->length()) || (static_cast<CORBA::Long
>(7) != rSL
[0])) {
265 ACE_DEBUG( (LM_ERROR
, "r is wrong\n")); testFailed
= 1;}
267 ACE_DEBUG( (LM_INFO
, "OK\n"));
269 //-----------------------------------------------------------------------
271 aA
= new CORBA::Any(),
273 cA
= new CORBA::Any(),
275 aA
<<= static_cast<CORBA::Long
>(1);
276 cA
<<= static_cast<CORBA::Long
>(3);
277 ACE_DEBUG( (LM_INFO
, ". Any() "));
278 rA
= foo
->TestAny( aA
.in(), bA
.out(), cA
.inout());
284 ACE_DEBUG( (LM_INFO
, "a is "));
285 if (0 != (aB
= (aA
>>= aL
)))
286 ACE_DEBUG( (LM_INFO
, "%d", aL
));
288 ACE_DEBUG( (LM_INFO
, "?"));
289 ACE_DEBUG( (LM_INFO
, ", b is "));
290 if (0 != (bB
= (bA
>>= bL
)))
291 ACE_DEBUG( (LM_INFO
, "%d", bL
));
293 ACE_DEBUG( (LM_INFO
, "?"));
294 ACE_DEBUG( (LM_INFO
, ", c is "));
295 if (0 != (cB
= (cA
>>= cL
)))
296 ACE_DEBUG( (LM_INFO
, "%d", cL
));
298 ACE_DEBUG( (LM_INFO
, "?"));
299 ACE_DEBUG( (LM_INFO
, ", r is "));
300 if (0 != (rB
= (rA
>>= rL
)))
301 ACE_DEBUG( (LM_INFO
, "%d", rL
));
303 ACE_DEBUG( (LM_INFO
, "?"));
304 ACE_DEBUG( (LM_INFO
, ": "));
305 if (!aB
|| (static_cast<CORBA::Long
>(1) != aL
)) {
306 ACE_DEBUG( (LM_ERROR
, "a is wrong\n")); testFailed
= 1;}
307 else if (!bB
|| (static_cast<CORBA::Long
>(2) != bL
)) {
308 ACE_DEBUG( (LM_ERROR
, "b is wrong\n")); testFailed
= 1;}
309 else if (!cB
|| (static_cast<CORBA::Long
>(4) != cL
)) {
310 ACE_DEBUG( (LM_ERROR
, "c is wrong\n")); testFailed
= 1;}
311 else if (!rB
|| (static_cast<CORBA::Long
>(7) != rL
)) {
312 ACE_DEBUG( (LM_ERROR
, "r is wrong\n")); testFailed
= 1;}
314 ACE_DEBUG( (LM_INFO
, "OK\n"));
316 //-----------------------------------------------------------------------
324 Test::MyArray_var arr_b
;
332 ACE_DEBUG( (LM_INFO
, ". MyArray() "));
333 Test::MyArray_var arr_ret
= foo
->TestArray (arr_a
, arr_b
.out (), arr_c
);
334 CORBA::ULong
zero (0), one (1); //Use ULong to avoid ambiguity
335 if (arr_c
[0].length () != 1 || arr_c
[0][0] != 24)
337 ACE_DEBUG( (LM_ERROR
, "arr_c[0] is wrong\n")); testFailed
= 1;
339 else if (arr_c
[1].length () != 1 || arr_c
[1][0] != 10)
341 ACE_DEBUG( (LM_ERROR
, "arr_c[1] is wrong\n")); testFailed
= 1;
343 else if (arr_b
[zero
].length () != 1 || arr_b
[zero
][0] != 8)
345 ACE_DEBUG( (LM_ERROR
, "arr_b[0] is wrong\n")); testFailed
= 1;
347 else if (arr_b
[one
].length () != 1 || arr_b
[one
][0] != 22)
349 ACE_DEBUG( (LM_ERROR
, "arr_b[1] is wrong\n")); testFailed
= 1;
351 else if (arr_ret
[zero
].length () != 1 || arr_ret
[zero
][0] != 7)
353 ACE_DEBUG( (LM_ERROR
, "arr_ret[0] is wrong\n")); testFailed
= 1;
355 else if (arr_ret
[one
].length () != 1 || arr_ret
[one
][0] != 21)
357 ACE_DEBUG( (LM_ERROR
, "arr_ret[1] is wrong\n")); testFailed
= 1;
360 ACE_DEBUG( (LM_INFO
, "OK\n"));
363 //-----------------------------------------------------------------------
365 CORBA::Object_var a
= CORBA::Object::_duplicate (foo
.in ());
367 CORBA::Object_var c
= CORBA::Object::_duplicate (a
.in ());
368 CORBA::Object_var ret
= foo
->TestObject (a
.in (), b
.out (), c
.inout ());
371 //-----------------------------------------------------------------------
372 foo
->ShutdownServer();
374 //-----------------------------------------------------------------------
378 catch (const CORBA::SystemException
& ex
)
380 ex
._tao_print_exception ("CORBA::SystemException: ");
383 catch (const CORBA::Exception
& ex
)
385 ex
._tao_print_exception ("CORBA::Exception: ");
390 ACE_DEBUG( (LM_ERROR
, "Unexpected general exception!\n"));
394 ACE_DEBUG( (LM_INFO
, "Regression test for Bug 2234 "));
396 ACE_DEBUG( (LM_ERROR
, "Failed\n"));
398 ACE_DEBUG( (LM_INFO
, "Passed\n"));
400 return testFailed
? -1 : 0;