Migrate multi-module project to single project.

This commit is contained in:
Andreas Schildbach 2019-07-19 19:14:13 +02:00
parent 04382fe67e
commit 070fcad64a
220 changed files with 73 additions and 85 deletions

View file

@ -0,0 +1,94 @@
/*
* Copyright 2014-2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.dto;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
* @author Andreas Schildbach
*/
public class StyleTest {
@Test
public void roundTripRGB() {
final int color = Style.parseColor("#123456");
assertEquals(color, Style.rgb(Style.red(color), Style.green(color), Style.blue(color)));
}
@Test
public void parseColor() {
assertEquals(0x11223344, Style.parseColor("#11223344"));
}
@Test
public void parseColor_noOverflow() {
assertEquals(0xffffffff, Style.parseColor("#ffffffff"));
}
@Test
public void parseColor_amendAlpha() {
assertEquals(0xff000000, Style.parseColor("#000000"));
}
@Test(expected = IllegalArgumentException.class)
public void parseColor_failTooShort() {
Style.parseColor("#");
}
@Test(expected = IllegalArgumentException.class)
public void parseColor_failNotANumber() {
Style.parseColor("#11111z");
}
@Test
public void deriveForegroundColorForLightBackground() {
final int acacia = Style.rgb(205, 200, 63);
final int lilac = Style.rgb(197, 163, 202);
final int mint = Style.rgb(121, 187, 146);
final int ochre = Style.rgb(223, 176, 57);
final int orange = Style.rgb(222, 139, 83);
final int ranunculus = Style.rgb(242, 201, 49);
final int rose = Style.rgb(223, 154, 177);
final int vinca = Style.rgb(137, 199, 214);
assertEquals(Style.BLACK, Style.deriveForegroundColor(acacia));
assertEquals(Style.BLACK, Style.deriveForegroundColor(lilac));
assertEquals(Style.BLACK, Style.deriveForegroundColor(mint));
assertEquals(Style.BLACK, Style.deriveForegroundColor(ochre));
assertEquals(Style.BLACK, Style.deriveForegroundColor(orange));
assertEquals(Style.BLACK, Style.deriveForegroundColor(ranunculus));
assertEquals(Style.BLACK, Style.deriveForegroundColor(rose));
assertEquals(Style.BLACK, Style.deriveForegroundColor(vinca));
}
@Test
public void deriveForegroundColorForDarkBackground() {
final int azure = Style.rgb(33, 110, 180);
final int brown = Style.rgb(141, 101, 56);
final int iris = Style.rgb(103, 50, 142);
final int parme = Style.rgb(187, 77, 152);
final int sapin = Style.rgb(50, 142, 91);
assertEquals(Style.WHITE, Style.deriveForegroundColor(azure));
assertEquals(Style.WHITE, Style.deriveForegroundColor(brown));
assertEquals(Style.WHITE, Style.deriveForegroundColor(iris));
assertEquals(Style.WHITE, Style.deriveForegroundColor(parme));
assertEquals(Style.WHITE, Style.deriveForegroundColor(sapin));
}
}

View file

@ -0,0 +1,179 @@
/*
* Copyright 2017 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.dto;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Patrick Kanzler
*/
public class TripTest {
private Trip getDummyTripForChanges(Integer changes, Boolean numChangesNull, Integer mode) {
Trip dummy;
Location from = new Location(LocationType.ANY, null);
Location to = new Location(LocationType.ANY, null);
List<Trip.Leg> legs = getDummyLegsForChanges(mode, changes);
if (numChangesNull) {
dummy = new Trip(null, from, to, legs, null, null, null);
} else {
dummy = new Trip(null, from, to, legs, null, null, changes);
}
return dummy;
}
private List<Trip.Leg> getDummyLegsForChanges(Integer mode, Integer changes) {
Location from = new Location(LocationType.ANY, null);
Location to = new Location(LocationType.ANY, null);
List<Trip.Leg> legs = new LinkedList<>();
Stop departureStop = new Stop(from, null, null, new Date(42), null);
Stop arrivalStop = new Stop(to, new Date(43), null, null, null);
Line dummyLine = new Line(null, null, null, null);
switch (mode) {
case 0:
// only Public
for (int i = 0; i < changes + 1; i++) {
legs.add(new Trip.Public(dummyLine, null, departureStop, arrivalStop, null, null, null));
}
break;
case 1:
// only Individual
for (int i = 0; i < changes + 1; i++) {
legs.add(
new Trip.Individual(Trip.Individual.Type.BIKE, from, new Date(42), to, new Date(43), null, 42));
}
break;
case 2:
// mixed
for (int i = 0; i < changes + 1; i++) {
if ((i % 2) == 0) {
legs.add(new Trip.Individual(Trip.Individual.Type.BIKE, from, new Date(42), to, new Date(43), null,
42));
} else {
legs.add(new Trip.Public(dummyLine, null, departureStop, arrivalStop, null, null, null));
}
}
break;
default:
break;
}
return legs;
}
@Test
public void getNumChangesNullPublic() {
Integer numChangesExpected = 0;
Trip dummy = getDummyTripForChanges(numChangesExpected, true, 0);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 1;
dummy = getDummyTripForChanges(numChangesExpected, true, 0);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 2;
dummy = getDummyTripForChanges(numChangesExpected, true, 0);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
}
@Test
public void getNumChangesNotNullPublic() {
Integer numChangesExpected = 0;
Trip dummy = getDummyTripForChanges(numChangesExpected, false, 0);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 1;
dummy = getDummyTripForChanges(numChangesExpected, false, 0);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 2;
dummy = getDummyTripForChanges(numChangesExpected, false, 0);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
}
@Test
public void getNumChangesNullIndividual() {
Integer numChangesExpected = 0;
Trip dummy = getDummyTripForChanges(numChangesExpected, true, 1);
Assert.assertNull(dummy.getNumChanges());
numChangesExpected = 1;
dummy = getDummyTripForChanges(numChangesExpected, true, 1);
Assert.assertNull(dummy.getNumChanges());
numChangesExpected = 2;
dummy = getDummyTripForChanges(numChangesExpected, true, 1);
Assert.assertNull(dummy.getNumChanges());
}
@Test
public void getNumChangesNotNullIndividual() {
Integer numChangesExpected = 0;
Trip dummy = getDummyTripForChanges(numChangesExpected, false, 1);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 1;
dummy = getDummyTripForChanges(numChangesExpected, false, 1);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 2;
dummy = getDummyTripForChanges(numChangesExpected, false, 1);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
}
@Test
public void getNumChangesNullMixed() {
Integer numChangesExpected = 0;
Trip dummy = getDummyTripForChanges(numChangesExpected, true, 2);
Assert.assertNull(dummy.getNumChanges());
numChangesExpected = 1;
dummy = getDummyTripForChanges(numChangesExpected, true, 2);
numChangesExpected = numChangesExpected - 1;
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 2;
dummy = getDummyTripForChanges(numChangesExpected, true, 2);
numChangesExpected = numChangesExpected - 2;
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 3;
dummy = getDummyTripForChanges(numChangesExpected, true, 2);
numChangesExpected = numChangesExpected - 2;
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
}
@Test
public void getNumChangesNotNullMixed() {
Integer numChangesExpected = 0;
Trip dummy = getDummyTripForChanges(numChangesExpected, false, 2);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 1;
dummy = getDummyTripForChanges(numChangesExpected, false, 2);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
numChangesExpected = 2;
dummy = getDummyTripForChanges(numChangesExpected, false, 2);
Assert.assertEquals(numChangesExpected, dummy.getNumChanges());
}
}

View file

@ -0,0 +1 @@
secrets.properties

View file

@ -0,0 +1,297 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Date;
import java.util.EnumSet;
import java.util.List;
import de.schildbach.pte.NetworkProvider;
import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.dto.LineDestination;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsContext;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.StationDepartures;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
/**
* @author Antonio El Khoury
*/
public abstract class AbstractNavitiaProviderLiveTest extends AbstractProviderLiveTest {
public AbstractNavitiaProviderLiveTest(final NetworkProvider provider) {
super(provider);
}
protected final void nearbyStationsAddress(final int lat, final int lon) throws IOException {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
Location.coord(lat, lon), 700, 10);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
print(result);
}
protected final void nearbyStationsStation(final String stationId) throws IOException {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
new Location(LocationType.STATION, stationId), 700, 10);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
print(result);
}
protected final void nearbyStationsPoi(final String poiId) throws IOException {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
new Location(LocationType.POI, poiId), 700, 10);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
print(result);
}
protected final void nearbyStationsAny(final int lat, final int lon) throws IOException {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
Location.coord(lat, lon), 700, 10);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
print(result);
}
protected final void nearbyStationsStationDistance(final String stationId) throws IOException {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
new Location(LocationType.STATION, stationId), 0, 10);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
assertTrue(result.locations.size() > 1);
print(result);
}
protected final void nearbyStationsInvalidStation(final String stationId) throws IOException {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
new Location(LocationType.STATION, stationId), 700, 10);
assertEquals(NearbyLocationsResult.Status.INVALID_ID, result.status);
print(result);
}
protected final void queryDeparturesEquivsFalse(final String stationId) throws IOException {
final int maxDepartures = 5;
final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, false);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
assertEquals(1, result.stationDepartures.size());
assertTrue(result.stationDepartures.get(0).departures.size() <= maxDepartures);
final List<LineDestination> lines = result.stationDepartures.get(0).lines;
assertNotNull(lines);
assertTrue(lines.size() >= 1);
print(result);
}
protected final void queryDeparturesStopArea(final String stationId) throws IOException {
final int maxDepartures = 5;
final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, true);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
assertTrue(result.stationDepartures.size() > 1);
int nbDepartures = 0;
int nbLines = 0;
for (final StationDepartures stationDepartures : result.stationDepartures) {
nbDepartures += stationDepartures.departures.size();
final List<LineDestination> lines = stationDepartures.lines;
if (lines != null)
nbLines += lines.size();
}
assertTrue(nbDepartures <= maxDepartures);
assertTrue(nbLines >= 2);
print(result);
}
protected final void queryDeparturesEquivsTrue(final String stationId) throws IOException {
final int maxDepartures = 5;
final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, true);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
assertTrue(result.stationDepartures.size() > 1);
int nbDepartures = 0;
int nbLines = 0;
for (StationDepartures stationDepartures : result.stationDepartures) {
nbDepartures += stationDepartures.departures.size();
final List<LineDestination> lines = stationDepartures.lines;
assertNotNull(lines);
nbLines += lines.size();
}
assertTrue(nbDepartures <= maxDepartures);
assertTrue(nbLines >= 2);
print(result);
}
protected final void queryDeparturesInvalidStation(final String stationId) throws IOException {
final QueryDeparturesResult result = queryDepartures(stationId, false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
protected final void suggestLocationsFromName(final CharSequence constraint) throws IOException {
final SuggestLocationsResult result = suggestLocations(constraint);
assertTrue(result.getLocations().size() > 0);
print(result);
}
protected final void suggestLocationsFromAddress(final CharSequence constraint) throws IOException {
final SuggestLocationsResult result = suggestLocations(constraint);
assertTrue(result.getLocations().size() > 0);
print(result);
}
protected final void suggestLocationsNoLocation(final CharSequence constraint) throws IOException {
final SuggestLocationsResult result = suggestLocations(constraint);
assertEquals(result.getLocations().size(), 0);
print(result);
}
protected final void queryTrip(final CharSequence from, final CharSequence to) throws IOException {
final SuggestLocationsResult fromResult = suggestLocations(from);
assertTrue(fromResult.getLocations().size() > 0);
final SuggestLocationsResult toResult = suggestLocations(to);
assertTrue(toResult.getLocations().size() > 0);
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null,
toResult.getLocations().get(0), new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
}
protected final void queryTripNoSolution(final CharSequence from, final CharSequence to) throws IOException {
final SuggestLocationsResult fromResult = suggestLocations(from);
assertTrue(fromResult.getLocations().size() > 0);
final SuggestLocationsResult toResult = suggestLocations(to);
assertTrue(toResult.getLocations().size() > 0);
final TripOptions options = new TripOptions(EnumSet.noneOf(Product.class), null, WalkSpeed.NORMAL,
Accessibility.NEUTRAL, null);
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null,
toResult.getLocations().get(0), new Date(), true, options);
assertEquals(QueryTripsResult.Status.NO_TRIPS, result.status);
print(result);
}
protected final void queryTripUnknownFrom(final CharSequence to) throws IOException {
final SuggestLocationsResult toResult = suggestLocations(to);
assertTrue(toResult.getLocations().size() > 0);
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "stop_area:RTP:SA:999999"), null,
toResult.getLocations().get(0), new Date(), true, null);
assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result.status);
print(result);
}
protected final void queryTripUnknownTo(final CharSequence from) throws IOException {
final SuggestLocationsResult fromResult = suggestLocations(from);
assertTrue(fromResult.getLocations().size() > 0);
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null,
new Location(LocationType.STATION, "stop_area:RTP:SA:999999"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.UNKNOWN_TO, result.status);
print(result);
}
protected final void queryTripAmbiguousFrom(final Location from, final CharSequence to) throws IOException {
final SuggestLocationsResult toResult = suggestLocations(to);
assertTrue(toResult.getLocations().size() > 0);
final QueryTripsResult result = queryTrips(from, null, toResult.getLocations().get(0), new Date(), true, null);
assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status);
assertTrue(result.ambiguousFrom != null);
assertTrue(result.ambiguousFrom.size() > 0);
print(result);
}
protected final void queryTripAmbiguousTo(final CharSequence from, final Location to) throws IOException {
final SuggestLocationsResult fromResult = suggestLocations(from);
assertTrue(fromResult.getLocations().size() > 0);
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, to, new Date(), true, null);
assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status);
assertTrue(result.ambiguousTo != null);
assertTrue(result.ambiguousTo.size() > 0);
print(result);
}
protected final void queryTripSlowWalk(final CharSequence from, final CharSequence to) throws IOException {
final SuggestLocationsResult fromResult = suggestLocations(from);
assertTrue(fromResult.getLocations().size() > 0);
final SuggestLocationsResult toResult = suggestLocations(to);
assertTrue(toResult.getLocations().size() > 0);
final TripOptions options = new TripOptions(Product.ALL, null, WalkSpeed.SLOW, Accessibility.NEUTRAL, null);
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null,
toResult.getLocations().get(0), new Date(), true, options);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
}
protected final void queryTripFastWalk(final CharSequence from, final CharSequence to) throws IOException {
final SuggestLocationsResult fromResult = suggestLocations(from);
assertTrue(fromResult.getLocations().size() > 0);
final SuggestLocationsResult toResult = suggestLocations(to);
assertTrue(toResult.getLocations().size() > 0);
final TripOptions options = new TripOptions(Product.ALL, null, WalkSpeed.FAST, Accessibility.NEUTRAL, null);
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null,
toResult.getLocations().get(0), new Date(), true, options);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
}
protected final void queryTripFromAdminToPoi(final CharSequence from, final CharSequence to) throws IOException {
final SuggestLocationsResult fromResult = suggestLocations(from);
assertTrue(fromResult.getLocations().size() > 0);
Location fromLocation = fromResult.getLocations().get(0);
assertEquals(fromLocation.type, LocationType.POI);
print(fromResult);
final SuggestLocationsResult toResult = suggestLocations(to);
assertTrue(toResult.getLocations().size() > 0);
Location toLocation = toResult.getLocations().get(0);
assertEquals(toLocation.type, LocationType.POI);
print(toResult);
final QueryTripsResult tripsResult = queryTrips(fromLocation, null, toLocation, new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, tripsResult.status);
print(tripsResult);
}
protected final void queryMoreTrips(final CharSequence from, final CharSequence to) throws IOException {
final SuggestLocationsResult fromResult = suggestLocations(from);
assertTrue(fromResult.getLocations().size() > 0);
final SuggestLocationsResult toResult = suggestLocations(to);
assertTrue(toResult.getLocations().size() > 0);
final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null,
toResult.getLocations().get(0), new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
final QueryTripsContext context = result.context;
final QueryTripsResult nextResult = queryMoreTrips(context, true);
assertEquals(QueryTripsResult.Status.OK, nextResult.status);
print(nextResult);
final QueryTripsResult prevResult = queryMoreTrips(context, false);
assertEquals(QueryTripsResult.Status.OK, prevResult.status);
print(prevResult);
}
}

View file

@ -0,0 +1,149 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.EnumSet;
import java.util.Properties;
import java.util.Set;
import javax.annotation.Nullable;
import de.schildbach.pte.NetworkProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsContext;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
/**
* @author Andreas Schildbach
*/
public abstract class AbstractProviderLiveTest {
protected final NetworkProvider provider;
public AbstractProviderLiveTest(final NetworkProvider provider) {
this.provider = provider;
}
protected final void print(final NearbyLocationsResult result) {
System.out.println(result);
// for (final Location location : result.locations)
// System.out.println(location);
}
protected final void print(final QueryDeparturesResult result) {
System.out.println(result);
// for (final StationDepartures stationDepartures : result.stationDepartures)
// for (final Departure departure : stationDepartures.departures)
// System.out.println(departure);
}
protected final void print(final SuggestLocationsResult result) {
System.out.println(result);
// for (final Location location : result.getLocations())
// System.out.println(location);
}
protected final void print(final QueryTripsResult result) {
System.out.println(result);
// for (final Trip trip : result.trips)
// {
// System.out.println(trip);
// for (final Leg leg : trip.legs)
// System.out.println("- " + leg);
// }
}
protected final NearbyLocationsResult queryNearbyStations(final Location location) throws IOException {
return queryNearbyLocations(EnumSet.of(LocationType.STATION), location, 0, 5);
}
protected final NearbyLocationsResult queryNearbyLocations(final Set<LocationType> types, final Location location)
throws IOException {
return queryNearbyLocations(types, location, 0, 5);
}
protected final NearbyLocationsResult queryNearbyLocations(final Set<LocationType> types, final Location location,
final int maxDistance, final int maxStations) throws IOException {
return provider.queryNearbyLocations(types, location, maxDistance, maxStations);
}
protected final QueryDeparturesResult queryDepartures(final String stationId, final boolean equivs)
throws IOException {
return queryDepartures(stationId, 5, equivs);
}
protected final QueryDeparturesResult queryDepartures(final String stationId, final int maxDepartures,
final boolean equivs) throws IOException {
final QueryDeparturesResult result = provider.queryDepartures(stationId, new Date(), maxDepartures, equivs);
if (result.status == QueryDeparturesResult.Status.OK) {
if (equivs)
assertTrue(result.stationDepartures.size() > 1);
else
assertTrue(result.stationDepartures.size() == 1);
}
return result;
}
protected final SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
return provider.suggestLocations(constraint, null, 0);
}
protected final QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
return provider.queryTrips(from, via, to, date, dep, options);
}
protected final QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later)
throws IOException {
return provider.queryMoreTrips(context, later);
}
protected final static String secretProperty(final String key) {
try {
final Properties properties = new Properties();
final String secretPropertiesFilename = "secrets.properties";
final InputStream is = AbstractProviderLiveTest.class.getResourceAsStream(secretPropertiesFilename);
if (is == null)
throw new IllegalStateException(
"Could not find secret property file " + secretPropertiesFilename + " in classpath.");
properties.load(is);
final String secret = properties.getProperty(key);
if (secret == null)
throw new IllegalStateException(
"Could not find secret value for '" + key + "' in " + secretPropertiesFilename + ".");
return secret;
} catch (final IOException x) {
throw new RuntimeException(x);
}
}
}

View file

