diff options
Diffstat (limited to 'TAO/tests/GIOP_Fragments')
23 files changed, 1294 insertions, 0 deletions
diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Reply/Client_Task.cpp b/TAO/tests/GIOP_Fragments/Java_Big_Reply/Client_Task.cpp new file mode 100644 index 00000000000..a6a92dab129 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Reply/Client_Task.cpp @@ -0,0 +1,60 @@ +// +// $Id$ +// + +#include "Client_Task.h" + +ACE_RCSID(Muxing, Client_Task, "$Id$") + +Client_Task::Client_Task (Test::Big_Reply_ptr reply_gen, + int event_count, + ACE_Thread_Manager *thr_mgr) + : ACE_Task_Base (thr_mgr) + , reply_gen_ (Test::Big_Reply::_duplicate (reply_gen)) + , event_count_ (event_count) + +{ +} + +int +Client_Task::svc (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Starting client task\n")); + + ACE_DECLARE_NEW_CORBA_ENV; + + // Now get the big replies.. + ACE_TRY + { + for (int i = 0; i != this->event_count_; ++i) + { + Test::Octet_Seq_var seq = + this->reply_gen_->get_big_reply (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ULong length = seq->length (); + for(CORBA::ULong i = 0; i < length; ++i) + { + if (seq[i] != 'A') + { + ACE_ERROR_RETURN ((LM_ERROR, + "Invalid data '%c' at %d\n", seq[i], i), + -1); + } + } + +// ACE_Time_Value tv(0, 10000000); +// ACE_OS::sleep(tv); + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception Caught \n"); + return -1; + } + ACE_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client task finished\n")); + return 0; +} diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Reply/Client_Task.h b/TAO/tests/GIOP_Fragments/Java_Big_Reply/Client_Task.h new file mode 100644 index 00000000000..40c669d8344 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Reply/Client_Task.h @@ -0,0 +1,38 @@ +// +// $Id$ +// + +#ifndef BIG_REPLY_CLIENT_TASK_H +#define BIG_REPLY_CLIENT_TASK_H +#include "ace/pre.h" + +#include "TestC.h" +#include "ace/Task.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/// Implement a Task to run the experiments using multiple threads. +class Client_Task : public ACE_Task_Base +{ +public: + /// Constructor + Client_Task (Test::Big_Reply_ptr receiver, + CORBA::Long event_count, + ACE_Thread_Manager *thr_mgr); + + /// Thread entry point + int svc (void); + +private: + + /// Reference to the test interface + Test::Big_Reply_var reply_gen_; + + /// Number of remote calls + int event_count_; +}; + +#include "ace/post.h" +#endif /* BIG_REPLY_CLIENT_TASK_H */ diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Reply/Java_Big_Reply.mpc b/TAO/tests/GIOP_Fragments/Java_Big_Reply/Java_Big_Reply.mpc new file mode 100644 index 00000000000..627a8a61136 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Reply/Java_Big_Reply.mpc @@ -0,0 +1,45 @@ +project(*IDL) { + requires += java + + // Define the Java IDL with a hack output extension + // Since our idl file has a module, the generated java files + // will go int the module name so we set the extension to / + Define_Custom(JAVA_IDL) { + command = idlj + inputext = .idl + generic_outputext = / + } + + // Make sure we don't get any of the defaults + Source_Files { + } + Inline_Files { + } + Header_Files { + } + + JAVA_IDL_Files { + // The idlj will automatically put the generated files + // in the Test directory + gendir = Test + + // We want both server and client side + commandflags += -fall + + Test.idl + } +} + +// This project will build the java server and C++ client +project(Java_Big_Reply): taoexe, portableserver { + requires += java + after += *IDL + + // Define the java type + Define_Custom(JAVA) { + command = javac + commandflags = -d . + inputext = .java + generic_outputext = .class + } +} diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Reply/Test.idl b/TAO/tests/GIOP_Fragments/Java_Big_Reply/Test.idl new file mode 100644 index 00000000000..442d6a746be --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Reply/Test.idl @@ -0,0 +1,18 @@ +//$Id$ +module Test +{ + + typedef sequence<octet> Octet_Seq; + + interface Big_Reply + { + /// Receive a big reply + Octet_Seq get_big_reply (); + + /// Ping message + void ping (); + + /// Shudown the remote ORB + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Reply/client.cpp b/TAO/tests/GIOP_Fragments/Java_Big_Reply/client.cpp new file mode 100644 index 00000000000..e900b46cdc1 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Reply/client.cpp @@ -0,0 +1,95 @@ +// $Id$ + +#include "Client_Task.h" +#include "ace/Get_Opt.h" + +ACE_RCSID(Muxing, client, "$Id$") + +static const char *ior = "file://server.ior"; +static size_t nthreads = 1; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "k:n:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.opt_arg (); + break; + case 'n': + nthreads = ACE_OS::atoi (get_opts.opt_arg ()); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "-n <nthreads> " + "\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::Big_Reply_var reply_gen = + Test::Big_Reply::_narrow(tmp.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (reply_gen.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil coordinator reference <%s>\n", + ior), + 1); + } + + + Client_Task client_task (reply_gen.in (), + 10, + ACE_Thread_Manager::instance ()); + + if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, + nthreads, 1) == -1) + { + ACE_ERROR ((LM_ERROR, "Error activating client task\n")); + } + ACE_Thread_Manager::instance ()->wait (); + + reply_gen->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/GIOP_Fragments/Java_Big_Reply/run_test.pl b/TAO/tests/GIOP_Fragments/Java_Big_Reply/run_test.pl new file mode 100755 index 00000000000..d51fafed5e6 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Reply/run_test.pl @@ -0,0 +1,62 @@ +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 Config; +sub which { + my($prog) = shift; + my($exec) = $prog; + + if (defined $ENV{'PATH'}) { + my($part) = ''; + foreach $part (split($Config{'path_sep'}, $ENV{'PATH'})) { + $part .= "/$prog"; + if ( -x $part ) { + $exec = $part; + last; + } + } + } + + return $exec; +} + +$iorfile = PerlACE::LocalFile ('server.ior'); +unlink $iorfile; + +$SV = new PerlACE::Process (which('java'), 'server'); +$CL = new PerlACE::Process ('client'); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$CL->Spawn (60); + +$client = $CL->WaitKill (60); + +if ($client1 != 0) { + print STDERR "ERROR: client 1 returned $client1\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/GIOP_Fragments/Java_Big_Reply/server.java b/TAO/tests/GIOP_Fragments/Java_Big_Reply/server.java new file mode 100644 index 00000000000..f23d552c542 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Reply/server.java @@ -0,0 +1,62 @@ +// $Id$ + +// If this server is compiled and run with the JDK ORB, it will +// fragment the GIOP Messages sent when get_big_reply() is called. + +import org.omg.CORBA.*; +import org.omg.PortableServer.*; +import Test.Big_ReplyPOA; + +class Big_ReplyImpl extends Big_ReplyPOA +{ + private org.omg.CORBA.ORB orb_; + + public byte[] get_big_reply () { + byte [] seq = new byte [1000000]; + for (int i = 0; i < seq.length; i++) + seq [i] = 'A'; + return seq; + } + + public void setORB (org.omg.CORBA.ORB orb_val) { + orb_ = orb_val; + } + + public void ping () { + } + + public void shutdown () { + orb_.shutdown (false); + } +} + + +public class server +{ + public static void main (String args[]) { + try { + ORB orb = ORB.init (args, null); + POA poa = org.omg.PortableServer.POAHelper.narrow ( + orb.resolve_initial_references ("RootPOA")); + + Big_ReplyImpl servant = new Big_ReplyImpl (); + servant.setORB (orb); + poa.activate_object (servant); + + String filename = new String ("server.ior"); + String ior = orb.object_to_string (servant._this ()); + java.io.FileWriter file = new java.io.FileWriter (filename); + file.write (ior); + file.flush (); + file.close (); + + poa.the_POAManager ().activate (); + System.out.println ("Ready..."); + orb.run (); + } + catch (Exception e) { + System.err.println ("ERROR: " + e); + e.printStackTrace (System.out); + } + } +} diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Request/Java_Big_Request.mpc b/TAO/tests/GIOP_Fragments/Java_Big_Request/Java_Big_Request.mpc new file mode 100644 index 00000000000..6503fb95c9b --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Request/Java_Big_Request.mpc @@ -0,0 +1,42 @@ +project(*IDL) { + requires += java + + // Define the Java IDL with a hack output extension + // Since our idl file has a module, the generated java files + // will go int the module name so we set the extension to / + Define_Custom(JAVA_IDL) { + command = idlj + inputext = .idl + generic_outputext = / + } + + // Make sure we don't get any of the defaults + Source_Files { + } + Inline_Files { + } + Header_Files { + } + + JAVA_IDL_Files { + // The idlj will automatically put the generated files + // in the Test directory + gendir = Test + + Test.idl + } +} + +// This project will build the java server and C++ client +project(Java_Big_Request): taoexe, portableserver { + requires += java + after += *IDL + + // Define the java type + Define_Custom(JAVA) { + command = javac + commandflags = -d . + inputext = .java + generic_outputext = .class + } +} diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Request/Payload_Receiver.cpp b/TAO/tests/GIOP_Fragments/Java_Big_Request/Payload_Receiver.cpp new file mode 100644 index 00000000000..41bb21bca37 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Request/Payload_Receiver.cpp @@ -0,0 +1,45 @@ +// +// $Id$ +// +#include "Payload_Receiver.h" + +ACE_RCSID(Big_Request_Muxing, Payload_Receiver, "$Id$") + +Payload_Receiver::Payload_Receiver (CORBA::ORB_ptr orb) + : count_ (0), + orb_(CORBA::ORB::_duplicate (orb)) +{ +} + +void +Payload_Receiver::more_data (const Test::Payload &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Test::Payload_Receiver::Invalid_Payload)) +{ + ++this->count_; + + CORBA::ULong length = payload.length (); + for (CORBA::ULong i = 0; i < length; ++i) + { + if (payload[i] != 'A') + { + ACE_THROW (Test::Payload_Receiver::Invalid_Payload ()); + } + } +} + + +void +Payload_Receiver::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->orb_->shutdown (); +} + + +int +Payload_Receiver::get_count () const +{ + return count_; +} diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Request/Payload_Receiver.h b/TAO/tests/GIOP_Fragments/Java_Big_Request/Payload_Receiver.h new file mode 100644 index 00000000000..8a0c4eafe74 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Request/Payload_Receiver.h @@ -0,0 +1,51 @@ +// +// $Id$ +// + +#ifndef BIG_REQUEST_MUXING_PAYLOAD_RECEIVER_H +#define BIG_REQUEST_MUXING_PAYLOAD_RECEIVER_H +#include "ace/pre.h" + +#include "TestS.h" + +#if defined (_MSC_VER) +# if (_MSC_VER >= 1200) +# pragma warning(push) +# endif /* _MSC_VER >= 1200 */ +# pragma warning (disable:4250) +#endif /* _MSC_VER */ + +/// Implement the Test::Payload_Receiver interface +/** + * Simply print count how many bytes were received. + */ +class Payload_Receiver + : public virtual POA_Test::Payload_Receiver + , public virtual PortableServer::RefCountServantBase +{ +public: + /// Constructor + Payload_Receiver (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual void more_data (const Test::Payload &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Test::Payload_Receiver::Invalid_Payload)); + + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + int get_count (void) const; + +public: + int count_; + CORBA::ORB_var orb_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma warning(pop) +#endif /* _MSC_VER */ + +#include "ace/post.h" +#endif /* BIG_REQUEST_MUXING_PAYLOAD_RECEIVER_H */ diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Request/Test.idl b/TAO/tests/GIOP_Fragments/Java_Big_Request/Test.idl new file mode 100644 index 00000000000..902aed29cf4 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Request/Test.idl @@ -0,0 +1,21 @@ +// +// $Id$ +// + +module Test +{ + typedef sequence<octet> Payload; + + interface Payload_Receiver + { + exception Invalid_Payload { + }; + + /// Send the data using a twoway operation + void more_data (in Payload the_payload) + raises (Invalid_Payload); + + /// Shudown the remote ORB + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Request/client.java b/TAO/tests/GIOP_Fragments/Java_Big_Request/client.java new file mode 100644 index 00000000000..b3d1dd3eafb --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Request/client.java @@ -0,0 +1,47 @@ +// $Id$ + +// If this server is compiled and run with the JDK ORB, it will +// fragment the GIOP Messages sent when more_data() is called. + +import java.io.FileReader; +import java.io.BufferedReader; +import org.omg.CORBA.*; +import org.omg.PortableServer.*; +import Test.Payload_Receiver; +import Test.Payload_ReceiverHelper; + +public class client +{ + public static void main (String args[]) { + try { + ORB orb = ORB.init (args, null); + + // Get the object reference + BufferedReader reader = new BufferedReader ( + new FileReader ("server.ior")); + StringBuffer ior = new StringBuffer(); + String line = null; + while ((line = reader.readLine()) != null) { + ior.append(line); + } + + org.omg.CORBA.Object obj = orb.string_to_object (ior.toString ()); + Payload_Receiver receiver = Payload_ReceiverHelper.narrow (obj); + + // Set up the payload + byte [] seq = new byte [1000000]; + for (int i = 0; i < seq.length; ++i) + seq [i] = 'A'; + + // Invoke the method on the server + for (int i = 0; i < 20; ++i) + receiver.more_data (seq); + + receiver.shutdown (); + } + catch (Exception e) { + System.err.println ("ERROR: " + e); + e.printStackTrace (System.out); + } + } +} diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Request/run_test.pl b/TAO/tests/GIOP_Fragments/Java_Big_Request/run_test.pl new file mode 100755 index 00000000000..e8514914409 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Request/run_test.pl @@ -0,0 +1,53 @@ +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; +$iorfile = PerlACE::LocalFile ('server.ior'); +$TARGETHOSTNAME = 'localhost'; +$port = PerlACE::uniqueid () + 12000; + +## No ORB fragments GIOP 1.0 messages. +## The JDK ORB only fragments GIOP 1.2 messages. +foreach my $giop ('1.2') { + print "Testing GIOP $giop Fragmentation\n"; + unlink $iorfile; + + $SV = new PerlACE::Process ('server', + '-ORBEndpoint ' . + "iiop://$giop\@$TARGETHOSTNAME" . ":$port"); + $SV->Spawn (); + + if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; + } + + my($cl) = system('java client'); + if ($cl != 0) { + print STDERR "ERROR: client returned $cl\n"; + ++$status; + } + + $server = $SV->WaitKill (20); + + if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + ++$status; + } + + unlink $iorfile; + + if ($status) { + last; + } +} + +exit $status; diff --git a/TAO/tests/GIOP_Fragments/Java_Big_Request/server.cpp b/TAO/tests/GIOP_Fragments/Java_Big_Request/server.cpp new file mode 100644 index 00000000000..8a7bbbd6c4b --- /dev/null +++ b/TAO/tests/GIOP_Fragments/Java_Big_Request/server.cpp @@ -0,0 +1,119 @@ +// $Id$ + +#include "Payload_Receiver.h" +#include "ace/Get_Opt.h" + +ACE_RCSID(Big_Request_Muxing, server, "$Id$") + +const char *ior_output_file = "server.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[]) +{ + int status = 0; + 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; + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + + 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; + + if (parse_args (argc, argv) != 0) + return 1; + + Payload_Receiver *payload_receiver_impl; + ACE_NEW_RETURN (payload_receiver_impl, + Payload_Receiver (orb.in ()), + 1); + PortableServer::ServantBase_var receiver_owner_transfer(payload_receiver_impl); + + Test::Payload_Receiver_var payload_receiver = + payload_receiver_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (payload_receiver.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // If the ior_output_file exists, output the ior to it + 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; + + if (payload_receiver_impl->get_count () != 20) + { + ACE_ERROR ((LM_ERROR, + "ERROR: %d is not the correct " + "number of calls\n", + payload_receiver_impl->get_count ())); + ++status; + } + + 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:"); + ++status; + } + ACE_ENDTRY; + + return status; +} diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/PMB_With_Fragments.mpc b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/PMB_With_Fragments.mpc new file mode 100644 index 00000000000..adbd1fd9303 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/PMB_With_Fragments.mpc @@ -0,0 +1,2 @@ +project: taoexe, portableserver { +} diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Payload_Receiver.cpp b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Payload_Receiver.cpp new file mode 100644 index 00000000000..41bb21bca37 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Payload_Receiver.cpp @@ -0,0 +1,45 @@ +// +// $Id$ +// +#include "Payload_Receiver.h" + +ACE_RCSID(Big_Request_Muxing, Payload_Receiver, "$Id$") + +Payload_Receiver::Payload_Receiver (CORBA::ORB_ptr orb) + : count_ (0), + orb_(CORBA::ORB::_duplicate (orb)) +{ +} + +void +Payload_Receiver::more_data (const Test::Payload &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Test::Payload_Receiver::Invalid_Payload)) +{ + ++this->count_; + + CORBA::ULong length = payload.length (); + for (CORBA::ULong i = 0; i < length; ++i) + { + if (payload[i] != 'A') + { + ACE_THROW (Test::Payload_Receiver::Invalid_Payload ()); + } + } +} + + +void +Payload_Receiver::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->orb_->shutdown (); +} + + +int +Payload_Receiver::get_count () const +{ + return count_; +} diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Payload_Receiver.h b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Payload_Receiver.h new file mode 100644 index 00000000000..8a0c4eafe74 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Payload_Receiver.h @@ -0,0 +1,51 @@ +// +// $Id$ +// + +#ifndef BIG_REQUEST_MUXING_PAYLOAD_RECEIVER_H +#define BIG_REQUEST_MUXING_PAYLOAD_RECEIVER_H +#include "ace/pre.h" + +#include "TestS.h" + +#if defined (_MSC_VER) +# if (_MSC_VER >= 1200) +# pragma warning(push) +# endif /* _MSC_VER >= 1200 */ +# pragma warning (disable:4250) +#endif /* _MSC_VER */ + +/// Implement the Test::Payload_Receiver interface +/** + * Simply print count how many bytes were received. + */ +class Payload_Receiver + : public virtual POA_Test::Payload_Receiver + , public virtual PortableServer::RefCountServantBase +{ +public: + /// Constructor + Payload_Receiver (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual void more_data (const Test::Payload &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Test::Payload_Receiver::Invalid_Payload)); + + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + int get_count (void) const; + +public: + int count_; + CORBA::ORB_var orb_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma warning(pop) +#endif /* _MSC_VER */ + +#include "ace/post.h" +#endif /* BIG_REQUEST_MUXING_PAYLOAD_RECEIVER_H */ diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Test.idl b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Test.idl new file mode 100644 index 00000000000..902aed29cf4 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/Test.idl @@ -0,0 +1,21 @@ +// +// $Id$ +// + +module Test +{ + typedef sequence<octet> Payload; + + interface Payload_Receiver + { + exception Invalid_Payload { + }; + + /// Send the data using a twoway operation + void more_data (in Payload the_payload) + raises (Invalid_Payload); + + /// Shudown the remote ORB + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/dribble.pl b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/dribble.pl new file mode 100755 index 00000000000..248b60d6a11 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/dribble.pl @@ -0,0 +1,147 @@ +eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' + & eval 'exec perl -w -S $0 $argv:q' + if 0; + +# ****************************************************************** +# Author: Chris Cleeland +# Date: 10/26/2002 +# $Id$ +# ****************************************************************** + +use Getopt::Long; +use File::Basename; +use IO::Socket::INET; +use IO::File; +use Carp; + +sub getnum { + use POSIX qw(strtoul); + my $str = shift; + $str =~ s/^\s+//; + $str =~ s/\s+$//; + $! = 0; + my($num, $unparsed) = strtoul($str); + if (($str eq '') || ($unparsed != 0) || $!) { + return undef; + } else { + return $num; + } +} + +my $corba_server_addr = "127.0.0.1"; +my $corba_server_port = 12345; +my $progress_interval = 10; +my $verbosity = 0; +my $interactive = undef; +my $datastreamfile = 'datastream.dat'; +my $dataxmitlayoutfile = undef; +my $delay = .25; + +my %options = ('host|h=s' => \$corba_server_addr, + 'port|p=s' => \$corba_server_port, + 'interval|i=i' => \$progress_interval, + 'verbose|verbosity|v+' => \$verbosity, + 'interactive' => \$interactive, + 'stream|s=s' => \$datastreamfile, + 'layout|l=s' => \$dataxmitlayoutfile, + 'delay|d=f' => \$delay, + ); +my $result = GetOptions (%options); + +if (!$result) { + my($str) = 'Usage: ' . basename($0); + my($initial) = length($str); + my($length) = $initial; + my($maxLine) = 78; + + print $str; + + foreach my $key (sort keys %options) { + my($opt, $type) = split(/[|=]/, $key); + my($str) = " [--$opt" . (defined $type ? " <$opt>" : "") . "]"; + my($len) = length($str); + if ($length + $len > $maxLine) { + print "\n" . (" " x $initial); + $length = $initial; + } + print $str; + $length += $len; + } + print "\n"; + exit(0); +} + +croak "Must supply a data file using --stream and a layout file using --layout" + unless defined $datastreamfile && defined $dataxmitlayoutfile; + +my $sock = IO::Socket::INET->new(PeerAddr => $corba_server_addr, + PeerPort => $corba_server_port, + Proto => 'tcp') + or croak "Unable to establish connection to $corba_server_addr:$corba_server_port: $!\n"; + +# +# Infer a name for the layout file +# +if (! defined $dataxmitlayoutfile) { + $dataxmitlayoutfile = $datastreamfile; + $dataxmitlayoutfile =~ s/\.dat$/\.layout/; +} + +# Now we just start reading from <> and writing to the socket We +# currently assume all are oneways, so we don't worry about reading +# from the socket. + +my $stream = new IO::File $datastreamfile, "r" + or croak "Unable to open $datastreamfile for reading: $!"; +my $layout = new IO::File $dataxmitlayoutfile, "r" + or croak "Unable to open $dataxmitlayoutfile for reading: $!"; + +$| = 1; +print "Sending...(1 dot every $progress_interval hunks)\n"; +print "Hit <RETURN> key to send a packet\n" if defined $interactive; +my $numread; +do { + + # + # Determine the size of the hunk we have to read/send + # + $_ = $layout->getline; + s/#.*$//; + chomp $_; + next if ($_ =~ /^\s*$/); + + my $requested_hunksize = getnum($_); + my $l = $layout->input_line_number; + + my $hunk; + + # + # Read in the hunk size we want + # + $numread = $stream->sysread($hunk, $requested_hunksize); + if (! defined $numread) { + carp "\nHunk $l: Error reading from stream: $!"; + next; + } + elsif ($numread != $requested_hunksize) { + carp "\nHunk $l: short read (expected $requested_hunksize, got $numread); going on."; + } + + print "Hunk $l: length ", length($hunk), "\n" if ($verbosity >= 1); + if (defined $interactive) { + <STDIN>; + } + else { + select(undef, undef, undef, $delay); + } + + my $ret = $sock->send($hunk, 0); + if ($ret != length($hunk)) { + carp "\nHunk $l: problem sending hunk $.: $!\n"; + exit(1); + } + + print "." if ($. % $progress_interval == 0); +} until $numread == 0 || $layout->eof; +print "\nDone.\n" + diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/giop1.2_fragments.dat b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/giop1.2_fragments.dat Binary files differnew file mode 100644 index 00000000000..09582c5f2c4 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/giop1.2_fragments.dat diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/giop1.2_fragments.layout b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/giop1.2_fragments.layout new file mode 100644 index 00000000000..aa5766e5a62 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/giop1.2_fragments.layout @@ -0,0 +1,86 @@ +2 +2 +6 +2 +3 +9 +272 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +25815 +18438 diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/run_test.pl b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/run_test.pl new file mode 100755 index 00000000000..41ae198c47f --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/run_test.pl @@ -0,0 +1,47 @@ +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; +$iorfile = PerlACE::LocalFile ('server.ior'); +$TARGETHOSTNAME = 'localhost'; +$port = PerlACE::uniqueid () + 12000; +$debug = 0; + +unlink $iorfile; + +$SV = new PerlACE::Process ('server', + '-ORBEndpoint ' . + "iiop://$TARGETHOSTNAME" . ":$port " . + "-ORBDebugLevel $debug"); +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +my($cl) = system("$^X dribble.pl --port=$port " . + "--stream=giop1.2_fragments.dat " . + "--layout=giop1.2_fragments.layout"); +if ($cl != 0) { + print STDERR "ERROR: client returned $cl\n"; + ++$status; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + ++$status; +} + +unlink $iorfile; +exit $status; diff --git a/TAO/tests/GIOP_Fragments/PMB_With_Fragments/server.cpp b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/server.cpp new file mode 100644 index 00000000000..b130d8c5747 --- /dev/null +++ b/TAO/tests/GIOP_Fragments/PMB_With_Fragments/server.cpp @@ -0,0 +1,137 @@ +// $Id$ + +#include "Payload_Receiver.h" +#include "ace/Get_Opt.h" + +ACE_RCSID(Big_Request_Muxing, server, "$Id$") + +const char *ior_output_file = "server.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[]) +{ + int status = 0; + 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; + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + + 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; + + if (parse_args (argc, argv) != 0) + return 1; + + PortableServer::LifespanPolicy_var lifespan = + root_poa->create_lifespan_policy (PortableServer::PERSISTENT); + CORBA::PolicyList policy_list; + policy_list.length (1); + policy_list[0] = PortableServer::LifespanPolicy::_duplicate ( + lifespan.in ()); + PortableServer::POA_var persistent_poa = + root_poa->create_POA ("PersistentPOA", poa_manager.in (), + policy_list); + lifespan->destroy (); + + + Payload_Receiver *payload_receiver_impl; + ACE_NEW_RETURN (payload_receiver_impl, + Payload_Receiver (orb.in ()), + 1); + PortableServer::ServantBase_var receiver_owner_transfer(payload_receiver_impl); + + PortableServer::ObjectId_var id = + persistent_poa->activate_object (payload_receiver_impl + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var obj = + persistent_poa->id_to_reference (id.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (obj.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // If the ior_output_file exists, output the ior to it + 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; + + if (payload_receiver_impl->get_count () != 2) + { + ACE_ERROR ((LM_ERROR, + "ERROR: %d is not the correct " + "number of calls\n", + payload_receiver_impl->get_count ())); + ++status; + } + + 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:"); + ++status; + } + ACE_ENDTRY; + + return status; +} |