diff options
Diffstat (limited to 'TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/Sequence_Supplier.cpp')
-rw-r--r-- | TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/Sequence_Supplier.cpp | 86 |
1 files changed, 54 insertions, 32 deletions
diff --git a/TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/Sequence_Supplier.cpp b/TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/Sequence_Supplier.cpp index 30c0a2e2b0d..2ce98df2f79 100644 --- a/TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/Sequence_Supplier.cpp +++ b/TAO/orbsvcs/tests/Notify/Sequence_Multi_Filter/Sequence_Supplier.cpp @@ -5,6 +5,7 @@ // ****************************************************************** #include "ace/Get_Opt.h" +#include "ace/Argv_Type_Converter.h" #include "ace/Auto_Ptr.h" // FUZZ: disable check_for_streams_include @@ -25,9 +26,9 @@ // ****************************************************************** // Data Section // ****************************************************************** -const int PER_BATCH = 4; + static TAO_Notify_Tests_SequencePushSupplier* supplier_1 = 0; -static int num_batches = 10; +static int max_events = 2; // 6 sets of 16 static const char* ior_output_file = "supplier.ior"; // ****************************************************************** @@ -84,14 +85,14 @@ public: int Supplier_Client::parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "o:e:"); + ACE_Get_Arg_Opt<char> get_opts (argc, argv, "o:e:"); int c; while ((c = get_opts ()) != -1) switch (c) { case 'e': - num_batches = ACE_OS::atoi(get_opts.optarg); + max_events = ACE_OS::atoi(get_opts.optarg); break; case 'o': @@ -131,11 +132,12 @@ create_supplieradmin (CosNotifyChannelAdmin::EventChannel_ptr ec static void SendEvents (int id ACE_ENV_ARG_DECL) { + const int MAX_EVENTS = 15; + static const char* types[] = { "good", "bad", "ugly" }; CosNotification::EventBatch events; CosNotification::StructuredEvent event; - event.header.fixed_header.event_type.domain_name = CORBA::string_dup("Orbix 2000 Demos"); event.header.fixed_header.event_type.type_name = @@ -143,44 +145,64 @@ SendEvents (int id ACE_ENV_ARG_DECL) event.header.fixed_header.event_name = CORBA::string_dup("test event"); + event.header.variable_header.length (1); event.header.variable_header[0].name = CORBA::string_dup(CosNotification::Priority); + event.header.variable_header[0].value <<= (CORBA::Short) + (id > max_events / 2 ? + -id : id); event.filterable_data.length (3); event.filterable_data[0].name = CORBA::string_dup("Number"); + event.filterable_data[0].value <<= (CORBA::Long)10; + event.filterable_data[1].name = CORBA::string_dup("Index"); + event.filterable_data[1].value <<= 0; + event.filterable_data[2].name = CORBA::string_dup("enum"); + event.filterable_data[2].value <<= types[id % 3]; - events.length(PER_BATCH); + events.length(16); + events[0] = event; - for(int z = 0; z < PER_BATCH; ++z) { - event.header.variable_header[0].value <<= (CORBA::Short) - (id > num_batches / 2 ? + CosNotification::StructuredEvent revents[15]; + for(int z = 0; z < MAX_EVENTS; ++z) { + revents[z].header.fixed_header.event_type.domain_name = + CORBA::string_dup("Orbix 2000 Demos"); + revents[z].header.fixed_header.event_type.type_name = + CORBA::string_dup("Sequence Notification Push Demo Event"); + + revents[z].header.fixed_header.event_name = CORBA::string_dup("test revents[z]"); + + revents[z].header.variable_header.length (1); + revents[z].header.variable_header[0].name = + CORBA::string_dup(CosNotification::Priority); + revents[z].header.variable_header[0].value <<= (CORBA::Short) + (id > max_events / 2 ? -id : id); + revents[z].filterable_data.length (3); + revents[z].filterable_data[0].name = CORBA::string_dup("Number"); + if (z % 2 == 0) { - event.filterable_data[0].value <<= (CORBA::Long)20; + revents[z].filterable_data[0].value <<= (CORBA::Long)20; } else { - event.filterable_data[0].value <<= (CORBA::Long)10; + revents[z].filterable_data[0].value <<= (CORBA::Long)10; } - event.filterable_data[1].value <<= z; + revents[z].filterable_data[1].name = CORBA::string_dup("Index"); + revents[z].filterable_data[1].value <<= z+1; - event.filterable_data[2].value <<= types[id % 3]; - events[z] = event; + revents[z].filterable_data[2].name = CORBA::string_dup("enum"); + revents[z].filterable_data[2].value <<= types[id % 3]; + events[z + 1] = revents[z]; } - ACE_TRY_NEW_ENV - { - supplier_1->send_events(events ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCH (CORBA::Exception, e) - { - ACE_PRINT_EXCEPTION (e, "Error: Supplier exception: "); - } - ACE_ENDTRY; + ACE_DEBUG ((LM_DEBUG, "Sending events.\n")); + + supplier_1->send_events(events ACE_ENV_ARG_PARAMETER); + ACE_CHECK; } static void @@ -205,15 +227,17 @@ create_suppliers (CosNotifyChannelAdmin::SupplierAdmin_ptr admin, // Main Section // ****************************************************************** -int main (int argc, char* argv[]) +int ACE_TMAIN (int argc, ACE_TCHAR* argv[]) { + ACE_Argv_Type_Converter convert (argc, argv); + ACE_Auto_Ptr< sig_i > sig_impl; int status = 0; ACE_TRY_NEW_ENV { Supplier_Client client; - status = client.init (argc, argv ACE_ENV_ARG_PARAMETER); + status = client.init (convert.get_argc(), convert.get_ASCII_argv() ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; if (status == 0) @@ -236,7 +260,7 @@ int main (int argc, char* argv[]) // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) { - FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + FILE *output_file= ACE_OS::fopen (ior_output_file, ACE_TEXT("w")); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for " @@ -256,19 +280,17 @@ int main (int argc, char* argv[]) sig_impl->wait_for_startup(); - ACE_DEBUG((LM_DEBUG, " 1 supplier sending %d batches of %d events...\n", num_batches, PER_BATCH)); - for (int i = 0; i < num_batches; ++i) + ACE_DEBUG((LM_DEBUG, " 1 supplier sending %d events...\n", max_events)); + for (int i = 0; i < max_events; ++i) { ACE_DEBUG((LM_DEBUG, "+")); SendEvents (i ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } - ACE_DEBUG((LM_DEBUG, "\nSupplier waiting for consumer completion...\n")); + ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", max_events)); sig_impl->wait_for_completion(); - ACE_DEBUG((LM_DEBUG, "\nSupplier finished.\n")); - ACE_OS::unlink (ior_output_file); ec->destroy(ACE_ENV_SINGLE_ARG_PARAMETER); |