@ -0,0 +1,305 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import java.io.IOException;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import org.junit.Ignore;
import org.junit.Test;
import de.schildbach.pte.AustraliaProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.Trip;
/**
* Test basic from/to directions for each mode of transport, in each state of Australia supported by Navitia.
* This is mainly to test whether or not the coverage is still in date or not. For example, at time of writing
* Cambera, Alice Springs, and Darwin were all present on Navitia, but out of date so were unable to provide
* journey planning.
*
* These tests work by taking the next Monday at 08:45 (a random peak hour time where you'd expect there to be
* a lot of public transport available). If they are unable to find a route for a specific mode of transport,
* then you should further investigate to see if the data is out of date or not in Navitia.
*
* Note that by default, only Melbourne is tested comprehensively to prevent running into API limits
* ({@see #RUN_EXPENSIVE_TESTS}).
*/
public class AustraliaProviderLiveTest extends AbstractNavitiaProviderLiveTest {
/**
* If enabled, the entire set of tests will run, resulting in over 30 API calls to Navitia. Given this
* test may or may not be run under, e.g. continuous integration, or run frequently while working on the
* Australian API, it could end up using up your API limit unneccesarily. Thus, the default value is to
* only perform a proper test of Melbourne, and the rest of the coverage is disabled until this flag is
* true.
*/
private static final boolean RUN_EXPENSIVE_TESTS = false;
public AustraliaProviderLiveTest() {
super(new AustraliaProvider(secretProperty("navitia.authorization")));
}
/**
* Ensures that each of the suburban/rural trains, trams, and buses are represented in the journey
* planning and location suggestion API. Based on travelling around the Camberwell area:
* http://www.openstreetmap.org/#map=15/-37.8195/145.0586&layers=T
*/
@Test
public void melbourne() throws IOException {
final Location suburbanTrainStation = assertAndGetLocation("Camberwell Railway Station (Camberwell)");
final Location ruralTrainStation = assertAndGetLocation("Geelong Railway Station (Geelong)");
assertJourneyExists(AustraliaProvider.NETWORK_PTV, new String[] { "Lilydale", "Belgrave", "Alamein" },
suburbanTrainStation, ruralTrainStation);
final Location tramStop = assertAndGetLocation("70-Cotham Rd/Burke Rd (Kew)");
assertJourneyExists(AustraliaProvider.NETWORK_PTV, "72", suburbanTrainStation, tramStop);
final Location busStop = assertAndGetLocation("Lawrence St/Burke Rd (Kew East)");
assertJourneyExists(AustraliaProvider.NETWORK_PTV, "548", tramStop, busStop);
}
@Test
public void adelaideRail() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location railwayStation = assertAndGetLocation("Woodville Park Railway Station");
final Location railwayStation2 = assertAndGetLocation("Unley Park Railway Station");
assertJourneyExists(AustraliaProvider.NETWORK_SA, new String[] { "GRNG", "BEL", "OUTHA" }, railwayStation,
railwayStation2);
}
@Test
public void adelaideBus() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location busStation = assertAndGetLocation("Stop 137 Portrush Rd - East side");
final Location busStation2 = assertAndGetLocation("Stop 144 Portrush Rd - East side");
assertJourneyExists(AustraliaProvider.NETWORK_SA, "300", busStation, busStation2);
}
@Test
public void adelaideTram() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location tramStation = assertAndGetLocation("Stop 15 Dunbar Tce - Brighton Rd");
final Location tramStation2 = assertAndGetLocation("Stop 5 Black Forest");
assertJourneyExists(AustraliaProvider.NETWORK_SA, "Tram", tramStation, tramStation2);
}
@Test
public void perthTrain() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location railwayStation = assertAndGetLocation("Kenwick Stn");
final Location railwayStation2 = assertAndGetLocation("Warwick Stn");
assertJourneyExists(AustraliaProvider.NETWORK_WA, "", railwayStation, railwayStation2);
}
@Test
public void perthBus() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location bus = assertAndGetLocation("Curtin University");
final Location bus2 = assertAndGetLocation("Murdoch Stn");
assertJourneyExists(AustraliaProvider.NETWORK_WA, "", bus, bus2);
}
@Test
public void perthFerry() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location ferry = assertAndGetLocation("Elizabeth Quay Stn");
final Location ferry2 = assertAndGetLocation("Ferry Route Mends St Jetty");
assertJourneyExists(AustraliaProvider.NETWORK_WA, "", ferry, ferry2);
}
@Test
public void brisbaneRail() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location railwayStation = assertAndGetLocation("Beenleigh station");
final Location railwayStation2 = assertAndGetLocation("Ipswich station");
assertJourneyExists(AustraliaProvider.NETWORK_QLD, "BNFG", railwayStation, railwayStation2);
}
@Test
public void brisbaneFerry() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location ferry = assertAndGetLocation("Broadbeach South");
final Location ferry2 = assertAndGetLocation("Southport");
assertJourneyExists(AustraliaProvider.NETWORK_QLD, "GLKN", ferry, ferry2);
}
@Test
public void brisbaneTram() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location tram = assertAndGetLocation("South Bank 2 ferry terminal");
final Location tram2 = assertAndGetLocation("Guyatt Park ferry terminal");
assertJourneyExists(AustraliaProvider.NETWORK_QLD, "UQSL", tram, tram2);
}
@Test
public void hobartBus() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location bus = assertAndGetLocation("Stop 15, No.237 New Town Rd");
final Location bus2 = assertAndGetLocation("Stop 2, No.131 Elizabeth St");
assertJourneyExists(AustraliaProvider.NETWORK_TAS, "504", bus, bus2);
}
@Test
public void launcestonBus() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location bus = assertAndGetLocation("Riverside Dr / Rannoch Ave");
final Location bus2 = assertAndGetLocation("Trevallyn Shops");
assertJourneyExists(AustraliaProvider.NETWORK_TAS, "90", bus, bus2);
}
@Test
public void bernieBus() throws IOException {
assumeTrue(RUN_EXPENSIVE_TESTS);
final Location bus = assertAndGetLocation("Stop 31, 197 Mount St");
final Location bus2 = assertAndGetLocation("Burnie Park opposite 55 West Park Gr");
assertJourneyExists(AustraliaProvider.NETWORK_TAS, "12", bus, bus2);
}
// Although Navitia has a GTFS feed for ACT, Darwin, and Alice Springs, they were out of date at time of
// writing.
@Test
@Ignore
public void act() {
}
@Test
@Ignore
public void darwin() {
}
@Test
@Ignore
public void aliceSprings() {
}
/**
* Suggests locations similar to {@param locationName}, but then ensures that one matches exactly and then
* returns it. Try not to use an ambiguous name such as "Central Station", because it may exist in several
* datasets on Navitia.
*/
private Location assertAndGetLocation(String locationName) throws IOException {
SuggestLocationsResult locations = suggestLocations(locationName);
assertEquals(SuggestLocationsResult.Status.OK, locations.status);
assertTrue(locations.getLocations().size() > 0);
StringBuilder nonMatching = new StringBuilder();
for (Location location : locations.getLocations()) {
if (locationName.equals(location.name)) {
return location;
}
nonMatching.append('[').append(location.name).append("] ");
}
throw new AssertionError(
"suggestLocations() did not find \"" + locationName + "\". Options were: " + nonMatching);
}
/**
* @see #assertJourneyExists(String, String[], Location, Location)
*/
private void assertJourneyExists(String network, String eligibleLine, Location from, Location to)
throws IOException {
assertJourneyExists(network, new String[] { eligibleLine }, from, to);
}
private Date getNextMondayMorning() {
Calendar date = Calendar.getInstance();
date.setTime(new Date());
date.set(Calendar.HOUR_OF_DAY, 8);
date.set(Calendar.MINUTE, 45);
while (date.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
date.add(Calendar.DATE, 1);
}
return date.getTime();
}
private void assertJourneyExists(String network, String[] eligibleLines, Location from, Location to)
throws IOException {
QueryTripsResult trips = queryTrips(from, null, to, getNextMondayMorning(), true, null);
assertNull(trips.ambiguousFrom);
assertNull(trips.ambiguousTo);
assertEquals(QueryTripsResult.Status.OK, trips.status);
assertNotNull(trips.trips);
assertTrue(trips.trips.size() > 0);
Set<String> eligibleLineSet = new HashSet<>();
Collections.addAll(eligibleLineSet, eligibleLines);
for (Trip trip : trips.trips) {
boolean hasPublicTransport = false;
boolean matchesCode = false;
for (Trip.Leg leg : trip.legs) {
if (leg instanceof Trip.Public) {
hasPublicTransport = true;
Trip.Public publicLeg = (Trip.Public) leg;
assertEquals(network, publicLeg.line.network);
if (eligibleLineSet.contains(publicLeg.line.label)) {
matchesCode = true;
}
}
}
if (hasPublicTransport && matchesCode) {
return;
}
}
StringBuilder sb = new StringBuilder();
for (Trip trip : trips.trips) {
sb.append("\n ");
for (Trip.Leg leg : trip.legs) {
String via = leg instanceof Trip.Public ? " (via " + ((Trip.Public) leg).line.label + ") " : " -> ";
sb.append('[').append(leg.arrival.name).append(']').append(via).append('[').append(leg.departure.name)
.append(']').append(" ... ");
}
}
fail("No public trip found between [" + from.name + "] and [" + to.name
+ "] using appropriate line. Found trips:" + sb);
}
}

View file

@ -0,0 +1,155 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.AvvAachenProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class AvvAachenProviderLiveTest extends AbstractProviderLiveTest {
public AvvAachenProviderLiveTest() {
super(new AvvAachenProvider(secretProperty("avv_aachen.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(50767803, 6091504));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("1008", false);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Aachen Hbf");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "1008", "Aachen", "Hbf")));
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Gaßmühle");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "1576", "Aachen", "Gaßmühle")));
}
@Test
public void suggestLocationsPOI() throws Exception {
final SuggestLocationsResult result = suggestLocations("Suermondt-Ludwig-Museum");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.POI,
"A=4@O=Aachen, Suermondt Ludwig Museum@X=6095720@Y=50773376@U=105@L=009900147@B=1@p=1515630730@")));
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Theaterstraße 49");
print(result);
assertEquals("Aachen", result.getLocations().get(0).place);
assertEquals("Theaterstraße 49", result.getLocations().get(0).name);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "1008", "Aachen", "Hbf");
final Location to = new Location(LocationType.STATION, "1016", "Aachen", "Schanz");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
final QueryTripsResult later3Result = queryMoreTrips(earlierResult.context, true);
print(later3Result);
}
@Test
public void shortViaTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "1008", "Aachen", "Hbf");
final Location via = new Location(LocationType.STATION, "1341", "Aachen", "Kellerhausstraße");
final Location to = new Location(LocationType.STATION, "3339", "Gulpen", "Busstation");
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenStations() throws Exception {
final Location from = new Location(LocationType.STATION, "1008", "Aachen", "Hbf");
final Location to = new Location(LocationType.STATION, "3339", "Gulpen", "Busstation");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(50767803, 6091504); // Aachen Hbf
final Location to = Location.coord(50769870, 6073840); // Aachen, Schanz
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals("1008", result.from.id);
assertEquals("1016", result.to.id);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, "Aachen", "Theaterstraße 49");
final Location to = new Location(LocationType.ADDRESS, null, "Aachen", "Jakobstraße 109");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripWithoutId() throws Exception {
final Location from = new Location(LocationType.STATION, null, "Aachen", "Hbf");
final Location to = new Location(LocationType.STATION, null, "Aachen", "Schanz");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals("1008", result.from.id);
assertEquals("1016", result.to.id);
}
}

View file

