Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Bug_1559 / client.cpp
blob50382009f30a8d68d3af1ea6379dd16284b4a760
1 #include "ace/Get_Opt.h"
2 #include "testC.h"
3 #include "Client_ORBInitializer.h"
4 #include "tao/ORBInitializer_Registry.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("ef:"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'e':
18 break;
19 case 'f':
20 ior = get_opts.opt_arg ();
21 break;
22 case '?':
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "usage: %s "
26 "-v "
27 "\n",
28 argv [0]),
29 -1);
31 return 0;
34 void
35 run_test (Test_Interceptors::Visual_ptr server)
38 server->normal (10);
40 ACE_DEBUG ((LM_DEBUG, "\"normal\" operation done\n"));
42 server->nothing ();
44 ACE_DEBUG ((LM_DEBUG, "\"nothing\" operation done\n"));
46 try
48 server->user ();
50 catch (const Test_Interceptors::Silly&)
52 ACE_DEBUG ((LM_DEBUG, "Caught Silly\n"));
55 try
57 server->system ();
59 catch (const CORBA::INV_OBJREF&)
61 ACE_DEBUG ((LM_DEBUG, "Caught CORBA::INV_OBJREF\n"));
65 int
66 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
68 try
70 PortableInterceptor::ORBInitializer_ptr temp_initializer;
72 ACE_NEW_RETURN (temp_initializer,
73 Client_ORBInitializer,
74 -1); // No exceptions yet!
75 PortableInterceptor::ORBInitializer_var initializer =
76 temp_initializer;
78 PortableInterceptor::register_orb_initializer (initializer.in ());
80 CORBA::ORB_var orb =
81 CORBA::ORB_init (argc, argv);
83 if (parse_args (argc, argv) != 0)
84 return 1;
86 CORBA::Object_var object =
87 orb->string_to_object (ior);
89 Test_Interceptors::Visual_var server =
90 Test_Interceptors::Visual::_narrow (object.in ());
92 if (CORBA::is_nil (server.in ()))
94 ACE_ERROR_RETURN ((LM_ERROR,
95 "Object reference <%s> is nil.\n",
96 ior),
97 1);
100 run_test (server.in ());
102 server->shutdown ();
104 orb->destroy ();
106 catch (const CORBA::Exception& ex)
108 ex._tao_print_exception ("Caught exception in client:");
109 return 1;
112 return 0;