Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Bug_1559 / client.cpp
blob2c332e94e2b163d9c0b68e4229ceec73ebad4c5e
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)
37 server->normal (10);
39 ACE_DEBUG ((LM_DEBUG, "\"normal\" operation done\n"));
41 server->nothing ();
43 ACE_DEBUG ((LM_DEBUG, "\"nothing\" operation done\n"));
45 try
47 server->user ();
49 catch (const Test_Interceptors::Silly&)
51 ACE_DEBUG ((LM_DEBUG, "Caught Silly\n"));
54 try
56 server->system ();
58 catch (const CORBA::INV_OBJREF&)
60 ACE_DEBUG ((LM_DEBUG, "Caught CORBA::INV_OBJREF\n"));
64 int
65 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
67 try
69 PortableInterceptor::ORBInitializer_ptr temp_initializer;
71 ACE_NEW_RETURN (temp_initializer,
72 Client_ORBInitializer,
73 -1); // No exceptions yet!
74 PortableInterceptor::ORBInitializer_var initializer =
75 temp_initializer;
77 PortableInterceptor::register_orb_initializer (initializer.in ());
79 CORBA::ORB_var orb =
80 CORBA::ORB_init (argc, argv);
82 if (parse_args (argc, argv) != 0)
83 return 1;
85 CORBA::Object_var object =
86 orb->string_to_object (ior);
88 Test_Interceptors::Visual_var server =
89 Test_Interceptors::Visual::_narrow (object.in ());
91 if (CORBA::is_nil (server.in ()))
93 ACE_ERROR_RETURN ((LM_ERROR,
94 "Object reference <%s> is nil.\n",
95 ior),
96 1);
99 run_test (server.in ());
101 server->shutdown ();
103 orb->destroy ();
105 catch (const CORBA::Exception& ex)
107 ex._tao_print_exception ("Caught exception in client:");
108 return 1;
111 return 0;