Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / Collocation_Exception_Test / Client_Task.cpp
blobb7f91b5c88e4e68d9bce3118d05c8ad036108636
2 #include "Client_Task.h"
4 Client_Task::Client_Task (const ACE_TCHAR *ior,
5 CORBA::ORB_ptr corb,
6 ACE_Thread_Manager *thr_mgr)
7 : ACE_Task_Base (thr_mgr)
8 , input_ (ior)
9 , corb_ (CORBA::ORB::_duplicate (corb))
13 void
14 Client_Task::test_system_exception (
15 Test::Hello_ptr hello_ptr)
17 try
19 hello_ptr->system_exception_test ();
21 catch (const CORBA::INTERNAL& )
23 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Caught internal exception as expected\n"));
24 // ignore
26 catch (const CORBA::Exception& ex)
28 ex._tao_print_exception (
29 "Unexpected exception caught in test_system_exception:");
30 throw;
34 void
35 Client_Task::test_user_exception_expected (
36 Test::Hello_ptr hello_ptr)
38 try
40 hello_ptr->user_exception_expected ();
42 catch (const ::Test::Hello::A& )
44 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Caught user A exception as expected\n"));
45 // ignore
47 catch (const CORBA::Exception& ex)
49 ex._tao_print_exception (
50 "Unexpected exception caught in test_user_exception_expected:");
51 throw;
55 void
56 Client_Task::test_user_exception_not_expected (
57 Test::Hello_ptr hello_ptr)
59 try
61 hello_ptr->user_exception_not_expected ();
63 catch (const CORBA::UNKNOWN& ex)
65 if ((ex.minor() & 0xFFFU) == 1)
67 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Caught unknown exception as expected\n"));
69 else
71 ex._tao_print_exception (
72 "Unexpected exception caught in user_exception_not_expected:");
73 throw;
75 // ignore
77 catch (const CORBA::Exception& ex)
79 ex._tao_print_exception (
80 "Unexpected exception caught in user_exception_not_expected:");
81 throw;
85 int
86 Client_Task::svc ()
88 try
90 CORBA::Object_var tmp = this->corb_->string_to_object (input_);
92 Test::Hello_var hello = Test::Hello::_narrow(tmp.in ());
94 if (CORBA::is_nil (hello.in ()))
96 ACE_ERROR_RETURN ((LM_DEBUG,
97 "Nil Test::Hello reference <%s>\n",
98 input_),
99 1);
102 CORBA::String_var the_string = hello->get_string ();
104 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
105 the_string.in ()));
107 this->test_system_exception (hello.in ());
109 this->test_user_exception_expected (hello.in ());
111 this->test_user_exception_not_expected (hello.in ());
113 hello->shutdown ();
115 catch (const CORBA::Exception& ex)
117 ex._tao_print_exception ("Exception caught:");
118 return 1;
121 return 0;