mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 06:08:52 +00:00
use APIs for Frankfurt whereever possible
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@643 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
77b80edd55
commit
7c6b3d2539
3 changed files with 62 additions and 472 deletions
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010, 2011 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class RmvProviderTest
|
||||
{
|
||||
@Test
|
||||
public void departureWithNoPrognosisMessage()
|
||||
{
|
||||
final Matcher m = assertFineDepartures("<b>Bus 42 </b>\n" //
|
||||
+ ">>\n" //
|
||||
+ "Frankfurt (Main) Enkheim\n" //
|
||||
+ "<br />\n" //
|
||||
+ "<b>20:21</b>\n" //
|
||||
+ "keine Prognose verfügbar\n" //
|
||||
+ "<span class=\"red\">heute Gl. Enkheim</span><br />\n");
|
||||
|
||||
assertNotNull(m.group(5)); // predictedPosition
|
||||
}
|
||||
|
||||
@Test
|
||||
public void departureWithMessage()
|
||||
{
|
||||
final Matcher m = assertFineDepartures("<b>Bus 274 </b>\n" //
|
||||
+ ">>\n" //
|
||||
+ "Bad Schwalbach Kurhaus\n" //
|
||||
+ "<br />\n" //
|
||||
+ "<b>15:47</b>\n" //
|
||||
+ "<span class=\"red\">Zug fällt aus</span>\n");
|
||||
|
||||
assertNotNull(m.group(7)); // message
|
||||
}
|
||||
|
||||
private Matcher assertFineDepartures(String s)
|
||||
{
|
||||
Matcher m = RmvProvider.P_DEPARTURES_FINE.matcher(s);
|
||||
assertTrue(m.matches());
|
||||
|
||||
// ParserUtils.printGroups(m);
|
||||
|
||||
assertNotNull(m.group(1)); // line
|
||||
assertNotNull(m.group(2)); // destination
|
||||
assertNotNull(m.group(3)); // time
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@ import org.junit.Test;
|
|||
|
||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||
import de.schildbach.pte.RmvProvider;
|
||||
import de.schildbach.pte.dto.Connection;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
|
@ -39,6 +38,30 @@ public class RmvProviderLiveTest
|
|||
private final RmvProvider provider = new RmvProvider();
|
||||
protected static final String ALL_PRODUCTS = "IRSUTBFC";
|
||||
|
||||
@Test
|
||||
public void nearbyStations() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 3000001), 0, 0);
|
||||
|
||||
System.out.println(result.stations.size() + " " + result.stations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStationsByCoordinate() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.ADDRESS, 50108625, 8669604), 0, 0);
|
||||
|
||||
System.out.println(result.stations.size() + " " + result.stations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDepartures() throws Exception
|
||||
{
|
||||
final QueryDeparturesResult result = provider.queryDepartures(3000408, 0, false);
|
||||
|
||||
System.out.println(result.stationDepartures);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autocomplete() throws Exception
|
||||
{
|
||||
|
@ -55,22 +78,6 @@ public class RmvProviderLiveTest
|
|||
System.out.println();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nearbyStations() throws Exception
|
||||
{
|
||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 3000001), 0, 0);
|
||||
|
||||
System.out.println(result.stations.size() + " " + result.stations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDepartures() throws Exception
|
||||
{
|
||||
final QueryDeparturesResult result = provider.queryDepartures(3000001, 0, false);
|
||||
|
||||
System.out.println(result.stationDepartures);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortConnection() throws Exception
|
||||
{
|
||||
|
@ -78,11 +85,9 @@ public class RmvProviderLiveTest
|
|||
new Location(LocationType.ANY, 0, null, "Frankfurt Hauptbahnhof!"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
|
||||
for (final Connection connection : result.connections)
|
||||
provider.getConnectionDetails(connection.link);
|
||||
System.out.println(moreResult);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void shortConnectionByName() throws Exception
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue