SEvMgr Logo  0.2.0
C++ Simulation-Oriented Discrete Event Management Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines
EventQueueManagementTestSuite.cpp
Go to the documentation of this file.
00001 
00005 // //////////////////////////////////////////////////////////////////////
00006 // Import section
00007 // //////////////////////////////////////////////////////////////////////
00008 // STL
00009 #include <sstream>
00010 #include <fstream>
00011 #include <map>
00012 #include <cmath>
00013 // Boost Unit Test Framework (UTF)
00014 #define BOOST_TEST_DYN_LINK
00015 #define BOOST_TEST_MAIN
00016 #define BOOST_TEST_MODULE EventQueueManagementTest
00017 #include <boost/test/unit_test.hpp>
00018 // StdAir
00019 #include <stdair/stdair_basic_types.hpp>
00020 #include <stdair/basic/BasLogParams.hpp>
00021 #include <stdair/basic/BasDBParams.hpp>
00022 #include <stdair/basic/BasFileMgr.hpp>
00023 #include <stdair/basic/ProgressStatusSet.hpp>
00024 #include <stdair/bom/EventStruct.hpp>
00025 #include <stdair/bom/EventQueue.hpp>
00026 #include <stdair/bom/BookingRequestStruct.hpp>
00027 #include <stdair/service/Logger.hpp>
00028 // SEvMgr
00029 #include <sevmgr/SEVMGR_Service.hpp>
00030 #include <sevmgr/config/sevmgr-paths.hpp>
00031 
00032 namespace boost_utf = boost::unit_test;
00033 
00034 // (Boost) Unit Test XML Report
00035 std::ofstream utfReportStream ("EventQueueManagementTestSuite_utfresults.xml");
00036 
00040 struct UnitTestConfig {
00042   UnitTestConfig() {
00043     boost_utf::unit_test_log.set_stream (utfReportStream);
00044     boost_utf::unit_test_log.set_format (boost_utf::XML);
00045     boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
00046     //boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
00047   }
00048   
00050   ~UnitTestConfig() {
00051   }
00052 };
00053 
00054 // Specific type definitions
00055 typedef std::pair<stdair::Count_T, stdair::Count_T> NbOfEventsPair_T;
00056 typedef std::map<const stdair::DemandStreamKeyStr_T,
00057                  NbOfEventsPair_T> NbOfEventsByDemandStreamMap_T;
00058 
00059 
00060 // /////////////// Main: Unit Test Suite //////////////
00061 
00062 // Set the UTF configuration (re-direct the output to a specific file)
00063 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
00064 
00065 // Start the test suite
00066 BOOST_AUTO_TEST_SUITE (master_test_suite)
00067 
00068 
00071 BOOST_AUTO_TEST_CASE (sevmgr_simple_simulation_test) {
00072 
00073   // Input file name
00074   const stdair::Filename_T lInputFilename (STDAIR_SAMPLE_DIR "/demand01.csv");
00075 
00076   // Check that the file path given as input corresponds to an actual file
00077   const bool doesExistAndIsReadable =
00078     stdair::BasFileMgr::doesExistAndIsReadable (lInputFilename);
00079   BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
00080                        "The '" << lInputFilename
00081                        << "' input file can not be open and read");
00082   
00083   // Output log File
00084   const stdair::Filename_T lLogFilename ("EventQueueManagementTestSuite.log");
00085   
00086   // Set the log parameters
00087   std::ofstream logOutputFile;
00088   // open and clean the log outputfile
00089   logOutputFile.open (lLogFilename.c_str());
00090   logOutputFile.clear();
00091   
00092   // Initialise the Sevmgr service object
00093   const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
00094   SEVMGR::SEVMGR_Service sevmgrService (lLogParams);
00095 
00097   sevmgrService.buildSampleBom();
00098 
00101   sevmgrService.reset();
00102 
00103   // DEBUG
00104   STDAIR_LOG_DEBUG ("End of the simulation");
00105 
00106   // Close the log file
00107   logOutputFile.close();
00108 }
00109 
00110 // End the test suite
00111 BOOST_AUTO_TEST_SUITE_END()
00112 
00113