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 (void)
27 // Implementation skeleton destructor
28 Test_Simple_Test_i::~Test_Simple_Test_i (void)
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 (
52 if (basic
!= TEST_BASIC_VALUE
)
53 ERROR_COUNT ("Hello::test_basic_arg")
57 Hello::test_unbounded_string_arg(const char* message
)
60 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_unbounded_string_arg ")
61 ACE_TEXT("got unbounded string: %s\n"),
63 if (ACE_OS::strncmp (message
, TEST_STR
, ACE_OS::strlen (TEST_STR
) != 0))
65 ERROR_COUNT ("Hello::test_unbounded_string_arg")
71 Hello::test_bounded_string_arg(const char* message
)
74 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_bounded_string_arg ")
75 ACE_TEXT("got bounded string: %s\n"),
77 if (ACE_OS::strncmp (message
, TEST_STR
, ::Test::BOUNDED_STRING_SIZE
) != 0)
79 ERROR_COUNT ("Hello::test_bounded_string_arg")
85 Hello::test_fixed_array_arg(const ::Test::Fixed_Array message
)
87 for (unsigned i
= 0; i
< ::Test::FIX_ARRAY_SIZE
; i
++)
90 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_fixed_array_arg ")
91 ACE_TEXT("got fixed array: %d\n"),
93 if (message
[i
] != static_cast<CORBA::Long
> (i
+ 999))
94 ERROR_COUNT ("Hello::test_fixed_array_arg")
100 Hello::test_bounded_var_size_arg(const ::Test::Bounded_Var_Size_Arg
& message
)
103 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_bounded_var_size_arg ")
104 ACE_TEXT("got bounded var size arg\n")));
105 if (ACE_OS::strncmp (message
.get_buffer (), TEST_STR
, ::Test::BOUNDED_VAR_SIZE
) != 0)
106 ERROR_COUNT ("Hello::test_bounded_var_size_arg")
111 Hello::test_unbounded_var_size_arg(const ::Test::Unbounded_Var_Size_Arg
& message
)
114 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_unbounded_var_size_arg ")
115 ACE_TEXT("got unbounded var size arg.\n")));
116 if (ACE_OS::strncmp (message
.get_buffer (), TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0)
117 ERROR_COUNT ("Hello::test_unbounded_var_size_arg")
122 Hello::test_fixed_size_arg(const ::Test::TimeOfDay
& t
)
125 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_fixed_size_arg ")
126 ACE_TEXT("got timeofday: %d:%d:%d\n"),
127 t
.hour
, t
.minute
, t
.second
));
129 if (t
.hour
!= TEST_HOUR
130 || t
.minute
!= TEST_MINUTE
131 || t
.second
!= TEST_SECOND
)
132 ERROR_COUNT ("Hello::test_fixed_size_arg")
137 Hello::test_var_array_arg(const Test::Var_Array messages
)
139 for (CORBA::ULong i
= 0; i
!= ::Test::VAR_ARRAY_SIZE
; i
++)
142 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_var_array_arg ")
143 ACE_TEXT("messages[%d] = %s\n"), i
, messages
[i
].in ()));
144 if (ACE_OS::strncmp (messages
[i
].in (), TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0)
145 ERROR_COUNT ("Hello::test_var_array_arg")
151 Hello::test_special_basic_arg(CORBA::Char value
)
154 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_special_basic_arg ")
155 ACE_TEXT(" got special basic arg: %c\n"), value
));
156 if (value
!= TEST_SPECIAL_VALUE
)
157 ERROR_COUNT ("Hello::test_special_basic_arg")
161 void Hello::test_objref_arg (
162 ::Test::Simple_Test_ptr test
166 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_objref_arg\n")));
168 if (CORBA::is_nil (test
))
169 ERROR_COUNT ("Hello::test_objref_arg")
172 // Increment the error_count before calling test_method() and decrement
173 // the error_count when the server handling the test_method() call.
174 CORBA::ULong error_count
= 0;
176 test
->test_method (error_count
);
177 if (error_count
!= 0)
179 ERROR_COUNT ("Hello::test_objref_arg")
184 void Hello::test_object_arg (
185 ::CORBA::Object_ptr o
189 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_object_arg\n")));
190 ::Test::Simple_Test_var simple_test
= ::Test::Simple_Test::_narrow (o
);
192 CORBA::ULong error_count
= 0;
194 simple_test
->test_method (error_count
);
195 if (error_count
!= 0)
197 ERROR_COUNT ("Hello::test_object_arg")
201 void Hello::test_args_1 (
202 ::CORBA::Object_ptr arg1
,
204 ::Test::Simple_Test_ptr arg3
208 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_args_1\n")));
209 ::Test::Simple_Test_var simple_test
= ::Test::Simple_Test::_narrow (arg1
);
211 CORBA::ULong error_count
= 0;
213 simple_test
->test_method (error_count
);
215 arg3
->test_method (error_count
);
217 if (error_count
!= 0)
219 ERROR_COUNT ("Hello::test_args_1")
222 if (arg2
!= TEST_SPECIAL_VALUE
)
223 ERROR_COUNT ("Hello::test_args_1")
226 void Hello::test_args_2 (
228 const ::Test::Fixed_Array arg2
,
229 const ::Test::TimeOfDay
& arg3
233 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_args_2\n")));
234 if (ACE_OS::strncmp (arg1
, TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0 )
235 ERROR_COUNT ("Hello::test_args_2")
237 for (unsigned i
= 0; i
< ::Test::FIX_ARRAY_SIZE
; i
++)
239 if (arg2
[i
] != static_cast<CORBA::Long
> (i
+ 999))
240 ERROR_COUNT ("Hello::test_args_2")
243 if (arg3
.hour
!= TEST_HOUR
244 || arg3
.minute
!= TEST_MINUTE
245 || arg3
.second
!= TEST_SECOND
)
246 ERROR_COUNT ("Hello::test_args_2")
249 void Hello::test_args_3 (
251 const ::Test::Bounded_Var_Size_Arg
& arg2
,
252 const ::Test::Unbounded_Var_Size_Arg
& arg3
,
253 const ::Test::Var_Array arg4
257 ACE_DEBUG((LM_DEBUG
, ACE_TEXT("(%P|%t)Hello::test_args_3\n")));
258 if (ACE_OS::strncmp (arg1
, TEST_STR
, ACE_OS::strlen (arg1
)) != 0)
259 ERROR_COUNT ("Hello::test_args_3")
260 if (ACE_OS::strncmp (arg2
.get_buffer (), TEST_STR
, ::Test::BOUNDED_VAR_SIZE
) != 0)
261 ERROR_COUNT ("Hello::test_args_3")
262 if (ACE_OS::strncmp (arg3
.get_buffer (), TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0)
263 ERROR_COUNT ("Hello::test_args_3")
264 for (CORBA::ULong i
= 0; i
!= ::Test::VAR_ARRAY_SIZE
; i
++)
266 if (ACE_OS::strncmp (arg4
[i
].in (), TEST_STR
, ACE_OS::strlen (TEST_STR
)) != 0)
267 ERROR_COUNT ("Hello::test_args_3")
272 Hello::get_string (void)
275 ACE_DEBUG ((LM_DEBUG
,
276 "(%P|%t) Upcall in process ..\n"));
278 if (ACE_Thread::self () == this->thr_id_
)
280 if (this->orb_
->orb_core ()->optimize_collocation_objects () &&
281 this->orb_
->orb_core ()->use_global_collocation ())
283 ACE_ERROR ((LM_ERROR
,
284 "(%P|%t) ERROR: A remote call has been made "
288 else if (this->orb_
->orb_core ()->optimize_collocation_objects () &&
289 this->orb_
->orb_core ()->use_global_collocation () == 0)
291 TAO::ORB_Table
* const orb_table
=
292 TAO::ORB_Table::instance ();
294 TAO_ORB_Core_Auto_Ptr
tmp (orb_table
->find ("server_orb"));
297 // We are running on a single ORB and this is an error.
298 ACE_ERROR ((LM_ERROR
,
299 "(%P|%t) ERROR: A remote call has been made "
300 " with a single ORB "
307 return CORBA::string_dup ("Hello there!");
311 Hello::test_unbounded_string (
317 char *retstr
= CORBA::string_dup (s1
);
318 s3
= CORBA::string_dup (s1
);
319 char *tmp
= CORBA::string_alloc (2*ACE_OS::strlen (s2
));
320 ACE_OS::sprintf (tmp
, "%s%s", s2
, s2
);
321 CORBA::string_free (s2
);
327 Hello::shutdown (void)
329 // Give the client thread time to return from the collocated
330 // call to this method before shutting down the ORB. We sleep
331 // to avoid BAD_INV_ORDER exceptions on fast dual processor machines.
333 this->orb_
->shutdown (0);
336 CORBA::ULong
Hello::error_count () const