2 #include "tao/DynamicInterface/Request.h" /* This must come first for
4 #include "Client_Task.h"
6 #include "tao/Object.h"
8 char TEST_STR
[] = "This is a DII collocation test.";
9 CORBA::Long TEST_BASIC_VALUE
= 12345;
10 CORBA::Char TEST_SPECIAL_VALUE
= 'x';
11 CORBA::Short TEST_HOUR
= 12;
12 CORBA::Short TEST_MINUTE
= 59;
13 CORBA::Short TEST_SECOND
= 59;
15 Client_Task::Client_Task (const ACE_TCHAR
*ior
,
16 const ACE_TCHAR
*simple_test_ior
,
18 ACE_Thread_Manager
*thr_mgr
)
19 : ACE_Task_Base (thr_mgr
)
21 , simple_test_input_ (simple_test_ior
)
22 , corb_ (CORBA::ORB::_duplicate (corb
))
28 Client_Task::svc (void)
32 CORBA::Object_var obj
=
33 this->corb_
->string_to_object (input_
);
35 if (CORBA::is_nil (obj
.in ()))
37 ACE_ERROR_RETURN ((LM_DEBUG
,
38 "Nil Test::Hello reference <%s>\n",
43 CORBA::Object_var simple_test_obj
=
44 this->corb_
->string_to_object (simple_test_input_
);
46 if (CORBA::is_nil (simple_test_obj
.in ()))
48 ACE_ERROR_RETURN ((LM_DEBUG
,
49 "Nil Test::Simple_Test reference <%s>\n",
54 Test::Simple_Test_var simple_test
55 = Test::Simple_Test::_narrow (simple_test_obj
.in ());
57 CORBA::Request_var
req (obj
->_request ("test_basic_arg"));
58 req
->add_in_arg ("basic") <<= TEST_BASIC_VALUE
;
62 req
= obj
->_request ("test_unbounded_string_arg");
64 req
->add_in_arg ("ub_string") <<= TEST_STR
;
68 req
= obj
->_request ("test_bounded_string_arg");
70 ACE_CString
bs (TEST_STR
);
71 bs
= bs
.substr (0, ::Test::BOUNDED_STRING_SIZE
);
73 req
->add_in_arg ("bd_string")
74 <<= CORBA::Any::from_string (bs
.c_str (), ::Test::BOUNDED_STRING_SIZE
);
78 req
= obj
->_request ("test_fixed_array_arg");
80 ::Test::Fixed_Array fixed_array
;
82 for (CORBA::ULong m
= 0 ; m
< ::Test::FIX_ARRAY_SIZE
; m
++)
84 fixed_array
[m
] = m
+ 999;
87 req
->add_in_arg ("fixed_array") <<= ::Test::Fixed_Array_forany (fixed_array
);
91 req
= obj
->_request ("test_var_array_arg");
93 ::Test::Var_Array var_array
;
95 for (CORBA::ULong i
= 0; i
< ::Test::VAR_ARRAY_SIZE
; ++i
)
97 var_array
[i
] = CORBA::string_dup(TEST_STR
);
100 req
->add_in_arg ("var_array") <<= var_array
;
104 req
= obj
->_request ("test_bounded_var_size_arg");
106 ACE_CString
bvs (TEST_STR
);
107 bvs
= bvs
.substr (0, ::Test::BOUNDED_VAR_SIZE
);
109 ::Test::Bounded_Var_Size_Arg
* bd_var_size
110 = new ::Test::Bounded_Var_Size_Arg();
112 bd_var_size
->replace (::Test::BOUNDED_VAR_SIZE
,
113 const_cast <CORBA::Char
*> (bvs
.c_str ()));
115 req
->add_in_arg ("bd_var_size") <<= bd_var_size
;
119 req
= obj
->_request ("test_unbounded_var_size_arg");
121 ::Test::Unbounded_Var_Size_Arg
* ub_var_size
122 = new ::Test::Unbounded_Var_Size_Arg();
123 ub_var_size
->replace (ub_var_size
->maximum (),
124 ACE_OS::strlen (TEST_STR
),
127 req
->add_in_arg ("ub_var_size") <<= ub_var_size
;
131 req
= obj
->_request ("test_fixed_size_arg");
135 t
.minute
= TEST_MINUTE
;
136 t
.second
= TEST_SECOND
;
138 req
->add_in_arg ("fixed_size") <<= t
;
142 req
= obj
->_request ("test_special_basic_arg");
144 req
->add_in_arg ("special") <<= CORBA::Any::from_char (TEST_SPECIAL_VALUE
);
148 req
= obj
->_request ("test_object_arg");
150 req
->add_in_arg ("object") <<= simple_test_obj
.in ();
154 req
= obj
->_request ("test_objref_arg");
156 req
->add_in_arg ("objref") <<= simple_test
.in ();
160 req
= obj
->_request ("test_args_1");
162 req
->add_in_arg ("arg1") <<= simple_test_obj
.in ();
163 req
->add_in_arg ("arg2") <<= CORBA::Any::from_char (TEST_SPECIAL_VALUE
);
164 req
->add_in_arg ("arg3") <<= simple_test
.in ();
168 req
= obj
->_request ("test_args_2");
170 req
->add_in_arg ("arg1") <<= TEST_STR
;
171 req
->add_in_arg ("arg2") <<= ::Test::Fixed_Array_forany (fixed_array
);
172 req
->add_in_arg ("arg3") <<= t
;
176 req
= obj
->_request ("test_args_3");
179 = new ::Test::Bounded_Var_Size_Arg();
180 bd_var_size
->replace (::Test::BOUNDED_VAR_SIZE
,
181 const_cast <CORBA::Char
*> (bvs
.c_str ()));
184 = new ::Test::Unbounded_Var_Size_Arg();
185 ub_var_size
->replace (ub_var_size
->maximum (),
186 ACE_OS::strlen (TEST_STR
),
189 for (CORBA::ULong j
= 0; j
< ::Test::VAR_ARRAY_SIZE
; ++j
)
191 var_array
[j
] = CORBA::string_dup(TEST_STR
);
194 req
->add_in_arg ("arg1")
195 <<= CORBA::Any::from_string (bs
.c_str (), ::Test::BOUNDED_STRING_SIZE
);
197 req
->add_in_arg ("arg2") <<= bd_var_size
;
198 req
->add_in_arg ("arg3") <<= ub_var_size
;
199 req
->add_in_arg ("arg4") <<= var_array
;
203 req
= obj
->_request ("shutdown");
209 catch (const CORBA::Exception
& ex
)
212 ex
._tao_print_exception ("Exception caught:");
218 ACE_ERROR ((LM_ERROR
, "(%P|%t)Client_Task::svc - caught unknown exception\n"));
227 Client_Task::error_count () const