0.08.01
C++ Open Travel Request Parsing Library
Toggle main menu visibility
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
20
#include <
opentrep/OPENTREP_Service.hpp
>
21
#include <
opentrep/basic/BasConst_OPENTREP_Service.hpp
>
22
#include <
opentrep/Location.hpp
>
23
#include <
opentrep/CityDetails.hpp
>
24
#include <opentrep/config/opentrep-paths.hpp>
25
26
namespace
boost_utf = boost::unit_test;
27
28
// (Boost) Unit Test XML Report
29
std::ofstream
utfReportStream
(
"IndexBuildingTestSuite_utfresults.xml"
);
30
34
struct
UnitTestConfig
{
36
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
48
~UnitTestConfig
() {
49
}
50
};
51
52
53
// //////////// Constants for the tests ///////////////
57
const
std::string K_POR_FILEPATH (OPENTREP_POR_DATA_DIR
58
"/csv/test-optd-por-public.csv"
);
59
63
const
std::string
X_XAPIAN_DB_FP
(
"/tmp/opentrep/test_traveldb"
);
64
68
const
std::string
X_SQL_DB_STR
(
""
);
69
73
const
OPENTREP::DeploymentNumber_T
X_DEPLOYMENT_NUMBER
(0);
74
78
const
OPENTREP::shouldIndexNonIATAPOR_T
K_ALL_POR =
false
;
79
83
const
OPENTREP::shouldIndexPORInXapian_T
K_XAPIAN_IDX =
true
;
84
88
const
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)
94
BOOST_GLOBAL_FIXTURE
(
UnitTestConfig
);
95
96
// Start the test suite
97
BOOST_AUTO_TEST_SUITE (master_test_suite)
98
99
102
BOOST_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
);
116
const
OPENTREP::DBType
lDBType (
OPENTREP::DBType::NODB
);
117
const
OPENTREP::SQLDBConnectionString_T
lSQLDBConnStr (
X_SQL_DB_STR
);
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
147
BOOST_AUTO_TEST_SUITE_END()
148
149
152
BasConst_OPENTREP_Service.hpp
CityDetails.hpp
Location.hpp
OPENTREP_Service.hpp
utfReportStream
std::ofstream utfReportStream("PartitionTestSuite_utfresults.xml")
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(partition_small_string)
Definition
PartitionTestSuite.cpp:60
BOOST_GLOBAL_FIXTURE
BOOST_GLOBAL_FIXTURE(UnitTestConfig)
X_XAPIAN_DB_FP
const std::string X_XAPIAN_DB_FP("/tmp/opentrep/test_traveldb")
X_SQL_DB_STR
const std::string X_SQL_DB_STR("")
X_DEPLOYMENT_NUMBER
const OPENTREP::DeploymentNumber_T X_DEPLOYMENT_NUMBER(0)
utfReportStream
std::ofstream utfReportStream("UnicodeTestSuite_utfresults.xml")
OPENTREP::OPENTREP_Service
Interface for the OPENTREP Services.
Definition
OPENTREP_Service.hpp:25
OPENTREP::WordList_T
std::list< Word_T > WordList_T
Definition
OPENTREP_Types.hpp:690
OPENTREP::shouldAddPORInSQLDB_T
bool shouldAddPORInSQLDB_T
Definition
OPENTREP_Types.hpp:146
OPENTREP::NbOfDBEntries_T
unsigned int NbOfDBEntries_T
Definition
OPENTREP_Types.hpp:680
OPENTREP::LocationList_T
std::list< Location > LocationList_T
Definition
LocationList.hpp:18
OPENTREP::shouldIndexPORInXapian_T
bool shouldIndexPORInXapian_T
Definition
OPENTREP_Types.hpp:141
OPENTREP::DeploymentNumber_T
unsigned short DeploymentNumber_T
Definition
OPENTREP_Types.hpp:108
OPENTREP::shouldIndexNonIATAPOR_T
bool shouldIndexNonIATAPOR_T
Definition
OPENTREP_Types.hpp:136
OPENTREP::DBType
Enumeration of database types.
Definition
DBType.hpp:17
OPENTREP::DBType::NODB
@ NODB
Definition
DBType.hpp:20
OPENTREP::PORFilePath_T
Definition
OPENTREP_Types.hpp:37
OPENTREP::SQLDBConnectionString_T
Definition
OPENTREP_Types.hpp:56
OPENTREP::TravelDBFilePath_T
Definition
OPENTREP_Types.hpp:46
UnitTestConfig
Definition
PartitionTestSuite.cpp:30
UnitTestConfig::UnitTestConfig
UnitTestConfig()
Definition
PartitionTestSuite.cpp:32
UnitTestConfig::~UnitTestConfig
~UnitTestConfig()
Definition
PartitionTestSuite.cpp:44
Generated on
for OpenTREP by
1.17.0