diff --git a/src/de/schildbach/pte/RmvProvider.java b/src/de/schildbach/pte/RmvProvider.java index 497d9dd5..5518c41d 100644 --- a/src/de/schildbach/pte/RmvProvider.java +++ b/src/de/schildbach/pte/RmvProvider.java @@ -134,8 +134,8 @@ public class RmvProvider implements NetworkProvider return (double) value / 1000000; } - private String connectionsQueryUri(final LocationType fromType, final String from, final LocationType viaType, final String via, final LocationType toType, final String to, - final Date date, final boolean dep) + private String connectionsQueryUri(final LocationType fromType, final String from, final LocationType viaType, final String via, + final LocationType toType, final String to, final Date date, final boolean dep) { final DateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yy"); final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm"); @@ -441,12 +441,13 @@ public class RmvProvider implements NetworkProvider + "Uhr, (\\d+\\.\\d+\\.\\d+).*?" // , Pattern.DOTALL); private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("

\n(.+?)

", Pattern.DOTALL); - private static final Pattern P_DEPARTURES_FINE = Pattern.compile("" // + static final Pattern P_DEPARTURES_FINE = Pattern.compile("" // + "\\s*(.*?)\\s*.*?" // line + ">>\n" // + "(.*?)\n" // destination + "
\n" // + "(\\d{1,2}:\\d{2})\n" // plannedTime + + "(?:keine Prognose verfügbar\n)?" // + "(?:ca\\. (\\d{1,2}:\\d{2})\n)?" // predictedTime + "(?:heute Gl\\. " + ParserUtils.P_PLATFORM + "
\n)?" // predictedPosition + "(?:(Gl\\. " + ParserUtils.P_PLATFORM + ")
\n)?" // position diff --git a/test/de/schildbach/pte/RmvProviderTest.java b/test/de/schildbach/pte/RmvProviderTest.java new file mode 100644 index 00000000..62813e14 --- /dev/null +++ b/test/de/schildbach/pte/RmvProviderTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010 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 . + */ + +package de.schildbach.pte; + +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() + { + assertFineDepartures("Bus 42 \n" // + + ">>\n" // + + "Frankfurt (Main) Enkheim\n" // + + "
\n" // + + "20:21\n" // + + "keine Prognose verfügbar\n" // + + "heute Gl. Enkheim
\n"); + } + + private void assertFineDepartures(String s) + { + Matcher m = RmvProvider.P_DEPARTURES_FINE.matcher(s); + assertTrue(m.matches()); + // ParserUtils.printGroups(m); + } +}