diff options
Diffstat (limited to 'TAO/orbsvcs/tests/Redundant_Naming/client.cpp')
-rw-r--r-- | TAO/orbsvcs/tests/Redundant_Naming/client.cpp | 189 |
1 files changed, 63 insertions, 126 deletions
diff --git a/TAO/orbsvcs/tests/Redundant_Naming/client.cpp b/TAO/orbsvcs/tests/Redundant_Naming/client.cpp index 070a8d06e7f..2f8a4561e24 100644 --- a/TAO/orbsvcs/tests/Redundant_Naming/client.cpp +++ b/TAO/orbsvcs/tests/Redundant_Naming/client.cpp @@ -44,7 +44,7 @@ public: // = Interface implementation accessor methods. - void id (CORBA::Short id ACE_ENV_ARG_DECL) + void id (CORBA::Short id) ACE_THROW_SPEC ((CORBA::SystemException)); // Sets id. @@ -73,7 +73,7 @@ My_Test_Object::id (void) } void -My_Test_Object::id (CORBA::Short id ACE_ENV_ARG_DECL_NOT_USED) +My_Test_Object::id (CORBA::Short id) ACE_THROW_SPEC ((CORBA::SystemException)) { id_ = id; @@ -149,11 +149,10 @@ main (int argc, ACE_TCHAR **argv) CosNaming::NamingContext_var root_context_1; CosNaming::NamingContext_var root_context_2; - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY_EX(bl_a) + try { // Initialize orb - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, 0 ACE_ENV_ARG_PARAMETER); + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, 0); // ior's are specified for the name servers through a commandline // option or a file. @@ -161,85 +160,69 @@ main (int argc, ACE_TCHAR **argv) // Resolve the first name server CORBA::Object_var ns1obj = orb->string_to_object ( - ACE_TEXT_ALWAYS_CHAR (ns1ref) ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_a); + ACE_TEXT_ALWAYS_CHAR (ns1ref)); if (CORBA::is_nil (ns1obj.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("invalid ior <%s>\n"), ns1ref), -1); - root_context_1 = CosNaming::NamingContext::_narrow (ns1obj.in () - ACE_ENV_ARG_PARAMETER); + root_context_1 = CosNaming::NamingContext::_narrow (ns1obj.in ()); - ACE_TRY_CHECK_EX(bl_a); // Resolve the second name server CORBA::Object_var ns2obj = orb->string_to_object ( - ACE_TEXT_ALWAYS_CHAR (ns2ref) ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_a); + ACE_TEXT_ALWAYS_CHAR (ns2ref)); if (CORBA::is_nil (ns2obj.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("invalid ior <%s>\n"), ns2ref), -1); - root_context_2 = CosNaming::NamingContext::_narrow (ns2obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_a); + root_context_2 = CosNaming::NamingContext::_narrow (ns2obj.in ()); } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Unable to resolve name servers")); + ex._tao_print_exception (ACE_TEXT ("Unable to resolve name servers")); return -1; } - ACE_ENDTRY; // Create a bunch of objects in one context // Note: strings to the naming service must be char, not wchar - ACE_TRY_EX(bl_b) + try { // Bind one context level under root. CosNaming::Name level1; level1.length (1); level1[0].id = CORBA::string_dup ("level1_context"); CosNaming::NamingContext_var level1_context; - level1_context = root_context_1->bind_new_context (level1 - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_b); + level1_context = root_context_1->bind_new_context (level1); for (i=0; i<o_breath; i++) { // Instantiate a dummy object and bind it under the new context. My_Test_Object *impl1 = new My_Test_Object (i+1); Test_Object_var obj1 = impl1->_this (); - ACE_TRY_CHECK_EX(bl_b); impl1->_remove_ref (); - ACE_TRY_CHECK_EX(bl_b); CosNaming::Name obj_name; obj_name.length (1); char wide_name[16]; ACE_OS::sprintf(wide_name, "obj_%d", i); obj_name[0].id = CORBA::string_dup (wide_name); - level1_context->bind (obj_name, obj1.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_b); + level1_context->bind (obj_name, obj1.in ()); } } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Unable to create a lot of objects")); + ex._tao_print_exception (ACE_TEXT ("Unable to create a lot of objects")); return -1; } - ACE_ENDTRY; // Create a deep context tree - ACE_TRY_EX(bl_c) + try { CosNaming::NamingContext_var next_context = root_context_1; for (i=0; i<c_depth; i++) @@ -251,22 +234,18 @@ main (int argc, ACE_TCHAR **argv) ACE_OS::sprintf(deep_name, "deep_%d", i); deep[0].id = CORBA::string_dup (deep_name); CosNaming::NamingContext_var deep_context; - deep_context = next_context->bind_new_context (deep - ACE_ENV_ARG_PARAMETER); + deep_context = next_context->bind_new_context (deep); next_context = deep_context; - ACE_TRY_CHECK_EX(bl_c); } } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Unable to create deep context")); + ex._tao_print_exception (ACE_TEXT ("Unable to create deep context")); return -1; } - ACE_ENDTRY; // Create a wide context tree - ACE_TRY_EX(bl_d) + try { for (i=0; i<c_breath; i++) { @@ -277,21 +256,17 @@ main (int argc, ACE_TCHAR **argv) ACE_OS::sprintf(wide_name, "wide_%d", i); wide[0].id = CORBA::string_dup (wide_name); CosNaming::NamingContext_var wide_context; - wide_context = root_context_1->bind_new_context (wide - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_d); + wide_context = root_context_1->bind_new_context (wide); } } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Unable to create wide context")); + ex._tao_print_exception (ACE_TEXT ("Unable to create wide context")); return -1; } - ACE_ENDTRY; // Delete three selected things, one from each tree - ACE_TRY_EX(bl_e) + try { // Remove the second to last object from the Naming Context CosNaming::Name wide1; @@ -300,30 +275,23 @@ main (int argc, ACE_TCHAR **argv) char wide_name[16]; ACE_OS::sprintf(wide_name, "obj_%d", o_breath-2); wide1[1].id = CORBA::string_dup (wide_name); - root_context_1->unbind (wide1 ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_e); + root_context_1->unbind (wide1); // Remove the second to last context from the wide root Naming Context CosNaming::Name wide2; wide2.length (1); ACE_OS::sprintf(wide_name, "wide_%d", c_breath-2); wide2[0].id = CORBA::string_dup (wide_name); - CORBA::Object_var result_obj_ref = root_context_1->resolve (wide2 - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_e); + CORBA::Object_var result_obj_ref = root_context_1->resolve (wide2); CosNaming::NamingContext_var result_object = - CosNaming::NamingContext::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_e); + CosNaming::NamingContext::_narrow (result_obj_ref.in ()); if (CORBA::is_nil (result_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Problems with resolving wide context ") ACE_TEXT ("- nil object ref.\n")), -1); result_object->destroy(); - ACE_TRY_CHECK_EX(bl_e); - root_context_1->unbind (wide2 ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_e); + root_context_1->unbind (wide2); // Remove the last context from the deep Naming Context CosNaming::Name deep; @@ -334,34 +302,27 @@ main (int argc, ACE_TCHAR **argv) ACE_OS::sprintf(deep_name, "deep_%d", i); deep[i].id = CORBA::string_dup (deep_name); } - result_obj_ref = root_context_1->resolve (deep ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_e); + result_obj_ref = root_context_1->resolve (deep); result_object = - CosNaming::NamingContext::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_e); + CosNaming::NamingContext::_narrow (result_obj_ref.in ()); if (CORBA::is_nil (result_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Problems with resolving deep context ") ACE_TEXT ("- nil object ref.\n")), -1); result_object->destroy(); - ACE_TRY_CHECK_EX(bl_e); - root_context_1->unbind (deep ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_e); + root_context_1->unbind (deep); } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Unable to delete objects")); + ex._tao_print_exception (ACE_TEXT ("Unable to delete objects")); return -1; } - ACE_ENDTRY; // Now use the other name server to access 3 objects next to the // deleted objects and the 3 deleted objects - ACE_TRY_EX(bl_f) + try { // Access the last object from the Naming Context CosNaming::Name wide; @@ -370,28 +331,23 @@ main (int argc, ACE_TCHAR **argv) char wide_name[16]; ACE_OS::sprintf(wide_name, "obj_%d", o_breath-1); wide[1].id = CORBA::string_dup (wide_name); - CORBA::Object_var result_obj_ref = root_context_2->resolve (wide - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_f); - Test_Object_var result_object = Test_Object::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_f); + CORBA::Object_var result_obj_ref = root_context_2->resolve (wide); + Test_Object_var result_object = Test_Object::_narrow (result_obj_ref.in ()); if (CORBA::is_nil (result_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Problems with resolving object from ") ACE_TEXT ("redundant server - nil object ref.\n")), -1); - ACE_TRY_CHECK_EX(bl_f); } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Unable to resolve object from redundant server")); + ex._tao_print_exception ( + ACE_TEXT ( + "Unable to resolve object from redundant server")); return -1; } - ACE_ENDTRY; - ACE_TRY_EX(bl_g) + try { // Access the deleted second to last object from the Naming Context CosNaming::Name wide; @@ -400,21 +356,18 @@ main (int argc, ACE_TCHAR **argv) char wide_name[16]; ACE_OS::sprintf(wide_name, "obj_%d", o_breath-2); wide[1].id = CORBA::string_dup (wide_name); - CORBA::Object_var result_obj_ref = root_context_2->resolve (wide - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_g); + CORBA::Object_var result_obj_ref = root_context_2->resolve (wide); ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Problems with resolving object from ") ACE_TEXT ("redundant server - deleted object found.\n")), -1); } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { //expect exception since the context was deleted } - ACE_ENDTRY; - ACE_TRY_EX(bl_h) + try { // Access the last context from the wide Naming Context CosNaming::Name wide; @@ -422,29 +375,24 @@ main (int argc, ACE_TCHAR **argv) char wide_name[16]; ACE_OS::sprintf(wide_name, "wide_%d", c_breath-1); wide[0].id = CORBA::string_dup (wide_name); - CORBA::Object_var result_obj_ref = root_context_2->resolve (wide - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_h); + CORBA::Object_var result_obj_ref = root_context_2->resolve (wide); CosNaming::NamingContext_var result_object = - CosNaming::NamingContext::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_h); + CosNaming::NamingContext::_narrow (result_obj_ref.in ()); if (CORBA::is_nil (result_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Problems with resolving wide context from ") ACE_TEXT ("redundant server - nil object ref.\n")), -1); - ACE_TRY_CHECK_EX(bl_h); } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Unable to resolve wide context from redundant server")); + ex._tao_print_exception ( + ACE_TEXT ( + "Unable to resolve wide context from redundant server")); return -1; } - ACE_ENDTRY; - ACE_TRY_EX(bl_i) + try { // Access the deleted second to last object from the Naming Context CosNaming::Name wide; @@ -452,21 +400,18 @@ main (int argc, ACE_TCHAR **argv) char wide_name[16]; ACE_OS::sprintf(wide_name, "wide_%d", c_breath-2); wide[0].id = CORBA::string_dup (wide_name); - CORBA::Object_var result_obj_ref = root_context_2->resolve (wide - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_i); + CORBA::Object_var result_obj_ref = root_context_2->resolve (wide); ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Problems with resolving wide context from ") ACE_TEXT ("redundant server - deleted object found.\n")), -1); } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { //expect exception since the context was deleted } - ACE_ENDTRY; - ACE_TRY_EX(bl_j) + try { // Access the deleted last context from the deep Naming Context CosNaming::Name deep; @@ -477,21 +422,18 @@ main (int argc, ACE_TCHAR **argv) ACE_OS::sprintf(deep_name, "deep_%d", i); deep[i].id = CORBA::string_dup (deep_name); } - CORBA::Object_var result_obj_ref = root_context_1->resolve (deep - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_j); + CORBA::Object_var result_obj_ref = root_context_1->resolve (deep); ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Problems with resolving deep context from ") ACE_TEXT ("redundant server - deleted object found.\n")), -1); } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { //expect exception since the context was deleted } - ACE_ENDTRY; - ACE_TRY_EX(bl_k) + try { // Access the second to last object from the Naming Context CosNaming::Name deep; @@ -502,29 +444,24 @@ main (int argc, ACE_TCHAR **argv) ACE_OS::sprintf(deep_name, "deep_%d", i); deep[i].id = CORBA::string_dup (deep_name); } - CORBA::Object_var result_obj_ref = root_context_1->resolve (deep - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_k); + CORBA::Object_var result_obj_ref = root_context_1->resolve (deep); CosNaming::NamingContext_var result_object = - CosNaming::NamingContext::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(bl_k); + CosNaming::NamingContext::_narrow (result_obj_ref.in ()); if (CORBA::is_nil (result_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Problems with resolving deep context from ") ACE_TEXT ("redundant server - nil object ref.\n")), -1); - ACE_TRY_CHECK_EX(bl_k); } - ACE_CATCHANY + catch (const CORBA::Exception& ex) { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Unable to resolve deep context from redundant server")); + ex._tao_print_exception ( + ACE_TEXT ( + "Unable to resolve deep context from redundant server")); return -1; } - ACE_ENDTRY; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Redundancy test OK\n"))); return 0; |