diff options
Diffstat (limited to 'TAO/tests/CSD_Strategy_Tests/TP_Foo_B')
14 files changed, 1224 insertions, 0 deletions
diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/CSD_TP_Foo_B_Export.h b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/CSD_TP_Foo_B_Export.h new file mode 100644 index 00000000000..c6e2f4cd967 --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/CSD_TP_Foo_B_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl -s CSD_TP_Foo_B +// ------------------------------ +#ifndef CSD_TP_FOO_B_EXPORT_H +#define CSD_TP_FOO_B_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CSD_TP_FOO_B_HAS_DLL) +# define CSD_TP_FOO_B_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CSD_TP_FOO_B_HAS_DLL */ + +#if !defined (CSD_TP_FOO_B_HAS_DLL) +# define CSD_TP_FOO_B_HAS_DLL 1 +#endif /* ! CSD_TP_FOO_B_HAS_DLL */ + +#if defined (CSD_TP_FOO_B_HAS_DLL) && (CSD_TP_FOO_B_HAS_DLL == 1) +# if defined (CSD_TP_FOO_B_BUILD_DLL) +# define CSD_TP_Foo_B_Export ACE_Proper_Export_Flag +# define CSD_TP_FOO_B_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CSD_TP_FOO_B_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CSD_TP_FOO_B_BUILD_DLL */ +# define CSD_TP_Foo_B_Export ACE_Proper_Import_Flag +# define CSD_TP_FOO_B_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CSD_TP_FOO_B_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CSD_TP_FOO_B_BUILD_DLL */ +#else /* CSD_TP_FOO_B_HAS_DLL == 1 */ +# define CSD_TP_Foo_B_Export +# define CSD_TP_FOO_B_SINGLETON_DECLARATION(T) +# define CSD_TP_FOO_B_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CSD_TP_FOO_B_HAS_DLL == 1 */ + +// Set CSD_TP_FOO_B_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CSD_TP_FOO_B_NTRACE) +# if (ACE_NTRACE == 1) +# define CSD_TP_FOO_B_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CSD_TP_FOO_B_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CSD_TP_FOO_B_NTRACE */ + +#if (CSD_TP_FOO_B_NTRACE == 1) +# define CSD_TP_FOO_B_TRACE(X) +#else /* (CSD_TP_FOO_B_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CSD_TP_FOO_B_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CSD_TP_FOO_B_NTRACE == 1) */ + +#endif /* CSD_TP_FOO_B_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback.idl b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback.idl new file mode 100644 index 00000000000..49be42260cb --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback.idl @@ -0,0 +1,11 @@ +// $Id$ +#ifndef CALLBACK_IDL +#define CALLBACK_IDL + +interface Callback +{ + void test_method(); +}; + + +#endif diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback_i.cpp b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback_i.cpp new file mode 100644 index 00000000000..d4158bf5324 --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback_i.cpp @@ -0,0 +1,28 @@ +// $Id$ +#include "Callback_i.h" + +Callback_i::Callback_i() + : num_callbacks_(0) +{ +} + + +Callback_i::~Callback_i () +{ +} + + +void +Callback_i::test_method(ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC((CORBA::SystemException)) +{ + this->num_callbacks_ ++; +} + + +void +Callback_i::gather_stats(Foo_B_Statistics& stats) +{ + stats.actual_callbacks(this->num_callbacks_.value ()); +} + diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback_i.h b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback_i.h new file mode 100644 index 00000000000..8404d72e382 --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Callback_i.h @@ -0,0 +1,32 @@ +// $Id$ +#ifndef CALLBACK_I_H +#define CALLBACK_I_H + +#include "CSD_TP_Foo_B_Export.h" +#include "CallbackS.h" +#include "Foo_B_Statistics.h" + + +class CSD_TP_Foo_B_Export Callback_i + : public virtual POA_Callback, + public virtual PortableServer::RefCountServantBase +{ + public: + + Callback_i(); + + virtual ~Callback_i(); + + virtual void test_method(ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + void gather_stats(Foo_B_Statistics& stats); + + + private: + + ACE_Atomic_Op <ACE_SYNCH_MUTEX, unsigned> num_callbacks_; +}; + + +#endif diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B.idl b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B.idl new file mode 100644 index 00000000000..2b6b7382fab --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B.idl @@ -0,0 +1,70 @@ +// $Id$ +#ifndef FOO_B_IDL +#define FOO_B_IDL + +#include "FooException.idl" +#include "Callback.idl" + + +typedef sequence<char, 32> Bounded_Var_Size; +typedef sequence<char> Unbounded_Var_Size; +typedef long Fixed_Array[20]; +typedef string Var_Array [3]; + +struct TimeOfDay { + short hour; // 0 - 23 + short minute; // 0 - 59 + short second; // 0 - 59 +}; +interface Foo_B +{ + /// void return-type, no arguments + void op1(); + + /// void return-type, 1 "in" argument + void op2(in long value); + + /// long return-type, 1 "in" argument + long op3(in long value); + + /// one-way version of op2 + oneway void op4(in long value); + + /// Operation that always raises an exception. + void op5() raises (FooException); + + /// Test fixed size "in" argument and the "inout" parameter. + boolean op6(in TimeOfDay t, + inout string message); + + /// Callback test. + + /// Pass the callback object and the server invoke operation on + /// the callback object reference. + void op7 (in Callback cb) raises (FooException); + + oneway void test_unbounded_string_arg(in string message); + + oneway void test_bounded_string_arg(in string<20> message); + + oneway void test_fixed_array_arg(in Fixed_Array message); + + oneway void test_var_array_arg(in Var_Array messages); + + oneway void test_bounded_var_size_arg(in Bounded_Var_Size message); + + oneway void test_unbounded_var_size_arg(in Unbounded_Var_Size message); + + oneway void test_fixed_size_arg (in TimeOfDay t); + + oneway void test_special_basic_arg(in boolean value, in long client_id); + + oneway void test_objref_arg (in Callback cb); + + /// Client calls this last. The last client to claim that it is + /// done will cause the server to shutdown. + void done(); +}; + + +#endif diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_ClientEngine.cpp b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_ClientEngine.cpp new file mode 100644 index 00000000000..2769f5ad9cf --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_ClientEngine.cpp @@ -0,0 +1,206 @@ +// $Id$ +#include "Foo_B_ClientEngine.h" +#include "Callback_i.h" +#include "Foo_B_Statistics.h" +#include "TestAppExceptionC.h" +#include "AppHelper.h" +#include "ace/Log_Msg.h" +#include "ace/OS.h" + +const char* ONEWAY_ARG_TEST_STR = "TEST"; + +Foo_B_ClientEngine::Foo_B_ClientEngine(Foo_B_ptr obj, + Callback_ptr callback, + unsigned client_id, + bool collocated) + : obj_(Foo_B::_duplicate(obj)), + callback_(Callback::_duplicate(callback)), + client_id_(client_id), + collocated_(collocated) +{ +} + + +Foo_B_ClientEngine::~Foo_B_ClientEngine() +{ +} + + +bool +Foo_B_ClientEngine::execute(ACE_ENV_SINGLE_ARG_DECL) +{ + // Make sure the connection is established before making + // remote invocations. + if (AppHelper::validate_connection (this->obj_.in ()) == false) + { + ACE_ERROR((LM_ERROR, "(%P|%t)Foo_A_ClientEngine::execute " \ + "client %d connect failed.\n", this->client_id_)); + return false; + } + + // Verify the return values and return the results. + bool check_validity = true; + + this->obj_->op1(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + this->obj_->op2(this->client_id_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Long value = this->obj_->op3(this->client_id_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (value != static_cast<CORBA::Long>(this->client_id_)) + { + check_validity = false; + } + + for (CORBA::ULong j = 1; j <= 5; j++) + { + this->obj_->op4(495 + (this->client_id_ * 5) + j ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + } + + bool caught_exception = false; + + ACE_TRY + { + this->obj_->op5(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (FooException, ex) + { + // Expected + caught_exception = true; + } + ACE_ENDTRY; + + if (! caught_exception) + { + check_validity = false; + } + + TimeOfDay t; + t.hour = 12; + t.minute = 30; + t.second = 10; + + char test_str [20]; + ACE_OS::sprintf (test_str, "%d %s", this->client_id_, ONEWAY_ARG_TEST_STR); + + char buffer [20]; + + // Two-Way calls with "inout" and fixed size "in" arguments. + CORBA::String_var message = CORBA::string_dup(test_str); + + CORBA::Boolean result = this->obj_->op6( t, message.inout() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + ACE_UNUSED_ARG(result); + + ACE_OS::sprintf (buffer, "%d %s %d:%d:%d", this->client_id_, ONEWAY_ARG_TEST_STR, + t.hour, t.minute, t.second); + + if (ACE_OS::strncmp (message.in (), buffer, ACE_OS::strlen (buffer)) != 0) + { + check_validity = false; + } + + // Callback test. + this->obj_->op7 (this->callback_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + // One-Way calls with various arguments. + CORBA::String_var ub_string = CORBA::string_dup( test_str ); + this->obj_->test_unbounded_string_arg (ub_string.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::String_var bd_string = CORBA::string_dup( test_str ); + this->obj_->test_bounded_string_arg (bd_string.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + Fixed_Array fixed_array; + + for (CORBA::ULong m = 0 ; m < 20; m ++) + { + fixed_array[m] = this->client_id_ + m; + } + + this->obj_->test_fixed_array_arg (fixed_array ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + Var_Array var_array; + + for (CORBA::ULong k = 0; k < 3; k++) + { + ACE_OS::sprintf (buffer, "%d %s %d", + this->client_id_, ONEWAY_ARG_TEST_STR, k); + var_array[k] = CORBA::string_dup(buffer); + } + + this->obj_->test_var_array_arg (var_array ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + Bounded_Var_Size_var bd_var_size_string = new Bounded_Var_Size(); + + bd_var_size_string->replace (bd_var_size_string->maximum (), + ACE_OS::strlen (test_str) + 1, + test_str); + this->obj_->test_bounded_var_size_arg (bd_var_size_string.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + Unbounded_Var_Size_var ub_var_size_string = new Unbounded_Var_Size(100); + ub_var_size_string->replace (ub_var_size_string->maximum (), + ACE_OS::strlen (test_str) + 1, + test_str); + this->obj_->test_unbounded_var_size_arg (ub_var_size_string.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + this->obj_->test_fixed_size_arg (t ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + this->obj_->test_special_basic_arg (this->client_id_ % 2, + this->client_id_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + this->obj_->test_objref_arg (this->callback_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + this->obj_->done(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + return check_validity; +} + + +void +Foo_B_ClientEngine::expected_results(Foo_B_Statistics& stats) +{ + stats.expected(1, 1, Foo_B_Statistics::FOO_B_STAT_NONE); + stats.expected(2, 1, Foo_B_Statistics::FOO_B_STAT_LONG); + stats.expected(3, 1, Foo_B_Statistics::FOO_B_STAT_LONG); + stats.expected(4, 5, Foo_B_Statistics::FOO_B_STAT_LONG); + stats.expected(5, 1, Foo_B_Statistics::FOO_B_STAT_NONE); + stats.expected(6, 1, Foo_B_Statistics::FOO_B_STAT_NONE); + stats.expected(7, 1, Foo_B_Statistics::FOO_B_STAT_NONE); + stats.expected(8, 1, Foo_B_Statistics::FOO_B_STAT_STRING); + stats.expected(9, 1, Foo_B_Statistics::FOO_B_STAT_STRING); + stats.expected(10, 1, Foo_B_Statistics::FOO_B_STAT_LONG); + stats.expected(11, 1, Foo_B_Statistics::FOO_B_STAT_STRING); + stats.expected(12, 1, Foo_B_Statistics::FOO_B_STAT_STRING); + stats.expected(13, 1, Foo_B_Statistics::FOO_B_STAT_NONE); + stats.expected(14, 1, Foo_B_Statistics::FOO_B_STAT_STRING); + stats.expected(15, 1, Foo_B_Statistics::FOO_B_STAT_NONE); + stats.expected(16, 1, Foo_B_Statistics::FOO_B_STAT_NONE); + stats.expected_callbacks (1); +} + + +unsigned +Foo_B_ClientEngine::expected_callbacks () +{ + return 1; +} diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_ClientEngine.h b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_ClientEngine.h new file mode 100644 index 00000000000..a6e8e51667b --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_ClientEngine.h @@ -0,0 +1,47 @@ +// This may look like C, but it's really -*- C++ -*- + +//============================================================================= +/** + * @file Foo_B_ClientEngine.h + * + * $Id$ + * + * @author Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef FOO_B_CLIENT_ENGINE_H +#define FOO_B_CLIENT_ENGINE_H + +#include "CSD_TP_Foo_B_Export.h" +#include "ClientEngine.h" +#include "Foo_BC.h" + +class Foo_B_Statistics; +class Callback_i; + +class CSD_TP_Foo_B_Export Foo_B_ClientEngine : public ClientEngine +{ + public: + + Foo_B_ClientEngine(Foo_B_ptr obj, + Callback_ptr callback, + unsigned client_id = 0, + bool collocated = false); + + virtual ~Foo_B_ClientEngine(); + + virtual bool execute(ACE_ENV_SINGLE_ARG_DECL); + + static void expected_results(Foo_B_Statistics& stats); + static unsigned expected_callbacks (); + + private: + + Foo_B_var obj_; + Callback_var callback_; + unsigned client_id_; + bool collocated_; +}; + +#endif diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_SimpleClientEngine.cpp b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_SimpleClientEngine.cpp new file mode 100644 index 00000000000..ec2d97c6bdf --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_SimpleClientEngine.cpp @@ -0,0 +1,83 @@ +// $Id$ +#include "Foo_B_SimpleClientEngine.h" +#include "Callback_i.h" +#include "Foo_B_Statistics.h" +#include "TestAppExceptionC.h" +#include "AppHelper.h" +#include "ace/Log_Msg.h" +#include "ace/OS.h" + +extern const char* ONEWAY_ARG_TEST_STR; + +Foo_B_SimpleClientEngine::Foo_B_SimpleClientEngine(Foo_B_ptr obj, + Callback_ptr callback, + unsigned client_id, + bool collocated) + : obj_(Foo_B::_duplicate(obj)), + callback_(Callback::_duplicate(callback)), + client_id_(client_id), + collocated_(collocated) +{ +} + + +Foo_B_SimpleClientEngine::~Foo_B_SimpleClientEngine() +{ +} + + +bool +Foo_B_SimpleClientEngine::execute(ACE_ENV_SINGLE_ARG_DECL) +{ + // Make sure the connection is established before making + // remote invocations. + if (AppHelper::validate_connection (this->obj_.in ()) == false) + { + ACE_ERROR((LM_ERROR, "(%P|%t)Foo_A_SimpleClientEngine::execute " \ + "client %d connect failed.\n", this->client_id_)); + return false; + } + + // Verify the return values and return the results. + bool check_validity = true; + + // Callback test. + ACE_TRY + { + if (CORBA::is_nil(this->callback_.in())) + { + ACE_ERROR((LM_ERROR, "(%P|%t)Foo_A_SimpleClientEngine::execute " \ + "The callback_ objref is nil before op7() call!\n")); + } + + this->obj_->op7 (this->callback_.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (FooException, ex) + { + ACE_ERROR((LM_ERROR, "(%P|%t)Foo_A_SimpleClientEngine::execute " \ + "FooException raised by op7() call.\n")); + check_validity = false; + } + ACE_ENDTRY; + + // Tell the servant that this client is done. + this->obj_->done(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + return check_validity; +} + + +void +Foo_B_SimpleClientEngine::expected_results(Foo_B_Statistics& stats) +{ + stats.expected(7, 1, Foo_B_Statistics::FOO_B_STAT_NONE); +} + + +unsigned +Foo_B_SimpleClientEngine::expected_callbacks () +{ + return 1; +} diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_SimpleClientEngine.h b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_SimpleClientEngine.h new file mode 100644 index 00000000000..38ef6a09bcf --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_SimpleClientEngine.h @@ -0,0 +1,47 @@ +// This may look like C, but it's really -*- C++ -*- + +//============================================================================= +/** + * @file Foo_B_SimpleClientEngine.h + * + * $Id$ + * + * @author Tim Bradley <bradley_t@ociweb.com> + */ +//============================================================================= + +#ifndef FOO_B_SIMPLE_CLIENT_ENGINE_H +#define FOO_B_SIMPLE_CLIENT_ENGINE_H + +#include "CSD_TP_Foo_B_Export.h" +#include "ClientEngine.h" +#include "Foo_BC.h" + +class Foo_B_Statistics; +class Callback_i; + +class CSD_TP_Foo_B_Export Foo_B_SimpleClientEngine : public ClientEngine +{ + public: + + Foo_B_SimpleClientEngine(Foo_B_ptr obj, + Callback_ptr callback, + unsigned client_id = 0, + bool collocated = false); + + virtual ~Foo_B_SimpleClientEngine(); + + virtual bool execute(ACE_ENV_SINGLE_ARG_DECL); + + static void expected_results(Foo_B_Statistics& stats); + static unsigned expected_callbacks (); + + private: + + Foo_B_var obj_; + Callback_var callback_; + unsigned client_id_; + bool collocated_; +}; + +#endif diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_Statistics.cpp b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_Statistics.cpp new file mode 100644 index 00000000000..d282c058b8e --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_Statistics.cpp @@ -0,0 +1,187 @@ +// $Id$ +#include "Foo_B_Statistics.h" +#include "Foo_B_ClientEngine.h" + +extern const char* ONEWAY_ARG_TEST_STR; +extern CORBA::Boolean special_value; + +Foo_B_Statistics::Foo_B_Statistics(unsigned num_remote_clients, + unsigned num_collcated_clients) +: num_clients_ (num_remote_clients + num_collcated_clients), + num_collcated_clients_ (num_collcated_clients), + expected_callbacks_ (0), + actual_callbacks_ (0), + servant_error_count_ (0) +{ + for (unsigned i = 0; i < 16; i++) + { + this->expected_op_count_[i] = 0; + this->actual_op_count_[i] = 0; + } +} + + +Foo_B_Statistics::~Foo_B_Statistics() +{ +} + + +void +Foo_B_Statistics::expected(unsigned op_num, unsigned count, In_Value_Type type) +{ + this->expected_op_count_[op_num-1] = count * this->num_clients_; + this->expected_in_value_type_[op_num-1] = type; +} + + +void +Foo_B_Statistics::actual(unsigned op_num, unsigned count) +{ + this->actual_op_count_[op_num-1] += count; +} + + +void +Foo_B_Statistics::actual(unsigned op_num, LongVector lv) +{ + unsigned sz = lv.size(); + for (unsigned i = 0; i < sz; i++) + { + this->actual_in_long_[op_num-1].push_back (lv[i]); + } +} + + +void +Foo_B_Statistics::actual(unsigned op_num, StringVector sv) +{ + unsigned sz = sv.size(); + for (unsigned i = 0; i < sz; i++) + { + this->actual_in_string_[op_num-1].push_back (sv[i]); + } +} + + +void +Foo_B_Statistics::expected_callbacks (unsigned num_cbs) +{ + expected_callbacks_ = num_cbs * this->num_collcated_clients_; +} + + +void +Foo_B_Statistics::actual_callbacks (unsigned num_cbs) +{ + actual_callbacks_ += num_cbs; +} + + +void +Foo_B_Statistics::servant_error_count (unsigned error_count) +{ + this->servant_error_count_ += error_count; +} + + +bool +Foo_B_Statistics::actual_vs_expected() +{ + // Verify the checking results in servant operation code. + if (this->servant_error_count_ > 0) + { + return false; + } + + // Verify the number of callbacks received for the collocated + // client. + if (actual_callbacks_ != expected_callbacks_) + { + return false; + } + + // Verify the number of operations server received. + for (unsigned int z = 0; z < 16; z++) + { + if (this->expected_op_count_[z] != this->actual_op_count_[z]) + { + return false; + } + } + + Foo_B_Statistics stats (1, 0); + Foo_B_ClientEngine::expected_results (stats); + + for (unsigned i = 0; i < 16; i++) + { + switch (expected_in_value_type_[i]) + { + case FOO_B_STAT_LONG: + { + unsigned actual_size + = this->actual_in_long_[i].size (); + unsigned expected_size + = this->num_clients_ * stats.expected_op_count_[i]; + if (actual_size != expected_size) + { + return false; + } + sort (this->actual_in_long_[i]); + + for (unsigned j = 0; j < actual_size - 1; j++) + { + if (this->actual_in_long_[i][j] != this->actual_in_long_[i][j + 1] - 1) + { + return false; + } + } + } + break; + + case FOO_B_STAT_STRING: + { + unsigned actual_size + = this->actual_in_string_[i].size (); + unsigned expected_size + = this->num_clients_ * stats.expected_op_count_[i]; + if (actual_size != expected_size) + { + return false; + } + + LongVector lvec; + char buffer[50]; + + for (unsigned k = 0; k < actual_size; k++) + { + unsigned client_id; + sscanf (this->actual_in_string_[i][k].c_str(), "%d %s", &client_id, buffer); + if (ACE_OS::strcmp (buffer, ONEWAY_ARG_TEST_STR) != 0) + { + return false; + } + lvec.push_back (client_id); + } + + sort (lvec); + + for (unsigned j = 0; j < actual_size - 1; j++) + { + if (lvec[j] != lvec[j + 1] - 1) + { + return false; + } + } + } + break; + + case FOO_B_STAT_NONE: + default: + break; + } + + } + + return true; +} + diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_Statistics.h b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_Statistics.h new file mode 100644 index 00000000000..cf21382c549 --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_Statistics.h @@ -0,0 +1,54 @@ +// $Id$ +#ifndef STATISTICS_B_H +#define STATISTICS_B_H + +#include "CSD_TP_Foo_B_Export.h" +#include "StatisticsHelper.h" + + +class CSD_TP_Foo_B_Export Foo_B_Statistics +{ + public: + + enum In_Value_Type + { + FOO_B_STAT_NONE, + FOO_B_STAT_STRING, + FOO_B_STAT_LONG + }; + + Foo_B_Statistics(unsigned num_remote_clients, + unsigned num_collcated_clients); + + virtual ~Foo_B_Statistics(); + + void expected(unsigned op_num, unsigned count, In_Value_Type type); + void actual(unsigned op_num, unsigned count); + void actual(unsigned op_num, LongVector lv); + void actual(unsigned op_num, StringVector sv); + void servant_error_count(unsigned error_count); + + void expected_callbacks (unsigned num_cbs); + void actual_callbacks (unsigned num_cbs); + + bool actual_vs_expected(); + +private: + + unsigned num_clients_; + unsigned num_collcated_clients_; + + LongVector actual_in_long_ [16]; + StringVector actual_in_string_ [16]; + + unsigned expected_op_count_[16]; + unsigned actual_op_count_[16]; + unsigned expected_in_value_type_[16]; + + unsigned expected_callbacks_; + unsigned actual_callbacks_; + + unsigned servant_error_count_; +}; + +#endif 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_); + } +} diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_i.h b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_i.h new file mode 100644 index 00000000000..c6838db5776 --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/Foo_B_i.h @@ -0,0 +1,93 @@ +// $Id$ +#ifndef FOO_B_I_H +#define FOO_B_I_H + +#include "CSD_TP_Foo_B_Export.h" +#include "Foo_BS.h" +#include "Foo_B_Statistics.h" + + +class CSD_TP_Foo_B_Export Foo_B_i : public virtual POA_Foo_B, + public virtual PortableServer::RefCountServantBase +{ + public: + + Foo_B_i(); + virtual ~Foo_B_i(); + + virtual void op1(ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void op2(CORBA::Long value ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual CORBA::Long op3(CORBA::Long value ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void op4(CORBA::Long value ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void op5(ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException, FooException)); + + virtual CORBA::Boolean op6(const TimeOfDay& t, + char*& message + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void op7(Callback_ptr cb + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException, + FooException)); + + virtual void test_unbounded_string_arg(const char* message + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void test_bounded_string_arg(const char* message + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void test_fixed_array_arg(const Fixed_Array message + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void test_var_array_arg(const Var_Array messages + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void test_bounded_var_size_arg(const Bounded_Var_Size& message + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void test_unbounded_var_size_arg(const Unbounded_Var_Size& message + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void test_fixed_size_arg(const TimeOfDay& t + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void test_special_basic_arg(CORBA::Boolean value, + CORBA::Long client_id + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void test_objref_arg(Callback_ptr cb + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + virtual void done(ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC((CORBA::SystemException)); + + void gather_stats (Foo_B_Statistics& stats); + + private: + + LongVector in_long_ [16]; + StringVector in_string_ [16]; + unsigned op_count_ [16]; + unsigned error_count_; +}; + +#endif diff --git a/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/csd_tp_foo_b_lib.mpc b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/csd_tp_foo_b_lib.mpc new file mode 100644 index 00000000000..a9503d73c5a --- /dev/null +++ b/TAO/tests/CSD_Strategy_Tests/TP_Foo_B/csd_tp_foo_b_lib.mpc @@ -0,0 +1,25 @@ +//$Id$ +project : csd_tp_test_lib { + sharedname = CSD_TP_Foo_B + dynamicflags = CSD_TP_FOO_B_BUILD_DLL + idlflags += -Wb,export_macro=CSD_TP_Foo_B_Export -Wb,export_include=CSD_TP_Foo_B_Export.h + includes += $(TAO_ROOT)/tao + + IDL_Files { + Foo_B.idl + Callback.idl + } + + Source_Files { + Foo_BC.cpp + Foo_BS.cpp + Foo_B_ClientEngine.cpp + Foo_B_SimpleClientEngine.cpp + Foo_B_i.cpp + Foo_B_Statistics.cpp + Callback_i.cpp + CallbackC.cpp + CallbackS.cpp + } + +} |