2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
7 parse_args (int argc
, ACE_TCHAR
*argv
[])
9 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
12 while ((c
= get_opts ()) != -1)
16 ior
= get_opts
.optarg
;
21 ACE_ERROR_RETURN ((LM_ERROR
,
28 // Indicates successful parsing of the command line
33 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
38 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - test started.\n"));
41 CORBA::ORB_init (argc
, argv
);
43 if (parse_args (argc
, argv
) != 0)
46 // Create and register factories.
48 OBV_AnyTest::VA_init
*va_factory
= 0;
49 ACE_NEW_RETURN (va_factory
,
51 1); // supplied by mapping
53 orb
->register_value_factory (va_factory
->tao_repository_id (),
55 va_factory
->_remove_ref (); // release ownership
58 OBV_AnyTest::VB_init
*vb_factory
= 0;
59 ACE_NEW_RETURN (vb_factory
,
61 1); // supplied by mapping
63 orb
->register_value_factory (vb_factory
->tao_repository_id (),
65 vb_factory
->_remove_ref (); // release ownership
69 OBV_AnyTest::VA_var va1
, va2
;
70 ACE_NEW_RETURN (va1
.inout (), OBV_OBV_AnyTest::VA
, 1);
71 ACE_NEW_RETURN (va2
.inout (), OBV_OBV_AnyTest::VA
, 1);
73 const CORBA::ULong magic
= 3145;
80 // Test both copying and non-copying version of operator<<=
83 OBV_AnyTest::VA
*pva
= va2
._retn();
86 OBV_AnyTest::VA
* dst
= 0;
88 if (!(a1
>>= dst
) || dst
->id () != magic
)
90 ACE_ERROR_RETURN ((LM_DEBUG
,
91 "(%P|%t) client - test failed.\n"),
95 if (!(a2
>>= dst
) || dst
->id () != magic
)
97 ACE_ERROR_RETURN ((LM_DEBUG
,
98 "(%P|%t) client - test failed.\n"),
103 // It should be possible to extract to a base type
104 OBV_AnyTest::VB_var vb1
;
105 ACE_NEW_RETURN (vb1
.inout (), OBV_OBV_AnyTest::VB
, 1);
109 CORBA::ValueBase_var target
;
110 if (!(a1
>>= CORBA::Any::to_value(target
.out())))
112 ACE_ERROR_RETURN ((LM_DEBUG
,
113 "(%P|%t) client - base extraction test failed.\n"),
116 dst
= OBV_AnyTest::VA::_downcast(target
.in());
117 if (dst
== 0 || dst
->id() != magic
)
119 ACE_ERROR_RETURN ((LM_DEBUG
,
120 "(%P|%t) client - base extraction test failed.\n"),
125 // Now do remote test
127 CORBA::Object_var tmp
=
128 orb
->string_to_object(ior
);
130 OBV_AnyTest::Test_var test
=
131 OBV_AnyTest::Test::_narrow(tmp
.in ());
133 if (CORBA::is_nil (test
.in ()))
135 ACE_ERROR_RETURN ((LM_DEBUG
,
136 "Nil OBV_AnyTest::Test reference <%s>\n",
143 CORBA::Any_var result
= test
->get_something (
146 if (!(result
.inout () >>= dst
) || dst
->id () != magic
)
148 ACE_ERROR_RETURN ((LM_DEBUG
,
149 "(%P|%t) client - test 1 failed.\n"),
154 OBV_AnyTest::VB
* dst_vb
= 0;
155 result
= test
->get_something (
158 if (!(result
.inout () >>= dst_vb
) || dst_vb
->id () != magic
)
160 ACE_ERROR_RETURN ((LM_DEBUG
,
161 "(%P|%t) client - test 2 failed.\n"),
165 // STEP 3. A sanity check demonstrating base-type pointer to
166 // derived type allowed.
167 OBV_AnyTest::VA_var dst_va
= test
->get_vb();
168 if (dst_va
->id () != magic
)
170 ACE_ERROR_RETURN ((LM_DEBUG
,
171 "(%P|%t) client - test 3 failed.\n"),
175 #if !defined (TAO_HAS_OPTIMIZED_VALUETYPE_MARSHALING)
176 // @@ There's still a problem here with the optimized valuetype
177 // marshaling and passing values through anys. The problem is
178 // that while the Any in fact contains all of the required type
179 // information, there is no way to share that with the
180 // ValueBase::_tao_unmarshal_pre() which needs the type info in
181 // order to select the appropriate value factory.
183 // STEP 4. get a VB, but extract to a VA*.
184 result
= test
->get_something (
187 if (!(result
.inout () >>= CORBA::Any::to_value(target
.out())))
189 ACE_ERROR_RETURN ((LM_DEBUG
,
190 "(%P|%t) client - test 4 extraction failed.\n"),
193 dst_va
= OBV_AnyTest::VA::_downcast(target
._retn());
194 if (dst_va
== 0 || dst_va
->id() != magic
)
196 ACE_ERROR_RETURN ((LM_DEBUG
,
197 "(%P|%t) client - test 4 failed.\n"),
200 #endif /* TAO_HAS_OPTIMIZED_VALUETYPE_MARSHALING */
206 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - test finished.\n"));
208 catch (const CORBA::Exception
& ex
)
210 ex
._tao_print_exception ("Exception caught in client:");