Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_3216_Regression / client.cpp
blob04aab458c3cfb3cd7b1d1e35901552a62931154b
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"
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 int one = 1;
45 char CLIENT[] = "client"; // Copy const into non-const storage.
46 char *argv1[] = { CLIENT, 0 };
48 CORBA::ORB_var orb1 =
49 CORBA::ORB_init (one, argv1, "orb1" );
51 int three = 3;
52 char OPTION[] = "-ORBFTSendFullGroupTC"; // Copy const into non-const storage.
53 char VALUE[] = "1"; // Copy const into non-const storage.
54 char *argv2[] = { CLIENT, OPTION, VALUE, 0 };
55 CORBA::ORB_var orb2;
57 try
59 orb2 =
60 CORBA::ORB_init (three, argv2, "orb2" );
62 catch (const CORBA::BAD_PARAM&)
64 ACE_DEBUG ((LM_ERROR, "Error - REGRESSION - ORB doesn't even accept the config option\n"));
65 return 1;
68 if (parse_args (argc, argv) != 0)
69 return 1;
71 CORBA::Object_var tmp =
72 orb1->string_to_object (ior );
74 Test::Hello_var hello =
75 Test::Hello::_narrow(tmp.in () );
77 if (CORBA::is_nil (hello.in ()))
79 ACE_ERROR_RETURN ((LM_DEBUG,
80 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
81 ior),
82 1);
85 try
87 hello->check_normal_context ();
89 catch (Test::MyException&)
91 ACE_DEBUG ((LM_ERROR, "Error - REGRESSION - normal format service context not transmitted\n"));
92 result = 1;
96 tmp =
97 orb2->string_to_object (ior );
99 hello =
100 Test::Hello::_narrow(tmp.in () );
102 if (CORBA::is_nil (hello.in ()))
104 ACE_ERROR_RETURN ((LM_DEBUG,
105 "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
106 ior),
112 hello->check_extended_context ();
114 catch (const Test::MyException&)
116 ACE_DEBUG ((LM_ERROR, "Error - REGRESSION - extended format service context not transmitted\n"));
117 result = 1;
121 hello->shutdown ();
123 orb1->destroy ();
124 orb2->destroy ();
126 catch (const CORBA::Exception& ex)
128 ex._tao_print_exception (
129 "Test failed (Not regression) because unexpected exception caught:");
130 return 1;
133 if (result)
135 ACE_DEBUG ((LM_ERROR, "Error: REGRESSION identified!!!\n"));
137 else
139 ACE_DEBUG ((LM_DEBUG, "Test passed !!!\n"));
141 return result;