diff options
Diffstat (limited to 'TAO/tests/DSI_Gateway/client.cpp')
-rw-r--r-- | TAO/tests/DSI_Gateway/client.cpp | 119 |
1 files changed, 85 insertions, 34 deletions
diff --git a/TAO/tests/DSI_Gateway/client.cpp b/TAO/tests/DSI_Gateway/client.cpp index e81a70270e4..238c2ce1b76 100644 --- a/TAO/tests/DSI_Gateway/client.cpp +++ b/TAO/tests/DSI_Gateway/client.cpp @@ -10,11 +10,13 @@ ACE_RCSID(DSI_Gateway, client, "$Id$") const char *ior = "file://gateway.ior"; int niterations = 5; int do_shutdown = 0; +int test_user_exception = 0; +int test_system_exception = 0; int parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "xk:i:"); + ACE_Get_Opt get_opts (argc, argv, "xusk:i:"); int c; while ((c = get_opts ()) != -1) @@ -24,6 +26,14 @@ parse_args (int argc, char *argv[]) do_shutdown = 1; break; + case 'u': + test_user_exception = 1; + break; + + case 's': + test_system_exception = 1; + break; + case 'k': ior = get_opts.optarg; break; @@ -36,12 +46,16 @@ parse_args (int argc, char *argv[]) default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s " + "-x " + "-u " + "-s " "-k <ior> " "-i <niterations> " "\n", argv [0]), -1); } + // Indicates sucessful parsing of the command line return 0; } @@ -56,7 +70,9 @@ main (int argc, char *argv[]) ACE_TRY_CHECK; if (parse_args (argc, argv) != 0) - return 1; + { + return 1; + } CORBA::Object_var object = orb->string_to_object (ior, ACE_TRY_ENV); @@ -77,40 +93,53 @@ main (int argc, char *argv[]) Structure the_in_structure; the_in_structure.seq.length (10); - for (int i = 0; i != niterations; ++i) + if (test_user_exception == 1) { - the_in_structure.i = i; - CORBA::String_var name = CORBA::string_dup ("the name"); - - Structure_var the_out_structure; - - CORBA::Long r = - server->test_method (i, - the_in_structure, - the_out_structure.out (), - name.inout (), - ACE_TRY_ENV); + server->raise_user_exception (ACE_TRY_ENV); ACE_TRY_CHECK; - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - "DSI_Simpler_Server ====\n" - " x = %d\n" - " i = %d\n" - " length = %d\n" - " name = <%s>\n", - r, - the_out_structure->i, - the_out_structure->seq.length (), - name.in ())); - } - - if (r != i) + } + else if (test_system_exception == 1) + { + server->raise_system_exception (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + else + { + for (int i = 0; i != niterations; ++i) { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) unexpected result = %d for %d", - r, i)); + the_in_structure.i = i; + CORBA::String_var name = CORBA::string_dup ("the name"); + + Structure_var the_out_structure; + + CORBA::Long r = + server->test_method (i, + the_in_structure, + the_out_structure.out (), + name.inout (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "DSI_Simpler_Server ====\n" + " x = %d\n" + " i = %d\n" + " length = %d\n" + " name = <%s>\n", + r, + the_out_structure->i, + the_out_structure->seq.length (), + name.in ())); + } + + if (r != i) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) unexpected result = %d for %d", + r, i)); + } } } @@ -120,10 +149,32 @@ main (int argc, char *argv[]) ACE_TRY_CHECK; } } + ACE_CATCH (test_exception, ex) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Client: exception caught - "); + + ACE_DEBUG ((LM_DEBUG, + "error code: %d\n" + "error info: %s\n" + "status: %s\n", + ex.error_code, + ex.error_message, + ex.status_message)); + + return 0; + } + ACE_CATCH (CORBA::NO_PERMISSION, ex) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Client: exception caught - "); + + return 0; + } ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Exception caught:"); + "Client: exception caught - "); return 1; } ACE_ENDTRY; |