diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
commit | 3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch) | |
tree | 197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/orbsvcs/tests/InterfaceRepo | |
parent | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff) | |
download | ATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/orbsvcs/tests/InterfaceRepo')
47 files changed, 8927 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/IFR_Application_Test.mpc b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/IFR_Application_Test.mpc new file mode 100644 index 00000000000..3396f7a98fe --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/IFR_Application_Test.mpc @@ -0,0 +1,21 @@ +// -*- MPC -*- +// $Id$ + +project(*server): taoexe, portableserver, ifr_client, minimum_corba { + + Source_Files { + test_i.cpp + server.cpp + } +} + +project(*client): taoexe, portableserver, ifr_client, dynamicinterface, minimum_corba { + + IDL_Files { + } + + Source_Files { + ifr_dii_client.cpp + client.cpp + } +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/Makefile.am b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/Makefile.am new file mode 100644 index 00000000000..7e6f5e5bdcf --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/Makefile.am @@ -0,0 +1,115 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf +TAO_ROOT = $(top_srcdir) + +noinst_PROGRAMS = + +## Makefile.IFR_Application_Test_Client.am + +if BUILD_CORBA_MESSAGING +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS += client + +client_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +client_SOURCES = \ + client.cpp \ + ifr_dii_client.cpp \ + ifr_dii_client.h + +client_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_DynamicInterface.la \ + $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ + $(TAO_BUILDDIR)/tao/libTAO_PI.la \ + $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ + $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_MINIMUM_CORBA +endif BUILD_CORBA_MESSAGING + +## Makefile.IFR_Application_Test_Server.am + +if !BUILD_MINIMUM_CORBA + +BUILT_SOURCES = \ + testC.cpp \ + testC.h \ + testC.inl \ + testS.cpp \ + testS.h \ + testS.inl + +CLEANFILES = \ + test-stamp \ + testC.cpp \ + testC.h \ + testC.inl \ + testS.cpp \ + testS.h \ + testS.inl + +testC.cpp testC.h testC.inl testS.cpp testS.h testS.inl: test-stamp + +test-stamp: $(srcdir)/test.idl $(TAO_IDL_DEP) + $(TAO_IDL) $(TAO_IDLFLAGS) $(srcdir)/test.idl + @touch $@ + +noinst_PROGRAMS += server + +server_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +server_SOURCES = \ + server.cpp \ + testC.cpp \ + testS.cpp \ + test_i.cpp \ + testC.h \ + testC.inl \ + testS.h \ + testS.inl \ + test_i.h + +server_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_MINIMUM_CORBA + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/README b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/README new file mode 100644 index 00000000000..113da0997f8 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/README @@ -0,0 +1,111 @@ +$Id$ + +The test in this directory utilizes the Interface Repository +as might be done in an application. This test is also the +only one in this suite that makes use of the Interface +Repository administration executable 'tao_ifr'. + +The test must be run by executing the Perl scrip 'run_test.pl'. +The order of events is as follows: + +(1) The Interface Repository service is started. + +(2) The server proces is started. The server makes + available an object reference to an interface + called 'inventory', which exists in a namespace + called 'warehouse', and contains an operation + called 'getCDinfo'. The operation takes an IN + argument which is a string representing the + artist's name, and INOUT argument which is a + string representing the album title, and an OUT + argument which is a float representing the price. + The operation returns a boolean value indicating + whether or not the particular CD is in stock. All + this iformation is contained in the IDL file + 'test.idl'. + +(3) The Interface Repository administration executable + 'tao_ifr' is executed on test.idl, which adds the + information in test.idl to the repository. + +(4) The client process is started. The client performs + the following actions: + + (a) Locates the Interface Repository by calling + resolve_initial_references ("InterfaceRepository"), + and narrowing. + + (b) Gets the IOR of the target object. In a real + application, this would probably be done + through the Naming Service, but here the + IOR is read from the file where it was + stored by the server. + + (c) The client then makes several calls to the + repository, first searching for an object + with the name 'warehouse'. Once this is + found, the client checks to see if 'warehouse' + may contain other objects. If so, it gets a + list of all the objects 'contained' by + warehouse which are interfaces. Each inteface's + name is checked to find one called 'inventory'. + Then the client gets a list of all inventory's + operations. Each of these is checked to find + one called 'getCDinfo'. The client then gets + the return type and a list of the operation's + parameters by querying the operation repository + object. + + (d) The client creates a DII request pseudo-object, + sets its return type and adds parameters + according to the information extracted from + the operation repository object. Notice that + the client does not have the correct string for + the album title, but one that is commonly used + by people when referring to that album. The + server will try to be smart about this, and + match a substring of the given album title with + a substring of the real album title, returning + the corrected album title if it finds a match. + + (e) The client invokes the DII request and displays + the results. + +(5) The server is shut down. + +(6) tao_ifr is again invoked on test.idl, this time with + the '-r' option, which removes the objects coresponding + to the contents of the IDL file from the repository. + +(7) The repository is shut down. + +By default, the client will call _get_interface() on the target +object to get its InterfaceDef from the respository, and then +query the IntefaceDef object to get information about its +operations and their parameters. If the command line option -n +is passed to the client (or to the Perl script), the client will +resolve the repository by a call to +orb->resolve_initial_references ("InterfaceRepository") and use +information it has (through some unspecified means) about the +local name of the interface and of its containing module, +to search the repository for the InterfaceDef of the target object, +and from there acquire the rest of the information the same way as +in the default case. + +If the default method is used, the call to CORBA::Object::_get_interface() +requires that the server (specifically the generated skeleton code) +know about the TAO_IFR_Client library, since the implementation of +this method is not found in the TAO library, requiring as it does the +knowledge of the rather large IFR client interface. To dynamically load +the TAO_IFR_Client library (assuming it has been compiled), the +header file ACE_ROOT/TAO/tao/IFR_Client/IFR_Client_Adapter_Impl.h is +included in the application (in test_i.h) and TAO_IFR_Client added to +the list of linked libraries. This will force the static Initializer +function in the library to initialize all the IFR typecodes and to +load the library. Applications that don't need to call _get_interface +don't need to link this library and can thus keep the server-side +footprint smaller. + +More information about the Interface Repository can be found in +TAO/docs/releasenotes/index.html. + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/client.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/client.cpp new file mode 100644 index 00000000000..3e16668c65b --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/client.cpp @@ -0,0 +1,45 @@ +// -*- C++ -*- +// $Id$ + +#include "ifr_dii_client.h" + +ACE_RCSID (Application_Test, + client, + "$Id$") + +int +main (int argc, char *argv[]) +{ + IFR_DII_Client client; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + if (client.init (argc, + argv + ACE_ENV_ARG_PARAMETER) + == -1) + { + return 1; + } + else + { + int status = client.run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (status == -1) + { + return 1; + } + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Client Exception"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/ifr_dii_client.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/ifr_dii_client.cpp new file mode 100644 index 00000000000..f6dd2238e12 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/ifr_dii_client.cpp @@ -0,0 +1,418 @@ +// -*- C++ -*- +// $Id$ + +#include "ifr_dii_client.h" +#include "ace/Get_Opt.h" + +ACE_RCSID (Application_Test, + ifr_dii_client, + "$Id$") + +IFR_DII_Client::IFR_DII_Client (void) + : namespace_name (CORBA::string_dup ("warehouse")), + interface_name (CORBA::string_dup ("inventory")), + op_name (CORBA::string_dup ("getCDinfo")), + lookup_by_name_ (false), + debug_ (false) +{ +} + +IFR_DII_Client::~IFR_DII_Client (void) +{ +} + +int +IFR_DII_Client::init (int argc, + char *argv[] + ACE_ENV_ARG_DECL) +{ + this->orb_ = CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + // In a reall application, we would get the scoped or + // local name from the Interface Repository and use that + // to get the object reference of the target via the Naming + // Service. Since we're not testing the Naming Service here, + // we just use the IOR which is stored in a file by the server. + this->target_ = + this->orb_->string_to_object ("file://iorfile" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + + if (CORBA::is_nil (this->target_.in ())) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "Unable to find interface repository in: file://iorfile\n"), + -1); + } + + if (this->parse_args (argc, argv) == -1) + { + return -1; + } + + return 0; +} + +int +IFR_DII_Client::run (ACE_ENV_SINGLE_ARG_DECL) +{ + int result = 0; + + if (this->lookup_by_name_) + { + result = this->lookup_interface_def (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (result == -1) + { + return -1; + } + } + else + { + result = this->find_interface_def (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (result == -1) + { + return (-1); + } + } + + this->get_operation_def (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + this->create_dii_request (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + this->invoke_and_display (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + return 0; +} + +int +IFR_DII_Client::parse_args (int argc, + char *argv[]) +{ + ACE_Get_Opt opts (argc, argv, "dn"); + int c; + + while ((c = opts ()) != -1) + switch (c) + { + case 'd': + this->debug_ = true; + break; + case 'n': // Select lookup by name. + this->lookup_by_name_ = true; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-n]" + "\n", + argv [0]), + -1); + } + + return 0; +} + +int +IFR_DII_Client::find_interface_def (ACE_ENV_SINGLE_ARG_DECL) +{ + this->target_def_ = + this->target_->_get_interface (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (this->target_def_.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to find interface def\n"), + -1); + } + + return 0; +} + +int +IFR_DII_Client::lookup_interface_def (ACE_ENV_SINGLE_ARG_DECL) +{ + CORBA::Object_var obj = + this->orb_->resolve_initial_references ("InterfaceRepository" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN(-1); + + this->repo_ = CORBA::Repository::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN(-1); + + // Is there a contained object of some kind at any level in the + // repository called "warehouse"? + CORBA::ContainedSeq_var candidates = + this->repo_->lookup_name (this->namespace_name.in (), + -1, // Unlimited level recursion. + CORBA::dk_all, // Any type of contained object. + 1 // Exclude parents of interfaces. + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN(-1); + + CORBA::ULong length = candidates->length (); + CORBA::Container_var candidate; + CORBA::ContainedSeq_var interfaces; + CORBA::ULong n_interfaces = 0; + CORBA::String_var name; + + // No point continuing; theres nothing to look at. + if (length == 0) + { + return -1; + } + + // The length is 1 in this case, but in general, it could + // be any length. + for (CORBA::ULong i = 0; i < length; ++i) + { + candidate = + CORBA::Container::_narrow (candidates[i] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN(-1); + + // Is this contained item itself a container? + if (!CORBA::is_nil (candidate.in ())) + { + // Does this container contain any interfaces? + interfaces = candidate->contents (CORBA::dk_Interface, + 1 // Exclude parents. + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN(-1); + + n_interfaces = interfaces->length (); + + // Here we are just getting out of the loop (which + // only has length 1 anyway) when we see the first + // container that contains at least one interface. + // In a real application, we'd probably have a more + // useful criterion, + if (n_interfaces > 0) + { + break; + } + } + } + + // The length is 1 in this case, but in general, it could + // be any length. + for (CORBA::ULong j = 0; j < n_interfaces ; ++j) + { + name = interfaces[j]->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN(-1); + + if (!ACE_OS::strcmp (name.in (), this->interface_name.in ())) + { + this->target_def_ = + CORBA::InterfaceDef::_narrow (interfaces[j] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN(-1); + } + } + return 0; +} + +void +IFR_DII_Client::get_operation_def (ACE_ENV_SINGLE_ARG_DECL) +{ + // What operation(s) does this interface contain? + CORBA::ContainedSeq_var operations = + this->target_def_->contents (CORBA::dk_Operation, + 0 // Do not exclude inherited operations. + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong n_operations = operations->length (); + CORBA::String_var operation_name; + + // The length is 1 in this case, but in general, it could + // be any length. + for (CORBA::ULong i = 0; i < n_operations; ++i) + { + operation_name = operations[i]->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (!ACE_OS::strcmp (operation_name.in (), this->op_name.in ())) + { + this->op_ = + CORBA::OperationDef::_narrow (operations[i] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + break; + } + } +} + +void +IFR_DII_Client::create_dii_request (ACE_ENV_SINGLE_ARG_DECL) +{ + this->req_ = this->target_->_request (this->op_name.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->result_ = this->op_->result (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->req_->set_return_type (this->result_.in ()); + + CORBA::ParDescriptionSeq_var params = + this->op_->params (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong length = params->length (); + + // This example of the discovery of parameter information is + // purposely contrived for the sake of brevity. A real + // application would have more versatile code here, and much + // more of it. + for (CORBA::ULong i = 0; i < length; ++i) + { + CORBA::TCKind const kind = + params[i].type->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + switch (params[i].mode) + { + case CORBA::PARAM_IN: + if (kind == CORBA::tk_string + && ACE_OS::strcmp (params[i].name.in (), "artist") == 0) + { + // The servant will match the substring 'Beatles'. + this->req_->add_in_arg (params[i].name.in ()) <<= "the Beatles"; + } + + break; + case CORBA::PARAM_INOUT: + if (kind == CORBA::tk_string + && ACE_OS::strcmp (params[i].name.in (), "title") == 0) + { + // This isn't the exact title, but the servant will find the + // partial match, and return the full, correct title. + this->req_->add_inout_arg (params[i].name.in ()) <<= "Sgt. Pepper's"; + } + + break; + case CORBA::PARAM_OUT: + { + if (kind == CORBA::tk_float + && ACE_OS::strcmp (params[i].name.in (), "price") == 0) + { + CORBA::Float tmp = -1.0f; + CORBA::Any any; + any <<= tmp; + + // The servant will return 0.0 if the title is not found. + this->req_->arguments ()->add_value (params[i].name.in (), + any, + CORBA::ARG_OUT + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + break; + } + } + } +} + +void +IFR_DII_Client::invoke_and_display (ACE_ENV_SINGLE_ARG_DECL) +{ + this->req_->invoke (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TypeCode_var tc = this->req_->return_value ().type (); + + CORBA::TCKind const kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (kind == CORBA::tk_boolean) + { + CORBA::NVList_ptr args = this->req_->arguments (); + + const char *artist = 0; + +# if (defined (_MSC_VER) && (_MSC_VER < 1310)) + ACE_ASSERT ((*args->item (0)->value () >>= artist) == 1); +# else + ACE_ASSERT ((*args->item (0)->value () >>= artist) == true); +# endif /* _MSC_VER <= 1310 */ + + ACE_ASSERT (ACE_OS::strcmp (artist, "the Beatles") == 0); + + const char *title = 0; + +# if (defined (_MSC_VER) && (_MSC_VER < 1310)) + ACE_ASSERT ((*args->item (1)->value () >>= title) == 1); +# else + ACE_ASSERT ((*args->item (1)->value () >>= title) == true); +# endif /* _MSC_VER <= 1310 */ + + const char *correct = "Sgt. Pepper's Lonely Hearts Club Band"; + ACE_ASSERT (ACE_OS::strcmp (title, correct) == 0); + ACE_UNUSED_ARG (correct); + + CORBA::Float price = 0.0f; + +# if (defined (_MSC_VER) && (_MSC_VER < 1310)) + ACE_ASSERT ((*args->item (2)->value () >>= price) == 1); +# else + ACE_ASSERT ((*args->item (2)->value () >>= price) == true); +# endif /* _MSC_VER <= 1310 */ + + ACE_ASSERT (price == 13.49f); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%s:\t%s\n") + ACE_TEXT ("%s:\t%s\n") + ACE_TEXT ("%s:\t$%2.2f\n"), + args->item (0)->name (), + artist, + args->item (1)->name (), + title, + args->item (2)->name (), + price)); + } + + CORBA::Boolean in_stock = 0; + + CORBA::Boolean ret_status = + (this->req_->return_value () >>= CORBA::Any::to_boolean (in_stock)); + ACE_UNUSED_ARG (ret_status); + + ACE_ASSERT (ret_status == 1); + ACE_ASSERT (in_stock == 1); + + if (this->debug_) + { + if (in_stock) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("status: in stock\n"))); + } + else + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("status: out of stock\n"))); + } + } + } +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/ifr_dii_client.h b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/ifr_dii_client.h new file mode 100644 index 00000000000..a362e0053cc --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/ifr_dii_client.h @@ -0,0 +1,85 @@ +// -*- C++ -*- +// $Id$ + +#ifndef IFR_DII_CLIENT_H +#define IFR_DII_CLIENT_H + +#include "tao/DynamicInterface/Request.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/IFR_Client/IFR_BasicC.h" + +class IFR_DII_Client +{ +public: + IFR_DII_Client (void); + ~IFR_DII_Client (void); + + int init (int argc, + char *argv[] + ACE_ENV_ARG_DECL); + // Initialize the client. + + int run (ACE_ENV_SINGLE_ARG_DECL); + // Run the client. + +private: + int parse_args (int argc, + char *argv[]); + // Process the command line arguments. + + int find_interface_def (ACE_ENV_SINGLE_ARG_DECL); + // Query the object reference to get its InterfaceDef in the IFR. + + int lookup_interface_def (ACE_ENV_SINGLE_ARG_DECL); + // Look up the InterfaceDef by name in the IFR. + + void get_operation_def (ACE_ENV_SINGLE_ARG_DECL); + // Find the desired operation in the interface definition. + + void create_dii_request (ACE_ENV_SINGLE_ARG_DECL); + // Query the interface definition to get the info needed + // to construct a CORBA::Request. + + void invoke_and_display (ACE_ENV_SINGLE_ARG_DECL); + // Do the invocation and display the results. + + CORBA::ORB_var orb_; + // Reference to our ORB. + + CORBA::Repository_var repo_; + // Reference to the Interface Repository. + + CORBA::Object_var target_; + // Reference to the target object. + + CORBA::InterfaceDef_var target_def_; + // Repository entry corresponding to target_. + + CORBA::OperationDef_var op_; + // Reference to the discovered operation. + + CORBA::TypeCode_var result_; + // Type of the return value, if any. + + CORBA::Request_var req_; + // DII request holder. + + CORBA::String_var namespace_name; + CORBA::String_var interface_name; + CORBA::String_var op_name; + // Things that we will be searching for in the repository. + + bool lookup_by_name_; + // Are we looking up info on the target object by querying the + // IFR directly with the target's name, or indirectly + // by calling _get_interface() on the target object? + + bool debug_; + // Display results and debugging info? +}; + +#endif /* IFR_DII_CLIENT_H */ diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/run_test.pl b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/run_test.pl new file mode 100755 index 00000000000..901935cfa40 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/run_test.pl @@ -0,0 +1,112 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../../bin"; +use PerlACE::Run_Test; + +$status = 0; + +$ifr_iorfile= "if_repo.ior"; +$svr_iorfile = "iorfile"; +$test_idl = PerlACE::LocalFile ("test.idl"); + +$lookup_by_name = ""; +$other = ""; + +for ($i = 0; $i <= $#ARGV; $i++) { + if ($ARGV[$i] eq "-n") { + $lookup_by_name = "-n"; + } + else { + $other .= $ARGV[$i]; + } +} + +$TAO_IFR = new PerlACE::Process ("../../../../../bin/tao_ifr"); + +# We want the tao_ifr executable to be found exactly in the path +# given, without being modified by the value of -ExeSubDir. +# So, we tell its Process object to ignore the setting of -ExeSubDir. + +$TAO_IFR->IgnoreExeSubDir (1); + +$IFR = new PerlACE::Process ("../../../IFR_Service/IFR_Service", " -o $ifr_iorfile"); +$SV = new PerlACE::Process ("server", "-ORBInitRef InterfaceRepository=file://$ifr_iorfile"); +$CL = new PerlACE::Process ("client", "-ORBInitRef InterfaceRepository=file://$ifr_iorfile" + . " $lookup_by_name"); +$CL2 = new PerlACE::Process ("client", "-ORBInitRef InterfaceRepository=file://$ifr_iorfile -n"); + +unlink $ifr_iorfile; +unlink $svr_iorfile; + +$IFR->Spawn (); + +if (PerlACE::waitforfile_timed ($ifr_iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$ifr_iorfile>\n"; + $IFR->Kill (); + exit 1; +} + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($svr_iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$svr_iorfile>\n"; + $IFR->Kill (); + $SV->Kill (); + exit 1; +} + +$TAO_IFR->Arguments ("-ORBInitRef InterfaceRepository=file://$ifr_iorfile $test_idl"); + +$tresult = $TAO_IFR->SpawnWaitKill (30); + +if ($tresult != 0) { + print STDERR "ERROR: tao_ifr (test.idl) returned $tresult\n"; + $status = 1; +} + +$client = $CL->SpawnWaitKill (60); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$TAO_IFR->Arguments ("-ORBInitRef InterfaceRepository=file://$ifr_iorfile -r $test_idl"); + +$tresult = $TAO_IFR->SpawnWaitKill (30); + +if ($tresult != 0) { + print STDERR "ERROR: tao_ifr (-r test.idl) returned $tresult\n"; + $status = 1; +} + +# Do another lookup to check it really has been removed. +$client = $CL2->SpawnWaitKill (60); + +if ($client == 0) { + print STDERR "ERROR: second client run returned $client\n"; + $status = 1; +} + +$server = $SV->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} +$server = $IFR->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: IFR returned $server\n"; + $status = 1; +} + +unlink $ifr_iorfile; +unlink $svr_iorfile; + +exit $status; diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/server.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/server.cpp new file mode 100644 index 00000000000..7cfe8d9c287 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/server.cpp @@ -0,0 +1,107 @@ +// -*- C++ -*- +// $Id$ + +#include "test_i.h" +#include "ace/OS_NS_stdio.h" + +ACE_RCSID(Application_Test, server, "$Id$") + +static const char *ior_output_file = "iorfile"; + +static int +write_ior_to_file (const char *ior) +{ + FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); + + if (output_file == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output files for writing IOR: %s\n", + ior_output_file), + -1); + } + + int result = ACE_OS::fprintf (output_file, + "%s", + ior); + if (result < 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "ACE_OS::fprintf failed while writing %s to %s\n", + ior, + ior_output_file), + -1); + } + + ACE_OS::fclose (output_file); + + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv, + "" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var poa_object = + orb->resolve_initial_references ("RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + inventory_i servant_impl; + + warehouse::inventory_var servant = + servant_impl._this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (servant.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + int write_result = write_ior_to_file (ior.in ()); + + if (write_result != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "write_ior_to_file"), + -1); + } + + orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + root_poa->destroy (1, + 1 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "server exception:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test.idl b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test.idl new file mode 100644 index 00000000000..8ac11a758fb --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test.idl @@ -0,0 +1,14 @@ +// -*- C++ -*- +// $Id$ + +module warehouse +{ + interface inventory + { + boolean getCDinfo (in string artist, + inout string title, + out float price); + }; +}; + + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test_i.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test_i.cpp new file mode 100644 index 00000000000..45214149850 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test_i.cpp @@ -0,0 +1,51 @@ +// -*- C++ -*- +// $Id$ + +#include "test_i.h" + +#include "ace/SString.h" + + +ACE_RCSID (Application_Test, + test_i, + "$Id$") + + +CORBA::Boolean +inventory_i::getCDinfo (const char * artist, + char *& title, + CORBA::Float_out price + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::Boolean in_stock = 0; + price = 0.0f; + ACE_CString name_key ("Beatles"); + ACE_CString name (artist); + + if (name.strstr (name_key) != ACE_CString::npos) + { + ACE_CString title_key ("Sgt. Pepper"); + ACE_CString working_title (title); + + if (working_title.strstr (title_key) != ACE_CString::npos) + { + title = + CORBA::string_dup ("Sgt. Pepper's Lonely Hearts Club Band"); + + price = 13.49f; + + in_stock = 1; + } + else + { + title = CORBA::string_dup ("not found"); + } + } + else + { + title = CORBA::string_dup ("not found"); + } + + return in_stock; +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test_i.h b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test_i.h new file mode 100644 index 00000000000..2e3a4164285 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Application_Test/test_i.h @@ -0,0 +1,19 @@ +// -*- C++ -*- +// $Id$ + +#include "testS.h" + +// Must include this header file and link to TAO_IFR_Client.lib +// to dynamically load this necessary library. +#include "tao/IFR_Client/IFR_Client_Adapter_Impl.h" + +class inventory_i : public POA_warehouse::inventory +{ +public: + CORBA::Boolean getCDinfo (const char * artist, + char *& title, + CORBA::Float_out price + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); +}; + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/IFR_IDL3_Test.mpc b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/IFR_IDL3_Test.mpc new file mode 100644 index 00000000000..e1f0a71cc46 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/IFR_IDL3_Test.mpc @@ -0,0 +1,14 @@ +// -*- MPC -*- +// $Id$ + +project: taoexe, ifr_client, minimum_corba { + exename = IDL3_Test + + Source_Files { + client.cpp + idl3_client.cpp + } + + IDL_Files { + } +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/Makefile.am b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/Makefile.am new file mode 100644 index 00000000000..34c2f1abb7d --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/Makefile.am @@ -0,0 +1,48 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_ROOT = $(top_srcdir) + + +## Makefile.IFR_IDL3_Test.am + +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS = IDL3_Test + +IDL3_Test_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +IDL3_Test_SOURCES = \ + client.cpp \ + idl3_client.cpp \ + idl3_client.h + +IDL3_Test_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_MINIMUM_CORBA + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/README b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/README new file mode 100644 index 00000000000..98b048231ad --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/README @@ -0,0 +1,33 @@ +$Id$ + +This test specializes in the Interface Repository support of +valuetypes and the IDL extensions that were added to +support the CORBA Component Model (CCM). Testing of most of +the other IDL types can be found in the nearby IFR_Test +directory. + +The test can be run automatically by executing the provided +Perl script run_test.pl. If debugging of one or more of +the processes is desired, each can be run by hand, in the +same order that they are found in the script. The script +also shows reasonable command line arguments for each process. + +No code is generated from the IDL file. It is there only to +have its contents loaded into the IFR by the Interface +Repository loader, tao_ifr. + +The -d option may be passed to the client, which will then +output detailed messages in the event of a test error. +Otherwise, only test success or failure will be output. + +All the numeric and string constants, storing the names, flags, +and sequence lengths found in test.idl, appear at the top of +idl3_client.cpp. This allows the test to be easily extended +to cover more complicated use cases. + +More information about the Interface Repository can be found in +TAO/docs/releasenotes/index.html. + + + +- Jeff Parsons
\ No newline at end of file diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/client.cpp b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/client.cpp new file mode 100644 index 00000000000..410ad1fd4f3 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/client.cpp @@ -0,0 +1,44 @@ +// -*- C++ -*- +// $Id$ + +#include "idl3_client.h" + +ACE_RCSID (Application_Test, + client, + "$Id$") + +int +main (int argc, char *argv[]) +{ + IDL3_Client client; + + ACE_TRY_NEW_ENV + { + if (client.init (argc, + argv + ACE_ENV_ARG_PARAMETER) + == -1) + { + return 1; + } + else + { + int status = client.run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (status == -1) + { + return 1; + } + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Client Exception"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/idl3_client.cpp b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/idl3_client.cpp new file mode 100644 index 00000000000..9c9a0a21607 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/idl3_client.cpp @@ -0,0 +1,1894 @@ +// -*- C++ -*- +// $Id$ + +#include "idl3_client.h" +#include "tao/ORB.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (Application_Test, + ifr_dii_client, + "$Id$") + +// All the magic quantities are here at the top. + +const char *COMPONENT_ID = "IDL:mod/test_component:1.0"; +const char *COMPONENT_SCOPED_NAME = "::mod::test_component"; +const char *COMP_BASE_ID = "IDL:help/c_base:1.0"; + +const char *VALUETYPE_ID = "IDL:mod/test_valuetype:1.0"; +const char *VALUETYPE_SCOPED_NAME = "::mod::test_valuetype"; +const char *VT_BASE_ID = "IDL:help/v_base:1.0"; + +const char *HOME_ID = "IDL:mod/test_home:1.0"; +const char *HOME_SCOPED_NAME = "::mod::test_home"; +const char *HOME_BASE_ID = "IDL:help/h_base:1.0"; +const char *HOME_KEY_ID = "IDL:help/h_key:1.0"; + +const char *EVENTTYPE_ID = "IDL:mod/test_eventtype:1.0"; + +const CORBA::ULong ATTRS_LEN = 1; +const CORBA::ULong OPS_LEN = 1; +const CORBA::ULong FACTORY_LEN = 2; + +const char *ATTR_LOCAL_NAMES[] = + { + "c_attr1" + }; + +const CORBA::TCKind ATTR_TC_KINDS[] = + { + CORBA::tk_long + }; + +const CORBA::ULong GET_EXCEP_LEN[] = + { + 1 + }; + +const CORBA::ULong PUT_EXCEP_LEN[] = + { + 2 + }; + +const char *OP_NAMES[] = + { + "v_op" + }; + +const CORBA::TCKind OP_RET_KINDS[] = + { + CORBA::tk_string + }; + +const CORBA::ULong PARAMS_LEN[] = + { + 3 + }; + +const char *PARAM_NAMES[] = + { + "inoutarg", + "inarg", + "outarg" + }; + +const CORBA::ULong OP_EXCEP_LEN[] = + { + 2 + }; + +const CORBA::ULong COMP_SUPPORTED_LEN = 2; + +const char *COMP_SUPPORTED_IDS[] = + { + "IDL:help/c_supp1:1.0", + "IDL:help/c_supp2:1.0" + }; + +const CORBA::ULong PROVIDES_LEN = 1; +const CORBA::ULong USES_LEN = 2; +const CORBA::ULong EMITS_LEN = 1; +const CORBA::ULong PUBLISHES_LEN = 1; +const CORBA::ULong CONSUMES_LEN = 1; + +const char *PROVIDES_NAMES[] = + { + "test_provides1" + }; + +const char *PROVIDES_TYPE_IDS[] = + { + "IDL:help/c_provides1:1.0" + }; + +const char *USES_NAMES[] = + { + "test_uses1", + "test_uses2" + }; + +const char *USES_TYPE_IDS[] = + { + "IDL:help/c_uses1:1.0", + "IDL:help/c_uses2:1.0" + }; + +const CORBA::Boolean USES_MULTIPLE_FLAGS[] = + { + 0, + 1 + }; + +const char *EMITS_NAMES[] = + { + "test_emits1" + }; + +const char *PUBLISHES_NAMES[] = + { + "test_publishes1" + }; + +const char *CONSUMES_NAMES[] = + { + "test_consumes1" + }; + +const char *EMITS_IDS[] = + { + "IDL:help/c_emits1:1.0" + }; + +const char *PUBLISHES_IDS[] = + { + "IDL:help/c_publishes1:1.0" + }; + +const char *CONSUMES_IDS[] = + { + "IDL:help/c_consumes1:1.0" + }; + +const CORBA::ULong VT_SUPPORTED_LEN = 2; + +const char *VT_SUPPORTED_IDS[] = + { + "IDL:help/v_supp1:1.0", + "IDL:help/v_supp2:1.0" + }; + +const CORBA::ULong MEM_LEN = 2; + +const CORBA::Visibility MEM_VIS[] = + { + CORBA::PUBLIC_MEMBER, + CORBA::PRIVATE_MEMBER + }; + +const char *MEM_NAMES[] = + { + "test_mem1", + "test_mem2", + }; + +const CORBA::ULong VT_FACTORY_PARAM_LENS[] = + { + 1, + 2 + }; + +const CORBA::ULong VT_FACTORY_EXCEP_LENS[] = + { + 0, + 2 + }; + +const char *VT_FACTORY_PARAM_NAMES[][2] = + { + {"set_tm1", 0}, + {"set_tm1a", "set_tm2"} + }; + +const char *VT_FACTORY_EXCEP_NAMES[][2] = + { + {0, 0}, + {"whups", "doh"} + }; + +const CORBA::ULong HOME_SUPPORTED_LEN = 2; + +const char *HOME_SUPPORTED_IDS[] = + { + "IDL:help/h_supp1:1.0", + "IDL:help/h_supp2:1.0" + }; + +const CORBA::ULong HOME_FACTORY_LEN = 1; +const CORBA::ULong HOME_FINDER_LEN = 1; + +const CORBA::ULong HOME_FACTORY_PARAM_LENS[] = + { + 1 + }; + +const char *HOME_FACTORY_PARAM_NAMES[][1] = + { + {"set_uid"} + }; + +const CORBA::ULong HOME_FACTORY_EXCEP_LENS[] = + { + 1 + }; + +const char *HOME_FACTORY_EXCEP_NAMES[][1] = + { + {"doh"} + }; + +const CORBA::ULong HOME_FINDER_PARAM_LENS[] = + { + 3 + }; + +const char *HOME_FINDER_PARAM_NAMES[][3] = + { + {"id_number", "id_string", "pkey"} + }; + +const CORBA::ULong HOME_FINDER_EXCEP_LENS[] = + { + 1 + }; + +const char *HOME_FINDER_EXCEP_NAMES[][1] = + { + {"whups"} + }; + +IDL3_Client::IDL3_Client (void) + : debug_ (0) +{ +} + +IDL3_Client::~IDL3_Client (void) +{ +} + +int +IDL3_Client::init (int argc, + char *argv[] + ACE_ENV_ARG_DECL) +{ + this->orb_ = CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + CORBA::Object_var obj = + this->orb_->resolve_initial_references ("InterfaceRepository" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (obj.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "IDL3_Client - IFR resolution failed\n"), + -1); + } + + this->repo_ = + CORBA::ComponentIR::Repository::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (this->repo_.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "IDL3_Client - IFR narrow failed\n"), + -1); + } + + if (this->parse_args (argc, argv) == -1) + { + return -1; + } + + return 0; +} + +int +IDL3_Client::run (ACE_ENV_SINGLE_ARG_DECL) +{ + int status = this->component_test (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return status; + } + + status = this->valuetype_test (VALUETYPE_ID, + "value" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return status; + } + + status = this->home_test (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return status; + } + + status = this->valuetype_test (EVENTTYPE_ID, + "event" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return status; + } + + return 0; +} + +int +IDL3_Client::parse_args (int argc, + char *argv[]) +{ + ACE_Get_Opt opts (argc, argv, "d"); + int c; + + while ((c = opts ()) != -1) + switch (c) + { + case 'd': // Turn on debugging outoput. + this->debug_ = 1; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + "\n", + argv [0]), + -1); + } + + return 0; +} + +int +IDL3_Client::component_test (ACE_ENV_SINGLE_ARG_DECL) +{ + CORBA::Contained_var result = + this->repo_->lookup_id (COMPONENT_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (result.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_test: lookup by id failed\n")); + } + + return -1; + } + + CORBA::String_var str = + result->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + const char *tmp = str.in (); + + if (tmp == 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_test: component has null scoped name\n")); + } + + return -1; + } + + if (ACE_OS::strcmp (tmp, COMPONENT_SCOPED_NAME) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_test: " + "component has incorrect scoped name\n")); + } + + return -1; + } + + CORBA::ComponentIR::ComponentDef_var comp_def = + CORBA::ComponentIR::ComponentDef::_narrow (result.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + CORBA::TypeCode_var comp_tc = + comp_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (comp_tc.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_test: " + "type code creation failed\n")); + } + + return -1; + } + + tmp = comp_tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (tmp == 0 || ACE_OS::strcmp (tmp, COMPONENT_ID) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_test: " + "bad id from type code\n")); + } + + return -1; + } + + CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription_var desc = + comp_def->describe_ext_interface (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (desc.ptr () == 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_test: " + "describe_ext_interface return null\n")); + } + + return -1; + } + + int status = this->component_attribute_test (desc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->component_inheritance_test (comp_def + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->component_port_test (comp_def + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + return 0; +} + +int +IDL3_Client::home_test (ACE_ENV_SINGLE_ARG_DECL) +{ + CORBA::Contained_var result = + this->repo_->lookup_id (HOME_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (result.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_test: lookup by id failed\n")); + } + + return -1; + } + + CORBA::ComponentIR::HomeDef_var home = + CORBA::ComponentIR::HomeDef::_narrow (result.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (result.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_test: home narrow failed\n")); + } + + return -1; + } + + CORBA::ComponentIR::ComponentDef_var managed = + home->managed_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (managed.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_test: managed component is null\n")); + } + + return -1; + } + + CORBA::String_var str = managed->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (str.in () == 0 || ACE_OS::strcmp (str.in (), COMPONENT_ID) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_test: bad id for managed component\n")); + } + + return -1; + } + + CORBA::ValueDef_var pkey = + home->primary_key (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (pkey.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_test: primary key is null\n")); + } + + return -1; + } + + str = pkey->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (str.in () == 0 || ACE_OS::strcmp (str.in (), HOME_KEY_ID) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_test: bad id for managed component\n")); + } + + return -1; + } + + int status = this->home_inheritance_test (home + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + CORBA::Contained::Description_var desc = + home->describe (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + CORBA::ComponentIR::HomeDescription *home_desc = 0; + + if ((desc->value >>= home_desc) == 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_test: extraction of HomeDescription failed\n")); + } + + return -1; + } + + status = this->home_factory_test (home_desc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->home_finder_test (home_desc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + return 0; +} + +int +IDL3_Client::valuetype_test (const char *repo_id, + const char *prefix + ACE_ENV_ARG_DECL) +{ + CORBA::Contained_var result = + this->repo_->lookup_id (repo_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (result.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_test: lookup by id failed\n", + prefix)); + } + + return -1; + } + + CORBA::ExtValueDef_var evd = + CORBA::ExtValueDef::_narrow (result.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (evd.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_test: narrow to ExtValueDef failed\n")); + } + + return -1; + } + + CORBA::ExtValueDef::ExtFullValueDescription_var desc = + evd->describe_ext_value (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + int status = this->valuetype_attribute_test (desc, + prefix + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->valuetype_inheritance_test (evd, + prefix + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->valuetype_operation_test (desc, + prefix + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->valuetype_member_test (desc, + prefix + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->valuetype_factory_test (desc, + prefix + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + return 0; +} + +int +IDL3_Client::component_attribute_test ( + CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription_var &desc + ACE_ENV_ARG_DECL + ) +{ + if (desc->attributes.length () != ATTRS_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_attribute_test: wrong number of attrs\n")); + } + + return -1; + } + + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < ATTRS_LEN; ++i) + { + tmp = desc->attributes[i].name.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, ATTR_LOCAL_NAMES[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_attribute_test: " + "wrong local name for attribute #%d\n", + i + 1)); + } + + return -1; + } + + CORBA::TCKind kind = + desc->attributes[i].type->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (kind != ATTR_TC_KINDS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_attribute_test: " + "wrong TCKind for attribute #%d\n", + i + 1)); + } + + return -1; + } + + if (desc->attributes[i].get_exceptions.length () != GET_EXCEP_LEN[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_attribute_test: " + "wrong number of get-exceptions" + " for attribute #%d\n", + i + 1)); + } + + return -1; + } + + if (desc->attributes[i].put_exceptions.length () != PUT_EXCEP_LEN[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_attribute_test: " + "wrong number of put-exceptions" + " for attribute #%d\n", + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::component_inheritance_test ( + CORBA::ComponentIR::ComponentDef_var &comp_def + ACE_ENV_ARG_DECL + ) +{ + CORBA::ComponentIR::ComponentDef_var comp_base = + comp_def->base_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (comp_base.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_inheritance_test: " + "base component is null\n")); + } + + return -1; + } + + CORBA::String_var str = comp_base->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (str.in () == 0 || ACE_OS::strcmp (str.in (), COMP_BASE_ID) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_inheritance_test: " + "bad id on base component\n")); + } + + return -1; + } + + CORBA::InterfaceDefSeq_var supported = + comp_base->supported_interfaces (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + CORBA::ULong length = supported->length (); + + if (length != COMP_SUPPORTED_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_inheritance_test: " + "wrong number of supported interfaces\n")); + } + + return -1; + } + + for (CORBA::ULong i = 0; i < length; ++i) + { + str = supported[i]->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (str.in () == 0 + || ACE_OS::strcmp (str.in (), COMP_SUPPORTED_IDS[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_inheritance_test: " + "bad id on supported interface #%d\n", + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::component_port_test ( + CORBA::ComponentIR::ComponentDef_var &comp_def + ACE_ENV_ARG_DECL + ) +{ + CORBA::Contained::Description_var desc = + comp_def->describe (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + CORBA::ComponentIR::ComponentDescription *cd = 0; + + if ((desc->value >>= cd) == 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "component_port_test: " + "Any extraction of component description failed\n")); + } + + return -1; + } + + int status = this->provides_test (cd->provided_interfaces + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->uses_test (cd->used_interfaces + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->event_port_test (cd->emits_events, + EMITS_LEN, + "emits", + EMITS_NAMES, + EMITS_IDS + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->event_port_test (cd->publishes_events, + PUBLISHES_LEN, + "publishes", + PUBLISHES_NAMES, + PUBLISHES_IDS + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + status = this->event_port_test (cd->consumes_events, + CONSUMES_LEN, + "consumes", + CONSUMES_NAMES, + CONSUMES_IDS + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (status != 0) + { + return -1; + } + + return 0; +} + +int +IDL3_Client::provides_test (CORBA::ComponentIR::ProvidesDescriptionSeq &pds + ACE_ENV_ARG_DECL_NOT_USED) +{ + if (pds.length () != PROVIDES_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "provides_test: " + "wrong number of provides interfaces\n")); + } + + return -1; + } + + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < PROVIDES_LEN; ++i) + { + tmp = pds[i].name.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, PROVIDES_NAMES[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "provides_test: " + "wrong local name for provides #%d\n", + i + 1)); + } + + return -1; + } + + tmp = pds[i].interface_type.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, PROVIDES_TYPE_IDS[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "provides_test: " + "wrong base interface type id for provides #%d\n", + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::uses_test (CORBA::ComponentIR::UsesDescriptionSeq &uds + ACE_ENV_ARG_DECL_NOT_USED) +{ + if (uds.length () != USES_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "uses_test: " + "wrong number of uses interfaces\n")); + } + + return -1; + } + + const char *tmp = 0; + CORBA::Boolean mult = 0; + + for (CORBA::ULong i = 0; i < USES_LEN; ++i) + { + tmp = uds[i].name.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, USES_NAMES[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "uses_test: " + "wrong local name for uses #%d\n", + i + 1)); + } + + return -1; + } + + tmp = uds[i].interface_type.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, USES_TYPE_IDS[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "uses_test: " + "wrong base interface type id for uses #%d\n", + i + 1)); + } + + return -1; + } + + mult = uds[i].is_multiple; + + if (mult != USES_MULTIPLE_FLAGS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "uses_test: " + "wrong is_multiple value for uses #%d\n", + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::event_port_test (CORBA::ComponentIR::EventPortDescriptionSeq &eds, + CORBA::ULong seq_length, + const char *port_type, + const char **names, + const char **ids + ACE_ENV_ARG_DECL_NOT_USED) +{ + if (eds.length () != seq_length) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "event_port_test: " + "wrong number of event %s ports\n", + port_type)); + } + + return -1; + } + + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < seq_length; ++i) + { + tmp = eds[i].name.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, names[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "event_port_test: " + "wrong local name for %s port #%d\n", + port_type, + i + 1)); + } + + return -1; + } + + tmp = eds[i].event.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, ids[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "event_port_test: " + "wrong base event type id for %s port #%d\n", + port_type, + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::valuetype_inheritance_test (CORBA::ExtValueDef_var &vd, + const char *prefix + ACE_ENV_ARG_DECL) +{ + CORBA::ValueDef_var bvd = vd->base_value (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (bvd.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_inheritance_test: " + "base valuetype is null\n", + prefix)); + } + + return -1; + } + + CORBA::String_var str = bvd->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (str.in () == 0 || ACE_OS::strcmp (str.in (), VT_BASE_ID) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_inheritance_test: " + "wrong repo id for base valuetype\n", + prefix)); + } + + return -1; + } + + CORBA::InterfaceDefSeq_var supported = + vd->supported_interfaces (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + CORBA::ULong length = supported->length (); + + if (length != VT_SUPPORTED_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_inheritance_test: " + "wrong number of supported interfaces\n", + prefix)); + } + + return -1; + } + + for (CORBA::ULong i = 0; i < length; ++i) + { + str = supported[i]->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (str.in () == 0 + || ACE_OS::strcmp (str.in (), VT_SUPPORTED_IDS[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_inheritance_test: " + "bad id on supported interface #%d\n", + prefix, + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::valuetype_attribute_test ( + CORBA::ExtValueDef::ExtFullValueDescription_var &desc, + const char *prefix + ACE_ENV_ARG_DECL + ) +{ + if (desc->attributes.length () != ATTRS_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_attribute_test: wrong number of attrs\n", + prefix)); + } + + return -1; + } + + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < ATTRS_LEN; ++i) + { + tmp = desc->attributes[i].name.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, ATTR_LOCAL_NAMES[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_attribute_test: " + "wrong local name for attribute #%d\n", + prefix, + i + 1)); + } + + return -1; + } + + CORBA::TCKind kind = + desc->attributes[i].type->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (kind != ATTR_TC_KINDS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_attribute_test: " + "wrong TCKind for attribute #%d\n", + prefix, + i + 1)); + } + + return -1; + } + + if (desc->attributes[i].get_exceptions.length () != GET_EXCEP_LEN[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_attribute_test: " + "wrong number of get-exceptions" + " for attribute #%d\n", + prefix, + i + 1)); + } + + return -1; + } + + if (desc->attributes[i].put_exceptions.length () != PUT_EXCEP_LEN[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_attribute_test: " + "wrong number of put-exceptions" + " for attribute #%d\n", + prefix, + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::valuetype_operation_test ( + CORBA::ExtValueDef::ExtFullValueDescription_var &desc, + const char *prefix + ACE_ENV_ARG_DECL + ) +{ + CORBA::ULong ops_length = desc->operations.length (); + + if (ops_length != OPS_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_operation_test: " + "wrong number of operations\n", + prefix)); + } + + return -1; + } + + const char *tmp = 0; + CORBA::ULong j = 0; + CORBA::ULong length = 0; + + for (CORBA::ULong i = 0; i < ops_length; ++i) + { + tmp = desc->operations[i].name.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, OP_NAMES[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_operation_test: " + "wrong name for operation #%d\n", + prefix, + i + 1)); + } + + return -1; + } + + CORBA::TCKind ret_kind = + desc->operations[i].result.in ()->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (ret_kind != OP_RET_KINDS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_operation_test: " + "wrong return type\n", + prefix)); + } + + return -1; + } + + length = desc->operations[i].parameters.length (); + + if (length != PARAMS_LEN[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_operation_test: " + "wrong number of parameters in operation #%d\n", + prefix, + i + 1)); + } + + return -1; + } + + for (j = 0; j < length; ++j) + { + tmp = desc->operations[i].parameters[j].name.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, PARAM_NAMES[j]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_operation_test: " + "wrong name for operation #%d," + "parameter #%d\n", + prefix, + i + 1, + j + 1)); + } + + return -1; + } + } + + length = desc->operations[i].exceptions.length (); + + if (length != OP_EXCEP_LEN[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_operation_test: " + "wrong number of exceptions in operation #%d\n", + prefix, + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::valuetype_member_test ( + CORBA::ExtValueDef::ExtFullValueDescription_var &desc, + const char *prefix + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + CORBA::ULong length = desc->members.length (); + + if (length != MEM_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_member_test: " + "wrong number of members\n", + prefix)); + } + + return -1; + } + + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < length; ++i) + { + if (desc->members[i].access != MEM_VIS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_member_test: " + "wrong access value in member #%d\n", + prefix, + i + 1)); + } + + return -1; + } + + tmp = desc->members[i].name.in (); + + if (tmp == 0 || ACE_OS::strcmp (tmp, MEM_NAMES[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_member_test: " + "wrong repo id for member #%d\n", + prefix, + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::valuetype_factory_test ( + CORBA::ExtValueDef::ExtFullValueDescription_var &desc, + const char *prefix + ACE_ENV_ARG_DECL_NOT_USED + ) +{ + CORBA::ULong length = desc->initializers.length (); + + if (length != FACTORY_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_factory_test: " + "wrong number of factories\n", + prefix)); + } + + return -1; + } + + CORBA::ULong inside_len = 0; + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < FACTORY_LEN; ++i) + { + inside_len = desc->initializers[i].members.length (); + + if (inside_len != VT_FACTORY_PARAM_LENS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_factory_test: " + "wrong number of params in factory #%d\n", + prefix, + i + 1)); + } + + return -1; + } + + CORBA::ULong j = 0; + + for (j = 0; j < VT_FACTORY_PARAM_LENS[i]; ++j) + { + tmp = desc->initializers[i].members[j].name.in (); + + if (tmp == 0 + || ACE_OS::strcmp (tmp, VT_FACTORY_PARAM_NAMES[i][j]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_factory_test: " + "wrong name for arg #%d in factory #%d\n", + prefix, + j + 1, + i + 1)); + } + + return -1; + } + } + + inside_len = desc->initializers[i].exceptions.length (); + + if (inside_len != VT_FACTORY_EXCEP_LENS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_factory_test: " + "wrong number of exceptions in factory #%d\n", + prefix, + i + 1)); + } + + return -1; + } + + for (j = 0; j < VT_FACTORY_EXCEP_LENS[i]; ++j) + { + tmp = desc->initializers[i].exceptions[j].name.in (); + + if (tmp == 0 + || ACE_OS::strcmp (tmp, VT_FACTORY_EXCEP_NAMES[i][j]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "%stype_factory_test: " + "wrong name for exception #%d in factory #%d\n", + prefix, + j + 1, + i + 1)); + } + + return -1; + } + } + } + + return 0; +} + +int +IDL3_Client::home_inheritance_test (CORBA::ComponentIR::HomeDef_var &hd + ACE_ENV_ARG_DECL) +{ + CORBA::ComponentIR::HomeDef_var bhd = + hd->base_home (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (bhd.in ())) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_inheritance_test: " + "base home is null\n")); + } + + return -1; + } + + CORBA::String_var str = bhd->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (str.in () == 0 || ACE_OS::strcmp (str.in (), HOME_BASE_ID) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_inheritance_test: " + "wrong repo id for base home\n")); + } + + return -1; + } + + CORBA::InterfaceDefSeq_var supported = + bhd->supported_interfaces (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + CORBA::ULong length = supported->length (); + + if (length != HOME_SUPPORTED_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_inheritance_test: " + "wrong number of supported interfaces\n")); + } + + return -1; + } + + for (CORBA::ULong i = 0; i < length; ++i) + { + str = supported[i]->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (str.in () == 0 + || ACE_OS::strcmp (str.in (), HOME_SUPPORTED_IDS[i]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_inheritance_test: " + "bad id on supported interface #%d\n", + i + 1)); + } + + return -1; + } + } + + return 0; +} + +int +IDL3_Client::home_factory_test (CORBA::ComponentIR::HomeDescription *hd + ACE_ENV_ARG_DECL_NOT_USED) +{ + CORBA::ULong length = hd->factories.length (); + + if (length != HOME_FACTORY_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_factory_test: " + "wrong number of factories\n")); + } + + return -1; + } + + CORBA::ULong inside_len = 0; + CORBA::ULong j = 0; + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < HOME_FACTORY_LEN; ++i) + { + inside_len = hd->factories[i].parameters.length (); + + if (inside_len != HOME_FACTORY_PARAM_LENS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_factory_test: " + "wrong number of params in factory #%d\n", + i + 1)); + } + + return -1; + } + + for (j = 0; j < inside_len; ++j) + { + tmp = hd->factories[i].parameters[j].name.in (); + + if (tmp == 0 + || ACE_OS::strcmp (tmp, HOME_FACTORY_PARAM_NAMES[i][j]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_factory_test: " + "wrong name for param #%d in factory #%d\n", + j + 1, + i + 1)); + } + + return -1; + } + } + + inside_len = hd->factories[i].exceptions.length (); + + if (inside_len != HOME_FACTORY_EXCEP_LENS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_factory_test: " + "wrong number of exceptions in factory #%d\n", + i + 1)); + } + + return -1; + } + + for (j = 0; j < inside_len; ++j) + { + tmp = hd->factories[i].exceptions[j].name.in (); + + if (tmp == 0 + || ACE_OS::strcmp (tmp, HOME_FACTORY_EXCEP_NAMES[i][j]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_factory_test: " + "wrong name for exception #%d in factory #%d\n", + j + 1, + i + 1)); + } + + return -1; + } + } + } + + return 0; +} + +int +IDL3_Client::home_finder_test (CORBA::ComponentIR::HomeDescription *hd + ACE_ENV_ARG_DECL_NOT_USED) +{ + CORBA::ULong length = hd->finders.length (); + + if (length != HOME_FINDER_LEN) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_finder_test: " + "wrong number of finders\n")); + } + + return -1; + } + + CORBA::ULong inside_len = 0; + CORBA::ULong j = 0; + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < HOME_FINDER_LEN; ++i) + { + inside_len = hd->finders[i].parameters.length (); + + if (inside_len != HOME_FINDER_PARAM_LENS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_finder_test: " + "wrong number of params in finder #%d\n", + i + 1)); + } + + return -1; + } + + for (j = 0; j < inside_len; ++j) + { + tmp = hd->finders[i].parameters[j].name.in (); + + if (tmp == 0 + || ACE_OS::strcmp (tmp, HOME_FINDER_PARAM_NAMES[i][j]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_finder_test: " + "wrong name for param #%d in finder #%d\n", + j + 1, + i + 1)); + } + + return -1; + } + } + + inside_len = hd->finders[i].exceptions.length (); + + if (inside_len != HOME_FINDER_EXCEP_LENS[i]) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_finder_test: " + "wrong number of exceptions in finder #%d\n", + i + 1)); + } + + return -1; + } + + for (j = 0; j < inside_len; ++j) + { + tmp = hd->finders[i].exceptions[j].name.in (); + + if (tmp == 0 + || ACE_OS::strcmp (tmp, HOME_FINDER_EXCEP_NAMES[i][j]) != 0) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "home_finder_test: " + "wrong name for exception #%d in finder #%d\n", + j + 1, + i + 1)); + } + + return -1; + } + } + } + + return 0; +} + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/idl3_client.h b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/idl3_client.h new file mode 100644 index 00000000000..df2bd70a044 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/idl3_client.h @@ -0,0 +1,133 @@ +// -*- C++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/orbsvcs/tests/InterfaceRepo +// +// = FILENAME +// idl3_client.h +// +// = DESCRIPTION +// This class tests the IFR support for CCM-related types. +// +// = AUTHOR +// Jeff Parsons <j.parsons@vanderbilt.edu> +// +// ============================================================================ + +#ifndef IDL3_CLIENT_H +#define IDL3_CLIENT_H + +#include "tao/IFR_Client/IFR_ComponentsC.h" + +class IDL3_Client +{ + // = TITLE + // Component-aware IFR Client Implementation + // + // = DESCRIPTION + // Class wrapper for a client which tests the Interface Repository + // support for the OMG IDL3 extensions. +public: + IDL3_Client (void); + // Constructor + + ~IDL3_Client (void); + // Destructor + + int init (int argc, + char *argv[] + ACE_ENV_ARG_DECL); + // Initialize the ORB and get the IFR object reference. + + int run (ACE_ENV_SINGLE_ARG_DECL); + // Execute test code. + +private: + int parse_args (int argc, + char *argv[]); + // Process the command line arguments. + + int component_test (ACE_ENV_SINGLE_ARG_DECL); + int home_test (ACE_ENV_SINGLE_ARG_DECL); + + // Also tests eventtype. + int valuetype_test (const char *repo_id, + const char *prefix + ACE_ENV_ARG_DECL); + + int component_attribute_test ( + CORBA::InterfaceAttrExtension::ExtFullInterfaceDescription_var & + ACE_ENV_ARG_DECL + ); + + int component_inheritance_test (CORBA::ComponentIR::ComponentDef_var & + ACE_ENV_ARG_DECL); + + int component_port_test (CORBA::ComponentIR::ComponentDef_var & + ACE_ENV_ARG_DECL); + + int provides_test (CORBA::ComponentIR::ProvidesDescriptionSeq & + ACE_ENV_ARG_DECL); + + int uses_test (CORBA::ComponentIR::UsesDescriptionSeq & + ACE_ENV_ARG_DECL); + + int event_port_test (CORBA::ComponentIR::EventPortDescriptionSeq &, + CORBA::ULong seq_length, + const char *port_type, + const char **names, + const char **ids + ACE_ENV_ARG_DECL); + + int valuetype_inheritance_test (CORBA::ExtValueDef_var &, + const char *prefix + ACE_ENV_ARG_DECL); + + int valuetype_attribute_test ( + CORBA::ExtValueDef::ExtFullValueDescription_var &, + const char *prefix + ACE_ENV_ARG_DECL + ); + + int valuetype_operation_test ( + CORBA::ExtValueDef::ExtFullValueDescription_var &, + const char *prefix + ACE_ENV_ARG_DECL + ); + + int valuetype_member_test ( + CORBA::ExtValueDef::ExtFullValueDescription_var &, + const char *prefix + ACE_ENV_ARG_DECL + ); + + int valuetype_factory_test ( + CORBA::ExtValueDef::ExtFullValueDescription_var &, + const char *prefix + ACE_ENV_ARG_DECL + ); + + int home_inheritance_test (CORBA::ComponentIR::HomeDef_var & + ACE_ENV_ARG_DECL); + + int home_factory_test (CORBA::ComponentIR::HomeDescription * + ACE_ENV_ARG_DECL); + + int home_finder_test (CORBA::ComponentIR::HomeDescription * + ACE_ENV_ARG_DECL); + +private: + CORBA::Boolean debug_; + // Flag to output detailed error messages. + + CORBA::ORB_var orb_; + // Storage of the ORB reference. + + CORBA::Repository_var repo_; + // Storage of the IFR reference. +}; + +#endif /* IDL3_CLIENT_H */ diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/run_test.pl b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/run_test.pl new file mode 100755 index 00000000000..80fb6ba003c --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/run_test.pl @@ -0,0 +1,82 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../../bin"; +use PerlACE::Run_Test; + +$status = 0; + +$ifr_iorfile= "if_repo.ior"; +$test_idl = PerlACE::LocalFile ("test.idl"); +$includes = "-I ../../../.. -I../../../../CIAO/ciao -I../../../../orbsvcs"; + +# find the tao_ifr executable. +# Its placement is dependent upon the OS and if MPC generated makefiles are used. +my $exec_extn=""; +if ($^O eq "MSWin32") { + $exec_extn=".exe"; +} + +$tao_ifr = "../../../../../bin/tao_ifr"; +if (! -e $tao_ifr . $exec_extn ) { + $tao_ifr = "../../../IFR_Service/tao_ifr"; + if (! -e $tao_ifr . $exec_extn ) { + print STDERR "ERROR: tao_ifr compiler not found.\n"; + exit 1; + } +} + +for ($i = 0; $i <= $#ARGV; $i++) { + if ($ARGV[$i] eq "-d") { + $debug = "-d"; + } + else { + $other .= $ARGV[$i]; + } +} + +$TAO_IFR = new PerlACE::Process ($tao_ifr); +$IFR = new PerlACE::Process ("../../../IFR_Service/IFR_Service", " -o $ifr_iorfile"); +$CL = new PerlACE::Process ("IDL3_Test", "-ORBInitRef InterfaceRepository=file://$ifr_iorfile" + . " $debug"); + +unlink $ifr_iorfile; + +$IFR->Spawn (); + +if (PerlACE::waitforfile_timed ($ifr_iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$ifr_iorfile>\n"; + $IFR->Kill (); + exit 1; +} + +$TAO_IFR->Arguments ("-ORBInitRef InterfaceRepository=file://$ifr_iorfile $includes $test_idl"); + +$tresult = $TAO_IFR->SpawnWaitKill (30); + +if ($tresult != 0) { + print STDERR "ERROR: tao_ifr (test.idl) returned $tresult\n"; + $status = 1; +} + +$client = $CL->SpawnWaitKill (60); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$server = $IFR->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: IFR returned $server\n"; + $status = 1; +} + +unlink $ifr_iorfile; + +exit $status; diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/test.idl b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/test.idl new file mode 100644 index 00000000000..b697c945933 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IDL3_Test/test.idl @@ -0,0 +1,123 @@ +// -*- C++ -*- +// $Id$ + +#ifndef INTERFACEREPO_IDL3_TEST +#define INTERFACEREPO_IDL3_TEST + +#include <Components.idl> + +module help +{ + exception doh {}; + exception whups {}; +}; + +module help +{ + interface c_supp1 {}; + interface c_supp2 {}; + component c_base supports c_supp1, c_supp2 {}; + valuetype v_base_base {}; + valuetype v_base : v_base_base {}; + interface v_supp1 {}; + abstract interface v_supp2 {}; + + valuetype h_key : Components::PrimaryKeyBase + { + public long id_key; + }; + + interface h_supp1 {}; + interface h_supp2 {}; + home h_base supports h_supp1, h_supp2 manages c_base {}; +}; + +module help +{ + interface c_provides1 {}; + interface c_uses1 {}; + interface c_uses2 {}; + eventtype c_emits1 {}; + eventtype c_publishes1 {}; + eventtype c_consumes1 {}; +}; + +module mod +{ + component test_component : help::c_base + { + attribute long c_attr1 + getraises (help::doh) + setraises (help::whups, help::doh); + + provides help::c_provides1 test_provides1; + + uses help::c_uses1 test_uses1; + + uses multiple help::c_uses2 test_uses2; + + emits help::c_emits1 test_emits1; + + publishes help::c_publishes1 test_publishes1; + + consumes help::c_consumes1 test_consumes1; + }; + + valuetype test_valuetype + : help::v_base supports help::v_supp1, help::v_supp2 + { + attribute long c_attr1 + getraises (help::doh) + setraises (help::whups, help::doh); + + string v_op (inout string inoutarg, + in help::v_supp1 inarg, + out long outarg) + raises (help::doh, help::whups); + + public string test_mem1; + private short test_mem2; + + factory default_factory (in string set_tm1); + factory create_tv (in string set_tm1a, + in short set_tm2) + raises (help::whups, help::doh); + }; + + home test_home : help::h_base + manages test_component primarykey help::h_key + { + factory create_tc (in string set_uid) + raises (help::doh); + + finder find_tc (in long id_number, + in string id_string, + in help::h_key pkey) + raises (help::whups); + }; + + eventtype test_eventtype + : help::v_base supports help::v_supp1, help::v_supp2 + { + attribute long c_attr1 + getraises (help::doh) + setraises (help::whups, help::doh); + + string v_op (inout string inoutarg, + in help::v_supp1 inarg, + out long outarg) + raises (help::doh, help::whups); + + public string test_mem1; + private short test_mem2; + + factory default_factory (in string set_tm1); + factory create_tv (in string set_tm1a, + in short set_tm2) + raises (help::whups, help::doh); + }; + +}; + +#endif /* INTERFACEREPO_IDL3_TEST */ + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/IFR_Inheritance_Test.idl b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/IFR_Inheritance_Test.idl new file mode 100644 index 00000000000..55d1cb99edb --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/IFR_Inheritance_Test.idl @@ -0,0 +1,33 @@ +// $Id$ +#ifndef __IFR_INHERITANCE_TEST_DEFINED +#define __IFR_INHERITANCE_TEST_DEFINED + +module IFR_Test +{ + typedef sequence<string> NameList; + + interface InterfaceRoot + { + readonly attribute string root_attr1; + attribute string root_attr2; + + void get_root(in string root_name, out InterfaceRoot iroot); + + readonly attribute string root_attr3; + + NameList get_all_roots(); + }; + + interface SubInterface : InterfaceRoot + { + attribute long sub_attr1; + + void set_sub(in string sub_name); + + NameList get_all_subs(); + + readonly attribute string sub_attr2; + }; +}; + +#endif diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/IFR_Inheritance_Test.mpc b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/IFR_Inheritance_Test.mpc new file mode 100644 index 00000000000..858b1fdd3ee --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/IFR_Inheritance_Test.mpc @@ -0,0 +1,11 @@ +// -*- MPC -*- +// $Id$ + +project: taoexe, ifr_client, portableserver { + exename = IFR_Inheritance_Test + + IDL_Files { + // exclude this file + !IFR_Inheritance_Test.idl + } +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/Makefile.am b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/Makefile.am new file mode 100644 index 00000000000..65568172685 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/Makefile.am @@ -0,0 +1,42 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_ROOT = $(top_srcdir) + +## Makefile.IFR_Inheritance_Test.am + +noinst_PROGRAMS = IFR_Inheritance_Test + +IFR_Inheritance_Test_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +IFR_Inheritance_Test_SOURCES = \ + main.cpp + +IFR_Inheritance_Test_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/README b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/README new file mode 100644 index 00000000000..5948342f0c9 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/README @@ -0,0 +1,75 @@ +$Id$ + +This is a simple test showing that Interface inheritance +is supported by the Interface Repository. + + --- The test should output: --- +operation InterfaceRoot::get_root +operation InterfaceRoot::get_all_roots +attribute InterfaceRoot::root_attr1 +attribute InterfaceRoot::root_attr2 +attribute InterfaceRoot::root_attr3 +operation SubInterface::get_root +operation SubInterface::get_all_roots +operation SubInterface::set_sub +operation SubInterface::get_all_subs +attribute SubInterface::root_attr1 +attribute SubInterface::root_attr2 +attribute SubInterface::root_attr3 +attribute SubInterface::sub_attr1 +attribute SubInterface::sub_attr2 + +Thanks to Bryan Cassell <BryanCassell@iti-team.com> for identifying +problem and providing non-automated test code. + + +To build this test, the TAO library, the TypeCodeFactory +library, the Interface Repository (the last two found in +TAO/orbsvcs/IFR_Service), and these test files must all be built. +In addition, the Interface Repository requires the TAO_Svc_Utils +library in TAO/orbsvcs/orbsvcs. + +To run this test, either use the Perl script run_test.pl, or + + + +(Windows) +start the Interface Repository by typing + + ..\..\..\IFR_Service\IFR_Service + +in one window, then (in another window) + +REM may need this to avoid error finding CL.EXE +"C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\vcvars32.bat" + +%ACE_ROOT%\bin\tao_ifr IFR_Inheritance_Test.idl -ORBInitRef InterfaceRepository=file://if_repo.ior + +and then + + IFR_Inheritance_Test -ORBInitRef InterfaceRepository=file://if_repo.ior + +(Unix) +in this directory, type + + ../../../IFR_Service/IFR_Service & + +then + +%TAO_ROOT%/orbsvcs/IFR_Service/tao_ifr IFR_Inheritance_Test.idl -ORBInitRef InterfaceRepository=file://if_repo.ior + +and then + ./IFR_Inheritance_Test -ORBInitRef InterfaceRepository=file://if_repo.ior + + + +You may use IP multicast discovery by starting the server with "-m 1" +and use the default multicast address for the InterfaceRepository. + + ../../../IFR_Service/IFR_Service -m 1 + +and + + ./IFR_Inheritance_Test + +- Scott Harris <harris_s@ociweb.com>
\ No newline at end of file diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/main.cpp b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/main.cpp new file mode 100644 index 00000000000..2b862e5fdb1 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/main.cpp @@ -0,0 +1,121 @@ +// -*- C++ -*- +// $Id$ + +// The run_test.pl perl script will check for the expected output. + +#include "tao/IFR_Client/IFR_BasicC.h" +#include "tao/ORB.h" + +ACE_RCSID (IFR_Inheritance_Test, + main, + "$Id$") + +void printContents( const CORBA::ContainedSeq& cont ) +{ + ACE_TRY_NEW_ENV + { + for( unsigned int i=0; i<cont.length(); i++ ) + { + if( cont[i]->describe()->kind == CORBA::dk_Interface ) + { + CORBA::InterfaceDef_var intDef = + CORBA::InterfaceDef::_narrow (cont[i] + ACE_ENV_ARG_PARAMETER ); + ACE_TRY_CHECK; + + CORBA::InterfaceDef::FullInterfaceDescription* desc = + intDef->describe_interface (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + //printf( "-- %s:\n", (const char*)(desc->name) ); + + for( unsigned int j1=0; j1 < desc->operations.length (); j1++ ) + printf( "operation %s::%s\n", + (const char*)(desc->name), + (const char*)((desc->operations[j1]).name) ); + + for( unsigned int j2=0; j2 < desc->attributes.length (); j2++ ) + printf( "attribute %s::%s\n", + (const char*)(desc->name), + (const char*)((desc->attributes[j2]).name) ); + } + else if( cont[i]->describe ()->kind == CORBA::dk_Module ) + { + CORBA::ModuleDef_var moduleDef = + CORBA::ModuleDef::_narrow (cont[i] + ACE_ENV_ARG_PARAMETER ); + ACE_TRY_CHECK; + + CORBA::ContainedSeq_var moduleContents = + moduleDef->contents (CORBA::dk_all,1 + ACE_ENV_ARG_PARAMETER ); + ACE_TRY_CHECK; + printContents (moduleContents.in ()); + } + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "printContents"); + ACE_OS::exit(-1); // the test has failed! + } + ACE_ENDTRY; +} + + +int main(int argc, char** argv) +{ + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + CORBA::Object_var object = + orb->resolve_initial_references ("InterfaceRepository" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (object.in ())) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "Null objref from resolve_initial_references\n" + ), + -1 + ); + } + + CORBA::Repository_var ifr = + CORBA::Repository::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (ifr.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "CORBA::Repository::_narrow failed\n"), + -1); + } + + CORBA::ContainedSeq_var cont = ifr->contents (CORBA::dk_all, 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + printContents (cont.in ()); + + orb->shutdown (); + + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "main"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/run_test.pl b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/run_test.pl new file mode 100755 index 00000000000..cdbe13a4a8f --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Inheritance_Test/run_test.pl @@ -0,0 +1,156 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../../bin"; +use PerlACE::Run_Test; +use strict; + +my %isa = (); +$isa{"InterfaceRoot::get_root"} = "operation"; +$isa{"InterfaceRoot::get_all_roots"} = "operation"; +$isa{"InterfaceRoot::root_attr1"} = "attribute"; +$isa{"InterfaceRoot::root_attr2"} = "attribute"; +$isa{"InterfaceRoot::root_attr3"} = "attribute"; +$isa{"SubInterface::get_root"} = "operation"; +$isa{"SubInterface::get_all_roots"} = "operation"; +$isa{"SubInterface::set_sub"} = "operation"; +$isa{"SubInterface::get_all_subs"} = "operation"; +$isa{"SubInterface::root_attr1"} = "attribute"; +$isa{"SubInterface::root_attr2"} = "attribute"; +$isa{"SubInterface::root_attr3"} = "attribute"; +$isa{"SubInterface::sub_attr1"} = "attribute"; +$isa{"SubInterface::sub_attr2"} = "attribute"; + +my %got = (); +$got{"InterfaceRoot::get_root"} = 13; +$got{"InterfaceRoot::get_all_roots"} = 13; +$got{"InterfaceRoot::root_attr1"} = 13; +$got{"InterfaceRoot::root_attr2"} = 13; +$got{"InterfaceRoot::root_attr3"} = 13; +$got{"SubInterface::get_root"} = 13; +$got{"SubInterface::get_all_roots"} = 13; +$got{"SubInterface::set_sub"} = 13; +$got{"SubInterface::get_all_subs"} = 13; +$got{"SubInterface::root_attr1"} = 13; +$got{"SubInterface::root_attr2"} = 13; +$got{"SubInterface::root_attr3"} = 13; +$got{"SubInterface::sub_attr1"} = 13; +$got{"SubInterface::sub_attr2"} = 13; + +my $iorfile = "if_repo.ior"; + +my $testoutputfilename = "IFR_Inheritance_test.output"; + +unlink $testoutputfilename; + +my $status = 0; + +unlink $iorfile; + +my $SV = new PerlACE::Process ("../../../IFR_Service/IFR_Service", " -o $iorfile" ); + +my $CL = new PerlACE::Process ("IFR_Inheritance_Test", + " -ORBInitRef InterfaceRepository=file://$iorfile"); + +# The location of the tao_idl utility - depends on O/S +my $tao_ifr = "undefined"; +if ($^O eq "MSWin32") +{ + $tao_ifr = "../../../../../bin/tao_ifr"; +} +else +{ + $tao_ifr = "../../../IFR_Service/tao_ifr"; +} + +# Compile the IDL +# +my $TAO_IFR = new PerlACE::Process("$tao_ifr", + "IFR_Inheritance_Test.idl" + . " -ORBInitRef InterfaceRepository=file://$iorfile"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); + exit 1; +} + +if( $TAO_IFR->SpawnWaitKill(10) != 0 ) +{ + print STDERR "ERROR: can't compile IDL\n"; + $TAO_IFR->Kill (); + $status = 1; + exit $status; +} + +# Redirect STDERR to a log file so that +# we can make sure that we got a warning +open(SAVE, ">&STDOUT"); +open(STDOUT, ">$testoutputfilename"); + +my $client = $CL->SpawnWaitKill (60); + +# Close the log file and restore STDERR +close(STDOUT); +open(STDOUT, ">&SAVE"); + + +my $type = ""; +my $name = ""; +open(THELOG, "< $testoutputfilename") or die "could not open the saved log"; +while (<THELOG>) { + if (/^attribute/ || "^operation") { + chomp($_); + ($type, $name) = split(/ /, $_); + #print "found $type $name\n"; + if ($isa{$name} eq $type) { + #print "got $name\n"; + $got{$name} = 1; + } + else { + print STDERR "ERROR: $type $name was not expected\n"; + $status = 1; + } + } + else { + print STDOUT "ERROR: unexpected line: $_\n"; + } +} +close(THELOG); + +### did we get all of the expected attributes and operations? +my $key = ""; +foreach $key (keys (%got)) { + #print "got\{$key\} = $got{$key}\n"; + if (! exists $isa{$key} ) { + print STDERR "CONFIG ERROR: \$got has $key but \$isa does not\n"; + $status = 1; + } + if ($got{$key} == 13) { + print STDERR "ERROR: $isa{$key} $key was not found\n"; + $status = 1; + } +} + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +my $server = $SV->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Admin_Client.cpp b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Admin_Client.cpp new file mode 100644 index 00000000000..ef26b0b054d --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Admin_Client.cpp @@ -0,0 +1,3577 @@ +// -*- C++ -*- +// $Id$ + +#include "Admin_Client.h" + +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/CDR.h" + +#include "ace/Get_Opt.h" +#include "ace/SString.h" + +ACE_RCSID (IFR_Test, + Admin_Client, + "$Id$") + +Admin_Client::Admin_Client (void) + : debug_ (0), + all_tests_ (1), + which_test_ (0), + iterations_ (1) +{ + // Initialize the array of pointers to member functions. + this->test_array_[0] = &Admin_Client::array_test; + this->test_array_[1] = &Admin_Client::enum_test; + this->test_array_[2] = &Admin_Client::alias_test; + this->test_array_[3] = &Admin_Client::native_test; + this->test_array_[4] = &Admin_Client::struct_test; + this->test_array_[5] = &Admin_Client::union_test; + this->test_array_[6] = &Admin_Client::exception_test; + this->test_array_[7] = &Admin_Client::constant_test; + this->test_array_[8] = &Admin_Client::interface_test; + this->test_array_[9] = &Admin_Client::move_test; + this->test_array_[10] = &Admin_Client::module_test; +} + +Admin_Client::~Admin_Client (void) +{ +} + +// An array of test names, so we can step through them when +// trying to find a match for a test selected on the command line. +const char *Admin_Client::test_names_[] = +{ + "array", + "enum", + "alias", + "native", + "struct", + "union", + "exception", + "constant", + "interface", + "move", + "module" +}; + +int +Admin_Client::init (int argc, + char *argv[]) +{ + ACE_TRY_NEW_ENV + { + this->orb_ = CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + int retval = this->parse_args (argc, + argv); + + if (retval != 0) + return retval; + + CORBA::Object_var object = + this->orb_->resolve_initial_references ("InterfaceRepository" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (object.in ())) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "Null objref from resolve_initial_references\n" + ), + -1 + ); + } + + this->repo_ = + CORBA::Repository::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (this->repo_.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "CORBA::Repository::_narrow failed\n"), + -1); + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Admin_Client::init"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + +int +Admin_Client::run (void) +{ + ACE_TRY_NEW_ENV + { + if (this->all_tests_ == 1) + { + for (CORBA::ULong i = 0; i < NUMBER_OF_TESTS; ++i) + { + // Each test is run twice to make sure everything + // gets destroyed properly. If not, we get a + // CORBA::BAD_PARAM exception the second time. + for (CORBA::ULong j = 0; j < this->iterations_; ++j) + { + (this->*test_array_[i])(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + } + else + { + for (CORBA::ULong j = 0; j < this->iterations_; ++j) + { + (this->*test_array_[this->which_test_])( + ACE_ENV_SINGLE_ARG_PARAMETER + ); + ACE_TRY_CHECK; + } + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Admin_Client::run"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + +int +Admin_Client::parse_args (int argc, + char *argv[]) +{ + ACE_Get_Opt opts (argc, argv, "di:t:"); + int c; + int result = 0; + CORBA::ULong i = 0; + char *name = 0; + + while ((c = opts ()) != -1) + switch (c) + { + case 'd': // debug flag + this->debug_ = 1; + break; + case 'i': // iterations + result = ACE_OS::atoi (opts.opt_arg ()); + if (result > 0) + this->iterations_ = result; + break; + case 't': // test selection + this->all_tests_ = 0; + name = opts.opt_arg (); + + for (i = 0; i < NUMBER_OF_TESTS; ++i) + { + if (ACE_OS::strcmp (name, this->test_names_[i]) == 0) + { + this->which_test_ = i; + break; + } + } + + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-i iterations]" + " [-t test name]" + "\n", + argv [0]), + -1); + } + + return 0; +} + +void +Admin_Client::array_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== ARRAY TEST ==============\n\n") + )); + } + + CORBA::IDLType_var atype = + this->repo_->create_string (7 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ArrayDef_var avar = + this->repo_->create_array (5, + atype.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong bound = avar->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ArrayDef::length: %d\n"), + bound)); + } + + ACE_ASSERT (bound == 5); + + CORBA::TypeCode_var tc = avar->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TCKind kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ArrayDef::type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_array); + + tc = avar->element_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ArrayDef::element_type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_string); + + CORBA::IDLType_var tdef = + avar->element_type_def (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + CORBA::DefinitionKind dk = tdef->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("ArrayDef::element_type_def::def_kind: %d\n"), + dk + )); + } + + ACE_ASSERT (dk == CORBA::dk_String); + + CORBA::StringDef_var pvar = + CORBA::StringDef::_narrow (tdef.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + bound = pvar->bound (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StringDef::bound: %d\n"), + bound)); + } + + ACE_ASSERT (bound == 7); + + CORBA::PrimitiveDef_var pdef = + this->repo_->get_primitive (CORBA::pk_short + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + avar->element_type_def (pdef.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ArrayDef::element_type_def (set)\n"))); + } + + tc = avar->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ArrayDef::type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_array); + + tdef = avar->element_type_def (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + dk = tdef->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ArrayDef::element_type_def::def_kind: %d\n"), + dk)); + } + + ACE_ASSERT (dk == CORBA::dk_Primitive); + + CORBA::PrimitiveDef_var zvar = + CORBA::PrimitiveDef::_narrow (tdef.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + CORBA::PrimitiveKind pkind = zvar->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("PrimitiveDef::kind: %d\n"), + pkind)); + } + + ACE_ASSERT (pkind == CORBA::pk_short); + + avar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::enum_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== ENUM TEST ==============\n\n") + )); + } + + CORBA::EnumMemberSeq members (4); + members.length (3); + + members[0] = CORBA::string_dup ("ZERO"); + members[1] = CORBA::string_dup ("ONE"); + members[2] = CORBA::string_dup ("TWO"); + + CORBA::EnumDef_var evar = + this->repo_->create_enum ("IDL:my_enum:1.0", + "my_enum", + "1.0", + members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::String_var str = evar->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::id: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "IDL:my_enum:1.0") == 0); + + str = evar->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "my_enum") == 0); + + str = evar->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::absolute_name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_enum") == 0); + + str = evar->version (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::version: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "1.0") == 0); + + CORBA::DefinitionKind dkind = + evar->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::def_kind: %d\n\n"), + dkind)); + } + + ACE_ASSERT (dkind == CORBA::dk_Enum); + + CORBA::Contained::Description_var desc = + evar->describe (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + dkind = desc->kind; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::kind: %d\n"), + dkind)); + } + + ACE_ASSERT (dkind == CORBA::dk_Enum); + + CORBA::TypeDescription *td; + desc->value >>= td; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::name: %s\n"), + td->name.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->name, "my_enum") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::id: %s\n"), + td->id.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->id, "IDL:my_enum:1.0") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::defined_in: %s\n"), + td->defined_in.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->defined_in, "") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::version: %s\n"), + td->version.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->version, "1.0") == 0); + + CORBA::TCKind kind = td->type->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_enum); + + str = td->type->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::type::id: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "IDL:my_enum:1.0") == 0); + + str = td->type->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::type::name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "my_enum") == 0); + + CORBA::ULong count = + td->type->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::type::member_count: %d\n\n"), + count + )); + } + + ACE_ASSERT (count == 3); + + CORBA::ULong i = 0; + + for (i = 0; i < count; ++i) + { + str = td->type->member_name (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::describe::value::type::") + ACE_TEXT ("member_name[%d]: %s\n"), + i, + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), members[i]) == 0); + } + + + members.length (4); + members[0] = CORBA::string_dup ("NOTHINGNESS"); + members[1] = CORBA::string_dup ("UNITY"); + members[2] = CORBA::string_dup ("DUALITY"); + members[3] = CORBA::string_dup ("TRINITY"); + + evar->members (members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nEnumDef::members (set)\n\n"))); + } + + CORBA::EnumMemberSeq_var fellows = + evar->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + count = fellows->length (); + const char *tmp = 0; + + for (i = 0; i < count; ++i) + { + tmp = fellows[i]; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::") + ACE_TEXT ("members[%d]: %s\n"), + i, + tmp)); + } + + ACE_ASSERT (ACE_OS::strcmp (fellows[i], members[i]) == 0); + } + + evar->name ("another_enum" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + str = evar->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nEnumDef::name (set)\n"))); + } + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "another_enum") == 0); + + str = evar->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("EnumDef::absolute_name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::another_enum") == 0); + + evar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::alias_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== ALIAS TEST ==============\n\n") + )); + } + + // This test also tests WstringDef and SequenceDef. + + CORBA::IDLType_var sq_elem = + this->repo_->create_wstring (7 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::SequenceDef_var sq_var = + this->repo_->create_sequence (5, + sq_elem.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::AliasDef_var a_var = + this->repo_->create_alias ("IDL:my_alias:1.0", + "my_alias", + "1.0", + sq_var.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::String_var str = a_var->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::id: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "IDL:my_alias:1.0") == 0); + + str = a_var->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "my_alias") == 0); + + str = a_var->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::absolute_name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_alias") == 0); + + str = a_var->version (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::version: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "1.0") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::version (set)\n"))); + } + + a_var->version ("1.1" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = a_var->version (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::version: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "1.1") == 0); + + CORBA::TypeCode_var tc = a_var->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + str = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nAliasDef::type::name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "my_alias") == 0); + + CORBA::TCKind kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_alias); + + CORBA::TypeCode_var ct = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + kind = ct->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::type::content_type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_sequence); + + CORBA::ULong length = ct->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::type::content_type::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 5); + + CORBA::TypeCode_var ct2 = + ct->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + kind = ct2->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::type::content_type::") + ACE_TEXT ("content_type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_wstring); + + length = ct2->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::type::content_type::") + ACE_TEXT ("content_type::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 7); + + CORBA::Contained::Description_var desc = + a_var->describe (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TypeDescription *td; + desc->value >>= td; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nAliasDef::describe::value::name: %s\n"), + td->name.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->name, "my_alias") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::describe::value::version: %s\n"), + td->version.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->version, "1.1") == 0); + + kind = td->type->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::describe::value::type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_alias); + + str = td->type->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::describe::value::type::id: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "IDL:my_alias:1.0") == 0); + + str = td->type->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::describe::value::type::name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "my_alias") == 0); + + CORBA::IDLType_var i_var = + a_var->original_type_def (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::SequenceDef_var seq_var = + CORBA::SequenceDef::_narrow (i_var.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = seq_var->bound (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AliasDef::original_type_def::bound: %d\n"), + length)); + } + + ACE_ASSERT (length == 5); + + a_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::native_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== NATIVE TEST ==============\n\n") + )); + } + + CORBA::NativeDef_var nvar = + this->repo_->create_native ("IDL:my_native:1.0", + "my_native", + "1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::String_var str = nvar->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("NativeDef::id: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "IDL:my_native:1.0") == 0); + + str = nvar->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("NativeDef::name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "my_native") == 0); + + str = nvar->version (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("NativeDef::version: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "1.0") == 0); + + str = nvar->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("NativeDef::absolute_name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_native") == 0); + + CORBA::DefinitionKind kind = + nvar->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("NativeDef::def_kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::dk_Native); + + nvar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::struct_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== STRUCT TEST ==============\n\n") + )); + } + + CORBA::StructMemberSeq members (3); + members.length (3); + + members[0].name = CORBA::string_dup ("ub_string"); + members[0].type_def = this->repo_->get_primitive (CORBA::pk_string + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[0].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + + members[1].name = CORBA::string_dup ("bd_string"); + members[1].type_def = this->repo_->create_string (5 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[1].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + + CORBA::EnumMemberSeq e_members (2); + e_members.length (2); + + e_members[0] = CORBA::string_dup ("ZERO"); + e_members[1] = CORBA::string_dup ("ONE"); + + members[2].name = CORBA::string_dup ("my_struct_enum"); + + CORBA::EnumDef_var e_var = + this->repo_->create_enum ("IDL:my_enum:1.0", + "my_enum", + "1.0", + e_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[2].type_def = CORBA::EnumDef::_duplicate (e_var.in ()); + members[2].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + + CORBA::StructDef_var svar = + this->repo_->create_struct ("IDL:my_struct:1.0", + "my_struct", + "1.0", + members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // This also tests the members() function. + CORBA::TypeCode_var tc = svar->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong length = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::type::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 3); + + CORBA::String_var str; + CORBA::ULong i = 0; + + for (i = 0; i < length; ++i) + { + str = tc->member_name (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::type::member_name[%d]: %s\n"), + i, + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), members[i].name) == 0); + } + + CORBA::Contained::Description_var desc = + svar->describe (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TypeDescription *td; + desc->value >>= td; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nStructDef::describe::value::name: %s\n"), + td->name.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->name, "my_struct") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::describe::value::id: %s\n"), + td->id.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->id, "IDL:my_struct:1.0") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::describe::value::version: %s\n"), + td->version.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->version, "1.0") == 0); + + members.length (2); + members[0].name = CORBA::string_dup ("long_mem"); + members[0].type_def = this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[0].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + + members[1].name = CORBA::string_dup ("array_mem"); + members[1].type_def = + this->repo_->create_array (5, + members[0].type_def.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[1].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + + svar->members (members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nStructDef::members (set)\n\n"))); + } + + CORBA::EnumMemberSeq def_members (2); + def_members.length (2); + + def_members[0] = CORBA::string_dup ("FIRST"); + def_members[1] = CORBA::string_dup ("SECOND"); + + CORBA::EnumDef_var e_def_var = svar->create_enum ("IDL:my_def_enum:1.0", + "my_enum", + "1.0", + def_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::StructMemberSeq_var out_members = + svar->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + length = out_members->length (); + int cmp_result = 0; + + for (i = 0; i < length; ++i) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::members[%d]::name: %s\n"), + i, + out_members[i].name.in ())); + } + + if (i == length - 1) + { + cmp_result = + ACE_OS::strcmp (out_members[i].name, "my_enum"); + ACE_ASSERT (cmp_result == 0); + } + else + { + cmp_result = + ACE_OS::strcmp (out_members[i].name, members[i].name); + ACE_ASSERT (cmp_result == 0); + } + } + + CORBA::Contained_var fox = this->repo_->lookup ("::my_struct::my_enum" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = fox->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::lookup::absolute_name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_struct::my_enum") == 0); + + fox = svar->lookup ("my_enum" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = fox->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::lookup::absolute_name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_struct::my_enum") == 0); + + CORBA::Container_var outer = fox->defined_in (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + CORBA::Contained_var schizo = + CORBA::Contained::_narrow (outer.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = schizo->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::lookup::defined_in::") + ACE_TEXT ("absolute_name: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_struct") == 0); + + CORBA::ContainedSeq_var contents = + this->repo_->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nRepository::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + contents = svar->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + for (i = 0; i < length; ++i) + { + str = contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("StructDef::contents[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + if (i == 0) + { + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_struct::my_enum") == 0); + } + else + { + // No more found in lookup. + } + } + + contents = this->repo_->lookup_name ("my_enum", + -1, + CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nRepository::lookup_name::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + for (i = 0; i < length; ++i) + { + str = contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("Repository::lookup_name[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + // Can't use ACE_ASSERT here because we don't know the order + // of the results of the search. + } + + CORBA::Container::DescriptionSeq_var cont_desc = + this->repo_->describe_contents (CORBA::dk_all, + 0, + -1 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = cont_desc->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nRepository::describe_contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + for (i = 0; i < length; ++i) + { + CORBA::TypeDescription *td; + cont_desc[i].value >>= td; + + str = td->type->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("Repository::describe_contents[%d]::id: %s\n"), + i, + str.in () + )); + } + + if (i == 0) + { + ACE_ASSERT (ACE_OS::strcmp (str.in (), "IDL:my_enum:1.0") == 0); + } + else if (i == 1) + { + ACE_ASSERT (ACE_OS::strcmp (str.in (), "IDL:my_struct:1.0") == 0); + } + } + + svar->name ("your_struct" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nStructDef::name (set)\n"))); + } + + contents = svar->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + const char *tmp = "::your_struct"; + + for (i = 0; i < length; ++i) + { + str = contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("StructDef::contents[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + // Whatever the scoped name now is, it must begin + // with "::your_struct". + cmp_result = + ACE_OS::strncmp (str.in (), tmp, ACE_OS::strlen (tmp)); + ACE_ASSERT (cmp_result == 0); + } + +#if defined (ACE_NDEBUG) + // ACE_ASSERT macro expands to nothing, so... + ACE_UNUSED_ARG (tmp); +#endif /* ACE_NDEBUG */ + + e_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + svar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::union_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== UNION TEST ==============\n\n") + )); + } + + CORBA::EnumMemberSeq d_members (4); + d_members.length (4); + + d_members[0] = CORBA::string_dup ("ZERO"); + d_members[1] = CORBA::string_dup ("ONE"); + d_members[2] = CORBA::string_dup ("TWO"); + d_members[3] = CORBA::string_dup ("THREE"); + + CORBA::EnumDef_var d_var = + this->repo_->create_enum ("IDL:disc_enum:1.0", + "disc_enum", + "1.0", + d_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::StructMemberSeq s_members (1); + s_members.length (1); + s_members[0].name = CORBA::string_dup ("string_in_struct"); + s_members[0].type_def = + this->repo_->create_string (6 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + s_members[0].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + + CORBA::StructDef_var s_var = + this->repo_->create_struct ("IDL:struct_in_union:1.0", + "struct_in_union", + "1.0", + s_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::UnionMemberSeq u_members (4); + u_members.length (4); + + u_members[0].name = CORBA::string_dup ("longval"); + u_members[0].type_def = + this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + u_members[0].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + CORBA::TypeCode_var d_type = d_var->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + TAO_OutputCDR maker2; + maker2.write_ulong (3); // THREE + TAO_InputCDR maker2_in (maker2); + TAO::Unknown_IDL_Type *impl2 = 0; + ACE_NEW (impl2, + TAO::Unknown_IDL_Type (d_type.in (), + maker2_in)); + CORBA::Any any2; + any2.replace (impl2); + u_members[0].label = any2; + + u_members[1].name = CORBA::string_dup ("longval"); + u_members[1].type_def = + this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + u_members[1].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + TAO_OutputCDR maker0; + maker0.write_ulong (2); // TWO + TAO_InputCDR maker0_in (maker0); + TAO::Unknown_IDL_Type *impl0 = 0; + ACE_NEW (impl0, + TAO::Unknown_IDL_Type (d_type.in (), + maker0_in)); + CORBA::Any any0; + any0.replace (impl0); + u_members[1].label = any0; + + u_members[2].name = CORBA::string_dup ("structval"); + u_members[2].type_def = CORBA::StructDef::_duplicate (s_var.in ()); + u_members[2].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + + TAO_OutputCDR maker1; + maker1.write_ulong (0); // ZERO + TAO_InputCDR maker1_in (maker1); + TAO::Unknown_IDL_Type *impl1 = 0; + ACE_NEW (impl1, + TAO::Unknown_IDL_Type (d_type.in (), + maker1_in)); + CORBA::Any any1; + any1.replace (impl1); + u_members[2].label = any1; + + u_members[3].name = CORBA::string_dup ("stringval"); + u_members[3].type_def = + this->repo_->create_string (17 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + u_members[3].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + u_members[3].label <<= CORBA::Any::from_octet (0); // default case (ONE) + + CORBA::UnionDef_var u_var = + this->repo_->create_union ("IDL:my_union:1.0", + "my_union", + "1.0", + d_var.in (), + u_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TypeCode_var disc_tc = + u_var->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong length = + disc_tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("UnionDef::discriminator_type::member_count: %d\n"), + length + )); + } + + ACE_ASSERT (length == 4); + + CORBA::TypeCode_var tc = u_var->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + length = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::type::member_count: %d\n"), + length)); + } + + ACE_ASSERT (length == 3); + + CORBA::Long slot = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::type::default_index: %d\n\n"), + slot)); + } + + ACE_ASSERT (slot == 2); + + CORBA::String_var str; + const char *tmp = 0; + + for (CORBA::ULong i = 0; i < length; ++i) + { + str = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::type::member_name[%d]: %s\n"), + i, + str.in ())); + } + + // Multiple labels for first member shifts index by 1. + ACE_ASSERT (ACE_OS::strcmp (str.in (), u_members[i + 1].name) == 0); + + CORBA::Any_var label = tc->member_label (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + TAO_InputCDR cdr (static_cast<ACE_Message_Block *> (0)); + CORBA::ULong val; + + TAO::Any_Impl *impl = label->impl (); + TAO_OutputCDR out; + impl->marshal_value (out); + TAO_InputCDR in (out); + + // If we're at the default index, it's in the label as octet 0, + // so just assign the slot value to val. + if (i != (CORBA::ULong) slot) + { + in.read_ulong (val); + tmp = d_members[val]; + } + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::type::member_label[%d]: %s\n"), + i, + i == (CORBA::ULong) slot ? "default" : tmp)); + } + + // Labels are not in order. + switch (i) + { + case 0: + ACE_ASSERT (val == 3 || val == 2); + break; + case 1: + ACE_ASSERT (val == 0); + break; + default: + break; + } + } + + u_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + s_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + d_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::exception_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== EXCEPTION TEST ==============\n\n") + )); + } + + CORBA::StructMemberSeq members (3); + members.length (3); + + members[0].name = CORBA::string_dup ("ub_string"); + members[0].type_def = this->repo_->get_primitive (CORBA::pk_string + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[0].type = + members[0].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + members[1].name = CORBA::string_dup ("bd_string"); + members[1].type_def = this->repo_->create_string (5 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[1].type = members[1].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::EnumMemberSeq e_members (2); + e_members.length (2); + + e_members[0] = CORBA::string_dup ("ZERO"); + e_members[1] = CORBA::string_dup ("ONE"); + + members[2].name = CORBA::string_dup ("my_exception_enum"); + CORBA::EnumDef_var e_var = + this->repo_->create_enum ("IDL:my_enum:1.0", + "my_enum", + "1.0", + e_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + members[2].type_def = CORBA::EnumDef::_duplicate (e_var.in ()); + + members[2].type = + members[2].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ExceptionDef_var exvar = + this->repo_->create_exception ("IDL:my_exception:1.0", + "my_exception", + "1.0", + members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TypeCode_var tc = exvar->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong length = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::type::member_count: %d\n"), + length)); + } + + ACE_ASSERT (length == 3); + + CORBA::String_var str; + CORBA::ULong i = 0; + + for (i = 0; i < length; ++i) + { + str = tc->member_name (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::type::member_name[%d]: %s\n"), + i, + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), members[i].name) == 0); + } + + CORBA::Contained::Description_var desc = + exvar->describe (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ExceptionDescription *ed; + desc->value >>= ed; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nExceptionDef::describe::value::name: %s\n"), + ed->name.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (ed->name, "my_exception") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::describe::value::id: %s\n"), + ed->id.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (ed->id, "IDL:my_exception:1.0") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::describe::value::defined_in: %s\n"), + ed->defined_in.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (ed->defined_in, "") == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::describe::value::version: %s\n"), + ed->version.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (ed->version, "1.0") == 0); + + members.length (2); + members[0].name = CORBA::string_dup ("long_mem"); + members[0].type_def = this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[0].type = + members[0].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + members[1].name = CORBA::string_dup ("array_mem"); + CORBA::ArrayDef_ptr a_ptr = + this->repo_->create_array (5, + members[0].type_def.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[1].type_def = a_ptr; + members[1].type = + members[1].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + exvar->members (members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nExceptionDef::members (set)\n\n"))); + } + + CORBA::EnumMemberSeq def_members (2); + def_members.length (2); + + def_members[0] = CORBA::string_dup ("FIRST"); + def_members[1] = CORBA::string_dup ("SECOND"); + + CORBA::EnumDef_var e_def_var = exvar->create_enum ("IDL:my_def_enum:1.0", + "my_enum", + "1.0", + def_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::StructMemberSeq_var out_members = + exvar->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + length = out_members->length (); + int cmp_result = 0; + + for (i = 0; i < length; ++i) + { + if (this->debug_) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::members[%d]::name: %s\n"), + i, + out_members[i].name.in ())); + + if (i == 2) + { + cmp_result = + ACE_OS::strcmp (out_members[i].name, "my_enum"); + ACE_ASSERT (cmp_result == 0); + } + else + { + cmp_result = + ACE_OS::strcmp (out_members[i].name, members[i].name); + ACE_ASSERT (cmp_result == 0); + } + } + + a_ptr->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nArrayDef::destroy\n\n"))); + } + + out_members = exvar->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + length = out_members->length (); + + for (i = 0; i < length; ++i) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::members[%d]::name: %s\n"), + i, + out_members[i].name.in ())); + } + + if (i == 1) + { + cmp_result = + ACE_OS::strcmp (out_members[i].name, "my_enum"); + ACE_ASSERT (cmp_result == 0); + } + else + { + cmp_result = + ACE_OS::strcmp (out_members[i].name, members[i].name); + ACE_ASSERT (cmp_result == 0); + } + } + + CORBA::Contained_var fox = this->repo_->lookup ("::my_exception::my_enum" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = fox->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nRepository::lookup: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_exception::my_enum") == 0); + + fox = exvar->lookup ("my_enum" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = fox->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::lookup: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_exception::my_enum") == 0); + + CORBA::ContainedSeq_var contents = + this->repo_->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nRepository::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + contents = exvar->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ExceptionDef::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + for (i = 0; i < length; ++i) + { + str = contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("ExceptionDef::contents[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + // Should be only the one member. + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::my_exception::my_enum") == 0); + } + + contents = this->repo_->lookup_name ("my_enum", + -1, + CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nRepository::lookup_name::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + for (i = 0; i < length; ++i) + { + str = contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("Repository::lookup_name%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + // Can't use ACE_ASSERT here - order of search results is unknown. + } + + CORBA::Container::DescriptionSeq_var cont_desc = + this->repo_->describe_contents (CORBA::dk_all, + 0, + -1 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = cont_desc->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nRepository::describe_contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + CORBA::TypeDescription *td; + + for (i = 0; i < length; ++i) + { + CORBA::DefinitionKind kind = cont_desc[i].kind; + + if (kind == CORBA::dk_Exception) + { + cont_desc[i].value >>= ed; + CORBA::TypeCode_ptr tc = ed->type.in (); + + length = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::describe_contents[%d]") + ACE_TEXT ("::value::type::member_count: %d\n"), + i, + length)); + } + + ACE_ASSERT (length == 2); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::describe_contents[%d]") + ACE_TEXT ("::value::name: %s\n"), + i, + ed->name.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (ed->name, "my_exception") == 0); + } + else + { + cont_desc[i].value >>= td; + CORBA::TypeCode_ptr tc = td->type.in (); + + length = tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::describe_contents[%d]") + ACE_TEXT ("::value::type::member_count: %d\n"), + i, + length)); + } + + ACE_ASSERT (length == 2); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::describe_contents[%d]") + ACE_TEXT ("::value::name: %s\n"), + i, + td->name.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (td->name, "my_enum") == 0); + } + } + + exvar->name ("your_exception" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nExceptionDef::name (set)\n\n"))); + } + + contents = exvar->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + const char *tmp = "::your_exception"; + + for (i = 0; i < length; ++i) + { + str = contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("ExceptionDef::contents[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + ACE_ASSERT (ACE_OS::strncmp (str.in (), tmp, ACE_OS::strlen (tmp)) == 0); + } + +#if defined (ACE_NDEBUG) + // ACE_ASSERT macro expands to nothing, so... + ACE_UNUSED_ARG (tmp); +#endif /* ACE_NDEBUG */ + + e_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + exvar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::constant_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== CONSTANT TEST ==============\n\n") + )); + } + + CORBA::IDLType_var ivar = + this->repo_->get_primitive (CORBA::pk_string + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Any any; + const char *s = "hello"; + any <<= s; + + CORBA::ConstantDef_var cvar = + this->repo_->create_constant ("IDL:my_constant:1.0", + "my_constant", + "1.0", + ivar.in (), + any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::TypeCode_var tc = cvar->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + CORBA::TCKind kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ConstantDef::type::kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_string); + + CORBA::IDLType_var tdef = + cvar->type_def (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + CORBA::DefinitionKind def_kind = + tdef->def_kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ConstantDef::type_def::def_kind: %d\n"), + def_kind)); + } + + ACE_ASSERT (def_kind == CORBA::dk_Primitive); + + CORBA::Any_var out_any; + out_any = cvar->value (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + const char *out_s; + out_any >>= out_s; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ConstantDef::value (string): %s\n"), + out_s)); + } + + ACE_ASSERT (ACE_OS::strcmp (out_s, s) == 0); + + ivar = this->repo_->get_primitive (CORBA::pk_double + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + cvar->type_def (ivar.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Double double_val = -1223.42256; + any <<= double_val; + cvar->value (any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nConstantDef::type_def (set)\n") + ACE_TEXT ("ConstantDef::value (set)\n"))); + } + + out_any = cvar->value (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Double out_double_val; + out_any >>= out_double_val; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ConstantDef::value (double): %.5f\n"), + out_double_val)); + } + + ACE_ASSERT (out_double_val == double_val); + + ivar = this->repo_->get_primitive (CORBA::pk_short + ACE_ENV_ARG_PARAMETER); + cvar->type_def (ivar.in () + ACE_ENV_ARG_PARAMETER); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nConstantDef::type_def (set)\n") + ACE_TEXT ("ConstantDef::value (set)\n"))); + } + + CORBA::Short short_val = -65; + any <<= short_val; + + cvar->value (any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + out_any = cvar->value (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Short out_short_val; + out_any >>= out_short_val; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ConstantDef::value (short): %hd\n"), + out_short_val)); + } + + ACE_ASSERT (out_short_val == short_val); + + ivar = this->repo_->get_primitive (CORBA::pk_float + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + cvar->type_def (ivar.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nConstantDef::type_def (set)\n") + ACE_TEXT ("ConstantDef::value (set)\n"))); + } + + CORBA::Float float_val = 2.33f; + any <<= float_val; + + cvar->value (any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + out_any = cvar->value (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Float out_float_val; + out_any >>= out_float_val; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ConstantDef::value (float): %.2f\n"), + out_float_val)); + } + + ACE_ASSERT (out_float_val == float_val); + + ivar = this->repo_->get_primitive (CORBA::pk_ulonglong + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + cvar->type_def (ivar.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nConstantDef::type_def (set)\n") + ACE_TEXT ("ConstantDef::value (set)\n"))); + } + + CORBA::ULongLong ull_val = 1234567890; + any <<= ull_val; + + cvar->value (any + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + out_any = cvar->value (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULongLong out_ull_val; + out_any >>= out_ull_val; + + if (this->debug_) + { +#if defined (ACE_LACKS_LONGLONG_T) + char buffer[32]; + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ConstantDef::value (ulonglong): %s\n"), + out_ull_val.as_string (buffer))); +#else + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ConstantDef::value (ulonglong): %Q\n"), + out_ull_val)); +#endif + } + ACE_ASSERT (out_ull_val == ull_val); + + cvar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::interface_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== INTERFACE TEST ==============\n\n") + )); + } + + CORBA::ULong i, length; + + CORBA::InterfaceDefSeq in_bases (1); + in_bases.length (0); + + CORBA::InterfaceDef_var gp_ivar = + this->repo_->create_interface ("IDL:gp_iface:1.0", + "gp_iface", + "1.0", + in_bases + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::PrimitiveDef_var p_long = + this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::AttributeDef_var gp_attr = + gp_ivar->create_attribute ("IDL:gp_iface/gp_attr:1.0", + "gp_attr", + "1.0", + p_long.in (), + CORBA::ATTR_NORMAL + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + in_bases.length (1); + in_bases[0] = CORBA::InterfaceDef::_duplicate (gp_ivar.in ()); + + CORBA::InterfaceDef_var p_ivar = + this->repo_->create_interface ("IDL:p_iface:1.0", + "p_iface", + "1.0", + in_bases + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::StringDef_var p_string = + this->repo_->create_string (5 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::AttributeDef_var p_attr = + p_ivar->create_attribute ("IDL:p_iface/p_attr:1.0", + "p_attr", + "1.0", + p_string.in (), + CORBA::ATTR_READONLY + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + const char *names[] = {"inarg", "inoutarg", "outarg"}; + + const CORBA::ParameterMode modes[] = + {CORBA::PARAM_IN, CORBA::PARAM_INOUT, CORBA::PARAM_OUT}; + + const char *contexts[] = {"straw", "sticks", "bricks"}; + + length = 3; + CORBA::ParDescriptionSeq par_seq (3); + par_seq.length (3); + + CORBA::StructMemberSeq members (0); + members.length (0); + + CORBA::ExceptionDef_var ex_var = + this->repo_->create_exception ("IDL:if_exception:1.0", + "if_exception", + "1.0", + members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ExceptionDefSeq get_seq (1); + get_seq.length (1); + get_seq[0] = CORBA::ExceptionDef::_duplicate (ex_var.in ()); + + CORBA::ContextIdSeq con_seq (3); + con_seq.length (3); + + for (i = 0; i < length; ++i) + { + par_seq[i].name = names[i]; + par_seq[i].type_def = CORBA::PrimitiveDef::_duplicate (p_long.in ()); + par_seq[i].type = p_long->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + par_seq[i].mode = modes[i]; + con_seq[i] = contexts[i]; + } + + CORBA::OperationDef_var p_op = + p_ivar->create_operation ("IDL:p_iface/p_op:1.0", + "p_op", + "1.0", + p_long.in (), + CORBA::OP_NORMAL, + par_seq, + get_seq, + con_seq + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Contained::Description_var desc = + p_op->describe (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::OperationDescription *od; + desc->value >>= od; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("OperationDef::describe::value::") + ACE_TEXT ("defined_in: %s\n"), + od->defined_in.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (od->defined_in, "IDL:p_iface:1.0") == 0); + + CORBA::TypeCode_var result = od->result; + CORBA::TCKind kind = result->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("OperationDef::describe::result::") + ACE_TEXT ("kind: %d\n"), + kind)); + } + + ACE_ASSERT (kind == CORBA::tk_long); + + length = od->parameters.length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nOperationDef::describe::parameters::") + ACE_TEXT ("length: %d\n"), + length)); + } + + ACE_ASSERT (length == 3); + + const char *tmp = 0; + + for (i = 0; i < length; ++i) + { + tmp = od->parameters[i].name; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("OperationDef::describe::parameters[%d]::") + ACE_TEXT ("name: %s\n"), + i, + tmp)); + } + + ACE_ASSERT (ACE_OS::strcmp (tmp, names[i]) == 0); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("OperationDef::describe::parameters[%d]::") + ACE_TEXT ("mode: %d\n"), + i, + od->parameters[i].mode)); + } + + ACE_ASSERT (od->parameters[i].mode == modes[i]); + } + + CORBA::Boolean is_it = p_ivar->is_a ("IDL:p_iface:1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::is_a (same class): %hd\n"), + is_it)); + } + + ACE_ASSERT (is_it == 1); + + is_it = p_ivar->is_a ("IDL:gp_iface:1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("InterfaceDef::is_a (base class): %hd\n"), + is_it)); + } + + ACE_ASSERT (is_it == 1); + + is_it = gp_ivar->is_a ("IDL:p_iface:1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("InterfaceDef::is_a (derived class): %hd\n"), + is_it)); + } + + ACE_ASSERT (is_it == 0); + + CORBA::InterfaceDef::FullInterfaceDescription_var fifd = + p_ivar->describe_interface (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::String_var str = fifd->type->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::describe_interface::") + ACE_TEXT ("type::id: %s\n"), + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "IDL:p_iface:1.0") == 0); + + length = fifd->operations.length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::describe_interface::") + ACE_TEXT ("operations::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + length = fifd->operations[0].contexts.length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::describe_interface::") + ACE_TEXT ("operations[3]::contexts::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 3); + + for (i = 0; i < length; ++i) + { + tmp = fifd->operations[0].contexts[i]; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("InterfaceDef::describe_interface::") + ACE_TEXT ("operations[0]::contexts[%d]: %s\n"), + i, + tmp)); + } + + ACE_ASSERT (ACE_OS::strcmp (tmp, contexts[i]) == 0); + } + + length = fifd->operations[0].exceptions.length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::describe_interface::") + ACE_TEXT ("operations[0]::exceptions::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + for (i = 0; i < length; ++i) + { + const char *tmp = fifd->operations[0].exceptions[i].name; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("InterfaceDef::describe::operations[3]::") + ACE_TEXT ("contexts[%d]: %s\n"), + i, + tmp)); + } + + ACE_ASSERT (ACE_OS::strcmp (tmp, "if_exception") == 0); + } + + tmp = fifd->attributes[0].defined_in; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::describe_interface::") + ACE_TEXT ("attributes::defined_in: %s\n"), + tmp)); + } + + ACE_ASSERT (ACE_OS::strcmp (tmp, "IDL:gp_iface:1.0") == 0); + + in_bases[0] = CORBA::InterfaceDef::_duplicate (p_ivar.in ()); + + CORBA::InterfaceDef_var ivar = + this->repo_->create_interface ("IDL:iface:1.0", + "iface", + "1.0", + in_bases + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + desc = ivar->describe (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::InterfaceDescription *ifd; + desc->value >>= ifd; + + length = ifd->base_interfaces.length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::describe::") + ACE_TEXT ("base_interfaces::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + const char *base_iface_id = 0; + + for (i = 0; i < length; ++i) + { + base_iface_id = ifd->base_interfaces[i]; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("InterfaceDef::describe::") + ACE_TEXT ("base_interfaces[%d]: %s\n"), + i, + base_iface_id)); + } + } + + CORBA::InterfaceDefSeq_var out_bases = + ivar->base_interfaces (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + length = out_bases->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::base_interfaces::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + for (i = 0; i < length; ++i) + { + str = out_bases[i]->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("InterfaceDef::base_interfaces[%d]::name: %s\n"), + i, + str.in () + )); + } + } + + CORBA::ContainedSeq_var contents = ivar->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 3); + + for (i = 0; i < length; ++i) + { + str = contents[i]->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("InterfaceDef::contents[%d]::name: %s\n"), + i, + str.in ())); + } + + CORBA::Container_var cr = + contents[i]->defined_in (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Contained_var cd = + CORBA::Contained::_narrow (cr.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = cd->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("InterfaceDef::contents[%d]::") + ACE_TEXT ("defined_in::name: %s\n"), + i, + str.in ())); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "p_iface") == 0 + || ACE_OS::strcmp (str.in (), "gp_iface") == 0); + } + + ex_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + ivar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + gp_ivar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + p_ivar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::move_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== MOVE TEST ==============\n\n") + )); + } + + CORBA::EnumMemberSeq e_members (2); + e_members.length (2); + + e_members[0] = CORBA::string_dup ("ZERO"); + e_members[1] = CORBA::string_dup ("ONE"); + + CORBA::EnumDef_var e_var = + this->repo_->create_enum ("IDL:o_enum:1.0", + "o_enum", + "1.0", + e_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + e_members[0] = CORBA::string_dup ("TEN"); + e_members[1] = CORBA::string_dup ("ELEVEN"); + + CORBA::EnumDef_var e_var2 = + this->repo_->create_enum ("IDL:i_enum:1.0", + "i_enum", + "1.0", + e_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::StructMemberSeq s_members (2); + s_members.length (2); + + const char *s_names[] = {"s_string", "s_enum"}; + + s_members[0].name = s_names[0]; + s_members[0].type_def = + this->repo_->get_primitive (CORBA::pk_string + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + s_members[0].type = + s_members[0].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + s_members[1].name = s_names[1]; + s_members[1].type_def = CORBA::EnumDef::_duplicate (e_var2.in ()); + s_members[1].type = + s_members[1].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::StructDef_var s_var = + this->repo_->create_struct ("IDL:o_struct:1.0", + "o_struct", + "1.0", + s_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::UnionMemberSeq u_members (2); + u_members.length (2); + + const char *u_names[] = {"u_enum", "u_struct"}; + + u_members[0].name = u_names[0]; + u_members[0].type_def = CORBA::EnumDef::_duplicate (e_var.in ()); + u_members[0].type = e_var->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + CORBA::Long label = 0; + CORBA::Any any; + any <<= label; + u_members[0].label = any; + + u_members[1].name = u_names[1]; + u_members[1].type_def = CORBA::StructDef::_duplicate (s_var.in ()); + u_members[1].type = s_var->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + label = 1; + any <<= label; + u_members[1].label = any; + + CORBA::PrimitiveDef_var d_var = + this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::UnionDef_var u_var = + this->repo_->create_union ("IDL:the_union:1.0", + "the_union", + "1.0", + d_var.in (), + u_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::UnionMemberSeq_var out_u_members = + u_var->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong length = out_u_members->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::members::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + CORBA::ULong i = 0; + const char *tmp = 0; + + for (i = 0; i < length; ++i) + { + tmp = out_u_members[i].name; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::members[%d]::name: %s\n"), + i, + tmp)); + } + + ACE_ASSERT (ACE_OS::strcmp (tmp, u_members[i].name) == 0); + } + + CORBA::ContainedSeq_var out_contents = + u_var->contents (CORBA::dk_all, + 1 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = out_contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nUnionDef::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 0); + + e_var->move (u_var.in (), + u_names[0], + "1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nEnumDef::move (into union)\n"))); + } + + out_u_members = u_var->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + length = out_u_members->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nUnionDef::members::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + for (i = 0; i < length; ++i) + { + tmp = out_u_members[i].name; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::members[%d]::name: %s\n"), + i, + tmp)); + } + + if (i == 0) + { + ACE_ASSERT (ACE_OS::strcmp (tmp, "u_enum") == 0); + } + else + { + ACE_ASSERT (ACE_OS::strcmp (tmp, u_members[i].name) == 0); + } + } + + out_contents = u_var->contents (CORBA::dk_all, + 1 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = out_contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nUnionDef::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + CORBA::String_var str; + + for (i = 0; i < length; ++i) + { + str = out_contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("UnionDef::contents[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + if (i == 0) + { + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::the_union::u_enum") == 0); + } + } + + e_var2->move (s_var.in (), + s_names[1], + "1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + s_var->move (u_var.in (), + u_names[1], + "1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nEnumDef::move (into struct)\n") + ACE_TEXT ("StructDef::move (into union)\n"))); + } + + out_contents = this->repo_->contents (CORBA::dk_all, + 1 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = out_contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nRepository::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + out_u_members = u_var->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + length = out_u_members->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nUnionDef::members::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + for (i = 0; i < length; ++i) + { + tmp = out_u_members[i].name; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::members[%d]::name: %s\n"), + i, + tmp)); + } + + ACE_ASSERT (ACE_OS::strcmp (tmp, u_names[i]) == 0); + } + + out_contents = u_var->contents (CORBA::dk_all, + 1 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = out_contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nUnionDef::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + ACE_CString scoped ("::the_union::"); + CORBA::StructDef_var s_tmp; + int cmp_result = 0; + + for (i = 0; i < length; ++i) + { + str = out_contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("UnionDef::contents[%d]::absolute_name: %s\n"), + i, + str.in ())); + } + + cmp_result = + ACE_OS::strcmp (str.in (), (scoped + u_names[i]).c_str ()); + + ACE_ASSERT (cmp_result == 0); + + if (i == 1) + { + s_tmp = CORBA::StructDef::_narrow (out_contents[i] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + } + + out_contents = s_tmp->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = out_contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nStructDef::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + const char *base = "::the_union::u_struct"; + + for (i = 0; i < length; ++i) + { + str = out_contents[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::contents[%d]::absolute_name: %s\n"), + i, + str.in ())); + } + + cmp_result = + ACE_OS::strncmp (str.in (), base, ACE_OS::strlen (base)); + + ACE_ASSERT (cmp_result == 0); + } + +#if defined (ACE_NDEBUG) + // ACE_ASSERT macro expands to nothing, so... + ACE_UNUSED_ARG (base); +#endif /* ACE_NDEBUG */ + + CORBA::StructMemberSeq_var out_s_members = + s_tmp->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + length = out_s_members->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nStructDef::members::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 2); + + for (i = 0; i < length; ++i) + { + tmp = out_s_members[i].name; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::members[%d]::name: %s\n"), + i, + tmp)); + } + + ACE_ASSERT (ACE_OS::strcmp (tmp, s_names[i]) == 0); + } + + u_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +Admin_Client::module_test (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== MODULE TEST ==============\n\n") + )); + } + + CORBA::ModuleDef_var outer = + this->repo_->create_module ("IDL:outer:1.0", + "outer", + "1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ModuleDef_var middle = + outer->create_module ("IDL:outer/middle:1.0", + "middle", + "1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ModuleDef_var inner = + middle->create_module ("IDL:outer/middle/inner:1.0", + "inner", + "1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::InterfaceDefSeq in_bases (1); + in_bases.length (0); + + CORBA::InterfaceDef_var p_iface = + outer->create_interface ("IDL:p_iface:1.0", + "p_iface", + "1.0", + in_bases + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + in_bases.length (1); + in_bases[0] = CORBA::InterfaceDef::_duplicate (p_iface.in ()); + + CORBA::InterfaceDef_var iface = + inner->create_interface ("IDL:iface:1.0", + "iface", + "1.0", + in_bases + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::PrimitiveDef_var p_void = + this->repo_->get_primitive (CORBA::pk_void + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + CORBA::PrimitiveDef_var p_long = + this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::AttributeDef_var attr = + p_iface->create_attribute ("IDL:iface/attr:1.0", + "attr", + "1.0", + p_void.in (), + CORBA::ATTR_NORMAL + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong length = 3; + CORBA::ULong i = 0; + + CORBA::ParDescriptionSeq par_seq (length); + par_seq.length (length); + + CORBA::ContextIdSeq con_seq (length); + con_seq.length (length); + + const char *p_names[] = {"inarg", "outarg", "inoutarg"}; + const char *contexts[] = {"straw", "sticks", "bricks"}; + + for (i = 0; i < length; ++i) + { + par_seq[i].name = p_names[i]; + par_seq[i].type_def = CORBA::PrimitiveDef::_duplicate (p_long.in ()); + par_seq[i].type = p_long->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + par_seq[i].mode = static_cast<CORBA::ParameterMode> (i); + + con_seq[i] = contexts[i]; + } + + CORBA::StructMemberSeq members (0); + members.length (0); + + CORBA::ExceptionDef_var ex_var = + this->repo_->create_exception ("IDL:if_exception:1.0", + "if_exception", + "1.0", + members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ExceptionDefSeq get_seq (1); + get_seq.length (1); + get_seq[0] = CORBA::ExceptionDef::_duplicate (ex_var.in ()); + + CORBA::OperationDef_var op = + iface->create_operation ("IDL:iface/op:1.0", + "op", + "1.0", + p_void.in (), + CORBA::OP_NORMAL, + par_seq, + get_seq, + con_seq + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::String_var str; + + CORBA::Contained_var result = + inner->lookup ("::outer::middle::inner::iface::op" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = result->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("ModuleDef::lookup (absolute)::absolute_name: %s\n"), + str.in () + )); + } + + int cmp_result = + ACE_OS::strcmp (str.in (), "::outer::middle::inner::iface::op"); + + ACE_ASSERT (cmp_result == 0); + + result = middle->lookup ("inner::iface::op" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + str = result->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("ModuleDef::lookup (relative)::absolute_name: %s\n"), + str.in () + )); + } + + cmp_result = + ACE_OS::strcmp (str.in (), "::outer::middle::inner::iface::op"); + + ACE_ASSERT (cmp_result == 0); + + CORBA::ContainedSeq_var cseq = + this->repo_->lookup_name ("op", + -1, + CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = cseq->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::lookup_name::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + for (i = 0; i < length; ++i) + { + str = cseq[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("Repository::lookup_name[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + cmp_result = + ACE_OS::strcmp (str.in (), "::outer::middle::inner::iface::op"); + + ACE_ASSERT (cmp_result == 0); + } + + cseq = middle->lookup_name ("attr", + 3, + CORBA::dk_Attribute, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = cseq->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::lookup_name::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + for (i = 0; i < length; ++i) + { + str = cseq[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("Repository::lookup_name[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::outer::p_iface::attr") == 0); + } + + iface->move (outer.in (), + "iface", + "1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nInterfaceDef::move (into outer module)\n"))); + } + + cseq = this->repo_->lookup_name ("op", + -1, + CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + length = cseq->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::lookup_name::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + for (i = 0; i < length; ++i) + { + str = cseq[i]->absolute_name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("Repository::lookup_name[%d]::absolute_name: %s\n"), + i, + str.in () + )); + } + + ACE_ASSERT (ACE_OS::strcmp (str.in (), "::outer::iface::op") == 0); + } + + ex_var->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + outer->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Admin_Client.h b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Admin_Client.h new file mode 100644 index 00000000000..2c478800c52 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Admin_Client.h @@ -0,0 +1,95 @@ +// -*- C++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/orbsvcs/tests/InterfaceRepo +// +// = FILENAME +// Admin_Client.h +// +// = DESCRIPTION +// This class tests the functionality of the IFR methods by inserting +// IR objects into the repository by hand, querying them, moving them, +// and destroying them. +// +// = AUTHOR +// Jeff Parsons <parsons@cs.wustl.edu> +// +// ============================================================================ + +#if !defined (ADMIN_CLIENT_H) +#define ADMIN_CLIENT_H + +#include "tao/IFR_Client/IFR_BasicC.h" +#include "tao/ORB.h" + +const CORBA::ULong NUMBER_OF_TESTS = 11; + +class Admin_Client +{ + // = TITLE + // Administrating IFR Client Implementation + // + // = DESCRIPTION + // Class wrapper for a client which puts the Interface Repository + // methods through their paces. +public: + Admin_Client (void); + // Constructor + + ~Admin_Client (void); + // Destructor + + int init (int argc, + char *argv[]); + // Initialize the ORB and get the IFR object reference. + + int run (void); + // Execute test code. + +private: + void array_test (ACE_ENV_SINGLE_ARG_DECL); + void enum_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void alias_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void native_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void struct_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void union_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void exception_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void constant_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void interface_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void move_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void module_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + // The various IFR tests. + + int parse_args (int argc, + char *argv[]); + // Process the command line arguments. + + void (Admin_Client::*test_array_[NUMBER_OF_TESTS])(ACE_ENV_SINGLE_ARG_DECL_NOT_USED); + // Array of pointers to the test functions. + + static const char *test_names_[]; + // Array of test names used in selection of one test. + + CORBA::Boolean debug_; + // Flag to output results of IFR queries. + + CORBA::Boolean all_tests_; + // Are we running all the tests or just one? + + CORBA::ULong which_test_; + // Array index of the selected test function. + + CORBA::ULong iterations_; + // # of times to run each test. + + CORBA::ORB_var orb_; + // Storage of the ORB reference. + + CORBA::Repository_var repo_; + // Storage of the IFR reference. +}; + +#endif /* ADMIN_CLIENT_H */ diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/IFR_IFR_Test.mpc b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/IFR_IFR_Test.mpc new file mode 100644 index 00000000000..c351c9ef039 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/IFR_IFR_Test.mpc @@ -0,0 +1,6 @@ +// -*- MPC -*- +// $Id$ + +project: taoexe, ifr_client, minimum_corba { + exename = IFR_Test +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Makefile.am b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Makefile.am new file mode 100644 index 00000000000..7df8ba75c5c --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/Makefile.am @@ -0,0 +1,48 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_ROOT = $(top_srcdir) + + +## Makefile.IFR_IFR_Test.am + +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS = IFR_Test + +IFR_Test_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +IFR_Test_SOURCES = \ + Admin_Client.cpp \ + client.cpp \ + Admin_Client.h + +IFR_Test_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_MINIMUM_CORBA + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/README b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/README new file mode 100644 index 00000000000..45898fd7299 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/README @@ -0,0 +1,113 @@ +$Id$ + +Admin_Client is a class containing several functions which test +the methods in various IFR object classes. Since automatic +administration of the TAO Interface Repository has not yet been +implemented, each of these functions creates, queries, modifies, +moves, and finally destroys several IFR objects, none of which +are related to anything found in an actual IDL file. + +Not every type of IFR object is represented by an Admin_Client +function (the name of which gives a hint about what type of +IFR object it tests). There are two reasons for this - the +first being that there will almost certainly be more tests +added later, and the second being that many of the functions +test more than one IFR object type. For example, interface_test() +tests not only the functionality of InterfaceDef, but also that +of AttributeDef and OperationDef, since these IFR objects are +created only by an InterfaceDef. In a similar way, alias_test() +tests WstringDef and SequenceDef in addition to AliasDef, and +StringDef and PrimitiveDef members are created and tested in +struct_test(), union_test() and exception_test(). + +To build this test, the TAO library, the TypeCodeFactory +library, the Interface Repository (the last two found in +TAO/orbsvcs/IFR_Service), and these test files must all be built. +In addition, the Interface Repository requires the TAO_Svc_Utils +library in TAO/orbsvcs/orbsvcs. + +To run this test, either use the Perl script run_test.pl, or + + + +(Windows) +start the Interface Repository by typing + + ..\..\..\IFR_Service\IFR_Service + +in one window, then (in another window) + + IFR_Test -ORBInitRef InterfaceRepository=file://if_repo.ior + +(Unix) +in this directory, type + + ../../../IFR_Service/IFR_Service & + +then + + ./IFR_Test -ORBInitRef InterfaceRepository=file://if_repo.ior + + + +You may use IP multicast discovery by starting the server with "-m 1" +and use the default multicast address for the InterfaceRepository. + + ../../../IFR_Service/IFR_Service -m 1 + +and + + ./IFR_Test + +You may add any of the options below to the IFR_Test command line. Both the +Perl script and the test executable have the same command line options. +They are: + + -d Outputs the results of queries along with a string + explaining the sequence of calls and/or accesses + leading to each result. There is also informative + output when an IFR object is modified or moved. + Default output is the test name only. + + -t (followed by test name - see below). This will + execute only the selected test. Default is to + execute all test functions. + Test names: + array + enum + alias + native + struct + union + exception + constant + interface + move + module + + + -i (followed by number of iterations). This will + cause each test function (or the selected one) + to be executed <n> times. A useful selection + here is -i 2. At the end of each test function, + all IFR objects created in that function are + destroyed. If the destroy() function does not + work properly, then the second execution will + raise a BAD_PARAM exception when the test + attempts to create the undestroyed object. + +ACE_ASSERT is used to check each result, so an incorrect result +will cause test execution to halt immediately. If a test function +is halted for this or any other reason, it is likely that the +destroy() call(s) at the end of the function were not exectuted. +Before running the test again, the Interface Repository process +should be stopped and restarted to avoid a BAD_PARAM exception. + +The IFR server is started in this test with locking enabled. Even +though the test itself is single-threaded, using this option will +ensure that future modifications to IFR code don't cause deadlocks. + +More information about the Interface Repository can be found in +TAO/docs/releasenotes.index.html. + +-Jeff Parsons <parsons@cs.wustl.edu>
\ No newline at end of file diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/client.cpp b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/client.cpp new file mode 100644 index 00000000000..aa3af160455 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/client.cpp @@ -0,0 +1,23 @@ +// -*- C++ -*- +// $Id$ + +#include "Admin_Client.h" + +ACE_RCSID (IFR_Test, + client, + "$Id$") + +int main (int argc, char *argv[]) +{ + Admin_Client admin_client; + + int retval = admin_client.init (argc, + argv); + + if (retval == -1) + { + return 1; + } + + return admin_client.run (); +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/run_test.pl b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/run_test.pl new file mode 100755 index 00000000000..2c0c628e6ef --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/IFR_Test/run_test.pl @@ -0,0 +1,72 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../../bin"; +use PerlACE::Run_Test; + +$locking = ""; + +$iorfile = "if_repo.ior"; + +$status = 0; + +$nice = ""; +$debug = ""; +$test = ""; +$iterations = ""; +$other = ""; + +for ($i = 0; $i <= $#ARGV; $i++) { + if ($ARGV[$i] eq "-d") { + $debug = "-d"; + } + elsif ($ARGV[$i] eq "-t") { + $test = "-t ".$ARGV[$i + 1]; + $i++; + } + elsif ($ARGV[$i] eq "-i") { + $iterations = "-i ".$ARGV[$i + 1]; + $i++; + } + else { + $other .= $ARGV[$i]; + } +} + +unlink $iorfile; + +$SV = new PerlACE::Process ("../../../IFR_Service/IFR_Service", " $nice " . " -o $iorfile" . " $locking"); +$CL = new PerlACE::Process ("IFR_Test", + "-ORBInitRef InterfaceRepository=file://$iorfile" + . " $debug $test $iterations"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); + exit 1; +} + +$client = $CL->SpawnWaitKill (60); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Query_Client.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Query_Client.cpp new file mode 100644 index 00000000000..c29daa4ff2a --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Query_Client.cpp @@ -0,0 +1,257 @@ +// -*- C++ -*- +// $Id$ + +#include "Latency_Query_Client.h" +#include "ace/Get_Opt.h" +#include "ace/High_Res_Timer.h" +#include "ace/Stats.h" +#include "ace/Sample_History.h" + +ACE_RCSID (Latency_Test, + Latency_Query_Client, + "$Id$") + +const CORBA::ULong DEFAULT_NUMCALLS = 20000; + +Latency_Query_Client::Latency_Query_Client (void) + : debug_ (false), + do_dump_history_ (0), + iterations_ (DEFAULT_NUMCALLS) +{ +} + +Latency_Query_Client::~Latency_Query_Client (void) +{ +} + +int +Latency_Query_Client::init (int argc, + char *argv[]) +{ + ACE_TRY_NEW_ENV + { + this->orb_ = CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + int retval = this->parse_args (argc, + argv); + + if (retval != 0) + { + return retval; + } + + CORBA::Object_var object = + this->orb_->resolve_initial_references ("InterfaceRepository" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (object.in ())) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "Null objref from resolve_initial_references\n" + ), + -1 + ); + } + + this->repo_ = + CORBA::Repository::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (this->repo_.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "CORBA::Repository::_narrow failed\n"), + -1); + } + + retval = this->populate_ifr (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (retval != 0) + { + return retval; + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Latency_Query_Client::init:"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + +int +Latency_Query_Client::run (void) +{ +// CORBA::DefinitionKind dk; + CORBA::AttributeMode am; + + ACE_TRY_NEW_ENV + { + for (int j = 0; j < 100; ++j) + { + am = this->attr_->mode (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (am != CORBA::ATTR_NORMAL) + { + return -1; + } + } + + ACE_Sample_History history (this->iterations_); + ACE_hrtime_t test_start = ACE_OS::gethrtime (); + + for (CORBA::ULong i = 0; i < this->iterations_; ++i) + { + ACE_hrtime_t start = ACE_OS::gethrtime (); + + am = this->attr_->mode (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_hrtime_t now = ACE_OS::gethrtime (); + history.sample (now - start); + } + + ACE_hrtime_t test_end = ACE_OS::gethrtime (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + "test finished\n")); + ACE_DEBUG ((LM_DEBUG, + "High resolution timer calibration....")); + ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor (); + ACE_DEBUG ((LM_DEBUG, + "done\n")); + + if (this->do_dump_history_) + { + history.dump_samples ("HISTORY", gsf); + } + + ACE_Basic_Stats stats; + history.collect_basic_stats (stats); + stats.dump_results ("Total", gsf); + + ACE_Throughput_Stats::dump_throughput ("Total", + gsf, + test_end - test_start, + stats.samples_count ()); + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Latency_Query_Client::run:"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + +int +Latency_Query_Client::parse_args (int argc, + char *argv[]) +{ + ACE_Get_Opt opts (argc, argv, "dhi:"); + int c; + int result = 0; + + while ((c = opts ()) != -1) + { + switch (c) + { + case 'd': + this->debug_ = true; + break; + case 'h': + this->do_dump_history_ = true; + break; + case 'i': + result = ACE_OS::atoi (opts.opt_arg ()); + + if (result > 0) + { + this->iterations_ = result; + } + + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-i iterations]" + "\n", + argv [0]), + -1); + } + } + + return 0; +} + +int +Latency_Query_Client::populate_ifr (ACE_ENV_SINGLE_ARG_DECL) +{ + CORBA::Contained_var irobj = this->repo_->lookup_id ("IDL:dummy/attr:1.0" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (! CORBA::is_nil (irobj.in ())) + { + this->attr_ = CORBA::AttributeDef::_narrow (irobj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil (this->attr_.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Latency_Query_Client::populate_ifr - " + "AttributeDef::_narrow returned null\n"), + -1); + } + + return 0; + } + + CORBA::InterfaceDefSeq in_bases (0); + in_bases.length (0); + + CORBA::InterfaceDef_var iface = + this->repo_->create_interface ("IDL:dummy:1.0", + "dummy", + "1.0", + in_bases + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + CORBA::PrimitiveDef_var p_long = + this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + this->attr_ = + iface->create_attribute ("IDL:dummt/attr:1.0", + "attr", + "1.0", + p_long.in (), + CORBA::ATTR_NORMAL + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + return 0; +} + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Query_Client.h b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Query_Client.h new file mode 100644 index 00000000000..fa223454637 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Query_Client.h @@ -0,0 +1,77 @@ +// -*- C++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/orbsvcs/tests/InterfaceRepo +// +// = FILENAME +// Latency_Query_Client.h +// +// = DESCRIPTION +// This class tests the latency of queries made on the IFR. +// +// = AUTHOR +// Jeff Parsons <parsons@isis-server.isis.vanderbilt.edu> +// +// ============================================================================ + +#if !defined (LATENCY_QUERY_CLIENT_H) +#define LATENCY_QUERY_CLIENT_H + +#include "tao/IFR_Client/IFR_BasicC.h" +#include "tao/ORB.h" + +class Latency_Query_Client +{ + // = TITLE + // Querying IFR Client Implementation + // + // = DESCRIPTION + // Class wrapper for a client which queries the Interface Repository. +public: + Latency_Query_Client (void); + // Constructor + + ~Latency_Query_Client (void); + // Destructor + + int init (int argc, + char *argv[]); + // Initialize the ORB and get the IFR object reference. + + int run (void); + // Execute test code. +private: + int parse_args (int argc, + char *argv[]); + // Process the command line arguments. + + int populate_ifr (ACE_ENV_SINGLE_ARG_DECL); + // Put in something to query about. + +private: + bool debug_; + // Toggle debugging output. + + bool do_dump_history_; + // Toggle saving of dump history. + + CORBA::ULong iterations_; + // Number of queries in a run. + + CORBA::ORB_var orb_; + // Storage of the ORB reference. + + CORBA::Repository_var repo_; + // Storage of the IFR reference. + +// CORBA::AliasDef_var tdef_; + // Storage of the typedef definition that we will query. + + CORBA::AttributeDef_var attr_; + // Storage of the attribute definition we will query. +}; + +#endif /* LATENCY_QUERY_CLIENT_H */ diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Test.mpc b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Test.mpc new file mode 100644 index 00000000000..f2cf973217a --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Test.mpc @@ -0,0 +1,4 @@ +// $Id$ +project: ifr_client { + avoids += ace_for_tao +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Makefile.am b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Makefile.am new file mode 100644 index 00000000000..269964f7a1a --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Makefile.am @@ -0,0 +1,48 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_ROOT = $(top_srcdir) + + +## Makefile.Latency_Test.am + +if !BUILD_ACE_FOR_TAO + +noinst_PROGRAMS = client + +client_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +client_SOURCES = \ + Latency_Query_Client.cpp \ + client.cpp \ + Latency_Query_Client.h + +client_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_ACE_FOR_TAO + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/client.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/client.cpp new file mode 100644 index 00000000000..43c9155ebb1 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/client.cpp @@ -0,0 +1,26 @@ +// -*- C++ -*- +// $Id$ + +#include "Latency_Query_Client.h" + +ACE_RCSID (Latency__Test, + client, + "$Id$") + +int +main (int argc, char *argv[]) +{ + Latency_Query_Client client; + + int retval = client.init (argc, + argv); + + if (retval == -1) + { + return 1; + } + + retval = client.run (); + + return retval; +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/run_test.pl b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/run_test.pl new file mode 100755 index 00000000000..6a3b2359b5f --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/run_test.pl @@ -0,0 +1,69 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../../bin"; +use PerlACE::Run_Test; + +$iorfile = "if_repo.ior"; + +$status = 0; +$nice = "-ORBDottedDecimalAddresses 1"; +$debug = ""; +$history = ""; +$iterations = ""; +$other = ""; + +for ($i = 0; $i <= $#ARGV; $i++) { + if ($ARGV[$i] eq "-d") { + $debug = "-d"; + } + elsif ($ARGV[$i] eq "-h") { + $history = "-h "; + $i++; + } + elsif ($ARGV[$i] eq "-i") { + $iterations = "-i ".$ARGV[$i + 1]; + $i++; + } + else { + $other .= $ARGV[$i]; + } +} + +unlink $iorfile; + +$SV = new PerlACE::Process ("../../../IFR_Service/IFR_Service", " $nice" . " -o $iorfile"); +$CL = new PerlACE::Process ("client", + "-ORBInitRef InterfaceRepository=file://$iorfile" + . " $debug $history $iterations"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); + exit 1; +} + +$client = $CL->SpawnWaitKill (60); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Makefile.am b/TAO/orbsvcs/tests/InterfaceRepo/Makefile.am new file mode 100644 index 00000000000..8d7805a1da0 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Makefile.am @@ -0,0 +1,18 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +SUBDIRS = \ + Application_Test \ + IDL3_Test \ + IFR_Inheritance_Test \ + IFR_Test \ + Latency_Test \ + Persistence_Test + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/IFR_Persistence_Test.mpc b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/IFR_Persistence_Test.mpc new file mode 100644 index 00000000000..57112a88744 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/IFR_Persistence_Test.mpc @@ -0,0 +1,6 @@ +// -*- MPC -*- +// $Id$ + +project: taoexe, ifr_client, minimum_corba { + exename = Persistence_Test +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Makefile.am b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Makefile.am new file mode 100644 index 00000000000..9a124a27e7b --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Makefile.am @@ -0,0 +1,48 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_ROOT = $(top_srcdir) + + +## Makefile.IFR_Persistence_Test.am + +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS = Persistence_Test + +Persistence_Test_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +Persistence_Test_SOURCES = \ + Ptest.cpp \ + test.cpp \ + Ptest.h + +Persistence_Test_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_IFR_Client.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_MINIMUM_CORBA + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Ptest.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Ptest.cpp new file mode 100644 index 00000000000..10146a9a882 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Ptest.cpp @@ -0,0 +1,270 @@ +// -*- C++ -*- +// $Id$ + +#include "Ptest.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID(Persistence_Test, Ptest, "$Id$") + +Ptest::Ptest (void) + : debug_ (0), + query_ (0) +{ +} + +Ptest::~Ptest (void) +{ +} + +int +Ptest::init (int argc, + char *argv[]) +{ + ACE_TRY_NEW_ENV + { + this->orb_ = CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + int retval = this->parse_args (argc, + argv); + + if (retval != 0) + return retval; + + CORBA::Object_var object = + this->orb_->resolve_initial_references ("InterfaceRepository" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (object.in ())) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "Null objref from resolve_initial_references\n" + ), + -1 + ); + } + + this->repo_ = + CORBA::Repository::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (this->repo_.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "CORBA::Repository::_narrow failed\n"), + -1); + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Ptest::init"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + +int +Ptest::run (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + if (this->query_ == 1) + { + this->query (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + else + { + this->populate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Ptest::run"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + +int +Ptest::parse_args (int argc, + char *argv[]) +{ + ACE_Get_Opt opts (argc, argv, "dq"); + int c; + + while ((c = opts ()) != -1) + switch (c) + { + case 'd': // debug flag + this->debug_ = 1; + break; + case 'q': // query toggle + this->query_ = 1; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-q]" + "\n", + argv [0]), + -1); + } + + return 0; +} + +void +Ptest::populate (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== POPULATE ==============\n\n") + )); + } + + CORBA::StructMemberSeq members (2); + members.length (2); + members[0].name = CORBA::string_dup ("long_mem"); + members[0].type_def = this->repo_->get_primitive (CORBA::pk_long + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[0].type = members[0].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + members[1].name = CORBA::string_dup ("array_mem"); + members[1].type_def = this->repo_->create_array (5, + members[0].type_def.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + members[1].type = members[1].type_def->type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + + CORBA::StructDef_var svar = this->repo_->create_struct ("IDL:my_struct:1.0", + "my_struct", + "1.0", + members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::EnumMemberSeq def_members (2); + def_members.length (2); + + def_members[0] = CORBA::string_dup ("ZERO"); + def_members[1] = CORBA::string_dup ("ONE"); + + CORBA::EnumDef_var e_def_var = svar->create_enum ("IDL:my_def_enum:1.0", + "my_enum", + "1.0", + def_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +Ptest::query (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->debug_) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("\n============== QUERY ==============\n\n") + )); + } + + const char *members[] = + { + "long_mem", + "array_mem", + "my_enum" + }; + + CORBA::ContainedSeq_var contents = + this->repo_->contents (CORBA::dk_all, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::ULong length = contents->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Repository::contents::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 1); + + CORBA::ULong i = 0; + + CORBA::StructDef_var svar = + CORBA::StructDef::_narrow (contents[i] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_ASSERT (!CORBA::is_nil (svar.in ())); + + CORBA::StructMemberSeq_var out_members = + svar->members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + length = out_members->length (); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nStructDef::members::length: %d\n"), + length)); + } + + ACE_ASSERT (length == 3); + + for (i = 0; i < length; ++i) + { + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("StructDef::members[%d]::name: %s\n"), + i, + out_members[i].name.in ())); + } + + if (i == length - 1) + { + ACE_ASSERT (ACE_OS::strcmp (out_members[i].name, "my_enum") == 0); + } + else + { + ACE_ASSERT (ACE_OS::strcmp (out_members[i].name, members[i]) == 0); + } + } + +#if defined (ACE_NDEBUG) + // ACE_ASSERT macro expands to nothing, so... + ACE_UNUSED_ARG (members); +#endif /* ACE_NDEBUG */ + + svar->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Ptest.h b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Ptest.h new file mode 100644 index 00000000000..bec1b5d88c7 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/Ptest.h @@ -0,0 +1,74 @@ +// -*- C++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/orbsvcs/tests/InterfaceRepo +// +// = FILENAME +// Ptest.h +// +// = DESCRIPTION +// This code tests the persistence of the IFR by inserting +// IR objects into the repository with one function, and querying the +// repository with another, with a repository shutdown in between. +// +// = AUTHOR +// Jeff Parsons <parsons@cs.wustl.edu> +// +// ============================================================================ + +#if !defined (PTEST_H) +#define PTEST_H + +#include "tao/IFR_Client/IFR_BasicC.h" +#include "tao/ORB.h" + +class Ptest +{ + // = TITLE + // IFR Persistence test Implementation + // + // = DESCRIPTION + // Class wrapper for code which either populates or queries the + // Interface Repository. Designed to be used with a Perl script + // which can start and stop both this process and the repository + // process in the necessary order. +public: + Ptest (void); + // Constructor + + ~Ptest (void); + // Destructor + + int init (int argc, + char *argv[]); + // Initialize the ORB and get the IFR object reference. + + int run (void); + // Execute test code. + +private: + void populate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + void query (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); + // The two IFR tests. + + int parse_args (int argc, + char *argv[]); + // Process the command line arguments. + + CORBA::Boolean debug_; + // Flag to output results of IFR queries. + + CORBA::Boolean query_; + // Are we populating a new IFR or querying a persistent one? + + CORBA::ORB_var orb_; + // Storage of the ORB reference. + + CORBA::Repository_var repo_; + // Storage of the IFR reference. +}; + +#endif /* PTEST_H */ diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/README b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/README new file mode 100644 index 00000000000..7eae42fd67c --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/README @@ -0,0 +1,69 @@ +$Id$ + +This test addresses the functionality of persistence in the +Interface Repository. + +Ptest is a class wrapper for the test code. The class contains +two functions: populate() and query(). + +To build this test, the TAO library, the TypeCodeFactory +library, the Interface Repository (the last two found in +TAO/orbsvcs/IFR_Service), must be previously built. In addition, +the Interface Repository requires the TAO_Svc_Utils library in +TAO/orbsvcs/orbsvcs. + +It is far easier to run the test with the provided Perl script +run_test.pl, but to do it by hand, first start the IFR with +(Windows users remember to use backslashes instead): + +../../../IFR_Service/IFR_Service -p -m 1 + +Then execute the test code with + +Persistence_Test + +This will populate the IFR with a few IFR objects. +After the test finishes, stop the IFR. Then start it again +with the same command line option. Then run the +test code again with the query option: + +Persistence_Test -q + +You may also add the option -d to this second run of the test +code to see the results of the IFR queries (this option will +have the same effect if used with the Perl script). + +After the query run of the test code, before starting again, you must +delete the IFR backing store file ("ifr_default_backing_store"). If you +like you can use another persistence file by starting the IFR both times with +the command line option '-p <filename>'. Just as with the default backing +file, it must be deleted before starting the test over. + +The query run of the test code will also destroy all IFR objects that were +created - the repository will be left empty except for the primitive kinds +which are always there (and cannot be destroyed). + +If for some reason IP multicast is not available or enabled on your platform, +then add + + -ORBInitRef InterfaceRepository=file://if_repo.ior + +to the client's command line. If the IFR_Service has been started with the +command line option -o <filename> (see the README file in the IFR_Service +directory), then instead add + + -ORBInitRef InterfaceRepository=file://<filename> + +to the client's command line. + +ACE_ASSERT is used to check each result, so an incorrect result +will cause test execution to halt immediately. If a test function +is halted for this or any other reason, it is likely that the +destroy() call(s) at the end of the function were not exectuted. +Before running the test again, the Interface Repository process +should be stopped and restarted to avoid a BAD_PARAM exception. + +More information about the Interface Repository can be found in +TAO/docs/releasenotes.index.html. + +-Jeff Parsons <parsons@cs.wustl.edu>
\ No newline at end of file diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/run_test.pl b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/run_test.pl new file mode 100755 index 00000000000..8ded8407764 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/run_test.pl @@ -0,0 +1,95 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../../bin"; +use PerlACE::Run_Test; + +$persistent = "-p"; + +$status = 0; + +$iorfile = "if_repo.ior"; +$backing_file = PerlACE::LocalFile ("ifr_default_backing_store"); + +$init_ref = "-ORBInitRef InterfaceRepository=file://$iorfile"; + +$debug = ""; +$query_opt = "-q"; +$other = ""; + +for ($i = 0; $i <= $#ARGV; $i++) { + if ($ARGV[$i] eq "-d") { + $debug = "-d"; + } + else { + $other .= $ARGV[$i]; + } +} + +unlink $iorfile; +unlink $backing_file; + +$IFR = new PerlACE::Process ("../../../IFR_Service/IFR_Service", " -o $iorfile" . " $persistent"); +$T = new PerlACE::Process ("Persistence_Test"); + +$IFR->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $IFR->Kill (); + exit 1; +} + +$T->Arguments ($init_ref); + +$test = $T->SpawnWaitKill (60); + +if ($test != 0) { + print STDERR "ERROR: populate test returned $test\n"; + $status = 1; +} + +$server = $IFR->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: IFR returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +$IFR->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $IFR->Kill (); + exit 1; +} + +$T->Arguments ("$init_ref $debug $query_opt"); + + +$test = $T->SpawnWaitKill (60); + +if ($test != 0) { + print STDERR "ERROR: query test returned $test\n"; + $status = 1; +} + + +$server = $IFR->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: IFR returned $server\n"; + $status = 1; +} + +unlink $iorfile; +unlink $backing_file; + +exit $status; + diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/svc.conf b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/svc.conf new file mode 100644 index 00000000000..ea66c67064d --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/svc.conf @@ -0,0 +1,2 @@ +# $Id$ +static Resource_Factory "-ORBDropRepliesDuringShutdown 0" diff --git a/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/test.cpp b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/test.cpp new file mode 100644 index 00000000000..2155c1c4c36 --- /dev/null +++ b/TAO/orbsvcs/tests/InterfaceRepo/Persistence_Test/test.cpp @@ -0,0 +1,23 @@ +// -*- C++ -*- +// $Id$ + +#include "Ptest.h" + +ACE_RCSID (Persistence_Test, + test, + "$Id$") + +int main (int argc, char *argv[]) +{ + Ptest ptest; + + int retval = ptest.init (argc, + argv); + + if (retval == -1) + return 1; + + retval = ptest.run (); + + return retval; +} |