Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Bug_2133 / client.cpp
blob5aba8dd860f5645c162cc87713df50719da6e5aa
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"
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("k:"));
13 int c;
15 while ((c = get_opts ()) != -1)
16 switch (c)
18 case 'k':
19 ior = get_opts.opt_arg ();
20 break;
22 case '?':
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "usage: %s "
26 "-k <ior> "
27 "\n",
28 argv [0]),
29 -1);
31 // Indicates successful parsing of the command line
32 return 0;
35 int
36 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
38 CORBA::ORB_var orb;
40 try
42 PortableInterceptor::ORBInitializer_ptr temp_orb_initializer =
43 PortableInterceptor::ORBInitializer::_nil ();
44 PortableInterceptor::ORBInitializer_var orb_initializer;
46 // Register the ClientRequest_Interceptor ORBInitializer.
47 ACE_NEW_RETURN (temp_orb_initializer,
48 ClientORBInitializer,
49 -1);
51 orb_initializer = temp_orb_initializer;
53 PortableInterceptor::register_orb_initializer (orb_initializer.in ());
55 orb = CORBA::ORB_init (argc, argv);
57 if (parse_args (argc, argv) != 0)
58 return 1;
60 CORBA::Object_var tmp =
61 orb->string_to_object (ior);
63 Test::Hello_var hello =
64 Test::Hello::_narrow(tmp.in ());
66 if (CORBA::is_nil (hello.in ()))
68 ACE_ERROR_RETURN ((LM_DEBUG,
69 "Nil Test::Hello reference <%s>\n",
70 ior),
71 1);
74 ACE_DEBUG ((LM_DEBUG, "Client about to make method call that is doomed to failure...\n"));
76 CORBA::String_var the_string =
77 hello->get_string ();
79 ACE_ERROR_RETURN ((LM_DEBUG,
80 "Error - the remote call succeeded which is bloody miraculous given that no server is running !!\n"),
81 1);
83 orb->destroy ();
85 catch (const CORBA::Exception&)
87 orb->destroy ();
89 if (ClientRequest_Interceptor::success_flag_)
91 ACE_DEBUG ((LM_DEBUG, "Success - the server was unreachable and PI receive_exception was invoked.\n"));
92 return 0;
94 else
96 ACE_ERROR_RETURN ((LM_DEBUG,
97 "Error: regression failed - interceptor receive_exception interception point was not invoked !!\n"),
98 1);
102 return 1;