@ -0,0 +1,122 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.AvvAugsburgProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class AvvAugsburgProviderLiveTest extends AbstractProviderLiveTest {
public AvvAugsburgProviderLiveTest() {
super(new AvvAugsburgProvider(secretProperty("avv_augsburg.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(
Location.coord(Point.fromDouble(48.3652470, 10.8855950))); // Hbf
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("8000013", false); // Hbf
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Augsburg");
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlautBarfuesserbruecke() throws Exception {
final SuggestLocationsResult result = suggestLocations("Barfüßerbrücke");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "780110")));
}
@Test
public void suggestLocationsWithUmlautGaertnerstrasse() throws Exception {
final SuggestLocationsResult result = suggestLocations("Gärtnerstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "780162")));
}
@Test
public void suggestLocationsPOI() throws Exception {
final SuggestLocationsResult result = suggestLocations("Fuggerei-Museum");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.POI,
"A=4@O=Augsburg, Fuggerei-Museum (Kultur und Unterhaltung@X=10904796@Y=48369103@U=104@L=990379647@B=1@p=1410875982@")));
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Milchberg 6");
print(result);
assertEquals("Augsburg", result.getLocations().get(0).place);
assertEquals("Milchberg 6", result.getLocations().get(0).name);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "781971"); // Königsplatz
final Location to = new Location(LocationType.STATION, "8000013"); // Hbf
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,112 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.AvvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class AvvProviderLiveTest extends AbstractProviderLiveTest {
public AvvProviderLiveTest() {
super(new AvvProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "100"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48367233, 10894976));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("100", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result1 = suggestLocations("Barfüßerbrücke");
print(result1);
assertThat(result1.getLocations(), hasItem(new Location(LocationType.STATION, "2000131")));
final SuggestLocationsResult result2 = suggestLocations("Gärtnerstraße");
print(result2);
assertThat(result2.getLocations(), hasItem(new Location(LocationType.STATION, "2000557")));
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "101", null, "Königsplatz"), null,
new Location(LocationType.STATION, "100", null, "Hauptbahnhof"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,215 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.EnumSet;
import org.junit.Test;
import de.schildbach.pte.BayernProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class BayernProviderLiveTest extends AbstractProviderLiveTest {
public BayernProviderLiveTest() {
super(new BayernProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "3001459"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(
Location.coord(Point.fromDouble(48.1331686, 11.5580299))); // München, Beethovenplatz
print(result);
assertTrue(result.locations.size() > 0);
}
@Test
public void nearbyLocationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION, LocationType.POI),
Location.coord(48135232, 11560650));
print(result);
assertTrue(result.locations.size() > 0);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult munichOstbahnhof = queryDepartures("80000793", false);
print(munichOstbahnhof);
final QueryDeparturesResult munichHauptbahnhof = queryDepartures("80000689", false);
print(munichHauptbahnhof);
final QueryDeparturesResult nurembergHauptbahnhof = queryDepartures("80001020", false);
print(nurembergHauptbahnhof);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Marien");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("München Mühldorfstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "1000921")));
}
@Test
public void suggestLocationsRegensburg() throws Exception {
final SuggestLocationsResult result = suggestLocations("Regensburg");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "80001083")));
}
@Test
public void suggestLocationsMunich() throws Exception {
final SuggestLocationsResult result = suggestLocations("München");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "91000100")));
}
@Test
public void suggestLocationsNuernberg() throws Exception {
final SuggestLocationsResult result = suggestLocations("Nürnberg");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "80001020")));
}
@Test
public void suggestPOI() throws Exception {
final SuggestLocationsResult result = suggestLocations("Ruhpolding, Seehaus");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.POI,
"poiID:40502661:9189140:-1:Seehaus:Ruhpolding:Seehaus:ANY:POI:1405062:5941100:MRCV:BAY")));
}
@Test
public void suggestAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("München, Friedenstraße 2");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:1500002757:2:9162000:-1:Friedenstraße:München:Friedenstraße::Friedenstraße:81671:ANY:DIVA_SINGLEHOUSE:1291659:5872432:MRCV:BAY")));
}
@Test
public void suggestStreet() throws Exception {
final SuggestLocationsResult result = suggestLocations("München, Friedenstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:1500002757::9162000:-1:Friedenstraße:München:Friedenstraße::Friedenstraße: 81671:ANY:DIVA_STREET:1292298:5871791:MRCV:BAY")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof");
final Location to = new Location(LocationType.STATION, "80000799", "München", "Pasing");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void longTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "1005530", "Starnberg", "Arbeitsamt");
final Location to = new Location(LocationType.STATION, "3001459", "Nürnberg", "Fallrohrstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(48165238, 11577473);
final Location to = Location.coord(47987199, 11326532);
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenCoordinateAndStation() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48238341, 11478230));
final Location to = new Location(LocationType.STATION, "80000793", "München", "Ostbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, null, "München, Maximilianstr. 1");
final Location to = new Location(LocationType.ADDRESS, null, null, "Starnberg, Jahnstraße 50");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenStationAndAddress() throws Exception {
final Location from = new Location(LocationType.STATION, "1001220", null, "Josephsburg");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(48188018, 11574239), null,
"München Frankfurter Ring 35");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenPOIs() throws Exception {
final Location from = new Location(LocationType.POI,
"poiID:40499046:9189140:-1:Seehaus:Ruhpolding:Seehaus:ANY:POI:1405062:5941100:MRCV:BAY", "Ruhpolding",
"Seehaus");
final Location to = new Location(LocationType.POI,
"poiID:40215904:9189140:-1:Alpengasthof Laubau:Ruhpolding:Alpengasthof Laubau:ANY:POI:1409082:5938642:MRCV:BAY",
"Ruhpolding", "Alpengasthof Laubau");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripRegensburg() throws Exception {
final Location from = new Location(LocationType.STATION, "4014051", "Regensburg", "Klenzestraße");
final Location to = new Location(LocationType.STATION, "4014080", "Regensburg", "Universität");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,57 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import org.junit.Test;
import de.schildbach.pte.BritishColumbiaProvider;
import de.schildbach.pte.dto.Location;
/**
* @author Stephane Berube
*/
public class BritishColumbiaProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public BritishColumbiaProviderLiveTest() {
super(new BritishColumbiaProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:VTA:SP:100084");
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
queryNearbyStations(Location.coord(48428611, -123365556));
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDepartures("stop_point:VTA:SP:xxxxxx", false);
}
@Test
public void queryDepartures() throws Exception {
queryDepartures("VTA:SP:100084", false);
}
@Test
public void suggestLocations() throws Exception {
suggestLocations("Airport");
}
}

View file

@ -0,0 +1,115 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.BsvagProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class BsvagProviderLiveTest extends AbstractProviderLiveTest {
public BsvagProviderLiveTest() {
super(new BsvagProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "26000178"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52272065, 10524788));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("26000256", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kurf");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Münzstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "26000300")));
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult braunschweigResult = suggestLocations("Braunschweig Rhönweg");
print(braunschweigResult);
assertThat(braunschweigResult.getLocations(), hasItem(new Location(LocationType.STATION, "26000351")));
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "26000178", null, "Hauptbahnhof"),
null, new Location(LocationType.STATION, "26000322", null, "Packhof"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,251 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.BvgProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class BvgProviderLiveTest extends AbstractProviderLiveTest {
public BvgProviderLiveTest() {
super(new BvgProvider(secretProperty("bvg.api_authorization")));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "900220302"));
assertEquals(NearbyLocationsResult.Status.OK, result.status);
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52486400, 13350744));
print(result);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "2449475"));
assertEquals(NearbyLocationsResult.Status.INVALID_ID, result.status);
}
@Test
public void queryDeparturesWilmsstrasse() throws Exception {
final QueryDeparturesResult result = queryDepartures("900016254", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesAlexanderplatzBhf() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100003", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesAlexanderplatzU2() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100703", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesAlexanderplatzU5() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100704", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesAlexanderplatzU8() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100705", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesEquivs() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100003", true);
print(result);
assertTrue(result.stationDepartures.size() > 1);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Güntzelstr.");
print(result);
assertThat(result.getLocations(),
hasItem(new Location(LocationType.STATION, "900043201", "Berlin", "U Güntzelstr.")));
}
@Test
public void suggestLocationsLocality() throws Exception {
final SuggestLocationsResult result = suggestLocations("seeling");
print(result);
assertEquals(new Location(LocationType.STATION, null, "Berlin", "Seelingstr."), result.getLocations().get(0));
}
@Test
public void suggestLocationsPOI() throws Exception {
final SuggestLocationsResult result = suggestLocations("schwules museum");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.POI,
"A=4@O=Berlin, Schwules Museum@X=13357979@Y=52504519@U=104@L=900980141@B=1@p=1540465509@")));
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Berlin, Sophienstr. 24");
print(result);
assertEquals("Sophienstr. 24", result.getLocations().get(0).name);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("nol");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "900056102", "Berlin", "Nollendorfplatz"), null,
new Location(LocationType.STATION, "900013103", "Berlin", "Prinzenstraße"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
final QueryTripsResult later3Result = queryMoreTrips(earlierResult.context, true);
print(later3Result);
}
@Test
public void tripBetweenStations() throws Exception {
final Location from = new Location(LocationType.STATION, "900055101", Point.from1E6(52496176, 13343273), null,
"U Viktoria-Luise-Platz");
final Location to = new Location(LocationType.STATION, "900089303", Point.from1E6(52588810, 13288699), null,
"S Tegel");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void shortViaTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "900056102", "Berlin", "Nollendorfplatz"),
new Location(LocationType.STATION, "900044202", "Berlin", "Bundesplatz"),
new Location(LocationType.STATION, "900013103", "Berlin", "Prinzenstraße"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final QueryTripsResult result = queryTrips(Location.coord(52501507, 13357026), null,
Location.coord(52513639, 13568648), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinatesAndAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52536099, 13426309), null,
"Christburger Straße 1, 10405 Berlin, Deutschland");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52486400, 13350744), null,
"Eisenacher Straße 70, 10823 Berlin, Deutschland");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void viaTripBetweenCoordinates() throws Exception {
final QueryTripsResult result = queryTrips(Location.coord(52501507, 13357026),
Location.coord(52479868, 13324247), Location.coord(52513639, 13568648), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278),
"10715 Berlin-Wilmersdorf", "Weimarische Str. 7");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52541536, 13421290),
"10437 Berlin-Prenzlauer Berg", "Göhrener Str. 5");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void viaTripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278),
"10715 Berlin-Wilmersdorf", "Weimarische Str. 7");
final Location via = new Location(LocationType.ADDRESS, null, Point.from1E6(52527872, 13381657),
"10115 Berlin-Mitte", "Hannoversche Str. 20");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52526029, 13399878),
"10178 Berlin-Mitte", "Sophienstr. 24");
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripAddressWithoutId() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52481922, 13388383), null,
"Bayernring, 12101 Berlin, Deutschland");
final Location to = new Location(LocationType.STATION, "900064301", Point.from1E6(52429099, 13328081), null,
"S Lichterfelde Ost Bhf");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,117 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.Date;
import java.util.EnumSet;
import org.junit.Test;
import de.schildbach.pte.CmtaProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Colin Murphy
*/
public class CmtaProviderLiveTest extends AbstractProviderLiveTest {
public CmtaProviderLiveTest() {
super(new CmtaProvider());
}
@Test(expected = IllegalArgumentException.class)
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "591"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(30275000, -97740000));
print(result);
assertThat(result.locations, hasItem(new Location(LocationType.STATION, "591")));
}
@Test
public void nearbyPOIsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.POI),
Location.coord(30275000, -97740000));
print(result);
assertThat(result.locations,
hasItem(new Location(LocationType.POI,
"A=4@O=Texas State Capitol@X=-97740215@Y=30275103@u=0@U=130@L=9819105@",
Point.from1E6(30275103, -97740215), null, "Texas State Capitol")));
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("591", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", 0, false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Capitol Station");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "591")));
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "591", null, "Capitol Station (NB)"), null,
new Location(LocationType.STATION, "5940", null, "Lavaca/17th (Midblock)"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void addressTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ADDRESS, null, null, "1501 Colorado St"),
null, new Location(LocationType.ADDRESS, null, null, "4299 Duval St"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,203 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.Date;
import java.util.EnumSet;
import org.junit.Test;
import de.schildbach.pte.AbstractHafasClientInterfaceProvider;
import de.schildbach.pte.DbProvider;
import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
/**
* @author Andreas Schildbach
*/
public class DbProviderLiveTest extends AbstractProviderLiveTest {
public DbProviderLiveTest() {
super(new DbProvider(secretProperty("db.api_authorization"), AbstractHafasClientInterfaceProvider
.decryptSalt(secretProperty("db.encrypted_salt"), secretProperty("hci.salt_encryption_key"))));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52525589, 13369548));
print(result);
}
@Test
public void nearbyPOIsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.POI),
Location.coord(Point.fromDouble(52.5304903, 13.3791152)));
print(result);
assertThat(result.locations, hasItem(new Location(LocationType.POI,
"A=4@O=Berlin, Museum für Naturkunde (Kultur und Unterhal@X=13380003@Y=52529724@u=0@U=104@L=991597061@",
"Berlin", "Museum für Naturkunde")));
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("692991", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult resultLive = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, resultLive.status);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Güntzelstr. (U)");
print(result);
assertThat(result.getLocations(),
hasItem(new Location(LocationType.STATION, "731371", "Berlin", "Güntzelstr. (U)")));
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dammt");
print(result);
assertThat(result.getLocations(),
hasItem(new Location(LocationType.STATION, "8002548", null, "Hamburg Dammtor")));
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Berlin");
print(result);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("München, Friedenstraße 2");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"A=2@O=München - Berg am Laim, Friedenstraße 2@X=11602251@Y=48123949@U=103@L=980857648@B=1@p=1378873973@",
"München - Berg am Laim", "Friedenstraße 2")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "8011160", null, "Berlin Hbf");
final Location to = new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
final QueryTripsResult later3Result = queryMoreTrips(earlierResult.context, true);
print(later3Result);
}
@Test
public void slowTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "732655", Point.from1E6(52535576, 13422171), null,
"Marienburger Str., Berlin");
final Location to = new Location(LocationType.STATION, "623234", Point.from1E6(48000221, 11342490), null,
"Tutzinger-Hof-Platz, Starnberg");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void noTrips() throws Exception {
final Location from = new Location(LocationType.STATION, "513729", null, "Schillerplatz, Kaiserslautern");
final Location to = new Location(LocationType.STATION, "403631", null, "Trippstadt Grundschule");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripWithFootway() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52517139, 13388749), null,
"Berlin - Mitte, Unter den Linden 24");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(47994243, 11338543), null,
"Starnberg, Possenhofener Straße 13");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripsAcrossBorder() throws Exception {
final TripOptions options = new TripOptions(EnumSet.of(Product.BUS), null, WalkSpeed.NORMAL,
Accessibility.NEUTRAL, null);
final Location from = new Location(LocationType.STATION, "8506131", null, "Kreuzlingen");
final Location to = new Location(LocationType.STATION, "8003400", null, "Konstanz");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, options);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(52535576, 13422171); // Berlin Marienburger Str.
final Location to = Location.coord(52525589, 13369548); // Berlin Hbf
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripsTooClose() throws Exception {
final Location location = new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf");
final QueryTripsResult result = queryTrips(location, null, location, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.TOO_CLOSE, result.status);
}
@Test
public void tripsInvalidDate() throws Exception {
final Location from = new Location(LocationType.STATION, "8011160", null, "Berlin Hbf");
final Location to = new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf");
final Date date = new Date(System.currentTimeMillis() - 2 * 365 * 24 * 3600 * 1000l); // 2 years ago
final QueryTripsResult result = queryTrips(from, null, to, date, true, null);
print(result);
assertEquals(QueryTripsResult.Status.INVALID_DATE, result.status);
}
@Test
public void tripBetweenAreas() throws Exception {
final Location from = new Location(LocationType.STATION, "8096021"); // FRANKFURT(MAIN)
final Location to = new Location(LocationType.STATION, "8096022"); // KÖLN
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,126 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.DingProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class DingProviderLiveTest extends AbstractProviderLiveTest {
public DingProviderLiveTest() {
super(new DingProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "90001611"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48401092, 9992037));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("90001611", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Ulm, Justizgebäude");
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result1 = suggestLocations("Schießstände");
print(result1);
assertThat(result1.getLocations(), hasItem(new Location(LocationType.STATION, "9001233")));
final SuggestLocationsResult result2 = suggestLocations("Blücherstraße");
print(result2);
assertThat(result2.getLocations(), hasItem(new Location(LocationType.STATION, "9001351")));
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "9001011", "Ulm", "Justizgebäude"), null,
new Location(LocationType.STATION, "9001010", "Ulm", "Theater"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripAnyToAny() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Hermaringen"), null,
new Location(LocationType.ANY, null, null, "Heidenheim"), new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.DsbProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class DsbProviderLiveTest extends AbstractProviderLiveTest {
public DsbProviderLiveTest() {
super(new DsbProvider(secretProperty("dsb.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(55670305, 12554169));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("860430302", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Airport");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "900000011", null, "Copenhagen Airport");
final Location to = new Location(LocationType.POI, "551922500", null, "Billund Airport");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(55.6724746, 12.5649895)); // Copenhagen Central
// Station
final Location to = Location.coord(Point.fromDouble(55.6650983, 12.5595897)); // Dybbølsbro
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,87 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.DubProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class DubProviderLiveTest extends AbstractProviderLiveTest {
public DubProviderLiveTest() {
super(new DubProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "3500131"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(25269008, 55312672));
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Airport");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "3505565", null, "Airport Terminal 1, Arrival"), null,
new Location(LocationType.STATION, "3505445", null, "Airport Terminal 3"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,94 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.EireannProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class EireannProviderLiveTest extends AbstractProviderLiveTest {
public EireannProviderLiveTest() {
super(new EireannProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8013500"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(53343993, -6267371));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("8013500", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dublin");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Busáras");
print(result);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dorfstrasse 10, Dällikon, Schweiz");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "8052281", null, "Dublin Rd (GMIT)"), null,
new Location(LocationType.STATION, "8013100", null, "Dublin Airport (Atrium Road)"), new Date(), true,
null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,145 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.FinlandProvider;
import de.schildbach.pte.dto.Point;
/**
* @author Adrian Perez de Castro <aperez@igalia.com>
*/
public class FinlandProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public FinlandProviderLiveTest() {
super(new FinlandProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
nearbyStationsAddress(60160920, 24941870);
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:OFI:SP:1050412");
}
@Test
public void nearbyStationsPoi() throws Exception {
nearbyStationsPoi("poi:osm:way:29071686");
}
@Test
public void nearbyStationsAny() throws Exception {
nearbyStationsAny(60160920, 24941870);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:9999999999");
}
@Test
public void queryDeparturesStopArea() throws Exception {
queryDeparturesStopArea("stop_area:OFI:SA:1000201");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:OFI:SP:1050412");
}
@Test
public void queryDeparturesEquivsTrue() throws Exception {
queryDeparturesEquivsTrue("stop_area:OFI:SA:1000201");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:OFI:SP:999999");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("postitalo");
}
@Test
public void suggestLocationsFromAddress() throws Exception {
suggestLocationsFromAddress("10 yrjönkatu");
}
@Test
public void suggestLocationsNoLocation() throws Exception {
suggestLocationsNoLocation("fontana di trevi blah blah");
}
@Test
public void queryTripAddresses() throws Exception {
queryTrip("Yrjönkatu, 10, Helsinki", "Kolmas Linja, 5, Helsinki");
}
@Test
public void queryTripAddressStation() throws Exception {
queryTrip("Viides Linja, 3, Helsinki", "Kapylän asema");
}
@Test
public void queryTripStations() throws Exception {
queryTrip("Kapylän asema", "Päärautatieasema");
}
@Test
public void queryTripNoSolution() throws Exception {
queryTripNoSolution("Steissi, Helsinki", "Keskuskatu 1, Kuopio");
}
@Test
public void queryTripUnknownFrom() throws Exception {
queryTripUnknownFrom("Rautatieasema");
}
@Test
public void queryTripUnknownTo() throws Exception {
queryTripUnknownTo("Rautatieasema");
}
@Test
public void queryTripSlowWalk() throws Exception {
queryTripSlowWalk("Rautatieasema", "Postitalo");
}
@Test
public void queryTripFastWalk() throws Exception {
queryTripFastWalk("Rautatieasema", "Postitalo");
}
@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("Steissi", "Töölöntori");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,198 @@
/*
* Copyright 2015-2016 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.FranceNorthEastProvider;
import de.schildbach.pte.dto.Point;
/**
* @author Nicolas Derive
* @author Stéphane Guillou
*/
public class FranceNorthEastProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public FranceNorthEastProviderLiveTest() {
super(new FranceNorthEastProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
// stations close to those coordinates (lat, lon)
// no decimal point, has to include 6 decimal places
nearbyStationsAddress(48573410, 7752110);
}
@Test
public void nearbyStationsAddress2() throws Exception {
// different test case for stations close to coordinates (lat, lon)
// no decimal point, has to include 6 decimal places
nearbyStationsAddress(48598480, 7761790);
}
@Test
public void nearbyStationsStation() throws Exception {
// station to find other stations around
// look in NTFS file for a stop_id (that contains "SP") and apend to "stop_point:"
nearbyStationsStation("stop_point:OST:SP:HOFER_11");
}
@Test
public void nearbyStationsPoi() throws Exception {
// POI to find stations around
// search OSM for a node, use identifier after
// "https://www.openstreetmap.org/node/" and apend it to "poi:n"
nearbyStationsPoi("poi:n39224822");
}
@Test
public void nearbyStationsAny() throws Exception {
// coordinates to find stations around
nearbyStationsAny(48573410, 7752110);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
// station that does not exist?
nearbyStationsInvalidStation("stop_point:RTP:SP:392");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
// what is it for??
queryDeparturesEquivsFalse("stop_point:OST:SP:HOFER_11");
}
@Test
public void queryDeparturesStopArea() throws Exception {
// what is it for??
// has to be an existing stop area (i.e. ID contains "SA")
queryDeparturesStopArea("stop_area:OST:SA:CTPHOFER_04");
}
@Test
public void queryDeparturesEquivsTrue() throws Exception {
// what is it for??
// can be the same to queryDeparturesEquivsFalse
queryDeparturesEquivsTrue("stop_point:OST:SP:HOFER_11");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
// station that does not exist
queryDeparturesInvalidStation("stop_point:OBO:SP:999999");
}
@Test
public void suggestLocations() throws Exception {
// start of a place name that should return something
suggestLocationsFromName("Observat");
}
@Test
public void suggestLocationsFromAddress() throws Exception {
// start of an address that should return something
suggestLocationsFromAddress("16 quai Saint");
}
@Test
public void suggestLocationsNoLocation() throws Exception {
// fake place that will not return results
suggestLocationsNoLocation("quinconcesadasdjkaskd");
}
@Test
public void queryTripAddresses() throws Exception {
// two existing addresses to define a trip
queryTrip("16 quai Saint-Nicolas Strasbourg", "37 rue Voltaire Vendenheim");
}
@Test
public void queryTripAddressStation() throws Exception {
// one existing address and one existing station to define a trip
queryTrip("16 quai Saint-Nicolas Strasbourg", "Illkirch Lixenbuhl");
}
@Test
public void queryTripStations() throws Exception {
// two existing stops to define a trip
queryTrip("Mathieu Zell", "Illkirch Lixenbuhl");
}
@Test
public void queryTripStations2() throws Exception {
// two existing stations for a trip, second test case
queryTrip("Homme de Fer", "Général Lejeune");
}
@Test
public void queryTripStations3() throws Exception {
// two existing stations for a trip, third test case
queryTrip("Eurofret", "Gare aux Marchandises");
}
@Test
public void queryTripStationsRapidTransit() throws Exception {
// two existing stations for "rapid transit"... ?
queryTrip("Observatoire Strasbourg", "Porte de l'Hôpital Strasbourg");
}
@Test
public void queryTripNoSolution() throws Exception {
// two existing stations that are not connected
queryTripNoSolution("Homme de Fer Strasbourg", "Villers Mairie Villers-Les-Nancy");
}
@Test
public void queryTripUnknownFrom() throws Exception {
// existing station for end of trip, don't know where from
queryTripUnknownFrom("Homme de Fer Strasbourg");
}
@Test
public void queryTripUnknownTo() throws Exception {
// existing station to start from, don't know where to
queryTripUnknownTo("Homme de Fer Strasbourg");
}
@Test
public void queryTripSlowWalk() throws Exception {
// two addresses for a "slow walk"
queryTripSlowWalk("16 quai Saint-Nicolas Strasbourg", "5 rue du Travail Strasbourg");
}
@Test
public void queryTripFastWalk() throws Exception {
// two addresses for a "fast walk", can be same as above
queryTripFastWalk("16 quai Saint-Nicolas Strasbourg", "5 rue du Travail Strasbourg");
}
@Test
public void queryMoreTrips() throws Exception {
// two addresses to show more trip options, can be same as above
queryMoreTrips("16 quai Saint-Nicolas Strasbourg", "5 rue du Travail Strasbourg");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright 2010-2016 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.FranceNorthWestProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Patrick Kanzler
*/
public class FranceNorthWestProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public FranceNorthWestProviderLiveTest() {
super(new FranceNorthWestProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(
new Location(LocationType.STATION, "stop_point:ORE:SP:1016"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48109710, -16793391));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("stop_point:ORE:SP:1016", 10, false);
print(result);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Anne");
print(result);
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,164 @@
/*
* Copyright 2016 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import org.junit.Assert;
import org.junit.Test;
import de.schildbach.pte.FranceSouthEastProvider;
import de.schildbach.pte.dto.Point;
/**
* @author Anthony Chaput
*/
public class FranceSouthEastProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public FranceSouthEastProviderLiveTest() {
super(new FranceSouthEastProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
nearbyStationsAddress(45185260, 5737800);
}
@Test
public void nearbyStationsAddress2() throws Exception {
nearbyStationsAddress(45184620, 5779780);
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:OGR:SP:2021");
}
@Test
public void nearbyStationsPoi() throws Exception {
nearbyStationsPoi("poi:n1245491811");
}
@Test
public void nearbyStationsAny() throws Exception {
nearbyStationsAny(45184630, 5779790);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:OGR:SP:S99999");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:OGR:SP:2021");
}
@Test
public void queryDeparturesStopArea() throws Exception {
queryDeparturesStopArea("stop_area:OGR:SA:S3105");
}
@Test
public void queryDeparturesEquivsTrue() throws Exception {
queryDeparturesEquivsTrue("stop_point:OGR:SP:2021");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:OBO:SP:999999");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("condil");
}
@Test
public void suggestLocationsFromAddress() throws Exception {
suggestLocationsFromAddress("360 rue des res");
}
@Test
public void suggestLocationsNoLocation() throws Exception {
suggestLocationsNoLocation("quinconcesadasdjkaskd");
}
@Test
public void queryTripAddresses() throws Exception {
queryTrip("360 rue des résidences", "2 rue Charles Michels");
}
@Test
public void queryTripAddressStation() throws Exception {
queryTrip("14 rue Barnave", "Louise Michel");
}
@Test
public void queryTripStations() throws Exception {
queryTrip("Victor Hugo", "Les Bauches");
}
@Test
public void queryTripStations2() throws Exception {
queryTrip("Chavant", "Louise Michel");
}
@Test
public void queryTripStations3() throws Exception {
queryTrip("Fontaine", "Vallier Libération");
}
@Test
public void queryTripStationsRapidTransit() throws Exception {
queryTrip("Alsace-Lorraine", "Vallier Libération");
}
@Test
public void queryTripNoSolution() throws Exception {
queryTripNoSolution("Robespierre", "Les Bauches");
}
@Test
public void queryTripUnknownFrom() throws Exception {
queryTripUnknownFrom("Chavant");
}
@Test
public void queryTripUnknownTo() throws Exception {
queryTripUnknownTo("Chavant");
}
@Test
public void queryTripSlowWalk() throws Exception {
queryTripSlowWalk("360 rue des résidences", "15 rue de la chimie");
}
@Test
public void queryTripFastWalk() throws Exception {
queryTripFastWalk("360 rue des résidences", "15 rue de la chimie");
}
@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("360 rue des résidences", "15 rue de la chimie");
}
@Test
public void getArea() throws Exception {
Point[] polygon = this.provider.getArea();
Assert.assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,165 @@
/*
* Copyright 2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.FranceSouthWestProvider;
import de.schildbach.pte.dto.Point;
/**
* @author Nicolas Derive
*/
public class FranceSouthWestProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public FranceSouthWestProviderLiveTest() {
super(new FranceSouthWestProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
nearbyStationsAddress(44826434, -557312);
}
@Test
public void nearbyStationsAddress2() throws Exception {
nearbyStationsAddress(44841225, -580036);
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:STE:SP:OCETrainTER-87581538");
}
@Test
public void nearbyStationsPoi() throws Exception {
nearbyStationsPoi("poi:n849494949");
}
@Test
public void nearbyStationsAny() throws Exception {
nearbyStationsAny(44826434, -557312);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:OBO:SP:7");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:OBO:SP:732");
}
@Test
public void queryDeparturesStopArea() throws Exception {
queryDeparturesStopArea("stop_area:OBO:SA:AEROG");
}
@Test
public void queryDeparturesEquivsTrue() throws Exception {
queryDeparturesEquivsTrue("stop_point:OBO:SP:732");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:OBO:SP:999999");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("quinco");
}
@Test
public void suggestLocationsFromAddress() throws Exception {
suggestLocationsFromAddress("78 rue cam");
}
@Test
public void suggestLocationsNoLocation() throws Exception {
suggestLocationsNoLocation("quinconcesadasdjkaskd");
}
@Test
public void queryTripAddresses() throws Exception {
queryTrip("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux");
}
@Test
public void queryTripAddressStation() throws Exception {
queryTrip("98, rue Jean-Renaud Dandicolle Bordeaux", "Saint-Augustin");
}
@Test
public void queryTripStations() throws Exception {
queryTrip("Hôpital Pellegrin", "Avenue de l'Université");
}
@Test
public void queryTripStations2() throws Exception {
queryTrip("Pelletan", "Barrière de Pessac");
}
@Test
public void queryTripStations3() throws Exception {
queryTrip("Barrière de Pessac", "Hôpital Pellegrin");
}
@Test
public void queryTripStationsRapidTransit() throws Exception {
queryTrip("Gaviniès Bordeaux", "Saint-Augustin Bordeaux");
}
@Test
public void queryTripNoSolution() throws Exception {
queryTripNoSolution("Patinoire Mériadeck Bordeaux", "Mérignac Centre");
}
@Test
public void queryTripUnknownFrom() throws Exception {
queryTripUnknownFrom("Patinoire Mériadeck Bordeaux");
}
@Test
public void queryTripUnknownTo() throws Exception {
queryTripUnknownTo("Patinoire Mériadeck Bordeaux");
}
@Test
public void queryTripSlowWalk() throws Exception {
queryTripSlowWalk("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux");
}
@Test
public void queryTripFastWalk() throws Exception {
queryTripFastWalk("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux");
}
@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,107 @@
/*
* Copyright 2017 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.GhanaProvider;
import de.schildbach.pte.dto.Point;
public class GhanaProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public GhanaProviderLiveTest() {
super(new GhanaProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
nearbyStationsAddress(5553473, -190438);
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_area:SA4980974759");
}
@Test
public void nearbyStationsDistance() throws Exception {
nearbyStationsStationDistance("stop_area:SA5036738888");
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_area:SC5031328601");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:5005030178");
}
@Test
public void queryDeparturesStopArea() throws Exception {
queryDeparturesStopArea("stop_area:SA5031328607");
}
@Test
public void queryDeparturesEquivsTrue() throws Exception {
queryDeparturesEquivsTrue("stop_area:SA5031328607");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:RTP:5005030178");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("mark");
}
@Test
public void suggestLocationsNoLocation() throws Exception {
suggestLocationsNoLocation("bellevilleadasdjkaskd");
}
@Test
public void queryTripStations() throws Exception {
queryTrip("College", "Market");
}
@Test
public void queryTripUnknownFrom() throws Exception {
queryTripUnknownFrom("Market");
}
@Test
public void queryTripUnknownTo() throws Exception {
queryTripUnknownTo("Market");
}
@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("College", "Market");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,167 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.GvhProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class GvhProviderLiveTest extends AbstractProviderLiveTest {
public GvhProviderLiveTest() {
super(new GvhProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "25000031"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52379497, 9735832));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("25000031", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Gümmer Straße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "25004748")));
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Hannover, Hannoversche Straße");
print(result);
}
@Test
public void suggestLocationsCity() throws Exception {
final SuggestLocationsResult result = suggestLocations("Hannover");
print(result);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Hannover");
print(result);
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult result = suggestLocations("Sarstedt");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "25001731")));
}
@Test
public void incompleteTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "hann"), null,
new Location(LocationType.ANY, null, null, "laat"), new Date(), true, null);
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "25000031", null, "Hannover Hauptbahnhof"), null,
new Location(LocationType.STATION, "25001141", null, "Hannover Bismarckstraße"), new Date(), true,
null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripBetweenAnyAndAddress() throws Exception {
final Location from = new Location(LocationType.ANY, null, Point.from1E6(53069619, 8799202), null,
"bremen, neustadtswall 12");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(53104124, 8788575), null,
"Bremen Glücksburger Straße 37");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(53622859, 10133545), null,
"Zamenhofweg 14, 22159 Hamburg, Deutschland");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(53734260, 9674990), null,
"Lehmkuhlen 5, 25337 Elmshorn, Deutschland");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,93 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.AbstractHafasClientInterfaceProvider;
import de.schildbach.pte.InvgProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class InvgProviderLiveTest extends AbstractProviderLiveTest {
public InvgProviderLiveTest() {
super(new InvgProvider(secretProperty("invg.api_authorization"), AbstractHafasClientInterfaceProvider
.decryptSalt(secretProperty("invg.encrypted_salt"), secretProperty("hci.salt_encryption_key"))));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "80301"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48744678, 11437941));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("80301", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Rathausplatz");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "60706", null, "Rathausplatz");
final Location to = new Location(LocationType.STATION, "146704", null, "Hochschule");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(48744414, 11434603); // Ingolstadt Hbf
final Location to = Location.coord(48751558, 11426546); // Ingolstadt Nordbahnhof
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,190 @@
/*
* Copyright 2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.ItalyProvider;
import de.schildbach.pte.dto.Point;
/**
* @author Antonio El Khoury
*/
public class ItalyProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public ItalyProviderLiveTest() {
super(new ItalyProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
nearbyStationsAddress(38143607, 13336346);
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:OPO:SP:100");
}
@Test
public void nearbyStationsPoi() throws Exception {
nearbyStationsPoi("poi:w300581846");
}
@Test
public void nearbyStationsAny() throws Exception {
nearbyStationsAny(38096070, 13400204);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:9999999999");
}
@Test
public void queryDeparturesEquivsFalsePalermo() throws Exception {
queryDeparturesEquivsFalse("stop_point:OTO:SP:54673002");
}
@Test
public void queryDeparturesStopAreaPalermo() throws Exception {
queryDeparturesStopArea("stop_area:OPO:SA:1974");
}
@Test
public void queryDeparturesEquivsTruePalermo() throws Exception {
queryDeparturesEquivsTrue("stop_point:OTO:SP:54673002");
}
@Test
public void queryDeparturesEquivsFalseRome() throws Exception {
queryDeparturesEquivsFalse("stop_point:ORA:SP:AD10");
}
@Test
public void queryDeparturesStopAreaRome() throws Exception {
queryDeparturesStopArea("stop_area:ORA:SA:50003");
}
@Test
public void queryDeparturesEquivsTrueRome() throws Exception {
queryDeparturesEquivsTrue("stop_point:ORA:SP:AD10");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:RTP:SP:999999");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("fontana trevi");
}
@Test
public void suggestLocationsFromAddress() throws Exception {
suggestLocationsFromAddress("12 via ferrata");
}
@Test
public void suggestLocationsNoLocation() throws Exception {
suggestLocationsNoLocation("bellevilleadasdjkaskd");
}
@Test
public void queryTripAddressesPalermo() throws Exception {
queryTrip("Via Giuseppe Lanza di Scalea, 2703, 90147 Palermo", "Via Eugenio Montale, 12, Palermo");
}
@Test
public void queryTripAddressStationPalermo() throws Exception {
queryTrip("Via Giuseppe Lanza di Scalea, 2703, 90147 Palermo", "Galletti - Zita");
}
@Test
public void queryTripStationsPalermo() throws Exception {
queryTrip("Palermo Centrale", "Galletti Zita");
}
@Test
public void queryTripAddressesRome() throws Exception {
queryTrip("Via Anton Giulio Barrili, 44-46, Roma", "Via delle Cave di Pietralata, 103, Roma");
}
@Test
public void queryTripAddressStationRome() throws Exception {
queryTrip("Via Anton Giulio Barrili, 44-46, Roma", "Policlinico");
}
@Test
public void queryTripStationsRome() throws Exception {
queryTrip("Ottaviano", "Policlinico");
}
@Test
public void queryTripNoSolution() throws Exception {
queryTripNoSolution("Palermo Centrale", "Galletti Zita");
}
@Test
public void queryTripUnknownFrom() throws Exception {
queryTripUnknownFrom("Palermo Centrale");
}
@Test
public void queryTripUnknownTo() throws Exception {
queryTripUnknownTo("Palermo Centrale");
}
@Test
public void queryTripSlowWalkPalermo() throws Exception {
queryTripSlowWalk("Palermo Centrale", "Galletti Zita");
}
@Test
public void queryTripFastWalkPalermo() throws Exception {
queryTripFastWalk("Palermo Centrale", "Galletti Zita");
}
@Test
public void queryMoreTripsPalermo() throws Exception {
queryMoreTrips("Palermo Centrale", "Galletti Zita");
}
@Test
public void queryTripSlowWalkRome() throws Exception {
queryTripSlowWalk("Ottaviano", "Policlinico");
}
@Test
public void queryTripFastWalkRome() throws Exception {
queryTripFastWalk("Ottaviano", "Policlinico");
}
@Test
public void queryMoreTripsRome() throws Exception {
queryMoreTrips("Ottaviano", "Policlinico");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,146 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.KvvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class KvvProviderLiveTest extends AbstractProviderLiveTest {
public KvvProviderLiveTest() {
super(new KvvProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "7000090"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(49008184, 8400736));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("7000090", false);
print(result);
}
@Test
public void queryDeparturesMesseKarlsruhe() throws Exception {
final QueryDeparturesResult result = queryDepartures("7000211", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Händelstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "7000044")));
}
@Test
public void suggestAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Karlsruhe, Bahnhofsplatz 2");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:1500000173:2:8212000:15:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz:76137:ANY:DIVA_SINGLEHOUSE:935315:5725973:MRCV:b_w")));
}
@Test
public void suggestStreet() throws Exception {
final SuggestLocationsResult result = suggestLocations("Karlsruhe, Bahnhofsplatz");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:1500000173::8212000:-1:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz: 76137:ANY:DIVA_STREET:935120:5726009:MRCV:b_w")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "7000001", Point.from1E6(49009526, 8404914),
"Karlsruhe", "Marktplatz");
final Location to = new Location(LocationType.STATION, "7000002", Point.from1E6(49009393, 8408866), "Karlsruhe",
"Kronenplatz (Kaiserstr.)");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:1500000173:2:8212000:15:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz:76137:ANY:DIVA_SINGLEHOUSE:935315:5725973:MRCV:b_w",
null, "Bahnhofsplatz 2");
final Location to = new Location(LocationType.ADDRESS,
"streetID:1500001060:15:8212000:-1:Lorenzstraße:Karlsruhe:Lorenzstraße::Lorenzstraße:76135:ANY:DIVA_SINGLEHOUSE:933225:5724788:MRCV:b_w",
null, "Lorenzstraße 15");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenStreets() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:1500000173::8212000:-1:Bahnhofplatz:Karlsruhe:Bahnhofplatz::Bahnhofplatz: 76137:ANY:DIVA_STREET:935120:5726009:MRCV:b_w",
null, "Bahnhofsplatz");
final Location to = new Location(LocationType.ADDRESS,
"streetID:1500001060::8212000:-1:Lorenzstraße:Karlsruhe:Lorenzstraße::Lorenzstraße: 76135:ANY:DIVA_STREET:933225:5724788:MRCV:b_w",
null, "Lorenzstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,133 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.LinzProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class LinzProviderLiveTest extends AbstractProviderLiveTest {
public LinzProviderLiveTest() {
super(new LinzProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "60500090"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48305726, 14287863));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("60501720", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Friedhof");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("grün");
print(result);
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Leonding, Haag");
print(result);
}
@Test
public void suggestLocationsCity() throws Exception {
final SuggestLocationsResult result = suggestLocations("Leonding");
print(result);
}
@Test
public void incompleteTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "linz"), null,
new Location(LocationType.ANY, null, null, "gel"), new Date(), true, null);
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, null, null, "Linz Hauptbahnhof"),
null, new Location(LocationType.STATION, null, null, "Linz Auwiesen"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void longTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, null, null, "Linz Auwiesen"),
null, new Location(LocationType.STATION, null, null, "Linz Hafen"), new Date(), true, null);
print(result);
// final QueryTripsResult laterResult = queryMoreTrips(provider, result.context, true);
// print(laterResult);
}
}

View file

@ -0,0 +1,96 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.LuProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class LuProviderLiveTest extends AbstractProviderLiveTest {
public LuProviderLiveTest() {
super(new LuProvider(secretProperty("lu.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(49610187, 6132746));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("200501001", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Aéroport");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "200416001", null, "Cité Aéroport");
final Location to = new Location(LocationType.STATION, "200405035", "Luxembourg", "Gare Centrale");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void addressTrip() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(49611610, 6130265), null,
"Luxembourg, Rue Génistre 2");
final Location to = new Location(LocationType.STATION, "200405035", "Luxembourg", "Gare Centrale");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(49.5999681, 6.1342493)); // Luxembourg Central
// Station
final Location to = Location.coord(Point.fromDouble(49.5956369, 6.1200199)); // Hollerich
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,56 @@
/*
* Copyright 2018 Erik Uhlmann.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import org.junit.Test;
import de.schildbach.pte.MassachusettsProvider;
/**
* @author Erik Uhlmann
*/
public class MassachusettsProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public MassachusettsProviderLiveTest() {
super(new MassachusettsProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStations() throws Exception {
nearbyStationsStation("stop_point:OUB:SP:70243");
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
nearbyStationsAny(42353187, -71067045);
}
@Test
public void queryDepartures() throws Exception {
queryDeparturesEquivsFalse("stop_point:OUB:SP:70198");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:OUB:SP:xxxx");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("Airport");
}
}

View file

@ -0,0 +1,112 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.EnumSet;
import org.junit.Test;
import de.schildbach.pte.MerseyProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class MerseyProviderLiveTest extends AbstractProviderLiveTest {
public MerseyProviderLiveTest() {
super(new MerseyProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "4017846"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
Location.coord(53401112, -2958903));
print(result);
}
@Test
public void nearbyLocationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION, LocationType.POI),
Location.coord(53401112, -2958903));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("4017846", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult resultLive = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, resultLive.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Liverpool");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "4017846", Point.from1E6(53401672, -2958720),
"Liverpool", "Orphan Street");
final Location to = new Location(LocationType.STATION, "4027286", Point.from1E6(53397324, -2961676),
"Liverpool", "Womens Hospital");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,127 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.MvgProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class MvgProviderLiveTest extends AbstractProviderLiveTest {
public MvgProviderLiveTest() {
super(new MvgProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "24200006"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51219852, 7639217));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("3", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Schützenhalle");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("grün");
print(result);
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult luedenscheidResult = suggestLocations("Lüdenscheid Freibad");
print(luedenscheidResult);
assertThat(luedenscheidResult.getLocations(), hasItem(new Location(LocationType.STATION, "24200153")));
final SuggestLocationsResult iserlohnResult = suggestLocations("Iserlohn Rathaus");
print(iserlohnResult);
assertThat(iserlohnResult.getLocations(), hasItem(new Location(LocationType.STATION, "24200764")));
final SuggestLocationsResult plettenbergResult = suggestLocations("Plettenberg Friedhof");
print(plettenbergResult);
assertThat(plettenbergResult.getLocations(), hasItem(new Location(LocationType.STATION, "24202864")));
final SuggestLocationsResult mendenResult = suggestLocations("Menden Am Gillfeld");
print(mendenResult);
assertThat(mendenResult.getLocations(), hasItem(new Location(LocationType.STATION, "24202193")));
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "24200200", null, "Lüd., Christuskirche"), null,
new Location(LocationType.STATION, "24200032", null, "Lüd., Friedrichstr."), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,238 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.EnumSet;
import org.junit.Test;
import de.schildbach.pte.MvvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class MvvProviderLiveTest extends AbstractProviderLiveTest {
public MvvProviderLiveTest() {
super(new MvvProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "350"));
print(result);
}
@Test
public void nearbyStationsByCoordinateMarienplatz() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(
Location.coord(Point.fromDouble(48.1364360, 11.5776610)));
print(result);
assertTrue(result.locations.size() > 0);
}
@Test
public void nearbyLocationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION, LocationType.POI),
Location.coord(48135232, 11560650));
print(result);
assertTrue(result.locations.size() > 0);
}
@Test
public void queryDeparturesMarienplatz() throws Exception {
final QueryDeparturesResult result1 = queryDepartures("2", false);
assertEquals(QueryDeparturesResult.Status.OK, result1.status);
print(result1);
final QueryDeparturesResult result2 = queryDepartures("1000002", false);
assertEquals(QueryDeparturesResult.Status.OK, result2.status);
print(result2);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Starnberg, Agentur für Arbeit");
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Marien");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Grüntal");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "1000619")));
}
@Test
public void suggestLocationsFraunhofer() throws Exception {
final SuggestLocationsResult result = suggestLocations("fraunhofer");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "1000150")));
}
@Test
public void suggestLocationsHirschgarten() throws Exception {
final SuggestLocationsResult result = suggestLocations("Hirschgarten");
print(result);
assertEquals("München", result.getLocations().get(0).place);
}
@Test
public void suggestLocationsOstbahnhof() throws Exception {
final SuggestLocationsResult result = suggestLocations("Ostbahnhof");
print(result);
assertEquals("München", result.getLocations().get(0).place);
}
@Test
public void suggestLocationsMarienplatz() throws Exception {
final SuggestLocationsResult result = suggestLocations("Marienplatz");
print(result);
assertEquals("München", result.getLocations().get(0).place);
}
@Test
public void suggestAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("München, Maximilianstr. 1");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:3239:1:9162000:9162000:Maximilianstraße:München:Maximilianstraße::Maximilianstraße:80539:ANY:DIVA_ADDRESS:4468763:826437:MVTT:MVV")));
}
@Test
public void suggestStreet() throws Exception {
final SuggestLocationsResult result = suggestLocations("München, Maximilianstr.");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:3239::9162000:-1:Maximilianstraße:München:Maximilianstraße::Maximilianstraße: 80539 80538:ANY:DIVA_STREET:4469138:826553:MVTT:MVV")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "2", "München", "Marienplatz");
final Location to = new Location(LocationType.STATION, "10", "München", "Pasing");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult earlierResult = queryMoreTrips(laterResult.context, false);
print(earlierResult);
}
@Test
public void longTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "1005530", Point.from1E6(48002924, 11340144),
"Starnberg", "Agentur für Arbeit");
final Location to = new Location(LocationType.STATION, null, null, "Ackermannstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(48165238, 11577473);
final Location to = Location.coord(47987199, 11326532);
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinateAndStation() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(48238341, 11478230));
final Location to = new Location(LocationType.ANY, null, null, "Ostbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:3239:1:9162000:9162000:Maximilianstraße:München:Maximilianstraße::Maximilianstraße:80539:ANY:DIVA_ADDRESS:4468763:826437:MVTT:MVV",
null, "Maximilianstraße 1");
final Location to = new Location(LocationType.ADDRESS,
"streetID:753:4:9162000:1:Burggrafenstraße:München:Burggrafenstraße::Burggrafenstraße:81671:ANY:DIVA_SINGLEHOUSE:4471134:827570:MVTT:MVV",
null, "Burggrafenstraße 4");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenStreets() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:3239::9162000:-1:Maximilianstraße:München:Maximilianstraße::Maximilianstraße: 80539 80538:ANY:DIVA_STREET:4469138:826553:MVTT:MVV",
null, "Maximilianstraße");
final Location to = new Location(LocationType.ADDRESS,
"streetID:753::9162000:1:Burggrafenstraße:München:Burggrafenstraße::Burggrafenstraße: 81671:ANY:DIVA_STREET:4471150:827576:MVTT:MVV",
null, "Burggrafenstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenStationAndAddress() throws Exception {
final Location from = new Location(LocationType.STATION, "1220", null, "Josephsburg");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(48188018, 11574239), null,
"München Frankfurter Ring 35");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripInvalidStation() throws Exception {
final Location valid = new Location(LocationType.STATION, "2", "München", "Marienplatz");
final Location invalid = new Location(LocationType.STATION, "99999", null, null);
final QueryTripsResult result1 = queryTrips(valid, null, invalid, new Date(), true, null);
assertEquals(QueryTripsResult.Status.UNKNOWN_TO, result1.status);
final QueryTripsResult result2 = queryTrips(invalid, null, valid, new Date(), true, null);
assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result2.status);
}
}

