1 #include "SharedIntfC.h"
2 #include "SharedIntfS.h"
4 #include "ace/SString.h"
5 #include "ace/Get_Opt.h"
7 #include "ace/OS_NS_unistd.h"
8 #include "ace/OS_NS_time.h"
10 Test_Idl::SharedIntf_var intf
;
12 ACE_Time_Value
upcall_start (0,0);
13 ACE_Time_Value
upcall_end (0,0);
14 ACE_Time_Value
ping_start (0,0);
15 ACE_Time_Value
ping_end (0,0);
17 class SharedIntfCB
: public POA_Test_Idl::AMI_SharedIntfHandler
22 ACE_DEBUG ((LM_DEBUG
, "ping returned\n"));
23 ping_end
= ping_end
.now ();
26 void ping_excep (::Messaging::ExceptionHolder
* )
28 ACE_DEBUG ((LM_DEBUG
, "exception caught on ping req\n"));
29 ping_end
= ping_end
.now ();
34 ACE_DEBUG ((LM_DEBUG
, "upcall returned\n"));
35 upcall_end
= upcall_end
.now ();
38 void do_upcall_excep (::Messaging::ExceptionHolder
* excep
)
42 excep
->raise_exception ();
44 catch (const CORBA::Exception
&)
47 ACE_DEBUG ((LM_DEBUG
, "exception caught on upcall req\n"));
48 upcall_end
= upcall_end
.now ();
54 parse_args (int argc
, ACE_TCHAR
*argv
[])
56 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("t:"));
59 while ((c
= get_opts ()) != -1)
64 ACE_ERROR_RETURN ((LM_ERROR
,
71 // Indicates successful parsing of the command line
76 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
83 ACE_DEBUG((LM_INFO
,"(%P|%t) START OF CLIENT TEST\n"));
85 orb_
= CORBA::ORB_init (argc
, argv
);
87 if (parse_args (argc
, argv
) != 0)
90 CORBA::Object_var obj
= orb_
->resolve_initial_references ("RootPOA");
91 PortableServer::POA_var root_poa
=
92 PortableServer::POA::_narrow (obj
.in());
94 PortableServer::POAManager_var poa_manager
=
95 root_poa
->the_POAManager ();
96 PortableServer::POA_var poa
= root_poa
;
98 poa_manager
->activate ();
100 PortableServer::ServantBase_var cb_serv
= new SharedIntfCB
;
101 PortableServer::ObjectId_var oid
= root_poa
->activate_object (cb_serv
.in());
102 obj
= root_poa
->id_to_reference (oid
.in());
104 Test_Idl::AMI_SharedIntfHandler_var cb
=
105 Test_Idl::AMI_SharedIntfHandler::_narrow (obj
.in());
107 obj
= orb_
->string_to_object ("file://server.ior");
108 intf
= Test_Idl::SharedIntf::_narrow(obj
.in());
110 ACE_DEBUG((LM_INFO
,"(%P|%t) invoking async upcall.\n"));
112 upcall_start
= upcall_start
.now ();
113 intf
->sendc_do_upcall (cb
.in());
114 ACE_DEBUG((LM_INFO
,"(%P|%t) invoking ping\n"));
116 ping_start
= ping_start
.now ();
118 ACE_DEBUG((LM_INFO
,"(%P|%t) sync ping returned\n"));
119 ping_end
= ping_end
.now ();
121 result
= (upcall_end
> ACE_Time_Value::zero
&& upcall_end
<= ping_end
) ? 0 : 1;
124 intf
= Test_Idl::SharedIntf::_nil ();
127 ACE_DEBUG ((LM_INFO
,"(%P|%t) Client Test %C\n",
128 (result
== 0 ? "succeeded":"failed")));
130 catch (const CORBA::Exception
& ex
)
132 ex
._tao_print_exception ("Error: Exception caught:");