diff options
Diffstat (limited to 'TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_i.cpp')
-rw-r--r-- | TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_i.cpp | 283 |
1 files changed, 283 insertions, 0 deletions
diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_i.cpp b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_i.cpp new file mode 100644 index 00000000000..73105ff1713 --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_i.cpp @@ -0,0 +1,283 @@ +// $Id$ +#include "Foo_B_i.h" +#include "AppShutdown.h" +#include "TestAppExceptionC.h" +#include "ace/OS.h" +#include "ace/SString.h" + + +Foo_B_i::Foo_B_i() +: error_count_ (0) +{ + for (unsigned i = 0; i < 16; i++) + { + op_count_[i] = 0; + } +} + + +Foo_B_i::~Foo_B_i() +{ +} + + +void +Foo_B_i::op1(ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[0] ++; +} + + +void +Foo_B_i::op2(CORBA::Long value ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[1] ++; + this->in_long_[1].push_back (value); +} + + +CORBA::Long +Foo_B_i::op3(CORBA::Long value ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[2] ++; + this->in_long_[2].push_back (value); + return value; +} + + +void +Foo_B_i::op4(CORBA::Long value ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[3] ++; + this->in_long_[3].push_back (value); +} + + +void +Foo_B_i::op5(ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC((CORBA::SystemException, FooException)) +{ + this->op_count_[4] ++; + ACE_THROW (FooException()); +} + + +CORBA::Boolean +Foo_B_i::op6(const TimeOfDay& t, + char*& message + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[5] ++; + char buf [20]; + ACE_OS::sprintf (buf, "%s %d:%d:%d", message, t.hour, t.minute, t.second); + message = CORBA::string_dup (buf); + + return 1; +} + + +void +Foo_B_i::op7(Callback_ptr cb + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC((CORBA::SystemException, + FooException)) +{ + this->op_count_[6] ++; + + if (CORBA::is_nil (cb)) + { + error_count_ ++; + ACE_THROW (FooException ()); + } + else + { + cb->test_method (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } +} + + +void +Foo_B_i::test_unbounded_string_arg(const char* message + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[7] ++; + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_unbounded_string_arg ") + // ACE_TEXT("got unbounded string %s\n"), + // message)); + this->in_string_[7].push_back (message); +} + + +void +Foo_B_i::test_bounded_string_arg(const char* message + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[8] ++; + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_bounded_string_arg ") + // ACE_TEXT("got bounded string %s\n"), + // message)); + this->in_string_[8].push_back (message); +} + + +void +Foo_B_i::test_fixed_array_arg(const Fixed_Array message + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[9] ++; + + for (unsigned i = 0; i < 19; i++) + { + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_fixed_array_arg ") + // ACE_TEXT("got fixed array[i] = %d\n"), + // i, message[i])); + + if (message[i] != message[i + 1] -1) + { + error_count_ ++; + break; + } + } + + + this->in_long_[9].push_back (message[0]); +} + + +void +Foo_B_i::test_bounded_var_size_arg(const Bounded_Var_Size& message + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[10] ++; + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_bounded_var_size_arg ") + // ACE_TEXT("got var array chars %s\n"), + // message.get_buffer ())); + this->in_string_[10].push_back (message.get_buffer ()); +} + + +void +Foo_B_i::test_unbounded_var_size_arg(const Unbounded_Var_Size& message + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[11] ++; + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_unbounded_var_size_arg ") + // ACE_TEXT("got var array chars %s\n"), + // message.get_buffer ())); + this->in_string_[11].push_back (message.get_buffer ()); +} + + +void +Foo_B_i::test_fixed_size_arg(const TimeOfDay& t + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_UNUSED_ARG(t); + + this->op_count_[12] ++; + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_fixed_size_arg ") + // ACE_TEXT("got timeofday %d:%d:%d\n"), + // t.hour, t.minute, t.second)); +} + + +void +Foo_B_i::test_var_array_arg(const Var_Array messages + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[13] ++; + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_var_array_arg ") + // ACE_TEXT(" %s \n"), messages[0].in ())); + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_var_array_arg ") + // ACE_TEXT(" %s \n"), messages[1].in ())); + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_var_array_arg ") + // ACE_TEXT(" %s \n"), messages[2].in ())); + unsigned cur_client_id = 0; + + for (unsigned i = 0 ; i < 3; i ++) + { + unsigned client_id = 0; + unsigned str_id = 0; + char test_str[20]; + sscanf (messages[i].in (), "%d %s %d", &client_id, test_str, &str_id); + + if (str_id != i) + { + error_count_ ++; + } + + if (i == 0) + { + cur_client_id = client_id; + } + else if (client_id != cur_client_id) + { + error_count_ ++; + } + } + this->in_string_[13].push_back (messages[0].in ()); +} + + +void +Foo_B_i::test_special_basic_arg(CORBA::Boolean value, + CORBA::Long client_id + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->op_count_[14] ++; + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_special_basic_arg ") + // ACE_TEXT(" got special basic arg: %d \n"), value)); + + CORBA::Boolean expected_special_value = client_id % 2; + if (expected_special_value != value) + { + error_count_ ++; + } +} + + +void +Foo_B_i::test_objref_arg(Callback_ptr cb + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_UNUSED_ARG(cb); + this->op_count_[15] ++; + //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t)Foo_B_i::test_objref_arg ") + // ACE_TEXT(" got callback object. \n"))); +} + + +void +Foo_B_i::done(ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + TheAppShutdown->client_done(); +} + + +void +Foo_B_i::gather_stats (Foo_B_Statistics& stats) +{ + for (unsigned i = 0; i < 16; i++) + { + stats.actual (i+1, this->op_count_[i]); + stats.actual (i+1, this->in_string_[i]); + stats.actual (i+1, this->in_long_[i]); + stats.servant_error_count (this->error_count_); + } +} |