Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / IORInterceptor / client.cpp
blob33e05aca03b7fac695b194c2d20e2faf856728c1
1 // -*- C++ -*-
2 #include "ace/Get_Opt.h"
4 #include "testC.h"
5 #include "FOO_Client_ORBInitializer.h"
7 #include "tao/ORBInitializer_Registry.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;
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "Usage: %s "
26 "-k IOR "
27 "\n",
28 argv[0]),
29 -1);
31 return 0;
34 int
35 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
37 try
39 #if TAO_HAS_INTERCEPTORS == 1
40 PortableInterceptor::ORBInitializer_ptr temp_initializer =
41 PortableInterceptor::ORBInitializer::_nil ();
43 ACE_NEW_RETURN (temp_initializer,
44 FOO_Client_ORBInitializer,
45 -1); // No exceptions yet!
46 PortableInterceptor::ORBInitializer_var orb_initializer =
47 temp_initializer;
49 PortableInterceptor::register_orb_initializer (orb_initializer.in ());
50 #endif /* TAO_HAS_INTERCEPTORS == 1 */
52 CORBA::ORB_var orb =
53 CORBA::ORB_init (argc, argv, "client_orb");
55 if (parse_args (argc, argv) != 0)
56 return 1;
58 CORBA::Object_var obj =
59 orb->string_to_object (ior);
61 FOO::test_var server =
62 FOO::test::_narrow (obj.in ());
64 if (CORBA::is_nil (server.in ()))
66 ACE_ERROR_RETURN ((LM_ERROR,
67 "Object reference <%s> is nil.\n",
68 ior),
69 1);
72 server->shutdown ();
74 orb->destroy ();
76 catch (const CORBA::Exception& ex)
78 ex._tao_print_exception ("IORInterceptor test (client-side):");
79 return -1;
82 return 0;