mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 06:08:52 +00:00
parse departure message for Germany
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@141 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
b9571a9399
commit
fc12d20236
6 changed files with 40 additions and 10 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -31,7 +32,8 @@ public class BahnProviderTest
|
|||
@Test
|
||||
public void connectionUebergang()
|
||||
{
|
||||
assertFineConnectionDetails("<span class=\"bold\">Berlin Hbf</span><br />\n" //
|
||||
assertFineConnectionDetails("" //
|
||||
+ "<span class=\"bold\">Berlin Hbf</span><br />\n" //
|
||||
+ "Übergang\n" //
|
||||
+ "<br />\n" //
|
||||
+ "<span class=\"bold\">Berlin-Lichtenberg</span><br />");
|
||||
|
@ -40,7 +42,8 @@ public class BahnProviderTest
|
|||
@Test
|
||||
public void departureWithPlatform()
|
||||
{
|
||||
assertFineDepartures("<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/731061/244203/590672/51649/80/si=8100352&bt=dep&ti=10:42&pt=10:42&p=1111111111&date=01.09.10&max=10&rt=1&&\">\n" //
|
||||
assertFineDepartures("" //
|
||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/731061/244203/590672/51649/80/si=8100352&bt=dep&ti=10:42&pt=10:42&p=1111111111&date=01.09.10&max=10&rt=1&&\">\n" //
|
||||
+ "<span class=\"bold\">S 1</span>\n" //
|
||||
+ "</a>\n" //
|
||||
+ ">>\n" //
|
||||
|
@ -52,7 +55,8 @@ public class BahnProviderTest
|
|||
@Test
|
||||
public void departureWithOnTime()
|
||||
{
|
||||
assertFineDepartures("<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/438441/245165/958/145668/80/si=8011160&bt=dep&ti=21:47&pt=21:47&p=1111101&date=05.09.10&max=10&rt=1&&\">\n" //
|
||||
assertFineDepartures("" //
|
||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/438441/245165/958/145668/80/si=8011160&bt=dep&ti=21:47&pt=21:47&p=1111101&date=05.09.10&max=10&rt=1&&\">\n" //
|
||||
+ "<span class=\"bold\">RE 38148</span>\n" //
|
||||
+ "</a>\n" //
|
||||
+ ">>\n" //
|
||||
|
@ -61,10 +65,24 @@ public class BahnProviderTest
|
|||
+ "<span class=\"bold\">21:58</span> <span class=\"green bold\">pünktl.</span>, Gl. 13");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void departureWithMessage()
|
||||
{
|
||||
assertFineDepartures("" //
|
||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/551037/330609/12448/177455/80/si=405341&bt=dep&ti=07:08&pt=07:08&p=1111111111&date=06.09.10&max=10&rt=1&&\">\n" //
|
||||
+ "<span class=\"bold\">ICE 824</span>\n" //
|
||||
+ "</a>\n" //
|
||||
+ ">>\n" //
|
||||
+ "Dortmund Hbf\n" //
|
||||
+ "<br />\n" //
|
||||
+ "<span class=\"bold\">07:02</span> <span class=\"red\">ca. +5</span>, <span class=\"red\">Fährt heute nur bis Düsseldorf Hbf</span>, Gl. 10");
|
||||
}
|
||||
|
||||
private void assertFineConnectionDetails(String s)
|
||||
{
|
||||
Matcher m = BahnProvider.P_CONNECTION_DETAILS_FINE.matcher(s);
|
||||
assertTrue(m.matches());
|
||||
|
||||
// ParserUtils.printGroups(m);
|
||||
}
|
||||
|
||||
|
@ -72,6 +90,12 @@ public class BahnProviderTest
|
|||
{
|
||||
Matcher m = BahnProvider.P_DEPARTURES_FINE.matcher(s);
|
||||
assertTrue(m.matches());
|
||||
// ParserUtils.printGroups(m);
|
||||
|
||||
ParserUtils.printGroups(m);
|
||||
|
||||
assertNotNull(m.group(1)); // line
|
||||
assertNotNull(m.group(2)); // destination
|
||||
assertNotNull(m.group(3)); // time
|
||||
assertNotNull(m.group(6)); // departure
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue