Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2287_Regression / client.cpp
blob43d8a6a7c1ef64b6f5f77d17c04316568ea1a662
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://test.ior");
12 int
13 parse_args (int argc, ACE_TCHAR *argv[])
15 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
16 int c;
18 while ((c = get_opts ()) != -1)
19 switch (c)
21 case 'k':
22 ior = get_opts.opt_arg ();
23 break;
25 case '?':
26 default:
27 ACE_ERROR_RETURN ((LM_ERROR,
28 "usage: %s "
29 "-k <ior> "
30 "\n",
31 argv [0]),
32 -1);
34 // Indicates successful parsing of the command line
35 return 0;
38 int
39 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
41 CORBA::Boolean result = 0;
42 try
44 CORBA::ORB_var orb =
45 CORBA::ORB_init (argc, argv);
47 if (parse_args (argc, argv) != 0)
48 return 1;
50 CORBA::Object_var tmp =
51 orb->string_to_object(ior);
53 Test::Hello_var hello =
54 Test::Hello::_narrow(tmp.in ());
56 if (CORBA::is_nil (hello.in ()))
58 ACE_ERROR_RETURN ((LM_DEBUG,
59 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
60 ior),
61 1);
64 // Check this isn't generating transients for any other reason
65 hello->ping ();
68 try
70 hello->throw_location_forward ();
72 ACE_DEBUG ((LM_ERROR, "REGRESSION - Test has failed !!!\n"));
73 result = 1;
75 catch (const CORBA::TRANSIENT& my_ex)
77 ACE_UNUSED_ARG (my_ex);
78 ACE_DEBUG ((LM_DEBUG, "Client catches a TRANSIENT, as expected. No problem !\n"));
81 hello->shutdown ();
83 orb->destroy ();
85 catch (const CORBA::Exception& ex)
87 ex._tao_print_exception (
88 "Test failed (Not regression) because unexpected exception caught:");
89 return 1;
92 if (result)
94 ACE_DEBUG ((LM_ERROR, "Error: REGRESSION identified!!!\n"));
96 else
98 ACE_DEBUG ((LM_DEBUG, "Test passed !!!\n"));
100 return result;