AirRAC Logo  0.2.0
C++ Simulated Revenue Accounting (RAC) System Library
YieldTestSuite.cpp
Go to the documentation of this file.
00001 
00005 // //////////////////////////////////////////////////////////////////////
00006 // Import section
00007 // //////////////////////////////////////////////////////////////////////
00008 // STL
00009 #include <sstream>
00010 #include <fstream>
00011 #include <string>
00012 // Boost Unit Test Framework (UTF)
00013 #define BOOST_TEST_DYN_LINK
00014 #define BOOST_TEST_MAIN
00015 #define BOOST_TEST_MODULE YieldTestSuite
00016 #include <boost/test/unit_test.hpp>
00017 // StdAir
00018 #include <stdair/basic/BasLogParams.hpp>
00019 #include <stdair/basic/BasDBParams.hpp>
00020 #include <stdair/basic/BasFileMgr.hpp>
00021 #include <stdair/bom/TravelSolutionStruct.hpp>
00022 #include <stdair/service/Logger.hpp>
00023 // Airrac
00024 #include <airrac/AIRRAC_Service.hpp>
00025 #include <airrac/config/airrac-paths.hpp>
00026 
00027 namespace boost_utf = boost::unit_test;
00028 
00029 // (Boost) Unit Test XML Report
00030 std::ofstream utfReportStream ("YieldTestSuite_utfresults.xml");
00031 
00035 struct UnitTestConfig {
00037   UnitTestConfig() {
00038     boost_utf::unit_test_log.set_stream (utfReportStream);
00039     boost_utf::unit_test_log.set_format (boost_utf::XML);
00040     boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
00041     //boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
00042   }
00043 
00045   ~UnitTestConfig() {
00046   }
00047 };
00048 
00049 
00050 // /////////////// Main: Unit Test Suite //////////////
00051 
00052 // Set the UTF configuration (re-direct the output to a specific file)
00053 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
00054 
00055 // Start the test suite
00056 BOOST_AUTO_TEST_SUITE (master_test_suite)
00057 
00058 
00061 BOOST_AUTO_TEST_CASE (airrac_simple_yield) {
00062     
00063   // Travel solution
00064   stdair::TravelSolutionStruct lTravelSolution;
00065   stdair::TravelSolutionList_T lTravelSolutionList;
00066     
00067   // Input file name
00068   const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR
00069                                                 "/yieldstore01.csv");
00070 
00071   // Check that the file path given as input corresponds to an actual file
00072   bool doesExistAndIsReadable =
00073     stdair::BasFileMgr::doesExistAndIsReadable (lYieldInputFilename);
00074   BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
00075                        "The '" << lYieldInputFilename
00076                        << "' input file can not be open and read");
00077 
00078   // Output log File
00079   const stdair::Filename_T lLogFilename ("YieldTestSuite.log");
00080   
00081   // Set the log parameters
00082   std::ofstream logOutputFile;
00083   // Open and clean the log outputfile
00084   logOutputFile.open (lLogFilename.c_str());
00085   logOutputFile.clear();
00086   
00087   // Initialise the list of classes/buckets
00088   const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
00089 
00090   AIRRAC::AIRRAC_Service airracService (lLogParams);
00091 
00092   // Build the BOM tree from parsing a yield file
00093   AIRRAC::YieldFilePath lYieldFilePath (lYieldInputFilename);
00094   airracService.parseAndLoad (lYieldFilePath);
00095   
00096   // Calculate the yields for the given travel solution
00097   lTravelSolutionList.push_back(lTravelSolution);
00098   airracService.calculateYields (lTravelSolutionList);
00099 
00100   // Close the log file
00101   logOutputFile.close();
00102 }
00103 
00104 // End the test suite
00105 BOOST_AUTO_TEST_SUITE_END()
00106 
00107