mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 16:48:49 +00:00
relax about subtags
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@218 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
da57c29103
commit
135b07f59e
2 changed files with 16 additions and 187 deletions
|
@ -442,7 +442,7 @@ public final class BahnProvider implements NetworkProvider
|
||||||
return uri.toString();
|
return uri.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<Journey (.*?)/>", Pattern.DOTALL);
|
private static final Pattern P_DEPARTURES_COARSE = Pattern.compile("<Journey (.*?)/?>", Pattern.DOTALL);
|
||||||
static final Pattern P_DEPARTURES_FINE = Pattern.compile("" //
|
static final Pattern P_DEPARTURES_FINE = Pattern.compile("" //
|
||||||
+ "fpTime=\"(\\d{1,2}:\\d{2})\" fpDate=\"(\\d{2}\\.\\d{2}\\.\\d{2})\" \n" // time, date
|
+ "fpTime=\"(\\d{1,2}:\\d{2})\" fpDate=\"(\\d{2}\\.\\d{2}\\.\\d{2})\" \n" // time, date
|
||||||
+ "delay=\"(?:-|k\\.A\\.?|cancel|\\+?\\s*(\\d+))\" \n" // delay
|
+ "delay=\"(?:-|k\\.A\\.?|cancel|\\+?\\s*(\\d+))\" \n" // delay
|
||||||
|
@ -497,7 +497,7 @@ public final class BahnProvider implements NetworkProvider
|
||||||
|
|
||||||
final String position = mDepFine.group(4) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(4)) : null;
|
final String position = mDepFine.group(4) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(4)) : null;
|
||||||
|
|
||||||
final String destination = ParserUtils.resolveEntities(mDepFine.group(6));
|
final String destination = ParserUtils.resolveEntities(mDepFine.group(6)).trim();
|
||||||
|
|
||||||
final String line = normalizeLine(ParserUtils.resolveEntities(mDepFine.group(7)));
|
final String line = normalizeLine(ParserUtils.resolveEntities(mDepFine.group(7)));
|
||||||
|
|
||||||
|
|
|
@ -36,194 +36,22 @@ public class BahnProviderTest
|
||||||
+ "<span class=\"bold\">Berlin Hbf</span><br />\n" //
|
+ "<span class=\"bold\">Berlin Hbf</span><br />\n" //
|
||||||
+ "Übergang\n" //
|
+ "Übergang\n" //
|
||||||
+ "<br />\n" //
|
+ "<br />\n" //
|
||||||
+ "<span class=\"bold\">Berlin-Lichtenberg</span><br />");
|
+ "<span class=\"bold\">Berlin-Lichtenberg</span><br />\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void departureWithPlatform()
|
public void newDepartureWithMessage()
|
||||||
{
|
{
|
||||||
final Matcher m = assertFineDepartures("" //
|
final Matcher m = 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" //
|
+ "fpTime=\"21:10\" fpDate=\"01.10.10\" \n" //
|
||||||
+ "<span class=\"bold\">S 1</span>\n" //
|
+ "delay=\"cancel\" \n" //
|
||||||
+ "</a>\n" //
|
+ "platform =\"1\" \n" //
|
||||||
+ ">>\n" //
|
+ "targetLoc=\"Magdeburg Hbf\" \n" //
|
||||||
+ "Gänserndorf\n" //
|
+ "prod=\"RE 38090\" \n" //
|
||||||
+ "<br />\n" //
|
+ "delayReason=\" Notarzteinsatz am Gleis\"\n");
|
||||||
+ "<span class=\"bold\">10:42</span>Gl. 1");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
assertNotNull(m.group(4)); // position
|
||||||
assertNotNull(m.group(8)); // position
|
assertNotNull(m.group(9)); // message
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureWithOnTime()
|
|
||||||
{
|
|
||||||
final Matcher m = 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" //
|
|
||||||
+ "Rathenow\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">21:58</span> <span class=\"green bold\">pünktl.</span>, Gl. 13");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(5)); // onTime
|
|
||||||
assertNotNull(m.group(8)); // position
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureWithMessage()
|
|
||||||
{
|
|
||||||
final Matcher m = 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");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(6)); // delay
|
|
||||||
assertNotNull(m.group(7)); // message
|
|
||||||
assertNotNull(m.group(8)); // position
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureUpdatedPosition()
|
|
||||||
{
|
|
||||||
final Matcher m = assertFineDepartures("" //
|
|
||||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/492282/296365/292060/18065/80/si=8000320&bt=dep&ti=17:08&pt=17:08&p=1111111111&date=07.09.10&max=10&rt=1&&\">\n" //
|
|
||||||
+ "<span class=\"bold\">RB 30240</span>\n" //
|
|
||||||
+ "</a>\n" //
|
|
||||||
+ ">>\n" //
|
|
||||||
+ "Holzkirchen\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">17:10</span> <span class=\"green bold\">pünktl.</span>, <span class=\"red\">heute Gl. 7 </span>");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(5)); // onTime
|
|
||||||
assertNotNull(m.group(8)); // position
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureMessageAndUpdatedPosition()
|
|
||||||
{
|
|
||||||
final Matcher m = assertFineDepartures("" //
|
|
||||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/220206/221797/157782/5489/80/si=727269&bt=dep&ti=19:56&pt=19:56&p=1111111111&date=06.09.10&max=10&rt=1&&\">\n" //
|
|
||||||
+ "<span class=\"bold\">CNL 450</span>\n" //
|
|
||||||
+ "</a>\n" //
|
|
||||||
+ ">>\n" //
|
|
||||||
+ "Paris Est\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">19:57</span> <span class=\"green bold\">pünktl.</span>, <span class=\"red\">Änderung im Zuglauf!</span>, <span class=\"red\">heute Gl. 7 </span>");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(5)); // onTime
|
|
||||||
assertNotNull(m.group(7)); // message
|
|
||||||
assertNotNull(m.group(8)); // position
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureWithWeirdMessage()
|
|
||||||
{
|
|
||||||
final Matcher m = assertFineDepartures("" //
|
|
||||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/760983/402261/557174/24926/80/si=808093&bt=dep&ti=02:41&pt=02:41&p=1111111111&date=06.09.10&max=10&rt=1&&\">\n" //
|
|
||||||
+ "<span class=\"bold\">ICE 609</span>\n" //
|
|
||||||
+ "</a>\n" //
|
|
||||||
+ ">>\n" //
|
|
||||||
+ "Basel SBB\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">04:52</span> k.A., Gl. 3");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(8)); // position
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureWithErsatzzugMessage()
|
|
||||||
{
|
|
||||||
final Matcher m = assertFineDepartures("" //
|
|
||||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/606621/948269/912326/253956/80/si=591375&bt=dep&ti=14:28&pt=14:28&p=1111111111&date=10.09.10&max=10&rt=1&&\">\n" //
|
|
||||||
+ "<span class=\"bold\">RB 93328</span>\n" //
|
|
||||||
+ "</a>\n" //
|
|
||||||
+ ">>\n" //
|
|
||||||
+ "München Hbf Gl.27-36\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">14:49</span> <span class=\"green bold\">pünktl.</span>, Gl. 1,<br/><span class=\"red\">Ersatzzug für<a class=\"red underline\" href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/611619/369020/735680/163967/80?ld=96159&rt=1&use_realtime_filter=1&date=10.09.10&time=14:49&station_evaId=8000220&station_type=dep&\">RB 5416</a></span>");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(5)); // onTime
|
|
||||||
assertNotNull(m.group(8)); // position
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureWithMessageAndErsatzzugMessage()
|
|
||||||
{
|
|
||||||
final Matcher m = assertFineDepartures("" //
|
|
||||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/208035/206616/13568/62563/80/si=624141&bt=dep&ti=09:34&pt=09:34&p=1111111111&date=08.09.10&max=10&rt=1&&\">\n" //
|
|
||||||
+ "<span class=\"bold\">S 1</span>\n" //
|
|
||||||
+ "</a>\n" //
|
|
||||||
+ ">>\n" //
|
|
||||||
+ "München Ost\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">10:27</span>, <span class=\"red\">Zug fällt aus</span>,<br/><a class=\"red underline\" href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/144627/793698/280606/92094/80?ld=96159&rt=1&use_realtime_filter=1&date=08.09.10&time=10:27&station_evaId=8001647&station_type=dep&\"><span class=\"red\">Ersatzzug S </a></span>");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(7)); // message
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureWithPositionAndMessages()
|
|
||||||
{
|
|
||||||
final Matcher m = assertFineDepartures("" //
|
|
||||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/32967/150423/39690/8856/80/si=676819&bt=dep&ti=00:57&pt=00:57&p=1111111111&date=09.09.10&max=10&rt=1&&\">\n" //
|
|
||||||
+ "<span class=\"bold\">RB 34075</span>\n" //
|
|
||||||
+ "</a>\n" //
|
|
||||||
+ ">>\n" //
|
|
||||||
+ "Nürnberg Hbf\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">00:18</span>, <span class=\"red\">Zug fällt aus</span>, Gl. 4,<br/><a class=\"red underline\" href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/843399/1026627/462944/49661/80?ld=96159&rt=1&use_realtime_filter=1&date=09.09.10&time=00:18&station_evaId=8001844&station_type=dep&\"><span class=\"red\">Ersatzzug RB 30535</a></span>");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(7)); // message
|
|
||||||
assertNotNull(m.group(8)); // position
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureWithMultipleMessages()
|
|
||||||
{
|
|
||||||
final Matcher m = assertFineDepartures("" //
|
|
||||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/66819/191058/790068/372764/80/si=445675&bt=dep&ti=10:44&pt=10:44&p=1111111111&date=15.09.10&max=10&rt=1&&\">\n" //
|
|
||||||
+ "<span class=\"bold\">S 11</span>\n" //
|
|
||||||
+ "</a>\n" //
|
|
||||||
+ ">>\n" //
|
|
||||||
+ "Bergisch Gladbach\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">10:59</span> <span class=\"green bold\">pünktl.</span>, <span class=\"red\">Änderung im Zuglauf!</span>, <span class=\"red\">Fährt heute nur bis Köln-Dellbrück</span>, Gl. 1");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(5)); // onTime
|
|
||||||
assertNotNull(m.group(7)); // message
|
|
||||||
assertNotNull(m.group(7)); // position
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void departureSonderzug()
|
|
||||||
{
|
|
||||||
final Matcher m = assertFineDepartures("" //
|
|
||||||
+ "<a href=\"http://mobile.bahn.de/bin/mobil/traininfo.exe/dox/656949/964945/873914/217974/80/si=675348&bt=dep&ti=22:16&pt=22:16&p=1111111111&date=16.09.10&max=50&rt=1&&\">\n" //
|
|
||||||
+ "<span class=\"bold\">RE 30534</span>\n" //
|
|
||||||
+ "</a>\n" //
|
|
||||||
+ ">>\n" //
|
|
||||||
+ "Nürnberg Hbf\n" //
|
|
||||||
+ "<br />\n" //
|
|
||||||
+ "<span class=\"bold\">22:58</span> <span class=\"green bold\">pünktl.</span>, Gl. 2,<br/> <span class=\"red\">Sonderzug</span>");
|
|
||||||
|
|
||||||
assertNotNull(m.group(1)); // lineLink
|
|
||||||
assertNotNull(m.group(5)); // onTime
|
|
||||||
assertNotNull(m.group(8)); // position
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertFineConnectionDetails(String s)
|
private void assertFineConnectionDetails(String s)
|
||||||
|
@ -241,9 +69,10 @@ public class BahnProviderTest
|
||||||
|
|
||||||
// ParserUtils.printGroups(m);
|
// ParserUtils.printGroups(m);
|
||||||
|
|
||||||
assertNotNull(m.group(2)); // line
|
assertNotNull(m.group(1)); // time
|
||||||
assertNotNull(m.group(3)); // destination
|
assertNotNull(m.group(2)); // date
|
||||||
assertNotNull(m.group(4)); // time
|
assertNotNull(m.group(6)); // destination
|
||||||
|
assertNotNull(m.group(7)); // line
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue