diff options
Diffstat (limited to 'TAO/orbsvcs/tests/ImplRepo/NameService')
5 files changed, 248 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/ImplRepo/NameService/ImplRepo_NameService.mpc b/TAO/orbsvcs/tests/ImplRepo/NameService/ImplRepo_NameService.mpc new file mode 100644 index 00000000000..fe939b060c5 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/NameService/ImplRepo_NameService.mpc @@ -0,0 +1,6 @@ +// -*- MPC -*- +// $Id$ + +project: namingexe, minimum_corba { +} + diff --git a/TAO/orbsvcs/tests/ImplRepo/NameService/Makefile.am b/TAO/orbsvcs/tests/ImplRepo/NameService/Makefile.am new file mode 100644 index 00000000000..038d3a8f254 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/NameService/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.ImplRepo_NameService.am + +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS = test + +test_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) \ + -I$(TAO_ROOT)/orbsvcs \ + -I$(TAO_BUILDDIR)/orbsvcs + +test_SOURCES = \ + test.cpp + +test_LDADD = \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.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/ImplRepo/NameService/README b/TAO/orbsvcs/tests/ImplRepo/NameService/README new file mode 100644 index 00000000000..b89a2d8e93d --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/NameService/README @@ -0,0 +1,3 @@ +================================================================================ +Soon there will be a test to show off how the Implementation Repository can +automatically activate the NameService and other common services. diff --git a/TAO/orbsvcs/tests/ImplRepo/NameService/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/NameService/run_test.pl new file mode 100755 index 00000000000..e8e91200bb0 --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/NameService/run_test.pl @@ -0,0 +1,139 @@ +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; + +################################################################################ +# Program locations + +$imr_ior = PerlACE::LocalFile ("imr.ior"); +$name_ior = PerlACE::LocalFile ("name.ior"); +$activator_ior = PerlACE::LocalFile("activator.ior"); + +$IMR = new PerlACE::Process ("../../../ImplRepo_Service/ImplRepo_Service"); +$ACTIVATOR = new PerlACE::Process("../../../ImplRepo_Service/ImR_Activator"); +$NS = new PerlACE::Process ("../../../Naming_Service/Naming_Service"); +$TAO_IMR = new PerlACE::Process ("../../../../../bin/tao_imr"); + +# We want the tao_imr 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_IMR->IgnoreExeSubDir (1); + +$TEST = new PerlACE::Process ("test"); + +$imr_init_ref = "-ORBInitRef ImplRepoService=file://$imr_ior"; + +################################################################################ + +$errors = 0; + +unlink $imr_ior; +unlink $name_ior; +unlink $activator_ior; + +################################################################################ +## Start the implementation Repository + +$IMR->Arguments ("-o $imr_ior -d 2"); +$IMR->Spawn (); + +if (PerlACE::waitforfile_timed ($imr_ior, 10) == -1) { + print STDERR "ERROR: waiting for $imr_ior\n"; + $IMR->Kill (); + exit 1; +} + +$ACTIVATOR->Arguments("-d 1 -o $activator_ior $imr_init_ref"); +$ACTIVATOR->Spawn(); + +if (PerlACE::waitforfile_timed ($activator_ior, 10) == -1) { + print STDERR "ERROR: waiting for $activator_ior\n"; + $IMR->Kill (); + $ACTIVATOR->Kill(); + exit 1; +} + +################################################################################ +## Register the NameService + +$TAO_IMR->Arguments("$imr_init_ref" + . " add NameService " + ." -c \"" . $NS->Executable () + ." $imr_init_ref" + ." -ORBUseIMR 1 .\""); + +$taoimr = $TAO_IMR->SpawnWaitKill (60); + +if ($taoimr != 0) { + print STDERR "ERROR: tao_imr (add) returned $taoimr\n"; + ++$errors; +} + +################################################################################ +## Create IOR for NameService + +$TAO_IMR->Arguments ("$imr_init_ref ior NameService -f $name_ior"); + + +$taoimr = $TAO_IMR->SpawnWaitKill (60); + +if ($taoimr != 0) { + print STDERR "ERROR: tao_imr (ior) returned $taoimr\n"; + ++$errors; +} + +################################################################################ +## Run the test + +$TEST->Arguments ("-ORBInitRef NameService=file://$name_ior"); + +$test = $TEST->SpawnWaitKill (60); + +if ($test != 0) { + print STDERR "ERROR: test returned $test\n"; + ++$errors; +} + + +################################################################################ +## Shutdown the NameService + +$TAO_IMR->Arguments ("-ORBInitRef ImplRepoService=file://$imr_ior shutdown " + . "NameService "); + +$taoimr = $TAO_IMR->SpawnWaitKill (60); + +if ($taoimr != 0) { + print STDERR "ERROR: tao_imr (shutdown) returned $taoimr\n"; + ++$errors; +} + +################################################################################ +## Kill the IMR + +$iserver = $ACTIVATOR->TerminateWaitKill (5); + +if ($iserver != 0) { + print STDERR "ERROR: ImR_Activator returned $iserver\n"; + ++$errors; +} + +$iserver = $IMR->TerminateWaitKill (5); + +if ($iserver != 0) { + print STDERR "ERROR: IMR returned $iserver\n"; + ++$errors; +} + +unlink $imr_ior; +unlink $name_ior; +unlink $activator_ior; + +exit $errors; diff --git a/TAO/orbsvcs/tests/ImplRepo/NameService/test.cpp b/TAO/orbsvcs/tests/ImplRepo/NameService/test.cpp new file mode 100644 index 00000000000..b885f1b28ed --- /dev/null +++ b/TAO/orbsvcs/tests/ImplRepo/NameService/test.cpp @@ -0,0 +1,52 @@ +// +// $Id$ +// + +#include "orbsvcs/CosNamingC.h" + +#include "ace/Log_Msg.h" + +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 ns_obj = + orb->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (ns_obj.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "Could not resolve Naming Service"), + 1); + + CosNaming::NamingContext_var inc = + CosNaming::NamingContext::_narrow (ns_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (inc.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "Could not resolve Naming Service"), + 1); + + CosNaming::Name name; + name.length (1); + name[0].id = CORBA::string_dup ("yourself"); + + inc->bind (name, ns_obj.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Test Successful\n")); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Test"); + return 1; + } + ACE_ENDTRY; + + return 0; +} |