Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / FaultTolerance / GroupRef_Manipulation / client.cpp
blobb57c464b174d8ff6ba047b23fea09190a0ca3254
1 // -*- C++ -*-
2 #include "ace/Get_Opt.h"
3 #include "testC.h"
4 // Ensure that the PI library is linked in when building statically
5 #include "tao/PI/PI.h"
6 #include "orbsvcs/FaultTolerance/FT_Service_Activate.h"
8 const ACE_TCHAR *ior = 0;
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;
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "Usage: %s "
26 "-k IOR_1 -k IOR_2\n",
27 argv[0]),
28 -1);
31 return 0;
34 int
35 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
37 int status = 0;
39 try
41 CORBA::ORB_var orb = CORBA::ORB_init (argc,
42 argv,
43 "Client ORB");
45 if (::parse_args (argc, argv) != 0)
46 return -1;
48 // Start out with the first IOR. Interaction with the second
49 // IOR occurs during the various interceptions executed during
50 // this test.
51 CORBA::Object_var object =
52 orb->string_to_object (ior);
54 ForwardRequestTest::test_var server =
55 ForwardRequestTest::test::_narrow (object.in ());
57 // Before and after the LOCATION_FORWARD_PERM the marshaled
58 // object reference must differ.
60 // Create a stringified/marshaled snapshot of Object reference
61 CORBA::String_var marshaled_obj_snapshot1 =
62 orb->object_to_string (server.in ());
64 if (CORBA::is_nil (server.in ()))
66 ACE_ERROR_RETURN ((LM_ERROR,
67 "Object reference <%s> is nil\n",
68 ior),
69 1);
72 CORBA::ULong number = 0;
73 for (int i = 1; i <= 25; ++i)
75 ACE_DEBUG ((LM_INFO,
76 "CLIENT: Issuing request %d.\n",
77 i));
79 number += server->number ();
81 ACE_DEBUG ((LM_INFO,
82 "CLIENT: Number %d .\n",
83 number));
86 if (number < 250)
88 ACE_ERROR ((LM_ERROR,
89 "(%P|%t) ERROR: Did not forward to new location\n"));
90 ACE_OS::abort ();
93 // One of the request triggerd a LOCATION_FORWARD_PERM, in
94 // consequence the marshaled representation of "server" should
95 // look different now, compare to snapshot1.
96 CORBA::String_var marshaled_obj_snapshot2 =
97 orb->object_to_string (server.in ());
99 if (ACE_OS::strcmp (marshaled_obj_snapshot1.in (), marshaled_obj_snapshot2.in ()) == 0)
101 // Error, before and after the marhaled object references look equal
102 ACE_ERROR ((LM_ERROR,
103 "(%P|%t) ERROR: Marshaled Object reference should differ after LOCATION_FORWARD_PERM\n"));
104 ACE_OS::abort ();
107 server->shutdown ();
109 catch (const CORBA::Exception& ex)
111 ex._tao_print_exception ("Caught exception:");
112 return -1;
115 ACE_DEBUG ((LM_INFO,
116 "Group_Ref_Manip Test passed.\n"));
118 return status;