diff options
Diffstat (limited to 'TAO/orbsvcs')
24 files changed, 44 insertions, 2148 deletions
diff --git a/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.mpc b/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.mpc index 2bdb8761528..220aa334965 100644 --- a/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.mpc +++ b/TAO/orbsvcs/CosEvent_Service/CosEvent_Service.mpc @@ -1,6 +1,6 @@ // -*- MPC -*- // $Id$ -project : orbsvcsexe, core, naming, event_serv, svc_utils, iortable, messaging, portableserver { +project : orbsvcsexe, core, event_serv, naming, svc_utils, iortable, messaging, portableserver { exename = CosEvent_Service } diff --git a/TAO/orbsvcs/orbsvcs/AV/RTP.cpp b/TAO/orbsvcs/orbsvcs/AV/RTP.cpp index eeb27381690..37b86fa9478 100644 --- a/TAO/orbsvcs/orbsvcs/AV/RTP.cpp +++ b/TAO/orbsvcs/orbsvcs/AV/RTP.cpp @@ -517,7 +517,7 @@ TAO_AV_RTP_Object::send_frame (const iovec *iov, // set the ssrc on the control object so the RTCP traffic can be matched // to the RTP traffic rtcp_prot_obj->ssrc(this->ssrc_); - ACE_UINT16 data_size = static_cast<ACE_UINT16> (iov[0].iov_len); + ACE_NEW_RETURN (rtp_packet, RTP_Packet (0, // padding @@ -528,8 +528,8 @@ TAO_AV_RTP_Object::send_frame (const iovec *iov, this->ssrc_, // ssrc csrc_count, // csrc count csrc_list, // csrc list - (char *)iov[0].iov_base, // data - data_size), // data size + (char *)iov[0].iov_base, // data + iov[0].iov_len), // data size -1); frame_info->sequence_num ++; @@ -575,7 +575,6 @@ TAO_AV_RTP_Object::send_frame (const iovec *iov, (now.sec () * samples_per_sec + ((double)now.usec () * samples_per_usec) + this->timestamp_offset_); - ACE_UINT16 data_size = static_cast<ACE_UINT16> (iov[0].iov_len); ACE_NEW_RETURN (rtp_packet, RTP_Packet (0, // padding @@ -586,8 +585,8 @@ TAO_AV_RTP_Object::send_frame (const iovec *iov, this->ssrc_, // ssrc csrc_count, // csrc count csrc_list, // csrc list - (char *)iov[0].iov_base, // data - data_size), // data size + (char *)iov[0].iov_base, // data + iov[0].iov_len), // data size -1); this->sequence_num_ ++; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Transport.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Transport.cpp index bcdd093c8d8..a78d1baf81f 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Transport.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Transport.cpp @@ -474,7 +474,7 @@ TAO_UIPMC_Transport::handle_input (TAO_Resume_Handle &rh, // Read the message into the message block that we have created on // the stack. - ssize_t n = this->recv (message_block.rd_ptr (), + ssize_t n = this->recv (message_block.wr_ptr (), message_block.space (), max_wait_time); @@ -498,14 +498,14 @@ TAO_UIPMC_Transport::handle_input (TAO_Resume_Handle &rh, // Set the write pointer in the stack buffer. message_block.wr_ptr (n); - // Parse the incoming message for validity. The check needs to be + // Check the incoming message for validity. The check needs to be // performed by the messaging objects. - if (this->parse_incoming_messages (message_block) == -1) + if (this->messaging_object ()->check_for_valid_header (message_block) == 0) { if (TAO_debug_level) { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO: (%P|%t|%N|%l) parse_incoming_messages failed on transport %d after fault %p\n"), + ACE_TEXT ("TAO: (%P|%t|%N|%l) failed to find a valid header on transport %d after fault %p\n"), this->id (), ACE_TEXT ("handle_input_i ()\n"))); } @@ -514,17 +514,27 @@ TAO_UIPMC_Transport::handle_input (TAO_Resume_Handle &rh, } // NOTE: We are not performing any queueing nor any checking for - // missing data. We are assuming that ALL the data would be got in a + // missing data. We are assuming that ALL the data arrives in a // single read. // Make a node of the message block.. - TAO_Queued_Data qd (&message_block); - - // Extract the data for the node.. - this->messaging_object ()->get_message_data (&qd); - - // Process the message - return this->process_parsed_messages (&qd, rh); + // + // We could make this more efficient by having a fixed Queued Data + // allocator, i.e., it always gave back the same thing. Actually, + // we *could* create an allocator that took a stack-allocated object + // as an argument and returned that when asked an allocation is + // done. Something to contemplate... + TAO_Queued_Data* qd = + TAO_Queued_Data::make_completed_message (message_block, + *this->messaging_object ()); + int retval = -1; + if (qd) + { + // Process the message + retval = this->process_parsed_messages (qd, rh); + TAO_Queued_Data::release (qd); + } + return retval; } int diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp index 00be46eb157..ba933c34608 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp @@ -271,7 +271,7 @@ TAO::SSLIOP::Connector::create_profile (TAO_InputCDR& cdr) } TAO_Profile * -TAO::SSLIOP::Connector::make_profile (int is_secure ACE_ENV_ARG_DECL) +TAO::SSLIOP::Connector::make_profile (ACE_ENV_SINGLE_ARG_DECL) { // The endpoint should be of the form: // N.n@host:port/object_key @@ -281,7 +281,7 @@ TAO::SSLIOP::Connector::make_profile (int is_secure ACE_ENV_ARG_DECL) TAO_Profile *profile = 0; ACE_NEW_THROW_EX (profile, TAO_SSLIOP_Profile (this->orb_core (), - is_secure), // SSL component + 0), // SSL component CORBA::NO_MEMORY ( CORBA::SystemException::_tao_minor_code ( TAO_DEFAULT_MINOR_CODE, @@ -292,78 +292,6 @@ TAO::SSLIOP::Connector::make_profile (int is_secure ACE_ENV_ARG_DECL) return profile; } - -TAO_Profile * -TAO::SSLIOP::Connector::corbaloc_scan (const char *endpoint, - size_t &len - ACE_ENV_ARG_DECL) -{ - int ssl_only = 0; - if( this->check_prefix( endpoint) == 0) - { - ssl_only = 1; - } - else - { - if (this->TAO_IIOP_Connector::check_prefix ( endpoint) != 0) - return 0; - } - - // Determine the (first in a list of possibly > 1) endpoint address - const char *comma_pos = ACE_OS::strchr ( endpoint,','); - const char *slash_pos = ACE_OS::strchr ( endpoint,'/'); - if( comma_pos == 0 && slash_pos == 0) - { - if( TAO_debug_level) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("(%P|%t) SSLIOP_Connector::corbaloc_scan warning: ") - ACE_TEXT("supplied string contains no comma or slash: %s\n"), - endpoint)); - } - len = ACE_OS::strlen (endpoint); - } - else if( slash_pos != 0 || comma_pos > slash_pos) - { - // The endpoint address does not extend past the first '/' or ',' - len = slash_pos - endpoint; - } - else - { - len = comma_pos - endpoint; - } - - return this->make_profile( ssl_only ACE_ENV_ARG_PARAMETER); -} - -int -TAO::SSLIOP::Connector::check_prefix (const char *endpoint) -{ - // Check for a valid string - if (!endpoint || !*endpoint) return -1; // Failure - - const char *protocol[] = { "ssliop", "sslioploc" }; - - size_t first_slot = ACE_OS::strchr (endpoint, ':') - endpoint; - - size_t len0 = ACE_OS::strlen (protocol[0]); - size_t len1 = ACE_OS::strlen (protocol[1]); - - // Check for the proper prefix in the IOR. If the proper prefix - // isn't in the IOR then it is not an IOR we can use. - if (first_slot == len0 && ACE_OS::strncmp (endpoint, protocol[0], len0) == 0) - return 0; - - if (first_slot == len1 && ACE_OS::strncmp (endpoint, protocol[1], len1) == 0) - return 0; - - // Failure: not an SSLIOP IOR - // DO NOT throw an exception here. - return -1; -} - - - TAO_Transport* TAO::SSLIOP::Connector::iiop_connect ( TAO_SSLIOP_Endpoint *ssl_endpoint, diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h index 518fe6310dd..9a3a5ddb1a2 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.h @@ -70,11 +70,6 @@ namespace TAO ACE_ENV_ARG_DECL); virtual TAO_Profile *create_profile (TAO_InputCDR& cdr); - virtual int check_prefix (const char *endpoint); - virtual TAO_Profile * corbaloc_scan (const char *ior, - size_t &len - ACE_ENV_ARG_DECL); - //@} protected: @@ -84,7 +79,7 @@ namespace TAO * * Please check the documentation in Pluggable.h. */ - virtual TAO_Profile * make_profile (int is_secure ACE_ENV_ARG_DECL); + virtual TAO_Profile * make_profile (ACE_ENV_SINGLE_ARG_DECL); /// Cancel the passed cvs handler from the connector virtual int cancel_svc_handler (TAO_Connection_Handler * svc_handler); diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp index c209a7aa563..fbb32f89f96 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Factory.cpp @@ -18,7 +18,7 @@ ACE_RCSID (SSLIOP, "$Id$") -static const char *prefix_[] = {"iiop", "ssliop"}; +static const char prefix_[] = "iiop"; namespace TAO { @@ -44,18 +44,13 @@ int TAO::SSLIOP::Protocol_Factory::match_prefix (const ACE_CString &prefix) { // Check for the proper prefix for this protocol. - return (ACE_OS::strcasecmp (prefix.c_str (), ::prefix_[0]) == 0) - || (ACE_OS::strcasecmp (prefix.c_str (), ::prefix_[1]) == 0); + return (ACE_OS::strcasecmp (prefix.c_str (), ::prefix_) == 0); } const char * TAO::SSLIOP::Protocol_Factory::prefix (void) const { - // Note: This method doesn't seem to be used anywhere. Moreover, - // keeping it may make things more confusing - a Factory can - // well be handling multiple protocol prefixes, not just one! - // Shouldn't it be deprecated? - return ::prefix_[0]; + return ::prefix_; } char diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp index 6a203a8813b..23642aaa94a 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.cpp @@ -23,8 +23,7 @@ TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (const ACE_INET_Addr & addr, object_key, version, orb_core), - ssl_endpoint_ (ssl_component, 0), - ssl_only_ (0) + ssl_endpoint_ (ssl_component, 0) { this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true); } @@ -42,8 +41,7 @@ TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (const char * host, addr, version, orb_core), - ssl_endpoint_ (ssl_component, 0), - ssl_only_ (0) + ssl_endpoint_ (ssl_component, 0) { this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true); } @@ -51,16 +49,14 @@ TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (const char * host, TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core, const ::SSLIOP::SSL * ssl_component) : TAO_IIOP_Profile (orb_core), - ssl_endpoint_ (ssl_component, 0), - ssl_only_ (0) + ssl_endpoint_ (ssl_component, 0) { this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true); } -TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core, int ssl_only) +TAO_SSLIOP_Profile::TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core) : TAO_IIOP_Profile (orb_core), - ssl_endpoint_ (0, 0), - ssl_only_ (ssl_only) + ssl_endpoint_ (0, 0) { this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true); } @@ -344,14 +340,4 @@ TAO_SSLIOP_Profile::parse_string (const char * ior ACE_CHECK; this->ssl_endpoint_.iiop_endpoint (&this->endpoint_, true); - - if( ssl_only_) - { - this->ssl_endpoint_.ssl_component_.port = this->endpoint_.port_; - - // Note that the Security::NoProtection bit is cleared since we - // are sure the server supports SSL (we're told so) - ACE_CLR_BITS (this->ssl_endpoint_.ssl_component_.target_supports, - Security::NoProtection); - } } diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h index 7d90d00f290..026765b860b 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Profile.h @@ -68,10 +68,8 @@ TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core, const ::SSLIOP::SSL * ssl_component); - /// Profile constructor. ssl_only != 0 will force secure - /// connections, pnly. - TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core, int ssl_only = 0); - + /// Profile constructor, default. + TAO_SSLIOP_Profile (TAO_ORB_Core * orb_core); // = Please see Profile.h for the documentation of these methods. virtual int decode (TAO_InputCDR& cdr); @@ -155,16 +153,6 @@ * rest of the SSL endpoint list is transmitted. */ TAO_SSLIOP_Endpoint ssl_endpoint_; - - /** - * Allways treat this endpoint as secure, even if the constructor - * did not explicitely specify a tagged component for SSL. - * @par - * Most likely the parse_string() will supply a subset of the - * attributes - port number, for instance. - */ - int ssl_only_; - }; // } // End SSLIOP namespace. diff --git a/TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc b/TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc index 1e76f1acf6f..48f43312e62 100644 --- a/TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc +++ b/TAO/orbsvcs/tests/Security/MT_SSLIOP/MT_SSLIOP.mpc @@ -1,7 +1,7 @@ // -*- MPC -*- // $Id$ -project(*security server): orbsvcsexe, portableserver, ssl, iortable { +project(*security server): orbsvcsexe, portableserver, ssl { Source_Files { Server_Worker.cpp test_i.cpp diff --git a/TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp b/TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp index e67568600ad..29c53ecb7b8 100644 --- a/TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp +++ b/TAO/orbsvcs/tests/Security/MT_SSLIOP/server.cpp @@ -1,27 +1,21 @@ // $Id$ #include "ace/Get_Opt.h" -#include "tao/IORTable/IORTable.h" #include "test_i.h" #include "Server_Worker.h" const char *ior_output_file = 0; -const char *ior_table_name = 0; int nthreads = 4; int parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "i:o:n:"); + ACE_Get_Opt get_opts (argc, argv, "o:n:"); int c; while ((c = get_opts ()) != -1) switch (c) { - case 'i': - ior_table_name = get_opts.opt_arg (); - break; - case 'o': ior_output_file = get_opts.opt_arg (); break; @@ -34,7 +28,6 @@ parse_args (int argc, char *argv[]) default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s " - "[-i <iortable name>]" "-o <iorfile>" "\n", argv [0]), @@ -87,29 +80,7 @@ main (int argc, char *argv[]) orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ()));A - - - if (ior_table_name != 0) - { - CORBA::Object_var table_object = - orb->resolve_initial_references ("IORTable" ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - IORTable::Table_var adapter = - IORTable::Table::_narrow (table_object.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - if (CORBA::is_nil (adapter.in ())) - { - ACE_ERROR ((LM_ERROR, "Nil IORTable\n")); - return -1; - } - - adapter->bind ( ior_table_name, ior.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - } - + ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ())); // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/README b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/README deleted file mode 100644 index 6e28b065fb8..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/README +++ /dev/null @@ -1,87 +0,0 @@ -// $Id$ - -These application tests address various features of TAO's -Naming Service. The functionality is the same as in the -Simple_Naming test, but the difference is that all the -communication is done over SSLIOP and clients are using -INS-style corbaloc URLs. - -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). - Make sure you use " -ORBSvcConf server.conf" and - "-ORBEndpoint iiop://localhost:23456/ssl_port=12345" - - Then run ./client with one of the options below. - Make sure you add " -ORBSvcConf client.conf" and - "-ORBInitRef NameService=corbaloc:ssliop:localhost:12345/NameService" - -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. - -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 -******************************************* -Please see $TAO_ROOT/orbsvcs/tests/Simple_Naming/README diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf deleted file mode 100644 index 880c1b7d372..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf +++ /dev/null @@ -1,5 +0,0 @@ -dynamic SSLIOP_Factory Service_Object * - TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory() - "-SSLPrivateKey PEM:pvtkey-client.pem -SSLCertificate PEM:selfsigncert-client.pem" -static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory" - diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf.xml b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf.xml deleted file mode 100644 index 50bb24f73ee..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.conf.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version='1.0'?> -<!-- Converted from client.conf by svcconf-convert.pl --> -<ACE_Svc_Conf> - <dynamic id="SSLIOP_Factory" type="Service_Object"> - <initializer path="TAO_SSLIOP" init="_make_TAO_SSLIOP_Protocol_Factory" params="-SSLPrivateKey PEM:pvtkey-client.pem -SSLCertificate PEM:selfsigncert-client.pem"/> - </dynamic> - <static id="Resource_Factory" params="-ORBProtocolFactory SSLIOP_Factory"/> -</ACE_Svc_Conf> - diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.cpp b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.cpp deleted file mode 100644 index 1279dee82b7..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.cpp +++ /dev/null @@ -1,1280 +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 PortableServer::RefCountServantBase, - 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/Security/ssliop_corbaloc/client.h b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.h deleted file mode 100644 index 15eb7fe577e..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/client.h +++ /dev/null @@ -1,334 +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/PortableServer/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 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/Security/ssliop_corbaloc/corbaloc_ssliop.mpc b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/corbaloc_ssliop.mpc deleted file mode 100644 index 97620a0feb0..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/corbaloc_ssliop.mpc +++ /dev/null @@ -1,9 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(*Client) : namingexe, portableserver { - Source_Files { - client.cpp - } -} - diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey-client.pem b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey-client.pem deleted file mode 100644 index cf53308cae2..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey-client.pem +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXwIBAAKBgQD3LcZOo8tF7BHEYMsm5pn3zYV+u6NhhvPC5G5bErY8qi8Xt4CZ -PSQPm4JmVFvLsY2H6Eme8Oe7j4bCquRuB1D/U5auKdINQ1aG2CgKqPtBy1SliHE3 -FD1Ht43O+z2mRzGHtqLowhEvFEpEVHcJLUQ7HVHPJaRNQkn80DA/nN9+5wIDAQAB -AoGBANpBJPWTU43uINIR1dAHlrRkWRfKfz1CeEMCiR8JqrhuXR7H/VlRz2Goor/Q -hS2bHal/xmH9veCznv6M/x7Yfv74hhUJxyqngNxbwGI4G+LfR3/x1fqVcweDGmv6 -LYLL4JWyDLEL5I3PEZP/dUnT6+bmmuXWU5z83itqYw8VRbsBAkEA/MnqXFlWl1KF -jTee5pijKOXGAvllrpN8MkTKM2MdjltzOkuhC1OEwhXYy86e90gRQvXAs3t7A4dT -Q5/eUYHgYQJBAPpRnYcqqDP0Rj/JqMDapwIVjMoMDQP+thB4Ey6fSRC7dYiX4+Qo -cyX8j0YnF0RYl426+Qv2O6egmOmzrQwQxEcCQQDAfUBocd7t+3iWv/PPxAr56X2O -Zjp3ZPb9kEQoPSEUda6YhV5sMXy2Dcy35O5Hfikmw9uo0C4r0bAlnma7yhoBAkEA -tI0/6ansDyVnskTbktdj1Q4EMgxFKxeC7RgfBebghdAg87hTKVO/0qt8EGbL0oFw -N0ugrW8bEkq1YQQ3kldZqwJBAJPIe/NE+NhSOoSo3kEQ70SkjU5EB2sbVxhjq6ci -UdXa+EOAna5JS5ZFMDq4AI+qU8OoSgI26hdH5S8lf10fIDo= ------END RSA PRIVATE KEY----- - diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey.pem b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey.pem deleted file mode 100644 index 81ba8e3f968..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/pvtkey.pem +++ /dev/null @@ -1,10 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIBOwIBAAJBAPXZ7YNyFU8T8PVitNwZmdwuc4tG64V/lDYHnmzolmFPQ6gvI2uo -KBQeHeJFPI6LJ5TGb8hCnypy+zbc+pve8vECAwEAAQJAE/fmZbW/a1PYT2X8AKCH -sa2ILvjMqmQpWpYV1QyzIiYQPEmQ/5GMUj/t3PZd/17BOH8aPakBT/c1Gp+os6vR -zQIhAP2RDmm6UyMrJhAtAcNC5s8nbfhKPG80Q0DZ2kiodjQfAiEA+DXqwEZlCh0j -VPzEXY7vrdQa641zQ5XIX1S/+WbCdu8CIDT9m4V86uLuoYW/4h5sXM/t7Y119itH -QMbMwFFu40UBAiEA9z+mN6An2BpMbsVXyiavREYMBuahkgprTeM7VHHzdssCIQCY -QEgmpzGzfdZoREy9B7ooNeRO919lR9qvbte9vvJvWQ== ------END RSA PRIVATE KEY----- - diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/run_test.pl b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/run_test.pl deleted file mode 100755 index a63768a2dc3..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/run_test.pl +++ /dev/null @@ -1,161 +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; - -# Amount of delay (in seconds) between starting a server and a client -# to allow proper server initialization. -$sleeptime = 10; - -# The default host name. -$TARGETHOSTNAME = "localhost"; - -$quiet = 0; -$use_ssl = 1; -$debug_level = 0; - -while (my $argument = shift) { - if ($argument eq '-q') { - $quiet = 1; - next; - } - if ($argument eq '-d') { - $debug_level = shift; - next; - } - print STDERR "Unknown: $argument\nUsage $0 [-q] [-d n]\n"; - exit(-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 (); -$ns_ssl_port = 14000 + 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 = "../../../Naming_Service/Naming_Service"; - $NS = new PerlACE::Process ($prog, $args); - - unlink $iorfile; - - print STDERR "CommandLine: server " . $NS->Arguments() . "\n\n" unless $quiet; - $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); - - print STDERR "CommandLine: client " . $CL->Arguments() . "\n\n" unless $quiet; - $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. - -$orb_debug_level = ($quiet || $debug_level == 0) ? "" : "-ORBDebugLevel $debug_level"; - -# Options for all simple tests recognized by the 'client' program. -@opts = ( - "-s -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService" - . " -ORBSvcConf client.conf $orb_debug_level", - "-t -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService" - . " -ORBSvcConf client.conf $orb_debug_level", - "-i -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService" - . " -ORBSvcConf client.conf $orb_debug_level", - "-e -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService" - . " -ORBSvcConf client.conf $orb_debug_level", - "-y -ORBInitRef NameService=corbaloc:ssliop:$TARGETHOSTNAME:$ns_ssl_port/NameService" - . " -ORBSvcConf client.conf $orb_debug_level", - - ); - -@server_opts = ( - "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port" - . " -ORBSvcConf server.conf $orb_debug_level", - "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port" - . " -ORBSvcConf server.conf $orb_debug_level", - "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port" - . " -ORBSvcConf server.conf $orb_debug_level", - "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port" - . " -ORBSvcConf server.conf $orb_debug_level", - "-ORBEndpoint iiop://$TARGETHOSTNAME:$ns_orb_port/ssl_port=$ns_ssl_port" - . " -ORBSvcConf server.conf $orb_debug_level", - - ); - -@comments = ( - "(SSL) Simple Test:", - "(SSL) Tree Test:", - "(SSL) Iterator Test:", - "(SSL) Exceptions Test:", - "(SSL) Destroy Test:", - ); - -$test_number = 0; - -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) { - - print STDERR "\n " . $comments[$test_number]; - if ($use_ssl == 0 && $comments[$test_number] =~ /SSL/) { - print STDERR " - Skipping, use -s to run the SSL tests"; - next; - } - - print STDERR "\n"; - name_server ($server_opts[$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); -unlink $iorfile; - -exit $status; diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert-client.pem b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert-client.pem deleted file mode 100644 index dc0a69d76e6..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert-client.pem +++ /dev/null @@ -1,24 +0,0 @@ ------BEGIN CERTIFICATE----- -MIID3zCCA0igAwIBAgIBADANBgkqhkiG9w0BAQUFADCBrDELMAkGA1UEBhMCVVMx -ETAPBgNVBAgTCE1pc3NvdXJpMRMwEQYDVQQHEwpDcmV2ZSBDb3JlMR4wHAYDVQQK -ExVPYmplY3QgQ29tcHV0aW5nIEluYy4xETAPBgNVBAsTCFRBTyBUZWFtMRswGQYD -VQQDExJvY2kxMTc5Lm9jaXdlYi5jb20xJTAjBgkqhkiG9w0BCQEWFmplbGlhemtv -dl9pQG9jaXdlYi5jb20wHhcNMDQwOTEwMTY0MjMwWhcNMDUwOTEwMTY0MjMxWjCB -rDELMAkGA1UEBhMCVVMxETAPBgNVBAgTCE1pc3NvdXJpMRMwEQYDVQQHEwpDcmV2 -ZSBDb3JlMR4wHAYDVQQKExVPYmplY3QgQ29tcHV0aW5nIEluYy4xETAPBgNVBAsT -CFRBTyBUZWFtMRswGQYDVQQDExJvY2kxMTc5Lm9jaXdlYi5jb20xJTAjBgkqhkiG -9w0BCQEWFmplbGlhemtvdl9pQG9jaXdlYi5jb20wgZ8wDQYJKoZIhvcNAQEBBQAD -gY0AMIGJAoGBAPctxk6jy0XsEcRgyybmmffNhX67o2GG88LkblsStjyqLxe3gJk9 -JA+bgmZUW8uxjYfoSZ7w57uPhsKq5G4HUP9Tlq4p0g1DVobYKAqo+0HLVKWIcTcU -PUe3jc77PaZHMYe2oujCES8USkRUdwktRDsdUc8lpE1CSfzQMD+c337nAgMBAAGj -ggENMIIBCTAdBgNVHQ4EFgQUgtnhUdIQh1ESq81PL+urdJj1LRkwgdkGA1UdIwSB -0TCBzoAUgtnhUdIQh1ESq81PL+urdJj1LRmhgbKkga8wgawxCzAJBgNVBAYTAlVT -MREwDwYDVQQIEwhNaXNzb3VyaTETMBEGA1UEBxMKQ3JldmUgQ29yZTEeMBwGA1UE -ChMVT2JqZWN0IENvbXB1dGluZyBJbmMuMREwDwYDVQQLEwhUQU8gVGVhbTEbMBkG -A1UEAxMSb2NpMTE3OS5vY2l3ZWIuY29tMSUwIwYJKoZIhvcNAQkBFhZqZWxpYXpr -b3ZfaUBvY2l3ZWIuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD -gYEAVZSDOJ40+iAJPb1GZWmmh5y5Y1DVXsQF5vRENYq15Pi5Y9GBhHaYFn3qjN2U -+zyO2Cp2IJJG4HNazhBoDEj7EhDsxEyOYZiG2pd6BLe1dPl/viy6ysvdijjpcXw7 -bFPbXpCIa5rg8VKQsGYscWerLxvi79uoo+p6DrOU1FxDcYo= ------END CERTIFICATE----- - diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert.pem b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert.pem deleted file mode 100644 index e616730ca63..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/selfsigncert.pem +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICeDCCAiKgAwIBAgIBADANBgkqhkiG9w0BAQQFADBjMQswCQYDVQQGEwJVUzEL -MAkGA1UECBMCTU8xDDAKBgNVBAcTA1NUTDELMAkGA1UEChMCV1UxDDAKBgNVBAsT -A0RPQzELMAkGA1UEAxMCS0ExETAPBgkqhkiG9w0BCQEWAktBMB4XDTAxMDgyNzE2 -NTUxMVoXDTAxMDkyNjE2NTUxMVowYzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAk1P -MQwwCgYDVQQHEwNTVEwxCzAJBgNVBAoTAldVMQwwCgYDVQQLEwNET0MxCzAJBgNV -BAMTAktBMREwDwYJKoZIhvcNAQkBFgJLQTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgC -QQD12e2DchVPE/D1YrTcGZncLnOLRuuFf5Q2B55s6JZhT0OoLyNrqCgUHh3iRTyO -iyeUxm/IQp8qcvs23Pqb3vLxAgMBAAGjgcAwgb0wHQYDVR0OBBYEFL8LnC8csuIX -+TUw6FCoReB27PHoMIGNBgNVHSMEgYUwgYKAFL8LnC8csuIX+TUw6FCoReB27PHo -oWekZTBjMQswCQYDVQQGEwJVUzELMAkGA1UECBMCTU8xDDAKBgNVBAcTA1NUTDEL -MAkGA1UEChMCV1UxDDAKBgNVBAsTA0RPQzELMAkGA1UEAxMCS0ExETAPBgkqhkiG -9w0BCQEWAktBggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADQQAZP9CT -TVRxAz3Acxxxn32rsnwSeNJr1uTA4hew7f4QZ187oZia+rcFLOILrwgCmtqEmWVj -dj6COUrqKo60BI5V ------END CERTIFICATE----- diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf deleted file mode 100644 index 672a471014d..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf +++ /dev/null @@ -1,6 +0,0 @@ -dynamic SSLIOP_Factory Service_Object * - TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory() - "-SSLPrivateKey PEM:pvtkey.pem -SSLCertificate PEM:selfsigncert.pem" -static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory" - - diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf.xml b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf.xml deleted file mode 100644 index 5aa645eb3bf..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/server.conf.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version='1.0'?> -<!-- Converted from server.conf by svcconf-convert.pl --> -<ACE_Svc_Conf> - <dynamic id="SSLIOP_Factory" type="Service_Object"> - <initializer path="TAO_SSLIOP" init="_make_TAO_SSLIOP_Protocol_Factory" params="-SSLPrivateKey PEM:pvtkey.pem -SSLCertificate PEM:selfsigncert.pem"/> - </dynamic> - <static id="Resource_Factory" params="-ORBProtocolFactory SSLIOP_Factory"/> -</ACE_Svc_Conf> diff --git a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/test_object.idl b/TAO/orbsvcs/tests/Security/ssliop_corbaloc/test_object.idl deleted file mode 100644 index 4737f6dc6c8..00000000000 --- a/TAO/orbsvcs/tests/Security/ssliop_corbaloc/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. -}; |