2 #include "tao/ORB_Core.h"
3 #include "tao/ORB_Table.h"
4 #include "tao/ORB_Core_Auto_Ptr.h"
5 // Force static build to load the DII_Arguments_Converter service.
6 #include "tao/DynamicInterface/DII_Arguments_Converter_Impl.h"
8 extern CORBA::Boolean debug
;
9 extern char TEST_STR
[];
10 extern CORBA::Long TEST_BASIC_VALUE
;
11 extern CORBA::Char TEST_SPECIAL_VALUE
;
12 extern CORBA::Short TEST_HOUR
;
13 extern CORBA::Short TEST_MINUTE
;
14 extern CORBA::Short TEST_SECOND
;
16 #define ERROR_COUNT(message) \
18 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)%s - failed error_count = %u\n"), \
19 message, error_count_)); \
22 // Implementation skeleton constructor
23 Test_Simple_Test_i::Test_Simple_Test_i ()
27 // Implementation skeleton destructor
28 Test_Simple_Test_i::~Test_Simple_Test_i ()
32 void Test_Simple_Test_i::test_method (
33 ::CORBA::ULong
& error_count
39 Hello::Hello (CORBA::ORB_ptr orb
,
41 : orb_ (CORBA::ORB::_duplicate (orb
))
48 Hello::test_basic_arg (
53 if (basic
!= TEST_BASIC_VALUE
)
54 ERROR_COUNT ("Hello::test_basic_arg")
60 Hello::test_unbounded_string_arg(const char* message
)
63 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_unbounded_string_arg ")
64 ACE_TEXT("got unbounded string: %s\n"),
66 if (ACE_OS::strncmp (message
, TEST_STR
, ACE_OS::strlen (TEST_STR
) != 0))
68 ERROR_COUNT ("Hello::test_unbounded_string_arg")
73 Hello::test_unbounded_string_arg_out(const char* message
, ::CORBA::String_out out_message
)
76 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_unbounded_string_arg_out ")
77 ACE_TEXT("got unbounded string: %s\n"),
79 if (ACE_OS::strncmp (message
, TEST_STR
, ACE_OS::strlen (TEST_STR
) != 0))
81 ERROR_COUNT ("Hello::test_unbounded_string_arg_out")
83 out_message
= CORBA::string_dup (message
);
88 Hello::test_bounded_string_arg(const char* message
)
91 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_bounded_string_arg ")
92 ACE_TEXT("got bounded string: %s\n"),
94 if (ACE_OS::strncmp (message
, TEST_STR
, ::Test::BOUNDED_STRING_SIZE
) != 0)
96 ERROR_COUNT ("Hello::test_bounded_string_arg")
102 Hello::test_fixed_array_arg(const ::Test::Fixed_Array message
)
104 for (unsigned i
= 0; i
< ::Test::FIX_ARRAY_SIZE
; i
++)
107 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_fixed_array_arg ")
108 ACE_TEXT("got fixed array: %d\n"),
110 if (message
[i
] != static_cast<CORBA::Long
> (i
+ 999))
111 ERROR_COUNT ("Hello::test_fixed_array_arg")
117 Hello::test_bounded_var_size_arg(const ::Test::Bounded_Var_Size_Arg
& message
)
120 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_bounded_var_size_arg ")
121 ACE_TEXT("got bounded var size arg\n")));
122 if (ACE_OS::strncmp (message
.get_buffer (), TEST_STR
, ::Test::BOUNDED_VAR_SIZE
) != 0)
123 ERROR_COUNT ("Hello::test_bounded_var_size_arg")
128 Hello::test_unbounded_var_size_arg(const ::Test::Unbounded_Var_Size_Arg
& message
)
131 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_unbounded_var_size_arg ")
132 ACE_TEXT("got unbounded var size arg.\n")));
133 if (ACE_OS::strncmp (message
.get_buffer (), TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0)
134 ERROR_COUNT ("Hello::test_unbounded_var_size_arg")
139 Hello::test_fixed_size_arg(const ::Test::TimeOfDay
& t
)
142 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_fixed_size_arg ")
143 ACE_TEXT("got timeofday: %d:%d:%d\n"),
144 t
.hour
, t
.minute
, t
.second
));
146 if (t
.hour
!= TEST_HOUR
147 || t
.minute
!= TEST_MINUTE
148 || t
.second
!= TEST_SECOND
)
149 ERROR_COUNT ("Hello::test_fixed_size_arg")
154 Hello::test_var_array_arg(const Test::Var_Array messages
)
156 for (CORBA::ULong i
= 0; i
!= ::Test::VAR_ARRAY_SIZE
; i
++)
159 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_var_array_arg ")
160 ACE_TEXT("messages[%d] = %s\n"), i
, messages
[i
].in ()));
161 if (ACE_OS::strncmp (messages
[i
].in (), TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0)
162 ERROR_COUNT ("Hello::test_var_array_arg")
168 Hello::test_special_basic_arg(CORBA::Char value
)
171 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_special_basic_arg ")
172 ACE_TEXT(" got special basic arg: %c\n"), value
));
173 if (value
!= TEST_SPECIAL_VALUE
)
174 ERROR_COUNT ("Hello::test_special_basic_arg")
178 void Hello::test_objref_arg (
179 ::Test::Simple_Test_ptr test
183 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_objref_arg\n")));
185 if (CORBA::is_nil (test
))
186 ERROR_COUNT ("Hello::test_objref_arg")
189 // Increment the error_count before calling test_method() and decrement
190 // the error_count when the server handling the test_method() call.
191 CORBA::ULong error_count
= 0;
193 test
->test_method (error_count
);
194 if (error_count
!= 0)
196 ERROR_COUNT ("Hello::test_objref_arg")
201 void Hello::test_object_arg (
202 ::CORBA::Object_ptr o
206 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_object_arg\n")));
207 ::Test::Simple_Test_var simple_test
= ::Test::Simple_Test::_narrow (o
);
209 CORBA::ULong error_count
= 0;
211 simple_test
->test_method (error_count
);
212 if (error_count
!= 0)
214 ERROR_COUNT ("Hello::test_object_arg")
218 void Hello::test_args_1 (
219 ::CORBA::Object_ptr arg1
,
221 ::Test::Simple_Test_ptr arg3
225 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_args_1\n")));
226 ::Test::Simple_Test_var simple_test
= ::Test::Simple_Test::_narrow (arg1
);
228 CORBA::ULong error_count
= 0;
230 simple_test
->test_method (error_count
);
232 arg3
->test_method (error_count
);
234 if (error_count
!= 0)
236 ERROR_COUNT ("Hello::test_args_1")
239 if (arg2
!= TEST_SPECIAL_VALUE
)
240 ERROR_COUNT ("Hello::test_args_1")
243 void Hello::test_args_2 (
245 const ::Test::Fixed_Array arg2
,
246 const ::Test::TimeOfDay
& arg3
250 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_args_2\n")));
251 if (ACE_OS::strncmp (arg1
, TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0 )
252 ERROR_COUNT ("Hello::test_args_2")
254 for (unsigned i
= 0; i
< ::Test::FIX_ARRAY_SIZE
; i
++)
256 if (arg2
[i
] != static_cast<CORBA::Long
> (i
+ 999))
257 ERROR_COUNT ("Hello::test_args_2")
260 if (arg3
.hour
!= TEST_HOUR
261 || arg3
.minute
!= TEST_MINUTE
262 || arg3
.second
!= TEST_SECOND
)
263 ERROR_COUNT ("Hello::test_args_2")
266 void Hello::test_args_3 (
268 const ::Test::Bounded_Var_Size_Arg
& arg2
,
269 const ::Test::Unbounded_Var_Size_Arg
& arg3
,
270 const ::Test::Var_Array arg4
274 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_args_3\n")));
275 if (ACE_OS::strncmp (arg1
, TEST_STR
, ACE_OS::strlen (arg1
)) != 0)
276 ERROR_COUNT ("Hello::test_args_3")
277 if (ACE_OS::strncmp (arg2
.get_buffer (), TEST_STR
, ::Test::BOUNDED_VAR_SIZE
) != 0)
278 ERROR_COUNT ("Hello::test_args_3")
279 if (ACE_OS::strncmp (arg3
.get_buffer (), TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0)
280 ERROR_COUNT ("Hello::test_args_3")
281 for (CORBA::ULong i
= 0; i
!= ::Test::VAR_ARRAY_SIZE
; i
++)
283 if (ACE_OS::strncmp (arg4
[i
].in (), TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0)
284 ERROR_COUNT ("Hello::test_args_3")
292 ACE_DEBUG ((LM_DEBUG
,
293 "(%P|%t) Upcall in process ..\n"));
295 if (ACE_Thread::self () == this->thr_id_
)
297 if (this->orb_
->orb_core ()->optimize_collocation_objects () &&
298 this->orb_
->orb_core ()->use_global_collocation ())
300 ACE_ERROR ((LM_ERROR
,
301 "(%P|%t) ERROR: A remote call has been made "
305 else if (this->orb_
->orb_core ()->optimize_collocation_objects () &&
306 this->orb_
->orb_core ()->use_global_collocation () == 0)
308 TAO::ORB_Table
* const orb_table
=
309 TAO::ORB_Table::instance ();
311 TAO_ORB_Core_Auto_Ptr
tmp (orb_table
->find ("server_orb"));
312 if (tmp
.get () == nullptr)
314 // We are running on a single ORB and this is an error.
315 ACE_ERROR ((LM_ERROR
,
316 "(%P|%t) ERROR: A remote call has been made "
317 " with a single ORB "
324 return CORBA::string_dup ("Hello there!");
328 Hello::test_unbounded_string (
334 char *retstr
= CORBA::string_dup (s1
);
335 s3
= CORBA::string_dup (s1
);
336 char *tmp
= CORBA::string_alloc (2*ACE_OS::strlen (s2
));
337 ACE_OS::sprintf (tmp
, "%s%s", s2
, s2
);
338 CORBA::string_free (s2
);
346 // Give the client thread time to return from the collocated
347 // call to this method before shutting down the ORB. We sleep
348 // to avoid BAD_INV_ORDER exceptions on fast dual processor machines.
350 this->orb_
->shutdown (false);
353 CORBA::ULong
Hello::error_count () const