Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / COIOP / COIOP_Simple_Test.cpp
blob40d2d5cb29617c1a199f45c6ec429aa697e8f827
1 #include "ace/Get_Opt.h"
2 #include "Hello.h"
3 #include "tao/Strategies/advanced_resource.h"
5 int
6 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
8 try
10 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Before creating ORB\n"));
12 CORBA::ORB_var orb =
13 CORBA::ORB_init (argc, argv);
15 CORBA::Object_var poa_object =
16 orb->resolve_initial_references("RootPOA");
18 PortableServer::POA_var root_poa =
19 PortableServer::POA::_narrow (poa_object.in ());
21 if (CORBA::is_nil (root_poa.in ()))
22 ACE_ERROR_RETURN ((LM_ERROR,
23 " (%P|%t) Panic: nil RootPOA\n"),
24 1);
26 PortableServer::POAManager_var poa_manager =
27 root_poa->the_POAManager ();
29 Hello *hello_impl = 0;
30 ACE_NEW_RETURN (hello_impl,
31 Hello (orb.in (),
32 0),
33 1);
35 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Activating servant\n"));
37 PortableServer::ServantBase_var owner_transfer(hello_impl);
39 PortableServer::ObjectId_var id =
40 root_poa->activate_object (hello_impl);
42 CORBA::Object_var object = root_poa->id_to_reference (id.in ());
44 Test::Hello_var hello =
45 Test::Hello::_narrow (object.in ());
47 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Activating POA Manager\n"));
49 poa_manager->activate ();
51 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Activated POA Manager\n"));
53 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Doing direct call\n"));
55 CORBA::String_var the_string_d =
56 hello->get_string ();
58 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
59 the_string_d.in ()));
61 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Object to string\n"));
63 CORBA::String_var ior =
64 orb->object_to_string (hello.in ());
66 CORBA::Object_var tmp =
67 orb->string_to_object (ior.in ());
69 Test::Hello_var hello_ref =
70 Test::Hello::_narrow(tmp.in ());
72 if (CORBA::is_nil (hello_ref.in ()))
74 ACE_ERROR_RETURN ((LM_DEBUG,
75 "Nil Test::Hello reference <%s>\n",
76 ior.in ()),
77 1);
80 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Going to call method\n"));
82 CORBA::String_var the_string =
83 hello_ref->get_string ();
85 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
86 the_string.in ()));
88 orb->destroy ();
90 catch (const CORBA::Exception&)
92 // Ignore exceptions..
94 return 0;