Skip to content

Commit

Permalink
Adjust local corpus-test slightly to ignore some more broken files
Browse files Browse the repository at this point in the history
  • Loading branch information
centic9 committed Mar 31, 2024
1 parent 1d6660b commit bb33970
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.lang3.time.FastDateFormat;
import org.dstadler.commons.testing.TestHelpers;
Expand Down Expand Up @@ -365,6 +366,8 @@ public void testParseAllLocalFiles() throws IOException {
String str = FileUtils.readFileToString(gpxFile, "UTF-8").trim();
if (str.contains("301 Moved Permanently") ||
str.startsWith("Moved Permanently") ||
str.startsWith("BCFZ") ||
str.startsWith("Found") ||
str.toLowerCase().startsWith("<!doctype html") ||
str.toLowerCase().startsWith("<html") ||
str.toUpperCase().startsWith("GEOMETRYCOLLECTION") ||
Expand All @@ -376,6 +379,13 @@ public void testParseAllLocalFiles() throws IOException {
final SortedMap<Long, TrackPoint> trackPoints = GPXTrackpointsParser.parseContent(gpxFile);
assertNotNull(trackPoints);
} catch (IOException | RuntimeException e) {
// ignore some broken files
String stackTrace = ExceptionUtils.getStackTrace(e);
if (stackTrace.contains("Expected to have tag 'lat' and 'lon'") ||
stackTrace.contains("For input string")) {
System.out.println("Skipping broken file " + gpxFile);
return;
}
throw new RuntimeException("Failed to process " + gpxFile, e);
}
});
Expand Down

0 comments on commit bb33970

Please sign in to comment.