Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Bug_3768_Regression / client.cpp
blob494c58d05fb1699ee3cb04c21f7e5f623c111ad1
1 #include "TestCallback.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-k <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
32 int
33 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
35 try
37 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
39 CORBA::Object_var poa_object =
40 orb->resolve_initial_references("RootPOA");
42 PortableServer::POA_var root_poa =
43 PortableServer::POA::_narrow (poa_object.in ());
45 if (CORBA::is_nil (root_poa.in ()))
46 ACE_ERROR_RETURN ((LM_ERROR,
47 " (%P|%t) Panic: nil RootPOA\n"),
48 1);
50 PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
52 if (parse_args (argc, argv) != 0)
53 return 1;
55 // Create client callback CORBA object
57 TestCallback *test_impl = 0;
58 ACE_NEW_RETURN (test_impl,
59 TestCallback (orb.in()),
60 1);
61 PortableServer::ServantBase_var owner_transfer(test_impl);
63 PortableServer::ObjectId_var id =
64 root_poa->activate_object (test_impl);
66 CORBA::Object_var object = root_poa->id_to_reference (id.in ());
68 Test::TestCallback_var client = Test::TestCallback::_narrow (object.in ());
70 poa_manager->activate ();
72 // Get server CORBA object and call it
74 CORBA::Object_var tmp = orb->string_to_object(ior);
76 Test::TestServer_var server = Test::TestServer::_narrow(tmp.in ());
78 if (CORBA::is_nil (server.in ()))
80 ACE_ERROR_RETURN ((LM_DEBUG,
81 "Nil Test::TestServer reference <%s>\n",
82 ior),
83 1);
86 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - calling server\n"));
87 server->pass_callback (client.in());
89 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - call failed to block\n"));
91 catch (const CORBA::Exception& ex)
93 ex._tao_print_exception ("Exception caught:");
94 return 1;
97 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - not stopped by server\n"));
98 return 1;