summaryrefslogtreecommitdiff
path: root/TAO/tests/Portable_Interceptors/ORB_Shutdown
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/Portable_Interceptors/ORB_Shutdown
parent6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff)
downloadATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz
Repo restructuring
Diffstat (limited to 'TAO/tests/Portable_Interceptors/ORB_Shutdown')
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/.cvsignore2
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/PI_ORB_Shutdown.mpc22
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/README16
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_ORBInitializer.cpp52
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_ORBInitializer.h71
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_Request_Interceptor.cpp90
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_Request_Interceptor.h116
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/client.cpp91
-rwxr-xr-xTAO/tests/Portable_Interceptors/ORB_Shutdown/run_test.pl53
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/server.cpp138
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/test.idl21
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/test_i.cpp34
-rw-r--r--TAO/tests/Portable_Interceptors/ORB_Shutdown/test_i.h53
13 files changed, 759 insertions, 0 deletions
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/.cvsignore b/TAO/tests/Portable_Interceptors/ORB_Shutdown/.cvsignore
new file mode 100644
index 00000000000..f2ad85300eb
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/.cvsignore
@@ -0,0 +1,2 @@
+client
+server
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/PI_ORB_Shutdown.mpc b/TAO/tests/Portable_Interceptors/ORB_Shutdown/PI_ORB_Shutdown.mpc
new file mode 100644
index 00000000000..600ba5c118b
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/PI_ORB_Shutdown.mpc
@@ -0,0 +1,22 @@
+// -*- MPC -*-
+//
+// $Id$
+
+project(*Server): taoserver, pi_server, interceptors {
+ Source_Files {
+ test_i.cpp
+ Server_ORBInitializer.cpp
+ Server_Request_Interceptor.cpp
+ server.cpp
+ }
+}
+
+project(*Client): taoclient, anytypecode {
+ after += *Server
+
+ Source_Files {
+ testC.cpp
+ client.cpp
+ }
+}
+
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/README b/TAO/tests/Portable_Interceptors/ORB_Shutdown/README
new file mode 100644
index 00000000000..285817b4223
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/README
@@ -0,0 +1,16 @@
+# $Id$
+
+This test verifies that the ServerRequestInterceptor::destroy() method
+is not called prematurely, e.g. during ORB::shutdown() and before
+ending interception points have been called.
+
+See bug report 1642 in our bug tracking system for complete details.
+
+Test output should be similar to the following:
+
+==== Running PortableInterceptor ORB::shutdown() test
+test servant: <IOR:010000000...>
+Hello!
+Shutting down ORB.
+Event loop finished.
+PortableInterceptor ORB::shutdown() test passed.
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_ORBInitializer.cpp b/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_ORBInitializer.cpp
new file mode 100644
index 00000000000..04262d84180
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_ORBInitializer.cpp
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+
+#include "Server_ORBInitializer.h"
+
+ACE_RCSID (ForwardRequest,
+ Server_ORBInitializer,
+ "$Id$")
+
+#if TAO_HAS_INTERCEPTORS == 1
+
+#include "Server_Request_Interceptor.h"
+
+#include "tao/ORB_Constants.h"
+
+Server_ORBInitializer::Server_ORBInitializer (bool & destroy_called)
+ : destroy_called_ (destroy_called)
+{
+}
+
+void
+Server_ORBInitializer::pre_init (
+ PortableInterceptor::ORBInitInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+Server_ORBInitializer::post_init (
+ PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ PortableInterceptor::ServerRequestInterceptor_ptr interceptor;
+ ACE_NEW_THROW_EX (interceptor,
+ Server_Request_Interceptor (this->destroy_called_),
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ TAO::VMCID,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ ACE_CHECK;
+
+ PortableInterceptor::ServerRequestInterceptor_var server_interceptor =
+ interceptor;
+
+ info->add_server_request_interceptor (interceptor
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_ORBInitializer.h b/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_ORBInitializer.h
new file mode 100644
index 00000000000..1498e7c020c
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_ORBInitializer.h
@@ -0,0 +1,71 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Server_ORBInitializer.h
+ *
+ * $Id$
+ *
+ * Implementation header for the PortableInterceptor ORB::shutdown()
+ * test server side ORB initializer.
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_SERVER_ORB_INITIALIZER_H
+#define TAO_SERVER_ORB_INITIALIZER_H
+
+#include "tao/LocalObject.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if TAO_HAS_INTERCEPTORS == 1
+
+#include "tao/PI/PI.h"
+
+// This is to remove "inherits via dominance" warnings from MSVC.
+// MSVC is being a little too paranoid.
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+// Forward declaration.
+class Server_Request_Interceptor;
+
+/// Server side ORB initializer.
+class Server_ORBInitializer
+ : public virtual PortableInterceptor::ORBInitializer,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ /// Constructor.
+ Server_ORBInitializer (bool & destroy_called);
+
+ virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+private:
+
+ /// Flag that states whether this interceptor's @c destroy() method
+ /// was called.
+ bool & destroy_called_;
+
+};
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
+
+#endif /* TAO_SERVER_ORB_INITIALIZER_H */
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_Request_Interceptor.cpp b/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_Request_Interceptor.cpp
new file mode 100644
index 00000000000..d7cd081e6d3
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_Request_Interceptor.cpp
@@ -0,0 +1,90 @@
+#include "Server_Request_Interceptor.h"
+
+#include "ace/Log_Msg.h"
+
+ACE_RCSID (ORB_Shutdown,
+ Server_Request_Interceptor,
+ "$Id$")
+
+Server_Request_Interceptor::Server_Request_Interceptor (bool & destroy_called)
+ : destroy_called_ (destroy_called)
+{
+ this->destroy_called_ = false; // Sanity check.
+}
+
+Server_Request_Interceptor::~Server_Request_Interceptor (void)
+{
+ // ORB::destroy() should have been called, which in turn should have
+ // called the Interceptor::destroy() method in all registered
+ // interceptors.
+ ACE_ASSERT (this->destroy_called_ == true);
+}
+
+char *
+Server_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return CORBA::string_dup ("Server_Request_Interceptor");
+}
+
+void
+Server_Request_Interceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ this->destroy_called_ = true;
+}
+
+void
+Server_Request_Interceptor::receive_request_service_contexts (
+ PortableInterceptor::ServerRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+ // Interceptor::destroy() should not have been called yet.
+ ACE_ASSERT (this->destroy_called_ == false);
+}
+
+void
+Server_Request_Interceptor::receive_request (
+ PortableInterceptor::ServerRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+
+{
+ // Interceptor::destroy() should not have been called yet.
+ ACE_ASSERT (this->destroy_called_ == false);
+}
+
+void
+Server_Request_Interceptor::send_reply (
+ PortableInterceptor::ServerRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // Interceptor::destroy() should not have been called yet.
+ ACE_ASSERT (this->destroy_called_ == false);
+}
+
+void
+Server_Request_Interceptor::send_exception (
+ PortableInterceptor::ServerRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+ // Interceptor::destroy() should not have been called yet.
+ ACE_ASSERT (this->destroy_called_ == false);
+}
+
+void
+Server_Request_Interceptor::send_other (
+ PortableInterceptor::ServerRequestInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest))
+{
+ // Interceptor::destroy() should not have been called yet.
+ ACE_ASSERT (this->destroy_called_ == false);
+}
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_Request_Interceptor.h b/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_Request_Interceptor.h
new file mode 100644
index 00000000000..10e3add572b
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/Server_Request_Interceptor.h
@@ -0,0 +1,116 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Server_Request_Interceptor.h
+ *
+ * $Id$
+ *
+ * Implementation header for the server request interceptor for the
+ * PortableInterceptor ORB::shutdown() test.
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef SERVER_REQUEST_INTERCEPTOR_H
+#define SERVER_REQUEST_INTERCEPTOR_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/PI_Server/PI_Server.h"
+#include "tao/PortableInterceptorC.h"
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+/**
+ * @class Server_Request_Interceptor
+ *
+ * @brief Simple concrete server request interceptor.
+ *
+ * This server request interceptor simply determines if its @c
+ * destroy() method is invoked out of order.
+ *
+ * See the README file for test details.
+ */
+class Server_Request_Interceptor
+ : public virtual PortableInterceptor::ServerRequestInterceptor,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ /// Constructor.
+ Server_Request_Interceptor (bool & destroy_called);
+
+ /**
+ * @name Methods Required by the Server Request Interceptor
+ * Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all server request interceptors.
+ */
+ //@{
+ /// Return the name of this ServerRequestinterceptor.
+ virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void receive_request_service_contexts (
+ PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+
+ virtual void receive_request (
+ PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+
+ virtual void send_reply (
+ PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void send_exception (
+ PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+
+ virtual void send_other (
+ PortableInterceptor::ServerRequestInfo_ptr ri
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableInterceptor::ForwardRequest));
+ //@}
+
+protected:
+
+ /// Destructor.
+ ~Server_Request_Interceptor (void);
+
+private:
+
+ /// Flag that states whether this interceptor's @c destroy() method
+ /// was called.
+ bool & destroy_called_;
+
+};
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* SERVER_REQUEST_INTERCEPTOR_H */
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/client.cpp b/TAO/tests/Portable_Interceptors/ORB_Shutdown/client.cpp
new file mode 100644
index 00000000000..ca70543c315
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/client.cpp
@@ -0,0 +1,91 @@
+// -*- C++ -*-
+
+#include "ace/Get_Opt.h"
+
+#include "testC.h"
+
+
+ACE_RCSID (ORB_Shutdown,
+ client,
+ "$Id$")
+
+
+const char *ior = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "k:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+
+ if (ior == 0)
+ ior = get_opts.opt_arg ();
+
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Usage: %s "
+ "-k IOR\n",
+ argv[0]),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv,
+ "Client ORB"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (::parse_args (argc, argv) != 0)
+ return -1;
+
+ CORBA::Object_var object =
+ orb->string_to_object (ior
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ test_var server = test::_narrow (object.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);
+ }
+
+ server->hello (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ server->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Caught exception:");
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ ACE_DEBUG ((LM_INFO,
+ "PortableInterceptor ORB::shutdown() test passed.\n"));
+
+ return 0;
+}
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/run_test.pl b/TAO/tests/Portable_Interceptors/ORB_Shutdown/run_test.pl
new file mode 100755
index 00000000000..6c03ec53a45
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/run_test.pl
@@ -0,0 +1,53 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# -*- perl -*-
+#
+# $Id$
+
+
+use lib '../../../../bin';
+use PerlACE::Run_Test;
+
+$file = PerlACE::LocalFile ("test.ior");
+
+unlink $file;
+
+if (PerlACE::is_vxworks_test()) {
+ $SV = new PerlACE::ProcessVX ("server", "-o test.ior");
+}
+else {
+ $SV = new PerlACE::Process ("server", "-o $file");
+}
+$CL = new PerlACE::Process ("client", "-k file://$file");
+
+$status = 0;
+
+print STDERR "\n\n==== Running PortableInterceptor ORB::shutdown() test\n";
+
+$SV->Spawn ();
+
+if (PerlACE::waitforfile_timed ($file, 15) == -1) {
+ print STDERR "ERROR: cannot find file <$file>\n";
+ $SV->Kill ();
+ exit 1;
+}
+
+$client = $CL->SpawnWaitKill (60);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+$server = $SV->WaitKill (5);
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ $status = 1;
+}
+
+unlink $file;
+
+exit $status;
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/server.cpp b/TAO/tests/Portable_Interceptors/ORB_Shutdown/server.cpp
new file mode 100644
index 00000000000..000fda92d76
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/server.cpp
@@ -0,0 +1,138 @@
+#include "ace/Get_Opt.h"
+
+#include "test_i.h"
+#include "Server_ORBInitializer.h"
+#include "Server_Request_Interceptor.h"
+
+#include "tao/ORBInitializer_Registry.h"
+#include "ace/OS_NS_stdio.h"
+
+
+ACE_RCSID (ORB_Shutdown,
+ server,
+ "$Id$")
+
+
+const char *ior_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_file = get_opts.opt_arg ();
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Usage: %s "
+ "-o IOR\n",
+ argv[0]),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ bool destroy_called = false;
+
+#if TAO_HAS_INTERCEPTORS == 1
+ Server_ORBInitializer *temp_initializer = 0;
+ ACE_NEW_RETURN (temp_initializer,
+ Server_ORBInitializer (destroy_called),
+ -1); // No exceptions yet!
+ PortableInterceptor::ORBInitializer_var orb_initializer =
+ temp_initializer;
+
+ PortableInterceptor::register_orb_initializer (orb_initializer.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+#endif /* TAO_HAS_INTERCEPTORS == 1 */
+
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv, "Server ORB" 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;
+
+ 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;
+
+ test_i servant (orb.in ());
+
+ CORBA::Object_var obj =
+ servant._this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::String_var ior =
+ orb->object_to_string (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "test servant: <%s>\n",
+ ior.in ()));
+
+ // Write IOR to a file.
+ FILE *output_file= ACE_OS::fopen (ior_file, "w");
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open output file <%s> for writing "
+ "IOR: %s",
+ ior.in ()),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ // Run the ORB event loop.
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (destroy_called == true);
+
+ ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Caught exception:");
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/test.idl b/TAO/tests/Portable_Interceptors/ORB_Shutdown/test.idl
new file mode 100644
index 00000000000..a186afb08e8
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/test.idl
@@ -0,0 +1,21 @@
+// -*- IDL -*-
+
+//=============================================================================
+/**
+ * @file test.idl
+ *
+ * $Id$
+ *
+ * Simple IDL file to test PortableInterceptor/ORB::shutdown()
+ * semantics.
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+interface test
+{
+ void hello ();
+
+ oneway void shutdown ();
+};
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/test_i.cpp b/TAO/tests/Portable_Interceptors/ORB_Shutdown/test_i.cpp
new file mode 100644
index 00000000000..8e96015a4c1
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/test_i.cpp
@@ -0,0 +1,34 @@
+#include "test_i.h"
+
+
+ACE_RCSID (ORB_Shutdown,
+ test_i,
+ "$Id$")
+
+
+test_i::test_i (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+test_i::~test_i (void)
+{
+}
+
+void
+test_i::hello (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ACE_DEBUG ((LM_DEBUG, "Hello!\n"));
+}
+
+void
+test_i::shutdown (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "Shutting down ORB.\n"));
+
+ this->orb_->shutdown (0
+ ACE_ENV_ARG_PARAMETER);
+}
diff --git a/TAO/tests/Portable_Interceptors/ORB_Shutdown/test_i.h b/TAO/tests/Portable_Interceptors/ORB_Shutdown/test_i.h
new file mode 100644
index 00000000000..4ada828b0c2
--- /dev/null
+++ b/TAO/tests/Portable_Interceptors/ORB_Shutdown/test_i.h
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file test_i.h
+ *
+ * $Id$
+ *
+ * Implementation header for the "test" IDL interface for the
+ * PortableInterceptor ORB::shutdown() test.
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include "testS.h"
+
+/**
+ * @class test_i
+ *
+ * @brief Simple test class.
+ *
+ * This class implements the "test" interface used in this test.
+ */
+class test_i : public virtual POA_test
+{
+public:
+
+ /// Constructor.
+ test_i (CORBA::ORB_ptr orb);
+
+ /// Destructor.
+ ~test_i (void);
+
+ /// Say hello.
+ virtual void hello (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// Shutdown the ORB.
+ virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+private:
+
+ /// Pseudo-reference to the ORB.
+ CORBA::ORB_var orb_;
+
+};
+
+#endif /* TEST_I_H */