From ae177e79a58a6b20b40f17684ec58a6801e39485 Mon Sep 17 00:00:00 2001 From: dengg Date: Mon, 28 Jul 2003 18:36:35 +0000 Subject: ChangeLogTag: Mon Jul 28 13:05:08 2003 Gan Deng --- TAO/ChangeLog | 8 ++ TAO/tests/Param_Test/except.cpp | 136 +++++++++++++++++++++++++++++++--- TAO/tests/Param_Test/param_test_i.cpp | 12 ++- 3 files changed, 143 insertions(+), 13 deletions(-) diff --git a/TAO/ChangeLog b/TAO/ChangeLog index bc0b02ef5b0..8dd19e2103b 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,11 @@ +Mon Jul 28 13:05:08 2003 Gan Deng + + * tests/Param_Test/except.cpp + * tests/Param_Test/param_test_i.cpp + + Added the testing for the SystemException into the + exception test. + Mon Jul 28 13:03:57 2003 Balachandran Natarajan * tao/Any.cpp: diff --git a/TAO/tests/Param_Test/except.cpp b/TAO/tests/Param_Test/except.cpp index 497f669281b..b535f380dbf 100644 --- a/TAO/tests/Param_Test/except.cpp +++ b/TAO/tests/Param_Test/except.cpp @@ -93,8 +93,8 @@ Test_Exception::dii_req_invoke (CORBA::Request_ptr req ACE_DEBUG ((LM_DEBUG, "Test_Exception::dii_req_invoke - " "expected user exception" - " (%s,%d)\n", - reason, + " (%s,%d)\n", + reason, mod_value)); } @@ -126,12 +126,66 @@ Test_Exception::dii_req_invoke (CORBA::Request_ptr req return; } + // Catch the SystemException type CORBA::NO_MEMORY thrown by the + // server to test the system exception. + ACE_CATCH (CORBA::NO_MEMORY, ex) + { + // 'NO_MEMORY' system exception should be caught here. This + // happens when the IN arg == 2. + // Otherwise we don't set the other arg values so the validity + // check will flag the error. + if (this->in_ % 4 == 2) + { + this->inout_ = this->in_ * 2; + this->out_ = this->in_ * 3; + this->ret_ = this->in_ * 4; + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Test_Exception::dii_req_invoke - " + "expected CORBA::NO_MEMORY system exception\n")); + } + } + else if (this->in_ % 4 == 1) + { + // We caught NO_MEMORY system exception when we should have caught Ooops. + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Test_Exception::run_sii_test - " + "caught NO_MEMORY system exception - " + "expected known user exception\n")); + } + } + else if (this->in_ % 4 == 3) + { + // We caught NO_MEMORY system exception when we should have caught UNKNOWN. + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Test_Exception::run_sii_test - " + "caught NO_MEMORY system exception - " + "expected UNKNOWN exception\n")); + } + } + else + { + // We caught NO_MEMORY system exception when we should have caught nothing. + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Test_Exception::run_sii_test - " + "caught unexpected uknown exception\n")); + } + } + } ACE_CATCH (CORBA::UNKNOWN, ex) { - // 'BadBoy' should be caught here. This happens when the IN arg == 2. + // 'BadBoy' should be caught here. This happens when the IN arg == 3. // Otherwise we don't set the other arg values so the validity // check will flag the error. - if (this->in_ % 3 == 2) + if (this->in_ % 4 == 3) { this->inout_ = this->in_ * 2; this->out_ = this->in_ * 3; @@ -144,7 +198,7 @@ Test_Exception::dii_req_invoke (CORBA::Request_ptr req "expected CORBA::UNKNOWN\n")); } } - else if (this->in_ % 3 == 1) + else if (this->in_ % 4 == 1) { // We caught UNKNOWN when we should have caught Ooops. if (TAO_debug_level > 0) @@ -155,6 +209,17 @@ Test_Exception::dii_req_invoke (CORBA::Request_ptr req "expected known user exception\n")); } } + else if (this->in_ % 4 == 2) + { + // We caught UNKNOWN exception when we should have caught NO_MEMORY. + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Test_Exception::run_sii_test - " + "caught unknown exception - " + "expected NO_MEMORY system exception\n")); + } + } else { // We caught UNKNOWN when we should have caught nothing. @@ -223,11 +288,53 @@ Test_Exception::run_sii_test (Param_Test_ptr objref ACE_DEBUG ((LM_DEBUG, "Test_Exception::run_sii_test - " "expected user exception" - " (%s,%d)\n", - reason, + " (%s,%d)\n", + reason, mod_value)); } + // These weren't passed back because of the exception. We + // set them here to the 'correct' values so the validity + // check won't return an error. + this->inout_ = this->in_ * 2; + this->out_ = this->in_ * 3; + this->ret_ = this->in_ * 4; + return 0; + } + ACE_CATCH (CORBA::NO_MEMORY, ex) + { + // 'SystemException' should be caught here, 'CORBA::NO_MEMORY' + // system exception is thrown by the servant when the + // IN argument == 2. + int d = this->in_ % 4; + + if (d != 2) + { + if (d == 1 && TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Test_Exception::run_sii_test - " + "caught system exception - " + "expected known user exception\n")); + } + else if (d == 3 && TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Test_Exception::run_sii_test - " + "caught system exception - " + "expected unknown exception\n")); + } + + return -1; + } + + if (TAO_debug_level > 0) + { + ACE_PRINT_EXCEPTION (ex, + "Test_Exception::run_sii_test - " + "expected system exception\n"); + } + // These weren't passed back because of the exception. We // set them here to the 'correct' values so the validity // check won't return an error. @@ -241,10 +348,10 @@ Test_Exception::run_sii_test (Param_Test_ptr objref // 'BadBoy' should be caught here, since generated code for // Param_Test::test_exception() knows nothing about it. // 'Ooops' however, should not be caught here. 'BadBoy' - // is thrown by the servant when the IN argument == 2. - int d = this->in_ % 3; + // is thrown by the servant when the IN argument == 3. + int d = this->in_ % 4; - if (d != 2) + if (d != 3) { if (d == 1 && TAO_debug_level > 0) { @@ -253,6 +360,13 @@ Test_Exception::run_sii_test (Param_Test_ptr objref "caught unknown exception - " "expected known user exception\n")); } + else if (d == 2 && TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Test_Exception::run_sii_test - " + "caught unknown exception - " + "expected known system exception\n")); + } return -1; } @@ -261,7 +375,7 @@ Test_Exception::run_sii_test (Param_Test_ptr objref { ACE_PRINT_EXCEPTION (ex, "Test_Exception::run_sii_test - " - "expected system exception\n"); + "expected unknown exception\n"); } // These weren't passed back because of the exception. We diff --git a/TAO/tests/Param_Test/param_test_i.cpp b/TAO/tests/Param_Test/param_test_i.cpp index 2e57fdb0f07..dd39fc19b52 100644 --- a/TAO/tests/Param_Test/param_test_i.cpp +++ b/TAO/tests/Param_Test/param_test_i.cpp @@ -964,17 +964,25 @@ Param_Test_i::test_exception (CORBA::ULong s1, ACE_THROW_SPEC ((CORBA::SystemException, Param_Test::Ooops)) { - CORBA::ULong d = s1 % 3; + CORBA::ULong d = s1 % 4; + // No exceptions to throw. if (d == 0) { s2 = s1 * 2; s3 = s1 * 3; return s1 * 4; } + // Throw a known user exceptio type to test the user exception. else if (d == 1) { - ACE_THROW_RETURN (Param_Test::Ooops (" % 3 == 1", d), 0); + ACE_THROW_RETURN (Param_Test::Ooops (" % 4 == 1", d), 0); + } + // Throw a CORBA::SystemException type CORBA::NO_MEMORY to test + // the system exception. + else if (d == 2) + { + ACE_THROW_RETURN (CORBA::NO_MEMORY (), 0); } // This will avoid the compiler -- cgit v1.2.1