Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / DynValue_Test / main.cpp
blob1edb8531c1c470149b324e54098db50ac6cb63a2
1 #include "Analyzer.h"
3 //============= Test main() ============
4 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
6 try
8 DynAnyAnalyzer analyzer (argc, argv);
10 ////////////////////////////////////////////
11 // DynValue_Test::BoxedLong
12 ////////////////////////////////////////////
14 const CORBA::Long l1= -157;
16 ACE_DEBUG ((LM_DEBUG,
17 "%N:%l Creating DynValue_Test::BoxedLong\n"));
18 DynValue_Test::BoxedLong *p_myBoxedLong =0;
19 ACE_NEW_THROW_EX (
20 p_myBoxedLong,
21 DynValue_Test::BoxedLong (l1),
22 CORBA::NO_MEMORY ());
23 DynValue_Test::BoxedLong_var myBoxedLong (p_myBoxedLong);
24 ACE_DEBUG ((LM_DEBUG,
25 "..%N:%l checking value, long is %d\n",
26 myBoxedLong->_value () ));
27 if (l1 != myBoxedLong->_value ())
29 ACE_DEBUG ((LM_DEBUG,
30 "..%N:%l FAILED should have been %d\n", l1));
31 return 1;
34 ACE_DEBUG ((LM_DEBUG, "..%N:%l Inserting into an any\n"));
35 CORBA::Any myAny;
36 myAny <<= myBoxedLong.in ();
38 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from an any\n"));
39 DynValue_Test::BoxedLong
40 *myBoxedLongExtracted =
41 reinterpret_cast<DynValue_Test::BoxedLong *> (9);
42 if (!(myAny >>= myBoxedLongExtracted))
44 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
45 return 1;
47 if (!myBoxedLongExtracted)
49 ACE_DEBUG ((LM_DEBUG,
50 "..%N:%l FAILED Null pointer extracted\n"));
51 return 1;
53 if (reinterpret_cast<DynValue_Test::BoxedLong *> (9)
54 == myBoxedLongExtracted)
56 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
57 return 1;
59 ACE_DEBUG ((LM_DEBUG,
60 "..%N:%l checking value, long is %d\n",
61 myBoxedLongExtracted->_value () ));
62 if (l1 != myBoxedLongExtracted->_value ())
64 ACE_DEBUG ((LM_DEBUG,
65 "..%N:%l FAILED should have been %d\n", l1));
66 return 1;
69 ACE_DEBUG ((LM_DEBUG, "..%N:%l Creating dynamic any from any\n"));
70 DynamicAny::DynAny_var dany_boxed (analyzer.DynAny (myAny));
71 analyzer.analyze (dany_boxed.in ());
73 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing dynamic any for non-null\n"));
74 DynamicAny::DynValueCommon *dvc =
75 dynamic_cast<DynamicAny::DynValueCommon *> (dany_boxed.in ());
76 if (!dvc)
78 ACE_DEBUG ((LM_DEBUG,
79 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
80 return 1;
82 if (dvc->is_null ())
84 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED this dynamic any is Null!\n"));
85 return 1;
88 ACE_DEBUG ((LM_DEBUG,
89 "..%N:%l Creating dynamic any from IDL generated typecode\n"));
90 DynamicAny::DynAny_var
91 dany (analyzer.DynAny (DynValue_Test::_tc_BoxedLong));
92 analyzer.analyze (dany.in ());
94 ACE_DEBUG ((LM_DEBUG,
95 "..%N:%l Testing typecode generated dynamic any for Null\n"));
96 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany.in ());
97 if (!dvc)
99 ACE_DEBUG ((LM_DEBUG,
100 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon\n"));
101 return 1;
103 if (!(dvc->is_null ()))
105 ACE_DEBUG ((LM_DEBUG,
106 "..%N:%l FAILED this dynamic any has a value!\n"));
107 return 1;
110 ACE_DEBUG ((LM_DEBUG,
111 "..%N:%l Testing for inequality with original dyanamic any\n"));
112 if (dany->equal (dany_boxed.in ()))
114 ACE_DEBUG ((LM_DEBUG,
115 "..%N:%l FAILED they test equal before setting shorts\n"));
116 return 1;
119 ACE_DEBUG ((LM_DEBUG,
120 "..%N:%l Setting to value and test for inequality with original dyanamic any\n"));
121 dvc->set_to_value ();
122 analyzer.analyze (dany.in ());
123 if (dany->equal (dany_boxed.in ()))
125 ACE_DEBUG ((LM_DEBUG,
126 "..%N:%l FAILED they test equal before setting long\n"));
127 return 1;
130 ACE_DEBUG ((LM_DEBUG,
131 "..%N:%l Setting the long of the typecode generated dynamic any\n"));
132 dany->insert_long (l1);
133 analyzer.analyze (dany.in ());
135 ACE_DEBUG ((LM_DEBUG,
136 "..%N:%l Testing for equality with original dyanamic any\n"));
137 if (!(dany->equal (dany_boxed.in ())))
139 ACE_DEBUG ((LM_DEBUG,
140 "..%N:%l FAILED they test unequal after setting long\n"));
141 return 1;
144 ACE_DEBUG ((LM_DEBUG,
145 "..%N:%l Setting typecode dynamic any back to Null\n"));
146 dvc->set_to_null ();
147 analyzer.analyze (dany.in ());
149 ACE_DEBUG ((LM_DEBUG,
150 "..%N:%l Setting the original dynamic any to Null object\n"));
151 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany_boxed.in ());
152 if (!dvc)
154 ACE_DEBUG ((LM_DEBUG,
155 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
156 return 1;
158 dvc->set_to_null ();
159 analyzer.analyze (dany_boxed.in ());
161 ACE_DEBUG ((LM_DEBUG,
162 "..%N:%l Testing for equality with typecode dyanamic any\n"));
163 if (!(dany->equal (dany_boxed.in ())))
165 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal!\n"));
166 return 1;
169 ACE_DEBUG ((LM_DEBUG,
170 "..%N:%l Converting from Null dynamic any back to any\n"));
171 CORBA::Any_var myAny_var (dany_boxed->to_any ());
173 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from this any\n"));
174 myBoxedLongExtracted=
175 reinterpret_cast<DynValue_Test::BoxedLong *> (9);
176 if (!(myAny_var.in () >>= myBoxedLongExtracted))
178 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
179 return 1;
181 if (reinterpret_cast<DynValue_Test::BoxedLong *> (9)
182 == myBoxedLongExtracted)
184 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
185 return 1;
187 if (myBoxedLongExtracted)
189 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED non-Null pointer extracted\n"));
190 return 1;
193 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting the dynamic any to VALUE object\n"));
194 dvc->set_to_value ();
195 analyzer.analyze (dany_boxed.in ());
197 ACE_DEBUG ((LM_DEBUG,
198 "..%N:%l Resetting Typecode dynamic any from original any\n"));
199 dany->from_any (myAny);
200 analyzer.analyze (dany.in ());
202 ACE_DEBUG ((LM_DEBUG,
203 "..%N:%l Testing for equality with original dyanamic any\n"));
204 if (!(dany->equal (dany_boxed.in ())))
206 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal!\n"));
207 return 1;
210 ACE_DEBUG ((LM_DEBUG,
211 "..%N:%l Converting from dynamic any back to any\n"));
212 myAny_var = dany_boxed->to_any ();
214 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from this any\n"));
215 myBoxedLongExtracted=
216 reinterpret_cast<DynValue_Test::BoxedLong *> (9);
217 if (!(myAny_var.in () >>= myBoxedLongExtracted))
219 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
220 return 1;
222 if (!myBoxedLongExtracted)
224 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED Null pointer extracted\n"));
225 return 1;
227 if (reinterpret_cast<DynValue_Test::BoxedLong *> (9)
228 == myBoxedLongExtracted)
230 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
231 return 1;
233 ACE_DEBUG ((LM_DEBUG,
234 "..%N:%l checking value, long is %d\n",
235 myBoxedLongExtracted->_value () ));
236 if (l1 != myBoxedLongExtracted->_value ())
238 ACE_DEBUG ((LM_DEBUG,
239 "..%N:%l FAILED should have been %d\n", l1));
240 return 1;
243 ACE_DEBUG ((LM_DEBUG,
244 "..%N:%l Attempting to get_long from dynamic any\n"));
245 CORBA::Long myLongExtracted = dany_boxed->get_long ();
246 ACE_DEBUG ((LM_DEBUG,
247 "..%N:%l checking value, long is %d\n",
248 myLongExtracted ));
249 if (l1 != myLongExtracted)
251 ACE_DEBUG ((LM_DEBUG,
252 "..%N:%l FAILED should have been %d\n", l1));
253 return 1;
256 ////////////////////////////////////////////
257 // DynValue_Test::NestedValue
258 ////////////////////////////////////////////
260 const CORBA::Short s1= -17;
261 const CORBA::Short s2= -23;
263 ACE_DEBUG ((LM_DEBUG,
264 "\n%N:%l Creating DynValue_Test::NestedValue\n"));
265 DynValue_Test::NestedValue *p_myNestedValue =0;
266 ACE_NEW_THROW_EX (
267 p_myNestedValue,
268 NestedValue_impl(s1, s2),
269 CORBA::NO_MEMORY ());
270 DynValue_Test::NestedValue_var myNestedValue (p_myNestedValue);
271 ACE_DEBUG ((LM_DEBUG,
272 "..%N:%l checking value, shorts are %hd, %hd\n",
273 myNestedValue->Nested_s1 (),
274 myNestedValue->Nested_s2 () ));
275 if (s1 != myNestedValue->Nested_s1 () ||
276 s2 != myNestedValue->Nested_s2 ())
278 ACE_DEBUG ((LM_DEBUG,
279 "..%N:%l FAILED should have been %hd, %hd\n",
280 s1, s2));
281 return 1;
284 ACE_DEBUG ((LM_DEBUG, "..%N:%l Inserting into an any\n"));
285 myAny <<= myNestedValue.in ();
287 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from an any\n"));
288 DynValue_Test::NestedValue::_ptr_type
289 myNestedValueExtracted =
290 reinterpret_cast<DynValue_Test::NestedValue::_ptr_type> (9);
291 if (!(myAny >>= myNestedValueExtracted))
293 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
294 return 1;
296 if (!myNestedValueExtracted)
298 ACE_DEBUG ((LM_DEBUG,
299 "..%N:%l FAILED Null pointer extracted\n"));
300 return 1;
302 if (reinterpret_cast<DynValue_Test::NestedValue::_ptr_type> (9)
303 == myNestedValueExtracted)
305 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
306 return 1;
308 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking value, shorts are %hd, %hd\n",
309 myNestedValueExtracted->Nested_s1 (),
310 myNestedValueExtracted->Nested_s2 ()));
311 if (s1 != myNestedValueExtracted->Nested_s1 () ||
312 s2 != myNestedValueExtracted->Nested_s2 () )
314 ACE_DEBUG ((LM_DEBUG,
315 "..%N:%l FAILED should have been %hd, %hd\n", s1, s2));
316 return 1;
319 ACE_DEBUG ((LM_DEBUG, "..%N:%l Creating dynamic any from any\n"));
320 DynamicAny::DynAny_var dany_nested = analyzer.DynAny (myAny);
321 analyzer.analyze (dany_nested.in ());
323 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing dynamic any for non-Null\n"));
324 dvc = dynamic_cast<DynamicAny::DynValueCommon *>
325 (dany_nested.in ());
326 if (!dvc)
328 ACE_DEBUG ((LM_DEBUG,
329 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
330 return 1;
332 if (dvc->is_null ())
334 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED this dynamic any is Null!\n"));
335 return 1;
338 ACE_DEBUG ((LM_DEBUG,
339 "..%N:%l Creating dynamic any from IDL generated typecode\n"));
340 dany = analyzer.DynAny (DynValue_Test::_tc_NestedValue);
341 analyzer.analyze (dany.in ());
343 ACE_DEBUG ((LM_DEBUG,
344 "..%N:%l Testing typecode generated dynamic any for Null\n"));
345 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany.in ());
346 if (!dvc)
348 ACE_DEBUG ((LM_DEBUG,
349 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon\n"));
350 return 1;
352 if (!(dvc->is_null ()))
354 ACE_DEBUG ((LM_DEBUG,
355 "..%N:%l FAILED this dynamic any has a value!\n"));
356 return 1;
359 ACE_DEBUG ((LM_DEBUG,
360 "..%N:%l Testing for inequality with original dyanamic any\n"));
361 if (dany->equal (dany_nested.in ()))
363 ACE_DEBUG ((LM_DEBUG,
364 "..%N:%l FAILED they test equal before setting shorts\n"));
365 return 1;
368 ACE_DEBUG ((LM_DEBUG,
369 "..%N:%l Setting to value and test for inequality with original dyanamic any\n"));
370 dvc->set_to_value ();
371 analyzer.analyze (dany.in ());
372 if (dany->equal (dany_nested.in ()))
374 ACE_DEBUG ((LM_DEBUG,
375 "..%N:%l FAILED they test equal before setting shorts\n"));
376 return 1;
379 ACE_DEBUG ((LM_DEBUG,
380 "..%N:%l Setting the shorts of the typecode generated dynamic any\n"));
381 dany->rewind ();
382 dany->insert_short (s1);
383 if (!(dany->next ()))
385 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED to move on to second short\n"));
386 return 1;
388 dany->insert_short (s2);
389 analyzer.analyze (dany.in ());
391 ACE_DEBUG ((LM_DEBUG,
392 "..%N:%l Testing for equality with original dyanamic any\n"));
393 if (!(dany->equal (dany_nested.in ())))
395 ACE_DEBUG ((LM_DEBUG,
396 "..%N:%l FAILED they test unequal after setting shorts\n"));
397 return 1;
400 ACE_DEBUG ((LM_DEBUG,
401 "..%N:%l Setting typecode dynamic any back to Null\n"));
402 dvc->set_to_null ();
403 analyzer.analyze (dany.in ());
405 ACE_DEBUG ((LM_DEBUG,
406 "..%N:%l Setting the original dynamic any to Null object\n"));
407 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany_nested.in ());
408 if (!dvc)
410 ACE_DEBUG ((LM_DEBUG,
411 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
412 return 1;
414 dvc->set_to_null ();
415 analyzer.analyze (dany_nested.in ());
417 ACE_DEBUG ((LM_DEBUG,
418 "..%N:%l Testing for equality with typecode dyanamic any\n"));
419 if (!(dany->equal (dany_nested.in ())))
421 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal!\n"));
422 return 1;
425 ACE_DEBUG ((LM_DEBUG,
426 "..%N:%l Converting from Null dynamic any back to any\n"));
427 myAny_var = dany_nested->to_any ();
429 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from this any\n"));
430 myNestedValueExtracted=
431 reinterpret_cast<DynValue_Test::NestedValue::_ptr_type> (9);
432 if (!(myAny_var.in () >>= myNestedValueExtracted))
434 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
435 return 1;
437 if (reinterpret_cast<DynValue_Test::NestedValue::_ptr_type> (9)
438 == myNestedValueExtracted)
440 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
441 return 1;
443 if (myNestedValueExtracted)
445 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED non-Null pointer extracted\n"));
446 return 1;
449 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting the dynamic any to VALUE object\n"));
450 dvc->set_to_value ();
451 analyzer.analyze (dany_nested.in ());
453 ACE_DEBUG ((LM_DEBUG,
454 "..%N:%l Resetting Typecode dynamic any from original any\n"));
455 dany->from_any (myAny);
456 analyzer.analyze (dany.in ());
458 ACE_DEBUG ((LM_DEBUG,
459 "..%N:%l Testing for equality with original dyanamic any\n"));
460 if (!(dany->equal (dany_nested.in ())))
462 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal!\n"));
463 return 1;
466 ACE_DEBUG ((LM_DEBUG,
467 "..%N:%l Converting from dynamic any back to any\n"));
468 myAny_var = dany_nested->to_any ();
470 ACE_DEBUG ((LM_DEBUG,
471 "..%N:%l Attempting to extract from this any (without factory)\n"));
472 myNestedValueExtracted=
473 reinterpret_cast<DynValue_Test::NestedValue::_ptr_type> (9);
474 if (myAny_var.in () >>= myNestedValueExtracted)
476 ACE_DEBUG ((LM_DEBUG,
477 "..%N:%l FAILED the extraction occurred without factory\n"));
478 return 1;
481 ACE_DEBUG ((LM_DEBUG,
482 "..%N:%l Attempting to get_val from dynamic any (without factory)\n"));
485 myNestedValueExtracted=
486 dynamic_cast<DynValue_Test::NestedValue*> (
487 dany_nested->get_val ());
488 if (myNestedValueExtracted)
490 ACE_DEBUG ((LM_DEBUG,
491 "..%N:%l FAILED get_val successful without factory\n"));
492 return 1;
495 catch (const CORBA::MARSHAL &)
497 // Expected with no factory registered
500 CORBA::ValueFactoryBase *vf= 0;
501 ACE_NEW_THROW_EX (vf, NestedValue_Factory, CORBA::NO_MEMORY ());
502 analyzer.register_factory (vf);
504 ACE_DEBUG ((LM_DEBUG,
505 "..%N:%l Extracting from this any (now with factory)\n"));
506 if (!(myAny_var.in () >>= myNestedValueExtracted))
508 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED the extraction\n"));
509 return 1;
511 if (!myNestedValueExtracted)
513 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED Null pointer extracted\n"));
514 return 1;
516 if (reinterpret_cast<DynValue_Test::NestedValue::_ptr_type> (9)
517 == myNestedValueExtracted)
519 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
520 return 1;
522 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking value, shorts are %hd, %hd\n",
523 myNestedValueExtracted->Nested_s1 (),
524 myNestedValueExtracted->Nested_s2 ()));
525 if (s1 != myNestedValueExtracted->Nested_s1 () ||
526 s2 != myNestedValueExtracted->Nested_s2 () )
528 ACE_DEBUG ((LM_DEBUG,
529 "..%N:%l FAILED should have been %hd, %hd\n", s1, s2));
530 return 1;
533 ACE_DEBUG ((LM_DEBUG,
534 "..%N:%l Attempting to get_val from dynamic any (now with factory)\n"));
535 myNestedValueExtracted=
536 dynamic_cast<DynValue_Test::NestedValue*> (
537 dany_nested->get_val ());
538 if (!myNestedValueExtracted)
540 ACE_DEBUG ((LM_DEBUG,
541 "..%N:%l FAILED get_val unsuccessful even with factory\n"));
542 return 1;
544 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking value, shorts are %hd, %hd\n",
545 myNestedValueExtracted->Nested_s1 (),
546 myNestedValueExtracted->Nested_s2 ()));
547 if (s1 != myNestedValueExtracted->Nested_s1 () ||
548 s2 != myNestedValueExtracted->Nested_s2 () )
550 ACE_DEBUG ((LM_DEBUG,
551 "..%N:%l FAILED should have been %hd, %hd\n", s1, s2));
552 return 1;
554 myNestedValueExtracted->_remove_ref ();
556 ////////////////////////////////////////////
557 // DynValue_Test::NullValue
558 ////////////////////////////////////////////
560 ACE_DEBUG ((LM_DEBUG, "\n%N:%l Creating DynValue_Test::NullValue\n"));
561 DynValue_Test::NullValue *p_myNullValue =0;
562 ACE_NEW_THROW_EX (p_myNullValue, NullValue_impl, CORBA::NO_MEMORY ());
563 DynValue_Test::NullValue_var myNullValue (p_myNullValue);
565 ACE_DEBUG ((LM_DEBUG, "..%N:%l Inserting into an any\n"));
566 myAny <<= myNullValue.in ();
568 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from an any\n"));
569 DynValue_Test::NullValue::_ptr_type myNullValueExtracted=
570 reinterpret_cast<DynValue_Test::NullValue::_ptr_type> (9);
571 if (!(myAny >>= myNullValueExtracted))
573 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
574 return 1;
576 if (!myNullValueExtracted)
578 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED Null pointer extracted\n"));
579 return 1;
581 if (reinterpret_cast<DynValue_Test::NullValue::_ptr_type> (9)
582 == myNullValueExtracted)
584 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
585 return 1;
588 ACE_DEBUG ((LM_DEBUG, "..%N:%l Creating dynamic any from any\n"));
589 DynamicAny::DynAny_var dany_null (analyzer.DynAny (myAny));
590 analyzer.analyze (dany_null.in ());
592 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing dynamic any for non-Null\n"));
593 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany_null.in ());
594 if (!dvc)
596 ACE_DEBUG ((LM_DEBUG,
597 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
598 return 1;
600 if (dvc->is_null ())
602 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED this dynamic any is Null!\n"));
603 return 1;
606 ACE_DEBUG ((LM_DEBUG,
607 "..%N:%l Creating dynamic any from IDL generated typecode\n"));
608 dany = analyzer.DynAny (DynValue_Test::_tc_NullValue);
609 analyzer.analyze (dany.in ());
611 ACE_DEBUG ((LM_DEBUG,
612 "..%N:%l Testing typecode generated dynamic any for Null\n"));
613 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany.in ());
614 if (!dvc)
616 ACE_DEBUG ((LM_DEBUG,
617 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
618 return 1;
620 if (!(dvc->is_null ()))
622 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED this dynamic any has a value!\n"));
623 return 1;
626 ACE_DEBUG ((LM_DEBUG,
627 "..%N:%l Testing for inequality with original dyanamic any\n"));
628 if (dany->equal (dany_null.in ()))
630 ACE_DEBUG ((LM_DEBUG,
631 "..%N:%l FAILED they test equal before setting to a value\n"));
632 return 1;
635 ACE_DEBUG ((LM_DEBUG,
636 "..%N:%l Setting to value and test for equality with original dyanamic any\n"));
637 dvc->set_to_value ();
638 analyzer.analyze (dany.in ());
639 if (!(dany->equal (dany_null.in ())))
641 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal\n"));
642 return 1;
645 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting typecode dynamic any back to Null\n"));
646 dvc->set_to_null ();
647 analyzer.analyze (dany.in ());
649 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting the original dynamic any to Null object\n"));
650 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany_null.in ());
651 if (!dvc)
653 ACE_DEBUG ((LM_DEBUG,
654 "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon\n"));
655 return 1;
657 dvc->set_to_null ();
658 analyzer.analyze (dany_null.in ());
660 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing for equality with typecode dyanamic any\n"));
661 if (!(dany->equal (dany_null.in ())))
663 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal!\n"));
664 return 1;
667 ACE_DEBUG ((LM_DEBUG, "..%N:%l Converting from Null dynamic any back to any\n"));
668 myAny_var= dany_null->to_any ();
670 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from this any\n"));
671 myNullValueExtracted= reinterpret_cast<DynValue_Test::NullValue::_ptr_type> (9);
672 if (!(myAny_var.in () >>= myNullValueExtracted))
674 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
675 return 1;
677 if (reinterpret_cast<DynValue_Test::NullValue::_ptr_type> (9)
678 == myNullValueExtracted)
680 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
681 return 1;
683 if (myNullValueExtracted)
685 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED non-Null pointer extracted\n"));
686 return 1;
689 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting the original dynamic any to VALUE object\n"));
690 dvc->set_to_value ();
691 analyzer.analyze (dany_null.in ());
693 ACE_DEBUG ((LM_DEBUG, "..%N:%l Resetting Typecode dynamic any from original any\n"));
694 dany->from_any (myAny);
695 analyzer.analyze (dany.in ());
697 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing for equality with original dyanamic any\n"));
698 if (!(dany->equal (dany_null.in ())))
700 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal!\n"));
701 return 1;
704 ACE_DEBUG ((LM_DEBUG, "..%N:%l Converting from dynamic any back to any\n"));
705 myAny_var = dany_null->to_any ();
707 ACE_DEBUG ((LM_DEBUG, "..%N:%l Attempting to extract from this any (without factory)\n"));
708 myNullValueExtracted= reinterpret_cast<DynValue_Test::NullValue::_ptr_type> (9);
709 if (myAny_var.in () >>= myNullValueExtracted)
711 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED the extraction occurred without factory\n"));
712 return 1;
715 ACE_DEBUG ((LM_DEBUG, "..%N:%l Attempting to get_val from dynamic any (without factory)\n"));
718 myNullValueExtracted= dynamic_cast<DynValue_Test::NullValue*> (dany_null->get_val ());
719 if (myNullValueExtracted)
721 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED get_val successful without factory\n"));
722 return 1;
725 catch (const CORBA::MARSHAL &)
727 // Expected with no factory registered
730 ACE_NEW_THROW_EX (vf, NullValue_Factory, CORBA::NO_MEMORY ());
731 analyzer.register_factory (vf);
733 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from this any (now with factory)\n"));
734 if (!(myAny_var.in () >>= myNullValueExtracted))
736 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED the extraction\n"));
737 return 1;
739 if (!myNullValueExtracted)
741 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED Null pointer extracted\n"));
742 return 1;
744 if (reinterpret_cast<DynValue_Test::NullValue::_ptr_type> (9) == myNullValueExtracted)
746 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
747 return 1;
750 ACE_DEBUG ((LM_DEBUG, "..%N:%l Attempting to get_val from dynamic any (now with factory)\n"));
751 myNullValueExtracted= dynamic_cast<DynValue_Test::NullValue*> (dany_null->get_val ());
752 if (!myNullValueExtracted)
754 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED get_val unsuccessful even with factory\n"));
755 return 1;
757 myNullValueExtracted->_remove_ref ();
759 ////////////////////////////////////////////
760 // DynValue_Test::Trunc
761 ////////////////////////////////////////////
763 const CORBA::Short us1= 12345;
764 const CORBA::Short us2= 321;
766 DynValue_Test::NullValue *p_myNullValue2 =0;
767 ACE_NEW_THROW_EX (p_myNullValue2, NullValue_impl, CORBA::NO_MEMORY ());
768 DynValue_Test::NullValue_var myNullValue2 (p_myNullValue2);
770 ACE_DEBUG ((LM_DEBUG, "\n%N:%l Creating DynValue_Test::Trunc\n"));
771 DynValue_Test::Trunc *p_myTrunc =0;
772 ACE_NEW_THROW_EX (
773 p_myTrunc,
774 Trunc_impl (
775 us1,
776 us2,
777 myBoxedLong.in (),
778 dynamic_cast<NestedValue_impl *> (myNestedValue.in ()),
779 dynamic_cast<NullValue_impl *> (myNullValue.in ()),
780 dynamic_cast<NullValue_impl *> (myNullValue.in ()),
781 dynamic_cast<NullValue_impl *> (myNullValue2.in ()) ),
782 CORBA::NO_MEMORY ());
783 DynValue_Test::Trunc_var myTrunc (p_myTrunc);
785 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking embedded values, "));
786 myTrunc->print ();
787 if (us1 != myTrunc.in ()->Base_us1 () ||
788 us2 != myTrunc.in ()->Base_us2 () ||
789 l1 != myTrunc.in ()->Trunc_bl()->_value () ||
790 s1 != myTrunc.in ()->Trunc_nested()->Nested_s1 () ||
791 s2 != myTrunc.in ()->Trunc_nested()->Nested_s2 () )
793 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED should have been %u, %u, %d and %d, %d\n", us1, us2, l1, s1, s2));
794 return 1;
797 ACE_DEBUG ((LM_DEBUG, "..%N:%l Inserting into an any\n"));
798 myAny <<= myTrunc.in ();
800 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from an any\n"));
801 DynValue_Test::Trunc::_ptr_type myTruncExtracted=
802 reinterpret_cast<DynValue_Test::Trunc::_ptr_type> (9);
803 if (!(myAny >>= myTruncExtracted))
805 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
806 return 1;
808 if (!myTruncExtracted)
810 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED Null pointer extracted\n"));
811 return 1;
813 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking embedded values, "));
814 myTruncExtracted->print ();
815 if (us1 != myTruncExtracted->Base_us1 () ||
816 us2 != myTruncExtracted->Base_us2 () ||
817 l1 != myTruncExtracted->Trunc_bl()->_value () ||
818 s1 != myTruncExtracted->Trunc_nested()->Nested_s1 () ||
819 s2 != myTruncExtracted->Trunc_nested()->Nested_s2 () )
821 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED should have been %u, %u, %d and %d, %d\n", us1, us2, l1, s1, s2));
822 return 1;
825 ACE_DEBUG ((LM_DEBUG, "..%N:%l Creating dynamic any from any\n"));
826 DynamicAny::DynAny_var dany_trunc (analyzer.DynAny (myAny));
827 analyzer.analyze (dany_trunc.in ());
829 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing dynamic any for non-Null\n"));
830 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany_trunc.in ());
831 if (!dvc)
833 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
834 return 1;
836 if (dvc->is_null ())
838 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED this dynamic any is Null!\n"));
839 return 1;
842 ACE_DEBUG ((LM_DEBUG, "..%N:%l Creating dynamic any from IDL generated typecode DynValue_Test::_tc_Trunc\n"));
843 dany = analyzer.DynAny (DynValue_Test::_tc_Trunc);
844 analyzer.analyze (dany.in ());
846 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing typecode generated dynamic any for Null\n"));
847 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany.in ());
848 if (!dvc)
850 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
851 return 1;
853 if (!(dvc->is_null ()))
855 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED this dynamic any has a value!\n"));
856 return 1;
859 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing for inequality with original dyanamic any\n"));
860 if (dany->equal (dany_trunc.in ()))
862 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test equal before setting shorts\n"));
863 return 1;
866 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting to value and testing for inequality with original dyanamic any\n"));
867 dvc->set_to_value ();
868 analyzer.analyze (dany.in ());
869 if (dany->equal (dany_trunc.in ()))
871 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test equal before setting members\n"));
872 return 1;
875 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting the members of the typecode generated dynamic any\n"));
876 dany->rewind ();
877 dany->insert_ushort (us1);
878 if (!(dany->next ()))
880 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED to move on to 2nd member\n"));
881 return 1;
883 dany->insert_ushort (us2);
884 if (!(dany->next ()))
886 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED to move on to 3rd member\n"));
887 return 1;
889 DynamicAny::DynValueCommon_var
890 dmem (dynamic_cast<DynamicAny::DynValueCommon *> (dany->current_component ()));
891 if (!dmem.in())
893 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain 3rd current_component ()\n"));
894 return 1;
896 dmem->set_to_value ();
897 dmem->insert_long (l1);
898 if (!(dany->next ()))
900 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED to move on to 4th member\n"));
901 return 1;
903 dmem= dynamic_cast<DynamicAny::DynValueCommon *> (dany->current_component ());
904 if (!dmem.in())
906 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain 4th current_component ()\n"));
907 return 1;
909 dmem->set_to_value ();
910 dmem->insert_val (myNestedValue.in ());
911 if (!(dany->next ()))
913 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED to move on to 5th member\n"));
914 return 1;
916 dmem= dynamic_cast<DynamicAny::DynValueCommon *> (dany->current_component ());
917 if (!dmem.in())
919 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain 5th current_component ()\n"));
920 return 1;
922 dmem->set_to_value ();
923 dmem->insert_val (myNullValue.in ());
924 if (!(dany->next ()))
926 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED to move on to 6th member\n"));
927 return 1;
929 dmem= dynamic_cast<DynamicAny::DynValueCommon *> (dany->current_component ());
930 if (!dmem.in())
932 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain 6th current_component ()\n"));
933 return 1;
935 dmem->set_to_value ();
936 dmem->insert_val (myNullValue.in ());
937 if (!(dany->next ()))
939 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED to move on to 7th member\n"));
940 return 1;
942 dmem= dynamic_cast<DynamicAny::DynValueCommon *> (dany->current_component ());
943 if (!dmem.in())
945 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain 7th current_component ()\n"));
946 return 1;
948 dmem->set_to_value ();
949 dmem->insert_val (myNullValue2.in ());
950 analyzer.analyze (dany.in ());
952 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing for equality with original dyanamic any\n"));
953 if (!(dany->equal (dany_trunc.in ())))
955 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal after setting members\n"));
956 return 1;
959 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting typecode dynamic any back to Null\n"));
960 dvc->set_to_null ();
961 analyzer.analyze (dany.in ());
963 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting the original dynamic any to Null object\n"));
964 dvc = dynamic_cast<DynamicAny::DynValueCommon *> (dany_trunc.in ());
965 if (!dvc)
967 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
968 return 1;
970 dvc->set_to_null ();
971 analyzer.analyze (dany_trunc.in ());
973 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing for equality with typecode dyanamic any\n"));
974 if (!(dany->equal (dany_trunc.in ())))
976 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal!\n"));
977 return 1;
980 ACE_DEBUG ((LM_DEBUG, "..%N:%l Converting from Null dynamic any back to any\n"));
981 myAny_var= dany_trunc->to_any ();
983 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from this any\n"));
984 myTruncExtracted= reinterpret_cast<DynValue_Test::Trunc::_ptr_type> (9);
985 if (!(myAny_var.in () >>= myTruncExtracted))
987 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
988 return 1;
990 if (reinterpret_cast<DynValue_Test::Trunc::_ptr_type> (9) == myTruncExtracted)
992 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
993 return 1;
995 if (myTruncExtracted)
997 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED non-Null pointer extracted\n"));
998 return 1;
1001 ACE_DEBUG ((LM_DEBUG, "..%N:%l Setting the dynamic any to VALUE object\n"));
1002 dvc->set_to_value ();
1003 analyzer.analyze (dany_trunc.in ());
1005 ACE_DEBUG ((LM_DEBUG, "..%N:%l Resetting Typecode dynamic any from original any\n"));
1006 dany->from_any (myAny);
1007 analyzer.analyze (dany.in ());
1009 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing for equality with original dyanamic any\n"));
1010 if (!(dany->equal (dany_trunc.in ())))
1012 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED they test unequal!\n"));
1013 return 1;
1016 ACE_DEBUG ((LM_DEBUG, "..%N:%l Converting from dynamic any back to any\n"));
1017 myAny_var = dany_trunc->to_any ();
1019 ACE_DEBUG ((LM_DEBUG, "..%N:%l Attempting to extract from this any (without factory)\n"));
1020 myTruncExtracted= reinterpret_cast<DynValue_Test::Trunc::_ptr_type> (9);
1021 if (myAny_var.in () >>= myTruncExtracted)
1023 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED the extraction occurred without factory\n"));
1024 return 1;
1027 ACE_DEBUG ((LM_DEBUG, "..%N:%l Attempting to get_val from dynamic any (without factory)\n"));
1030 myTruncExtracted= dynamic_cast<DynValue_Test::Trunc *> (dany_trunc->get_val ());
1031 if (myTruncExtracted)
1033 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED get_val successful without factory\n"));
1034 return 1;
1037 catch (const CORBA::MARSHAL &)
1039 // Expected with no factory registered
1042 ACE_NEW_THROW_EX (vf, Trunc_Factory, CORBA::NO_MEMORY ());
1043 analyzer.register_factory (vf);
1045 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from this any (now with factory)\n"));
1046 if (!(myAny_var.in () >>= myTruncExtracted))
1048 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
1049 return 1;
1051 if (!myTruncExtracted)
1053 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED Null pointer extracted\n"));
1054 return 1;
1056 if (reinterpret_cast<DynValue_Test::Trunc::_ptr_type> (9) == myTruncExtracted)
1058 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
1059 return 1;
1061 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking embedded values, "));
1062 myTruncExtracted->print ();
1063 if (us1 != myTruncExtracted->Base_us1 () ||
1064 us2 != myTruncExtracted->Base_us2 () ||
1065 l1 != myTruncExtracted->Trunc_bl()->_value () ||
1066 s1 != myTruncExtracted->Trunc_nested()->Nested_s1 () ||
1067 s2 != myTruncExtracted->Trunc_nested()->Nested_s2 () )
1069 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED should have been %u, %u, %d and %d, %d\n", us1, us2, l1, s1, s2));
1070 return 1;
1073 ACE_DEBUG ((LM_DEBUG, "..%N:%l Attempting to get_val from dynamic any (now with factory)\n"));
1074 myTruncExtracted= dynamic_cast<DynValue_Test::Trunc*> (dany_trunc->get_val ());
1075 if (!myTruncExtracted)
1077 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED get_val unsuccessful even with factory\n"));
1078 return 1;
1080 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking embedded values, "));
1081 myTruncExtracted->print ();
1082 if (us1 != myTruncExtracted->Base_us1 () ||
1083 us2 != myTruncExtracted->Base_us2 () ||
1084 l1 != myTruncExtracted->Trunc_bl()->_value () ||
1085 s1 != myTruncExtracted->Trunc_nested()->Nested_s1 () ||
1086 s2 != myTruncExtracted->Trunc_nested()->Nested_s2 () )
1088 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED should have been %u, %u, %d and %d, %d\n", us1, us2, l1, s1, s2));
1089 return 1;
1091 myTruncExtracted->_remove_ref ();
1093 ///////////////////////////////////////////////////
1094 // DynValue_Test::Trunc -> DynValue_Test::BaseValue
1095 ///////////////////////////////////////////////////
1097 ACE_DEBUG ((LM_DEBUG, "\n%N:%l Placing DynValue_Test::Trunc into DynValue_Test::BaseValue\n"));
1098 DynValue_Test::BaseValue::_ptr_type p_myBaseValue = myTrunc.in ();
1100 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking values, "));
1101 p_myBaseValue->print ();
1102 if (us1 != p_myBaseValue->Base_us1 () ||
1103 us2 != p_myBaseValue->Base_us2 () )
1105 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED should have been %u and %u\n", us1, us2));
1106 return 1;
1109 ACE_DEBUG ((LM_DEBUG, "..%N:%l Inserting into an any\n"));
1110 CORBA::Any myAny_trunc;
1111 myAny_trunc <<= p_myBaseValue;
1112 ACE_DEBUG ((LM_DEBUG, "..%N:%l any reports type %C\n", myAny_trunc._tao_get_typecode ()->id ()));
1113 myAny_trunc.type (DynValue_Test::_tc_BaseValue);
1114 ACE_DEBUG ((LM_DEBUG, "..%N:%l any NOW reports type %C\n", myAny_trunc._tao_get_typecode ()->id ()));
1116 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting BaseValue from an any\n"));
1117 DynValue_Test::BaseValue::_ptr_type myBaseExtracted=
1118 reinterpret_cast<DynValue_Test::BaseValue::_ptr_type> (9);
1119 if (!(myAny_trunc >>= myBaseExtracted))
1121 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
1122 return 1;
1124 if (!myBaseExtracted)
1126 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED Null pointer extracted\n"));
1127 return 1;
1129 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking embedded values, "));
1130 myBaseExtracted->print ();
1131 if (us1 != myBaseExtracted->Base_us1 () ||
1132 us2 != myBaseExtracted->Base_us2 () )
1134 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED should have been %u and %u\n", us1, us2));
1135 return 1;
1138 ACE_DEBUG ((LM_DEBUG, "..%N:%l Creating dynamic any from any\n"));
1139 DynamicAny::DynAny_var dany_base (analyzer.DynAny (myAny_trunc));
1140 analyzer.analyze (dany_base.in ());
1142 ACE_DEBUG ((LM_DEBUG, "..%N:%l Testing dynamic any for non-Null\n"));
1143 dvc= dynamic_cast<DynamicAny::DynValueCommon *> (dany_base.in ());
1144 if (!dvc)
1146 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILURE can not obtain DynamicAny::DynValueCommon *\n"));
1147 return 1;
1149 if (dvc->is_null ())
1151 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED this dynamic any is Null!\n"));
1152 return 1;
1155 ACE_DEBUG ((LM_DEBUG, "..%N:%l Converting from dynamic any back to any\n"));
1156 myAny_var = dany_base->to_any ();
1159 ACE_DEBUG ((LM_DEBUG, "..%N:%l Attempting to extract from this any (without factory)\n"));
1160 myBaseExtracted= reinterpret_cast<DynValue_Test::BaseValue::_ptr_type> (9);
1161 if (myAny_var.in () >>= myBaseExtracted)
1163 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED the extraction occurred without factory\n"));
1164 return 1;
1167 ACE_NEW_THROW_EX (vf, BaseValue_Factory, CORBA::NO_MEMORY ());
1168 analyzer.register_factory (vf);
1170 ACE_DEBUG ((LM_DEBUG, "..%N:%l Extracting from this any (now with factory)\n"));
1171 if (!(myAny_var.in () >>= myBaseExtracted))
1173 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED extraction\n"));
1174 return 1;
1176 if (!myBaseExtracted)
1178 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED Null pointer extracted\n"));
1179 return 1;
1181 if (reinterpret_cast<DynValue_Test::BaseValue::_ptr_type> (9) == myBaseExtracted)
1183 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED pointer NOT extracted\n"));
1184 return 1;
1186 ACE_DEBUG ((LM_DEBUG, "..%N:%l checking embedded values, "));
1187 myBaseExtracted->print ();
1188 if (us1 != myBaseExtracted->Base_us1 () ||
1189 us2 != myBaseExtracted->Base_us2 () )
1191 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED should have been %u, and %u\n", us1, us2));
1192 return 1;
1195 ACE_DEBUG ((LM_DEBUG, "..%N:%l Creating dynamic any from truncted any (no truncation allowed)\n"));
1198 DynamicAny::DynAny_var dany_base (analyzer.DynAny_NoTrunc (myAny_trunc));
1199 ACE_DEBUG ((LM_DEBUG, "..%N:%l FAILED, obtained Dynamic any\n"));
1200 analyzer.analyze (dany_base.in ());
1201 return 1;
1203 catch (const DynamicAny::MustTruncate &)
1205 ACE_DEBUG ((LM_DEBUG, "..%N:%l obtained MustTruncate as expected\n"));
1208 ACE_DEBUG ((LM_DEBUG, "\nAll tests passed\n"));
1210 catch (const CORBA::TRANSIENT &)
1212 ACE_DEBUG ((LM_INFO, "Transient\n"));
1214 catch (const CORBA::COMM_FAILURE &)
1216 ACE_DEBUG ((LM_INFO, "COMM_FAILURE\n"));
1218 catch (const CORBA::Exception & ex)
1220 ex._tao_print_exception ("Tests failed with CORBA exception:");
1221 return 1;
1223 catch (...)
1225 ACE_ERROR_RETURN ((LM_ERROR, "Test failed with NON-CORBA exception\n"), 1);
1228 return 0;