View file

@ -0,0 +1,161 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.NasaProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.util.Iso8601Format;
/**
* @author Andreas Schildbach
*/
public class NasaProviderLiveTest extends AbstractProviderLiveTest {
public NasaProviderLiveTest() {
super(new NasaProvider(secretProperty("nasa.api_authorization")));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "13000"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51346546, 12383333));
print(result);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
assertTrue(result.locations.size() > 0);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("13000", false);
print(result);
}
@Test
public void queryDeparturesEquivs() throws Exception {
final QueryDeparturesResult result = queryDepartures("13000", true);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Flughafen");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Höhle");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "11063", null, "Leipzig, Johannisplatz"), null,
new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void anotherShortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "8010205", Point.from1E6(51346546, 12383333), null,
"Leipzig Hbf");
final Location to = new Location(LocationType.STATION, "8012183", Point.from1E6(51423340, 12223423), null,
"Leipzig/Halle Flughafen");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void outdatedTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "13002", null, "Leipzig, Augustusplatz"), null,
new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf"),
Iso8601Format.newDateFormat().parse("2011-01-01"), true, null);
assertEquals(QueryTripsResult.Status.INVALID_DATE, result.status);
}
@Test
public void ambiguousTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Platz"), null,
new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status);
print(result);
}
@Test
public void sameStationTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf"),
null, new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.TOO_CLOSE, result.status);
}
@Test
public void addressTrip() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51334078, 12478331),
"04319 Leipzig-Engelsdorf", "August-Bebel-Platz");
final Location to = new Location(LocationType.STATION, "8010205", null, "Leipzig Hbf");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,187 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.EnumSet;
import org.junit.Test;
import de.schildbach.pte.NegentweeProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author full-duplex
*/
public class NegentweeProviderLiveTest extends AbstractProviderLiveTest {
public NegentweeProviderLiveTest() {
super(new NegentweeProvider(NegentweeProvider.Language.EN_GB));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(
new Location(LocationType.STATION, "station-amsterdam-centraal"));
print(result);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
// Assert that queryNearbyStations only returns STATION locations
assertNotNull(result.locations);
assertTrue(result.locations.size() > 0);
for (Location location : result.locations) {
assertEquals(location.type, LocationType.STATION);
}
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52377548, 4901218));
print(result);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
}
@Test
public void nearbyLocationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.ANY),
Location.coord(52377548, 4901218), -1, 101);
print(result);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("station-amsterdam-centraal", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesWithEquivalents() throws Exception {
final QueryDeparturesResult result = queryDepartures("station-amsterdam-centraal", true);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsComplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Amsterdam Centraal");
print(result);
assertEquals(SuggestLocationsResult.Status.OK, result.status);
}
@Test
public void suggestLocationsStreet() throws Exception {
final SuggestLocationsResult result = suggestLocations("Isolatorweg");
print(result);
assertEquals(SuggestLocationsResult.Status.OK, result.status);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Isolatorweg 32");
print(result);
assertEquals(SuggestLocationsResult.Status.OK, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Amsterdam");
print(result);
assertEquals(SuggestLocationsResult.Status.OK, result.status);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Brüssel");
print(result);
assertEquals(SuggestLocationsResult.Status.OK, result.status);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "station-amsterdam-centraal", null, "Amsterdam Centraal"), null,
new Location(LocationType.STATION, "station-amsterdam-zuid", null, "Amsterdam Zuid"), new Date(), true,
null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
}
@Test
public void earlierTrip() throws Exception {
final QueryTripsResult result1 = queryTrips(
new Location(LocationType.STATION, "station-amsterdam-centraal", null, "Amsterdam Centraal"), null,
new Location(LocationType.STATION, "station-rotterdam-centraal", null, "Rotterdam Centraal"),
new Date(), true, null);
print(result1);
assertEquals(QueryTripsResult.Status.OK, result1.status);
assertTrue(result1.context.canQueryLater());
final QueryTripsResult result2 = queryMoreTrips(result1.context, false);
print(result2);
assertEquals(QueryTripsResult.Status.OK, result2.status);
}
@Test
public void ambiguousTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Amsterdam Zuid"),
new Location(LocationType.STATION, "station-amsterdam-centraal", null, "Amsterdam Centraal"),
new Location(LocationType.ANY, null, null, "Rotterdam Centraal"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status);
}
@Test
public void longTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.ADDRESS, "amsterdam/prins-hendrikkade-80e", null, "Prins Hendrikkade"), null,
new Location(LocationType.STATION, "breda/bushalte-cornelis-florisstraat", null,
"Cornelis Florisstraat"),
new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
}
@Test
public void coordinatesTrip() throws Exception {
final Location from = new Location(LocationType.COORD, null, Point.from1E6(51677273, 4437548));
final Location via = new Location(LocationType.COORD, null, Point.from1E6(52162772, 4583171));
final Location to = new Location(LocationType.COORD, null, Point.from1E6(53347140, 6720583));
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.NicaraguaProvider;
import de.schildbach.pte.dto.Point;
public class NicaraguaProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public NicaraguaProviderLiveTest() {
super(new NicaraguaProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
// Managua
nearbyStationsAddress(13090080, -86356250);
}
@Test
public void nearbyStationsAddress2() throws Exception {
// Esteli
nearbyStationsAddress(12146120, -86274660);
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:MNI:SP:node3230617621");
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:MNIX:SP:node3230617621");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:MNI:SP:node3230617621");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:MNIX:SP:node3230617621");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("Hospital");
}
@Test
public void queryTripStations() throws Exception {
queryTrip("27 de Mayo", "San Miguel Arcángel");
}
@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("Hospital", "Super Las Segovias");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,86 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.NsProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class NsProviderLiveTest extends AbstractProviderLiveTest {
public NsProviderLiveTest() {
super(new NsProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8800004"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52377548, 4901218));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("8800004", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Brussel S");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Brüssel");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "8400058", null, "Amsterdam Centraal"), null,
new Location(LocationType.STATION, "8400061", null, "Amsterdam Zuid"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
}
}

View file

@ -0,0 +1,254 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.NvbwProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class NvbwProviderLiveTest extends AbstractProviderLiveTest {
public NvbwProviderLiveTest() {
super(new NvbwProvider());
}
@Test
public void nearbyStationsStuttgart() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "5006022")); // Schlossplatz
print(result);
}
@Test
public void nearbyStationsReutlingen() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "53019174")); // Reutlingen
print(result);
}
@Test
public void nearbyStationsFreiburg() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "6930112")); // Faulerstraße
print(result);
}
@Test
public void nearbyStationsByCoordinateStuttgart() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48778953, 9178963));
print(result);
}
@Test
public void nearbyStationsByCoordinateReutlingen() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48493550, 9205656));
print(result);
}
@Test
public void nearbyStationsByCoordinateFreiburg() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48000295, 7854338));
print(result);
}
@Test
public void queryDeparturesStuttgart() throws Exception {
final QueryDeparturesResult result = queryDepartures("5006022", false); // Schlossplatz
print(result);
}
@Test
public void queryDeparturesReutlingen() throws Exception {
final QueryDeparturesResult result = queryDepartures("53019174", false); // Reutlingen
print(result);
}
@Test
public void queryDeparturesKarlsruhe() throws Exception {
final QueryDeparturesResult result = queryDepartures("7000211", false); // Messe
print(result);
}
@Test
public void queryDeparturesFreiburg() throws Exception {
final QueryDeparturesResult result = queryDepartures("6930112", false); // Faulerstraße
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("grünwink");
print(result);
}
@Test
public void suggestLocationsCoverageFreiburg() throws Exception {
final SuggestLocationsResult result = suggestLocations("Freiburg Hauptbahnhof");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "6906508")));
}
@Test
public void suggestLocationsCoverageBasel() throws Exception {
final SuggestLocationsResult result = suggestLocations("Basel");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "51000007")));
}
@Test
public void suggestLocationsCoverageKonstanz() throws Exception {
final SuggestLocationsResult result = suggestLocations("Konstanz");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "8706554")));
}
@Test
public void suggestAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Stuttgart, Kronenstraße 3");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:1500000599:3:8111000:51:Kronenstraße:Stuttgart:Kronenstraße::Kronenstraße:70173:ANY:DIVA_SINGLEHOUSE:1021956:5762095:MRCV:B_W")));
}
@Test
public void suggestStreet() throws Exception {
final SuggestLocationsResult result = suggestLocations("Stuttgart, Kronenstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:1500000599::8111000:51:Kronenstraße:Stuttgart:Kronenstraße::Kronenstraße: 70174 70173:ANY:DIVA_STREET:1021539:5761790:MRCV:B_W")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "17002402", null, "Bahnhof");
final Location to = new Location(LocationType.STATION, "17009001", null, "Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void shortTripReutlingen() throws Exception {
final Location from = new Location(LocationType.STATION, "8029333", Point.from1E6(48492484, 9207456),
"Reutlingen", "ZOB");
final Location to = new Location(LocationType.STATION, "8029109", Point.from1E6(48496968, 9213320),
"Reutlingen", "Bismarckstr.");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void shortTripFreiburg() throws Exception {
final Location from = new Location(LocationType.STATION, "6930100", null, "Freiburg Bertoldsbrunnen");
final Location to = new Location(LocationType.STATION, "6930101", null, "Freiburg Siegesdenkmal");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void trip() throws Exception {
final Location from = new Location(LocationType.STATION, "6900037", Point.from1E6(48063184, 7779532),
"Buchheim (Breisgau)", "Fortuna");
final Location to = new Location(LocationType.STATION, "6906508", Point.from1E6(47996616, 7840450),
"Freiburg im Breisgau", "Freiburg im Breisgau, Hauptbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
}
@Test
public void tripPforzheimToKarlsruhe() throws Exception {
final Location from = new Location(LocationType.STATION, "7900050");
final Location to = new Location(LocationType.STATION, "7000090");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:1500000484:11:8111000:-1:Wilhelmsplatz (Stgt):Stuttgart:Wilhelmsplatz (Stgt)::Wilhelmsplatz (Stgt):70182:ANY:DIVA_SINGLEHOUSE:1021706:5763896:MRCV:B_W",
null, "Wilhelmsplatz 11");
final Location to = new Location(LocationType.ADDRESS,
"streetID:1500000599:3:8111000:51:Kronenstraße:Stuttgart:Kronenstraße::Kronenstraße:70173:ANY:DIVA_SINGLEHOUSE:1021956:5762095:MRCV:B_W",
null, "Kronenstraße 3");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null);
print(result);
}
@Test
public void tripBetweenStreets() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:1500000484::8111000:51:Wilhelmsplatz (Stgt):Stuttgart:Wilhelmsplatz (Stgt)::Wilhelmsplatz (Stgt): 70182:ANY:DIVA_STREET:1021828:5763870:MRCV:B_W",
null, "Wilhelmsplatz");
final Location to = new Location(LocationType.ADDRESS,
"streetID:1500000599::8111000:51:Kronenstraße:Stuttgart:Kronenstraße::Kronenstraße: 70174 70173:ANY:DIVA_STREET:1021539:5761790:MRCV:B_W",
null, "Kronenstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null);
print(result);
}
}

