Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2615_Regression / client.cpp
blob03c2aec6daba111a18a305a7ef3df5411a972d5c
1 #include "TestS.h"
2 #include "ace/Get_Opt.h"
3 // Ensure that the PI library is linked in when building statically
4 #include "tao/PI/PI.h"
5 #include "orbsvcs/FaultTolerance/FT_ClientService_Activate.h"
6 #include "Hello.h"
9 const ACE_TCHAR *ior = ACE_TEXT("file://ior.ior");
10 const ACE_TCHAR *iogr = ACE_TEXT("file://iogr.ior");
12 int
13 parse_args (int argc, ACE_TCHAR *argv[])
15 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:l:"));
16 int c;
18 while ((c = get_opts ()) != -1)
19 switch (c)
21 case 'k':
22 ior = get_opts.opt_arg ();
23 break;
24 case 'l':
25 iogr = get_opts.opt_arg ();
26 break;
27 case '?':
28 default:
29 ACE_ERROR_RETURN ((LM_ERROR,
30 "usage: %s "
31 "-k <ior> "
32 "-l <iogr> "
33 "\n",
34 argv [0]),
35 -1);
37 // Indicates successful parsing of the command line
38 return 0;
41 int
42 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
44 CORBA::Boolean result = 0;
45 try
47 CORBA::ORB_var orb =
48 CORBA::ORB_init (argc, argv);
50 if (parse_args (argc, argv) != 0)
51 return 1;
53 // First perform the test with an IOR
54 CORBA::Object_var tmp =
55 orb->string_to_object(ior);
57 Test::Hello_var hello =
58 Test::Hello::_narrow(tmp.in ());
60 if (CORBA::is_nil (hello.in ()))
62 ACE_ERROR_RETURN ((LM_DEBUG,
63 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
64 ior),
65 1);
68 // Check this isn't generating exceptions for any other reason
69 hello->ping ();
71 if (hello->has_ft_request_service_context ())
73 ACE_DEBUG ((LM_ERROR, "ERROR - REGRESSION - Request made on a plain IOR has a FT_REQUEST service context.\n" ));
74 result = 1;
76 else
78 ACE_DEBUG ((LM_DEBUG, "Request made on a plain IOR has no FT_REQUEST service context. This is OK.\n" ));
81 // Now repeat the test (for the converse result) with an IOGR
82 tmp =
83 orb->string_to_object(iogr);
85 hello =
86 Test::Hello::_narrow(tmp.in ());
88 if (CORBA::is_nil (hello.in ()))
90 ACE_ERROR_RETURN ((LM_DEBUG,
91 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
92 iogr),
93 1);
96 // Check this isn't generating transients for any other reason
97 hello->ping ();
99 if (! hello->has_ft_request_service_context ())
101 ACE_DEBUG ((LM_ERROR, "ERROR - REGRESSION - Request made on an IOGR has no FT_REQUEST service context.\n" ));
102 result = 1;
104 else
106 ACE_DEBUG ((LM_DEBUG, "Request made on an IOGR has a FT_REQUEST service context. This is OK.\n" ));
109 hello->shutdown ();
111 orb->destroy ();
113 catch (const CORBA::Exception& ex)
115 ex._tao_print_exception (
116 "Test failed (Not regression) because unexpected exception caught:");
117 return 1;
120 if (result)
122 ACE_DEBUG ((LM_ERROR, "Error: REGRESSION identified!!!\n"));
124 else
126 ACE_DEBUG ((LM_DEBUG, "Test passed !!!\n"));
128 return result;