Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / IORTable_Locator / client.cpp
blobd5ace201f7719a2803da50f9c4c82bb82a5f9860
1 #include "simple_testC.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/Task.h"
5 const ACE_TCHAR *testIOR = ACE_TEXT ("corbaloc:iiop:localhost:15989/SIMPLE_TEST_KEY");
7 int
8 parse_args (int argc, ACE_TCHAR *argv[])
10 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("a:"));
11 int c;
13 while ((c = get_opts ()) != -1)
14 switch (c)
16 case 'a':
17 testIOR = get_opts.opt_arg ();
18 break;
20 case '?':
21 default:
22 ACE_ERROR_RETURN ((LM_ERROR,
23 "usage: %s "
24 "-a <cobraloc>"
25 "\n",
26 argv [0]),
27 -1);
29 // Indicates successful parsing of the command line
30 return 0;
33 int
34 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
36 try
38 CORBA::ORB_var orb =
39 CORBA::ORB_init (argc, argv, "MY_TEST_ORB");
41 if (parse_args (argc, argv) != 0)
42 return 1;
44 try
46 ACE_DEBUG ((LM_DEBUG,
47 "OK, now try to resolve a remote "
48 "IORTable::Locator entry...\n"));
50 CORBA::Object_var clientObj = orb->string_to_object (testIOR);
52 simple::SimpleTest_T_var simpleTestClient =
53 simple::SimpleTest_T::_narrow (clientObj.in ());
55 if (CORBA::is_nil (simpleTestClient.in ()))
57 ACE_ERROR ((LM_ERROR,
58 "Simpe client is nil!\n"));
59 return 1;
62 ACE_DEBUG ((LM_DEBUG,
63 "We narrowed the object, now let's invoke it!\n"));
65 simpleTestClient->shutdown ();
67 catch(const CORBA::OBJ_ADAPTER &objAdapter)
69 objAdapter._tao_print_exception ("CAUGHT OBJ_ADAPTER!!!");
71 catch(const CORBA::OBJECT_NOT_EXIST &objNE)
73 objNE._tao_print_exception ("CAUGHT OBJECT NOT EXIST!!!");
76 ACE_DEBUG ((LM_DEBUG,
77 "Leaving!\n"));
79 orb->destroy ();
81 catch (const CORBA::Exception &ex)
83 ex._tao_print_exception ("CAUGHT EXCEPTION: ");
84 return -1;
87 return 0;