View file

@ -0,0 +1,201 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.NvvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
/**
* @author Andreas Schildbach
*/
public class NvvProviderLiveTest extends AbstractProviderLiveTest {
public NvvProviderLiveTest() {
super(new NvvProvider(secretProperty("nvv.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(50108625, 8669604));
print(result);
}
@Test
public void nearbyStationsByCoordinateKassel() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51318447, 9496250));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("3000408", false);
print(result);
final QueryDeparturesResult result2 = queryDepartures("3000010", false);
print(result2);
final QueryDeparturesResult result3 = queryDepartures("3015989", false);
print(result3);
final QueryDeparturesResult result4 = queryDepartures("3000139", false);
print(result4);
}
@Test
public void queryDeparturesEquivs() throws Exception {
final QueryDeparturesResult result = queryDepartures("3000010", true);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Flughafen");
print(result);
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kassel Wilhelmshöhe");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("könig");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "3000001", null, "Hauptwache");
final Location to = new Location(LocationType.STATION, "3000912", null, "Südbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult later3Result = queryMoreTrips(later2Result.context, true);
print(later3Result);
final QueryTripsResult later4Result = queryMoreTrips(later3Result.context, true);
print(later4Result);
final QueryTripsResult later5Result = queryMoreTrips(later4Result.context, true);
print(later5Result);
final QueryTripsResult later6Result = queryMoreTrips(later5Result.context, true);
print(later6Result);
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
print(earlierResult);
final QueryTripsResult earlier2Result = queryMoreTrips(earlierResult.context, false);
print(earlier2Result);
final QueryTripsResult earlier3Result = queryMoreTrips(earlier2Result.context, false);
print(earlier3Result);
final QueryTripsResult earlier4Result = queryMoreTrips(earlier3Result.context, false);
print(earlier4Result);
}
@Test
public void shortTripKassel() throws Exception {
final Location from = new Location(LocationType.STATION, "2200007", null, "Kassel Wilhelmshöhe");
final Location to = new Location(LocationType.STATION, "2200278", null, "Kassel Wilhelmshöher Weg");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void slowTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "3029079", Point.from1E6(50017679, 8229480), "Mainz",
"An den Dünen");
final Location to = new Location(LocationType.STATION, "3013508", Point.from1E6(50142890, 8895203), "Hanau",
"Beethovenplatz");
final TripOptions options = new TripOptions(Product.ALL, null, WalkSpeed.NORMAL, Accessibility.BARRIER_FREE,
null);
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, options);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void shortTripByName() throws Exception {
final Location from = new Location(LocationType.ANY, null, null, "Frankfurt Bockenheimer Warte!");
final Location to = new Location(LocationType.ANY, null, null, "Frankfurt Hauptbahnhof!");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripUsingMuchBuffer() throws IOException {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(50119563, 8697044), null,
"Hegelstrasse, 60316 Frankfurt am Main");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(50100364, 8615193), null,
"Mainzer Landstrasse, Frankfurt");
final QueryTripsResult result = queryTrips(from, null, to, new Date(1378368840000l), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripUsingEvenMoreBuffer() throws IOException {
final Location from = new Location(LocationType.STATION, "3000909", Point.from1E6(50094052, 8690923), null,
"F Brauerei");
final Location to = new Location(LocationType.STATION, "3001201", Point.from1E6(50119950, 8653924), null,
"F Bockenheimer Warte");
final QueryTripsResult result = queryTrips(from, null, to, new Date(1378368840000l), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(51.3183386, 9.4896007)); // Kassel Hauptbahnhof
final Location to = Location.coord(Point.fromDouble(51.3245728, 9.4521398)); // Kassel-Kirchditmold
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,89 @@
/*
* Copyright 2014-2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.NzProvider;
import de.schildbach.pte.dto.Point;
/**
* @author Torsten Grote
*/
public class NzProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public NzProviderLiveTest() {
super(new NzProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
// Auckland
nearbyStationsAddress(-36852200, 174763000);
}
@Test
public void nearbyStationsAddress2() throws Exception {
// Wellington
nearbyStationsAddress(-41292500, 174777000);
}
@Test
public void nearbyStationsStation() throws Exception {
// Ghuznee Street at Cuba Street (Wellington)
nearbyStationsStation("stop_point:OWT:SP:6909");
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:OWX:SP:6909");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:OWT:SP:6911");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:OWX:SP:6911");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("Cuba St");
}
@Test
public void queryTripStations() throws Exception {
queryTrip("Cuba Street at Weltec", "Petone");
}
@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("Manners Street", "Lower Hutt");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,134 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.OebbProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class OebbProviderLiveTest extends AbstractProviderLiveTest {
public OebbProviderLiveTest() {
super(new OebbProvider(secretProperty("oebb.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48200239, 16370773));
print(result);
assertEquals(NearbyLocationsResult.Status.OK, result.status);
assertTrue(result.locations.size() > 0);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("902006", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
assertTrue(result.stationDepartures.size() > 0);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Wien");
print(result);
assertTrue(result.getLocations().size() > 0);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Obirhöhle");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "1140101", null, "Linz");
final Location to = new Location(LocationType.STATION, "1190100", null, "Wien");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void slowTrip() throws Exception {
final Location from = new Location(LocationType.ANY, null, null, "Ramsen Zoll!");
final Location to = new Location(LocationType.ANY, null, null, "Azuga!");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripWithFootway() throws Exception {
final Location from = new Location(LocationType.ANY, null, null, "Graz, Haselweg!");
final Location to = new Location(LocationType.ANY, null, null, "Innsbruck, Gumppstraße 69!");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripWithFootway2() throws Exception {
final Location from = new Location(LocationType.ANY, null, null, "Wien, Krottenbachstraße 110!");
final Location to = new Location(LocationType.ADDRESS, null, null, "Wien, Meidlinger Hauptstraße 1!");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(48.1850101, 16.3778549)); // Wien Hauptbahnhof
final Location to = Location.coord(Point.fromDouble(48.2902408, 14.2918619)); // Linz Hauptbahnhof
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,69 @@
/*
* Copyright 2010-2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import de.schildbach.pte.OntarioProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Stephane Berube
*/
public class OntarioProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public OntarioProviderLiveTest() {
super(new OntarioProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(
new Location(LocationType.STATION, "stop_point:OAW:SP:CH240"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(45416667, -75683333));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("OAW:SP:CH240", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("OAW:SP:CHxxx", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Airport");
print(result);
}
}

View file

@ -0,0 +1,166 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.OoevvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class OoevvProviderLiveTest extends AbstractProviderLiveTest {
public OoevvProviderLiveTest() {
super(new OoevvProvider(secretProperty("ooevv.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48207355, 16370602));
print(result);
}
@Test
public void nearbyStationsByCoordinateSalzburg() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(47809195, 13054919));
print(result);
}
@Test
public void queryDeparturesLinz() throws Exception {
final QueryDeparturesResult result = queryDepartures("444116400", 0, false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesSalzburg() throws Exception {
final QueryDeparturesResult result = queryDepartures("455000200", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", 0, false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Linz Hauptbahnhof");
print(result);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Mutterstraße 4, 6800 Feldkirch");
print(result);
}
@Test
public void suggestLocationsEncoding() throws Exception {
final SuggestLocationsResult result = suggestLocations("Wien Schönbrunn");
assertEquals("Wien Schönbrunn", result.getLocations().get(0).name);
print(result);
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult result = suggestLocations("Linz Hauptbahnhof");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "444116400")));
}
@Test
public void shortTripFeldkirch() throws Exception {
final Location from = new Location(LocationType.STATION, "480082200", null, "Feldkirch Katzenturm");
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult laterResult2 = queryMoreTrips(laterResult.context, true);
print(laterResult2);
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
print(earlierResult);
}
@Test
public void shortTripWien() throws Exception {
final Location from = new Location(LocationType.STATION, "490132000", null, "Wien Stephansplatz");
final Location to = new Location(LocationType.STATION, "490024500", null, "Wien Stubentor");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult laterResult2 = queryMoreTrips(laterResult.context, true);
print(laterResult2);
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
print(earlierResult);
}
@Test
public void shortTripSalzburg() throws Exception {
final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409),
"Salzburg", "Vogelweiderstraße");
final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278),
"Salzburg", "Merianstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripAddressToStation() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"A=2@O=6800 Feldkirch, Kapfweg 6@X=9585539@Y=47239257@U=103@L=980092305@B=1@p=1437727591@",
"6800 Feldkirch", "Kapfweg 6");
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripCoordinateToStation() throws Exception {
final Location from = Location.coord(47238096, 9585581);
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,68 @@
/*
* Copyright 2016 Clayton Craft.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import de.schildbach.pte.OregonProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Stephane Berube
*/
public class OregonProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public OregonProviderLiveTest() {
super(new OregonProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "OTP:SP:5017"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(45514998, -122673334));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("OTP:SP:5017", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("OTP:SP:xxxx", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Airport");
print(result);
}
}

View file

@ -0,0 +1,197 @@
/*
* Copyright 2014-2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.ParisProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.Point;
/**
* @author Antonio El Khoury
*/
public class ParisProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public ParisProviderLiveTest() {
super(new ParisProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
nearbyStationsAddress(48877523, 2378353);
}
@Test
public void nearbyStationsAddress2() throws Exception {
nearbyStationsAddress(48785420, 2212050);
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:OIF:SP:59:5657291");
}
@Test
public void nearbyStationsPoi() throws Exception {
nearbyStationsPoi("poi:n668579722");
}
@Test
public void nearbyStationsAny() throws Exception {
nearbyStationsAny(48877523, 2378353);
}
@Test
public void nearbyStationsDistance() throws Exception {
nearbyStationsStationDistance("stop_point:OIF:SP:80:137");
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:RTP:SP:392");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:OIF:SP:59:5657291");
}
@Test
public void queryDeparturesStopArea() throws Exception {
queryDeparturesStopArea("stop_area:OIF:SA:59864");
}
@Test
public void queryDeparturesEquivsTrue() throws Exception {
queryDeparturesEquivsTrue("stop_point:OIF:SP:59:5657291");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:RTP:SP:999999");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("bellevi");
}
@Test
public void suggestLocationsFromAddress() throws Exception {
suggestLocationsFromAddress("13 rue man");
}
@Test
public void suggestLocationsNoLocation() throws Exception {
suggestLocationsNoLocation("bellevilleadasdjkaskd");
}
@Test
public void queryTripAddresses() throws Exception {
queryTrip("5 rue Manin Paris", "10 rue Elanger Paris");
}
@Test
public void queryTripAddressStation() throws Exception {
queryTrip("155 bd hopital paris", "Gare St-Lazare");
}
@Test
public void queryTripStations() throws Exception {
queryTrip("Campo Formio", "Gare St-Lazare");
}
@Test
public void queryTripCablecar() throws Exception {
queryTrip("Campo Formio", "Aéroport Orly Sud");
}
@Test
public void queryTripStations2() throws Exception {
queryTrip("Tour Eiffel", "Orsay Ville");
}
@Test
public void queryTripStations3() throws Exception {
queryTrip("Tour Eiffel", "Campo Formio");
}
@Test
public void queryTripStationsOrlyval() throws Exception {
queryTrip("Orly Sud", "Gare De Lyon");
}
@Test
public void queryTripStationsRapidTransit() throws Exception {
queryTrip("Luxembourg Paris", "Antony Antony");
}
@Test
public void queryTripFromAdministrativeRegionToPoi() throws Exception {
queryTripFromAdminToPoi("Paris 10e Arrondissement", "Paris Tour Eiffel");
}
@Test
public void queryTripNoSolution() throws Exception {
queryTripNoSolution("secretan buttes chaumont paris", "Antony Antony");
}
@Test
public void queryTripUnknownFrom() throws Exception {
queryTripUnknownFrom("secretan buttes chaumont paris");
}
@Test
public void queryTripUnknownTo() throws Exception {
queryTripUnknownTo("secretan buttes chaumont paris");
}
@Test
public void queryTripAmbiguousFrom() throws Exception {
queryTripAmbiguousFrom(new Location(LocationType.ANY, "ambiguous", null, "Eiffel"), "Gare St-Lazare");
}
@Test
public void queryTripAmbiguousTo() throws Exception {
queryTripAmbiguousTo("Gare St-Lazare", new Location(LocationType.ANY, "ambiguous", null, "Eiffel"));
}
@Test
public void queryTripSlowWalk() throws Exception {
queryTripSlowWalk("5 rue manin paris", "10 rue marcel dassault velizy");
}
@Test
public void queryTripFastWalk() throws Exception {
queryTripFastWalk("5 rue manin paris", "10 rue marcel dassault velizy");
}
@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("5 rue manin paris", "10 rue marcel dassault velizy");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,197 @@
/*
* Copyright 2018 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.PlNavitiaProvider;
import de.schildbach.pte.dto.Point;
/**
* @author Michel Le Bihan
*/
public class PlNavitiaProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public PlNavitiaProviderLiveTest() {
super(new PlNavitiaProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
// stations close to those coordinates (lat, lon)
// no decimal point, has to include 6 decimal places
nearbyStationsAddress(52231160, 21010740);
}
@Test
public void nearbyStationsAddress2() throws Exception {
// different test case for stations close to coordinates (lat, lon)
// no decimal point, has to include 6 decimal places
nearbyStationsAddress(52244700, 21001260);
}
@Test
public void nearbyStationsStation() throws Exception {
// station to find other stations around
// look in NTFS file for a stop_id (that contains "SP") and append to "stop_point:"
nearbyStationsStation("stop_point:OWW:SP:ctr");
}
@Test
public void nearbyStationsPoi() throws Exception {
// POI to find stations around
// search OSM for a node, use identifier after
// "https://www.openstreetmap.org/node/" and append it to "poi:n"
nearbyStationsPoi("poi:n35121252");
}
@Test
public void nearbyStationsAny() throws Exception {
// coordinates to find stations around
nearbyStationsAny(52231160, 21010740);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
// station that does not exist?
nearbyStationsInvalidStation("stop_point:RTP:SP:392");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
// what is it for??
queryDeparturesEquivsFalse("stop_point:OWW:SP:ctr");
}
@Test
public void queryDeparturesStopArea() throws Exception {
// what is it for??
// has to be an existing stop area (i.e. ID contains "SA")
queryDeparturesStopArea("stop_area:OWW:SA:709003");
}
@Test
public void queryDeparturesEquivsTrue() throws Exception {
// what is it for??
// can be the same to queryDeparturesEquivsFalse
queryDeparturesEquivsTrue("stop_point:OWW:SP:709003");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
// station that does not exist
queryDeparturesInvalidStation("stop_point:OBO:SP:999999");
}
@Test
public void suggestLocations() throws Exception {
// start of a place name that should return something
suggestLocationsFromName("Pałac");
}
@Test
public void suggestLocationsFromAddress() throws Exception {
// start of an address that should return something
suggestLocationsFromAddress("Radarowa 1");
}
@Test
public void suggestLocationsNoLocation() throws Exception {
// fake place that will not return results
suggestLocationsNoLocation("quinconcesadasdjkaskd");
}
@Test
public void queryTripAddresses() throws Exception {
// two existing addresses to define a trip
queryTrip("Radarowa 1, Warszawa", "Nowowiejska 37a, Warszawa");
}
@Test
public void queryTripAddressStation() throws Exception {
// one existing address and one existing station to define a trip
queryTrip("Nowowiejska 37a, Warszawa", "Centrum 01, Warszawa");
}
@Test
public void queryTripStations() throws Exception {
// two existing stops to define a trip
queryTrip("Radarowa 01", "Centrum 01");
}
@Test
public void queryTripStations2() throws Exception {
// two existing stations for a trip, second test case
queryTrip("Ratuszowa - ZOO 01", "Nowowiejska 01");
}
@Test
public void queryTripStations3() throws Exception {
// two existing stations for a trip, third test case
queryTrip("Warszawa Zoo", "Politechnika");
}
@Test
public void queryTripStationsRapidTransit() throws Exception {
// two existing stations for "rapid transit"... ?
queryTrip("Politechnika", "Centrum");
}
@Test
public void queryTripNoSolution() throws Exception {
// two existing stations that are not connected
queryTripNoSolution("Centrum", "Sródmiescie SKM");
}
@Test
public void queryTripUnknownFrom() throws Exception {
// existing station for end of trip, don't know where from
queryTripUnknownFrom("Centrum");
}
@Test
public void queryTripUnknownTo() throws Exception {
// existing station to start from, don't know where to
queryTripUnknownTo("Politechnika");
}
@Test
public void queryTripSlowWalk() throws Exception {
// two addresses for a "slow walk"
queryTripSlowWalk("Nowowiejska 37a, Warszawa", "Centrum 01, Warszawa");
}
@Test
public void queryTripFastWalk() throws Exception {
// two addresses for a "fast walk", can be same as above
queryTripFastWalk("Nowowiejska 37a, Warszawa", "Centrum 01, Warszawa");
}
@Test
public void queryMoreTrips() throws Exception {
// two addresses to show more trip options, can be same as above
queryMoreTrips("Nowowiejska 37a, Warszawa", "Centrum 01, Warszawa");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,86 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.PlProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class PlProviderLiveTest extends AbstractProviderLiveTest {
public PlProviderLiveTest() {
super(new PlProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "5100065"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52227027, 20989795));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("5100065", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Warszawa");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Służewiec");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "5196001", null, "KRAKÓW"), null,
new Location(LocationType.STATION, "5196003", null, "WARSZAWA"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,51 @@
/*
* Copyright 2010-2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import org.junit.Test;
import de.schildbach.pte.QuebecProvider;
/**
* @author Stephane Berube
*/
public class QuebecProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public QuebecProviderLiveTest() {
super(new QuebecProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_area:OML:SA:CTP3102842");
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_area:OML:SA:CTPxxxxxxx");
}
@Test
public void queryDeparturesStopArea() throws Exception {
queryDeparturesStopArea("stop_area:OML:SA:CTP3102842");
}
@Test
public void suggestLocations() throws Exception {
suggestLocations("Airport");
}
}

View file

@ -0,0 +1,146 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.RtProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class RtProviderLiveTest extends AbstractProviderLiveTest {
public RtProviderLiveTest() {
super(new RtProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8500010"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52525589, 13369548));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("8588344", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("haupt");
print(result);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dorfstrasse 10, Dällikon, Schweiz");
print(result);
}
@Test
public void suggestLocationsEncoding() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dorfstrasse 1, Schäftland");
assertEquals("Schöftland, Dorfstrasse", result.getLocations().get(0).name);
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8503000", null, "Zürich HB"),
null, new Location(LocationType.STATION, "8507785", null, "Bern, Hauptbahnhof"), new Date(), true,
null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void slowTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.ANY, null, null, "Schocherswil, Alte Post!"), null,
new Location(LocationType.ANY, null, null, "Laconnex, Mollach"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripWithFootway() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.ADDRESS, null, null, "Spiez, Seestraße 62"), null,
new Location(LocationType.ADDRESS, null, null, "Einsiedeln, Erlenmoosweg 24"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripFromAddress() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51521886, -51447), null,
"26 Coopers Close, Poplar, Greater London E1 4, Vereinigtes Königreich");
final Location to = new Location(LocationType.STATION, "8096022", Point.from1E6(50941312, 6967206), null,
"COLOGNE");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void viaTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8400056", null, "Amsterdam RAI"),
new Location(LocationType.STATION, "8400058", null, "Amsterdam Centraal"),
new Location(LocationType.STATION, "8000085", null, "Düsseldorf Hbf"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void crossStateTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8000207", null, "Köln Hbf"),
null, new Location(LocationType.STATION, "6096001", null, "DUBLIN"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,99 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.RtaChicagoProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class RtaChicagoProviderLiveTest extends AbstractProviderLiveTest {
public RtaChicagoProviderLiveTest() {
super(new RtaChicagoProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10101442"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(41870003, -88156946));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("10101442", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Station");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "10101442"), null,
new Location(LocationType.STATION, "10101111"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,127 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.SbbProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class SbbProviderLiveTest extends AbstractProviderLiveTest {
public SbbProviderLiveTest() {
super(new SbbProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8500010"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52525589, 13369548));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("8500010", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("haupt");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Höhle");
print(result);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dorfstrasse 10, Dällikon, Schweiz");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8503000", null, "Zürich HB"),
null, new Location(LocationType.STATION, "8507785", null, "Bern, Hauptbahnhof"), new Date(), true,
null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void slowTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "8587210", null, "Schocherswil, Alte Post"), null,
new Location(LocationType.STATION, "8592972", null, "Laconnex, Mollach"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripWithFootway() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(46689354, 7683444), null,
"Spiez, Seestraße 62");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(47133169, 8767425), null,
"Einsiedeln, Erlenmoosweg 24");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripFromAddress() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(47438595, 8437369), null,
"Dorfstrasse 10, Dällikon, Schweiz");
final Location to = new Location(LocationType.STATION, "8500010", null, "Basel");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,118 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.SeProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class SeProviderLiveTest extends AbstractProviderLiveTest {
public SeProviderLiveTest() {
super(new SeProvider(secretProperty("se.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(57709311, 11988459));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("740017515", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Airport");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Luleå");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "740098049")));
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult result = suggestLocations("Stockholm");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "740098000")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "740014867", null, "Luleå Airport");
final Location to = new Location(LocationType.STATION, "740098000", null, "STOCKHOLM");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void shortStockholmTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "740098000", null, "STOCKHOLM");
final Location to = new Location(LocationType.STATION, "740020101", "Stockholm", "Slussen T-bana");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void longTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "740098086", null, "KIRUNA");
final Location to = new Location(LocationType.STATION, "740098000", null, "STOCKHOLM");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(59.3299775, 18.0576622)); // Stockholm Central
final Location to = Location.coord(Point.fromDouble(59.3136500, 18.0620848)); // Stockholms södra
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,136 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.ShProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class ShProviderLiveTest extends AbstractProviderLiveTest {
public ShProviderLiveTest() {
super(new ShProvider(secretProperty("sh.api_authorization")));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8002547"));
print(result);
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "999999"));
assertEquals(NearbyLocationsResult.Status.INVALID_ID, result.status);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(54325845, 10122920));
print(result);
assertTrue(result.locations.size() > 0);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("8002547", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Lübeck");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Achterüm");
print(result);
}
@Test
public void suggestLocationsWithoutCoordinatesInResult() throws Exception {
final SuggestLocationsResult result = suggestLocations("aachen");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "8002547", null, "Flughafen Hamburg"), null,
new Location(LocationType.STATION, "8003781", null, "Lübeck Airport"), new Date(), true, null);
print(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripKiel() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "3490015"), null,
new Location(LocationType.STATION, "706923"), new Date(), true, null);
print(result);
}
@Test
public void tripKielVia() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "3490015"),
new Location(LocationType.STATION, "3490020"), new Location(LocationType.STATION, "706923"), new Date(),
true, null);
print(result);
}
@Test
public void tripKielPoi() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "3490015"), null,
new Location(LocationType.POI,
"A=4@O=Kiel, Hiroshimapark@X=10131697@Y=54324466@U=104@L=970001375@B=1@V=14.9,@p=1397713274@"),
new Date(), true, null);
print(result);
}
@Test
public void trip_errorTooClose() throws Exception {
final Location station = new Location(LocationType.STATION, "003665026");
final QueryTripsResult result = queryTrips(station, null, station, new Date(), true, null);
assertEquals(QueryTripsResult.Status.TOO_CLOSE, result.status);
}
}

View file

@ -0,0 +1,123 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.SncbProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class SncbProviderLiveTest extends AbstractProviderLiveTest {
public SncbProviderLiveTest() {
super(new SncbProvider(secretProperty("sncb.api_authorization")));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8813003"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(50748017, 3407118));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result1 = queryDepartures("240229", false);
print(result1);
final QueryDeparturesResult result2 = queryDepartures("8813003", false);
print(result2);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Brussel S");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Brüssel");
print(result);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Rue Paul Janson 9, 1030 Bruxelles");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "8821006", "Antwerpen", "Centraal");
final Location to = new Location(LocationType.STATION, "8813003", "Brussel", "Centraal");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void longTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "207280", "Brussel", "Wannecouter");
final Location to = new Location(LocationType.STATION, "207272", "Brussel", "Stadion");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripFromAddress() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, null, "Bruxelles - Haren, Rue Paul Janson 9");
final Location to = new Location(LocationType.STATION, "8500010", null, "Basel");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(50.8356748, 4.3362419)); // Brussels-Midi
final Location to = Location.coord(Point.fromDouble(50.8605993, 4.3612788)); // Brussel-Noord
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright 2015-2016 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import de.schildbach.pte.SpainProvider;
import de.schildbach.pte.dto.Point;
public class SpainProviderLiveTest extends AbstractNavitiaProviderLiveTest {
public SpainProviderLiveTest() {
super(new SpainProvider(secretProperty("navitia.authorization")));
}
@Test
public void nearbyStationsAddress() throws Exception {
// Valencia
nearbyStationsAddress(39473600, -371100);
}
@Test
public void nearbyStationsAddress2() throws Exception {
// Madrid
nearbyStationsAddress(40410400, -3702400);
}
@Test
public void nearbyStationsStation() throws Exception {
nearbyStationsStation("stop_point:E38:SP:2223");
}
@Test
public void nearbyStationsInvalidStation() throws Exception {
nearbyStationsInvalidStation("stop_point:EX38:SP:2223");
}
@Test
public void queryDeparturesEquivsFalse() throws Exception {
queryDeparturesEquivsFalse("stop_point:E38:SP:2223");
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
queryDeparturesInvalidStation("stop_point:OWX:SP:6911");
}
@Test
public void suggestLocations() throws Exception {
suggestLocationsFromName("Turia");
}
@Test
public void queryTripStations() throws Exception {
queryTrip("Benimaclet", "Nou d'Octubre");
}
@Test
public void queryMoreTrips() throws Exception {
queryMoreTrips("Valencia Sud", "Faitanar");
}
@Test
public void getArea() throws Exception {
final Point[] polygon = provider.getArea();
assertTrue(polygon.length > 0);
}
}

View file

@ -0,0 +1,131 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.StvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class StvProviderLiveTest extends AbstractProviderLiveTest {
public StvProviderLiveTest() {
super(new StvProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "63203040"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(47072612, 15431814));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("63203040", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("grün");
print(result);
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult grazResult = suggestLocations("Graz Brauhaus");
print(grazResult);
assertThat(grazResult.getLocations(), hasItem(new Location(LocationType.STATION, "63203044")));
final SuggestLocationsResult leobenResult = suggestLocations("Leoben Blockhäuser");
print(leobenResult);
assertThat(leobenResult.getLocations(), hasItem(new Location(LocationType.STATION, "63206224")));
final SuggestLocationsResult bruckResult = suggestLocations("Bruck Hauptplatz");
print(bruckResult);
assertThat(bruckResult.getLocations(), hasItem(new Location(LocationType.STATION, "63202063")));
final SuggestLocationsResult kindbergResult = suggestLocations("Kindberg Friedhof");
print(kindbergResult);
assertThat(kindbergResult.getLocations(), hasItem(new Location(LocationType.STATION, "63208877")));
final SuggestLocationsResult mariborResult = suggestLocations("Maribor Dravograjska Sokolska");
print(mariborResult);
assertThat(mariborResult.getLocations(), hasItem(new Location(LocationType.STATION, "63300136")));
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "63203040", null, "Graz Hauptbahnhof"), null,
new Location(LocationType.STATION, "63203149", null, "Graz Babenbergerstraße"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,114 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.SvvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class SvvProviderLiveTest extends AbstractProviderLiveTest {
public SvvProviderLiveTest() {
super(new SvvProvider(secretProperty("svv.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(47813093, 13045065));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("455000200", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", 0, false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Salzburg Hauptbahnhof");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "455000200")));
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Südstadt");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "900017135")));
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kaigasse 10");
print(result);
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult result = suggestLocations("Salzburg Hauptbahnhof");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "455000200")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "455002100", Point.from1E6(47797110, 13053632),
"Salzburg", "Justizgebäude");
final Location to = new Location(LocationType.STATION, "455002200", Point.from1E6(47794000, 13059223),
"Salzburg", "Akademiestraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,124 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.SydneyProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class SydneyProviderLiveTest extends AbstractProviderLiveTest {
public SydneyProviderLiveTest() {
super(new SydneyProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "10101101"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(-32823911, 151462824));
print(result);
}
@Test
public void queryDeparturesTownHall() throws Exception {
final QueryDeparturesResult result = queryDepartures("10101101", false);
print(result);
}
@Test
public void queryDeparturesCircularQuay() throws Exception {
final QueryDeparturesResult result = queryDepartures("10101103", false);
print(result);
}
@Test
public void queryDeparturesConvention() throws Exception {
final QueryDeparturesResult result = queryDepartures("10101439", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Sydney, Town Hall Station");
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsEmpty() throws Exception {
final SuggestLocationsResult result = suggestLocations("kreide");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "10101100", "Sydney", "Central Station"), null,
new Location(LocationType.STATION, null, "Sydney", "Capitol Square"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,102 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.TfiProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class TfiProviderLiveTest extends AbstractProviderLiveTest {
public TfiProviderLiveTest() {
super(new TfiProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "51013670"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(53348656, -6262221));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("51013670", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Lower O'Connell Street");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "51013670", "Dublin City South",
"O'Connell Bridge (on Lower O'Connell Street)"),
null, new Location(LocationType.STATION, "51005661", "Dublin City South", "Dublin (Baggot Street)"),
new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,207 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.TlemProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class TlemProviderLiveTest extends AbstractProviderLiveTest {
public TlemProviderLiveTest() {
super(new TlemProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result1 = queryNearbyStations(new Location(LocationType.STATION, "1001003"));
print(result1);
final NearbyLocationsResult result2 = queryNearbyStations(new Location(LocationType.STATION, "1000086"));
print(result2);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51507161, -0127144));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result1 = queryDepartures("1001003", false);
print(result1);
final QueryDeparturesResult result2 = queryDepartures("1000086", false);
print(result2);
}
@Test
public void queryDeparturesEquivs() throws Exception {
final QueryDeparturesResult result = queryDepartures("1001003", true);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult resultLive = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, resultLive.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Lower Arncott The Plough");
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Birming");
print(result);
}
@Test
public void shortTrip1() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "1008730", null, "King & Queen Wharf"), null,
new Location(LocationType.STATION, "1006433", null, "Edinburgh Court"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void shortTrip2() throws Exception {
final Location from = new Location(LocationType.STATION, "2099014", Point.from1E6(52478184, -1898364),
"Birmingham", "Birmingham New Street Rail Station");
final Location to = new Location(LocationType.STATION, "2099150", Point.from1E6(52585468, -2122962),
"Wolverhampton", "Wolverhampton Rail Station");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripArncott() throws Exception {
final Location from = new Location(LocationType.STATION, "60011202", Point.from1E6(51850168, -1094302),
"Upper Arncott", "Bullingdon Prison");
final Location to = new Location(LocationType.STATION, "60006013", Point.from1E6(51856612, -1112904),
"Lower Arncott", "The Plough E");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripFromPOI() throws Exception {
final Location from = new Location(LocationType.POI,
"poiID:48863:31117134:-1:Statue:Ham (London):Statue:ANY:POI:517246:826916:TFLV:uk",
Point.from1E6(51444620, -314316), "Ham (London)", "Statue");
final Location to = new Location(LocationType.ADDRESS, "streetID:106269::31117001:-1", "London",
"Cannon Street, London");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripFromAddress() throws Exception {
final Location from = new Location(LocationType.ADDRESS, "streetID:203417::31117006:-1", "London",
"Kings Cross, London");
final Location to = new Location(LocationType.STATION, "1002070", Point.from1E6(51508530, 46706),
"Royal Albert", "Royal Albert");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripPostcode() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "se7 7tr"), null,
new Location(LocationType.ANY, null, null, "n9 0nx"), new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,187 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VaoProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VaoProviderLiveTest extends AbstractProviderLiveTest {
public VaoProviderLiveTest() {
super(new VaoProvider(secretProperty("vao.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48207355, 16370602));
print(result);
}
@Test
public void nearbyStationsByCoordinateSalzburg() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(47809195, 13054919));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("480082200", 0, false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesSalzburg() throws Exception {
final QueryDeparturesResult result = queryDepartures("455000200", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", 0, false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Katzenturm");
print(result);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Mutterstraße 4, 6800 Feldkirch");
print(result);
}
@Test
public void suggestLocationsEncoding() throws Exception {
final SuggestLocationsResult result = suggestLocations("Schönbrunn");
assertEquals("Wien Schönbrunn", result.getLocations().get(0).name);
print(result);
}
@Test
public void suggestLocationsCoverageSalzburg() throws Exception {
final SuggestLocationsResult result = suggestLocations("Salzburg Süd");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "900022177")));
}
@Test
public void suggestLocationsCoverageStrasswalchen() throws Exception {
final SuggestLocationsResult result = suggestLocations("Straßwalchen West");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "455648300")));
}
@Test
public void suggestLocationsCoverageSchwarzach() throws Exception {
final SuggestLocationsResult result = suggestLocations("Schwarzach Abtsdorf");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "455661400")));
}
@Test
public void suggestLocationsCoverageTrimmelkam() throws Exception {
final SuggestLocationsResult result = suggestLocations("Trimmelkam");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "900018413")));
}
@Test
public void shortTripFeldkirch() throws Exception {
final Location from = new Location(LocationType.STATION, "480082200", null, "Feldkirch Katzenturm");
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult laterResult2 = queryMoreTrips(laterResult.context, true);
print(laterResult2);
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
print(earlierResult);
}
@Test
public void shortTripWien() throws Exception {
final Location from = new Location(LocationType.STATION, "490132000", null, "Wien Stephansplatz");
final Location to = new Location(LocationType.STATION, "490024500", null, "Wien Stubentor");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult laterResult2 = queryMoreTrips(laterResult.context, true);
print(laterResult2);
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
print(earlierResult);
}
@Test
public void shortTripSalzburg() throws Exception {
final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409),
"Salzburg", "Vogelweiderstraße");
final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278),
"Salzburg", "Merianstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripAddressToStation() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"A=2@O=6800 Feldkirch, Kapfweg 6@X=9585539@Y=47239257@U=103@L=980092305@B=1@p=1437727591@",
"6800 Feldkirch", "Kapfweg 6");
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripCoordinateToStation() throws Exception {
final Location from = Location.coord(47238096, 9585581);
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,213 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import de.schildbach.pte.AbstractHafasClientInterfaceProvider;
import de.schildbach.pte.VbbProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VbbProviderLiveTest extends AbstractProviderLiveTest {
public VbbProviderLiveTest() {
super(new VbbProvider(secretProperty("vbb.api_authorization"), AbstractHafasClientInterfaceProvider
.decryptSalt(secretProperty("vbb.encrypted_salt"), secretProperty("hci.salt_encryption_key"))));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(52548505, 13388640));
print(result);
assertTrue(result.locations.size() > 0);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("900007102", false);
print(result);
}
@Test
public void queryDeparturesAlexanderplatzBhf() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100003", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesAlexanderplatzU2() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100703", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesAlexanderplatzU5() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100704", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesAlexanderplatzU8() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100705", false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesEquivs() throws Exception {
final QueryDeparturesResult result = queryDepartures("900100003", true);
print(result);
assertTrue(result.stationDepartures.size() > 1);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult resultLive = queryDepartures("111111", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, resultLive.status);
final QueryDeparturesResult resultPlan = queryDepartures("2449475", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, resultPlan.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Haubachstr.");
print(result);
Assert.assertEquals("Haubachstr.", result.getLocations().get(0).name);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Güntzelstr.");
print(result);
Assert.assertEquals("U Güntzelstr.", result.getLocations().get(0).name);
}
@Test
public void suggestLocationsPOI() throws Exception {
final SuggestLocationsResult result = suggestLocations("schwules museum");
print(result);
Assert.assertThat(result.getLocations(), hasItem(new Location(LocationType.POI,
"A=4@O=Berlin, Schwules Museum@X=13357979@Y=52504519@U=104@L=900980141@B=1@V=3.9,@p=1542286309@")));
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("10178 Berlin, Sophienstr. 24");
print(result);
Assert.assertEquals("Sophienstr. 24", result.getLocations().get(0).name);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("nol");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "900056102", "Berlin", "Nollendorfplatz");
final Location to = new Location(LocationType.STATION, "900013103", "Berlin", "Prinzenstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult earlierResult = queryMoreTrips(laterResult.context, false);
print(earlierResult);
}
@Test
public void shortFootwayTrip() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52435193, 13473409),
"12357 Berlin-Buckow", "Kernbeisserweg 4");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52433989, 13474353),
"12357 Berlin-Buckow", "Distelfinkweg 35");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void shortViaTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "900056102", "Berlin", "Nollendorfplatz");
final Location via = new Location(LocationType.STATION, "900044202", "Berlin", "Bundesplatz");
final Location to = new Location(LocationType.STATION, "900013103", "Berlin", "Prinzenstraße");
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(52.5249451, 13.3696614)); // Berlin Hbf
final Location to = Location.coord(Point.fromDouble(52.5071378, 13.3318680)); // S Zoologischer Garten
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void viaTripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(52.4999599, 13.3619411)); // U Kurfürsterstr.
final Location via = Location.coord(Point.fromDouble(52.4778673, 13.3286942)); // S+U Bundesplatz
final Location to = Location.coord(Point.fromDouble(52.5126122, 13.5752134)); // S+U Wuhletal
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278),
"10715 Berlin-Wilmersdorf", "Weimarische Str. 7");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52541536, 13421290),
"10437 Berlin-Prenzlauer Berg", "Göhrener Str. 5");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void viaTripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(52479663, 13324278),
"10715 Berlin-Wilmersdorf", "Weimarische Str. 7");
final Location via = new Location(LocationType.ADDRESS, null, Point.from1E6(52527872, 13381657),
"10115 Berlin-Mitte", "Hannoversche Str. 20");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(52526029, 13399878),
"10178 Berlin-Mitte", "Sophienstr. 24");
final QueryTripsResult result = queryTrips(from, via, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,115 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VblProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VblProviderLiveTest extends AbstractProviderLiveTest {
public VblProviderLiveTest() {
super(new VblProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "119"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(47049107, 8312502));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("717", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Luzern, Kantonalbank");
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("grün");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "53020041", Point.from1E6(47050164, 8310352), "Luzern",
"Bahnhof");
final Location to = new Location(LocationType.STATION, "53028841", Point.from1E6(47048564, 8306016), "Luzern",
"Kantonalbank");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,194 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.AbstractHafasClientInterfaceProvider;
import de.schildbach.pte.VbnProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VbnProviderLiveTest extends AbstractProviderLiveTest {
public VbnProviderLiveTest() {
super(new VbnProvider(secretProperty("vbn.api_authorization"), AbstractHafasClientInterfaceProvider
.decryptSalt(secretProperty("vbn.encrypted_salt"), secretProperty("hci.salt_encryption_key"))));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result1 = queryNearbyStations(Location.coord(53086421, 8806388));
print(result1);
final NearbyLocationsResult result2 = queryNearbyStations(Location.coord(51536614, 9925673));
print(result2);
final NearbyLocationsResult result3 = queryNearbyStations(Location.coord(54078314, 12131715));
print(result3);
}
@Test
public void queryDeparturesFreudenstadt() throws Exception {
final QueryDeparturesResult result = queryDepartures("8000110", false);
print(result);
}
@Test
public void queryDeparturesGoettingen() throws Exception {
final QueryDeparturesResult result = queryDepartures("8000128", false);
print(result);
}
@Test
public void queryDeparturesRostockHbf() throws Exception {
final QueryDeparturesResult result = queryDepartures("8010304", false);
print(result);
}
@Test
public void queryDeparturesEquivs() throws Exception {
final QueryDeparturesResult result = queryDepartures("8010304", true);
print(result);
assertTrue(result.stationDepartures.size() > 1);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsBremen() throws Exception {
final SuggestLocationsResult result = suggestLocations("Bremen");
print(result);
}
@Test
public void suggestLocationsHannover() throws Exception {
final SuggestLocationsResult result = suggestLocations("Hannover");
print(result);
}
@Test
public void suggestLocationsRostock() throws Exception {
final SuggestLocationsResult result = suggestLocations("Rostock");
print(result);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result1 = suggestLocations("Göttingen Hauptbahnhof");
print(result1);
assertEquals("Göttingen", result1.getLocations().get(0).name);
final SuggestLocationsResult result2 = suggestLocations("Lütten Klein");
print(result2);
assertEquals("Lütten Klein", result2.getLocations().get(0).name);
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult rostockResult = suggestLocations("Rostock");
print(rostockResult);
assertThat(rostockResult.getLocations(), hasItem(new Location(LocationType.STATION, "8010304")));
final SuggestLocationsResult warnemuendeResult = suggestLocations("Warnemünde");
print(warnemuendeResult);
assertThat(warnemuendeResult.getLocations(), hasItem(new Location(LocationType.STATION, "8013236")));
}
@Test
public void suggestLocationsLocality() throws Exception {
final SuggestLocationsResult result = suggestLocations("lange straße");
print(result);
assertThat(result.getLocations(),
hasItem(new Location(LocationType.STATION, "708425", "Rostock", "Lange Straße")));
}
@Test
public void suggestLocationsWithoutCoordinatesInResult() throws Exception {
final SuggestLocationsResult result = suggestLocations("aachen");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8096109", null, "Oldenburg"),
null, new Location(LocationType.STATION, "625398", null, "Bremerhaven"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
if (!earlierResult.context.canQueryEarlier())
return;
final QueryTripsResult earlier2Result = queryMoreTrips(earlierResult.context, false);
print(earlier2Result);
}
@Test
public void shortTripGoettingen() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8000128", null, "Göttingen"),
null, new Location(LocationType.STATION, "1140061", null, "Göttingen Nikolausberger Weg"), new Date(),
true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripDateOutsideTimetablePeriod() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8096109", null, "Oldenburg"),
null, new Location(LocationType.STATION, "625398", null, "Bremerhaven"), new Date(1155822689759l), true,
null);
assertEquals(QueryTripsResult.Status.INVALID_DATE, result.status);
}
}

View file

@ -0,0 +1,151 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VgnProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VgnProviderLiveTest extends AbstractProviderLiveTest {
public VgnProviderLiveTest() {
super(new VgnProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "3000510"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(49455472, 11079655));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("3000510", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlautDuerrenhof() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dürrenhof");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "3000427")));
}
@Test
public void suggestLocationsWithUmlautRoethenbach() throws Exception {
final SuggestLocationsResult result = suggestLocations("Röthenbach");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "3001970")));
}
@Test
public void suggestAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Nürnberg, Wodanstraße 25");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:2519:25:9564000:1:Wodanstraße:Nürnberg:Wodanstraße::Wodanstraße:90461:ANY:DIVA_SINGLEHOUSE:4434433:681777:NAV4:VGN")));
}
@Test
public void suggestStreet() throws Exception {
final SuggestLocationsResult result = suggestLocations("Nürnberg, Wodanstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:2519::9564000:-1:Wodanstraße:Nürnberg:Wodanstraße::Wodanstraße: 90461:ANY:DIVA_STREET:4434565:681747:NAV4:VGN")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "451", "Nürnberg", "Ostring");
final Location to = new Location(LocationType.STATION, "510", "Nürnberg", "Hauptbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripToPOI() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(49527298, 10836204));
final Location to = new Location(LocationType.POI,
"poiID:246:9564000:1:Grundschule Grimmstr.:Nürnberg:Grundschule Grimmstr.:ANY:POI:4436708:678322:NAV4:VGN",
Point.from1E6(49468692, 11125334), "Nürnberg", "Grundschule Grimmstr.");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:832:2:9564000:1:Saarbrückener Straße:Nürnberg:Saarbrückener Straße::Saarbrückener Straße:90469:ANY:DIVA_SINGLEHOUSE:4433846:685282:NAV4:VGN",
null, "Saarbrückener Straße 2");
final Location to = new Location(LocationType.ADDRESS,
"streetID:2519:25:9564000:1:Wodanstraße:Nürnberg:Wodanstraße::Wodanstraße:90461:ANY:DIVA_SINGLEHOUSE:4434433:681777:NAV4:VGN",
null, "Wodanstraße 25");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null);
print(result);
}
@Test
public void tripBetweenStreets() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:832::9564000:-1:Saarbrückener Straße:Nürnberg:Saarbrückener Straße::Saarbrückener Straße: 90469:ANY:DIVA_STREET:4433819:685855:NAV4:VGN",
null, "Saarbrückener Straße");
final Location to = new Location(LocationType.ADDRESS,
"streetID:2519::9564000:-1:Wodanstraße:Nürnberg:Wodanstraße::Wodanstraße: 90461:ANY:DIVA_STREET:4434565:681747:NAV4:VGN",
null, "Wodanstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), false, null);
print(result);
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.AbstractHafasClientInterfaceProvider;
import de.schildbach.pte.VgsProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VgsProviderLiveTest extends AbstractProviderLiveTest {
public VgsProviderLiveTest() {
super(new VgsProvider(secretProperty("vgs.api_authorization"), AbstractHafasClientInterfaceProvider
.decryptSalt(secretProperty("vgs.encrypted_salt"), secretProperty("hci.salt_encryption_key"))));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8000244"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(49234783, 6995687));
print(result);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Flughafen");
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("8000244", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "10640", "Saarbrücken", "Hauptbahnhof"), null,
new Location(LocationType.STATION, "10700", "Saarbrücken", "Ostbahnhof"), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,187 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VmobilProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VmobilProviderLiveTest extends AbstractProviderLiveTest {
public VmobilProviderLiveTest() {
super(new VmobilProvider(secretProperty("vmobil.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48207355, 16370602));
print(result);
}
@Test
public void nearbyStationsByCoordinateSalzburg() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(47809195, 13054919));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("480082200", 0, false);
print(result);
assertEquals(QueryDeparturesResult.Status.OK, result.status);
}
@Test
public void queryDeparturesSalzburg() throws Exception {
final QueryDeparturesResult result = queryDepartures("455000200", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", 0, false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Feldkirch");
print(result);
}
@Test
public void suggestLocationsAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Mutterstraße 4, 6800 Feldkirch");
print(result);
}
@Test
public void suggestLocationsEncoding() throws Exception {
final SuggestLocationsResult result = suggestLocations("Wien Schönbrunn");
assertEquals("Wien Schönbrunn", result.getLocations().get(0).name);
print(result);
}
@Test
public void suggestLocationsCoverageFeldkirch() throws Exception {
final SuggestLocationsResult result = suggestLocations("Feldkirch Bahnhof");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "480081700")));
}
@Test
public void suggestLocationsCoverageStrasswalchen() throws Exception {
final SuggestLocationsResult result = suggestLocations("Straßwalchen West");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "455648300")));
}
@Test
public void suggestLocationsCoverageSchwarzach() throws Exception {
final SuggestLocationsResult result = suggestLocations("Schwarzach Abtsdorf");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "455661400")));
}
@Test
public void suggestLocationsCoverageTrimmelkam() throws Exception {
final SuggestLocationsResult result = suggestLocations("Trimmelkam");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "900018413")));
}
@Test
public void shortTripFeldkirch() throws Exception {
final Location from = new Location(LocationType.STATION, "480082200", null, "Feldkirch Katzenturm");
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult laterResult2 = queryMoreTrips(laterResult.context, true);
print(laterResult2);
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
print(earlierResult);
}
@Test
public void shortTripWien() throws Exception {
final Location from = new Location(LocationType.STATION, "490132000", null, "Wien Stephansplatz");
final Location to = new Location(LocationType.STATION, "490024500", null, "Wien Stubentor");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult laterResult2 = queryMoreTrips(laterResult.context, true);
print(laterResult2);
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
print(earlierResult);
}
@Test
public void shortTripSalzburg() throws Exception {
final Location from = new Location(LocationType.STATION, "455000900", Point.from1E6(47808976, 13056409),
"Salzburg", "Vogelweiderstraße");
final Location to = new Location(LocationType.STATION, "455084400", Point.from1E6(47811556, 13050278),
"Salzburg", "Merianstraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripAddressToStation() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"A=2@O=6800 Feldkirch, Kapfweg 6@X=9585539@Y=47239257@U=103@L=980092305@B=1@p=1437727591@",
"6800 Feldkirch", "Kapfweg 6");
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripCoordinateToStation() throws Exception {
final Location from = Location.coord(47238096, 9585581);
final Location to = new Location(LocationType.STATION, "480081700", null, "Feldkirch Bahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,103 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VmsProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VmsProviderLiveTest extends AbstractProviderLiveTest {
public VmsProviderLiveTest() {
super(new VmsProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "36030062"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(50832754, 12918348));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("36030062", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "36030131", Point.from1E6(50831380, 12922278),
"Chemnitz", "Zentralhaltestelle");
final Location to = new Location(LocationType.STATION, "36030522", Point.from1E6(50836056, 12922042),
"Chemnitz", "Stadthalle");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,97 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VmtProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VmtProviderLiveTest extends AbstractProviderLiveTest {
public VmtProviderLiveTest() {
super(new VmtProvider(secretProperty("vmt.api_authorization")));
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "153166"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(50972622, 11037283));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("153166", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Jena Stadtzentrum");
print(result);
final SuggestLocationsResult result2 = suggestLocations("Spittelplatz");
print(result2);
}
@Test
public void suggestLocationsUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Höhle");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "153166", Point.from1E6(50926947, 11586987), null,
"Jena, Stadtzentrum");
final Location to = new Location(LocationType.STATION, "153014", Point.from1E6(50933887, 11590592), null,
"Jena, Spittelpl.");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
System.out.println(result);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
System.out.println(laterResult);
}
}

View file

@ -0,0 +1,110 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VmvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VmvProviderLiveTest extends AbstractProviderLiveTest {
public VmvProviderLiveTest() {
super(new VmvProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "44402031"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(53637555, 11392593));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("80001834", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsSchwerin() throws Exception {
final SuggestLocationsResult result = suggestLocations("Schwerin Hauptbahnhof");
print(result);
assertEquals("Schwerin", result.getLocations().get(0).place);
assertEquals("Hauptbahnhof", result.getLocations().get(0).name);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "44402006", null, "Schwerin Marienplatz");
final Location to = new Location(LocationType.STATION, "44402007", Point.from1E6(53625272, 11409350), null,
"Schlossblick");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,131 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VorProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VorProviderLiveTest extends AbstractProviderLiveTest {
public VorProviderLiveTest() {
super(new VorProvider(secretProperty("vor.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48207355, 16370602));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("490134900", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", 0, false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Wien Hauptbahnhof");
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Längenfeld");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "900019683")));
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult huetteldorfResult = suggestLocations("Wien Hütteldorf");
print(huetteldorfResult);
assertThat(huetteldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "490056000")));
final SuggestLocationsResult wienerNeustadtResult = suggestLocations("Wiener Neustadt Nord");
print(wienerNeustadtResult);
assertThat(wienerNeustadtResult.getLocations(), hasItem(new Location(LocationType.STATION, "430522300")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "490065700", Point.from1E6(48200852, 16368880), "Wien",
"Karlsplatz");
final Location to = new Location(LocationType.STATION, "490109400", Point.from1E6(48198362, 16367667), "Wien",
"Resselgasse");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripToPOI() throws Exception {
final Location from = new Location(LocationType.STATION, "490134900", Point.from1E6(48185184, 16376413));
final Location to = new Location(LocationType.POI,
"A=4@O=Naschmarkt, Wien@X=16362903@Y=48198290@U=130@L=960068499@B=1@p=1476842541@",
Point.from1E6(48198290, 16362903), "Wien", "Naschmarkt");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(48180281, 16333551);
final Location to = Location.coord(48240452, 16444788);
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,176 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VrnProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VrnProviderLiveTest extends AbstractProviderLiveTest {
public VrnProviderLiveTest() {
super(new VrnProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result1 = queryNearbyStations(new Location(LocationType.STATION, "6032236"));
print(result1);
final NearbyLocationsResult result2 = queryNearbyStations(new Location(LocationType.STATION, "17001301"));
print(result2);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result1 = queryNearbyStations(Location.coord(49486561, 8477297));
print(result1);
final NearbyLocationsResult result2 = queryNearbyStations(Location.coord(49757571, 6639147));
print(result2);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result1 = queryDepartures("6032236", false);
print(result1);
final QueryDeparturesResult result2 = queryDepartures("17001301", false);
print(result2);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Käfertal");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "6005547")));
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Bremen, KUR");
print(result);
}
@Test
public void suggestLocationsLocality() throws Exception {
final SuggestLocationsResult result = suggestLocations("Bremen");
print(result);
}
@Test
public void suggestLocationsCity() throws Exception {
final SuggestLocationsResult result = suggestLocations("Mannheim");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "6002417", Point.from1E6(49479748, 8469938),
"Mannheim", "Mannheim, Hauptbahnhof");
final Location to = new Location(LocationType.STATION, "6005542", Point.from1E6(49482892, 8473050), "Mannheim",
"Kunsthalle");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void shortTrip2() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "17002402", null, "Bahnhof"),
null, new Location(LocationType.STATION, "17009001", null, "Bahnhof"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripWithUmlaut() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Käfertal"), null,
new Location(LocationType.STATION, "6002417", "Mannheim", "Hauptbahnhof"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
assertEquals(result.trips.get(0).from, new Location(LocationType.STATION, "6005547"));
}
}

View file

@ -0,0 +1,248 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VrrProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VrrProviderLiveTest extends AbstractProviderLiveTest {
public VrrProviderLiveTest() {
super(new VrrProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "20019904"));
print(result);
}
@Test
public void nearbyStationsByCoordinateDuesseldorf() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(
Location.coord(Point.fromDouble(51.2190163, 6.7757496)));
print(result);
assertThat(result.locations, hasItem(new Location(LocationType.STATION, "20018243"))); // Graf-Adolf-Platz
}
@Test
public void nearbyStationsByCoordinatePaderborn() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(
Location.coord(Point.fromDouble(51.7169873, 8.7537501)));
print(result);
assertThat(result.locations, hasItem(new Location(LocationType.STATION, "23207100"))); // Rathausplatz
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("1007258", false);
print(result);
final QueryDeparturesResult result2 = queryDepartures("20019904", false);
print(result2);
// Bonn
queryDepartures("22000687", false); // Hauptbahnhof
queryDepartures("22001374", false); // Suedwache
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void queryManyDeparturesWithEquivs() throws Exception {
final QueryDeparturesResult result = queryDepartures("20018235", true);
print(result);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Köln Mülheim");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "22000572")));
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Düsseldorf, Am Frohnhof");
print(result);
}
@Test
public void suggestLocationsCologne() throws Exception {
final SuggestLocationsResult result = suggestLocations("Köln Ebertplatz");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "22000035")));
}
@Test
public void suggestLocationsDortmund() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dortmund Zugstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "20000524")));
}
@Test
public void suggestLocationsDuesseldorf() throws Exception {
final SuggestLocationsResult result = suggestLocations("Düsseldorf Sternstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "20018017")));
}
@Test
public void suggestLocationsMuenster() throws Exception {
final SuggestLocationsResult result = suggestLocations("Münster Vennheideweg");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "24047291")));
}
@Test
public void suggestLocationsAachen() throws Exception {
final SuggestLocationsResult result = suggestLocations("Aachen Elisenbrunnen");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "21001029")));
}
@Test
public void suggestLocationsPaderborn() throws Exception {
final SuggestLocationsResult result = suggestLocations("Paderborn Hbf");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "23207000")));
}
@Test
public void suggestLocationsCity() throws Exception {
final SuggestLocationsResult result = suggestLocations("Düsseldorf");
print(result);
}
@Test
public void suggestAddress() throws Exception {
final SuggestLocationsResult result = suggestLocations("Hagen, Siegstraße 30");
print(result);
assertThat(result.getLocations(),
hasItem(new Location(LocationType.ADDRESS, "streetID:1500000683:30:5914000:-1")));
}
@Test
public void suggestStreet() throws Exception {
final SuggestLocationsResult result = suggestLocations("Hagen, Siegstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.ADDRESS,
"streetID:1500000683::5914000:-1:Siegstraße:Hagen:Siegstraße::Siegstraße: 58097:ANY:DIVA_STREET:831366:5312904:MRCV:nrw")));
}
@Test
public void anyTrip() throws Exception {
final Location from = new Location(LocationType.ANY, null, null, "Köln");
final Location to = new Location(LocationType.ANY, null, null, "Bonn");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status);
}
@Test
public void shortTripEssen() throws Exception {
final Location from = new Location(LocationType.STATION, "20009289", "Essen", "Hauptbahnhof");
final Location to = new Location(LocationType.STATION, "20009161", "Essen", "Bismarckplatz");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void shortTripPaderborn() throws Exception {
final Location from = new Location(LocationType.STATION, "23207000"); // Paderborn Hbf
final Location to = new Location(LocationType.STATION, "23207700"); // Höxter, Bahnhof / Rathaus
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void shortTripDorsten() throws Exception {
final Location from = new Location(LocationType.STATION, "20009643", "Bottrop", "West S");
final Location to = new Location(LocationType.STATION, "20003214", "Dorsten", "ZOB Dorsten");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void tripBetweenAddresses() throws Exception {
final Location from = new Location(LocationType.ADDRESS, "streetID:1500000683:30:5914000:-1", null,
"Siegstraße 30");
final Location to = new Location(LocationType.ADDRESS, "streetID:1500000146:1:5914000:-1", null,
"Berliner Platz 1");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
@Test
public void tripBetweenStreets() throws Exception {
final Location from = new Location(LocationType.ADDRESS,
"streetID:1500000683::5914000:-1:Siegstraße:Hagen:Siegstraße::Siegstraße: 58097:ANY:DIVA_STREET:831366:5312904:MRCV:nrw",
null, "Siegstraße");
final Location to = new Location(LocationType.ADDRESS,
"streetID:1500000146::5914000:29:Berliner Platz:Hagen:Berliner Platz::Berliner Platz: 58089:ANY:DIVA_STREET:830589:5314386:MRCV:nrw",
null, "Berliner Platz");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,591 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.net.SocketTimeoutException;
import java.util.Comparator;
import java.util.Date;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import org.junit.Ignore;
import org.junit.Test;
import com.google.common.collect.ComparisonChain;
import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.VrsProvider;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.LineDestination;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.StationDepartures;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
import de.schildbach.pte.util.Iso8601Format;
/**
* @author Michael Dyrna
*/
public class VrsProviderLiveTest extends AbstractProviderLiveTest {
public VrsProviderLiveTest() {
super(new VrsProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "8"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51218693, 6777785));
print(result);
final NearbyLocationsResult result2 = queryNearbyStations(Location.coord(51719648, 8754330));
print(result2);
}
@Test
public void nearbyLocationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
Location.coord(50732100, 7096820), 100, 1);
print(result);
final NearbyLocationsResult result2 = queryNearbyLocations(EnumSet.of(LocationType.ADDRESS),
Location.coord(50732100, 7096820));
print(result2);
final NearbyLocationsResult result3 = queryNearbyLocations(EnumSet.of(LocationType.POI),
Location.coord(50732100, 7096820));
print(result3);
final NearbyLocationsResult result4 = queryNearbyLocations(
EnumSet.of(LocationType.ADDRESS, LocationType.STATION), Location.coord(50732100, 7096820));
print(result4);
}
@Test
public void nearbyLocationsByRandomCoordinates() throws Exception {
Random rand = new Random(new Date().getTime());
final int LAT_FROM = 50500000;
final int LAT_TO = 51600000;
final int LON_FROM = 6200000;
final int LON_TO = 7600000;
for (int i = 0; i < 10; i++) {
int lat = LAT_FROM + rand.nextInt(LAT_TO - LAT_FROM);
int lon = LON_FROM + rand.nextInt(LON_TO - LON_FROM);
NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.ANY), Location.coord(lat, lon));
System.out.println(result);
assertNotNull(result.locations);
assertNotNull(result.locations.get(0));
}
}
@Test
public void nearbyStationsWithLimits() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
Location.coord(50732100, 7096820), 0, 0);
print(result);
final NearbyLocationsResult result2 = queryNearbyLocations(EnumSet.of(LocationType.STATION),
Location.coord(50732100, 7096820), 0, 50);
print(result2);
final NearbyLocationsResult result3 = queryNearbyLocations(EnumSet.of(LocationType.STATION),
Location.coord(50732100, 7096820), 1000, 50);
print(result3);
}
@Test
public void nearbyLocationsEmpty() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.allOf(LocationType.class),
Location.coord(1, 0), 0, 0);
print(result);
assertEquals(0, result.locations.size());
}
private static void printLineDestinations(final QueryDeparturesResult result) {
for (StationDepartures stationDepartures : result.stationDepartures) {
final List<LineDestination> lines = stationDepartures.lines;
if (lines != null) {
for (LineDestination lineDestination : lines) {
System.out.println(lineDestination.line + " to " + lineDestination.destination);
}
}
}
}
@Test
public void queryDeparturesBonnHbf() throws Exception {
final QueryDeparturesResult result = queryDepartures("687", false);
print(result);
printLineDestinations(result);
}
@Test
public void queryDeparturesKoelnHbf() throws Exception {
final QueryDeparturesResult result = queryDepartures("8", false);
print(result);
printLineDestinations(result);
}
@Test
public void queryDeparturesGaussstr() throws Exception {
final QueryDeparturesResult result = queryDepartures("8984", false);
// will return {"error": "Keine Abfahrten gefunden."}
print(result);
printLineDestinations(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void queryManyDepartures() throws Exception {
Random rand = new Random(new Date().getTime());
for (int i = 0; i < 10; i++) {
Integer id = 1 + rand.nextInt(20000);
try {
final QueryDeparturesResult result = queryDepartures(id.toString(), false);
if (result.status == QueryDeparturesResult.Status.OK) {
print(result);
printLineDestinations(result);
} else {
System.out.println("Status is " + result.status);
}
} catch (SocketTimeoutException ex) {
System.out.println("SocketTimeoutException: " + ex);
}
}
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult stationResult = suggestLocations("Beuel");
print(stationResult);
final SuggestLocationsResult addressResult = suggestLocations("Lützow 41 Köln");
print(addressResult);
final SuggestLocationsResult poiResult = suggestLocations("Schokolade");
print(poiResult);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("grün");
print(result);
}
@Test
public void suggestLocationsIdentified() throws Exception {
final SuggestLocationsResult result = suggestLocations("Düsseldorf, Am Frohnhof");
print(result);
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult cologneResult = suggestLocations("Köln Ebertplatz");
print(cologneResult);
assertThat(cologneResult.getLocations(), hasItem(new Location(LocationType.STATION, "35")));
final SuggestLocationsResult dortmundResult = suggestLocations("Dortmund Zugstraße");
print(dortmundResult);
assertThat(dortmundResult.getLocations(), hasItem(new Location(LocationType.STATION, "54282")));
final SuggestLocationsResult duesseldorfResult = suggestLocations("Düsseldorf Sternstraße");
print(duesseldorfResult);
assertThat(duesseldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "52839")));
final SuggestLocationsResult muensterResult = suggestLocations("Münster Vennheideweg");
print(muensterResult);
assertThat(muensterResult.getLocations(), hasItem(new Location(LocationType.STATION, "41112")));
final SuggestLocationsResult aachenResult = suggestLocations("Aachen Elisenbrunnen");
print(aachenResult);
assertThat(aachenResult.getLocations(), hasItem(new Location(LocationType.STATION, "20580")));
final SuggestLocationsResult bonnResult = suggestLocations("Bonn Konrad-Adenauer-Platz");
print(aachenResult);
assertThat(bonnResult.getLocations(), hasItem(new Location(LocationType.STATION, "1500")));
}
@Test
public void suggestLocationsCity() throws Exception {
final SuggestLocationsResult result = suggestLocations("Düsseldorf");
print(result);
}
@Test
public void suggestManyLocations() throws Exception {
Random rand = new Random(new Date().getTime());
for (int i = 0; i < 10; i++) {
String s = "";
int len = rand.nextInt(256);
for (int j = 0; j < len; j++) {
char c = (char) ('a' + rand.nextInt(26));
s += c;
}
final SuggestLocationsResult result = suggestLocations(s);
System.out.print(s + " => ");
print(result);
}
}
@Test
public void anyTripAmbiguous() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "Köln"),
new Location(LocationType.ANY, null, null, "Leverkusen"),
new Location(LocationType.ANY, null, null, "Bonn"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status);
assertNotNull(result.ambiguousFrom);
assertNotNull(result.ambiguousVia);
assertNotNull(result.ambiguousTo);
}
@Test
public void anyTripUnique() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "T-Mobile"), null,
new Location(LocationType.ANY, null, null, "Schauspielhalle"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
}
@Test
public void anyTripUnknown() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.ANY, null, null, "\1"), null,
new Location(LocationType.ANY, null, null, "\2"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result.status);
}
@Test
public void tripEarlierLater() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8"), null,
new Location(LocationType.STATION, "9"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
assertEquals(QueryTripsResult.Status.OK, laterResult.status);
assertTrue(laterResult.trips.size() > 0);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
assertEquals(QueryTripsResult.Status.OK, later2Result.status);
assertTrue(later2Result.trips.size() > 0);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
assertEquals(QueryTripsResult.Status.OK, earlierResult.status);
assertTrue(earlierResult.trips.size() > 0);
print(earlierResult);
}
@Test
public void tripEarlierLaterCologneBerlin() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1"), null,
new Location(LocationType.STATION, "11458"), new Date(), true, null);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
print(result);
System.out.println("And now earlier...");
final QueryTripsResult earlierResult = queryMoreTrips(result.context, false);
assertEquals(QueryTripsResult.Status.OK, earlierResult.status);
assertTrue(earlierResult.trips.size() > 0);
print(earlierResult);
}
@Test
public void testTripWithProductFilter() throws Exception {
final TripOptions options = new TripOptions(EnumSet.of(Product.ON_DEMAND, Product.SUBWAY, Product.FERRY,
Product.TRAM, Product.CABLECAR, Product.BUS), null, WalkSpeed.NORMAL, Accessibility.NEUTRAL, null);
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1504"), null,
new Location(LocationType.STATION, "1"), new Date(), true, options);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
print(result);
}
@Test
public void testTripBeuelKoelnSued() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "1504"), null,
new Location(LocationType.STATION, "25"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripBonnHbfBonnBeuel() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "687"), null,
new Location(LocationType.STATION, "1504"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripBonnHbfDorotheenstr() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "687"), null,
new Location(LocationType.STATION, "1150"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripKoelnHbfBresslauerPlatz() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8"), null,
new Location(LocationType.STATION, "9"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripDuerenLammersdorf() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "6868"), null,
new Location(LocationType.STATION, "21322"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripEhrenfeldNeumarkt() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "251"), null,
new Location(LocationType.STATION, "2"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripCologneWickede() throws Exception {
final TripOptions options = new TripOptions(
EnumSet.of(Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY, Product.TRAM), null,
WalkSpeed.NORMAL, Accessibility.NEUTRAL, null);
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "8"), null,
new Location(LocationType.STATION, "10781"), new Date(), true, options);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripByCoord() throws Exception {
final QueryTripsResult result = queryTrips(Location.coord(50740530, 7129200), null,
Location.coord(50933930, 6932440), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripByAddressAndEmptyPolygon() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null /* id */, Point.from1E6(50909350, 6676310),
"Kerpen-Sindorf", "Erftstraße 43");
final Location to = new Location(LocationType.ADDRESS, null /* id */, Point.from1E6(50923000, 6818440),
"Frechen", "Zedernweg 1");
final QueryTripsResult result = queryTrips(from, null, to, Iso8601Format.parseDateTime("2015-03-17 21:11:18"),
true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripWithSurchargeInfo() throws Exception {
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "687"), null,
new Location(LocationType.STATION, "892"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
@Test
public void testTripAachenEschweilerBus() throws Exception {
final TripOptions options = new TripOptions(EnumSet.of(Product.BUS), null, WalkSpeed.NORMAL,
Accessibility.NEUTRAL, null);
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "10004"), null,
new Location(LocationType.STATION, "10003"), new Date(), true, options);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
private void manyRandomTrips(int latFrom, int latTo, int lonFrom, int lonTo) throws Exception {
Random rand = new Random(new Date().getTime());
int errors = 0;
long startTime = System.currentTimeMillis();
for (int i = 0; i < 5; i++) {
try {
int fromLat = latFrom + rand.nextInt(latTo - latFrom);
int fromLon = lonFrom + rand.nextInt(lonTo - lonFrom);
int toLat = latFrom + rand.nextInt(latTo - latFrom);
int toLon = lonFrom + rand.nextInt(lonTo - lonFrom);
final QueryTripsResult result = queryTrips(Location.coord(fromLat, fromLon), null,
Location.coord(toLat, toLon), new Date(), true, null);
System.out.println("# " + (i + 1));
if (result.status.equals(QueryTripsResult.Status.OK)) {
print(result);
} else {
System.out.println("Status is " + result.status);
errors++;
}
} catch (SocketTimeoutException ex) {
System.out.println("SocketTimeoutException: " + ex);
errors++;
}
}
final long stopTime = System.currentTimeMillis();
final long elapsedTime = stopTime - startTime;
System.out.println("Elapsed: " + (elapsedTime / 1000) + " seconds");
System.out.println("Errors: " + errors);
}
@Ignore
@Test
public void manyRandomTripsNRW() throws Exception {
manyRandomTrips(50500000, 51600000, 6200000, 7600000);
}
@Ignore
@Test
public void manyRandomTripsCologne() throws Exception {
manyRandomTrips(50828176, 51083369, 6770942, 7161643);
}
@Ignore
@Test
public void manyRandomTripsBonn() throws Exception {
manyRandomTrips(50632639, 50774408, 7019582, 7209096);
}
@Ignore
@Test
public void manyRandomTripsDuesseldorf() throws Exception {
manyRandomTrips(51123960, 51353094, 6689381, 6940006);
}
private static class LocationComparator implements Comparator<Location> {
@Override
public int compare(Location o1, Location o2) {
return ComparisonChain.start().compare(o1.name, o2.name).result();
}
}
private void crawlStationsAndLines(int latFrom, int latTo, int lonFrom, int lonTo) throws Exception {
Set<Location> stations = new TreeSet<>(new LocationComparator());
Random rand = new Random(new Date().getTime());
for (int i = 0; i < 5; i++) {
int lat = latFrom + rand.nextInt(latTo - latFrom);
int lon = lonFrom + rand.nextInt(lonTo - lonFrom);
System.out.println(i + " " + lat + " " + lon);
NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION),
Location.coord(lat, lon), 0, 3);
if (result.status == NearbyLocationsResult.Status.OK) {
stations.addAll(result.locations);
}
}
Set<Line> lines = new TreeSet<>();
for (Location station : stations) {
QueryDeparturesResult qdr = provider.queryDepartures(station.id,
Iso8601Format.parseDateTime("2015-03-16 02:00:00"), 100, false);
if (qdr.status == QueryDeparturesResult.Status.OK) {
for (StationDepartures stationDepartures : qdr.stationDepartures) {
final List<LineDestination> stationDeparturesLines = stationDepartures.lines;
if (stationDeparturesLines != null) {
for (LineDestination ld : stationDeparturesLines) {
lines.add(ld.line);
}
}
}
}
}
for (Location station : stations) {
System.out.println(station.toString());
}
for (Line line : lines) {
final Product product = line.product;
if (product != null) {
if (product.equals(Product.BUS)) {
final Style style = line.style;
if (style != null) {
System.out.printf("%s %6x\n", line.label, style.backgroundColor);
}
}
}
}
}
@Ignore
@Test
public void crawlStationsAndLinesNRW() throws Exception {
crawlStationsAndLines(50500000, 51600000, 6200000, 7600000);
}
@Ignore
@Test
public void crawlStationsAndLinesCologne() throws Exception {
crawlStationsAndLines(50828176, 51083369, 6770942, 7161643);
}
@Ignore
@Test
public void crawlStationsAndLinesBonn() throws Exception {
crawlStationsAndLines(50632639, 50774408, 7019582, 7209096);
}
@Ignore
@Test
public void crawlStationsAndLinesDuesseldorf() throws Exception {
crawlStationsAndLines(51123960, 51353094, 6689381, 6940006);
}
@Ignore
@Test
public void crawlStationsAndLinesEssen() throws Exception {
crawlStationsAndLines(51347508, 51533689, 6893109, 7137554);
}
}

