diff options
Diffstat (limited to 'TAO/orbsvcs/tests/Property/main.cpp')
-rw-r--r-- | TAO/orbsvcs/tests/Property/main.cpp | 368 |
1 files changed, 189 insertions, 179 deletions
diff --git a/TAO/orbsvcs/tests/Property/main.cpp b/TAO/orbsvcs/tests/Property/main.cpp index 639cfc6c116..eb739fae1d6 100644 --- a/TAO/orbsvcs/tests/Property/main.cpp +++ b/TAO/orbsvcs/tests/Property/main.cpp @@ -2,18 +2,18 @@ // ======================================================================== // -// = FILE +// = FILE // Program to test the property services. // // = DESCRIPTION // Here all the objects are at one address space. See the // client.cpp and server.cpp to see property calls on remote -// objects. +// objects. // // = AUTHOR // Alexander Babu Arulanthu <alex@cs.wustl.edu> // -// ======================================================================== +// ======================================================================== #include "orbsvcs/CosPropertyServiceS.h" #include "orbsvcs/Property/CosPropertyService_i.h" @@ -36,35 +36,35 @@ public: TAO_PropertySet_Tester (void); // Constructor. - + ~TAO_PropertySet_Tester (void); // Destructor. - - int test_define_property (CORBA::Environment &ACE_TRY_ENV); + + int test_define_property (CORBA::Environment &env); // Defines a char,a short, a long, a float and a string property. - - int test_get_number_of_properties (CORBA::Environment &ACE_TRY_ENV); + + int test_get_number_of_properties (CORBA::Environment &env); // Gets the number of properties currently defined in the PropertySet. - + int test_delete_property (const char *property_name, - CORBA::Environment &ACE_TRY_ENV); + CORBA::Environment &env); // Delete a given property. - - int test_is_property_defined (CORBA::Environment &ACE_TRY_ENV); + + int test_is_property_defined (CORBA::Environment &env); // Check the following properties are defined or // no. "char_property", "short_property" and a "string_property". - - int test_get_property_value (CORBA::Environment &ACE_TRY_ENV); + + int test_get_property_value (CORBA::Environment &env); // Get the "float_property" and "string_property" and print them // out. - - int test_delete_properties (CORBA::Environment &ACE_TRY_ENV); + + int test_delete_properties (CORBA::Environment &env); // Delete char, short,long, and string properties. - - int test_delete_all_properties (CORBA::Environment &ACE_TRY_ENV); + + int test_delete_all_properties (CORBA::Environment &env); // Delete all the properties. - - int test_define_properties (CORBA::Environment &ACE_TRY_ENV); + + int test_define_properties (CORBA::Environment &env); // Define a sequence of properties. a char, a short, a long, a float // and a string. @@ -73,7 +73,7 @@ private: // The PropertySet. }; -class TAO_PropertyNamesIterator_Tester +class TAO_PropertyNamesIterator_Tester { // = TITLE // The testing code for the PropertyNamesIterator interface are grouped @@ -85,18 +85,18 @@ class TAO_PropertyNamesIterator_Tester public: TAO_PropertyNamesIterator_Tester (TAO_PropertySet_Tester &propertyset_tester); // Constructor. To make names iterator from the property set object. - + ~TAO_PropertyNamesIterator_Tester (void); // Destructor. - int test_next_one (CORBA::Environment &ACE_TRY_ENV); + int test_next_one (CORBA::Environment &env); // Test next one method. Iterate thru all the names in the // PropertySet and print them out. - - int test_reset (CORBA::Environment &ACE_TRY_ENV); + + int test_reset (CORBA::Environment &env); // Test the reset method. - - int test_next_n (size_t n, CORBA::Environment &ACE_TRY_ENV); + + int test_next_n (size_t n, CORBA::Environment &env); // Test the next_n method. private: TAO_PropertyNamesIterator iterator_; @@ -116,13 +116,13 @@ TAO_PropertySet_Tester::~TAO_PropertySet_Tester (void) // Defines a char, a short, a long, a float and a string. int -TAO_PropertySet_Tester::test_define_property (CORBA::Environment &ACE_TRY_ENV) +TAO_PropertySet_Tester::test_define_property (CORBA::Environment &env) { ACE_DEBUG ((LM_DEBUG, "\nChecking define_property\n")); - + CORBA::Any anyval; - + // Prepare a char and "define" that in the PropertySet. CORBA::Char ch = '#'; anyval <<= from_char (ch); @@ -133,23 +133,23 @@ TAO_PropertySet_Tester::test_define_property (CORBA::Environment &ACE_TRY_ENV) ch)); property_set_.define_property ("char_property", anyval, - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); - + env); + TAO_CHECK_ENV_RETURN (env, 1); + // Prepare a Short and "define" that in the PropertySet. CORBA::Short s = 3; - anyval <<= s; - s = 7; + anyval <<= s; + s = 7; anyval >>= s; ACE_DEBUG ((LM_DEBUG, "Main : Short s = %d\n", s)); property_set_.define_property ("short_property", anyval, - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); - + env); + TAO_CHECK_ENV_RETURN (env, 1); + // Prepare a Long and "define" that in the PropertySet. CORBA::Long l = 931232; anyval <<= l; @@ -159,12 +159,12 @@ TAO_PropertySet_Tester::test_define_property (CORBA::Environment &ACE_TRY_ENV) "Main : Long l = %d\n", l)); CORBA::Any newany(anyval); - + property_set_.define_property ("long_property", anyval, - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); - + env); + TAO_CHECK_ENV_RETURN (env, 1); + // Prepare a Float and "define" that in the PropertySet. CORBA::Float f = 3.14; anyval <<= f; @@ -173,11 +173,11 @@ TAO_PropertySet_Tester::test_define_property (CORBA::Environment &ACE_TRY_ENV) ACE_DEBUG ((LM_DEBUG, "Main : Float f = %f\n", f)); - property_set_.define_property ("float_property", - anyval, - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); - + property_set_.define_property ("float_property", + anyval, + env); + TAO_CHECK_ENV_RETURN (env, 1); + // Prepare a String and "define" that in the PropertySet. ACE_DEBUG ((LM_DEBUG, "Main: Any holding String\n")); @@ -191,20 +191,20 @@ TAO_PropertySet_Tester::test_define_property (CORBA::Environment &ACE_TRY_ENV) newstr)); property_set_.define_property ("string_property", anyval, - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); + env); + TAO_CHECK_ENV_RETURN (env, 1); return 0; } // Testing, get_number_of_properties. int -TAO_PropertySet_Tester::test_get_number_of_properties (CORBA::Environment &ACE_TRY_ENV) +TAO_PropertySet_Tester::test_get_number_of_properties (CORBA::Environment &env) { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "Main : Number of props : %d\n", - property_set_.get_number_of_properties (ACE_TRY_ENV))); - ACE_CHECK_RETURN ( 1); + property_set_.get_number_of_properties (env))); + TAO_CHECK_ENV_RETURN (env, 1); return 0; } @@ -213,12 +213,12 @@ TAO_PropertySet_Tester::test_get_number_of_properties (CORBA::Environment &ACE_T // if that exsists. int TAO_PropertySet_Tester::test_delete_property (const char *property_name, - CORBA::Environment &ACE_TRY_ENV) + CORBA::Environment &env) { ACE_DEBUG ((LM_DEBUG, "\nChecking delete_property\n")); property_set_.delete_property (property_name, - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); + env); + TAO_CHECK_ENV_RETURN (env, 1); return 0; } @@ -226,15 +226,15 @@ TAO_PropertySet_Tester::test_delete_property (const char *property_name, // Gets the value of "short_property" and "string_property". int -TAO_PropertySet_Tester::test_get_property_value (CORBA::Environment &ACE_TRY_ENV) +TAO_PropertySet_Tester::test_get_property_value (CORBA::Environment &env) { ACE_DEBUG ((LM_DEBUG, "\nChecking get_property_value\n")); - + CORBA::Any_ptr anyptr = property_set_.get_property_value ("short_property", - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); - + env); + TAO_CHECK_ENV_RETURN (env, 1); + // Get the short value. if (anyptr != 0) { @@ -249,8 +249,8 @@ TAO_PropertySet_Tester::test_get_property_value (CORBA::Environment &ACE_TRY_ENV "Short property not found\n")); // Get the string. anyptr = property_set_.get_property_value ("string_property", - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); + env); + TAO_CHECK_ENV_RETURN (env, 1); if (anyptr != 0) { CORBA::String str; @@ -258,7 +258,7 @@ TAO_PropertySet_Tester::test_get_property_value (CORBA::Environment &ACE_TRY_ENV ACE_DEBUG ((LM_DEBUG, "Str %s\n", str)); } - else + else ACE_DEBUG ((LM_DEBUG, "string_property not found\n")); return 0; @@ -268,34 +268,34 @@ TAO_PropertySet_Tester::test_get_property_value (CORBA::Environment &ACE_TRY_ENV // "string_property" and "char_property". int -TAO_PropertySet_Tester::test_is_property_defined (CORBA::Environment &ACE_TRY_ENV) +TAO_PropertySet_Tester::test_is_property_defined (CORBA::Environment &env) { ACE_DEBUG ((LM_DEBUG, "\nChecking is_property_defined ()\n")); if (property_set_.is_property_defined ("short_property", - ACE_TRY_ENV) == 0) + env) == 0) ACE_DEBUG ((LM_DEBUG, "short_property not defined\n")); - else + else ACE_DEBUG ((LM_DEBUG, "short_property defined\n")); - ACE_CHECK_RETURN ( 1); + TAO_CHECK_ENV_RETURN (env, 1); if (property_set_.is_property_defined ("string_property", - ACE_TRY_ENV) == 0) + env) == 0) ACE_DEBUG ((LM_DEBUG, "string_property not defined\n")); else ACE_DEBUG ((LM_DEBUG, "string_property defined\n")); - ACE_CHECK_RETURN ( 1); + TAO_CHECK_ENV_RETURN (env, 1); if (property_set_.is_property_defined ("char_property", - ACE_TRY_ENV) == 0) + env) == 0) ACE_DEBUG ((LM_DEBUG, "char_property not defined\n")); else ACE_DEBUG ((LM_DEBUG, "char_property defined\n")); - ACE_CHECK_RETURN ( 1); + TAO_CHECK_ENV_RETURN (env, 1); return 0; } @@ -304,7 +304,7 @@ TAO_PropertySet_Tester::test_is_property_defined (CORBA::Environment &ACE_TRY_EN // PropertySet. Deleting char, short, long, float and string // properties. int -TAO_PropertySet_Tester::test_delete_properties (CORBA::Environment &ACE_TRY_ENV) +TAO_PropertySet_Tester::test_delete_properties (CORBA::Environment &env) { ACE_DEBUG ((LM_DEBUG, "\nChecking delete_properties == Deleting a sequence of Properties\n")); @@ -319,17 +319,17 @@ TAO_PropertySet_Tester::test_delete_properties (CORBA::Environment &ACE_TRY_ENV) prop_names.length (), prop_names.maximum ())); property_set_.delete_properties (prop_names, - ACE_TRY_ENV); - ACE_CHECK_RETURN ( 0); - + env); + TAO_CHECK_ENV_RETURN (env, 0); + return 0; } // Defines a sequnce of properties containing, char, short, long, // float and string property in the property set. int -TAO_PropertySet_Tester::test_define_properties (CORBA::Environment &ACE_TRY_ENV) -{ +TAO_PropertySet_Tester::test_define_properties (CORBA::Environment &env) +{ ACE_DEBUG ((LM_DEBUG, "\nChecking define_properties == Defining sequence of properties\n")); // TAO_TRY @@ -341,55 +341,55 @@ TAO_PropertySet_Tester::test_define_properties (CORBA::Environment &ACE_TRY_ENV) CORBA::Char ch = '#'; anyval <<= from_char (ch); ch = '*'; - anyval >>= to_char (ch); - nproperties[0].property_name = CORBA::string_dup ("char_property"); + anyval >>= to_char (ch); + nproperties[0].property_name = CORBA::string_copy ("char_property"); nproperties[0].property_value <<= from_char (ch); - + // Prepare a Short and "define" that in the PropertySet. CORBA::Short s = 3; - anyval <<= s; - s = 7; + anyval <<= s; + s = 7; anyval >>= s; - nproperties[1].property_name = CORBA::string_dup ("short_property"); + nproperties[1].property_name = CORBA::string_copy ("short_property"); nproperties[1].property_value <<= s; - + // Prepare a Long and "define" that in the PropertySet. CORBA::Long l = 931232; anyval <<= l; l = 931233; anyval >>= l; - nproperties[2].property_name = CORBA::string_dup ("long_property"); + nproperties[2].property_name = CORBA::string_copy ("long_property"); nproperties[2].property_value <<= l; - + // Prepare a Float and "define" that in the PropertySet. CORBA::Float f = 3.14; anyval <<= f; f = 4.14; anyval >>= f; - nproperties[3].property_name = CORBA::string_dup ("float_property"); + nproperties[3].property_name = CORBA::string_copy ("float_property"); nproperties[3].property_value <<= f; - + // Prepare a String and "define" that in the PropertySet. CORBA::String_var strvar (CORBA::string_dup ("Test_String")); anyval <<= strvar.in (); - nproperties[4].property_name = CORBA::string_dup ("string_property"); + nproperties[4].property_name = CORBA::string_copy ("string_property"); nproperties[4].property_value <<= strvar.in (); - + // Define this sequence of properties now. - property_set_.define_properties (nproperties, ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); + property_set_.define_properties (nproperties, env); + TAO_CHECK_ENV_RETURN (env, 1); return 0; } // Delete all the properties. int -TAO_PropertySet_Tester::test_delete_all_properties (CORBA::Environment &ACE_TRY_ENV) +TAO_PropertySet_Tester::test_delete_all_properties (CORBA::Environment &env) { - // Deleting all the properties + // Deleting all the properties ACE_DEBUG ((LM_DEBUG, "\nChecking delete_all_properties\n")); - if (property_set_.delete_all_properties (ACE_TRY_ENV) == 1) + if (property_set_.delete_all_properties (env) == 1) ACE_DEBUG ((LM_DEBUG, "All properties deleted, I guess\n")); else @@ -402,7 +402,7 @@ TAO_PropertySet_Tester::test_delete_all_properties (CORBA::Environment &ACE_TRY_ TAO_PropertyNamesIterator_Tester::TAO_PropertyNamesIterator_Tester (TAO_PropertySet_Tester &propertyset_tester) : iterator_ (propertyset_tester.property_set_) { -} +} // Destructor. TAO_PropertyNamesIterator_Tester::~TAO_PropertyNamesIterator_Tester (void) @@ -411,16 +411,16 @@ TAO_PropertyNamesIterator_Tester::~TAO_PropertyNamesIterator_Tester (void) // Test next one method. Iterate thru all the names in the // PropertySet and print them out. -int -TAO_PropertyNamesIterator_Tester::test_next_one (CORBA::Environment &ACE_TRY_ENV) +int +TAO_PropertyNamesIterator_Tester::test_next_one (CORBA::Environment &env) { CORBA::String_var strvar; ACE_DEBUG ((LM_DEBUG, "\nTesting next_one of NamesIterator, Iterating thru names.\n")); // Let us iterate, now. - while (iterator_.next_one (strvar.out (), ACE_TRY_ENV) != 0) - { - ACE_CHECK_RETURN ( 1); + while (iterator_.next_one (strvar.out (), env) != 0) + { + TAO_CHECK_ENV_RETURN (env, 1); ACE_DEBUG ((LM_DEBUG, "Str : %s\n", strvar.in ())); } return 0; @@ -428,33 +428,33 @@ TAO_PropertyNamesIterator_Tester::test_next_one (CORBA::Environment &ACE_TRY_ENV // Reset the names iterator. int -TAO_PropertyNamesIterator_Tester::test_reset (CORBA::Environment &ACE_TRY_ENV) +TAO_PropertyNamesIterator_Tester::test_reset (CORBA::Environment &env) { ACE_DEBUG ((LM_DEBUG, "Resetting (reset ()) the NamesIterator.")); - iterator_.reset (ACE_TRY_ENV); - ACE_CHECK_RETURN ( 1); + iterator_.reset (env); + TAO_CHECK_ENV_RETURN (env, 1); return 0; } // Test the next_n method. Get the next n names and print them all. int TAO_PropertyNamesIterator_Tester::test_next_n (size_t n, - CORBA::Environment &ACE_TRY_ENV) + CORBA::Environment &env) { CosPropertyService::PropertyNames_var pnames_var; ACE_DEBUG ((LM_DEBUG, - "Checking next_n (), next %d\n", + "Checking next_n (), next %d\n", n)); - if (iterator_.next_n (n, pnames_var.out (), ACE_TRY_ENV) == 0) + if (iterator_.next_n (n, pnames_var.out (), env) == 0) { // Return if no more items in the iterator. - ACE_CHECK_RETURN ( 1); + TAO_CHECK_ENV_RETURN (env, 1); ACE_DEBUG ((LM_DEBUG, "Iterator has no more items\n")); return 0; } - ACE_CHECK_RETURN ( 1); + TAO_CHECK_ENV_RETURN (env, 1); for (size_t i = 0; i < pnames_var.in ().length (); i++) ACE_DEBUG ((LM_DEBUG, "str %s \n", @@ -462,120 +462,130 @@ TAO_PropertyNamesIterator_Tester::test_next_n (size_t n, return 0; } -int -main (int argc, char *argv []) +int +main (int argc, char *argv []) { - ACE_TRY + TAO_TRY { CORBA::ORB_var orb_var = CORBA::ORB_init (argc, argv, "internet", - ACE_TRY_ENV); - ACE_TRY_CHECK; + TAO_TRY_ENV); + TAO_CHECK_ENV; // = Checking PropertySet interface. - + ACE_DEBUG ((LM_DEBUG, "\nTAO_PropertySet Testing\n")); TAO_PropertySet_Tester propertyset_tester; - + // Checking define_property. define a char, a short,a long, a float // and a string. - propertyset_tester.test_define_property (ACE_TRY_ENV); - ACE_TRY_CHECK; + propertyset_tester.test_define_property (TAO_TRY_ENV); + TAO_CHECK_ENV; // Test the number of properties and print it out. - propertyset_tester.test_get_number_of_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; + propertyset_tester.test_get_number_of_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; // Test delete property. Delete "string_property" - propertyset_tester.test_delete_property ("string_property", ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_delete_property ("string_property", TAO_TRY_ENV); + TAO_CHECK_ENV; + // Test the number of properties and print it out. - propertyset_tester.test_get_number_of_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; + propertyset_tester.test_get_number_of_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; // Test delete_properties. Delete char, short, long and float. - propertyset_tester.test_delete_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_delete_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Test the number of properties and print it out. - propertyset_tester.test_get_number_of_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_get_number_of_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Define a sequence of properties. char, short, long, float and // string. - propertyset_tester.test_define_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_define_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Test the number of properties and print it out. - propertyset_tester.test_get_number_of_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_get_number_of_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Checking get_property_value. get the value of short and string. - propertyset_tester.test_get_property_value (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_get_property_value (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Checking delete_all_properties. - propertyset_tester.test_delete_all_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_delete_all_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Test the number of properties and print it out. - propertyset_tester.test_get_number_of_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_get_number_of_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Define a sequence of properties. char, short, long, float and // string. - propertyset_tester.test_define_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_define_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Test the number of properties and print it out. - propertyset_tester.test_get_number_of_properties (ACE_TRY_ENV); - ACE_TRY_CHECK; - + propertyset_tester.test_get_number_of_properties (TAO_TRY_ENV); + TAO_CHECK_ENV; + // = Checking the PropertyNamesIterator interface. - + ACE_DEBUG ((LM_DEBUG, "\nTAO_PropertyNamesIterator Testing\n")); - + // Construct the names iterator from the PropertySet object. TAO_PropertyNamesIterator_Tester names_iterator_tester (propertyset_tester); - + // Checking next_one. Iterate thru the property names. - names_iterator_tester.test_next_one (ACE_TRY_ENV); - ACE_TRY_CHECK; - + names_iterator_tester.test_next_one (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Checking the reset () method. - names_iterator_tester.test_reset (ACE_TRY_ENV); - ACE_TRY_CHECK; - + names_iterator_tester.test_reset (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Iterating again thru the property names. - names_iterator_tester.test_next_one (ACE_TRY_ENV); - ACE_TRY_CHECK; - + names_iterator_tester.test_next_one (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Reset again. - names_iterator_tester.test_reset (ACE_TRY_ENV); - ACE_TRY_CHECK; - + names_iterator_tester.test_reset (TAO_TRY_ENV); + TAO_CHECK_ENV; + // Checking next_n. Prints out all the names it has got. - names_iterator_tester.test_next_n (6, ACE_TRY_ENV); - ACE_TRY_CHECK; - + names_iterator_tester.test_next_n (6, TAO_TRY_ENV); + TAO_CHECK_ENV; + // Try next_n without resetting. - names_iterator_tester.test_next_n (6, ACE_TRY_ENV); - ACE_TRY_CHECK; + names_iterator_tester.test_next_n (6, TAO_TRY_ENV); + TAO_CHECK_ENV; } - ACE_CATCH (CORBA::SystemException, sysex) + TAO_CATCH (CORBA::SystemException, sysex) { - ACE_TRY_ENV.print_exception ("System Exception"); + TAO_TRY_ENV.print_exception ("System Exception"); return -1; } - ACE_CATCH (CORBA::UserException, userex) + TAO_CATCH (CORBA::UserException, userex) { - ACE_TRY_ENV.print_exception ("User Exception"); + TAO_TRY_ENV.print_exception ("User Exception"); return -1; } - ACE_ENDTRY; + TAO_ENDTRY; return 0; -} +} + + + + + + + + + + |