summaryrefslogtreecommitdiff
path: root/TAO/tests/Connect_Strategy_Test
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:21 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:21 +0000
commit3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch)
tree197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/tests/Connect_Strategy_Test
parent6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff)
downloadATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz
Repo restructuring
Diffstat (limited to 'TAO/tests/Connect_Strategy_Test')
-rw-r--r--TAO/tests/Connect_Strategy_Test/.cvsignore2
-rw-r--r--TAO/tests/Connect_Strategy_Test/Connect_Strategy_Test.mpc18
-rw-r--r--TAO/tests/Connect_Strategy_Test/Hello.cpp26
-rw-r--r--TAO/tests/Connect_Strategy_Test/Hello.h33
-rw-r--r--TAO/tests/Connect_Strategy_Test/README19
-rw-r--r--TAO/tests/Connect_Strategy_Test/Test.idl20
-rw-r--r--TAO/tests/Connect_Strategy_Test/blocked.conf4
-rw-r--r--TAO/tests/Connect_Strategy_Test/blocked.conf.xml8
-rw-r--r--TAO/tests/Connect_Strategy_Test/client.cpp94
-rw-r--r--TAO/tests/Connect_Strategy_Test/reactor.conf4
-rw-r--r--TAO/tests/Connect_Strategy_Test/reactor.conf.xml8
-rwxr-xr-xTAO/tests/Connect_Strategy_Test/run_test.pl71
-rw-r--r--TAO/tests/Connect_Strategy_Test/server.cpp115
13 files changed, 422 insertions, 0 deletions
diff --git a/TAO/tests/Connect_Strategy_Test/.cvsignore b/TAO/tests/Connect_Strategy_Test/.cvsignore
new file mode 100644
index 00000000000..f2ad85300eb
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/.cvsignore
@@ -0,0 +1,2 @@
+client
+server
diff --git a/TAO/tests/Connect_Strategy_Test/Connect_Strategy_Test.mpc b/TAO/tests/Connect_Strategy_Test/Connect_Strategy_Test.mpc
new file mode 100644
index 00000000000..e64ad8d08a8
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/Connect_Strategy_Test.mpc
@@ -0,0 +1,18 @@
+// -*- MPC -*-
+// $Id$
+
+project(*Server): taoserver {
+ Source_Files {
+ Hello.cpp
+ server.cpp
+ }
+}
+
+project(*Client): taoclient, anytypecode {
+ after += *Server
+ Source_Files {
+ TestC.cpp
+ client.cpp
+ }
+}
+
diff --git a/TAO/tests/Connect_Strategy_Test/Hello.cpp b/TAO/tests/Connect_Strategy_Test/Hello.cpp
new file mode 100644
index 00000000000..ca23555f202
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/Hello.cpp
@@ -0,0 +1,26 @@
+//
+// $Id$
+//
+#include "Hello.h"
+
+ACE_RCSID(Connect_Strategy_Test,
+ Hello, "$Id$")
+
+Hello::Hello (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+char *
+Hello::get_string (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return CORBA::string_dup ("Hello there!");
+}
+
+void
+Hello::shutdown (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER);
+}
diff --git a/TAO/tests/Connect_Strategy_Test/Hello.h b/TAO/tests/Connect_Strategy_Test/Hello.h
new file mode 100644
index 00000000000..1a404058944
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/Hello.h
@@ -0,0 +1,33 @@
+//
+// $Id$
+//
+
+#ifndef HELLO_H
+#define HELLO_H
+#include /**/ "ace/pre.h"
+
+#include "TestS.h"
+
+/// Implement the Test::Hello interface
+class Hello
+ : public virtual POA_Test::Hello
+{
+public:
+ /// Constructor
+ Hello (CORBA::ORB_ptr orb);
+
+ // = The skeleton methods
+ virtual char * get_string (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+private:
+ /// Use an ORB reference to conver strings to objects and shutdown
+ /// the application.
+ CORBA::ORB_var orb_;
+};
+
+#include /**/ "ace/post.h"
+#endif /* HELLO_H */
diff --git a/TAO/tests/Connect_Strategy_Test/README b/TAO/tests/Connect_Strategy_Test/README
new file mode 100644
index 00000000000..06be22c2caa
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/README
@@ -0,0 +1,19 @@
+/**
+
+@page Connect_Strategy Test README File
+
+ The simplest possible test for connection strategies in TAO.
+This is a very simple test for the connection strategies, and it can
+be argued that it is in fact too simple to make any conclusions based
+on the results from this test.
+
+ Please refrain from "improving", extending or expanding this
+test, if you need to change
+
+ To run the test use the run_test.pl script:
+
+$ ./run_test.pl
+
+ the script returns 0 if the test was successful.
+
+*/
diff --git a/TAO/tests/Connect_Strategy_Test/Test.idl b/TAO/tests/Connect_Strategy_Test/Test.idl
new file mode 100644
index 00000000000..3c0976e106d
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/Test.idl
@@ -0,0 +1,20 @@
+//
+// $Id$
+//
+
+/// Put the interfaces in a module, to avoid global namespace pollution
+module Test
+{
+ /// A very simple interface
+ interface Hello
+ {
+ /// Return a simple string
+ string get_string ();
+
+ /// A method to shutdown the ORB
+ /**
+ * This method is used to simplify the test shutdown process
+ */
+ oneway void shutdown ();
+ };
+};
diff --git a/TAO/tests/Connect_Strategy_Test/blocked.conf b/TAO/tests/Connect_Strategy_Test/blocked.conf
new file mode 100644
index 00000000000..bb70bf3b8bb
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/blocked.conf
@@ -0,0 +1,4 @@
+#
+# $Id$
+#
+static Client_Strategy_Factory "-ORBConnectStrategy Blocked"
diff --git a/TAO/tests/Connect_Strategy_Test/blocked.conf.xml b/TAO/tests/Connect_Strategy_Test/blocked.conf.xml
new file mode 100644
index 00000000000..3171e986573
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/blocked.conf.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+<!-- Converted from ./tests/Connect_Strategy_Test/blocked.conf by svcconf-convert.pl -->
+<ACE_Svc_Conf>
+ <!-- -->
+ <!-- $Id$ -->
+ <!-- -->
+ <static id="Client_Strategy_Factory" params="-ORBConnectStrategy Blocked"/>
+</ACE_Svc_Conf>
diff --git a/TAO/tests/Connect_Strategy_Test/client.cpp b/TAO/tests/Connect_Strategy_Test/client.cpp
new file mode 100644
index 00000000000..07d0572d547
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/client.cpp
@@ -0,0 +1,94 @@
+// $Id$
+
+#include "TestC.h"
+#include "ace/Get_Opt.h"
+
+ACE_RCSID(Connect_Strategy_Test,
+ client,
+ "$Id$")
+
+const char *ior = "file://test.ior";
+int do_shutdown = 0;
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "k:x:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+ case 'x':
+ do_shutdown = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-k <ior> "
+ "-x <do_shutdown>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ 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;
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CORBA::Object_var tmp =
+ orb->string_to_object(ior ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ Test::Hello_var hello =
+ Test::Hello::_narrow(tmp.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (hello.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Nil Test::Hello reference <%s>\n",
+ ior),
+ 1);
+ }
+
+ CORBA::String_var the_string =
+ hello->get_string (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%s>\n",
+ the_string.in ()));
+
+ if (do_shutdown)
+ {
+ hello->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Exception caught:");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/tests/Connect_Strategy_Test/reactor.conf b/TAO/tests/Connect_Strategy_Test/reactor.conf
new file mode 100644
index 00000000000..75f11aa8a40
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/reactor.conf
@@ -0,0 +1,4 @@
+#
+# $Id$
+#
+static Client_Strategy_Factory "-ORBConnectStrategy Reactive"
diff --git a/TAO/tests/Connect_Strategy_Test/reactor.conf.xml b/TAO/tests/Connect_Strategy_Test/reactor.conf.xml
new file mode 100644
index 00000000000..1cb8ac86ea6
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/reactor.conf.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+<!-- Converted from ./tests/Connect_Strategy_Test/reactor.conf by svcconf-convert.pl -->
+<ACE_Svc_Conf>
+ <!-- -->
+ <!-- $Id$ -->
+ <!-- -->
+ <static id="Client_Strategy_Factory" params="-ORBConnectStrategy Reactive"/>
+</ACE_Svc_Conf>
diff --git a/TAO/tests/Connect_Strategy_Test/run_test.pl b/TAO/tests/Connect_Strategy_Test/run_test.pl
new file mode 100755
index 00000000000..c5797abb37e
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/run_test.pl
@@ -0,0 +1,71 @@
+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 = PerlACE::LocalFile ("server.ior");
+unlink $iorfile;
+$status = 0;
+
+if (PerlACE::is_vxworks_test()) {
+ $SV = new PerlACE::ProcessVX ("server", "-o server.ior");
+}
+else {
+ $SV = new PerlACE::Process ("server", "-o $iorfile");
+}
+$CL1 = new PerlACE::Process ("client", "-k file://$iorfile");
+$CL2 = new PerlACE::Process ("client", "-ORBSvcConf reactor$PerlACE::svcconf_ext -k file://$iorfile");
+$CL3 = new PerlACE::Process ("client", "-ORBSvcConf blocked$PerlACE::svcconf_ext -k file://$iorfile -x 1");
+
+
+$SV->Spawn ();
+
+if (PerlACE::waitforfile_timed ($iorfile,
+ $PerlACE::wait_interval_for_process_creation) == -1) {
+ print STDERR "ERROR: cannot find file <$iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+print STDERR "===== Base test, using LF \n";
+$client1 = $CL1->SpawnWaitKill (100);
+
+if ($client1 != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+
+print STDERR "=================================== \n";
+print STDERR "===== Test, using reactor to connect \n";
+$client2 = $CL2->SpawnWaitKill (100);
+
+if ($client2 != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+print STDERR "========================================= \n";
+print STDERR "===== Test, using blocked connect strategy\n";
+$client3 = $CL3->SpawnWaitKill (100);
+
+if ($client3 != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+$server = $SV->WaitKill (10);
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ $status = 1;
+}
+
+unlink $iorfile;
+
+exit $status;
diff --git a/TAO/tests/Connect_Strategy_Test/server.cpp b/TAO/tests/Connect_Strategy_Test/server.cpp
new file mode 100644
index 00000000000..acd62195b16
--- /dev/null
+++ b/TAO/tests/Connect_Strategy_Test/server.cpp
@@ -0,0 +1,115 @@
+// $Id$
+
+#include "Hello.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+
+ACE_RCSID (Connect_Strategy_Test,
+ server,
+ "$Id$")
+
+const char *ior_output_file = "test.ior";
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "o:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ 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;
+
+ if (CORBA::is_nil (root_poa.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Panic: nil RootPOA\n"),
+ 1);
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ Hello *hello_impl;
+ ACE_NEW_RETURN (hello_impl,
+ Hello (orb.in ()),
+ 1);
+ PortableServer::ServantBase_var owner_transfer(hello_impl);
+
+ Test::Hello_var hello =
+ hello_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::String_var ior =
+ orb->object_to_string (hello.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Output the IOR to the <ior_output_file>
+ FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open output file for writing IOR: %s",
+ ior_output_file),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
+
+ root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Exception caught:");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}