View file

@ -0,0 +1,112 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VvmProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VvmProviderLiveTest extends AbstractProviderLiveTest {
public VvmProviderLiveTest() {
super(new VvmProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "3000510"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(49455472, 11079655));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("3000510", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kloster Südstraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "2007534")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "3700075", Point.from1E6(49801076, 9934302),
"Würzburg", "Busbahnhof");
final Location to = new Location(LocationType.STATION, "3700403", Point.from1E6(49797772, 9934986), "Würzburg",
"Stift Haug");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VvoProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VvoProviderLiveTest extends AbstractProviderLiveTest {
public VvoProviderLiveTest() {
super(new VvoProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "33000013"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(51052467, 13733196));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("100", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Hülßestraße");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "33000123")));
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult dresdenResult = suggestLocations("Dresden Postplatz");
print(dresdenResult);
assertThat(dresdenResult.getLocations(), hasItem(new Location(LocationType.STATION, "33000037")));
}
@Test
public void suggestAddressLocation() throws Exception {
final SuggestLocationsResult result = suggestLocations("Dresden, Töpferstr. 10");
print(result);
}
@Test
public void shortTrip() throws Exception {
final QueryTripsResult result = queryTrips(
new Location(LocationType.STATION, "33000013", null, "Dresden Albertplatz"), null,
new Location(LocationType.STATION, "33000262", null, "Dresden Bischofsweg"), new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripFromAddressToAddress() throws Exception {
final Location from = new Location(LocationType.ADDRESS, null, Point.from1E6(51052260, 13740998), "Dresden",
"Dresden, Töpferstraße 10");
final Location to = new Location(LocationType.ADDRESS, null, Point.from1E6(51029752, 13700666), "Dresden",
"Dresden, Tharandter Straße 88");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
}
}

View file

@ -0,0 +1,119 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VvsProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VvsProviderLiveTest extends AbstractProviderLiveTest {
public VvsProviderLiveTest() {
super(new VvsProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "6118"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48775005, 9166517));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("6118", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Nürtingen");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "5002931")));
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult result = suggestLocations("backnang");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "5007600")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "5006118", Point.from1E6(48782984, 9179846),
"Stuttgart", "Stuttgart, Hauptbahnhof");
final Location to = new Location(LocationType.STATION, "5006024", Point.from1E6(48782584, 9187098), "Stuttgart",
"Staatsgalerie");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,100 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VvtProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VvtProviderLiveTest extends AbstractProviderLiveTest {
public VvtProviderLiveTest() {
super(new VvtProvider(secretProperty("vvt.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(47271228, 11402063));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("470118700", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", 0, false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Innsbruck Hauptbahnhof");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "470118700")));
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("grün");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "476151200", Point.from1E6(47268248, 11355560),
"Innsbruck", "Allerheiligen");
final Location to = new Location(LocationType.STATION, "476151000", Point.from1E6(47267241, 11351003),
"Innsbruck", "Tschiggfreystraße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,109 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.VvvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class VvvProviderLiveTest extends AbstractProviderLiveTest {
public VvvProviderLiveTest() {
super(new VvvProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "80007271"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(50776518, 12056032));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("80007271", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kirchweidach, Kirchweidach");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("grün");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "30202006", Point.from1E6(50484564, 12140028),
"Plauen (Vogtl)", "Bickelstraße");
final Location to = new Location(LocationType.STATION, "30202012", Point.from1E6(50487332, 12139050),
"Plauen (Vogtl)", "Hofer Straße");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
}

View file

@ -0,0 +1,141 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.EnumSet;
import org.junit.Test;
import de.schildbach.pte.WienProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class WienProviderLiveTest extends AbstractProviderLiveTest {
public WienProviderLiveTest() {
super(new WienProvider());
}
@Test
public void nearbyStations() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "60203090"));
print(result);
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(48207355, 16370602));
print(result);
}
@Test
public void nearbyLocationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION, LocationType.POI),
Location.coord(48207355, 16370602));
print(result);
assertTrue(result.locations.size() > 0);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("60203090", false);
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocationsIncomplete() throws Exception {
final SuggestLocationsResult result = suggestLocations("Kur");
print(result);
}
@Test
public void suggestLocationsWithUmlaut() throws Exception {
final SuggestLocationsResult result = suggestLocations("Längenfeld");
print(result);
assertThat(result.getLocations(), hasItem(new Location(LocationType.STATION, "60200820")));
}
@Test
public void suggestLocationsCoverage() throws Exception {
final SuggestLocationsResult huetteldorfResult = suggestLocations("Wien Hütteldorf");
print(huetteldorfResult);
assertThat(huetteldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "60200560")));
final SuggestLocationsResult wienerNeustadtResult = suggestLocations("Wiener Neustadt Nord");
print(wienerNeustadtResult);
assertThat(wienerNeustadtResult.getLocations(), hasItem(new Location(LocationType.STATION, "60205223")));
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "60200657", Point.from1E6(48200756, 16369001), "Wien",
"Karlsplatz");
final Location to = new Location(LocationType.STATION, "60201094", Point.from1E6(48198612, 16367719), "Wien",
"Resselgasse");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
assertEquals(QueryTripsResult.Status.OK, result.status);
assertTrue(result.trips.size() > 0);
if (!result.context.canQueryLater())
return;
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
if (!laterResult.context.canQueryLater())
return;
final QueryTripsResult later2Result = queryMoreTrips(laterResult.context, true);
print(later2Result);
if (!later2Result.context.canQueryEarlier())
return;
final QueryTripsResult earlierResult = queryMoreTrips(later2Result.context, false);
print(earlierResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final QueryTripsResult result = queryTrips(Location.coord(48180281, 16333551), null,
Location.coord(48240452, 16444788), new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
}

View file

@ -0,0 +1,114 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.live;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import de.schildbach.pte.ZvvProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
/**
* @author Andreas Schildbach
*/
public class ZvvProviderLiveTest extends AbstractProviderLiveTest {
public ZvvProviderLiveTest() {
super(new ZvvProvider(secretProperty("zvv.api_authorization")));
}
@Test
public void nearbyStationsByCoordinate() throws Exception {
final NearbyLocationsResult result = queryNearbyStations(Location.coord(47378968, 8540534));
print(result);
}
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("8503000", false); // Hauptbahnhof
print(result);
}
@Test
public void queryDeparturesSuburbanTrain() throws Exception {
final QueryDeparturesResult result = queryDepartures("8500169", false); // Muriaux
print(result);
}
@Test
public void queryDeparturesTram() throws Exception {
final QueryDeparturesResult result = queryDepartures("8591276", false); // Milchbuck
print(result);
}
@Test
public void queryDeparturesTrolley() throws Exception {
final QueryDeparturesResult result = queryDepartures("8591177", false); // Hardplatz
print(result);
}
@Test
public void queryDeparturesInvalidStation() throws Exception {
final QueryDeparturesResult result = queryDepartures("999999", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}
@Test
public void suggestLocations() throws Exception {
final SuggestLocationsResult result = suggestLocations("Flughafen");
print(result);
}
@Test
public void shortTrip() throws Exception {
final Location from = new Location(LocationType.STATION, "8503000", "Zürich", "Hauptbahnhof");
final Location to = new Location(LocationType.STATION, "8507785", "Bern", "Hauptbahnhof");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void trip() throws Exception {
final Location from = new Location(LocationType.STATION, "8503000", Point.from1E6(47378491, 8537945), "Zürich",
"Zürich, Hauptbahnhof");
final Location to = new Location(LocationType.STATION, "8530812", Point.from1E6(47361762, 8560715), "Zürich",
"Hegibachplatz");
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
final QueryTripsResult laterResult = queryMoreTrips(result.context, true);
print(laterResult);
}
@Test
public void tripBetweenCoordinates() throws Exception {
final Location from = Location.coord(Point.fromDouble(47.3782535, 8.5392280)); // Zürich Hauptbahnhof
final Location to = Location.coord(Point.fromDouble(47.3852910, 8.5172170)); // Bahnhof Hardbrücke
final QueryTripsResult result = queryTrips(from, null, to, new Date(), true, null);
print(result);
}
}

View file

@ -0,0 +1,32 @@
# Secrets are needed to run some of the live tests.
navitia.authorization =
hci.salt_encryption_key =
db.api_authorization =
db.encrypted_salt =
bvg.api_authorization =
vbb.api_authorization =
vbb.encrypted_salt =
nvv.api_authorization =
avv_augsburg.api_authorization =
sh.api_authorization =
vbn.api_authorization =
vbn.encrypted_salt =
nasa.api_authorization =
vgs.api_authorization =
vgs.encrypted_salt =
vmt.api_authorization =
invg.api_authorization =
invg.encrypted_salt =
avv_aachen.api_authorization =
oebb.api_authorization =
vor.api_authorization =
ooevv.api_authorization =
svv.api_authorization =
vvt.api_authorization =
vmobil.api_authorization =
vao.api_authorization =
zvv.api_authorization =
sncb.api_authorization =
dsb.api_authorization =
se.api_authorization =
lu.api_authorization =

View file

@ -0,0 +1,105 @@
/*
* Copyright 2014-2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import okhttp3.HttpUrl;
/**
* @author Andreas Schildbach
*/
public class HttpClientTest {
private HttpUrl base;
@Before
public void setUp() throws Exception {
base = HttpUrl.parse("http://example.com");
}
@Test
public void vodafoneRedirect() throws Exception {
final HttpUrl url = HttpClient.testRedirect(base,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.1//EN \" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"; xml:lang=\"en\"><head><title>Vodafone Center</title><meta http-equiv=\"Cache-Control\" content=\"no-cache\"/><meta http-equiv=\"refresh\" content=\"1;URL=https://center.vodafone.de/vfcenter/index.html?targetUrl=http%3A%2F%2Fwww.fahrinfo-berlin.de/Fahrinfo/bin/query.bin/dn%3fstart=Suchen&REQ0JourneyStopsS0ID=A%253D1%2540L%253D9083301&REQ0JourneyStopsZ0ID=A%253D1%2540L%253D9195009&REQ0HafasSearchForw=1&REQ0JourneyDate=16.06.14&REQ0JourneyTime=16%253A32&REQ0JourneyProduct_prod_list_1=11111011&h2g-direct=11&L=vs_oeffi\"/><style type=\"text/css\">*{border:none;font-family:Arial,Helvetica,sans-serif} body{font-size:69%;line-height:140%;background-color:#F4F4F4 !important}</style></head><body><h1>Sie werden weitergeleitet ...</h1><p>Sollten Sie nicht weitergeleitet werden, klicken Sie bitte <a href=\"https://center.vodafo");
assertNotNull(url);
assertEquals("center.vodafone.de", url.host());
}
public void kabelDeutschlandRedirect() throws Exception {
final HttpUrl url = HttpClient.testRedirect(base,
"<script type=\"text/javascript\"> window.location = \"http://www.hotspot.kabeldeutschland.de/portal/?RequestedURI=http%3A%2F%2Fwww.fahrinfo-berlin.de%2FFahrinfo%2Fbin%2Fajax-getstop.bin%2Fdny%3Fgetstop%3D1%26REQ0JourneyStopsS0A%3D255%26REQ0JourneyStopsS0G%3Dgneisenustra%25DFe%3F%26js%3Dtrue&RedirectReason=Policy&RedirectAqpId=100&DiscardAqpId=100&SubscriberId=4fa432d4a653e5f8b2acb27aa862f98d&SubscriberType=ESM&ClientIP=10.136.25.241&SystemId=10.143.181.2-1%2F2&GroupId=1&PartitionId=2&Application=Unknown&ApplicationGroup=Unknown\" </script>");
assertNotNull(url);
assertEquals("www.hotspot.kabeldeutschland.de", url.host());
}
@Test
public void tplinkRedirect() throws Exception {
final HttpUrl url = HttpClient.testRedirect(base,
"<body><script language=\"javaScript\">location.href=\"http://tplinkextender.net/\";</script></body></html>");
assertNotNull(url);
assertEquals("tplinkextender.net", url.host());
}
@Test
public void mshtmlRedirect() throws Exception {
final HttpUrl url = HttpClient.testRedirect(base,
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><HEAD><TITLE>HTML Redirection</TITLE><META http-equiv=Content-Type content=\"text/html; \"><META http-equiv=Refresh content=\"0;URL=/cgi-bin/index.cgi\"><META content=\"MSHTML 6.00.2900.2873\" name=GENERATOR></HEAD><BODY > <NOSCRIPT> If your browser can not redirect you to home page automatically.<br> Please click <a href=/cgi-bin/welcome.cgi?lang=0>here</a>. </NOSCRIPT></BODY></HTML>");
assertNotNull(url);
assertEquals("example.com", url.host());
}
@Test
public void efaExpired() throws Exception {
assertTrue(HttpClient.testExpired(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; \"/><meta http-equiv=\"Expires\" content=\"0\"/><title>Efa9 Internal Error</title><style>.BOLD {font: bold large Arial;}.NORMAL {font: normal x-small Arial;}</style></head><body><div class=\"BOLD\">Internal Error</div><div class=\"NORMAL\">Your session has expired.</div><!--<p>&nbsp;</p><div class=\"NORMAL\">.\\EfaHttpServer.cpp</div><div class=\"NORMAL\">Line: 2043</div>--></body></html>"));
}
@Test
public void tflExpired() throws Exception {
assertTrue(HttpClient.testExpired(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><title>Session Expired</title><style type=\"text/css\">body{ font-family:Verdana, Arial, Helvetica, sans-serif}</style></head><body bgcolor=\"#FFFFFF\" leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\"><!--Logo--><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr> <td width=\"100%\" height=\"40\" valign=\"top\" class=\"fenster\"><table width=\"389\" height=\"40\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr> <td width=\"93\" valign=\"top\"><span>&nbsp;</span></td><td width=\"296\" valign=\"top\"><img src=\"images/logo.gif\" alt=\"\" width=\"372\" height=\"86\" border=\"0\"></td></tr></table></td></tr></table><!--/ Logo--><!--Content--><span><!--Headline--><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td width=\"18\" valign=\"top\"><span>&nbsp;</span></td><td width=\"566\" valign=\"top\"><span class=\"headline\"><b>Session Expire"));
}
@Test
public void nvbwExpired() throws Exception {
assertTrue(HttpClient.testExpired("<h2>Ihre Verbindungskennung ist nicht mehr gültig.</h2>"));
}
@Test
public void internalError() throws Exception {
assertTrue(HttpClient.testInternalError(
"<?xml version=\"1.0\"?> <!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <title> Internal error in gateway </title> </head> <body> <h1> Internal error in gateway </h1> </body> </html>"));
}
@Test
public void vgnInternalError() throws Exception {
assertTrue(HttpClient.testInternalError(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/><meta http-equiv=\"Expires\" content=\"0\"/><title>Efa9 Internal Error</title></head><body><div style=\"font: bold large Arial;\">Internal Error</div><div style=\"font: normal x-small Arial;\">.\\EfaHttpServer.cpp</div><div style=\"font: normal x-small Arial;\">Line: 2507</div></body></html>"));
}
@Test
public void vrnInternalError() throws Exception {
assertTrue(HttpClient.testInternalError(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><title>VRN - Keine Verbindung zum Server möglich</title></head><body><center><table border=\"0\" width=\"450\" cellpadding=\"5\"><tr><td height=\"50\">&nbsp;</td></tr><tr><td align=\"center\"><img src=\"/vrn/ExceptionFiles/cookies.jpg\"></td></tr></table></center></body></html>"));
}
}

View file

@ -0,0 +1,54 @@
/*
* Copyright 2012-2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* @author Andreas Schildbach
*/
@SuppressWarnings("serial")
public class Iso8601Format extends SimpleDateFormat {
private Iso8601Format(final String formatString) {
super(formatString, Locale.US);
}
public static DateFormat newTimeFormat() {
return new Iso8601Format("HH:mm:ss");
}
public static DateFormat newDateFormat() {
return new Iso8601Format("yyyy-MM-dd");
}
public static DateFormat newDateTimeFormat() {
return new Iso8601Format("yyyy-MM-dd HH:mm:ss");
}
public static String formatDateTime(final Date date) {
return newDateTimeFormat().format(date);
}
public static Date parseDateTime(final String date) throws ParseException {
return newDateTimeFormat().parse(date);
}
}

View file

@ -0,0 +1,40 @@
/*
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.schildbach.pte.util;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import de.schildbach.pte.dto.Point;
/**
* @author Andreas Schildbach
*/
public class PolylineFormatTest {
@Test
public void test() {
final List<Point> polyline = PolylineFormat.decode(
"}qfeHyn|bBnBdA\\R]xBzA|@r@f@u@hCWS{@bCe@t@e@v@h@vCIFu@`@MPDJ@L?NAPIZXf@|@`Br@pAHLZp@~@jBbArBbBjDLTTd@fAzBcFnH[d@Vf@iA`BWb@t@zAb@~@LTNNdCzE~A{BAA??");
assertEquals(44, polyline.size());
assertEquals(Point.fromDouble(48.2078300, 16.3711700), polyline.get(0));
assertEquals(Point.fromDouble(48.2051400, 16.3579600), polyline.get(43));
}
}