diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2006-04-26 13:00:32 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2006-04-26 13:00:32 +0000 |
commit | 921463a19521c905f3a5491d1974e570929b1c0e (patch) | |
tree | 8f3bedbf368362f1624e286607bbac495378e32e | |
parent | e4d86a20b2fb6ea4d9ba7a30788f1e398ae37c24 (diff) | |
download | ATCD-921463a19521c905f3a5491d1974e570929b1c0e.tar.gz |
ChangeLogTag: Wed Apr 26 12:52:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
-rw-r--r-- | TAO/tests/POA/Bug_2511_Regression/Bug_2511_Regression.mpc | 5 | ||||
-rwxr-xr-x | TAO/tests/POA/Bug_2511_Regression/run_test.pl | 25 | ||||
-rw-r--r-- | TAO/tests/POA/Bug_2511_Regression/server.cpp | 286 | ||||
-rw-r--r-- | TAO/tests/POA/Bug_2511_Regression/test.idl | 8 |
4 files changed, 324 insertions, 0 deletions
diff --git a/TAO/tests/POA/Bug_2511_Regression/Bug_2511_Regression.mpc b/TAO/tests/POA/Bug_2511_Regression/Bug_2511_Regression.mpc new file mode 100644 index 00000000000..8bd676130d6 --- /dev/null +++ b/TAO/tests/POA/Bug_2511_Regression/Bug_2511_Regression.mpc @@ -0,0 +1,5 @@ +// -*- MPC -*- +// $Id$ + +project(POA*): taoserver, minimum_corba { +} diff --git a/TAO/tests/POA/Bug_2511_Regression/run_test.pl b/TAO/tests/POA/Bug_2511_Regression/run_test.pl new file mode 100755 index 00000000000..2fa2e079325 --- /dev/null +++ b/TAO/tests/POA/Bug_2511_Regression/run_test.pl @@ -0,0 +1,25 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib '../../../../bin'; +use PerlACE::Run_Test; + +if (PerlACE::is_vxworks_test()) { + $T = new PerlACE::ProcessVX ("server"); +} +else { + $T = new PerlACE::Process ("server"); +} + +$test = $T->SpawnWaitKill (60); + +if ($test != 0) { + print STDERR "ERROR: test returned $test\n"; + exit 1; +} + +exit 0; diff --git a/TAO/tests/POA/Bug_2511_Regression/server.cpp b/TAO/tests/POA/Bug_2511_Regression/server.cpp new file mode 100644 index 00000000000..a12ae327ee7 --- /dev/null +++ b/TAO/tests/POA/Bug_2511_Regression/server.cpp @@ -0,0 +1,286 @@ +// $Id$ + +//======================================================================== +// +// = LIBRARY +// TAO/tests/POA/MT_Servant_Locator +// +// = FILENAME +// server.cpp +// +// = DESCRIPTION +// This program tests that multiple calls to the Servant Locator +// can take place simultaneously. +// +// = AUTHOR +// Irfan Pyarali +// +//========================================================================= + +#include "testS.h" +#include "ace/OS.h" +#include "tao/PortableServer/ServantLocatorC.h" +#include "tao/CDR.h" + +int postCount = 0; +int errorCount = 0; + +class test_i : + public virtual POA_test +{ +public: + + test_i (PortableServer::POA_ptr poa); + + void normal (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void exceptional (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void notexisting (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + PortableServer::POA_var poa_; +}; + +test_i::test_i (PortableServer::POA_ptr poa) + : poa_ (PortableServer::POA::_duplicate (poa)) +{ +} + +void +test_i::normal (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "executing normal\n")); +} + +void +test_i::exceptional (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "executing exceptional\n")); +} + +void +test_i::notexisting (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "executing notexisting\n")); +} + +class Servant_Locator : + public PortableServer::ServantLocator +{ +public: + + Servant_Locator (PortableServer::POA_ptr poa); + + ::PortableServer::Servant preinvoke (const PortableServer::ObjectId &, + PortableServer::POA_ptr, + const char *, + PortableServer::ServantLocator::Cookie & + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableServer::ForwardRequest)); + + void postinvoke (const PortableServer::ObjectId &, + PortableServer::POA_ptr, + const char *, + PortableServer::ServantLocator::Cookie, + PortableServer::Servant + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + test_i servant_; +}; + +Servant_Locator::Servant_Locator (PortableServer::POA_ptr poa) + : servant_ (poa) +{ +} + +::PortableServer::Servant +Servant_Locator::preinvoke (const PortableServer::ObjectId &oid, + PortableServer::POA_ptr, + const char *op, + PortableServer::ServantLocator::Cookie & + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableServer::ForwardRequest)) +{ + CORBA::String_var name = + PortableServer::ObjectId_to_string (oid); + + ACE_DEBUG ((LM_DEBUG, + "Servant_Locator::preinvoke for %s.%s ", + name.in (), op )); + + if (ACE_OS::strcmp (op, "normal") == 0) + { + ACE_DEBUG ((LM_DEBUG, "returning servant\n")); + return &this->servant_; + } + else if (ACE_OS::strcmp (op, "exceptional") == 0) + { + ACE_DEBUG ((LM_DEBUG, "throwing exception\n")); + throw CORBA::INTERNAL(); + } + else + { + ACE_DEBUG ((LM_DEBUG, "returning NULL\n")); + return 0; + } +} + +void +Servant_Locator::postinvoke (const PortableServer::ObjectId &oid, + PortableServer::POA_ptr, + const char *op, + PortableServer::ServantLocator::Cookie, + PortableServer::Servant + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ++postCount; + CORBA::String_var name = + PortableServer::ObjectId_to_string (oid); + + if (!op) + { + op = "NULL"; + ++errorCount; + } + + ACE_DEBUG ((LM_DEBUG, + "Servant_Locator::postinvoke for %s.%s\n", + name.in (), op )); + +} + +int +main (int argc, char **argv) +{ + int retval = 0; + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var obj = + orb->resolve_initial_references ("RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::PolicyList policies; + CORBA::ULong current_length = 0; + + policies.length (current_length + 1); + policies[current_length++] = + root_poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + policies.length (current_length + 1); + policies[current_length++] = + root_poa->create_servant_retention_policy (PortableServer::NON_RETAIN + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + policies.length (current_length + 1); + policies[current_length++] = + root_poa->create_id_assignment_policy (PortableServer::USER_ID + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var child_poa = + root_poa->create_POA ("child", + poa_manager.in (), + policies + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Servant_Locator* servant_locator = new Servant_Locator(child_poa.in ()) ; + child_poa->set_servant_manager (servant_locator + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::ObjectId_var objectID = + PortableServer::string_to_ObjectId ("object"); + + CORBA::Object_var objectREF = + child_poa->create_reference_with_id (objectID.in (), + "IDL:test:1.0" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + test_var testObject = + test::_narrow (objectREF.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + testObject->normal(); + + bool caught = false; + ACE_TRY + { + testObject->exceptional(); + } + ACE_CATCHANY + { + ACE_DEBUG ((LM_DEBUG, "exceptional() yielded exception\n")); + caught = true; + } + ACE_ENDTRY; + if (!caught) ++errorCount; + + caught = false; + ACE_TRY + { + testObject->notexisting(); + } + ACE_CATCHANY + { + ACE_DEBUG ((LM_DEBUG, "notexisting() yielded exception\n")); + caught = true; + } + ACE_ENDTRY; + if (!caught) ++errorCount; + + if (!errorCount) + { + ACE_DEBUG ((LM_DEBUG,"test successful\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG,"unsuccessfull: %d errors\n", errorCount )); + } + + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught"); + retval = -1; + } + ACE_ENDTRY; + + return retval; +} diff --git a/TAO/tests/POA/Bug_2511_Regression/test.idl b/TAO/tests/POA/Bug_2511_Regression/test.idl new file mode 100644 index 00000000000..373c4ef82f0 --- /dev/null +++ b/TAO/tests/POA/Bug_2511_Regression/test.idl @@ -0,0 +1,8 @@ +// $Id$ + +interface test +{ + void normal (); + void exceptional (); + void notexisting (); +}; |