Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2615_Regression / client.cpp
bloba70b3b6b156b5b207e6029303539b6cb4397ceaf
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"
10 const ACE_TCHAR *ior = ACE_TEXT("file://ior.ior");
11 const ACE_TCHAR *iogr = ACE_TEXT("file://iogr.ior");
13 int
14 parse_args (int argc, ACE_TCHAR *argv[])
16 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:l:"));
17 int c;
19 while ((c = get_opts ()) != -1)
20 switch (c)
22 case 'k':
23 ior = get_opts.opt_arg ();
24 break;
25 case 'l':
26 iogr = get_opts.opt_arg ();
27 break;
28 case '?':
29 default:
30 ACE_ERROR_RETURN ((LM_ERROR,
31 "usage: %s "
32 "-k <ior> "
33 "-l <iogr> "
34 "\n",
35 argv [0]),
36 -1);
38 // Indicates successful parsing of the command line
39 return 0;
42 int
43 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
45 CORBA::Boolean result = 0;
46 try
48 CORBA::ORB_var orb =
49 CORBA::ORB_init (argc, argv);
51 if (parse_args (argc, argv) != 0)
52 return 1;
54 // First perform the test with an IOR
55 CORBA::Object_var tmp =
56 orb->string_to_object(ior);
58 Test::Hello_var hello =
59 Test::Hello::_narrow(tmp.in ());
61 if (CORBA::is_nil (hello.in ()))
63 ACE_ERROR_RETURN ((LM_DEBUG,
64 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
65 ior),
66 1);
69 // Check this isn't generating exceptions for any other reason
70 hello->ping ();
72 if (hello->has_ft_request_service_context ())
74 ACE_DEBUG ((LM_ERROR, "ERROR - REGRESSION - Request made on a plain IOR has a FT_REQUEST service context.\n" ));
75 result = 1;
77 else
79 ACE_DEBUG ((LM_DEBUG, "Request made on a plain IOR has no FT_REQUEST service context. This is OK.\n" ));
82 // Now repeat the test (for the converse result) with an IOGR
83 tmp =
84 orb->string_to_object(iogr);
86 hello =
87 Test::Hello::_narrow(tmp.in ());
89 if (CORBA::is_nil (hello.in ()))
91 ACE_ERROR_RETURN ((LM_DEBUG,
92 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
93 iogr),
94 1);
97 // Check this isn't generating transients for any other reason
98 hello->ping ();
100 if (! hello->has_ft_request_service_context ())
102 ACE_DEBUG ((LM_ERROR, "ERROR - REGRESSION - Request made on an IOGR has no FT_REQUEST service context.\n" ));
103 result = 1;
105 else
107 ACE_DEBUG ((LM_DEBUG, "Request made on an IOGR has a FT_REQUEST service context. This is OK.\n" ));
110 hello->shutdown ();
112 orb->destroy ();
114 catch (const CORBA::Exception& ex)
116 ex._tao_print_exception (
117 "Test failed (Not regression) because unexpected exception caught:");
118 return 1;
121 if (result)
123 ACE_DEBUG ((LM_ERROR, "Error: REGRESSION identified!!!\n"));
125 else
127 ACE_DEBUG ((LM_DEBUG, "Test passed !!!\n"));
129 return result;