diff options
Diffstat (limited to 'TAO/orbsvcs/tests/Simple_Naming')
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/Makefile.am | 88 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/README | 262 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/Simple_Naming.mpc | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/client.cpp | 1279 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/client.h | 335 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Simple_Naming/process-m-output.pl | 115 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Simple_Naming/run_test.pl | 196 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Simple_Naming/run_test_ffp.pl | 131 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/test_object.idl | 11 |
9 files changed, 0 insertions, 2426 deletions
diff --git a/TAO/orbsvcs/tests/Simple_Naming/Makefile.am b/TAO/orbsvcs/tests/Simple_Naming/Makefile.am deleted file mode 100644 index 01c8adb2ce2..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/Makefile.am +++ /dev/null @@ -1,88 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## ../bin/mwc.pl -type automake -noreldefs TAO.mwc - -ACE_BUILDDIR = $(top_builddir)/.. -ACE_ROOT = $(top_srcdir)/.. -TAO_BUILDDIR = $(top_builddir) -TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl -TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf -TAO_ROOT = $(top_srcdir) - -## Makefile.Simple_Naming_Client.am - -BUILT_SOURCES = \ - test_objectC.cpp \ - test_objectC.h \ - test_objectC.inl \ - test_objectS.cpp \ - test_objectS.h \ - test_objectS.inl \ - test_objectS_T.cpp \ - test_objectS_T.h \ - test_objectS_T.inl - -CLEANFILES = \ - test_object-stamp \ - test_objectC.cpp \ - test_objectC.h \ - test_objectC.inl \ - test_objectS.cpp \ - test_objectS.h \ - test_objectS.inl \ - test_objectS_T.cpp \ - test_objectS_T.h \ - test_objectS_T.inl - -test_objectC.cpp test_objectC.h test_objectC.inl test_objectS.cpp test_objectS.h test_objectS.inl test_objectS_T.cpp test_objectS_T.h test_objectS_T.inl: test_object-stamp - -test_object-stamp: $(srcdir)/test_object.idl $(TAO_IDL_DEP) - $(TAO_IDL) $(TAO_IDLFLAGS) -I$(TAO_ROOT)/orbsvcs -GT $(srcdir)/test_object.idl - @touch $@ - -noinst_PROGRAMS = client - -client_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -client_SOURCES = \ - client.cpp \ - test_objectC.cpp \ - test_objectS.cpp \ - client.h \ - test_objectC.h \ - test_objectC.inl \ - test_objectS.h \ - test_objectS.inl \ - test_objectS_T.h \ - test_objectS_T.inl - -client_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/Simple_Naming/README b/TAO/orbsvcs/tests/Simple_Naming/README deleted file mode 100644 index 5e8c01ad0d3..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/README +++ /dev/null @@ -1,262 +0,0 @@ -// $Id$ - -This application tests different features of TAO's Naming Service. - -To run all tests automatically - - execute Perl script run_test.pl - -To run tests manually - - start the Naming Service (see - TAO/orbsvcs/Naming_Service/README for valid options), - then run ./client with one of the options below. - -NOTE: if running tests manually, Naming Service has to be restarted -before each test (this is due to some tests not 'cleaning up' bindings -after themselves). - -The following options exist: ---------------------------- --s Run the Simple test of the Naming Service. - --t Run the Tree test of the Naming Service. - --e Run the Exceptions test of the Naming Service - --i Run the Iterator test of the Naming Service. - --y Run the Destroy test of the Naming Service. - --m <n> Run the Multi-Threaded test of the Naming Service (multiple - client threads). Requires integer argument specifying number - of thread to spawn. (If running this test manually, its - output should be redirected to some file, say, "foo". Then, - "process-m-output.pl" script can be used to analyze the test - output and print out a diagnostic message. Invoke the output - processing script like so: - "process-m-output.pl foo number_of_threads", - where <foo> is the name of the file containing test output, - and <number_of_threads> is the argument that was supplied with - "-m" option to the client.) - - Example (on a Unix system): - $ ../../Naming_Service & - $ ./client -m 10 >& foo - $ ./process-m-output.pl foo 10 - - where the steps correspond to 1)starting the Naming Service, - 2) running the client and redirecting the output to a file, - and 3) running the diagnostic script. - Don't forget to kill the Naming Service after you are done. - -Persistent test consists of two parts (below). - --p <file_name> - Run the Persistent Naming Service test, part 1. Requires an - argument specifying the name of the file in which to store an ior for - use by Persistent Naming Service test, part 2. Note, in order - to test out persistent capabilities of the Naming Service, the - Naming Service must be started with -f and -ORBendpoint options. - The values for these options must be the same for both runs of - the Naming Service (i.e., for part 1 and part 2 of persistent test). - --c <ior> - Run the Persistent Naming Service test, part 2. Requires an - argument specifying the ior, which was produced in part 1 of - the test. Note, in order to test out persistent capabilities - of the Naming Service, the Naming Service must be started with - -f and -ORBendpoint options. The values for these options - must remain the same for both runs of the Naming Service (i.e., - for part 1 and part 2 of persistent test). - - Example of testing persistence on a Unix system: - $ ../../Naming_Service -f log -ORBendpoint iiop://localhost:20000 - $ ./client -p ior_file - kill the Naming_Service process - $ ../../Naming_Service -f log -ORBendpoint iiop://localhost:20000 - $ ./client -c file://ior_file - - where the steps correspond to 1)starting the Naming Service on - port 20000 in persistent mode, with persistent state being - stored in file called "log", 2) running the first part of the - client persistent naming test, and sending its data to file - called "ior_file", 3) killing the Naming Service process, 4) - restarting the Naming Service on the same port with the same - persistent state storage file, and 5) running the second part - of the client persistence test by specifying the ior from part - 1 in the file format. - - We kill the Naming Service process between 2 client runs to - make sure it can recreate its state from persistent storage. - It is necessary to restart the Naming Service on the same - host/port in order for the persistent IORs from the first - run to be valid for the second run. - -If no option is specified, Simple test is run. If more than one -option is specified, only one test runs. - - -DESCRIPTION AND EXPECTED OUTPUT FOR EACH TEST -******************************************* - -Simple Test. - -Performs bind (), resolve (), and unbind () of an object reference in -the root context. - -Expected Output: - -Bound name OK -Resolved name OK -Unbound name OK - -******************************************** - -MT Test. - -Spawns a specified number of threads. Threads concurrently attempt to -bind (), resolve (), and unbind () the object reference. - -Expected Output (produced by the output processing script): - -Multithreaded output is ok - -The output of the actual test varies from run to run, due to the -variation in the thread scheduling. Correct output must have the -following properties (these are the properties that the processing -script checks for): -1) number of bind () calls = number of resolve () calls = number of -unbind () calls = number of threads specified for the test -2) number of successful bind () calls = number of successful unbind () calls. - -******************************************* - -Tree Test. - -Checks all Naming Service functions with a tree of Naming Contexts. - -root->bind_new_context (level1) - -new = root->new_context (), new->bind (foo, obj), and - root->bind_context (level1/level2, new) - -We now have root->level1->level2->foo - -root->resolve (level1/level2/foo). -root->unbind (level1/level2/foo). -root->bind (level1/level2/foo, obj). - -new = root->new_context() -root->rebind_context(level1/level2, new) - -root->bind (level1/level2/foo obj) -root->resolve (level1/level2/foo) -root->rebind (level1/level2/foo, obj2) to have a different object under the name bar. -root->resolve (level1/level2/foo) to make sure correct reference is returned. - - -Expected Output: - -All funtions work properly -******************************************** - -Exceptions Test. - -Makes sure that Naming Service throws exceptions as expected, and data -inside exceptions is set correctly. - -Create a tree of Naming Contexts: root context -> level1 -> level2. - -Bind an object with the name foo into each of the Naming Contexts. - -root->resolve () (with a Name of length 0) - should get InvalidName exception. -root->bind (foo, obj) - should get AlreadyBound exception. -root->bind (level1/foo, obj) - should get AlreadyBound exception. -root->unbind (level1/level2/bar) - should get NotFound exception - with why = missing_node, rest_of_name = bar. -root->unbind (level1/level3/foo) - should get NotFound exception - with why = missing_node, rest_of_name = level3/foo. -root->unbind (level1/foo/foo) -should get NotFound exception - with why = not_context, rest_of_name = foo/foo. - - -Expected Output: - -AlreadyBound exception (case 1) works properly -AlreadyBound exception (case 2) works properly -NotFound exception (case 1) works properly -NotFound exception (case 2) works properly -NotFound exception (case 3) works properly - -********************************************* - -Iterator Test. - -Checks iterator functions. - -Bind () objects with the following names foo1, foo2, foo3, and foo4 -into the root Naming Context. - -root->lists (1, bl, iter) -iter->next_one () -iter->next_n (2, bl) -iter->next_one () - should return false -iter->destroy () - - -Expected Output: - -First binding: foo1 -Second binding: foo2 -Third binding: foo3 -Fourth binding: foo4 - -********************************************* - -Destroy Test. - -Makes sure destroy method is working properly. - -Create a context and bind an object under it. -Attempt to destroy the context - NotEmpty exception should be raised. - -Unbind the object and call destroy on the context. -Attempt to call destroy on the object again - OBJECT_NOT_EXIST -exception should be raised. - - -Expected Output: - -NotEmpty exception works properly -Destroy works properly - -******************************************** - -Persistent Test (part 1). - -Makes sure persistence mode of the Naming Service functions properly: -this test sets things up for part 2 - -Creates the Naming Context hierarchy: -root -> level1_context -> level2_context, -and prints out the ior of the <level1_context> to the specified file. - - -Expected Output: - -Persistent Naming test (part 1) OK. - -******************************************** -Persistent Test (part 2). - -Makes sure persistence mode of the Naming Service functions properly. - -Attempts to resolve <level2_context> both through the ior obtained -from part 1 of the test, and through the Naming Context obtained from -<resolve_initial_references>. Compares the results of both resolve () -calls. - -Expected Output: - -Persistent Naming test (part 2) OK. - -******************************************** diff --git a/TAO/orbsvcs/tests/Simple_Naming/Simple_Naming.mpc b/TAO/orbsvcs/tests/Simple_Naming/Simple_Naming.mpc deleted file mode 100644 index 0a4a4f0b63a..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/Simple_Naming.mpc +++ /dev/null @@ -1,9 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*Client) : namingexe, utils, portableserver { - Source_Files { - client.cpp - } -} - diff --git a/TAO/orbsvcs/tests/Simple_Naming/client.cpp b/TAO/orbsvcs/tests/Simple_Naming/client.cpp deleted file mode 100644 index 904a68a489b..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/client.cpp +++ /dev/null @@ -1,1279 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO/orbsvcs/Naming_Service/ -// -// = FILENAME -// client.cpp -// -// = DESCRIPTION -// This class implements a simple CORBA client for the CosNaming -// example using stubs generated by the TAO ORB IDL compiler. -// -// = AUTHORS -// Sergio Flores-Gaitan <sergio@cs.wustl.edu>, -// Marina Spivak <marina@cs.wustl.edu>, and -// Douglas C. Schmidt <schmidt@cs.wustl.edu> -// ============================================================================ - -#include "client.h" -#include "tao/debug.h" -#include "ace/Get_Opt.h" - -ACE_RCSID(Simple_Naming, client, "$Id$") - -#if defined (_MSC_VER) -# pragma warning (disable : 4250) -#endif /* _MSC_VER */ - -class My_Test_Object : - public virtual POA_Test_Object -{ -public: - // = Initialization and termination methods. - My_Test_Object (CORBA::Short id = 0); - // Constructor. - - ~My_Test_Object (void); - // Destructor. - - // = Interface implementation accessor methods. - - void id (CORBA::Short id ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - // Sets id. - - CORBA::Short id (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - // Gets id. - -private: - short id_; -}; - -My_Test_Object::My_Test_Object (CORBA::Short id) - : id_ (id) -{ -} - -My_Test_Object::~My_Test_Object (void) -{ -} - -CORBA::Short -My_Test_Object::id (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - return id_; -} - -void -My_Test_Object::id (CORBA::Short id ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - id_ = id; -} - -// Constructor. - -CosNaming_Client::CosNaming_Client (void) - : argc_ (0), - argv_ (0), - test_ (0) -{ -} - -// Parses the command line arguments and returns an error status. - -int -CosNaming_Client::parse_args (void) -{ - ACE_Get_Opt get_opts (argc_, argv_, "p:dstieym:c:"); - int c; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'd': // debug flag - TAO_debug_level++; - break; - case 's': - if (this->test_ == 0) - ACE_NEW_RETURN (this->test_, - Simple_Test, - -1); - break; - case 'm': - if (this->test_ == 0) - { - int size = ACE_OS::atoi (get_opts.opt_arg ()); - if (size <= 0) - size = 10; - - ACE_NEW_RETURN (this->test_, - MT_Test (this->orbmgr_.orb (), size), - -1); - } - - break; - case 't': - if (this->test_ == 0) - ACE_NEW_RETURN (this->test_, - Tree_Test, - -1); - break; - case 'i': - if (this->test_ == 0) - ACE_NEW_RETURN (this->test_, - Iterator_Test, - -1); - break; - case 'e': - if (this->test_ == 0) - ACE_NEW_RETURN (this->test_, - Exceptions_Test, - -1); - break; - case 'y': - if (this->test_ == 0) - ACE_NEW_RETURN (this->test_, - Destroy_Test, - -1); - break; - case 'p': - if (this->test_ == 0) - { - FILE * ior_output_file = - ACE_OS::fopen (get_opts.opt_arg (), "w"); - - if (ior_output_file == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Unable to open %s for writing: %p\n", - get_opts.opt_arg ()), -1); - - ACE_NEW_RETURN (this->test_, - Persistent_Test_Begin (this->orbmgr_.orb (), - ior_output_file), - -1); - } - break; - case 'c': - if (this->test_ == 0) - ACE_NEW_RETURN (this->test_, - Persistent_Test_End (this->orbmgr_.orb (), - get_opts.opt_arg ()), - -1); - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "Argument %c \n usage: %s" - " [-d]" - " [-s or -e or -t or -i or -y or -p or -c<ior> or -m<size>]" - "\n", - c, - this->argv_ [0]), - -1); - } - - if (this->test_ == 0) - ACE_NEW_RETURN (this->test_, - Simple_Test, - -1); - - // Indicates successful parsing of command line. - return 0; -} - -// Execute client example code. - -int -CosNaming_Client::run (void) -{ - return test_->execute (naming_client_); -} - -CosNaming_Client::~CosNaming_Client (void) -{ - delete test_; -} - -int -CosNaming_Client::init (int argc, char **argv) -{ - this->argc_ = argc; - this->argv_ = argv; - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Initialize ORB. - this->orbmgr_.init (this->argc_, - this->argv_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->orbmgr_.activate_poa_manager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Parse command line and verify parameters. - if (this->parse_args () == -1) - return -1; - - CORBA::ORB_var orb = this->orbmgr_.orb (); - return this->naming_client_.init (orb.in ()); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "init"); - // and return -1 below . . . - } - ACE_ENDTRY; - - return -1; -} - -MT_Test::MT_Test (CORBA::ORB_ptr orb, - int size) - :size_ (size), - orb_ (orb), - name_service_ior_ (0) -{ -} - -int -MT_Test::svc (void) -{ - // Obtain object reference to the Naming Service (create new stub.) - - CosNaming::NamingContext_var name_service; - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY_EX (SETUP) - { - CORBA::Object_var name_service_obj = - orb_->string_to_object (name_service_ior_ ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX (SETUP); - - name_service = - CosNaming::NamingContext::_narrow (name_service_obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX (SETUP); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in MT test setup"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - if (name_service.in () == 0) - return -1; - - // Bind the object. - ACE_TRY_EX (BIND) - { - name_service->bind (test_name_, - test_ref_.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX (BIND); - ACE_DEBUG ((LM_DEBUG, - "Bound name OK in thread %t\n")); - } - ACE_CATCH (CosNaming::NamingContext::AlreadyBound, ex) - { - ACE_DEBUG ((LM_DEBUG, - "Unable to bind in thread %t\n")); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in MT test bind"); - // This debug statement works around a IRIX/MIPSPro 7.3 bug (it - // fails with optimize=1 debug=0; but works with any other - // settings for those flags). - ACE_DEBUG ((LM_DEBUG, "MT_Test(%t) - bind[3] %d\n", - test_name_.length ())); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - // Resolve the object from the Naming Context. - ACE_TRY_EX (RESOLVE) - { - CORBA::Object_var result_obj_ref = - name_service->resolve (test_name_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX (RESOLVE); - - Test_Object_var result_object = - Test_Object::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX (RESOLVE); - - if (!CORBA::is_nil (result_object.in ())) - { - CORBA::Short id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK_EX (RESOLVE); - - if (id == CosNaming_Client::OBJ1_ID) - ACE_DEBUG ((LM_DEBUG, - "Resolved name OK in thread %t\n")); - } - } - ACE_CATCH (CosNaming::NamingContext::NotFound, ex) - { - ACE_DEBUG ((LM_DEBUG, - "Unable to resolve in thread %t\n")); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in MT test resolve"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - // Unbind the object from the Naming Context. - ACE_TRY_EX (UNBIND) - { - name_service->unbind (test_name_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX (UNBIND); - ACE_DEBUG ((LM_DEBUG, - "Unbound name OK in thread %t\n")); - } - ACE_CATCH (CosNaming::NamingContext::NotFound, ex) - { - ACE_DEBUG ((LM_DEBUG, - "Unable to unbind in thread %t\n")); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in MT test unbind"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - return 0; -} - -int -MT_Test::execute (TAO_Naming_Client &root_context) -{ - if (CORBA::is_nil (this->orb_.in ())) - return -1; - - // Create data which will be used by all threads. - - // Dummy object instantiation. - My_Test_Object *test_obj_impl = - new My_Test_Object (CosNaming_Client::OBJ1_ID); - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - test_ref_ = - test_obj_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - test_obj_impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Get the IOR for the Naming Service. Each thread can use it - // in <string_to_object> to create its own stub for the Naming - // Service. This 'trick' is necessary, because multiple threads - // cannot be using the same stub - bad things happen... This is - // just a way to give each thread its own stub. - - CosNaming::NamingContext_var context = - root_context.get_context (); - - name_service_ior_ = - orb_->object_to_string (context.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception while instantiating dummy"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - // Create a name for dummy. - test_name_.length (1); - test_name_[0].id = CORBA::string_dup ("Foo"); - - // Spawn threads, each of which will be executing svc (). - int status = this->activate (THR_NEW_LWP | THR_JOINABLE, - size_); - - if (status == -1) - return -1; - - status = this->wait (); - return status; -} - -int -Simple_Test::execute (TAO_Naming_Client &root_context) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Dummy object instantiation. - My_Test_Object *test_obj_impl = new My_Test_Object (CosNaming_Client::OBJ1_ID); - Test_Object_var test_obj_ref = - test_obj_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Give ownership of this object to POA. - test_obj_impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Bind an object to the Naming Context. - CosNaming::Name test_name; - test_name.length (1); - test_name[0].id = CORBA::string_dup ("Foo"); - root_context->bind (test_name, - test_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Bound name OK\n")); - - // Resolve the object from the Naming Context. - CORBA::Object_var result_obj_ref = - root_context->resolve (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - Test_Object_var result_object = - Test_Object::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (!CORBA::is_nil (result_object.in ())) - { - CORBA::Short id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - if (id == CosNaming_Client::OBJ1_ID) - ACE_DEBUG ((LM_DEBUG, "Resolved name OK\n")); - } - - // Unbind the object from the Naming Context. - root_context->unbind (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Unbound name OK\n")); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Simple test"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - return 0; -} - -int -Tree_Test::execute (TAO_Naming_Client &root_context) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Create a tree of contexts: root->level1->level2. Bind object - // foo under context level2. - - // Bind level1 context 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->bind_new_context (level1 - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Create a new context. - CosNaming::NamingContext_var level2_context; - level2_context = root_context->new_context (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Instantiate a dummy object and bind it under the new context. - My_Test_Object *impl1 = - new My_Test_Object (CosNaming_Client::OBJ1_ID); - Test_Object_var obj1 = impl1->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - impl1->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosNaming::Name obj_name; - obj_name.length (1); - obj_name[0].id = CORBA::string_dup ("foo"); - level2_context->bind (obj_name, obj1.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Bind the context we just created under level1. - CosNaming::Name level2 (level1); - level2.length (2); - level2[1].id = CORBA::string_dup ("level2_context"); - root_context->bind_context (level2, - level2_context.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Resolve and unbind level1/level2/foo, and bind it back. - CosNaming::Name test_name (level2); - test_name.length (3); - test_name[2].id = obj_name[0].id; - CORBA::Object_var result_obj_ref = - root_context->resolve (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - Test_Object_var result_object = - Test_Object::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (result_object.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - "Problems with resolving foo in Tree Test - nil object ref.\n"), - -1); - - CORBA::Short id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (id != CosNaming_Client::OBJ1_ID) - ACE_ERROR_RETURN ((LM_ERROR, - "Problems with resolving foo in Tree Test - wrong id.\n"), - -1); - - // Unbind the object from the Naming Context and bind it back - // in. - root_context->unbind (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - root_context->bind (test_name, - obj1.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Create new context and rebind under the name level1/level2. - CosNaming::NamingContext_var new_level2_context; - new_level2_context = - root_context->new_context (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - root_context->rebind_context (level2, - new_level2_context.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Bind, resolve, rebind, and resolve foo under level1/level2. - root_context->bind (test_name, - obj1.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - result_obj_ref = root_context->resolve (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - result_object = Test_Object::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CORBA::Short obj_id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (result_object.in ()) - || !(obj_id == CosNaming_Client::OBJ1_ID)) - ACE_ERROR_RETURN ((LM_ERROR, - "Problems in the Tree Test\n"), - -1); - - My_Test_Object *impl2 = - new My_Test_Object (CosNaming_Client::OBJ2_ID); - Test_Object_var obj2 = impl2->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - impl2->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - root_context->rebind (test_name, - obj2.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - result_obj_ref = root_context->resolve (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - result_object = Test_Object::_narrow (result_obj_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - obj_id = result_object->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (result_object.in ()) - || !( obj_id == CosNaming_Client::OBJ2_ID)) - ACE_ERROR_RETURN ((LM_ERROR, - "Problems with rebind in Tree Test\n"), - -1); - } - - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Tree test"); - return -1; - } - - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - ACE_DEBUG ((LM_DEBUG, - "All functions work properly \n")); - return 0; -} - -int -Exceptions_Test::execute (TAO_Naming_Client &root_context) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Set things up. - - // Create a tree of contexts root->level1->level2. - CosNaming::Name context_name; - context_name.length (1); - context_name[0].id = CORBA::string_dup ("level1_context"); - CosNaming::NamingContext_var level1_context; - level1_context = root_context->bind_new_context (context_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - context_name[0].id = CORBA::string_dup ("level2_context"); - CosNaming::NamingContext_var level2_context; - level2_context = level1_context->bind_new_context (context_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Bind a dummy object foo under each context. - My_Test_Object *impl = new My_Test_Object; - Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosNaming::Name object_name; - object_name.length (1); - object_name[0].id = CORBA::string_dup ("foo"); - root_context->bind (object_name, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - level1_context->bind (object_name, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - level2_context->bind (object_name, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Run exceptions tests. - invalid_name_test (root_context - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - already_bound_test (root_context - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - already_bound_test2 (root_context - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - not_found_test (root_context - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - not_found_test2 (root_context - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - not_found_test3 (root_context - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Exceptions test"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - return 0; -} - -void -Exceptions_Test::invalid_name_test (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - CosNaming::Name test_name; - test_name.length (0); - - root_context->resolve (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Invalid name test failed\n")); - } - ACE_CATCH (CosNaming::NamingContext::InvalidName, ex) - { - ACE_DEBUG ((LM_DEBUG, - "InvalidName exception works properly\n")); - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, "Invalid name test failed\n")); - ACE_RE_THROW; - } - ACE_ENDTRY; - ACE_CHECK; -} - -void -Exceptions_Test::already_bound_test (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - CosNaming::Name test_name; - test_name.length (1); - test_name[0].id = CORBA::string_dup ("foo"); - My_Test_Object *impl = new My_Test_Object; - Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - root_context->bind (test_name, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Already bound (case 1) test failed\n")); - } - ACE_CATCH (CosNaming::NamingContext::AlreadyBound, ex) - { - ACE_DEBUG ((LM_DEBUG, - "AlreadyBound exception (case 1) works properly\n")); - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, "Already bound (case 1) test failed\n")); - ACE_RE_THROW; - } - - ACE_ENDTRY; - ACE_CHECK; -} - -void -Exceptions_Test::already_bound_test2 (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - CosNaming::Name test_name; - test_name.length (2); - test_name[0].id = CORBA::string_dup ("level1_context"); - test_name[1].id = CORBA::string_dup ("foo"); - My_Test_Object *impl = new My_Test_Object; - Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - root_context->bind (test_name, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Already bound (case 2) test failed\n")); - } - ACE_CATCH (CosNaming::NamingContext::AlreadyBound, ex) - { - ACE_DEBUG ((LM_DEBUG, - "AlreadyBound exception (case 2) works properly\n")); - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, "Already bound (case 2) test failed\n")); - ACE_RE_THROW; - } - ACE_ENDTRY; - ACE_CHECK; -} - -void -Exceptions_Test::not_found_test (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - CosNaming::Name test_name; - test_name.length (3); - test_name[0].id = CORBA::string_dup ("level1_context"); - test_name[1].id = CORBA::string_dup ("level2_context"); - test_name[2].id = CORBA::string_dup ("bar"); - - root_context->unbind (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Not found test failed\n")); - } - ACE_CATCH (CosNaming::NamingContext::NotFound, ex) - { - if (ex.why == CosNaming::NamingContext::missing_node && - ex.rest_of_name.length () == 1 - && ACE_OS::strcmp (ex.rest_of_name[0].id.in (), - "bar") == 0) - ACE_DEBUG ((LM_DEBUG, - "NotFound exception (case 1) works properly\n")); - else - ACE_DEBUG ((LM_DEBUG, - "NotFound exception (case 1)" - " - parameters aren't set correctly\n")); - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, "Not found test failed\n")); - ACE_RE_THROW; - } - ACE_ENDTRY; - ACE_CHECK; -} - -void -Exceptions_Test::not_found_test2 (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - CosNaming::Name test_name; - test_name.length (3); - test_name[0].id = CORBA::string_dup ("level1_context"); - test_name[1].id = CORBA::string_dup ("level3_context"); - test_name[2].id = CORBA::string_dup ("foo"); - - root_context->unbind (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Unbind test failed\n")); - } - ACE_CATCH (CosNaming::NamingContext::NotFound, ex) - { - if (ex.why == CosNaming::NamingContext::missing_node - && ex.rest_of_name.length () == 2 - && ACE_OS::strcmp (ex.rest_of_name[0].id.in (), - "level3_context") == 0 - && ACE_OS::strcmp (ex.rest_of_name[1].id.in (), - "foo") == 0) - ACE_DEBUG ((LM_DEBUG, - "NotFound exception (case 2) works properly\n")); - else - ACE_DEBUG ((LM_DEBUG, - "NotFound exception (case 2)" - " - parameters aren't set correctly\n")); - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, "Unbind test failed\n")); - ACE_RE_THROW; - } - - ACE_ENDTRY; - ACE_CHECK; -} - -void -Exceptions_Test::not_found_test3 (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - CosNaming::Name test_name; - test_name.length (3); - test_name[0].id = CORBA::string_dup ("level1_context"); - test_name[1].id = CORBA::string_dup ("foo"); - test_name[2].id = CORBA::string_dup ("foo"); - - root_context->unbind (test_name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Not found (case 3) test failed - no exception was thrown\n")); - } - ACE_CATCH (CosNaming::NamingContext::NotFound, ex) - { - if (ex.why == CosNaming::NamingContext::not_context - && ex.rest_of_name.length () == 2 - && ACE_OS::strcmp (ex.rest_of_name[0].id.in (), - "foo") == 0 - && ACE_OS::strcmp (ex.rest_of_name[1].id.in (), - "foo") == 0) - ACE_DEBUG ((LM_DEBUG, - "NotFound exception (case 3) works properly\n")); - else - ACE_DEBUG ((LM_DEBUG, - "NotFound exception (case 3)" - " - parameters aren't set correctly\n")); - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, "Not found (case 3) test failed\n")); - ACE_RE_THROW; - } - ACE_ENDTRY; - ACE_CHECK; -} - -int -Iterator_Test::execute (TAO_Naming_Client &root_context) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Instantiate four dummy objects. - My_Test_Object *impl = new My_Test_Object; - Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Bind objects to the naming context. - CosNaming::Name name1; - name1.length (1); - name1[0].id = CORBA::string_dup ("foo1"); - CosNaming::Name name2; - name2.length (1); - name2[0].id = CORBA::string_dup ("foo2"); - CosNaming::Name name3; - name3.length (1); - name3[0].id = CORBA::string_dup ("foo3"); - CosNaming::Name name4; - name4.length (1); - name4[0].id = CORBA::string_dup ("foo4"); - root_context->bind (name1, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - root_context->bind (name2, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - root_context->bind (name3, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - root_context->bind (name4, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // List the content of the Naming Context. - CosNaming::BindingIterator_var iter; - CosNaming::BindingList_var bindings_list; - root_context->list (1, - bindings_list.out (), - iter.out () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (CORBA::is_nil (iter.in ()) - || bindings_list->length () != 1 - || bindings_list[0u].binding_type != CosNaming::nobject) - ACE_ERROR_RETURN ((LM_ERROR, - "CosNaming::list does not function properly\n"), - -1); - ACE_DEBUG ((LM_DEBUG, - "First binding: %s\n", - bindings_list[0u].binding_name[0u].id.in ())); - - // Invoke operations on the iterator. - CosNaming::Binding_var binding; - iter->next_one (binding.out () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (binding->binding_type != CosNaming::nobject) - ACE_ERROR_RETURN ((LM_ERROR, - "CosNaming::next_one does not function properly\n"), - -1); - ACE_DEBUG ((LM_DEBUG, - "Second binding: %s\n", - binding->binding_name[0].id.in ())); - - iter->next_n (2, bindings_list.out () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (bindings_list->length () != 2 - || bindings_list[0u].binding_type != CosNaming::nobject - || bindings_list[1u].binding_type != CosNaming::nobject) - ACE_ERROR_RETURN ((LM_ERROR, - "CosNaming::BindingIterator does not function properly\n"), - -1); - ACE_DEBUG ((LM_DEBUG, - "Third binding: %s\n" - "Fourth binding: %s\n", - bindings_list[0u].binding_name[0].id.in (), - bindings_list[1u].binding_name[0].id.in ())); - - // We already iterated over all the bindings, so the following - // should return false. - CORBA::Boolean result = iter->next_one (binding.out () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (result) - ACE_ERROR_RETURN ((LM_ERROR, - "CosNaming::BindingIterator does not function properly\n"), - -1); - iter->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Iterator test"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - return 0; -} - -int -Destroy_Test::execute (TAO_Naming_Client &root_context) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Create a context and bind an object under it. - - CosNaming::NamingContext_var my_context; - my_context = root_context->new_context (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Bind a dummy object foo under my_context. - My_Test_Object *impl = new My_Test_Object; - Test_Object_var obj = impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - impl->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosNaming::Name object_name; - object_name.length (1); - object_name[0].id = CORBA::string_dup ("foo"); - my_context->bind (object_name, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Do the testing. - not_empty_test (my_context - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - my_context->unbind (object_name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - my_context->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - not_exist_test (my_context - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unexpected exception in Destroy test"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - return 0; -} - -void -Destroy_Test::not_empty_test (CosNaming::NamingContext_var &ref - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - ref->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - - ACE_CATCH (CosNaming::NamingContext::NotEmpty, ex) - { - ACE_DEBUG ((LM_DEBUG, - "NotEmpty exception works properly\n")); - } - ACE_ENDTRY; - ACE_CHECK; -} - -void -Destroy_Test::not_exist_test (CosNaming::NamingContext_var &ref - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - ref->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - - ACE_CATCH (CORBA::OBJECT_NOT_EXIST, ex) - { - ACE_DEBUG ((LM_DEBUG, - "Destroy works properly\n")); - } - ACE_ENDTRY; - ACE_CHECK; -} - -Persistent_Test_Begin::Persistent_Test_Begin (CORBA::ORB_ptr orb, - FILE * ior_output_file) - : orb_ (orb), - file_ (ior_output_file) -{ -} - -Persistent_Test_Begin::~Persistent_Test_Begin (void) -{ -} - -int -Persistent_Test_Begin::execute (TAO_Naming_Client &root_context) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Create a name structure we will reuse. - CosNaming::Name test_name; - test_name.length (1); - test_name[0].id = CORBA::string_dup ("level1"); - - // Create and bind a naming context under the <root> context. - CosNaming::NamingContext_var level1_context = - root_context->bind_new_context (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Create and bind a naming context under <level1> context. - test_name[0].id = CORBA::string_dup ("level2"); - CosNaming::NamingContext_var level2_context = - level1_context->bind_new_context (test_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Log the ior of <level1_context> for use by <Persistent_Test_End>. - CORBA::String_var ior = - orb_->object_to_string (level1_context.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_OS::fprintf (this->file_, - "%s", - ior.in ()); - ACE_OS::fclose (this->file_); - - ACE_DEBUG ((LM_DEBUG, "Persistent Naming test (part 1) OK.\n")); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Unexpected exception in Persistent Test (part 1)"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - return 0; -} - -Persistent_Test_End::Persistent_Test_End (CORBA::ORB_ptr orb, - const char *ior) - : orb_ (orb), - ior_ (ior) -{ -} - -Persistent_Test_End::~Persistent_Test_End (void) -{ -} - -int -Persistent_Test_End::execute (TAO_Naming_Client &root_context) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Create a name structure we will reuse. - CosNaming::Name test_name; - test_name.length (1); - test_name[0].id = CORBA::string_dup ("level2"); - - // Convert stringified ior we got from <Persistent_Test_Begin> - // for <level1> Naming Context to Naming Context reference. - CORBA::Object_var obj = - orb_->string_to_object (ior_ ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosNaming::NamingContext_var level1_context = - CosNaming::NamingContext::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (level1_context.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - "Cannot narrow object to Naming Context\n"), - -1); - - // Resolve for <level2> context through the persistent ior we - // got from part 1 of this test. - obj = level1_context->resolve (test_name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Now, resolve for <level2> context using the <root> context - // reference which we obtained through <resolve_initial_references>. - test_name.length (2); - test_name[0].id = CORBA::string_dup ("level1"); - test_name[1].id = CORBA::string_dup ("level2"); - CORBA::Object_var obj2 = - root_context->resolve (test_name ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Make sure we got the same answer through both methods. - if (obj2->_is_equivalent (obj.in ())) - ACE_DEBUG ((LM_DEBUG, "Persistent Naming test (part 2) OK.\n")); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Unexpected exception in Persistent Test (part 2)"); - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - return 0; -} - -// This function runs the test. - -int -main (int argc, char **argv) -{ - CosNaming_Client cosnaming_client; - - if (cosnaming_client.init (argc, argv) == -1) - return 1; - - return cosnaming_client.run (); -} diff --git a/TAO/orbsvcs/tests/Simple_Naming/client.h b/TAO/orbsvcs/tests/Simple_Naming/client.h deleted file mode 100644 index e8fe27385c1..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/client.h +++ /dev/null @@ -1,335 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO/orbsvcs/tests -// -// = FILENAME -// client.h -// -// = DESCRIPTION -// This class tests the facilities to connect to the naming service. -// -// = AUTHORS -// Marina Spivak <marina@cs.wustl.edu> -// -// ============================================================================ - -#include "test_objectS.h" -#include "orbsvcs/CosNamingC.h" -#include "orbsvcs/Naming/Naming_Client.h" -#include "tao/Utils/ORB_Manager.h" -#include "ace/Task.h" - -class Naming_Test -{ - // = TITLE - // This is an abstract class which is subclassed - // to create different Naming Service tests. - // - // = DESCRIPTION - // This is a basic example of the "Strategy" pattern. This class - // provides a common interface for different tests (or - // "strategies"), so that a specific test to be used can be - // chosen at runtime. - -public: - virtual ~Naming_Test (void) {} - virtual int execute (TAO_Naming_Client &root_context) = 0; - // Execute the test code. <root_context> is the context to assume - // as the root for all tests operations. -}; - -class Simple_Test : public Naming_Test -{ - // = TITLE - // This class implements a simple Naming Service test. - // - // = DESCRIPTION - // The test binds(), resolves(), and unbinds() an object - // reference from the given Naming Context. -public: - virtual int execute (TAO_Naming_Client &root_context); - // Execute the simple test code. -}; - -class MT_Test : public Naming_Test, public ACE_Task_Base -{ - // = TITLE - // This class implements a simple Multithreaded (multiclient) Naming Service test. - // - // = DESCRIPTION - // The test spawns multiple threads: each attempts to - // bind(), resolve(), and unbind() an object - // reference using the same name, and the same Naming Context. -public: - // = Initialization and termination methods. - - MT_Test (CORBA::ORB_ptr orb, - int size = 10); - // Constructor. Takes in an orb pointer and number of threads to spawn. - - virtual int execute (TAO_Naming_Client &root_context); - // Execute the MT test code. - - virtual int svc (void); - // This code is executed by each thread. - -private: - int size_; - // Number of threads to spawn. By default is set to 10. - - CORBA::ORB_var orb_; - // A pointer to our ORB. - - char* name_service_ior_; - // IOR in the string format for Naming Service we are to deal with. - // Each thread will use string_to_object() and this IOR to create - // its own NamingContext stub for invoking operations on the - // Naming Service. If all threads try to use the same stub, bad things - // happen... - - // This can be replaced with CORBA::String_var when <string_to_object> - // is fixed - this will clean up the memory properly. - - CosNaming::Name test_name_; - // Holds name used for registering the object with Naming Service. - - Test_Object_var test_ref_; - // Holds object to be registered with the Naming Service by each thread. - -}; - -class Tree_Test : public Naming_Test -{ - // = TITLE - // This class implements a test of all Naming Service functions - // on a tree of Naming Contexts. - // - // = DESCRIPTION - // Bind_context() under the root context with the name level1. - // Create_new_context(), bind() foo object into it, and - // bind the context into root/level1 under the name level2. - // Resolve (root/level1/level2/foo). - // Unbind (root/level1/level2/foo). - // Bind (root/level1/level2/foo, obj) - // Create_new_context() - // and invoke rebind_context() to substitute it for the current - // level2 context. - // Bind (root/level1/level2/foo, obj) - // Resolve (root/level1/level2/foo). - // Rebind() to have a different object under the name bar. - // Resolve (root/level1/level2/foo) to make sure correct reference is returned. -public: - virtual int execute (TAO_Naming_Client &root_context); - // Execute the tree test code. -}; - -class Iterator_Test : public Naming_Test -{ - // = TITLE - // This class implements a test of Naming Service functions - // which involve BindingIterator. - // - // = DESCRIPTION - // The test binds foo1, foo2, foo3, and foo4 objects to the - // Naming Context. It lists() one binding and receives - // BindingIterator to iterate over the rest of the bindings. It - // then invokes next_one(), next_n(2), next_one(), and destroy() - // on the iterator. -public: - virtual int execute (TAO_Naming_Client &root_context); - // Execute the iterator test code. -}; - -class Exceptions_Test : public Naming_Test -{ - // = TITLE - // This class implements a test of exceptions in the Naming Service. - // - // = DESCRIPTION - // Makes sure that Naming Service throws exceptions as expected, and - // data inside exceptions is set correctly. The test creates a tree of - // of Naming Contexts: root context -> level1 -> level2. It then binds() an - // object with the name foo to each of Naming Contexts in the tree. - // Invoke resolve() with a Name of length 0 - make sure we get InvalidName exception. - // Invoke bind( foo, obj) on root context - make sure we get AlreadyBound exception. - // Invoke bind( level1/foo, obj) on root context - make sure we get AlreadyBound exc. - // Invoke unbind( level1/level2/bar) on root context - make sure we get NotFound exc. - // with why = not_object, rest_of_name = bar. - // Invoke unbind( level1/level3/foo) on root context - make sure we get NotFound exc. - // with why = missing_node, rest_of_name = level3/foo. - // Invoke unbind( level1/foo/foo) on root context - make sure we get NotFound exc. - // with why = not_context, rest_of_name = foo/foo. -public: - virtual int execute (TAO_Naming_Client &root_context); - // Execute the exceptions test code. - -private: - // the following functions isolate specific tests due to the - // limitation of only 1 TAO_TRY being allowed per function. - - void invalid_name_test (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL); - void already_bound_test (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL); - void already_bound_test2 (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL); - void not_found_test (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL); - void not_found_test2 (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL); - void not_found_test3 (TAO_Naming_Client &root_context - ACE_ENV_ARG_DECL); -}; - -class Destroy_Test : public Naming_Test -{ - // = TITLE - // This class implements a test of destroy() function - // in the Naming Service. - // - // = DESCRIPTION - // Create a context and bind an object under it. - // Attempt to destroy the context - NotEmpty exception should be raised. - // - // Unbind the object and call destroy on the context. - // Attempt to call destroy on the object again - OBJECT_NOT_EXIST - // exception should be raised. - // -public: - virtual int execute (TAO_Naming_Client &root_context); - // Execute the destroy test code. - -private: - // = The following functions isolate specific tests. - void not_empty_test (CosNaming::NamingContext_var &ref - ACE_ENV_ARG_DECL); - void not_exist_test (CosNaming::NamingContext_var &ref - ACE_ENV_ARG_DECL); -}; - -class Persistent_Test_Begin : public Naming_Test -{ - // = TITLE - // This class implements the first part of the Persistent Naming - // Service test. - // - // = DESCRIPTION - // This test creates the Naming Context hierarchy: - // root -> level1_context -> level2_context, - // and prints out the ior of the <level1_context>. -public: - // = Initialization and termination methods. - - Persistent_Test_Begin (CORBA::ORB_ptr orb, - FILE * ior_output_file); - // Constructor. Takes in an orb pointer. - - virtual ~Persistent_Test_Begin (void); - // Destructor. - - virtual int execute (TAO_Naming_Client &root_context); - // Execute the persistent test (part 1) code. - -private: - - CORBA::ORB_var orb_; - // A pointer to our ORB (needed for object/string conversion). - - FILE *file_; - // File where we output the ior for use by part 2 of persistent test. -}; - -class Persistent_Test_End : public Naming_Test -{ - // = TITLE - // This class implements the second part of the Persistent Naming - // Service test. - // - // = DESCRIPTION - // This test attempts to resolve <level2_context> both through the - // <root> Naming Context, which it gets from <resolve_initial_references>, and - // through <level1_context> stringified ior, which it gets from part 1 of - // the persistent test. The results of both methods are then - // compared for equality. -public: - // = Initialization and termination methods. - - Persistent_Test_End (CORBA::ORB_ptr orb, - const char * ior); - // Constructor. Takes in an orb pointer and the ior received from - // <Persistent_Test_Begin>. - - virtual ~Persistent_Test_End (void); - // Destructor. - - virtual int execute (TAO_Naming_Client &root_context); - // Execute the persistent test (part 2). - -private: - - CORBA::ORB_var orb_; - // A pointer to our ORB (used for string/object conversion). - - const char* ior_; - // IOR of <level1_context> recorded during the run of part 1 of - // persistent test. -}; - -class CosNaming_Client -{ - // = TITLE, - // Defines a class that encapsulates behaviour of the CosNaming - // client example. Provides a better understanding of the logic - // in an object-oriented way. - // - // = DESCRIPTION - // This class declares an interface to run the example client for - // CosNaming CORBA server. All the complexity for initializing - // the server is hidden in the class. Just the <run> interface - // is needed. -public: - // = Initialization and termination methods. - - CosNaming_Client (void); - // Constructor. - - ~CosNaming_Client (void); - // Destructor. - - int run (void); - // Execute client example code. - - int init (int argc, char **argv); - // Initialize the client communication endpoint with server. - - // = Symbolic ids. - enum OBJ_ID - { - OBJ1_ID = 5, - OBJ2_ID = 6 - }; - -private: - int parse_args (void); - // Parses the arguments passed on the command line. - - int argc_; - // # of arguments on the command line. - - char **argv_; - // arguments from command line. - - Naming_Test *test_; - // A pointer to the specific Naming Service test a client will - // execute. - - TAO_ORB_Manager orbmgr_; - // Our ORB manager helper class. - - TAO_Naming_Client naming_client_; - // Our naming client helper class. -}; diff --git a/TAO/orbsvcs/tests/Simple_Naming/process-m-output.pl b/TAO/orbsvcs/tests/Simple_Naming/process-m-output.pl deleted file mode 100755 index c9205bda74a..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/process-m-output.pl +++ /dev/null @@ -1,115 +0,0 @@ -# $Id$ -# -*- perl -*- -eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' - & eval 'exec perl -S $0 $argv:q' - if 0; - -# This is a Perl script that processes the output of the multithreaded -# client test. Usage: process-m-output.pl output-file-name number-of-threads - -# The following checks are performed: -# 1) Number of sucessful binds equals to the number of sucessful -# unbinds. -# 2) Each thread id has 1 output line for each of the following: bind, -# resolve and unbind. -# 3) There are no unexpected output lines (e.g., more lines than -# expected or with unexpected content like Exceptions, seg faults). - -# Open the output file. -$input_file = $ARGV[0]; -if ($input_file and $ARGV[1]) -{ - open (DATA, $input_file); -} -else -{ - die "Usage: process-m-output.pl output-file-name number-of-threads \n"; -} - -$errors = 0; - -$binds = 0; -$unbinds = 0; - -while ($line = <DATA>) -{ - # Process the line. - chomp $line; - @words = split (/ /, $line); - - # Ignore the empty line, the "CommandLine:" line and the "WARNING:" line - # from the orbsvcs/orbsvcs/Shutdown_Utilities.cpp. - if ($#words == -1 or - $words[0] eq "CommandLine:" or - $line =~ /WARNING: /) { - next; - } - - # Make sure the line contains expected output. - if (not ($words[0] eq "Unbound" or - $words[0] eq "Bound" or - $words[0] eq "Resolved" or - $words[0] eq "Unable")) - { - close (DATA); - die "Error is detected in the output file <$input_file> \n"; - } - - # Keep track of sucessful binds/unbinds. - if ($words[0] eq "Bound") - { - ++$binds; - } - if ($words[0] eq "Unbound") - { - ++$unbinds; - } - - # Keep track of output lines for each thread. - $count = $threads{$words[5]}; - - if ($count eq "" and - ($words[0] eq "Bound" or $words[2] eq "bind")) - { - ++$threads{$words[5]}; - } - elsif ($count eq 1 and - ($words[0] eq "Resolved" or $words[2] eq "resolve")) - { - ++$threads{$words[5]}; - } - elsif ($count eq 2 and - ($words[0] eq "Unbound" or $words[2] eq "unbind")) - { - ++$threads{$words[5]}; - } - else - { - close (DATA); - die "Wrong output for thread $word[5]\n"; - } -} -close (DATA); -# Check that each thread performed 3 operations. -if (grep {not $_ eq 3} values %threads) -{ - die "Some thread has performed a wrong number of operations\n"; -} -$number = values %threads; -if ($number ne $ARGV[1]) -{ - die "Not all threads performed operations\n"; -} - -# Check that number of binds equals to those of unbinds. -if ($binds == $unbinds) -{ - print "Multithreaded output is ok \n"; -} -else -{ - print "Number of sucessfule binds is different from number of -sucessful unbinds\n"; -} - -exit $errors; diff --git a/TAO/orbsvcs/tests/Simple_Naming/run_test.pl b/TAO/orbsvcs/tests/Simple_Naming/run_test.pl deleted file mode 100755 index 28ed2918ece..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/run_test.pl +++ /dev/null @@ -1,196 +0,0 @@ -eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' - & eval 'exec perl -S $0 $argv:q' - if 0; - -# $Id$ -# -*- perl -*- - -# This is a Perl script that runs some Naming Service tests. -# It runs all the tests that will run with min CORBA. -# It starts all the servers and clients as necessary. - -use lib '../../../../bin'; -use PerlACE::Run_Test; -use Cwd; - -## Save the starting directory -$startdir = getcwd(); - -# Amount of delay (in seconds) between starting a server and a client -# to allow proper server initialization. -$sleeptime = 10; - -$quiet = 0; - -# check for -q flag -if ($ARGV[0] eq '-q') { - $quiet = 1; -} - -# Variables for command-line arguments to client and server -# executables. -$ns_multicast_port = 10001 + PerlACE::uniqueid (); # Can not be 10000 on Chorus 4.0 -$ns_orb_port = 12000 + PerlACE::uniqueid (); -$iorfile = PerlACE::LocalFile ("ns.ior"); -$persistent_ior_file = PerlACE::LocalFile ("pns.ior"); -$persistent_log_file = PerlACE::LocalFile ("test_log"); -$data_file = PerlACE::LocalFile ("test_run.data"); - -$status = 0; - -sub name_server -{ - my $args = "-ORBNameServicePort $ns_multicast_port -o $iorfile -m 1 @_"; - my $prog = "$startdir/../../Naming_Service/Naming_Service"; - $NS = new PerlACE::Process ($prog, $args); - - unlink $iorfile; - - $NS->Spawn (); - - if (PerlACE::waitforfile_timed ($iorfile, $sleeptime) == -1) { - print STDERR "ERROR: cannot find IOR file <$iorfile>\n"; - $NS->Kill (); - exit 1; - } -} - -sub client -{ - my $args = "@_"." "; - my $prog = "$startdir/client"; - - $CL = new PerlACE::Process ($prog, $args); - - $client = $CL->SpawnWaitKill (60); - - if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; - $status = 1; - } -} - -## The options below have been reordered due to a -## initialization problem (within the Naming_Service) -## that has only been seen on Windows XP. - -# Options for all simple tests recognized by the 'client' program. -@opts = ("-s -ORBInitRef NameService=file://$iorfile", - "-p $persistent_ior_file -ORBInitRef NameService=file://$iorfile", - "-s -ORBInitRef NameService=mcast://:$ns_multicast_port\::/NameService", - "-t -ORBInitRef NameService=file://$iorfile", - "-i -ORBInitRef NameService=file://$iorfile", - "-e -ORBInitRef NameService=file://$iorfile", - "-y -ORBInitRef NameService=file://$iorfile", - "-c file://$persistent_ior_file -ORBInitRef NameService=file://$iorfile", - ); - -@server_opts = ("-t 30", - "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port -f $persistent_log_file", - "", "", "", "", "", - "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port -f $persistent_log_file", - ); - -@comments = ("Simple Test: \n", - "mmap() Persistent Test (Part 1): \n", - "Simple Test (using multicast to locate the server): \n", - "Tree Test: \n", - "Iterator Test: \n", - "Exceptions Test: \n", - "Destroy Test: \n", - "mmap() Persistent Test (Part 2): \n", - ); - -$test_number = 0; - -## Allow the user to determine where the persistent file will be located -## just in case the current directory is not suitable for locking. -## We can't change the name of the persistent file because that is not -## sufficient to work around locking problems for Tru64 when the current -## directory is NFS mounted from a system that does not properly support -## locking. -foreach my $possible ($ENV{TMPDIR}, $ENV{TEMP}, $ENV{TMP}) { - if (defined $possible && -d $possible) { - if (chdir($possible)) { - last; - } - } -} - -print "INFO: Running the test in ", getcwd(), "\n"; - -unlink ($persistent_ior_file, $persistent_log_file); - -# Run server and client for each of the tests. Client uses ior in a -# file to bootstrap to the server. -foreach $o (@opts) { - name_server ($server_opts[$test_number]); - - print STDERR "\n ".$comments[$test_number]; - - client ($o); - - $NS->Kill (); - - ## For some reason, only on Windows XP, we need to - ## wait before starting another Naming_Service when - ## the mmap persistence option is used - if ($^O eq "MSWin32") { - sleep(1); - } - - $test_number++; -} - -unlink ($persistent_ior_file, $persistent_log_file); - -# Now run the multithreaded test, sending output to the file. -print STDERR "\n Multithreaded Test:\n"; -unlink $data_file; - -open (OLDOUT, ">&STDOUT"); -open (STDOUT, ">$data_file") or die "can't redirect stdout: $!"; -open (OLDERR, ">&STDERR"); -open (STDERR, ">&STDOUT") or die "can't redirect stderror: $!"; - -# just here to quiet warnings -$fh = \*OLDOUT; -$fh = \*OLDERR; - -name_server (); - -client ("-ORBInitRef NameService=file://$iorfile", "-m15"); - -close (STDERR); -close (STDOUT); -open (STDOUT, ">&OLDOUT"); -open (STDERR, ">&OLDERR"); - -$NS->Kill (); - -unlink $iorfile; - - -$errors = system ("perl $startdir/process-m-output.pl $data_file 15") >> 8; - -if ($errors > 0) { - $status = 1; - - if (!$quiet) { - print STDERR "Errors Detected, printing output\n"; - if (open (DATA, "<$data_file")) { - print STDERR "================================= Begin\n"; - print STDERR <DATA>; - print STDERR "================================= End\n"; - close (DATA); - } - else { - print STDERR "ERROR: Could not open $data_file\n"; - } - unlink $data_file; - } -} - -unlink $iorfile; - -exit $status; diff --git a/TAO/orbsvcs/tests/Simple_Naming/run_test_ffp.pl b/TAO/orbsvcs/tests/Simple_Naming/run_test_ffp.pl deleted file mode 100755 index 068b5c66038..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/run_test_ffp.pl +++ /dev/null @@ -1,131 +0,0 @@ -eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' - & eval 'exec perl -S $0 $argv:q' - if 0; - -# $Id$ -# -*- perl -*- - -# This is a Perl script that runs additional Naming Service tests. -# It runs all the tests that will *not* run with min CORBA. -# It starts all the servers and clients as necessary. - -use lib '../../../../bin'; -use PerlACE::Run_Test; - -# Amount of delay (in seconds) between starting a server and a client -# to allow proper server initialization. -$sleeptime = 10; - -$quiet = 0; - -# check for -q flag -if ($ARGV[0] eq '-q') { - $quiet = 1; -} - -# Variables for command-line arguments to client and server -# executables. -$ns_multicast_port = 10001 + PerlACE::uniqueid (); # Can not be 10000 on Chorus 4.0 -$ns_orb_port = 12000 + PerlACE::uniqueid (); -$iorfile = PerlACE::LocalFile ("ns.ior"); -$file_persistent_ior_file = PerlACE::LocalFile ("fpns.ior"); - -$status = 0; - -sub name_server -{ - my $args = "-ORBNameServicePort $ns_multicast_port -o $iorfile -m 1 @_"; - my $prog = "../../Naming_Service/Naming_Service"; - $NS = new PerlACE::Process ($prog, $args); - - unlink $iorfile; - - $NS->Spawn (); - - if (PerlACE::waitforfile_timed ($iorfile, $sleeptime) == -1) { - print STDERR "ERROR: cannot find IOR file <$iorfile>\n"; - $NS->Kill (); - exit 1; - } -} - -sub client -{ - my $args = "@_"." "; - my $prog = "client"; - - $CL = new PerlACE::Process ($prog, $args); - - $client = $CL->SpawnWaitKill (60); - - if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; - $status = 1; - } -} - -## The options below have been reordered due to a -## initialization problem (within the Naming_Service) -## that has only been seen on Windows XP. - -# Options for all simple tests recognized by the 'client' program. -@opts = ("-p $file_persistent_ior_file -ORBInitRef NameService=file://$iorfile", - "-c file://$file_persistent_ior_file -ORBInitRef NameService=file://$iorfile"); - -@server_opts = ("-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port -u NameService", - "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port -u NameService"); - -@comments = ("Flat File Persistent Test (Part 1): \n", - "Flat File Persistent Test (Part 2): \n"); - -$test_number = 0; - -unlink ($file_persistent_ior_file); - -if ( ! -d "NameService" ) { - mkdir (NameService, 0777); - } -else { - chdir "NameService"; - opendir(THISDIR, "."); - @allfiles = grep(!/^\.\.?$/, readdir(THISDIR)); - closedir(THISDIR); - unlink @allfiles; - chdir ".."; - } - - -# Run server and client for each of the tests. Client uses ior in a -# file to bootstrap to the server. -foreach $o (@opts) { - name_server ($server_opts[$test_number]); - - print STDERR "\n ".$comments[$test_number]; - - client ($o); - - $NS->Kill (); - - ## For some reason, only on Windows XP, we need to - ## wait before starting another Naming_Service when - ## the mmap persistence option is used - if ($^O eq "MSWin32") { - sleep(1); - } - - $test_number++; -} - -unlink ($file_persistent_ior_file); - -chdir "NameService"; -opendir(THISDIR, "."); -@allfiles = grep(!/^\.\.?$/, readdir(THISDIR)); -closedir(THISDIR); -unlink @allfiles; -chdir ".."; -rmdir "NameService"; - -unlink $iorfile; - -exit $status; diff --git a/TAO/orbsvcs/tests/Simple_Naming/test_object.idl b/TAO/orbsvcs/tests/Simple_Naming/test_object.idl deleted file mode 100644 index 4737f6dc6c8..00000000000 --- a/TAO/orbsvcs/tests/Simple_Naming/test_object.idl +++ /dev/null @@ -1,11 +0,0 @@ -// $Id$ - -interface Test_Object -{ - // = TITLE - // This is a simple interface that tests the Naming Service. - - attribute short id; - // This provides an easy way to differentiate objects if each - // objects is served by a separate servant. -}; |