diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2006-01-13 13:23:21 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2006-01-13 13:23:21 +0000 |
commit | 5bfda4801ea3f8261938d5617533b57a3a58ba17 (patch) | |
tree | 1a5c6b9586c543e0a30e66c06eab002e845571bc | |
parent | 45cbaa2197f88cf72dee799393824e00ab04c049 (diff) | |
download | ATCD-5bfda4801ea3f8261938d5617533b57a3a58ba17.tar.gz |
ChangeLogTag: Fri Jan 13 12:49:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
-rw-r--r-- | TAO/tests/Bug_1869_Regression/AMI.idl | 7 | ||||
-rw-r--r-- | TAO/tests/Bug_1869_Regression/Bug_1869_Regression.mpc | 14 | ||||
-rw-r--r-- | TAO/tests/Bug_1869_Regression/client.cpp | 93 | ||||
-rw-r--r-- | TAO/tests/Bug_1869_Regression/run_test.pl | 40 | ||||
-rw-r--r-- | TAO/tests/Bug_1869_Regression/server.cpp | 87 |
5 files changed, 241 insertions, 0 deletions
diff --git a/TAO/tests/Bug_1869_Regression/AMI.idl b/TAO/tests/Bug_1869_Regression/AMI.idl new file mode 100644 index 00000000000..d0c2a9eb238 --- /dev/null +++ b/TAO/tests/Bug_1869_Regression/AMI.idl @@ -0,0 +1,7 @@ +// $Id$ + +module AMI_test { + interface adder { + long add(in long a, in long b); + }; +}; diff --git a/TAO/tests/Bug_1869_Regression/Bug_1869_Regression.mpc b/TAO/tests/Bug_1869_Regression/Bug_1869_Regression.mpc new file mode 100644 index 00000000000..15f79878b23 --- /dev/null +++ b/TAO/tests/Bug_1869_Regression/Bug_1869_Regression.mpc @@ -0,0 +1,14 @@ +// -*- MPC -*- +// $Id$ + +project(*Server): taoserver, iortable, ami, exceptions { + Source_Files { + server.cpp + } +} + +project(*Client): taoclient, ami, exceptions { + Source_Files { + client.cpp + } +} diff --git a/TAO/tests/Bug_1869_Regression/client.cpp b/TAO/tests/Bug_1869_Regression/client.cpp new file mode 100644 index 00000000000..9dbc3a8c6a3 --- /dev/null +++ b/TAO/tests/Bug_1869_Regression/client.cpp @@ -0,0 +1,93 @@ +// $Id$ + +#include "AMIS.h" +#include "ace/Task.h" +#include "ace/OS_NS_unistd.h" + +class AdderCallback + : public POA_AMI_test::AMI_adderHandler, + public ACE_Task_Base { + + public: + AdderCallback(CORBA::ORB_ptr orb) + : orb(CORBA::ORB::_duplicate(orb)) { + activate(); + } + + virtual void add ( + CORBA::Long ami_return_val + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + { + ACE_DEBUG ((LM_DEBUG, "Return value: %d\n", ami_return_val)); + } + + virtual void add_excep ( + ::Messaging::ExceptionHolder * excep_holder + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + { + ACE_DEBUG ((LM_DEBUG, "Caught exception in _excep\n")); + } + + virtual int svc() { + orb->run(); + + return 0; + } + + CORBA::ORB_var orb; + +}; + +int main (int argc, char* argv[]) { + + try { + + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + // Get reference to Root POA + CORBA::Object_var obj + = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var rootPOA = PortableServer::POA::_narrow (obj.in ()); + + // Activate POA manager + PortableServer::POAManager_var mgr + = rootPOA->the_POAManager (); + + mgr->activate(); + + // Resolve Adder Reference + obj = orb->string_to_object("corbaloc:iiop:127.0.0.1:4711/Adder"); + AMI_test::adder_var adder = AMI_test::adder::_narrow(obj.in ()); + + AdderCallback cb_servant(orb); + + while(true) { + try + { + adder->sendc_add(cb_servant._this(), 3, 2); + } + catch(...) + { + ACE_ERROR ((LM_ERROR, "ERROR: Caught exception after sendc_add\n")); + } + ACE_OS::sleep (1); + } + } + catch(...) + { + ACE_ERROR ((LM_ERROR, "ERROR: Caught exception in main\n")); + return 1; + } + + return 0; +} + + + diff --git a/TAO/tests/Bug_1869_Regression/run_test.pl b/TAO/tests/Bug_1869_Regression/run_test.pl new file mode 100644 index 00000000000..2a6eb183455 --- /dev/null +++ b/TAO/tests/Bug_1869_Regression/run_test.pl @@ -0,0 +1,40 @@ +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()) { + $SV = new PerlACE::ProcessVX ("server", "-ORBEndpoint iiop://127.0.0.1:4711"); +} +else { + $SV = new PerlACE::Process ("server", "-ORBEndpoint iiop://127.0.0.1:4711"); +} +$CL = new PerlACE::Process ("client", ""); + +$SV->Spawn (); + +$client = $CL->Spawn (300); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +sleep (5); + +print STDERR "Kill server\n"; +$server = $SV->Kill (); + +sleep (5); + +print STDERR "Restart server\n"; +$SV->Spawn (); + +sleep (30); + +exit $status; diff --git a/TAO/tests/Bug_1869_Regression/server.cpp b/TAO/tests/Bug_1869_Regression/server.cpp new file mode 100644 index 00000000000..6b741d07984 --- /dev/null +++ b/TAO/tests/Bug_1869_Regression/server.cpp @@ -0,0 +1,87 @@ +// $Id$ + +#include "AMIS.h" +#include "tao/IORTable/IORTable.h" + +class AdderServant : + public POA_AMI_test::adder { + +public: + AdderServant (void) {} + + virtual ~AdderServant (void) {} + + virtual + CORBA::Long add ( + CORBA::Long a, + CORBA::Long b + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) { + return a + b; + } +}; + + +int main (int argc, char* argv[]) { + + try { + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + // Get reference to Root POA + CORBA::Object_var obj + = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var rootPOA = PortableServer::POA::_narrow (obj.in ()); + + // Activate POA manager + PortableServer::POAManager_var mgr + = rootPOA->the_POAManager (); + + mgr->activate(); + + // Create Persistent Lifespan Policy and User Id Policy + PortableServer::LifespanPolicy_var lifespan = + rootPOA->create_lifespan_policy(PortableServer::PERSISTENT); + PortableServer::IdAssignmentPolicy_var idassignment = + rootPOA->create_id_assignment_policy(PortableServer::USER_ID); + + // Stuff them into a policy list + CORBA::PolicyList policies(2); + policies.length(2); + policies[0] = PortableServer::IdAssignmentPolicy::_duplicate(idassignment.in()); + policies[1] = PortableServer::LifespanPolicy::_duplicate(lifespan.in()); + + // Create the Child POA + PortableServer::POA_var persistentPOA = + rootPOA->create_POA("persistentPOA", mgr.in(), policies); + + // Policies are no longer needed + idassignment->destroy(); + lifespan->destroy(); + + AdderServant servant; + + // Create an id + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId("Adder"); + + // Activate the object (with id) + persistentPOA->activate_object_with_id(oid.in(), & servant); + + CORBA::Object_var ref = persistentPOA->id_to_reference(oid.in()); + CORBA::String_var iors = orb->object_to_string(ref.in()); + + CORBA::Object_var tobj = orb->resolve_initial_references("IORTable"); + IORTable::Table_var table = IORTable::Table::_narrow(tobj.in()); + table->bind("Adder", iors.in ()); + + orb->run(); + } catch (...) { + ACE_ERROR ((LM_ERROR, "ERROR: Caught exception in server")); + return 1; + } + return 0; +} + |