diff options
Diffstat (limited to 'TAO/tests/CallbackTest/Service.cpp')
| -rw-r--r-- | TAO/tests/CallbackTest/Service.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/TAO/tests/CallbackTest/Service.cpp b/TAO/tests/CallbackTest/Service.cpp new file mode 100644 index 00000000000..c8563ef6ad7 --- /dev/null +++ b/TAO/tests/CallbackTest/Service.cpp @@ -0,0 +1,100 @@ +// +// $Id$ +// +#include "Service.h" + +ACE_RCSID(Callback, Service, "$Id$") + +Service::Service (CORBA::ORB_ptr orb) + : test_count_ (0), + orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +void +Service::dump_results (void) +{ + if (this->test_count_ == 0) + { + ACE_DEBUG ((LM_DEBUG, + "ERROR: no tests were completed!\n")); + } +} + +void +Service::run_test (Test::Callback_ptr callback) +{ + int exceptions = + this->call_are_you_there (callback); + + exceptions += + this->call_test_oneway (callback); + + if (exceptions != 0) + { + ACE_ERROR ((LM_ERROR, + "ERROR: There were %d exceptions\n")); + } + + /// Increment the number of tests completed + this->test_count_++; + + try + { + callback->shutdown (); + } + catch (const CORBA::Exception&) + { + ACE_DEBUG ((LM_ERROR, "(%P|%t) - Service, client shutdown FAILED\n")); + } + + // shutdown ourselves + this->orb_->shutdown (0); +} + + +int +Service::call_are_you_there (Test::Callback_ptr callback) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Service, calling are_you_there\n")); + const int iterations = 10; + + int exception_count = 0; + for (int i = 0; i != iterations; ++i) + { + char* outstr; + CORBA::String_out out_str (outstr); + try + { + (void) callback->are_you_there (out_str); + } + catch (const CORBA::Exception&) + { + exception_count++; + } + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Service, answer = %s\n", outstr)); + } + return exception_count; +} + +int +Service::call_test_oneway (Test::Callback_ptr callback) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Service, calling test_oneway\n")); + const int iterations = 10; + + int exception_count = 0; + for (int i = 0; i != iterations; ++i) + { + try + { + (void) callback->test_oneway (); + } + catch (const CORBA::Exception&) + { + exception_count++; + } + } + return exception_count; +} |
