diff options
author | marina <marina@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-09-14 02:34:08 +0000 |
---|---|---|
committer | marina <marina@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-09-14 02:34:08 +0000 |
commit | 54613f955d008f7d85622ab7e0fcc928e77eca56 (patch) | |
tree | e0eeaaca774b417596b1c2c8197188d4712a5bf0 | |
parent | 33e656498392ece4ff62748f5f3d86a5eeb24ca3 (diff) | |
download | ATCD-54613f955d008f7d85622ab7e0fcc928e77eca56.tar.gz |
updated Naming Tests.
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/README | 45 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/client.cpp | 143 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/client.h | 4 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Simple_Naming/run_test.pl | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/test_object.idl | 7 |
5 files changed, 123 insertions, 78 deletions
diff --git a/TAO/orbsvcs/tests/Simple_Naming/README b/TAO/orbsvcs/tests/Simple_Naming/README index 2751649d669..7d2df0b62ae 100644 --- a/TAO/orbsvcs/tests/Simple_Naming/README +++ b/TAO/orbsvcs/tests/Simple_Naming/README @@ -1,7 +1,13 @@ // $Id$ -This application tests different features of TAO's Naming Service -based on the command line option. +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 Naming Service ($TAO_ROOT/orbsvcs/Naming_Service/Naming_Service), + then run ./client with one of the following options below. The following options exist: @@ -18,7 +24,12 @@ The following options exist: If no option is specified, Simple test is run. If more than one option is specified, only one test runs. -Below is the description of each test. +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). + + + +DESCRIPTION AND EXPECTED OUTPUT FOR EACH TEST ******************************************* Simple Test. @@ -26,6 +37,13 @@ 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 + ******************************************** Tree Test. @@ -51,6 +69,8 @@ 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: none ******************************************** Exceptions Test. @@ -72,6 +92,15 @@ root->unbind (level1/level3/foo) - should get NotFound exception 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. @@ -85,10 +114,18 @@ 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. -This test will ... +Expected Output: ******************************************** diff --git a/TAO/orbsvcs/tests/Simple_Naming/client.cpp b/TAO/orbsvcs/tests/Simple_Naming/client.cpp index 0190b07dd35..29520530541 100644 --- a/TAO/orbsvcs/tests/Simple_Naming/client.cpp +++ b/TAO/orbsvcs/tests/Simple_Naming/client.cpp @@ -24,33 +24,53 @@ ACE_RCSID(Simple_Naming, client, "$Id$") -//@@ Please make sure you run Purify on these tests! - class My_Test_Object : public POA_Test_Object { public: - // @@ Please move the definitions of the method bodies to outside of - // the class definition. - My_Test_Object (CORBA::Short id = 0) - // @@ Please use the base-member initialization section, i.e., - // : id_ (id) - { - id_ = id; - }; - - ~My_Test_Object (void) {}; - - // @@ For kicks, you might define id() as an "attribute" rather than - // an "operation" in the IDL file. - CORBA::Short get_id (CORBA::Environment &_env) - { - return id_; - }; + // = Initialization and termination methods. + + My_Test_Object (CORBA::Short id); + // Constructor. + + ~My_Test_Object (void); + // Destructor. + + // = Interface implementation accessor methods. + + void id (CORBA::Short id, CORBA::Environment &_env); + // Sets id. + + CORBA::Short id (CORBA::Environment &_env); + // Gets id. private: short id_; }; + +My_Test_Object::My_Test_Object (CORBA::Short id = 0) + : id_ (id) +{ +} + +My_Test_Object::~My_Test_Object (void) +{ +} + +CORBA::Short +My_Test_Object::id (CORBA::Environment &_env) +{ + return id_; +} + + +void +My_Test_Object::id (CORBA::Short id, CORBA::Environment &_env) +{ + id_ = id; +} + + // Constructor. CosNaming_Client::CosNaming_Client (void) @@ -67,9 +87,6 @@ CosNaming_Client::parse_args (void) { ACE_Get_Opt get_opts (argc_, argv_, "dstiey"); int c; - // @@ Instead of using a not_set flag, why not set this->test_ to 0 - // initially, and then just check to see if it's already set?! - int not_set = 1; while ((c = get_opts ()) != -1) switch (c) @@ -78,45 +95,34 @@ CosNaming_Client::parse_args (void) TAO_debug_level++; break; case 's': - if (not_set) - { - // @@ Please use the ACE_NEW_RETURN macro to make sure - // that you check the return status in case new fails. - // if (this->test_ == 0) - // ACE_NEW_RETURN (this->test_, - // Simple_Test, - // -1); - this->test_ = new Simple_Test (); - not_set = 0; - } + if (this->test_ == 0) + ACE_NEW_RETURN (this->test_, + Simple_Test, + -1); break; case 't': - if (not_set) - { - this->test_ = new Tree_Test (); - not_set = 0; - } + if (this->test_ == 0) + ACE_NEW_RETURN (this->test_, + Tree_Test, + -1); break; case 'i': - if (not_set) - { - this->test_ = new Iterator_Test (); - not_set = 0; - } + if (this->test_ == 0) + ACE_NEW_RETURN (this->test_, + Iterator_Test, + -1); break; case 'e': - if (not_set) - { - this->test_ = new Exceptions_Test (); - not_set = 0; - } + if (this->test_ == 0) + ACE_NEW_RETURN (this->test_, + Exceptions_Test, + -1); break; case 'y': - if (not_set) - { - this->test_ = new Destroy_Test (); - not_set = 0; - } + if (this->test_ == 0) + ACE_NEW_RETURN (this->test_, + Destroy_Test, + -1); break; default: ACE_ERROR_RETURN ((LM_ERROR, @@ -128,9 +134,11 @@ CosNaming_Client::parse_args (void) -1); } - // @@ Same thing here... - if (not_set) - test_ = new Simple_Test (); + if (this->test_ == 0) + ACE_NEW_RETURN (this->test_, + Simple_Test, + -1); + // Indicates successful parsing of command line. return 0; } @@ -184,10 +192,7 @@ Simple_Test::execute (TAO_Naming_Client &root_context) TAO_TRY { // Dummy object instantiation. - - // @@ Can you please replace the use of "5" with a symbolic - // constant, i.e., "DEFAULT_ID" or something? - My_Test_Object test_obj_impl (5); + My_Test_Object test_obj_impl (CosNaming_Client::OBJ1_ID); Test_Object_var test_obj_ref = test_obj_impl._this (TAO_TRY_ENV); TAO_CHECK_ENV; @@ -213,7 +218,7 @@ Simple_Test::execute (TAO_Naming_Client &root_context) TAO_TRY_ENV); TAO_CHECK_ENV; if (!CORBA::is_nil (result_object.in ()) - && result_object->get_id (TAO_TRY_ENV) == 5) + && result_object->id (TAO_TRY_ENV) == CosNaming_Client::OBJ1_ID) ACE_DEBUG ((LM_DEBUG, "Resolved name OK\n")); TAO_CHECK_ENV; @@ -256,7 +261,7 @@ Tree_Test::execute (TAO_Naming_Client &root_context) TAO_CHECK_ENV; // Instantiate a dummy object and bind it under the new context. - My_Test_Object impl1 (1); + My_Test_Object impl1 (CosNaming_Client::OBJ1_ID); Test_Object_var obj1 = impl1._this (TAO_TRY_ENV); TAO_CHECK_ENV; CosNaming::Name obj_name; @@ -278,7 +283,7 @@ Tree_Test::execute (TAO_Naming_Client &root_context) // Resolve and unbind level1/level2/foo, and bind it back. CosNaming::Name test_name (level2); test_name.length (3); - test_name[0].id = obj_name[0].id; + test_name[2].id = obj_name[0].id; CORBA::Object_var result_obj_ref = root_context->resolve (test_name, TAO_TRY_ENV); @@ -288,7 +293,7 @@ Tree_Test::execute (TAO_Naming_Client &root_context) TAO_TRY_ENV); TAO_CHECK_ENV; if (CORBA::is_nil (result_object.in ()) - || !result_object->get_id (TAO_TRY_ENV) == 1) + || !result_object->id (TAO_TRY_ENV) == CosNaming_Client::OBJ1_ID) ACE_ERROR_RETURN ((LM_ERROR, "Problems with resolving foo in Tree Test\n"), -1); @@ -303,13 +308,13 @@ Tree_Test::execute (TAO_Naming_Client &root_context) obj1.in (), TAO_TRY_ENV); TAO_CHECK_ENV; - + // Create new context and rebind under the name level1/level2. CosNaming::NamingContext_var new_level2_context; new_level2_context = root_context->new_context (TAO_TRY_ENV); TAO_CHECK_ENV; - root_context->bind_context (level2, + root_context->rebind_context (level2, new_level2_context.in (), TAO_TRY_ENV); TAO_CHECK_ENV; @@ -326,13 +331,13 @@ Tree_Test::execute (TAO_Naming_Client &root_context) TAO_TRY_ENV); TAO_CHECK_ENV; if (CORBA::is_nil (result_object.in ()) - || !result_object->get_id (TAO_TRY_ENV) == 1) + || !result_object->id (TAO_TRY_ENV) == CosNaming_Client::OBJ1_ID) ACE_ERROR_RETURN ((LM_ERROR, "Problems in the Tree Test\n"), -1); TAO_CHECK_ENV; - My_Test_Object impl2 (2); + My_Test_Object impl2 (CosNaming_Client::OBJ2_ID); Test_Object_var obj2 = impl2._this (TAO_TRY_ENV); TAO_CHECK_ENV; root_context->rebind (test_name, @@ -346,7 +351,7 @@ Tree_Test::execute (TAO_Naming_Client &root_context) TAO_TRY_ENV); TAO_CHECK_ENV; if (CORBA::is_nil (result_object.in ()) - || !result_object->get_id (TAO_TRY_ENV) == 2) + || !result_object->id (TAO_TRY_ENV) == CosNaming_Client::OBJ2_ID) ACE_ERROR_RETURN ((LM_ERROR, "Problems with rebind in Tree Test\n"), -1); diff --git a/TAO/orbsvcs/tests/Simple_Naming/client.h b/TAO/orbsvcs/tests/Simple_Naming/client.h index 551fc54600c..88ef2de37ee 100644 --- a/TAO/orbsvcs/tests/Simple_Naming/client.h +++ b/TAO/orbsvcs/tests/Simple_Naming/client.h @@ -164,6 +164,7 @@ class CosNaming_Client // is needed. public: // = Initialization and termination methods. + CosNaming_Client (void); // Constructor. @@ -176,6 +177,9 @@ public: int init (int argc, char **argv); // Initialize the client communication endpoint with server. + enum {OBJ1_ID = 5, OBJ2_ID = 6}; + // symbolic ids. + private: int parse_args (void); // Parses the arguments passed on the command line. diff --git a/TAO/orbsvcs/tests/Simple_Naming/run_test.pl b/TAO/orbsvcs/tests/Simple_Naming/run_test.pl index 8db1f2d9c32..409c859abc3 100755 --- a/TAO/orbsvcs/tests/Simple_Naming/run_test.pl +++ b/TAO/orbsvcs/tests/Simple_Naming/run_test.pl @@ -13,7 +13,7 @@ require Uniqueid; # amount of delay between running the servers -$sleeptime = 3; +$sleeptime = 10; # variables for parameters diff --git a/TAO/orbsvcs/tests/Simple_Naming/test_object.idl b/TAO/orbsvcs/tests/Simple_Naming/test_object.idl index b3a4b8f02a4..0ad7a7b3b5e 100644 --- a/TAO/orbsvcs/tests/Simple_Naming/test_object.idl +++ b/TAO/orbsvcs/tests/Simple_Naming/test_object.idl @@ -5,8 +5,7 @@ interface Test_Object // = TITLE // This is a simple interface to test the Naming Service. - short get_id (); - // Returns the id of the object. This method provides an easy - // way to differentiate objects if each objects is served by a - // separate servant. + attribute short id; + // This provides an easy way to differentiate objects + // if each objects is served by a separate servant. }; |