2 #include "ace/Get_Opt.h"
5 #include "Client_ORBInitializer.h"
7 #include "tao/ORBInitializer_Registry.h"
9 const ACE_TCHAR
*ior1
= 0;
10 const ACE_TCHAR
*ior2
= 0;
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 if (argc
!= 5) // foo -k IOR_1 -k IOR_2
16 ACE_ERROR_RETURN ((LM_ERROR
,
17 "Wrong number of arguments.\n"),
20 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
23 while ((c
= get_opts ()) != -1)
29 ior1
= get_opts
.opt_arg ();
31 ior2
= get_opts
.opt_arg ();
35 ACE_ERROR_RETURN ((LM_ERROR
,
37 "-k IOR_1 -k IOR_2\n",
46 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
52 #if TAO_HAS_INTERCEPTORS == 1
53 PortableInterceptor::ORBInitializer_ptr temp_initializer
=
54 PortableInterceptor::ORBInitializer::_nil ();
56 ACE_NEW_RETURN (temp_initializer
,
57 Client_ORBInitializer
,
58 -1); // No exceptions yet!
59 PortableInterceptor::ORBInitializer_var orb_initializer
=
62 PortableInterceptor::register_orb_initializer (orb_initializer
.in ());
63 #endif /* TAO_HAS_INTERCEPTORS == 1 */
65 CORBA::ORB_var orb
= CORBA::ORB_init (argc
,
69 if (::parse_args (argc
, argv
) != 0)
72 // Start out with the first IOR. Interaction with the second
73 // IOR occurs during the various interceptions executed during
75 CORBA::Object_var object
=
76 orb
->string_to_object (ior1
);
78 ForwardRequestTest::test_var server
=
79 ForwardRequestTest::test::_narrow (object
.in ());
81 if (CORBA::is_nil (server
.in ()))
83 ACE_ERROR_RETURN ((LM_ERROR
,
84 "Object reference <%s> is nil.\n",
89 // Invoke the operation four times. By design, the last three
90 // invocations in this test will cause
91 // PortableInterceptor::ForwardRequest exceptions to be thrown,
92 // thus causing the request to be forwarded to another object.
94 CORBA::Short old_number
= 0; // Previous invocation result.
95 CORBA::Short number
= 0; // New invocation result.
96 for (int i
= 1; i
<= 5; ++i
)
99 "CLIENT: Issuing request %d.\n",
105 number
= server
->number ();
109 "CLIENT: Request %d handled by object %d.\n",
113 // Check if the new result is the same as the previous
116 // This test is designed so that no two sequential
117 // invocation results are the same. If they are the same,
118 // then the requests were invoked on the same object, one
119 // after the other. This means that forwarding did not
120 // occur, which is of course a failure in the
121 // PortableInterceptor::ForwardRequest support.
122 if (i
> 1 && old_number
== number
)
126 ACE_ERROR ((LM_ERROR
,
127 "TEST FAILED: Request was not "
137 catch (const CORBA::Exception
& ex
)
139 ex
._tao_print_exception ("Caught exception:");
145 "PortableInterceptor::ForwardRequest test passed.\n"));