int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) { return 1; } CORBA::Object_var object = orb->string_to_object (ior); Simple_Server_var server = Simple_Server::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil.\n", ior), 1); } Structure the_in_structure; the_in_structure.seq.length (10); if (test_user_exception == 1) { server->raise_user_exception (); } else if (test_system_exception == 1) { server->raise_system_exception (); } else { for (int i = 0; i != niterations; ++i) { CORBA::Long const tv = i + 100; server->test_val(tv); CORBA::Long const rtv = server->test_val (); if (TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, "DSI_Simpler_Server ==== Expected result = %d for %d\n", rtv, tv)); } if (rtv != tv) { ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: unexpected result = %d for %d\n", rtv, tv)); } the_in_structure.i = i; CORBA::String_var name = CORBA::string_dup ("the name"); Structure_var the_out_structure; CORBA::Long const r = server->test_method (i, the_in_structure, the_out_structure.out (), name.inout ()); if (TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, "DSI_Simpler_Server ====\n" " x = %d\n" " i = %d\n" " length = %d\n" " name = <%C>\n", r, the_out_structure->i, the_out_structure->seq.length (), name.in ())); } if (r != i) { ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: unexpected result = %d for %d", r, i)); } } } if (do_shutdown) { server->shutdown (); } } catch (const test_exception& ex) { if (test_user_exception == 1) ACE_DEBUG ((LM_DEBUG, "Client: caught expected user exception: %C\n", ex._name())); else ex._tao_print_exception ("Client: exception caught - "); ACE_DEBUG ((LM_DEBUG, "error code: %d\n" "error info: %C\n" "status: %C\n", ex.error_code, ex.error_message.in (), ex.status_message.in ())); return test_user_exception == 1 ? 0 : 1; } catch (const CORBA::NO_PERMISSION& ex) { if (test_system_exception == 1) ACE_DEBUG ((LM_DEBUG, "Client: caught expected system exception: %C\n", ex._name())); else ex._tao_print_exception ("Client: exception caught - "); return test_system_exception == 1 ? 0 : 1; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Client: exception caught - "); return 1; } return 0; }
void do_primary_test (CORBA::ORB_var &orb, Simple_Server_var &server) { try { CORBA::Object_var nilobj = CORBA::Object::_nil(); CORBA::Object_var object = orb->string_to_object (ior); server = Simple_Server::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR ((LM_ERROR, "Object reference <%s> is nil\n", ior)); return; } CORBA::Short x = server->s(); ACE_ERROR ((LM_ERROR,"Server->s() returned %d\n", x)); server->s(510); Structure the_in_structure; the_in_structure.i = x; the_in_structure.seq.length (10); the_in_structure.obj = CORBA::Object::_duplicate(server.in()); Structure_var out_struct; CORBA::String_var name = CORBA::string_dup ("test"); server->struct_test (12345, the_in_structure, out_struct.out(), name.inout()); CORBA::String_var outior = orb->object_to_string(out_struct->obj); ACE_DEBUG ((LM_DEBUG,"Got outior:\n%s\n", outior.in())); if (test_user_exception == 1) { server->raise_user_exception (); } else if (test_system_exception == 1) { server->raise_system_exception (); } if (test_user_exception != 0 || test_system_exception != 0) { ACE_DEBUG ((LM_DEBUG,"Expected exception not caught!\n")); return; } ACE_DEBUG ((LM_DEBUG,"Sending main ref\n")); CORBA::Object_var echo = server->echo_object (server.in()); ACE_DEBUG ((LM_DEBUG,"Sending nil ref\n")); echo = server->echo_object (nilobj.in()); CORBA::Any a; a <<= "String through Any"; CORBA::Boolean success = server->any_test (a); ACE_DEBUG ((LM_DEBUG,"any_test(string) returned %d\n",success)); a <<= server.in(); success = server->any_test (a); ACE_DEBUG ((LM_DEBUG,"any_test(objref) returned %d\n",success)); for (int i = 0; i != niterations; ++i) { the_in_structure.i = i; CORBA::String_var name = CORBA::string_dup ("the name"); Structure_var the_out_structure; CORBA::Long r = server->struct_test (i, the_in_structure, the_out_structure.out (), name.inout ()); 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)); } } } catch (const test_exception& ex) { ex._tao_print_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.in (), ex.status_message.in ())); } catch (const CORBA::NO_PERMISSION& ex) { ex._tao_print_exception ("Client: exception caught - "); } catch (const CORBA::SystemException& sysEx) { sysEx._tao_print_system_exception (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Client: exception caught - "); } }