Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / POA / On_Demand_Act_Direct_Coll / Client_Task.cpp
blobc016fbdee32447e40ae42f3d0b070bff6c788a27
1 #include "Client_Task.h"
2 #include "testC.h"
4 Client_Task::Client_Task (const ACE_TCHAR *ior,
5 CORBA::ORB_ptr corb,
6 ACE_Thread_Manager *thr_mgr,
7 CORBA::Boolean except)
8 : ACE_Task_Base (thr_mgr)
9 , input_ (ior)
10 , corb_ (CORBA::ORB::_duplicate (corb))
11 , except_ (except)
15 int
16 Client_Task::svc ()
18 int status = 0;
19 try
21 // Get an object reference from the argument string.
22 CORBA::Object_var tmp =
23 this->corb_->string_to_object (input_);
25 // Try to narrow the object reference to a test reference.
26 test_var test = test::_narrow (tmp.in ());
27 if (CORBA::is_nil (test.in ()))
29 ACE_ERROR_RETURN ((LM_DEBUG,
30 "Nil Test::Hello reference <%s>\n",
31 input_),
32 1);
35 CORBA::String_var ior =
36 this->corb_->object_to_string (test.in ());
38 ACE_DEBUG ((LM_DEBUG,
39 "\nConnecting to: %C\n\n",
40 ior.in ()));
41 try
43 CORBA::String_var the_string = test->get_string ();
44 if (ACE_OS::strcmp (the_string.in (), "Hello there!") != 0)
46 ACE_ERROR ((LM_ERROR, "(%P|%t) - Error, incorrect string returned <%C>\n",
47 the_string.in ()));
49 else
51 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - OK , correct string returned <%C>\n",
52 the_string.in ()));
55 catch (const CORBA::INTERNAL&)
57 if (this->except_)
59 ACE_DEBUG ((LM_DEBUG,
60 "OK: Client_Task Expected excep with "
61 "direct collocation received\n"));
62 status = 0;
64 else
66 ACE_ERROR ((LM_ERROR,
67 "ERROR: Client_Task Unxpected exception with"
68 "thru_poa collocation received\n"));
69 status = 1;
71 corb_->destroy ();
72 return 1;
75 catch (const CORBA::Exception& ex)
77 ex._tao_print_exception ("Exception caught:");
78 status = 1;
80 corb_->destroy ();
81 return status;