diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2013-05-29 07:01:17 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2013-05-29 07:01:17 +0000 |
commit | d2d9797c0fecefc29dadb5b7fc1846ad45b5936f (patch) | |
tree | 55e1a83b0e2a01dffe44485d286705ec43f63759 /TAO/orbsvcs/tests/Trading/Offer_Importer.cpp | |
parent | dae67a6a82b3a50719cfdce75e02ebd6ac5d1c86 (diff) | |
download | ATCD-d2d9797c0fecefc29dadb5b7fc1846ad45b5936f.tar.gz |
Wed May 29 07:00:03 UTC 2013 Johnny Willemsen <jwillemsen@remedy.nl>
* orbsvcs/orbsvcs/Trader/Constraint_Visitors.cpp:
* orbsvcs/orbsvcs/Trader/Offer_Iterators.cpp:
* orbsvcs/orbsvcs/Trader/Service_Type_Repository.cpp:
* orbsvcs/tests/Trading/Offer_Exporter.cpp:
* orbsvcs/tests/Trading/Offer_Importer.cpp:
* orbsvcs/tests/Trading/Service_Type_Exporter.h:
* orbsvcs/tests/Trading/Service_Type_Exporter.cpp:
* orbsvcs/tests/Trading/TT_Info.cpp:
* orbsvcs/tests/Trading/colocated_test.cpp:
* orbsvcs/tests/Trading/export_test.cpp:
* orbsvcs/tests/Trading/import_test.cpp:
Fixed several memory leaks in the trading service and
also extensions to the unit test. Thanks to Rudy Pot
<rpot at aweta dot nl> for delivering the patches. This
fixed bugzilla 4100
* tao/PortableServer/Operation_Table_Dynamic_Hash.h:
Doxygen fix
Diffstat (limited to 'TAO/orbsvcs/tests/Trading/Offer_Importer.cpp')
-rw-r--r-- | TAO/orbsvcs/tests/Trading/Offer_Importer.cpp | 130 |
1 files changed, 75 insertions, 55 deletions
diff --git a/TAO/orbsvcs/tests/Trading/Offer_Importer.cpp b/TAO/orbsvcs/tests/Trading/Offer_Importer.cpp index ac8b5a1014f..fef66fc1a15 100644 --- a/TAO/orbsvcs/tests/Trading/Offer_Importer.cpp +++ b/TAO/orbsvcs/tests/Trading/Offer_Importer.cpp @@ -22,7 +22,6 @@ TAO_Offer_Importer::perform_queries (void) policies.match_card (16*NUM_OFFERS); policies.return_card (16*NUM_OFFERS); policies.link_follow_rule (CosTrading::always); - this->perform_queries_with_policies (policies); } @@ -94,14 +93,14 @@ TAO_Offer_Importer::perform_directed_queries (void) } else { - ACE_DEBUG ((LM_DEBUG, "This test requires a complete" - " graph of three traders.\n")); + ACE_ERROR ((LM_ERROR, ACE_TEXT("ERROR, This test requires a complete graph of three traders!\n"))); + throw CORBA::BAD_INV_ORDER(); // Let outside world know we can't continue this way. } } else { - ACE_DEBUG ((LM_DEBUG, "This test requires a complete" - " graph of three traders.\n")); + ACE_ERROR ((LM_ERROR, ACE_TEXT("ERROR, This test requires a complete graph of three traders!\n"))); + throw CORBA::BAD_INV_ORDER(); // Let outside world know we can't continue this way. } } @@ -125,67 +124,87 @@ TAO_Offer_Importer::perform_queries_with_policies ( CosTrading::PropertyNameSeq prop_name_seq (4, 4, props, 0); desired_props.prop_names (prop_name_seq); - + for (int i = 0; i < TT_Info::NUM_QUERIES; i++) { ACE_DEBUG ((LM_DEBUG, "\n")); ACE_DEBUG ((LM_DEBUG, "*** Performing query for %C.\n", TT_Info::QUERIES[i][0])); ACE_DEBUG ((LM_DEBUG, "*** Query: %C\n", TT_Info::QUERIES[i][1])); ACE_DEBUG ((LM_DEBUG, "*** Preferences: %C\n", TT_Info::QUERIES[i][2])); - CosTrading::OfferSeq *offer_seq_ptr = 0; - CosTrading::OfferIterator_ptr offer_iterator_ptr = 0; - CosTrading::PolicyNameSeq *limits_applied_ptr = 0; - - CosTrading::OfferSeq_out offer_seq_out (offer_seq_ptr); - CosTrading::OfferIterator_out offer_iterator_out (offer_iterator_ptr); - CosTrading::PolicyNameSeq_out limits_applied_out (limits_applied_ptr); + CosTrading::OfferSeq_var offer_seq; + CosTrading::OfferIterator_var offer_iterator; + CosTrading::PolicyNameSeq_var limits_applied; + + // Test with different how_many amount, both should work. + // Initially try to get this amount in the sequence. + CORBA::ULong how_many = 8; + if (i&0x0001) + { + how_many=0; // 0: Don't retrieve in offers but all in iterator. + }; this->lookup_->query (TT_Info::QUERIES[i][0], TT_Info::QUERIES[i][1], TT_Info::QUERIES[i][2], policies.policy_seq (), desired_props, - 8, - offer_seq_out, - offer_iterator_out, - limits_applied_out); - - CosTrading::OfferSeq_var offer_seq (offer_seq_ptr); - CosTrading::OfferIterator_var offer_iterator (offer_iterator_ptr); - CosTrading::PolicyNameSeq_var limits_applied (limits_applied_ptr); - - CORBA::ULong total = (offer_seq_ptr == 0 ? 0 : - offer_seq_ptr->length ()) + - (offer_iterator_ptr == 0 ? 0 : - offer_iterator_ptr->max_left ()); + how_many, + offer_seq.out(), + offer_iterator.out(), + limits_applied.out()); + + CORBA::ULong seqlen = (offer_seq.ptr() == 0 ? 0 : + offer_seq->length ()); + CORBA::ULong itrlen = (CORBA::is_nil(offer_iterator.in()) ? 0 : + offer_iterator->max_left ()); + CORBA::ULong total = seqlen + itrlen; CORBA::ULong expected = ACE_OS::atoi (TT_Info::QUERIES[i][3]); - if (total != expected) - ACE_ERROR ((LM_ERROR, - "ERROR: Expected %d for query %d, but got %d\n", - expected, i, total)); + if (total != expected) + { + ACE_ERROR ((LM_ERROR + ,"ERROR: Expected %d for query %d, got seq(%d) + itr(%d) = %d\n" + ,expected + ,i + ,seqlen + ,itrlen + ,total + )); + throw CORBA::TRANSIENT(); // Try again later? + } + else if (this->verbose_) + { + ACE_DEBUG ((LM_DEBUG + ,"Expected %d for query %d, got seq(%d) + itr(%d) = %d\n" + ,expected + ,i + ,seqlen + ,itrlen + ,total + )); + }; + if (this->verbose_) { ACE_DEBUG ((LM_DEBUG, "*** Results:\n\n")); - this->display_results (*offer_seq_ptr, - offer_iterator_ptr); + this->display_results (*offer_seq.ptr(), + offer_iterator.in()); - if (limits_applied_out->length () > 0) + if (limits_applied->length () > 0) ACE_DEBUG ((LM_DEBUG, "*** Limits Applied:\n\n")); - for (int length = limits_applied_out->length (), j = 0; j < length; j++) + for (int length = limits_applied->length (), j = 0; j < length; j++) { - const char *policy_name = (*limits_applied_ptr)[j]; + const char *policy_name = (*limits_applied.ptr())[j]; ACE_DEBUG ((LM_DEBUG, "%C\n", static_cast<const char*> (policy_name))); } } } } - catch (const CORBA::Exception& ex) + catch (const CORBA::Exception& e) { - ex._tao_print_exception ( - "TAO_Offer_Importer::perform_queries"); + e._tao_print_exception ("TAO_Offer_Importer::perform_queries_with_policies"); throw; } } @@ -196,13 +215,14 @@ TAO_Offer_Importer::display_results (const CosTrading::OfferSeq& offer_seq, { try { - CORBA::ULong length = 0, i = 0; ACE_DEBUG ((LM_DEBUG, "------------------------------\n")); ACE_DEBUG ((LM_DEBUG, "Offers in the sequence:\n")); ACE_DEBUG ((LM_DEBUG, "------------------------------\n")); - for (length = offer_seq.length (), i = 0; i < length; i++) + for (CORBA::ULong i = 0; i < offer_seq.length (); i++) { // Call back to the exported object. + // FIXME: shouldn't this be done in a separate 'verify_results' method? + // (confirm () now skipped in quiet mode) TAO_Trader_Test::Remote_Output_var remote_output = TAO_Trader_Test::Remote_Output::_narrow (offer_seq[i].reference.in ()); @@ -216,27 +236,28 @@ TAO_Offer_Importer::display_results (const CosTrading::OfferSeq& offer_seq, ACE_DEBUG ((LM_DEBUG, "------------------------------\n")); if (! CORBA::is_nil (offer_iterator)) { - length = offer_seq.length (); CORBA::Boolean any_left = 0; - do { - CosTrading::OfferSeq *iter_offers_ptr; - CosTrading::OfferSeq_out iter_offers_out (iter_offers_ptr); - - any_left = offer_iterator->next_n (length, - iter_offers_out); - - CosTrading::OfferSeq_var iter_offers (iter_offers_ptr); - for (length = iter_offers->length (), i = 0; i < length; i++) + CosTrading::OfferSeq_var offers; + // Use of iterator->max_left() to get all iterator results is not + // recommended? (see p.879 Advanced CORBA programming book) + // Howmany to process is a choice between next_n call 'dispatch + // costs' and 'larges results marshalling bandwidth costs'. + CORBA::ULong how_many = 100; + any_left = offer_iterator->next_n (how_many, offers.out()); + + for (CORBA::ULong i = 0; i < offers->length (); i++) { // Call back to the exported object. + // FIXME: shouldn't this be done in a separate 'verify_results' method? + // (confirm () now skipped in quiet mode) TAO_Trader_Test::Remote_Output_var remote_output = - TAO_Trader_Test::Remote_Output::_narrow (offer_seq[i].reference.in ()); + TAO_Trader_Test::Remote_Output::_narrow ((*offers)[i].reference.in ()); remote_output->confirm (); - CosTrading::PropertySeq& props = iter_offers[i].properties; + CosTrading::PropertySeq& props = (*offers)[i].properties; TT_Info::dump_properties (props, 1); ACE_DEBUG ((LM_DEBUG, "------------------------------\n")); @@ -247,10 +268,9 @@ TAO_Offer_Importer::display_results (const CosTrading::OfferSeq& offer_seq, offer_iterator->destroy (); } } - catch (const CORBA::Exception& ex) + catch (const CORBA::Exception& e) { - ex._tao_print_exception ( - "TAO_Offer_Importer::display_results"); + e._tao_print_exception ("TAO_Offer_Importer::display_results"); throw; } } |