##// END OF EJS Templates
Handles "Not found" error for AMDA result parser
Alexandre Leroux -
r446:f2dd25b3cc0a
parent child
Show More
@@ -0,0 +1,3
1 Not Found
2
3 The requested URL /AMDA/data/WSRESULT/imf(0)-1343153090-1343153092-60.txt was not found on this server. No newline at end of file
@@ -12,6 +12,9 Q_LOGGING_CATEGORY(LOG_AmdaResultParser, "AmdaResultParser")
12 12
13 13 namespace {
14 14
15 /// Message in result file when the file was not found on server
16 const auto FILE_NOT_FOUND_MESSAGE = QStringLiteral("Not Found");
17
15 18 /// Format for dates in result files
16 19 const auto DATE_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz");
17 20
@@ -119,8 +122,16 std::shared_ptr<IDataSeries> AmdaResultParser::readTxt(const QString &filePath)
119 122
120 123 QTextStream stream{&file};
121 124
122 // Ignore first two lines (comments lines)
123 stream.readLine();
125 // Checks if the file was found on the server
126 auto firstLine = stream.readLine();
127 if (firstLine.compare(FILE_NOT_FOUND_MESSAGE) == 0) {
128 qCCritical(LOG_AmdaResultParser())
129 << QObject::tr("Can't retrieve AMDA data from file %1: file was not found on server")
130 .arg(filePath);
131 return nullptr;
132 }
133
134 // Ignore comments lines
124 135 stream.readLine();
125 136
126 137 // Reads x-axis unit
@@ -155,9 +155,12 void TestAmdaResultParser::testReadTxt_data()
155 155 QVector<QDateTime>{dateTime(2013, 9, 23, 9, 1, 30), dateTime(2013, 9, 23, 9, 2, 30)},
156 156 QVector<double>{-2.71850, -2.52150}};
157 157
158 // Invalid file
159 QTest::newRow("Invalid file (unexisting file)") << QStringLiteral("UnexistingFile.txt")
160 << ExpectedResults{};
158 // Invalid files
159 QTest::newRow("Invalid file (unexisting file)")
160 << QStringLiteral("UnexistingFile.txt") << ExpectedResults{};
161
162 QTest::newRow("Invalid file (file not found on server)")
163 << QStringLiteral("FileNotFound.txt") << ExpectedResults{};
161 164 }
162 165
163 166 void TestAmdaResultParser::testReadTxt()
General Comments 0
You need to be logged in to leave comments. Login now