Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Bug_3598a_Regression / client.cpp
blobbdd21dc4fca441be111543988c0182260c1e29ec
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
3 #include "tao/PortableInterceptorC.h"
4 #include "ClientORBInitializer.h"
5 #include "tao/ORBInitializer_Registry.h"
6 #include "tao/Strategies/advanced_resource.h"
7 #include "tao/Strategies/OC_Endpoint_Selector_Loader.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;
24 case '?':
25 default:
26 ACE_ERROR_RETURN ((LM_ERROR,
27 "usage: %s "
28 "-k <ior> "
29 "\n",
30 argv [0]),
31 -1);
33 // Indicates successful parsing of the command line
34 return 0;
37 int
38 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
40 int retval = 0;
41 try
43 PortableInterceptor::ORBInitializer_ptr temp_orb_initializer =
44 PortableInterceptor::ORBInitializer::_nil ();
45 PortableInterceptor::ORBInitializer_var orb_initializer;
47 // Register the ClientRequest_Interceptor ORBInitializer.
48 ACE_NEW_RETURN (temp_orb_initializer,
49 ClientORBInitializer,
50 -1);
52 orb_initializer = temp_orb_initializer;
54 PortableInterceptor::register_orb_initializer (orb_initializer.in ());
56 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
58 if (parse_args (argc, argv) != 0)
59 return 1;
61 CORBA::Object_var tmp =
62 orb->string_to_object (ior);
64 Test::Hello_var hello =
65 Test::Hello::_narrow(tmp.in ());
67 if (CORBA::is_nil (hello.in ()))
69 ACE_ERROR_RETURN ((LM_DEBUG,
70 "Nil Test::Hello reference <%s>\n",
71 ior),
72 1);
75 ACE_DEBUG ((LM_DEBUG, "Client about to make method call that is doomed to failure...\n"));
77 bool call_failed = false;
78 try
80 CORBA::String_var the_string =
81 hello->get_string ();
83 catch (const CORBA::Exception&)
85 call_failed = true;
88 if (!call_failed)
90 ACE_ERROR ((LM_ERROR,
91 "Error - the remote call succeeded which is bloody miraculous given that no server is running !!\n"));
92 ++retval;
95 if (ClientRequest_Interceptor::success_flag_)
97 ACE_DEBUG ((LM_DEBUG, "Success - the server was unreachable and PI receive_exception was invoked.\n"));
99 else
101 ACE_ERROR ((LM_DEBUG,
102 "Error: regression failed - interceptor receive_exception interception point was not invoked !!\n"));
103 ++retval;
106 orb->destroy ();
108 catch (const CORBA::Exception& ex)
110 ex._tao_print_exception ("Exception caught:");
111 ++retval;
114 return retval;