summaryrefslogtreecommitdiff
path: root/TAO/tests/MProfile
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:21 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:21 +0000
commit3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch)
tree197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/tests/MProfile
parent6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff)
downloadATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz
Repo restructuring
Diffstat (limited to 'TAO/tests/MProfile')
-rw-r--r--TAO/tests/MProfile/.cvsignore2
-rw-r--r--TAO/tests/MProfile/MProfile.mpc17
-rw-r--r--TAO/tests/MProfile/README29
-rw-r--r--TAO/tests/MProfile/client.cpp169
-rw-r--r--TAO/tests/MProfile/server.cpp115
-rw-r--r--TAO/tests/MProfile/test.idl9
-rw-r--r--TAO/tests/MProfile/test_i.cpp35
-rw-r--r--TAO/tests/MProfile/test_i.h50
8 files changed, 426 insertions, 0 deletions
diff --git a/TAO/tests/MProfile/.cvsignore b/TAO/tests/MProfile/.cvsignore
new file mode 100644
index 00000000000..f2ad85300eb
--- /dev/null
+++ b/TAO/tests/MProfile/.cvsignore
@@ -0,0 +1,2 @@
+client
+server
diff --git a/TAO/tests/MProfile/MProfile.mpc b/TAO/tests/MProfile/MProfile.mpc
new file mode 100644
index 00000000000..e48d767fd5c
--- /dev/null
+++ b/TAO/tests/MProfile/MProfile.mpc
@@ -0,0 +1,17 @@
+// -*- MPC -*-
+// $Id$
+
+project(*Server): taoserver, iormanip {
+ Source_Files {
+ test_i.cpp
+ server.cpp
+ }
+}
+
+project(*Client): taoclient, iormanip {
+ after += *Server
+ Source_Files {
+ testC.cpp
+ client.cpp
+ }
+}
diff --git a/TAO/tests/MProfile/README b/TAO/tests/MProfile/README
new file mode 100644
index 00000000000..cb231703e4f
--- /dev/null
+++ b/TAO/tests/MProfile/README
@@ -0,0 +1,29 @@
+This program tests fundamentals of TAO's ORB fault tolerance by
+merging multiple profiles in a single object reference.
+
+Run the application as follows.
+
+$ server -o (file_name1) -ORBEndpoint iiop://localhost:10007
+$ server -o (file_name2) -ORBEndpoint iiop://localhost:10008
+$ client -k file://file_name1 -m file://file_name2
+(When a message "Kill primray " appears on screen, kill the server
+exhibiting the IOR in file with name "file_name1". )
+
+Test purpose:
+
+This is a test to see whether we generate exceptions as per the
+spec. When we loose connection with a connected server, the ORB would
+throw a COMM_FAILURE exception. This is platform dependent. One
+wouldn't see this on NT. The reason for this is the way TCP has been
+been implemented on NT & Solaris. I am not going in to the details for
+this behaviour. TRANSIENT exceptions are thrown when the ORB has
+tried all the object references it has and is not able to establish
+connection with any of them (TRANSIENT exceptions are also thrown for
+few other cases, but here the test is for the case that has been
+mentioned above).
+
+Comments:
+========
+
+- The run exhibits different behaviours on SUN and NT
+
diff --git a/TAO/tests/MProfile/client.cpp b/TAO/tests/MProfile/client.cpp
new file mode 100644
index 00000000000..b25b828894c
--- /dev/null
+++ b/TAO/tests/MProfile/client.cpp
@@ -0,0 +1,169 @@
+// $Id$
+
+#include "tao/IORManipulation/IORManip_Loader.h"
+#include "ace/SString.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_unistd.h"
+#include "testC.h"
+
+ACE_RCSID(MT_Server, client, "$Id$")
+
+const char *ior = "file://test.ior";
+int do_shutdown = 0;
+
+const char *name = "file://amba.ior";
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "xk:m:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'x':
+ do_shutdown = 1;
+ break;
+
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+
+ case 'm':
+ name = get_opts.opt_arg ();
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-k <ior> "
+ "-i <niterations> "
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+void
+run_test (Simple_Server_ptr server
+ ACE_ENV_ARG_DECL);
+
+int
+main (int argc, char *argv[])
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+
+ ACE_TRY
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ // Primary server
+ CORBA::Object_var object_primary =
+ orb->string_to_object (ior ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ //Secondary server
+ CORBA::Object_var object_secondary =
+ orb->string_to_object (name ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Get an object reference for the ORBs IORManipultion object!
+ CORBA::Object_ptr IORM =
+ orb->resolve_initial_references (TAO_OBJID_IORMANIPULATION,
+ 0
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ TAO_IOP::TAO_IOR_Manipulation_ptr iorm =
+ TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ TAO_IOP::TAO_IOR_Manipulation::IORList iors (2);
+ iors.length(2);
+ iors [0] = object_primary;
+ iors [1] = object_secondary;
+
+ CORBA::Object_var merged = iorm->merge_iors (iors ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Combined IOR stuff
+ Simple_Server_var server =
+ Simple_Server::_narrow (merged.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (server.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Object reference <%s> is nil\n",
+ ior),
+ 1);
+ }
+
+ run_test (server.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Caught an exception \n");
+ return -1;
+ }
+ ACE_ENDTRY;
+ return 0;
+}
+
+void run_test (Simple_Server_ptr server
+ ACE_ENV_ARG_DECL)
+{
+ for (int loop = 0; loop < 10; loop++)
+ {
+ ACE_TRY
+ {
+ // Make a remote call
+ CORBA::Long ret =
+ server->remote_call (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_UNUSED_ARG (ret);
+
+ ACE_OS::sleep (25);
+ }
+ ACE_CATCH (CORBA::TRANSIENT, t)
+ {
+ if (t.completed () != CORBA::COMPLETED_NO)
+ {
+ ACE_PRINT_EXCEPTION (t, "Unexpected kind of TRANSIENT");
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "The completed status %d\n", t.completed ()));
+ ACE_DEBUG ((LM_DEBUG,
+ "Automagically re-issuing request on TRANSIENT\n"));
+ ACE_OS::sleep (1);
+ }
+ }
+ ACE_CATCH (CORBA::COMM_FAILURE, f)
+ {
+ ACE_PRINT_EXCEPTION (f, "A (sort of) expected COMM_FAILURE");
+ ACE_DEBUG ((LM_DEBUG,
+ "Automagically re-issuing request on COMM_FAILURE\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Unexpected exception");
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+ }
+}
diff --git a/TAO/tests/MProfile/server.cpp b/TAO/tests/MProfile/server.cpp
new file mode 100644
index 00000000000..12aea589a09
--- /dev/null
+++ b/TAO/tests/MProfile/server.cpp
@@ -0,0 +1,115 @@
+// $Id$
+
+#include "ace/Get_Opt.h"
+#include "test_i.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_RCSID(MT_Client, server, "$Id$")
+
+const char *ior_output_file = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "o:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (poa_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Get the POAManager of the RootPOA.
+ 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;
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ Simple_Server_i server_impl (orb.in ());
+
+ Simple_Server_var server =
+ server_impl._this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::String_var ior =
+ orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ()));
+
+ // If the ior_output_file exists, output the ior to it
+ if (ior_output_file != 0)
+ {
+ 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",
+ ior_output_file),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+ }
+
+
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
+
+ root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_OS::sleep (5);
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Caught exception:");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/tests/MProfile/test.idl b/TAO/tests/MProfile/test.idl
new file mode 100644
index 00000000000..a87da7f07d6
--- /dev/null
+++ b/TAO/tests/MProfile/test.idl
@@ -0,0 +1,9 @@
+/*
+ * $Id$
+ */
+
+interface Simple_Server
+{
+ long remote_call ();
+ oneway void shutdown ();
+};
diff --git a/TAO/tests/MProfile/test_i.cpp b/TAO/tests/MProfile/test_i.cpp
new file mode 100644
index 00000000000..8135b51217d
--- /dev/null
+++ b/TAO/tests/MProfile/test_i.cpp
@@ -0,0 +1,35 @@
+// $Id$
+
+#include "test_i.h"
+
+ACE_RCSID(MT_Client, test_i, "$Id$")
+
+Simple_Server_i::Simple_Server_i (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ val_ (1)
+{
+}
+
+Simple_Server_i::Simple_Server_i (void)
+ : orb_ (0)
+{
+ // no-op
+}
+
+CORBA::Long
+Simple_Server_i::remote_call (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "Print out from process id (%P) hosting the servant \n"));
+
+ return this->val_++;
+}
+
+
+void
+Simple_Server_i::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ this->orb_->shutdown (0);
+}
diff --git a/TAO/tests/MProfile/test_i.h b/TAO/tests/MProfile/test_i.h
new file mode 100644
index 00000000000..f6d4df6ebee
--- /dev/null
+++ b/TAO/tests/MProfile/test_i.h
@@ -0,0 +1,50 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/tests/Mprofile
+//
+// = FILENAME
+// test_i.h
+//
+// = AUTHOR
+// Carlos O'Ryan <coryan@uci.edu>
+//
+// ============================================================================
+
+#ifndef TAO_MPROFILE_TEST_I_H
+#define TAO_MPROFILE_TEST_I_H
+
+#include "testS.h"
+
+class Simple_Server_i : public POA_Simple_Server
+{
+ // = TITLE
+ // Simpler Server implementation
+ //
+ // = DESCRIPTION
+ // Implements the Simple_Server interface in test.idl
+ //
+public:
+ Simple_Server_i (CORBA::ORB_ptr orb);
+ // ctor
+
+ Simple_Server_i (void);
+ // ctor
+
+ // = The Simple_Server methods.
+ CORBA::Long remote_call (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+private:
+ CORBA::ORB_var orb_;
+
+ CORBA::Long val_;
+
+};
+
+#endif /* TAO_MPROFILE_TEST_I_H */