use of org.opentripplanner.datastore.FileType.GTFS in project OpenTripPlanner by opentripplanner.
the class ZipFileDataSourceTest method testIO.
@Test
public void testIO() throws IOException {
// Given:
File target = new File(FILENAME);
CompositeDataSource subject = new ZipFileDataSource(target, GTFS);
Collection<DataSource> content = subject.content();
Collection<String> names = content.stream().map(it -> it.name()).collect(Collectors.toList());
// System.out.println(names);
assertTrue(names.toString(), names.containsAll(List.of("agency.txt", "stops.txt", "trips.txt")));
DataSource entry = subject.entry("agency.txt");
List<String> lines = IOUtils.readLines(entry.asInputStream(), StandardCharsets.UTF_8);
assertEquals("agency_id,agency_name,agency_url,agency_timezone", lines.get(0));
assertEquals("Caltrain,Caltrain,http://www.caltrain.com,America/Los_Angeles", lines.get(1));
// Close zip
subject.close();
}
use of org.opentripplanner.datastore.FileType.GTFS in project OpenTripPlanner by opentripplanner.
the class ZipStreamDataSourceDecoratorTest method testIO.
@Test
public void testIO() throws IOException {
// Given:
File target = new File(FILENAME);
CompositeDataSource subject = new ZipStreamDataSourceDecorator(new FileDataSource(target, GTFS));
Collection<DataSource> content = subject.content();
Collection<String> names = content.stream().map(it -> it.name()).collect(Collectors.toList());
System.out.println(names);
assertTrue(names.toString(), names.containsAll(List.of("trips.txt", "agency.txt", "calendar.txt", "calendar_dates.txt", "fare_attributes.txt", "fare_rules.txt", "routes.txt", "shapes.txt", "stop_times.txt", "stops.txt")));
DataSource entry = subject.entry("agency.txt");
List<String> lines = IOUtils.readLines(entry.asInputStream(), StandardCharsets.UTF_8);
assertEquals("agency_id,agency_name,agency_url,agency_timezone", lines.get(0));
// Close zip
subject.close();
}
Aggregations