1 #include "tao/Utils/ORB_Manager.h"
2 #include "Offer_Exporter.h"
3 #include "Offer_Importer.h"
4 #include "Service_Type_Exporter.h"
5 #include "ace/Auto_Ptr.h"
6 #include "orbsvcs/Trader/Trader.h"
7 #include "orbsvcs/Trader/Service_Type_Repository.h"
8 #include "ace/Get_Opt.h"
10 const ACE_TCHAR
*done_file
= ACE_TEXT("export_test_ready");
13 parse_args_spec (int argc
, ACE_TCHAR
*argv
[], int help
)
18 "\nUsage: export_test <options>\n"
19 "Test the trader's exporter role, the options are:\n"
20 "-ORBInitRef <orb_options> E.g. '-ORBInitRef TradingService=iiop://localhost:8901/TradingService'\n"
21 "-quiet or -q (optional) Run the tests in quiet mode, don't show the query and list results.\n"
22 "-federate or -f (optional) Setup for federated trader tests.\n"
23 "-iorfile or -i (optional) Get TradingService reference through IOR instead of resolve.\n"
24 "-d <done_file> (optional) Filename for signalling that we are ready for serving dynamic properties (for import_test).\n"
26 "This test needs an external TradingServer running, example:\n"
27 " Trading_Service -ORBEndpoint iiop://:8901 -TSdumpior trading.ior\n"
28 "See also TAO/docs/releasenotes/trader.html.\n\n"));
33 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("d:"));
34 for (int opt
; (opt
= get_opts()) != -1;)
38 done_file
= get_opts
.opt_arg ();
47 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
55 TAO_ORB_Manager orb_manager
;
56 orb_manager
.init (argc
, argv
);
58 // Command line argument parser for use with comlex pearl tests.
59 if (parse_args_spec (argc
, argv
, help
) != 0)
62 // Command line argument parser for the trading tests.
63 TT_Parse_Args
parse_args (argc
, argv
);
65 // Init the orb and bootstrap to the trading service.
66 CORBA::ORB_var orb
= orb_manager
.orb ();
67 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("*** Bootstrap to the Lookup interface.\n")));
69 char* ior
= parse_args
.ior ();
70 CORBA::Object_var trading_obj
= (ior
== 0) ?
71 orb
->resolve_initial_references ("TradingService") :
72 orb
->string_to_object (ior
);
74 if (CORBA::is_nil (trading_obj
.in ()))
75 ACE_ERROR_RETURN ((LM_ERROR
,
76 ACE_TEXT("ERROR, Unable to bootstrap to the Trading Service!\n")),
79 // Narrow the lookup interface.
80 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("*** Narrowing the lookup interface.\n")));
81 CosTrading::Lookup_var lookup_if
=
82 CosTrading::Lookup::_narrow (trading_obj
.in ());
84 // Run the Service Type Exporter tests.
85 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("*** Running the Service Type Exporter tests.\n")));
86 TAO_Service_Type_Exporter
type_exporter (lookup_if
.in (), ! parse_args
.quiet ());
88 type_exporter
.remove_all_types ();
90 type_exporter
.add_all_types ();
92 type_exporter
.remove_all_types ();
94 type_exporter
.add_all_types ();
96 if (parse_args
.federated ())
98 type_exporter
.add_all_types_to_all ();
101 type_exporter
.list_all_types ();
103 type_exporter
.describe_all_types ();
105 type_exporter
.fully_describe_all_types ();
107 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("*** Service Type Exporter tests complete.\n")));
109 // Run the Offer Exporter tests.
110 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("*** Running the Offer Exporter tests.\n")));
111 TAO_Offer_Exporter
offer_exporter (lookup_if
.in (), ! parse_args
.quiet ());
115 offer_exporter
.withdraw_offers ();
117 offer_exporter
.export_offers ();
119 offer_exporter
.describe_offers ();
121 offer_exporter
.modify_offers ();
123 offer_exporter
.describe_offers ();
125 offer_exporter
.withdraw_offers_using_constraints ();
127 offer_exporter
.describe_offers ();
129 offer_exporter
.withdraw_offers ();
131 offer_exporter
.export_offers ();
133 if (parse_args
.federated ())
135 offer_exporter
.export_offers_to_all ();
138 offer_exporter
.describe_offers ();
140 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("*** Offer Exporter tests complete.\n")));
141 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT("*** Now serving dynamic properties.\n")));
143 FILE *ready_file
= ACE_OS::fopen (done_file
, ACE_TEXT("w"));
146 ACE_OS::fprintf (ready_file
, "The export test is ready\n");
147 ACE_OS::fclose (ready_file
);
151 ACE_DEBUG ((LM_WARNING
,
152 ACE_TEXT("Unable to open %s for output.\n"),
158 catch (const CORBA::Exception
& e
)
160 e
._tao_print_exception ("Trader export test ERROR!");