diff --git a/src/de/schildbach/pte/AbstractHafasProvider.java b/src/de/schildbach/pte/AbstractHafasProvider.java index 7908c82e..c791b697 100644 --- a/src/de/schildbach/pte/AbstractHafasProvider.java +++ b/src/de/schildbach/pte/AbstractHafasProvider.java @@ -700,6 +700,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider if (XmlPullUtil.test(pp, "Err")) { 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 return new QueryConnectionsResult(Status.SERVICE_DOWN); throw new IllegalStateException("error " + code + " " + XmlPullUtil.attr(pp, "text")); diff --git a/test/de/schildbach/pte/live/VbnProviderLiveTest.java b/test/de/schildbach/pte/live/VbnProviderLiveTest.java index 9857e8ce..dd2ba9d0 100644 --- a/test/de/schildbach/pte/live/VbnProviderLiveTest.java +++ b/test/de/schildbach/pte/live/VbnProviderLiveTest.java @@ -17,6 +17,8 @@ package de.schildbach.pte.live; +import static junit.framework.Assert.assertEquals; + import java.util.Date; import java.util.List; @@ -83,8 +85,17 @@ public class VbnProviderLiveTest { 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); + assertEquals(QueryConnectionsResult.Status.OK, result.status); System.out.println(result); final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context); 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); + } }