Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / TransportCurrent / IIOP / IIOP_Tester.cpp
blobfc92ac1c7e0945d2fee21aba7e3cae4936d690a9
1 // -*- C++ -*-
2 #include "tao/TransportCurrent/IIOP_Transport_Current.h"
3 #include "tao/SystemException.h"
5 #if defined (TAO_AS_STATIC_LIBS)
6 #include "tao/TransportCurrent/IIOP_Current_Loader.h"
8 // Create an object that will insert the <Current_Loader> into the
9 // list of statically linked services that the <ACE_Service_Config>
10 // will initialize at run-time.
11 ACE_STATIC_SVC_REQUIRE (TAO_Transport_Current_Loader)
12 ACE_STATIC_SVC_REQUIRE (TAO_Transport_IIOP_Current_Loader)
13 #endif /* TAO_AS_STATIC_LIBS */
15 using namespace TAO;
17 /// Test referencing the TC data outside of the context of an upcall,
18 /// or a client-side interceptor
20 int
21 test_transport_current (CORBA::ORB_ptr orb)
23 // Get the Current object.
24 CORBA::Object_var tcobject =
25 orb->resolve_initial_references ("TAO::Transport::IIOP::Current");
27 if (TAO_debug_level >= 1)
28 ACE_DEBUG ((LM_DEBUG,
29 ACE_TEXT ("Tester (%P|%t) Resolved initial reference for IIOP::Current\n")));
31 Transport::IIOP::Current_var tc =
32 Transport::IIOP::Current::_narrow (tcobject.in ());
34 if (TAO_debug_level >= 1)
35 ACE_DEBUG ((LM_DEBUG,
36 ACE_TEXT ("Tester (%P|%t) Narowed the IIOP Transport Current\n")));
38 if (CORBA::is_nil (tc.in ()))
40 ACE_ERROR ((LM_ERROR,
41 ACE_TEXT ("Tester (%P|%t) ERROR: Could not resolve ")
42 ACE_TEXT ("TAO::Transport::IIOP::Current object.\n")));
44 throw CORBA::INTERNAL ();
47 ::CORBA::String_var rhost (tc->remote_host ());
49 ::CORBA::String_var lhost (tc->local_host ());
51 ::CORBA::Long id = tc->id ();
53 ::TAO::CounterT bs = tc->bytes_sent ();
55 ::TAO::CounterT br = tc->bytes_received ();
57 ::TAO::CounterT rs = tc->messages_sent ();
59 ::TAO::CounterT rr = tc->messages_received ();
61 ACE_DEBUG ((LM_DEBUG,
62 ACE_TEXT ("Tester (%P|%t) Transport [%q] [%C:%d -> %C:%d] ")
63 ACE_TEXT ("Sent/Received [bytes=%q/%q, messages=%q/%q]\n"),
64 (ACE_UINT64)id,
65 rhost.in (), tc->remote_port (),
66 lhost.in (), tc->local_port (),
67 (ACE_UINT64)bs,
68 (ACE_UINT64)br,
69 (ACE_UINT64)rs,
70 (ACE_UINT64)rr));
71 return 0;