Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_3598b_Regression / client.cpp
blob58d437c5f68fb815a258e7d2822c4dc4bcc8acfc
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 "orbsvcs/FaultTolerance/FT_ClientService_Activate.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 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 CORBA::ORB_var 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 catch (const CORBA::Exception&)
85 if (ClientRequest_Interceptor::success_flag_)
87 ACE_DEBUG ((LM_DEBUG, "Success - the server was unreachable and PI receive_exception was invoked.\n"));
88 return 0;
90 else
92 ACE_ERROR_RETURN ((LM_DEBUG,
93 "Error: regression failed - interceptor receive_exception interception point was not invoked !!\n"),
94 1);
98 return 1;