2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_unistd.h"
6 #include "ClientORBInitializer.h"
8 #include "tao/ORBInitializer_Registry.h"
11 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
14 parse_args (int argc
, ACE_TCHAR
*argv
[])
16 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
19 while ((c
= get_opts ()) != -1)
23 ior
= get_opts
.opt_arg ();
26 ACE_ERROR_RETURN ((LM_ERROR
,
37 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
41 PortableInterceptor::ORBInitializer_ptr temp_initializer
=
42 PortableInterceptor::ORBInitializer::_nil ();
44 ACE_NEW_RETURN (temp_initializer
,
46 -1); // No exceptions yet!
47 PortableInterceptor::ORBInitializer_var orb_initializer
=
50 PortableInterceptor::register_orb_initializer (orb_initializer
.in ());
53 CORBA::ORB_init (argc
,
57 if (parse_args (argc
, argv
) != 0)
60 // Get the PICurrent object.
61 CORBA::Object_var obj
=
62 orb
->resolve_initial_references ("PICurrent");
64 PortableInterceptor::Current_var pi_current
=
65 PortableInterceptor::Current::_narrow (obj
.in ());
67 if (CORBA::is_nil (pi_current
.in ()))
69 ACE_ERROR_RETURN ((LM_ERROR
,
70 "(%P|%t) ERROR: Could not resolve "
71 "PICurrent object.\n"),
75 // Insert some data into the allocated PICurrent slot.
77 CORBA::Long number
= 46;
81 // Now reset the contents of our slot in the thread-scope
83 pi_current
->set_slot (::slot_id
,
86 // Resolve the target object, and perform the invocation.
88 orb
->string_to_object (ior
);
90 PICurrentTest::test_var server
=
91 PICurrentTest::test::_narrow (obj
.in ());
93 if (CORBA::is_nil (server
.in ()))
95 ACE_ERROR_RETURN ((LM_ERROR
,
96 "Object reference <%s> is nil.\n",
101 // BUG 2656 testing - _get_policy_overrides() should return an empty
102 // sequence rather than nill.
103 CORBA::PolicyTypeSeq types
;
104 CORBA::PolicyList_var policies
= server
->_get_policy_overrides(types
);
106 if (policies
.ptr () == 0)
108 ACE_ERROR ((LM_ERROR
,
109 "(%P|%t) _get_policy_overrides returned nill pointer\n"));
110 throw CORBA::INTERNAL ();
114 CORBA::ULong
const list_size
= policies
->length();
117 ACE_ERROR ((LM_ERROR
,
118 "(%P|%t) _get_policy_overrides returned list with size not equal 0\n"));
119 throw CORBA::INTERNAL ();
123 server
->invoke_me ();
125 CORBA::Any_var new_data
=
126 pi_current
->get_slot (::slot_id
);
128 // The original data in the TSC was of type CORBA::Long. If the
129 // following extraction from the CORBA::Any fails, then the
130 // original data in the TSC was not replaced within the client
131 // request interceptor, as this test should do.
133 if (new_data
.in () >>= str
)
135 ACE_DEBUG ((LM_DEBUG
,
136 "(%P|%t) Retrieved \"%C\" from the TSC.\n",
141 ACE_ERROR ((LM_ERROR
,
142 "(%P|%t) Unable to extract data (a string) "
145 throw CORBA::INTERNAL ();
148 server
->invoke_we ();
155 catch (const CORBA::Exception
& ex
)
157 ex
._tao_print_exception ("PICurrent test (client-side):");