OpenTREP Logo  0.07.18
C++ Open Travel Request Parsing Library
Loading...
Searching...
No Matches
IndexBuildingTestSuite.cpp
Go to the documentation of this file.
1
5// //////////////////////////////////////////////////////////////////////
6// Import section
7// //////////////////////////////////////////////////////////////////////
8// STL
9#include <cassert>
10#include <iostream>
11#include <sstream>
12#include <fstream>
13#include <string>
14// Boost Unit Test Framework (UTF)
15#define BOOST_TEST_DYN_LINK
16#define BOOST_TEST_MAIN
17#define BOOST_TEST_MODULE IndexBuildingTestSuite
18#include <boost/test/unit_test.hpp>
19// OpenTrep
22#include <opentrep/Location.hpp>
24#include <opentrep/config/opentrep-paths.hpp>
25
26namespace boost_utf = boost::unit_test;
27
28// (Boost) Unit Test XML Report
29std::ofstream utfReportStream ("IndexBuildingTestSuite_utfresults.xml");
30
34struct UnitTestConfig {
37 boost_utf::unit_test_log.set_stream (utfReportStream);
38#if defined(BOOST_VERSION) && BOOST_VERSION >= 105900
39 boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
40#else // BOOST_VERSION
41 boost_utf::unit_test_log.set_format (boost_utf::XML);
42#endif // BOOST_VERSION
43 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
44 //boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);
45 }
46
49 }
50};
51
52
53// //////////// Constants for the tests ///////////////
57const std::string K_POR_FILEPATH (OPENTREP_POR_DATA_DIR
58 "/test_optd_por_public.csv");
59
63const std::string X_XAPIAN_DB_FP ("/tmp/opentrep/test_traveldb");
64
68const std::string X_SQL_DB_STR ("");
69
74
78const OPENTREP::shouldIndexNonIATAPOR_T K_ALL_POR = false;
79
83const OPENTREP::shouldIndexPORInXapian_T K_XAPIAN_IDX = true;
84
88const OPENTREP::shouldAddPORInSQLDB_T K_SQLDB_ADD = false;
89
90
91// /////////////// Main: Unit Test Suite //////////////
92
93// Set the UTF configuration (re-direct the output to a specific file)
95
96// Start the test suite
97BOOST_AUTO_TEST_SUITE (master_test_suite)
98
99
102BOOST_AUTO_TEST_CASE (opentrep_simple_index) {
103
104 // Output log File
105 std::string lLogFilename ("IndexBuildingTestSuite.log");
106
107 // Set the log parameters
108 std::ofstream logOutputFile;
109 // Open and clean the log outputfile
110 logOutputFile.open (lLogFilename.c_str());
111 logOutputFile.clear();
112
113 // Initialise the context
114 const OPENTREP::PORFilePath_T lPORFilePath (K_POR_FILEPATH);
115 const OPENTREP::TravelDBFilePath_T lTravelDBFilePath (X_XAPIAN_DB_FP);
118 const OPENTREP::DeploymentNumber_T lDeploymentNumber (X_DEPLOYMENT_NUMBER);
119 const OPENTREP::shouldIndexNonIATAPOR_T lShouldIndexNonIATAPOR (K_ALL_POR);
120 const OPENTREP::shouldIndexPORInXapian_T lShouldIndexPORInXapian(K_XAPIAN_IDX);
121 const OPENTREP::shouldAddPORInSQLDB_T lShouldAddPORInSQLDB (K_SQLDB_ADD);
122 OPENTREP::OPENTREP_Service opentrepService (logOutputFile, lPORFilePath,
123 lTravelDBFilePath,
124 lDBType, lSQLDBConnStr,
125 lDeploymentNumber,
126 lShouldIndexNonIATAPOR,
127 lShouldIndexPORInXapian,
128 lShouldAddPORInSQLDB);
129
130 // Query the Xapian database (index)
131 OPENTREP::WordList_T lNonMatchedWordList;
132 OPENTREP::LocationList_T lLocationList;
133 // Launch the indexation
134 const OPENTREP::NbOfDBEntries_T nbOfEntries =
135 opentrepService.insertIntoDBAndXapian();
136
137 BOOST_CHECK_MESSAGE (nbOfEntries == 9,
138 "The Xapian index ('" << lTravelDBFilePath
139 << "') contains " << nbOfEntries
140 << " entries, where as 9 are expected.");
141
142 // Close the Log outputFile
143 logOutputFile.close();
144}
145
146// End the test suite
147BOOST_AUTO_TEST_SUITE_END()
148
149
152
std::ofstream utfReportStream("PartitionTestSuite_utfresults.xml")
BOOST_AUTO_TEST_CASE(partition_small_string)
BOOST_GLOBAL_FIXTURE(UnitTestConfig)
const std::string X_XAPIAN_DB_FP("/tmp/opentrep/test_traveldb")
const std::string X_SQL_DB_STR("")
const OPENTREP::DeploymentNumber_T X_DEPLOYMENT_NUMBER(0)
std::ofstream utfReportStream("UnicodeTestSuite_utfresults.xml")
Interface for the OPENTREP Services.
std::list< Word_T > WordList_T
bool shouldAddPORInSQLDB_T
unsigned int NbOfDBEntries_T
std::list< Location > LocationList_T
bool shouldIndexPORInXapian_T
unsigned short DeploymentNumber_T
bool shouldIndexNonIATAPOR_T
Enumeration of database types.
Definition DBType.hpp:17