Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2285_Regression / client.cpp
bloba0b18143cae3f8cd1a119cd92391236e07d76983
1 #include "TestS.h"
2 #include "ace/Get_Opt.h"
3 // Ensure that the PI library is linked in when building statically
4 #include "tao/PI/PI.h"
5 #include "orbsvcs/FaultTolerance/FT_ClientService_Activate.h"
6 #include "Hello.h"
9 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
11 int
12 parse_args (int argc, ACE_TCHAR *argv[])
14 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
15 int c;
17 while ((c = get_opts ()) != -1)
18 switch (c)
20 case 'k':
21 ior = get_opts.opt_arg ();
22 break;
24 case '?':
25 default:
26 ACE_ERROR_RETURN ((LM_ERROR,
27 "usage: %s "
28 "-k <ior> "
29 "\n",
30 argv [0]),
31 -1);
33 // Indicates successful parsing of the command line
34 return 0;
37 int
38 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
40 CORBA::Boolean result = 0;
41 try
43 CORBA::ORB_var orb =
44 CORBA::ORB_init (argc, argv);
46 if (parse_args (argc, argv) != 0)
47 return 1;
49 CORBA::Object_var tmp =
50 orb->string_to_object(ior);
52 Test::Hello_var hello =
53 Test::Hello::_narrow(tmp.in ());
55 if (CORBA::is_nil (hello.in ()))
57 ACE_ERROR_RETURN ((LM_DEBUG,
58 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
59 ior),
60 1);
63 CORBA::Object_var poa_object =
64 orb->resolve_initial_references("RootPOA");
66 PortableServer::POA_var root_poa =
67 PortableServer::POA::_narrow (poa_object.in ());
69 if (CORBA::is_nil (root_poa.in ()))
70 ACE_ERROR_RETURN ((LM_ERROR,
71 " (%P|%t) Test failed - Not regression - unexpected nil RootPOA\n"),
72 1);
74 PortableServer::POAManager_var poa_manager =
75 root_poa->the_POAManager ();
77 if (parse_args (argc, argv) != 0)
78 return 1;
80 Hello *hello_impl;
81 ACE_NEW_RETURN (hello_impl,
82 Hello (orb.in (), hello.in ()),
83 1);
84 PortableServer::ServantBase_var owner_transfer(hello_impl);
86 Test::Hello_var me =
87 hello_impl->_this ();
89 poa_manager->activate ();
91 try
93 hello->throw_exception ();
95 catch (const Test::MyException& my_ex)
97 ACE_UNUSED_ARG (my_ex);
98 ACE_DEBUG ((LM_DEBUG, "Client catches a MyException, as expected. No problem !\n"));
101 result = ! hello->call_me_back (me.in ());
103 hello->shutdown ();
105 orb->destroy ();
107 catch (const CORBA::Exception& ex)
109 ex._tao_print_exception (
110 "Test failed (Not regression) because unexpected exception caught:");
111 return 1;
114 if (result)
116 ACE_DEBUG ((LM_ERROR, "Error: REGRESSION identified!!!\n"));
118 else
120 ACE_DEBUG ((LM_DEBUG, "Test passed !!!\n"));
122 return result;