diff options
Diffstat (limited to 'TAO/tests/Portable_Interceptors/Dynamic/server_interceptor.cpp')
-rw-r--r-- | TAO/tests/Portable_Interceptors/Dynamic/server_interceptor.cpp | 173 |
1 files changed, 140 insertions, 33 deletions
diff --git a/TAO/tests/Portable_Interceptors/Dynamic/server_interceptor.cpp b/TAO/tests/Portable_Interceptors/Dynamic/server_interceptor.cpp index 4f12e95e2d5..222a168df48 100644 --- a/TAO/tests/Portable_Interceptors/Dynamic/server_interceptor.cpp +++ b/TAO/tests/Portable_Interceptors/Dynamic/server_interceptor.cpp @@ -6,32 +6,101 @@ #include "testC.h" #include "ace/Log_Msg.h" -#include "ace/OS_NS_string.h" +#include <cstring> -Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor (void) - : myname_ ("Echo_Server_Interceptor") -{ -} - -Echo_Server_Request_Interceptor::~Echo_Server_Request_Interceptor () +Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor (int& result) + : result_ (result) { } char * -Echo_Server_Request_Interceptor::name (void) +Echo_Server_Request_Interceptor::name () { - return CORBA::string_dup (this->myname_); + return CORBA::string_dup ("Echo_Server_Interceptor"); } void -Echo_Server_Request_Interceptor::destroy (void) +Echo_Server_Request_Interceptor::destroy () { } void Echo_Server_Request_Interceptor::receive_request_service_contexts ( - PortableInterceptor::ServerRequestInfo_ptr) + PortableInterceptor::ServerRequestInfo_ptr ri) { + bool catched_exception = false; + try + { + CORBA::String_var tmdi = ri->target_most_derived_interface (); + } + catch (const ::CORBA::BAD_INV_ORDER& ex) + { + // BAD_INV_ORDER should be thrown with minor code 14 + catched_exception = (ex.minor () == (CORBA::OMGVMCID | 14)); + } + + if (!catched_exception) + { + ++this->result_; + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR, no exception when calling target_most_derived_interface from receive_request_service_contexts\n")); + } + + catched_exception = false; + try + { + CORBA::Boolean const tmdi = ri->target_is_a ("FOO"); + ACE_UNUSED_ARG(tmdi); + } + catch (const ::CORBA::BAD_INV_ORDER& ex) + { + // BAD_INV_ORDER should be thrown with minor code 14 + catched_exception = (ex.minor () == (CORBA::OMGVMCID | 14)); + } + + if (!catched_exception) + { + ++this->result_; + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR, no exception when calling target_is_a from receive_request_service_contexts\n")); + } + + catched_exception = false; + try + { + PortableInterceptor::ReplyStatus const tmdi = ri->reply_status (); + ACE_UNUSED_ARG(tmdi); + } + catch (const ::CORBA::BAD_INV_ORDER& ex) + { + // BAD_INV_ORDER should be thrown with minor code 14 + catched_exception = (ex.minor () == (CORBA::OMGVMCID | 14)); + } + + if (!catched_exception) + { + ++this->result_; + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR, no exception when calling reply_status from receive_request_service_contexts\n")); + } + + catched_exception = false; + try + { + Dynamic::ParameterList_var paramlist = ri->arguments (); + } + catch (const ::CORBA::BAD_INV_ORDER& ex) + { + // BAD_INV_ORDER should be thrown with minor code 14 + catched_exception = (ex.minor () == (CORBA::OMGVMCID | 14)); + } + + if (!catched_exception) + { + ++this->result_; + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR, no exception when calling arguments from receive_request_service_contexts\n")); + } } void @@ -44,13 +113,15 @@ Echo_Server_Request_Interceptor::receive_request ( PortableInterceptor::ReplyStatus rstatus = ri->reply_status (); ACE_UNUSED_ARG (rstatus); } - catch (const ::CORBA::BAD_INV_ORDER&) + catch (const ::CORBA::BAD_INV_ORDER& ex) { - catched_exception = true; + // BAD_INV_ORDER should be thrown with minor code 14 + catched_exception = (ex.minor () == (CORBA::OMGVMCID | 14)); } if (!catched_exception) { + ++this->result_; ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR, no exception when getting reply status\n")); } @@ -61,10 +132,26 @@ Echo_Server_Request_Interceptor::receive_request ( "Echo_Server_Request_Interceptor::receive_request from \"%C\"\n", op.in ())); - if (ACE_OS::strcmp (op.in (), "normal") == 0) + CORBA::Boolean targetisa = ri->target_is_a ("FOO"); + if (targetisa) { - Dynamic::ParameterList_var paramlist = - ri->arguments (); + ++this->result_; + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR in receive_request while checking " + "target_is_a, it is not a FOO\n")); + } + targetisa = ri->target_is_a ("IDL:Test_Interceptors/Visual:1.0"); + if (!targetisa) + { + ++this->result_; + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR in receive_request while checking " + "target_is_a, it should be IDL:Test_Interceptors/Visual:1.0\n")); + } + + if (std::strcmp (op.in (), "normal") == 0) + { + Dynamic::ParameterList_var paramlist = ri->arguments (); CORBA::Long param; CORBA::ULong i = 0; // index -- explicitly used to avoid @@ -79,6 +166,7 @@ Echo_Server_Request_Interceptor::receive_request ( CORBA::TypeCode_var second_typecode = paramlist[i].argument.type (); if (second_typecode->kind () != CORBA::tk_null) { + ++this->result_; ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR in receive_request while checking " "the type of the extracted out" @@ -86,29 +174,52 @@ Echo_Server_Request_Interceptor::receive_request ( } } - CORBA::String_var tmdi = - ri->target_most_derived_interface (); + CORBA::String_var tmdi = ri->target_most_derived_interface (); ACE_DEBUG ((LM_DEBUG, "Target most derived interface: %C\n", tmdi.in ())); + + if (std::strcmp (tmdi.in (), "IDL:Test_Interceptors/Visual:1.0") != 0) + { + ++this->result_; + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR in receive_request while checking " + "target_most_derived_interface\n")); + } + + catched_exception = false; + try + { + PortableInterceptor::ReplyStatus const tmdi = ri->reply_status (); + ACE_UNUSED_ARG(tmdi); + } + catch (const ::CORBA::BAD_INV_ORDER& ex) + { + // BAD_INV_ORDER should be thrown with minor code 14 + catched_exception = (ex.minor () == (CORBA::OMGVMCID | 14)); + } + + if (!catched_exception) + { + ++this->result_; + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR, no exception when calling reply_status from receive_request\n")); + } } void -Echo_Server_Request_Interceptor::send_reply ( - PortableInterceptor::ServerRequestInfo_ptr ri) +Echo_Server_Request_Interceptor::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri) { - CORBA::String_var op = ri->operation (); ACE_DEBUG ((LM_DEBUG, "Echo_Server_Request_Interceptor::send_reply from \"%C\"\n", op.in ())); - if (ACE_OS::strcmp (op.in (), "normal") == 0) + if (std::strcmp (op.in (), "normal") == 0) { - Dynamic::ParameterList_var paramlist = - ri->arguments (); + Dynamic::ParameterList_var paramlist = ri->arguments (); CORBA::Long param; CORBA::ULong i = 0; // index -- explicitly used to avoid @@ -119,10 +230,9 @@ Echo_Server_Request_Interceptor::send_reply ( param)); } - if (ACE_OS::strcmp (op.in (), "calculate") == 0) + if (std::strcmp (op.in (), "calculate") == 0) { - Dynamic::ParameterList_var paramlist = - ri->arguments (); + Dynamic::ParameterList_var paramlist = ri->arguments (); CORBA::Long param1, param2, result = 0; CORBA::ULong i = 0; // index -- explicitly used to avoid @@ -146,7 +256,6 @@ void Echo_Server_Request_Interceptor::send_exception ( PortableInterceptor::ServerRequestInfo_ptr ri) { - CORBA::String_var op = ri->operation (); ACE_DEBUG ((LM_DEBUG, @@ -154,17 +263,15 @@ Echo_Server_Request_Interceptor::send_exception ( "from \"%C\"\n", op.in ())); - - CORBA::Any_var any = - ri->sending_exception (); + CORBA::Any_var any = ri->sending_exception (); CORBA::TypeCode_var type = any->type (); - const char *exception_id = type->id (); + CORBA::String_var exception_id = type->id (); ACE_DEBUG ((LM_DEBUG, "Exception ID = %C\n", - exception_id)); + exception_id.in ())); } void |