parse invalid date error

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@743 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-08-16 14:03:22 +00:00
parent ba155714e1
commit 1755a530e0
2 changed files with 13 additions and 0 deletions

View file

@ -700,6 +700,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
if (XmlPullUtil.test(pp, "Err")) if (XmlPullUtil.test(pp, "Err"))
{ {
final String code = XmlPullUtil.attr(pp, "code"); final String code = XmlPullUtil.attr(pp, "code");
if (code.equals("I3")) // Input: date outside of the timetable period
return new QueryConnectionsResult(Status.INVALID_DATE);
if (code.equals("F1")) // Spool: Error reading the spoolfile if (code.equals("F1")) // Spool: Error reading the spoolfile
return new QueryConnectionsResult(Status.SERVICE_DOWN); return new QueryConnectionsResult(Status.SERVICE_DOWN);
throw new IllegalStateException("error " + code + " " + XmlPullUtil.attr(pp, "text")); throw new IllegalStateException("error " + code + " " + XmlPullUtil.attr(pp, "text"));

View file

@ -17,6 +17,8 @@
package de.schildbach.pte.live; package de.schildbach.pte.live;
import static junit.framework.Assert.assertEquals;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -83,8 +85,17 @@ public class VbnProviderLiveTest
{ {
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 8096109, null, "Oldenburg"), null, final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 8096109, null, "Oldenburg"), null,
new Location(LocationType.STATION, 625398, null, "Bremerhaven"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL); new Location(LocationType.STATION, 625398, null, "Bremerhaven"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
assertEquals(QueryConnectionsResult.Status.OK, result.status);
System.out.println(result); System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult); System.out.println(moreResult);
} }
@Test
public void connectionDateOutsideTimetablePeriod() throws Exception
{
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 8096109, null, "Oldenburg"), null,
new Location(LocationType.STATION, 625398, null, "Bremerhaven"), new Date(1155822689759l), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
assertEquals(QueryConnectionsResult.Status.INVALID_DATE, result.status);
}
} }