Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_3216_Regression / client.cpp
blob6d70dc6b4e403a9137e59ab4c5d123cec1c94571
1 // Ensure that the PI library is linked in when building statically
2 #include "tao/PI/PI.h"
3 #include "TestC.h"
4 #include "ace/Get_Opt.h"
5 #include "orbsvcs/FaultTolerance/FT_ClientService_Activate.h"
6 #include "Hello.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 CORBA::Boolean result = 0;
41 try
43 int one = 1;
44 char CLIENT[] = "client"; // Copy const into non-const storage.
45 char *argv1[] = { CLIENT, 0 };
47 CORBA::ORB_var orb1 =
48 CORBA::ORB_init (one, argv1, "orb1");
50 int three = 3;
51 char OPTION[] = "-ORBFTSendFullGroupTC"; // Copy const into non-const storage.
52 char VALUE[] = "1"; // Copy const into non-const storage.
53 char *argv2[] = { CLIENT, OPTION, VALUE, 0 };
54 CORBA::ORB_var orb2;
56 try
58 orb2 =
59 CORBA::ORB_init (three, argv2, "orb2");
61 catch (const CORBA::BAD_PARAM&)
63 ACE_DEBUG ((LM_ERROR, "Error - REGRESSION - ORB doesn't even accept the config option\n"));
64 return 1;
67 if (parse_args (argc, argv) != 0)
68 return 1;
70 CORBA::Object_var tmp =
71 orb1->string_to_object (ior);
73 Test::Hello_var hello =
74 Test::Hello::_narrow(tmp.in ());
76 if (CORBA::is_nil (hello.in ()))
78 ACE_ERROR_RETURN ((LM_DEBUG,
79 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
80 ior),
81 1);
84 try
86 hello->check_normal_context ();
88 catch (Test::MyException&)
90 ACE_DEBUG ((LM_ERROR, "Error - REGRESSION - normal format service context not transmitted\n"));
91 result = 1;
95 tmp =
96 orb2->string_to_object (ior);
98 hello =
99 Test::Hello::_narrow(tmp.in ());
101 if (CORBA::is_nil (hello.in ()))
103 ACE_ERROR_RETURN ((LM_DEBUG,
104 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
105 ior),
111 hello->check_extended_context ();
113 catch (const Test::MyException&)
115 ACE_DEBUG ((LM_ERROR, "Error - REGRESSION - extended format service context not transmitted\n"));
116 result = 1;
120 hello->shutdown ();
122 orb1->destroy ();
123 orb2->destroy ();
125 catch (const CORBA::Exception& ex)
127 ex._tao_print_exception (
128 "Test failed (Not regression) because unexpected exception caught:");
129 return 1;
132 if (result)
134 ACE_DEBUG ((LM_ERROR, "Error: REGRESSION identified!!!\n"));
136 else
138 ACE_DEBUG ((LM_DEBUG, "Test passed !!!\n"));
140 return result;