Skip to content

Commit

Permalink
Merge pull request RemedyIT#337 from jwillemsen/jwi-currentexception
Browse files Browse the repository at this point in the history
Add some exception testing for PICurrent
  • Loading branch information
jwillemsen authored Nov 15, 2023
2 parents 1d8e4f3 + 5b30d63 commit d4f75e4
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 12 deletions.
7 changes: 2 additions & 5 deletions tao/x11/pi/client_request_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ namespace TAOX11_NAMESPACE
IOP::TaggedProfile rc {};
try
{
TAO_IOP::TaggedProfile_var tao_tp =
this->reqinf_->effective_profile ();
rc = IOP::TaggedProfile (
tao_tp->tag,
seq_to_x11<CORBA::OctetSeq> (tao_tp->profile_data));
TAO_IOP::TaggedProfile_var tao_tp = this->reqinf_->effective_profile ();
rc = IOP::TaggedProfile (tao_tp->tag, seq_to_x11<CORBA::OctetSeq> (tao_tp->profile_data));
}
catch_tao_system_ex (_sx)
return rc;
Expand Down
12 changes: 10 additions & 2 deletions tests/pi/current/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])

server->invoke_me ();

CORBA::Any new_data =
pi_current->get_slot (::slot_id);
CORBA::Any new_data = pi_current->get_slot (::slot_id);

// The original data in the TSC was of type uint32_t. If the
// following extraction from the CORBA::Any fails, then the
Expand All @@ -96,6 +95,15 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])

server->invoke_we ();

try
{
server->test_exception ();
}
catch (const PICurrentTest::bar&)
{
TAOX11_TEST_INFO << "Caught correct exception" << std::endl;
}

server->shutdown ();

std::this_thread::sleep_for (std::chrono::seconds (1));
Expand Down
14 changes: 13 additions & 1 deletion tests/pi/current/client_request_interceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,20 @@ ClientRequestInterceptor::receive_reply (

void
ClientRequestInterceptor::receive_exception (
IDL::traits<PortableInterceptor::ClientRequestInfo>::ref_type)
IDL::traits<PortableInterceptor::ClientRequestInfo>::ref_type ri)
{
TAOX11_TEST_INFO << "ClientRequestInterceptor::receive_exception (" << ri->operation () << ") with id " << ri->request_id () << std::endl;

std::string const op = ri->operation ();

if (op == "test_exception")
{
TAOX11_TEST_INFO << "ClientRequestInterceptor::receive_exception, exception: (" << ri->received_exception () << ") id: (" << ri->received_exception_id () << ")" << std::endl;
}
else
{
TAOX11_TEST_ERROR << "ClientRequestInterceptor::receive_exception called for operation " << op << std::endl;
}
}

void
Expand Down
15 changes: 13 additions & 2 deletions tests/pi/current/server_request_interceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,26 @@ ServerRequestInterceptor::send_reply (
throw CORBA::INTERNAL ();
}


TAOX11_TEST_INFO << "Server side RSC/TSC semantics appear " \
"to be correct." << std::endl;
}

void
ServerRequestInterceptor::send_exception (
IDL::traits<PortableInterceptor::ServerRequestInfo>::ref_type)
IDL::traits<PortableInterceptor::ServerRequestInfo>::ref_type ri)
{
TAOX11_TEST_INFO << "ServerRequestInterceptor::send_exception (" << ri->operation () << ")" << std::endl;

std::string const op = ri->operation ();

if (op == "test_exception")
{
TAOX11_TEST_INFO << "ServerRequestInterceptor::send_exception, exception: (" << ri->sending_exception () << ")" << std::endl;
}
else
{
TAOX11_TEST_ERROR << "ServerRequestInterceptor::send_exception called for operation " << op << std::endl;
}
}

void
Expand Down
5 changes: 5 additions & 0 deletions tests/pi/current/test.idl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

module PICurrentTest
{
exception bar
{
};

interface test
{
Expand All @@ -20,6 +23,8 @@ module PICurrentTest

void invoke_we ();

void test_exception () raises (bar);

oneway void shutdown ();
};

Expand Down
11 changes: 9 additions & 2 deletions tests/pi/current/test_i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ test_i::invoke_you ()
{
// Nothing to be tested here. This method is here just so that we
// have a different method

TAOX11_TEST_INFO << "test_i::invoke_you method invoked." << std::endl;
}

Expand All @@ -128,7 +127,7 @@ test_i::invoke_we ()
TAOX11_TEST_INFO << "test_i::invoke_we method invoked." << std::endl;

// Insert some data into the TSC PICurrent object.
const std::string str = "We drink milk!";
std::string const str = "We drink milk!";

CORBA::Any data;

Expand Down Expand Up @@ -158,3 +157,11 @@ test_i::shutdown ()

this->orb_->shutdown (false);
}

void
test_i::test_exception ()
{
TAOX11_TEST_INFO << "test_exception." << std::endl;

throw PICurrentTest::bar ();
}
3 changes: 3 additions & 0 deletions tests/pi/current/test_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class test_i final :
/// Shutdown the ORB.
void shutdown () override;

/// Test exceptions
void test_exception () override;

private:
/// Reference to the PICurrent object.
IDL::traits<PortableInterceptor::Current>::ref_type current_;
Expand Down

0 comments on commit d4f75e4

Please sign in to comment.