From 1755a530e0ff96a16f5c3014289c0e4359c206cd Mon Sep 17 00:00:00 2001 From: "andreas.schildbach@gmail.com" Date: Tue, 16 Aug 2011 14:03:22 +0000 Subject: [PATCH] parse invalid date error git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@743 0924bc21-9374-b0fa-ee44-9ff1593b38f0 --- src/de/schildbach/pte/AbstractHafasProvider.java | 2 ++ test/de/schildbach/pte/live/VbnProviderLiveTest.java | 11 +++++++++++ 2 files changed, 13 insertions(+) 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); + } }