From bd604a5e5db99bc3e2be3008572b14662f634cf4 Mon Sep 17 00:00:00 2001 From: labancap Date: Mon, 14 Jan 2013 22:05:29 +0000 Subject: Added test documentation --- TAO/OCI_RE_ChangeLog | 17 +++++ TAO/orbsvcs/tests/FT_Naming/Federation/Hello.cpp | 2 +- .../tests/FT_Naming/Federation/NamingTask.cpp | 87 ---------------------- .../tests/FT_Naming/Federation/NamingTask.h | 27 ------- TAO/orbsvcs/tests/FT_Naming/Federation/README | 70 +++++++++++++++++ TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp | 36 +++++---- TAO/orbsvcs/tests/FT_Naming/Federation/server.cpp | 82 +++++++++++--------- 7 files changed, 156 insertions(+), 165 deletions(-) delete mode 100644 TAO/orbsvcs/tests/FT_Naming/Federation/NamingTask.cpp delete mode 100644 TAO/orbsvcs/tests/FT_Naming/Federation/NamingTask.h create mode 100644 TAO/orbsvcs/tests/FT_Naming/Federation/README diff --git a/TAO/OCI_RE_ChangeLog b/TAO/OCI_RE_ChangeLog index 69e0590688c..b458ac240c6 100644 --- a/TAO/OCI_RE_ChangeLog +++ b/TAO/OCI_RE_ChangeLog @@ -1,3 +1,20 @@ +Mon Jan 14 21:49:20 UTC 2013 Phillip LaBanca + + * orbsvcs/tests/FT_Naming/Federation/Hello.cpp: + * orbsvcs/tests/FT_Naming/Federation/client.cpp: + * orbsvcs/tests/FT_Naming/Federation/server.cpp: + + Added missing ACE_TEXT wrapper macros + + * orbsvcs/tests/FT_Naming/Federation/README: + + Added test documentation + + * orbsvcs/tests/FT_Naming/Federation/NamingTask.h: + * orbsvcs/tests/FT_Naming/Federation/NamingTask.cpp: + + Removed these files. + Mon Jan 14 19:51:29 UTC 2013 Byron Harris * tests/Storable/README: diff --git a/TAO/orbsvcs/tests/FT_Naming/Federation/Hello.cpp b/TAO/orbsvcs/tests/FT_Naming/Federation/Hello.cpp index 752bb07aa19..817955f5d36 100644 --- a/TAO/orbsvcs/tests/FT_Naming/Federation/Hello.cpp +++ b/TAO/orbsvcs/tests/FT_Naming/Federation/Hello.cpp @@ -13,7 +13,7 @@ Hello::Hello (CORBA::ORB_ptr orb) char * Hello::get_string (void) { - return CORBA::string_dup ("Hello there!"); + return CORBA::string_dup ( ACE_TEXT ("Hello there!")); } void diff --git a/TAO/orbsvcs/tests/FT_Naming/Federation/NamingTask.cpp b/TAO/orbsvcs/tests/FT_Naming/Federation/NamingTask.cpp deleted file mode 100644 index 8b92aae35ac..00000000000 --- a/TAO/orbsvcs/tests/FT_Naming/Federation/NamingTask.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// $Id$ - -#include "NamingTask.h" -#include "orbsvcs/Naming/Naming_Server.h" -#include "ace/OS_NS_unistd.h" -#include "ace/Argv_Type_Converter.h" - -NamingTask::NamingTask (const char* orbname, int argc, ACE_TCHAR **argv, unsigned short port) - : initialized_(false) -{ - ACE_TCHAR **my_argv = new ACE_TCHAR *[argc + 2]; - ACE_TCHAR buf[128]; - int my_argc = 0; - for(; my_argc (epopt); - my_argv[my_argc++] = buf; - - orb_ = CORBA::ORB_init (my_argc, my_argv, orbname); - - delete [] my_argv; -} - -void NamingTask::waitInit () -{ - // Wait for Naming Service initialized. - while (! initialized_) { - ACE_OS::sleep(ACE_Time_Value(0, 100 * 1000)); - } -} - -void NamingTask::end() -{ - orb_->shutdown(0); - this->wait(); -} - -const char* NamingTask::ior() -{ - return ior_.in (); -} - -int NamingTask::svc() -{ - try { - // Get reference to Root POA - CORBA::Object_var obj = orb_->resolve_initial_references("RootPOA"); - PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in()); - - // Activate POA Manager - PortableServer::POAManager_var poaManager = poa->the_POAManager(); - poaManager->activate(); - - // Initialize the naming service - // We are not going to look for other naming servers - TAO_Naming_Server naming; - if (naming.init(orb_.in(), - poa.in(), - ACE_DEFAULT_MAP_SIZE, - 0, - 0, - 0, - TAO_NAMING_BASE_ADDR, - 0) == 0) - { - ACE_DEBUG ((LM_DEBUG, "The Naming Service Task is ready.\n")); - ior_ = naming.naming_service_ior (); - initialized_ = true; - // Accept requests - orb_->run(); - return 0; - } - else - { - ACE_ERROR ((LM_ERROR, "Unable to initialize the Naming Service.\n")); - } - } - catch (const CORBA::Exception& ex) - { - ex._tao_print_exception ("NamingTask::svc() CORBA::Exception: "); - } - - return -1; -} - diff --git a/TAO/orbsvcs/tests/FT_Naming/Federation/NamingTask.h b/TAO/orbsvcs/tests/FT_Naming/Federation/NamingTask.h deleted file mode 100644 index b82ec5dbf88..00000000000 --- a/TAO/orbsvcs/tests/FT_Naming/Federation/NamingTask.h +++ /dev/null @@ -1,27 +0,0 @@ -// $Id$ - -#ifndef NAMINGTASK_H -#define NAMINGTASK_H - -#include "tao/CORBA_String.h" -#include "tao/ORB.h" -#include "ace/Task.h" -#include "ace/Synch_Traits.h" - -class NamingTask : public ACE_Task_Base -{ -public: - NamingTask (const char* orbname, int argc, ACE_TCHAR **argv, unsigned short port); - virtual int svc(); - void waitInit (); - void end(); - - const char* ior (); - -private: - CORBA::ORB_var orb_; - bool initialized_; - CORBA::String_var ior_; -}; - -#endif diff --git a/TAO/orbsvcs/tests/FT_Naming/Federation/README b/TAO/orbsvcs/tests/FT_Naming/Federation/README new file mode 100644 index 00000000000..b2d7e2838f4 --- /dev/null +++ b/TAO/orbsvcs/tests/FT_Naming/Federation/README @@ -0,0 +1,70 @@ +$Id$ + +This tests the federated fault tolerant naming service use case: + +To run all tests automatically - + execute Perl script run_test.pl + +Example Perl script execution output: +$./run_test.pl +Hello object bound in Naming Service B +Root context of NS B bound in Naming Service A under name 'nsB' +Wrote IOR file +Starting client +**** Narrowed root NamingContext +**** Resolved #nsB/example/Hello +(12960|3069859584) - string returned +INFO: server being killed. +INFO: removing +INFO: removing +$ + +To run tests manually - + start the 2 redundant pairs of tao_ft_naming (see + TAO/orbsvcs/Naming_Service/README for valid options), + then run ./server and ./client as shown below: + +NOTE: if running tests manually, the NameService1 and NameService2 directories +must exist before starting the Naming Service and these directories must be +cleaned out manually after stopping the Naming Service. + +1) server connects to Naming Service B (localhost:9932) and attempts to bind + context "example" to it. + +2) server attempts to bind "Hello" object to the newly created context "example". + +3) server connects to Naming Service A (localhost:9931) and bind + Naming Service B as name "nsB". + +4) server writes out ior file. + +5) client connects to Naming Service A (localhost:9931) and attempts to resolve + "nsB/example/Hello" from the root context. + +6) client attempts to narrow the Hello object and reports the output of the + Hello object's get_string() method. + +Example (on a Unix system): + +$tao_ft_naming --primary -ORBListenEndPoints iiop://localhost:9931 \ + -r NameService1 & +$tao_ft_naming --backup -ORBListenEndPoints iiop://localhost:9933 -c ns1.ior \ + -g nm1.ior -r NameService1 & + +$tao_ft_naming --primary -ORBListenEndPoints iiop://localhost:9932 \ + -r NameService2 & +$tao_ft_naming --backup -ORBListenEndPoints iiop://localhost:9934 -c ns2.ior \ + -g nm2.ior -r NameService2 & + +$./server -o test.ior & + +Hello object bound in Naming Service B +Root context of NS B bound in Naming Service A under name 'nsB' +Wrote IOR file + +$./client + +**** Narrowed root NamingContext +**** Resolved #nsB/example/Hello +(10911|3069798144) - string returned + diff --git a/TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp b/TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp index 771a9582325..0fa3468806d 100644 --- a/TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp +++ b/TAO/orbsvcs/tests/FT_Naming/Federation/client.cpp @@ -13,52 +13,56 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var tmp = - orb->string_to_object("corbaloc:iiop:1.2@localhost:9931/NameService"); + orb->string_to_object ( + ACE_TEXT_ALWAYS_CHAR ("corbaloc:iiop:1.2@localhost:9931/NameService")); CosNaming::NamingContext_var root = - CosNaming::NamingContext::_narrow(tmp.in()); + CosNaming::NamingContext::_narrow (tmp.in ()); if (CORBA::is_nil (root.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, - "Nil NamingService reference\n"), - 1); + ACE_TEXT ("Nil NamingService reference\n")), + 1); } - ACE_DEBUG ((LM_INFO, "**** Narrowed root NamingContext\n")); + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("**** Narrowed root NamingContext\n"))); CosNaming::Name name; name.length(3); - name[0].id = CORBA::string_dup("nsB"); - name[1].id = CORBA::string_dup("example"); - name[2].id = CORBA::string_dup("Hello"); - + name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR ("nsB")); + name[1].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR ("example")); + name[2].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR ("Hello")); try { tmp = root->resolve (name); - ACE_DEBUG ((LM_INFO, "**** Resolved #nsB/example/Hello\n")); + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("**** Resolved #nsB/example/Hello\n"))); Test::Hello_var hello = - Test::Hello::_narrow(tmp.in ()); + Test::Hello::_narrow (tmp.in ()); if (CORBA::is_nil (hello.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, - "Nil Test::Hello reference\n"), - 1); + ACE_TEXT ("Nil Test::Hello reference\n")), + 1); } CORBA::String_var the_string = hello->get_string (); - ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n", + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) - string returned <%C>\n"), the_string.in ())); hello->shutdown (); } catch (const CosNaming::NamingContext::CannotProceed&) { - ACE_DEBUG ((LM_DEBUG, "Caught correct exception\n")); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Caught correct exception\n"))); } orb->shutdown (); @@ -66,7 +70,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) } catch (const CORBA::Exception& ex) { - ex._tao_print_exception ("Exception caught:"); + ex._tao_print_exception (ACE_TEXT ("Exception caught:")); return 1; } diff --git a/TAO/orbsvcs/tests/FT_Naming/Federation/server.cpp b/TAO/orbsvcs/tests/FT_Naming/Federation/server.cpp index 578e3e056ae..a1bee3a289b 100644 --- a/TAO/orbsvcs/tests/FT_Naming/Federation/server.cpp +++ b/TAO/orbsvcs/tests/FT_Naming/Federation/server.cpp @@ -23,7 +23,7 @@ private: TestTask::TestTask(int argc, ACE_TCHAR **argv) { - orb_ = CORBA::ORB_init (argc, argv, "ServerORB"); + orb_ = CORBA::ORB_init (argc, argv, ACE_TEXT_ALWAYS_CHAR ("ServerORB")); shutdown_ns_ = false; parse_args (argc, argv); } @@ -37,7 +37,7 @@ void TestTask::end() int TestTask::parse_args (int argc, ACE_TCHAR **argv) { - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:s")); + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("o:s")); int c; while ((c = get_opts ()) != -1) @@ -59,60 +59,70 @@ int TestTask::svc() try { // Get reference to Root POA - CORBA::Object_var obj = orb_->resolve_initial_references("RootPOA"); - PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in()); + CORBA::Object_var obj = orb_->resolve_initial_references ( + ACE_TEXT_ALWAYS_CHAR ("RootPOA")); + + PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); // Activate POA Manager - PortableServer::POAManager_var mgr = poa->the_POAManager(); - mgr->activate(); + PortableServer::POAManager_var mgr = poa->the_POAManager (); + mgr->activate (); // Find the Naming Service - obj = orb_->string_to_object ("corbaloc:iiop:1.2@localhost:9932/NameService"); + obj = orb_->string_to_object ( + ACE_TEXT_ALWAYS_CHAR ("corbaloc:iiop:1.2@localhost:9932/NameService")); + CosNaming::NamingContext_var rootB = - CosNaming::NamingContext::_narrow(obj.in()); + CosNaming::NamingContext::_narrow (obj.in ()); - if (CORBA::is_nil(rootB.in())) { - ACE_ERROR ((LM_ERROR, "Error, Nil Naming Context reference\n")); + if (CORBA::is_nil (rootB.in ())) { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Error, Nil Naming Context reference\n"))); return 1; } // Bind the example Naming Context, if necessary CosNaming::NamingContext_var example_nc; CosNaming::Name name; name.length(1); - name[0].id = CORBA::string_dup("example"); + name[0].id = CORBA::string_dup( ACE_TEXT_ALWAYS_CHAR ("example")); try { - obj = rootB->resolve(name); + obj = rootB->resolve (name); example_nc = - CosNaming::NamingContext::_narrow(obj.in()); + CosNaming::NamingContext::_narrow (obj.in ()); } catch (const CosNaming::NamingContext::NotFound&) { - example_nc = rootB->bind_new_context(name); + example_nc = rootB->bind_new_context (name); } // Bind the Test object - name.length(2); - name[1].id = CORBA::string_dup("Hello"); + name.length (2); + name[1].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR ("Hello")); // Create an object - Hello servant(orb_.in ()); - PortableServer::ObjectId_var oid = poa->activate_object(&servant); - obj = poa->id_to_reference(oid.in()); - rootB->rebind(name, obj.in()); + Hello servant (orb_.in ()); + PortableServer::ObjectId_var oid = poa->activate_object (&servant); + obj = poa->id_to_reference (oid.in ()); + rootB->rebind (name, obj.in ()); - ACE_DEBUG ((LM_INFO, "Hello object bound in Naming Service B\n")); + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("Hello object bound in Naming Service B\n"))); - name.length(1); - name[0].id = CORBA::string_dup ("nsB"); + name.length (1); + name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR ("nsB")); + + obj = orb_->string_to_object ( + ACE_TEXT_ALWAYS_CHAR ("corbaloc:iiop:1.2@localhost:9931/NameService")); - obj = orb_->string_to_object ("corbaloc:iiop:1.2@localhost:9931/NameService"); CosNaming::NamingContext_var rootA = - CosNaming::NamingContext::_narrow(obj.in()); + CosNaming::NamingContext::_narrow (obj.in ()); rootA->bind_context (name, rootB.in ()); - ACE_DEBUG ((LM_INFO, "Root context of NS B bound in Naming Service A under name 'nsB'\n")); + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("Root context of NS B bound in Naming Service A ") + ACE_TEXT ("under name 'nsB'\n"))); CORBA::String_var ior = orb_->object_to_string (obj.in ()); @@ -121,14 +131,16 @@ int TestTask::svc() FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, - "Cannot open output file %s for writing IOR: %C\n", - ior_output_file, - ior.in ()), - 1); - ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_TEXT ("Cannot open output file %s for writing ") + ACE_TEXT ("IOR: %C\n"), + ior_output_file, + ior.in ()), + 1); + ACE_OS::fprintf (output_file, ACE_TEXT ("%s"), ior.in ()); ACE_OS::fclose (output_file); - ACE_DEBUG ((LM_INFO, "Wrote IOR file\n")); + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("Wrote IOR file\n"))); // Normally we run the orb and the orb is shutdown by // calling TestTask::end(). @@ -140,7 +152,7 @@ int TestTask::svc() } catch (CORBA::Exception& ex) { - ex._tao_print_exception ("CORBA exception: "); + ex._tao_print_exception (ACE_TEXT ("CORBA exception: ")); } return -1; @@ -152,7 +164,9 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) TestTask test_ (argc, argv); if (test_.activate() == -1) { - ACE_ERROR_RETURN ((LM_ERROR, "Unable to start test task.\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Unable to start test task.\n")), + -1); } // Wait the tasks to finish. -- cgit v1.2.1