summaryrefslogtreecommitdiff
path: root/TAO/tests/OBV/Supports
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/OBV/Supports
parent6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff)
downloadATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz
Repo restructuring
Diffstat (limited to 'TAO/tests/OBV/Supports')
-rw-r--r--TAO/tests/OBV/Supports/README32
-rw-r--r--TAO/tests/OBV/Supports/Supports_Test.idl98
-rw-r--r--TAO/tests/OBV/Supports/Supports_Test.mpc32
-rw-r--r--TAO/tests/OBV/Supports/Supports_Test_impl.cpp292
-rw-r--r--TAO/tests/OBV/Supports/Supports_Test_impl.h136
-rw-r--r--TAO/tests/OBV/Supports/client.cpp236
-rwxr-xr-xTAO/tests/OBV/Supports/run_test.pl42
-rw-r--r--TAO/tests/OBV/Supports/server.cpp99
8 files changed, 967 insertions, 0 deletions
diff --git a/TAO/tests/OBV/Supports/README b/TAO/tests/OBV/Supports/README
new file mode 100644
index 00000000000..e708dff9ed8
--- /dev/null
+++ b/TAO/tests/OBV/Supports/README
@@ -0,0 +1,32 @@
+// $Id$
+
+The Supports_Test example tests the ability of valuetypes to support concrete
+interfaces. Valuetypes are manipulated both as normal valuetypes and as object
+references.
+
+Since operations of a supported interface are mapped to pure virtual methods in
+the valuetype (and are not inherited), an application using this feature should
+probably not define an implementation of the interface. Doing so will result in
+multiple implementations of the same method - one for objects of the interface,
+and one for valuetypes - and clients will have no way to distiguish between the
+two, other than narrowing objects of the interface type to the
+valuetype. Instead, one can leave the interface unimplemented, and only define
+implementations of its methods in the valuetype.
+
+The steps are as follows:
+
+1. Activate a POA in which the valuetype will reside and create the valuetype.
+2. Call the valuetype's "_this ()" method, which is inherited from the skeleton
+ class of the supported interface. This will return an active object reference
+ to an object that is the type of the supported interface.
+3. This object reference can be passed as a parameter and supports remote
+ operation invokations.
+
+Supports_Test checks proper operation of the following features:
+-Valuetypes that support concrete interfaces:
+ Using the same valuetype implementation, Supports_Test creates both
+ valuetypes and object references, passes them as parameters, and
+ invokes both local and remote calls.
+-ORB::register_value_factory () return values:
+ Supports_Test checks the return values of register_value_factory () to
+ ensure compliance with the spec.
diff --git a/TAO/tests/OBV/Supports/Supports_Test.idl b/TAO/tests/OBV/Supports/Supports_Test.idl
new file mode 100644
index 00000000000..4085c5db6a1
--- /dev/null
+++ b/TAO/tests/OBV/Supports/Supports_Test.idl
@@ -0,0 +1,98 @@
+// $Id$
+
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * \file Supports_Test.idl
+ *
+ * \author George Edwards <g.edwards@vanderbilt.edu>
+ *
+ * This file contain definitions of the valuetypes and interfaces of
+ * Supports_Test, a test of TAO's OBV capabilities. Specifically, Supports_Test
+ * checks proper operation of the following features:
+ *
+ * -Valuetypes that support concrete interfaces:
+ * Using the same valuetype implementation, Supports_Test creates both
+ * valuetypes and object references, passes them as parameters, and
+ * invokes both local and remote calls.
+ * -ORB::register_value_factory () return values:
+ * Supports_Test checks the return values of register_value_factory () to
+ * ensure compliance with the spec.
+ */
+///////////////////////////////////////////////////////////////////////////////
+
+module Supports_Test
+{
+
+ valuetype Node;
+
+ typedef sequence<Node> Node_List;
+
+ /**
+ *
+ * This valuetype is the basic building block of the vt_graph valuetype,
+ * defined below. Some of these operations and state members are not
+ * currently used in the test.
+ */
+ valuetype Node
+ {
+
+ void print ();
+
+ public string name_;
+ private long weight_;
+ private short degree_;
+ private Node_List neighbors_;
+
+ void change_weight (in long new_weight);
+ void add_edge (in Node neighbor);
+ void remove_edge (in Node neighbor);
+
+ factory create ();
+
+ };
+
+ /**
+ * \interface graph
+ *
+ * This interface contains the operations we will invoke on vt_graph
+ * valuetypes as well as graph object references. The implementations of
+ * these operations will be defined in vt_graph. All graph object refs will
+ * be vt_graphs under the hood.
+ */
+ interface graph
+ {
+
+ long size ();
+ void add_node (in string name);
+ void print ();
+
+ };
+
+ valuetype vt_graph supports graph
+ {
+
+ private Node_List nodes_;
+ factory create ();
+
+ };
+
+ /**
+ * \interface test
+ *
+ * This interface contains the operations that will perform the tests.
+ */
+ interface test
+ {
+
+ void pass_vt_graph_in (in vt_graph vt_graph_param);
+ void pass_obj_graph_in (in graph graph_param);
+ void pass_vt_graph_out (out vt_graph vt_graph_param);
+ void pass_obj_graph_out (out graph graph_param);
+ void pass_vt_graph_inout (inout vt_graph vt_graph_param);
+ void pass_obj_graph_inout (inout graph graph_param);
+ void start ();
+ oneway void finish ();
+
+ };
+
+};
diff --git a/TAO/tests/OBV/Supports/Supports_Test.mpc b/TAO/tests/OBV/Supports/Supports_Test.mpc
new file mode 100644
index 00000000000..7d9df51c0b7
--- /dev/null
+++ b/TAO/tests/OBV/Supports/Supports_Test.mpc
@@ -0,0 +1,32 @@
+// $Id$
+
+project(*Server): taoserver, valuetype, strategies {
+ // This is just a dummy_label to prevent the test from being compiled
+ // in MPC builds
+ requires += dummy_label
+ Source_Files {
+ server.cpp
+ Supports_Test_impl.cpp
+ Supports_TestC.cpp
+ Supports_TestS.cpp
+ }
+ Header_Files {
+ Supports_Test_impl.h
+ Supports_TestC.h
+ Supports_TestS.h
+ }
+}
+
+project(*Client): taoclient, taoserver, valuetype {
+ exename = client
+ after += *Server
+ // This is just a dummy_label to prevent the test from being compiled
+ // in MPC builds
+ requires += dummy_label
+ Source_Files {
+ client.cpp
+ Supports_Test_impl.cpp
+ Supports_TestC.cpp
+ Supports_TestS.cpp
+ }
+}
diff --git a/TAO/tests/OBV/Supports/Supports_Test_impl.cpp b/TAO/tests/OBV/Supports/Supports_Test_impl.cpp
new file mode 100644
index 00000000000..eeccce8dc1d
--- /dev/null
+++ b/TAO/tests/OBV/Supports/Supports_Test_impl.cpp
@@ -0,0 +1,292 @@
+// $Id$
+// FUZZ: disable check_for_streams_include
+
+#include "Supports_Test_impl.h"
+
+#include "ace/streams.h"
+
+/* vt_graph_impl */
+
+vt_graph_impl::vt_graph_impl (void)
+{
+}
+
+// Creates a vt_graph_impl with the given number of nodes. There will be one
+// root node and the rest will be children of it.
+vt_graph_impl::vt_graph_impl (int num_nodes ACE_ENV_ARG_DECL)
+{
+ nodes_ ().length (0);
+ add_node ("ROOT" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ for (int i = 1; i < num_nodes; i++)
+ {
+ add_node ("CHILD" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ nodes_ ()[0]->add_edge (nodes_ ()[i] ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ }
+}
+
+// Get the number of nodes in the vt_graph.
+CORBA::Long vt_graph_impl::size (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return nodes_ ().length ();
+}
+
+// Add a node to the graph with no edges.
+void
+vt_graph_impl::add_node (const char * name ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ Supports_Test::Node * new_node = 0;
+ ACE_NEW (new_node, node_impl (name));
+ nodes_ ().length (nodes_ ().length () + 1);
+ nodes_ ()[nodes_ ().length () - 1] = new_node;
+}
+
+// Print out information about each node.
+void
+vt_graph_impl::print (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "Printing graph data... \n"));
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Number of nodes: [%d] \n", nodes_ ().length ()));
+
+ for (size_t i = 0; i < nodes_ ().length (); i++)
+ nodes_ ()[i]->print ();
+}
+
+
+/* vt_graph_init_impl - factory operations */
+
+Supports_Test::vt_graph *
+vt_graph_init_impl::create (void)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ vt_graph_impl * ret_val = 0;
+ ACE_NEW_RETURN (ret_val, vt_graph_impl, 0);
+ return ret_val;
+}
+
+CORBA::ValueBase *
+vt_graph_init_impl::create_for_unmarshal (void)
+{
+ vt_graph_impl * ret_val = 0;
+ ACE_NEW_RETURN (ret_val, vt_graph_impl, 0);
+ return ret_val;
+}
+
+
+/* test_impl */
+
+test_impl::test_impl (CORBA::ORB_ptr orb) : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+test_impl::~test_impl (void)
+{
+ this->orb_->shutdown (0);
+}
+
+void
+test_impl::pass_obj_graph_in (
+ Supports_Test::graph * graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException))
+{
+ ACE_ASSERT (graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 3);
+ ACE_CHECK;
+ graph_param->add_node ("NEW1" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ ACE_ASSERT (graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 4);
+ ACE_CHECK;
+}
+
+void
+test_impl::pass_vt_graph_in (
+ Supports_Test::vt_graph * vt_graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException))
+{
+ ACE_ASSERT (vt_graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 3);
+ ACE_CHECK;
+ vt_graph_param->add_node ("NEW1" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ ACE_ASSERT (vt_graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 4);
+ ACE_CHECK;
+}
+
+void
+test_impl::pass_obj_graph_out (
+ Supports_Test::graph_out graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException))
+{
+ vt_graph_impl * the_vt_graph = 0;
+ ACE_NEW (the_vt_graph, vt_graph_impl (4 ACE_ENV_ARG_PARAMETER));
+ ACE_CHECK;
+ graph_param = the_vt_graph->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+
+ ACE_ASSERT (graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 4);
+ ACE_CHECK;
+ graph_param->add_node ("NEW1" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ ACE_ASSERT (graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 5);
+ ACE_CHECK;
+}
+
+void
+test_impl::pass_vt_graph_out (
+ Supports_Test::vt_graph_out vt_graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException))
+{
+
+ vt_graph_impl * the_vt_graph = 0;
+ ACE_NEW (the_vt_graph, vt_graph_impl (4 ACE_ENV_ARG_PARAMETER));
+ ACE_CHECK;
+ vt_graph_param = the_vt_graph;
+
+ ACE_ASSERT (vt_graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 4);
+ ACE_CHECK;
+ vt_graph_param->add_node ("NEW1" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ ACE_ASSERT (vt_graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 5);
+ ACE_CHECK;
+
+}
+
+void
+test_impl::pass_obj_graph_inout (
+ Supports_Test::graph * &graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException))
+{
+
+ ACE_ASSERT (graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 6);
+ ACE_CHECK;
+ graph_param->add_node ("NEW3" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ ACE_ASSERT (graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 7);
+ ACE_CHECK;
+}
+
+void
+test_impl::pass_vt_graph_inout (
+ Supports_Test::vt_graph * &vt_graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException))
+{
+
+ ACE_ASSERT (vt_graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 6);
+ ACE_CHECK;
+ vt_graph_param->add_node ("NEW3" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ ACE_ASSERT (vt_graph_param->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 7);
+ ACE_CHECK;
+
+}
+
+void
+test_impl::start (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+test_impl::finish (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ this->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+
+/* node_impl */
+
+node_impl::node_impl (void)
+{
+}
+
+// Initialize state.
+node_impl::node_impl (const char * name)
+{
+ name_ (name);
+ weight_ (0);
+ degree_ (0);
+ neighbors_ ().length (0);
+}
+
+// Add an edge from this node to neighbor.
+void
+node_impl::add_edge (Supports_Test::Node * neighbor ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ degree_ (degree_ () + 1);
+ neighbors_ ().length (neighbors_ ().length () + 1);
+ neighbors_ ()[neighbors_ ().length () - 1] = neighbor;
+ neighbor->_add_ref ();
+ return;
+}
+
+// Remove the edge from this node to neighbor.
+void
+node_impl::remove_edge (Supports_Test::Node * neighbor ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ for (unsigned int i = 0; i < neighbors_ ().length (); i++)
+ if (neighbors_ ()[i] == neighbor)
+ {
+ neighbors_ ()[i] = neighbors_ ()[neighbors_ ().length () - 1];
+ neighbors_ ().length (neighbors_ ().length () - 1);
+ neighbor->_remove_ref ();
+ }
+}
+
+void
+node_impl::change_weight (CORBA::Long new_weight ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ weight_ (new_weight);
+}
+
+void
+node_impl::print (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ cout << " Name: " << name_ () << endl;
+ cout << " Weight: " << weight_ () << endl;
+ cout << " Degree: " << degree_ () << endl;
+ cout << " Neighbors: " << endl;
+ for (size_t i = 0; i < neighbors_ ().length (); i++)
+ cout << " " << neighbors_ ()[i]->name_ () << endl;
+}
+
+/* node_init_impl - factory operations */
+
+Supports_Test::Node *
+node_init_impl::create (void)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ node_impl * ret_val = 0;
+ ACE_NEW_RETURN (ret_val, node_impl, 0);
+ return ret_val;
+}
+
+CORBA::ValueBase *
+node_init_impl::create_for_unmarshal (void)
+{
+ node_impl * ret_val = 0;
+ ACE_NEW_RETURN (ret_val, node_impl, 0);
+ return ret_val;
+}
diff --git a/TAO/tests/OBV/Supports/Supports_Test_impl.h b/TAO/tests/OBV/Supports/Supports_Test_impl.h
new file mode 100644
index 00000000000..9d0932b1d87
--- /dev/null
+++ b/TAO/tests/OBV/Supports/Supports_Test_impl.h
@@ -0,0 +1,136 @@
+// $Id$
+
+#ifndef TAO_SUPPORTS_TEST_IMPL_H
+#define TAO_SUPPORTS_TEST_IMPL_H
+
+#include "Supports_TestS.h"
+#include "ace/Get_Opt.h"
+
+/**
+ * \class node_impl
+ *
+ *
+ */
+class node_impl :
+ public virtual OBV_Supports_Test::Node,
+ public virtual CORBA::DefaultValueRefCountBase
+{
+
+public:
+
+ node_impl (void);
+
+ node_impl (const char * name);
+
+ virtual void add_edge (Supports_Test::Node * neighbor ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void remove_edge (Supports_Test::Node * neighbor ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ void change_weight (CORBA::Long new_weight ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ void print (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+};
+
+class node_init_impl : public Supports_Test::Node_init
+{
+
+ public:
+
+ virtual Supports_Test::Node * create (void)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual CORBA::ValueBase * create_for_unmarshal (void);
+
+};
+
+
+class vt_graph_impl :
+ public virtual OBV_Supports_Test::vt_graph,
+ public virtual POA_Supports_Test::vt_graph,
+ public virtual CORBA::DefaultValueRefCountBase
+{
+
+ public:
+
+ vt_graph_impl (void);
+
+ vt_graph_impl (int num_nodes
+ ACE_ENV_ARG_DECL);
+
+ virtual CORBA::Long size (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void add_node (const char * name
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void print (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+};
+
+class vt_graph_init_impl :
+ public Supports_Test::vt_graph_init
+{
+
+ public:
+
+ virtual Supports_Test::vt_graph * create (void)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual CORBA::ValueBase * create_for_unmarshal (void);
+
+};
+
+class test_impl :
+ public virtual POA_Supports_Test::test
+{
+
+ public:
+
+ test_impl (CORBA::ORB_ptr orb);
+
+ virtual ~test_impl (void);
+
+ virtual void pass_obj_graph_in (Supports_Test::graph * graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void pass_vt_graph_in (Supports_Test::vt_graph * vt_graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void pass_obj_graph_out (Supports_Test::graph_out graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void pass_vt_graph_out (Supports_Test::vt_graph_out vt_graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void pass_obj_graph_inout (Supports_Test::graph * &graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void pass_vt_graph_inout (Supports_Test::vt_graph * &vt_graph_param
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void start (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void finish (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ private:
+
+ CORBA::ORB_var orb_;
+
+};
+
+#endif /* TAO_SUPPORTS_TEST_IMPL_H */
diff --git a/TAO/tests/OBV/Supports/client.cpp b/TAO/tests/OBV/Supports/client.cpp
new file mode 100644
index 00000000000..076d397dfa4
--- /dev/null
+++ b/TAO/tests/OBV/Supports/client.cpp
@@ -0,0 +1,236 @@
+// $Id$
+
+#include "Supports_Test_impl.h"
+
+const char * ior = "file://test.ior";
+int num_trials = 1;
+int id = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "t:i:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 't':
+ num_trials = atoi (get_opts.optarg);
+ break;
+
+ case 'i':
+ id = atoi (get_opts.optarg);
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-t <trials> "
+ "\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;
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (root_poa.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR," (%P|%t) Nil RootPOA\n"), 1);
+
+ 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;
+
+ /* Create, register factories */
+
+ Supports_Test::Node_init * node_factory = 0;
+
+ ACE_NEW_RETURN (node_factory, node_init_impl, 1);
+
+ CORBA::ValueFactory returned_factory =
+ orb->register_value_factory (node_factory->tao_repository_id (),
+ node_factory
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (returned_factory == 0);
+
+ node_factory->_remove_ref ();
+
+
+ Supports_Test::vt_graph_init * vt_graph_factory = 0;
+
+ ACE_NEW_RETURN (vt_graph_factory, vt_graph_init_impl, 1);
+
+ returned_factory =
+ orb->register_value_factory (vt_graph_factory->tao_repository_id (),
+ vt_graph_factory
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (returned_factory == 0);
+
+ vt_graph_factory->_remove_ref ();
+
+
+ /* Check return values for register_value_factory */
+
+ Supports_Test::Node_init * node_factory2 = 0;
+
+ ACE_NEW_RETURN (node_factory2, node_init_impl, 1);
+
+ returned_factory =
+ orb->register_value_factory (node_factory2->tao_repository_id (),
+ node_factory2
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (returned_factory == node_factory);
+
+ node_factory2->_remove_ref ();
+
+
+ /* Get test object reference */
+
+ CORBA::Object_var tmp = orb->string_to_object (ior ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ Supports_Test::test_var my_test =
+ Supports_Test::test::_narrow (tmp.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (my_test.in ()))
+ ACE_ERROR_RETURN ((LM_DEBUG, "Nil Supports_Test::test obj ref <%s>\n", ior), 1);
+
+ my_test->start (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ /* Perform test */
+
+ for (int i = 0; i < num_trials; i++)
+ {
+
+ // Create a vt_graph_impl instance and store the reference as a
+ // vt_graph_var. Then register the instance with the POA to obtain an
+ // object reference, stored as a graph_var. Increment the reference count
+ // of the vt_graph_impl instance.
+ vt_graph_impl * the_vt_graph = 0;
+ ACE_NEW_RETURN (the_vt_graph, vt_graph_impl (3 ACE_ENV_ARG_PARAMETER), 1);
+ Supports_Test::vt_graph_var test_vt_graph = the_vt_graph;
+
+ Supports_Test::graph_var test_graph =
+ the_vt_graph->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (CORBA::is_nil (test_graph.in ()))
+ ACE_ERROR_RETURN ((LM_DEBUG, "Nil Supports_Test::graph obj ref\n"), 1);
+ the_vt_graph->DefaultValueRefCountBase::_add_ref ();
+
+ // At this point, test_vt_graph and test_graph refer to the same object.
+ ACE_ASSERT (test_vt_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 3);
+ ACE_TRY_CHECK;
+ my_test->pass_vt_graph_in (test_vt_graph.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_ASSERT (test_vt_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 3);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (test_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 3);
+ ACE_TRY_CHECK;
+ my_test->pass_obj_graph_in (test_graph.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_ASSERT (test_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 4);
+ ACE_TRY_CHECK;
+
+ test_vt_graph->add_node ("NEW2" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ test_graph->add_node ("NEW3" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // After the 'pass_vt_graph_out' call returns, test_vt_graph will refer to
+ // a new object.
+ ACE_ASSERT (test_vt_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 6);
+ ACE_TRY_CHECK;
+ my_test->pass_vt_graph_out (test_vt_graph.out () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_ASSERT (test_vt_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 5);
+ ACE_TRY_CHECK;
+
+ // 'test_graph' still refers to the original object, but after the
+ // 'pass_obj_graph_out' call returns, it will refer to a new object,
+ // residing on the server.
+ ACE_ASSERT (test_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 6);
+ ACE_TRY_CHECK;
+ my_test->pass_obj_graph_out (test_graph.out () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_ASSERT (test_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 5);
+ ACE_TRY_CHECK;
+
+ // test_vt_graph and test_graph now refer to different objects.
+ test_vt_graph->add_node ("NEW2" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ test_graph->add_node ("NEW2" ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (test_vt_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 6);
+ ACE_TRY_CHECK;
+ my_test->pass_vt_graph_inout (test_vt_graph.inout () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_ASSERT (test_vt_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 7);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (test_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 6);
+ ACE_TRY_CHECK;
+ my_test->pass_obj_graph_inout (test_graph.inout () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ ACE_ASSERT (test_graph->size (ACE_ENV_SINGLE_ARG_PARAMETER) == 7);
+ ACE_TRY_CHECK;
+
+ }
+
+ my_test->finish (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ /* Shut down */
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "Client (%P.%t) completed test successfully\n", id));
+
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Exception caught:");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/tests/OBV/Supports/run_test.pl b/TAO/tests/OBV/Supports/run_test.pl
new file mode 100755
index 00000000000..f871c5cfade
--- /dev/null
+++ b/TAO/tests/OBV/Supports/run_test.pl
@@ -0,0 +1,42 @@
+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;
+
+$iorfile = PerlACE::LocalFile ("test.ior");
+unlink $iorfile;
+
+$SV = new PerlACE::Process ("server");
+$CL1 = new PerlACE::Process ("client", " -t 16 -i 1");
+
+$SV->Spawn ();
+
+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;
+}
+
+$CL1->Spawn ();
+
+$client1 = $CL1->WaitKill (300);
+
+if ($client1 != 0) {
+ print STDERR "ERROR: client returned $client1\n";
+ $status = 1;
+}
+
+$server = $SV->WaitKill (10);
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ $status = 1;
+}
+
+exit $status;
diff --git a/TAO/tests/OBV/Supports/server.cpp b/TAO/tests/OBV/Supports/server.cpp
new file mode 100644
index 00000000000..f92eee137c5
--- /dev/null
+++ b/TAO/tests/OBV/Supports/server.cpp
@@ -0,0 +1,99 @@
+// $Id$
+
+#include "Supports_Test_impl.h"
+#include "tao/Strategies/advanced_resource.h"
+
+const char * ior_output_file = "test.ior";
+
+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;
+
+ PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR," (%P|%t) Nil RootPOA\n"), 1);
+
+ PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+
+ /* Create, register factories */
+
+ Supports_Test::Node_init * node_factory = 0;
+
+ ACE_NEW_RETURN (node_factory, node_init_impl, 1);
+
+ CORBA::ValueFactory returned_factory = orb->register_value_factory (node_factory->tao_repository_id (), node_factory ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (returned_factory == 0);
+
+ node_factory->_remove_ref ();
+
+ Supports_Test::vt_graph_init * vt_graph_factory = 0;
+
+ ACE_NEW_RETURN (vt_graph_factory, vt_graph_init_impl, 1);
+
+ returned_factory = orb->register_value_factory (vt_graph_factory->tao_repository_id (), vt_graph_factory ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_ASSERT (returned_factory == 0);
+
+ vt_graph_factory->_remove_ref ();
+
+ test_impl * a_test_impl;
+
+ ACE_NEW_RETURN (a_test_impl, test_impl (orb.in ()), 1);
+
+ //PortableServer::ServantBase_var owner_transfer = a_test_impl;
+
+ Supports_Test::test_ptr a_test = a_test_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::String_var ior = orb->object_to_string (a_test ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ 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);
+
+ poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ a_test_impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ root_poa->destroy (0, 0 ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "Server (%P.%t) completed test successfully\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Exception caught:");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}