Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Service_Context_Manipulation / client.cpp
blob1fe2ff983db5e62f9228ea7b244e28671cbc6a86
1 #include "ace/Get_Opt.h"
2 #include "testC.h"
3 #include "Client_ORBInitializer.h"
5 #include "tao/ORBInitializer_Registry.h"
7 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
9 int
10 parse_args (int argc, ACE_TCHAR *argv[])
12 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("ef:"));
13 int c;
15 while ((c = get_opts ()) != -1)
16 switch (c)
18 case 'e':
19 break;
20 case 'f':
21 ior = get_opts.opt_arg ();
22 break;
23 case '?':
24 default:
25 ACE_ERROR_RETURN ((LM_ERROR,
26 "usage: %s "
27 "-v "
28 "\n",
29 argv [0]),
30 -1);
32 return 0;
35 void
36 run_test (Test_Interceptors::Visual_ptr server)
39 server->normal (10);
41 ACE_DEBUG ((LM_DEBUG, "\"normal\" operation done\n"));
43 server->nothing ();
45 ACE_DEBUG ((LM_DEBUG, "\"nothing\" operation done\n"));
47 try
49 server->user ();
51 catch (const Test_Interceptors::Silly&)
53 ACE_DEBUG ((LM_DEBUG, "Caught Silly\n"));
56 try
58 server->system ();
60 catch (const CORBA::INV_OBJREF&)
62 ACE_DEBUG ((LM_DEBUG, "Caught CORBA::INV_OBJREF\n"));
66 int
67 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
69 try
71 PortableInterceptor::ORBInitializer_ptr temp_initializer;
73 ACE_NEW_RETURN (temp_initializer,
74 Client_ORBInitializer,
75 -1); // No exceptions yet!
76 PortableInterceptor::ORBInitializer_var initializer =
77 temp_initializer;
79 PortableInterceptor::register_orb_initializer (initializer.in ());
81 CORBA::ORB_var orb =
82 CORBA::ORB_init (argc, argv);
84 if (parse_args (argc, argv) != 0)
85 return 1;
87 CORBA::Object_var object =
88 orb->string_to_object (ior);
90 Test_Interceptors::Visual_var server =
91 Test_Interceptors::Visual::_narrow (object.in ());
93 if (CORBA::is_nil (server.in ()))
95 ACE_ERROR_RETURN ((LM_ERROR,
96 "Object reference <%s> is nil.\n",
97 ior),
98 1);
101 run_test (server.in ());
103 server->shutdown ();
105 orb->destroy ();
107 catch (const CORBA::Exception& ex)
109 ex._tao_print_exception ("Caught exception in client:");
110 return 1;
113 return 0;