Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / RTCORBA / Server_Protocol / client.cpp
blobfe72f82d57ebb664edafb544bb8b66986a7f77df
1 #include "testC.h"
2 #include "ace/Get_Opt.h"
3 #include "tao/RTCORBA/RTCORBA.h"
4 #include "tao/Strategies/advanced_resource.h"
6 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
8 int
9 parse_args (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'k':
18 ior = get_opts.opt_arg ();
19 break;
20 case '?':
21 default:
22 ACE_ERROR_RETURN ((LM_ERROR,
23 "usage: %s "
24 "-k <ior> "
25 "\n",
26 argv [0]),
27 -1);
30 return 0;
33 int
34 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
36 try
38 // Initialize and obtain reference to the Test object.
39 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
41 if (parse_args (argc, argv) != 0)
42 return -1;
44 CORBA::Object_var object = orb->string_to_object (ior);
46 Test_var server = Test::_narrow (object.in ());
48 if (CORBA::is_nil (server.in ()))
50 ACE_ERROR_RETURN ((LM_ERROR,
51 "ERROR: Object reference <%s> is nil\n",
52 ior),
53 -1);
56 // Make an invocation on the obtained Test object.
57 server->shutdown ();
59 catch (const CORBA::Exception& ex)
61 ex._tao_print_exception ("Caught exception:");
62 return -1;
65 return 0;