summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Bug_2800_Regression
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2007-02-12 13:56:49 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2007-02-12 13:56:49 +0000
commit5a86f790c055b146026009f53601c323f5020f89 (patch)
tree7d82107e3c69c032dd5d779d38d72fb4396deba0 /TAO/orbsvcs/tests/Bug_2800_Regression
parentad8df096c29de8532d4dcebb8f0cd6714a45f37b (diff)
downloadATCD-5a86f790c055b146026009f53601c323f5020f89.tar.gz
Mon Feb 12 13:41:14 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/orbsvcs/tests/Bug_2800_Regression')
-rw-r--r--TAO/orbsvcs/tests/Bug_2800_Regression/Bug_2800_Regression.mpc16
-rw-r--r--TAO/orbsvcs/tests/Bug_2800_Regression/Hello.cpp2
-rw-r--r--TAO/orbsvcs/tests/Bug_2800_Regression/Hello.h6
-rwxr-xr-xTAO/orbsvcs/tests/Bug_2800_Regression/run_test_federated.pl122
-rw-r--r--TAO/orbsvcs/tests/Bug_2800_Regression/server.cpp152
5 files changed, 291 insertions, 7 deletions
diff --git a/TAO/orbsvcs/tests/Bug_2800_Regression/Bug_2800_Regression.mpc b/TAO/orbsvcs/tests/Bug_2800_Regression/Bug_2800_Regression.mpc
index 04fcfb3257f..b6c8462eff7 100644
--- a/TAO/orbsvcs/tests/Bug_2800_Regression/Bug_2800_Regression.mpc
+++ b/TAO/orbsvcs/tests/Bug_2800_Regression/Bug_2800_Regression.mpc
@@ -8,7 +8,8 @@ project(*idl): taoidldefaults {
custom_only = 1
}
-project(*Server): namingexe, naming_serv {
+project(*NsMain): namingexe, naming_serv {
+ exename = nsmain
after += *idl
Source_Files {
Hello.cpp
@@ -31,3 +32,16 @@ project(*Client): namingexe {
}
}
+project(*Server): namingexe, portableserver {
+ exename = server
+ after += *idl
+ Source_Files {
+ server.cpp
+ Hello.cpp
+ }
+ Source_Files {
+ TestC.cpp
+ TestS.cpp
+ }
+}
+
diff --git a/TAO/orbsvcs/tests/Bug_2800_Regression/Hello.cpp b/TAO/orbsvcs/tests/Bug_2800_Regression/Hello.cpp
index 3bb0a772b76..df5dc90d3d9 100644
--- a/TAO/orbsvcs/tests/Bug_2800_Regression/Hello.cpp
+++ b/TAO/orbsvcs/tests/Bug_2800_Regression/Hello.cpp
@@ -12,14 +12,12 @@ Hello::Hello (CORBA::ORB_ptr orb)
char *
Hello::get_string (void)
- ACE_THROW_SPEC ((CORBA::SystemException))
{
return CORBA::string_dup ("Hello there!");
}
void
Hello::shutdown (void)
- ACE_THROW_SPEC ((CORBA::SystemException))
{
this->orb_->shutdown (0);
}
diff --git a/TAO/orbsvcs/tests/Bug_2800_Regression/Hello.h b/TAO/orbsvcs/tests/Bug_2800_Regression/Hello.h
index 6131e1a3c88..f87205c3011 100644
--- a/TAO/orbsvcs/tests/Bug_2800_Regression/Hello.h
+++ b/TAO/orbsvcs/tests/Bug_2800_Regression/Hello.h
@@ -17,11 +17,9 @@ public:
Hello (CORBA::ORB_ptr orb);
// = The skeleton methods
- virtual char * get_string (void)
- ACE_THROW_SPEC ((CORBA::SystemException));
+ virtual char * get_string (void);
- virtual void shutdown (void)
- ACE_THROW_SPEC ((CORBA::SystemException));
+ virtual void shutdown (void);
private:
/// Use an ORB reference to conver strings to objects and shutdown
diff --git a/TAO/orbsvcs/tests/Bug_2800_Regression/run_test_federated.pl b/TAO/orbsvcs/tests/Bug_2800_Regression/run_test_federated.pl
new file mode 100755
index 00000000000..8d73ffb4ae7
--- /dev/null
+++ b/TAO/orbsvcs/tests/Bug_2800_Regression/run_test_federated.pl
@@ -0,0 +1,122 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# $Id$
+# -*- perl -*-
+
+# This is a Perl script that runs a Naming Service test. It starts
+# all the servers and clients as necessary.
+
+use lib "$ENV{ACE_ROOT}/bin";
+use PerlACE::Run_Test;
+use Cwd;
+
+# Amount of delay (in seconds) between starting a server and a client
+# to allow proper server initialization.
+$sleeptime = 10;
+
+$quiet = 0;
+$debug_level = '0';
+
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+ if ($ARGV[0] eq '-q') {
+ $quiet = 1;
+ }
+}
+
+
+# Variables for command-line arguments to client and server
+# executables.
+$ns_orb_port1 = 9931;
+$ns_orb_port2 = 9932;
+$ns_endpoint1 = "iiop://localhost:$ns_orb_port1";
+$ns_endpoint2 = "iiop://localhost:$ns_orb_port2";
+$nsiorfile1 = PerlACE::LocalFile ("ns1.ior");
+$nsiorfile2 = PerlACE::LocalFile ("ns2.ior");
+$iorfile = PerlACE::LocalFile ("test.ior");
+
+$status = 0;
+
+# Run two Naming Servers
+
+my $args = "-ORBEndPoint $ns_endpoint1 -o $nsiorfile1 -m 0";
+my $prog = "../../Naming_Service/Naming_Service";
+$NS1 = new PerlACE::Process ($prog, $args);
+
+unlink $nsiorfile1;
+unlink $iorfile;
+
+$NS1->Spawn ();
+
+if (PerlACE::waitforfile_timed ($nsiorfile1, $PerlACE::wait_interval_for_process_creation) == -1) {
+ print STDERR "ERROR: cannot find IOR file <$nsiorfile1>\n";
+ $NS1->Kill ();
+ exit 1;
+}
+
+my $args = "-ORBEndPoint $ns_endpoint2 -o $nsiorfile2 -m 0";
+my $prog = "../../Naming_Service/Naming_Service";
+$NS2 = new PerlACE::Process ($prog, $args);
+
+unlink $nsiorfile2;
+
+$NS2->Spawn ();
+
+if (PerlACE::waitforfile_timed ($nsiorfile2, $PerlACE::wait_interval_for_process_creation) == -1) {
+ print STDERR "ERROR: cannot find IOR file <$nsiorfile2>\n";
+ $NS2->Kill ();
+ exit 1;
+}
+
+$SV = new PerlACE::Process ("server", "-ORBDebuglevel $debug_level");
+$CL = new PerlACE::Process ("client", "");
+
+$server = $SV->Spawn ();
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ exit 1;
+}
+
+if (PerlACE::waitforfile_timed ($iorfile,
+ $PerlACE::wait_interval_for_process_creation) == -1) {
+ print STDERR "ERROR: cannot find file <$iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+# Kill naming service 2
+print STDERR "Killing second naming server\n";
+$NS2->Kill ();
+
+print STDERR "Starting client\n";
+$client = $CL->Spawn (10);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+sleep (15);
+
+print STDERR "Starting NS2 again\n";
+
+$NS2->Spawn ();
+
+$server = $SV->WaitKill (10);
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ $status = 1;
+}
+
+$NS1->Kill ();
+
+unlink $iorfile1;
+unlink $iorfile2;
+
+exit $status;
diff --git a/TAO/orbsvcs/tests/Bug_2800_Regression/server.cpp b/TAO/orbsvcs/tests/Bug_2800_Regression/server.cpp
new file mode 100644
index 00000000000..78515124da8
--- /dev/null
+++ b/TAO/orbsvcs/tests/Bug_2800_Regression/server.cpp
@@ -0,0 +1,152 @@
+// $Id$
+
+#include "Hello.h"
+#include "orbsvcs/CosNamingC.h"
+#include "ace/Get_Opt.h"
+#include "ace/Task.h"
+
+const char *ior_output_file = "test.ior";
+
+class TestTask : public ACE_Task_Base
+{
+public:
+ TestTask(int argc, char **argv);
+ virtual int svc();
+
+ int parse_args (int argc, char **argv);
+
+ void end();
+private:
+ CORBA::ORB_var orb_;
+ CORBA::Boolean shutdown_ns_;
+};
+
+TestTask::TestTask(int argc, char **argv)
+{
+ orb_ = CORBA::ORB_init(argc, argv, "ServerORB");
+ shutdown_ns_ = false;
+ parse_args(argc, argv);
+}
+
+void TestTask::end()
+{
+ orb_->shutdown(0);
+ wait();
+}
+
+int
+TestTask::parse_args (int argc, char **argv)
+{
+ ACE_Get_Opt get_opts (argc, argv, "o:s");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 's':
+ shutdown_ns_ = true;
+ break;
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+int TestTask::svc()
+{
+
+ try {
+ // Get reference to Root POA
+ CORBA::Object_var obj = orb_->resolve_initial_references("RootPOA");
+ PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());
+
+ // Activate POA Manager
+ PortableServer::POAManager_var mgr = poa->the_POAManager();
+ mgr->activate();
+
+ // Find the Naming Service
+ obj = orb_->string_to_object ("corbaloc:iiop:1.2@localhost:9932/NameService");
+ CosNaming::NamingContext_var root =
+ CosNaming::NamingContext::_narrow(obj.in());
+
+ if (CORBA::is_nil(root.in())) {
+ ACE_ERROR ((LM_ERROR, "Error, Nil Naming Context reference\n"));
+ return 1;
+ }
+ // Bind the example Naming Context, if necessary
+ CosNaming::NamingContext_var example_nc;
+ CosNaming::Name name;
+ name.length(1);
+ name[0].id = CORBA::string_dup("example");
+ try {
+ obj = root->resolve(name);
+ example_nc =
+ CosNaming::NamingContext::_narrow(obj.in());
+ }
+ catch (CosNaming::NamingContext::NotFound&) {
+ example_nc = root->bind_new_context(name);
+ }
+
+ // Bind the Test object
+ name.length(2);
+ name[1].id = CORBA::string_dup("Hello");
+
+ // Create an object
+ Hello servant(orb_.in ());
+ PortableServer::ObjectId_var oid = poa->activate_object(&servant);
+ obj = poa->id_to_reference(oid.in());
+ root->rebind(name, obj.in());
+
+ ACE_DEBUG ((LM_INFO, "Hello object bound in Naming Service B\n"));
+
+ name.length(1);
+ obj = orb_->string_to_object ("corbaloc:iiop:1.2@localhost:9931/NameService");
+ root = CosNaming::NamingContext::_narrow(obj.in());
+ root->bind_context (name, example_nc.in ());
+
+ ACE_DEBUG ((LM_INFO, "'example' context of NS B bound in Naming Service A\n"));
+
+ CORBA::String_var ior =
+ orb_->object_to_string (obj.in ());
+
+ // Output the IOR to the <ior_output_file>
+ FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open output file for writing IOR: %s\n",
+ ior_output_file),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ ACE_DEBUG ((LM_INFO, "Wrote IOR file\n"));
+
+ // Normally we run the orb and the orb is shutdown by
+ // calling TestTask::end().
+ // Accept requests
+ orb_->run();
+ orb_->destroy();
+
+ return 0;
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("CORBA exception: ");
+ }
+
+ return -1;
+}
+
+int main(int argc, char* argv[])
+{
+ // Start the Test task
+ TestTask test_(argc, argv);
+ test_.activate();
+
+ // Wait the Test task finish.
+ test_.wait();
+
+ return 0;
+}