1 #include "Supports_Test_impl.h"
3 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
8 parse_args (int argc
, ACE_TCHAR
*argv
[])
10 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("t:i:k:"));
13 while ((c
= get_opts ()) != -1)
17 num_trials
= ACE_OS::atoi (get_opts
.opt_arg ());
21 id
= ACE_OS::atoi (get_opts
.opt_arg ());
25 ior
= get_opts
.opt_arg ();
30 ACE_ERROR_RETURN ((LM_ERROR
,
39 // Indicates successful parsing of the command line
44 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
48 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
50 if (parse_args (argc
, argv
) != 0)
53 CORBA::Object_var poa_object
=
54 orb
->resolve_initial_references ("RootPOA");
56 PortableServer::POA_var root_poa
=
57 PortableServer::POA::_narrow (poa_object
.in ());
59 if (CORBA::is_nil (root_poa
.in ()))
60 ACE_ERROR_RETURN ((LM_ERROR
," (%P|%t) Nil RootPOA\n"), 1);
62 PortableServer::POAManager_var poa_manager
=
63 root_poa
->the_POAManager ();
65 poa_manager
->activate ();
67 /* Create, register factories */
69 Supports_Test::Node_init
* node_factory
= 0;
71 ACE_NEW_RETURN (node_factory
, node_init_impl
, 1);
73 CORBA::ValueFactory returned_factory
=
74 orb
->register_value_factory (node_factory
->tao_repository_id (),
77 ACE_ASSERT (returned_factory
== 0);
79 node_factory
->_remove_ref ();
82 Supports_Test::vt_graph_init
* vt_graph_factory
= 0;
84 ACE_NEW_RETURN (vt_graph_factory
, vt_graph_init_impl
, 1);
87 orb
->register_value_factory (vt_graph_factory
->tao_repository_id (),
90 ACE_ASSERT (returned_factory
== 0);
92 vt_graph_factory
->_remove_ref ();
95 /* Check return values for register_value_factory */
97 Supports_Test::Node_init
* node_factory2
= 0;
99 ACE_NEW_RETURN (node_factory2
, node_init_impl
, 1);
102 orb
->register_value_factory (node_factory2
->tao_repository_id (),
105 ACE_ASSERT (returned_factory
== node_factory
);
107 node_factory2
->_remove_ref ();
110 /* Get test object reference */
112 CORBA::Object_var tmp
= orb
->string_to_object (ior
);
114 Supports_Test::test_var my_test
=
115 Supports_Test::test::_narrow (tmp
.in ());
117 if (CORBA::is_nil (my_test
.in ()))
118 ACE_ERROR_RETURN ((LM_DEBUG
, "Nil Supports_Test::test obj ref <%s>\n", ior
), 1);
124 for (int i
= 0; i
< num_trials
; i
++)
126 // Create a vt_graph_impl instance and store the reference as a
127 // vt_graph_var. Then register the instance with the POA to obtain an
128 // object reference, stored as a graph_var. Increment the reference count
129 // of the vt_graph_impl instance.
130 vt_graph_impl
* the_vt_graph
= 0;
131 ACE_NEW_RETURN (the_vt_graph
, vt_graph_impl (3), 1);
132 Supports_Test::vt_graph_var test_vt_graph
= the_vt_graph
;
134 Supports_Test::graph_var test_graph
=
135 the_vt_graph
->_this ();
136 if (CORBA::is_nil (test_graph
.in ()))
137 ACE_ERROR_RETURN ((LM_DEBUG
, "Nil Supports_Test::graph obj ref\n"), 1);
138 the_vt_graph
->DefaultValueRefCountBase::_add_ref ();
140 // At this point, test_vt_graph and test_graph refer to the same object.
141 ACE_ASSERT (test_vt_graph
->size () == 3);
142 my_test
->pass_vt_graph_in (test_vt_graph
.in ());
143 ACE_ASSERT (test_vt_graph
->size () == 3);
145 ACE_ASSERT (test_graph
->size () == 3);
146 my_test
->pass_obj_graph_in (test_graph
.in ());
147 ACE_ASSERT (test_graph
->size () == 4);
149 test_vt_graph
->add_node ("NEW2");
151 test_graph
->add_node ("NEW3");
153 // After the 'pass_vt_graph_out' call returns, test_vt_graph will refer to
155 ACE_ASSERT (test_vt_graph
->size () == 6);
156 my_test
->pass_vt_graph_out (test_vt_graph
.out ());
157 ACE_ASSERT (test_vt_graph
->size () == 5);
159 // 'test_graph' still refers to the original object, but after the
160 // 'pass_obj_graph_out' call returns, it will refer to a new object,
161 // residing on the server.
162 ACE_ASSERT (test_graph
->size () == 6);
163 my_test
->pass_obj_graph_out (test_graph
.out ());
164 ACE_ASSERT (test_graph
->size () == 5);
166 // test_vt_graph and test_graph now refer to different objects.
167 test_vt_graph
->add_node ("NEW2");
169 test_graph
->add_node ("NEW2");
171 ACE_ASSERT (test_vt_graph
->size () == 6);
172 my_test
->pass_vt_graph_inout (test_vt_graph
.inout ());
173 ACE_ASSERT (test_vt_graph
->size () == 7);
175 ACE_ASSERT (test_graph
->size () == 6);
176 my_test
->pass_obj_graph_inout (test_graph
.inout ());
177 ACE_ASSERT (test_graph
->size () == 7);
186 ACE_DEBUG ((LM_DEBUG
, "Client (%P.%t) completed test successfully\n", id
));
188 catch (const CORBA::Exception
& ex
)
190 ex
._tao_print_exception ("Exception caught:");