Go to the documentation of this file.00001
00005
00006
00007
00008
00009 #include <sstream>
00010 #include <fstream>
00011 #include <string>
00012
00013 #define BOOST_TEST_DYN_LINK
00014 #define BOOST_TEST_MAIN
00015 #define BOOST_TEST_MODULE FQTTestSuite
00016 #include <boost/test/unit_test.hpp>
00017
00018 #include <stdair/basic/BasLogParams.hpp>
00019 #include <stdair/basic/BasDBParams.hpp>
00020 #include <stdair/basic/BasFileMgr.hpp>
00021 #include <stdair/service/Logger.hpp>
00022 #include <stdair/bom/TravelSolutionStruct.hpp>
00023 #include <stdair/bom/BookingRequestStruct.hpp>
00024
00025 #include <simfqt/SIMFQT_Service.hpp>
00026 #include <simfqt/config/simfqt-paths.hpp>
00027
00028 namespace boost_utf = boost::unit_test;
00029
00033 struct UnitTestConfig {
00035 UnitTestConfig() {
00036 static std::ofstream _test_log ("FQTTestSuite_utfresults.xml");
00037 boost_utf::unit_test_log.set_stream (_test_log);
00038 boost_utf::unit_test_log.set_format (boost_utf::XML);
00039 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
00040
00041 }
00042
00044 ~UnitTestConfig() {
00045 }
00046 };
00047
00048
00052 void testFareQuoterHelper (const unsigned short iTestFlag,
00053 const stdair::Filename_T iFareInputFilename,
00054 const bool isBuiltin) {
00055
00056
00057 std::ostringstream oStr;
00058 oStr << "FQTTestSuite_" << iTestFlag << ".log";
00059 const stdair::Filename_T lLogFilename (oStr.str());
00060
00061
00062 std::ofstream logOutputFile;
00063
00064 logOutputFile.open (lLogFilename.c_str());
00065 logOutputFile.clear();
00066
00067
00068 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
00069 logOutputFile);
00070
00071
00072 SIMFQT::SIMFQT_Service simfqtService (lLogParams);
00073
00074
00075 if (isBuiltin == true) {
00076
00077
00078 simfqtService.buildSampleBom();
00079
00080 } else {
00081
00082
00083 SIMFQT::FareFilePath lFareFilePath (iFareInputFilename);
00084 simfqtService.parseAndLoad (lFareFilePath);
00085 }
00086
00087
00088 stdair::TravelSolutionList_T lTravelSolutionList;
00089 simfqtService.buildSampleTravelSolutions (lTravelSolutionList);
00090 stdair::BookingRequestStruct lBookingRequest =
00091 simfqtService.buildBookingRequest();
00092
00093
00094 simfqtService.quotePrices (lBookingRequest, lTravelSolutionList);
00095
00096
00097 logOutputFile.close();
00098
00099 }
00100
00101
00102
00103
00104 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
00105
00106
00107 BOOST_AUTO_TEST_SUITE (master_test_suite)
00108
00109
00112 BOOST_AUTO_TEST_CASE (simfqt_simple_pricing_test) {
00113
00114
00115 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fare01.csv");
00116
00117
00118 const bool isBuiltin = false;
00119
00120
00121 BOOST_CHECK_NO_THROW (testFareQuoterHelper (0, lFareInputFilename, isBuiltin));
00122
00123 }
00124
00129 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_01) {
00130
00131
00132 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError01.csv");
00133
00134
00135 const bool isBuiltin = false;
00136
00137
00138 BOOST_CHECK_THROW (testFareQuoterHelper (1, lFareInputFilename, isBuiltin),
00139 SIMFQT::AirportPairNotFoundException);
00140 }
00141
00146 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_02) {
00147
00148
00149 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError02.csv");
00150
00151
00152 const bool isBuiltin = false;
00153
00154
00155 BOOST_CHECK_THROW (testFareQuoterHelper (2, lFareInputFilename, isBuiltin),
00156 SIMFQT::PosOrChannelNotFoundException);
00157 }
00158
00163 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_03) {
00164
00165
00166 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError03.csv");
00167
00168
00169 const bool isBuiltin = false;
00170
00171
00172 BOOST_CHECK_THROW (testFareQuoterHelper (3, lFareInputFilename, isBuiltin),
00173 SIMFQT::FlightDateNotFoundException);
00174 }
00175
00180 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_04) {
00181
00182
00183 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError04.csv");
00184
00185
00186 const bool isBuiltin = false;
00187
00188
00189 BOOST_CHECK_THROW (testFareQuoterHelper (4, lFareInputFilename, isBuiltin),
00190 SIMFQT::FlightTimeNotFoundException);
00191 }
00192
00197 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_05) {
00198
00199
00200 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError05.csv");
00201
00202
00203 const bool isBuiltin = false;
00204
00205
00206 BOOST_CHECK_THROW (testFareQuoterHelper (5, lFareInputFilename, isBuiltin),
00207 SIMFQT::FeaturesNotFoundException);
00208 }
00209
00214 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_06) {
00215
00216
00217 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError06.csv");
00218
00219
00220 const bool isBuiltin = false;
00221
00222
00223 BOOST_CHECK_THROW (testFareQuoterHelper (6, lFareInputFilename, isBuiltin),
00224 SIMFQT::AirlineNotFoundException);
00225 }
00226
00231 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_07) {
00232
00233
00234 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError07.csv");
00235
00236
00237 const bool isBuiltin = false;
00238
00239
00240 BOOST_CHECK_THROW (testFareQuoterHelper (7, lFareInputFilename, isBuiltin),
00241 SIMFQT::FareFileParsingFailedException);
00242 }
00243
00248 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_08) {
00249
00250
00251 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/missingFile.csv");
00252
00253
00254 const bool isBuiltin = false;
00255
00256
00257 BOOST_CHECK_THROW (testFareQuoterHelper (8, lFareInputFilename, isBuiltin),
00258 SIMFQT::FareInputFileNotFoundException);
00259 }
00260
00265 BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_09) {
00266
00267
00268 const stdair::Filename_T lEmptyInputFilename (STDAIR_SAMPLE_DIR "/ ");
00269
00270
00271 const bool isBuiltin = true;
00272
00273
00274 BOOST_CHECK_NO_THROW(testFareQuoterHelper (9, lEmptyInputFilename, isBuiltin));
00275 }
00276
00277
00278
00279 BOOST_AUTO_TEST_SUITE_END()
00280
00281