mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 23:18:48 +00:00
relax about invalid closing bracket in xml
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@220 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
9af8c00ede
commit
f7a6b7497f
2 changed files with 55 additions and 3 deletions
|
@ -432,7 +432,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);
|
static final Pattern P_DEPARTURES_COARSE = Pattern.compile("\\G<Journey (.*?)/?>(?:\n|\\z)", 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
|
||||||
|
|
|
@ -29,6 +29,49 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class BahnProviderTest
|
public class BahnProviderTest
|
||||||
{
|
{
|
||||||
|
@Test
|
||||||
|
public void coarseDeparture()
|
||||||
|
{
|
||||||
|
assertCoarseDepartures("" //
|
||||||
|
+ "<Journey fpTime=\"17:45\" fpDate=\"02.10.10\" \n" //
|
||||||
|
+ "delay=\"k.A\" \n" //
|
||||||
|
+ "platform =\"1\" \n" //
|
||||||
|
+ "targetLoc=\"Berlin Südkreuz (S)\" \n" //
|
||||||
|
+ "prod=\"S 41\" \n" //
|
||||||
|
+ "depStation=\"Berlin Sonnenallee\"\n" //
|
||||||
|
+ "delayReason=\" \"\n" //
|
||||||
|
+ "/>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void coarseDepartureWithoutTrailingNewLine()
|
||||||
|
{
|
||||||
|
assertCoarseDepartures("" //
|
||||||
|
+ "<Journey fpTime=\"17:45\" fpDate=\"02.10.10\" \n" //
|
||||||
|
+ "delay=\"k.A\" \n" //
|
||||||
|
+ "platform =\"1\" \n" //
|
||||||
|
+ "targetLoc=\"Berlin Südkreuz (S)\" \n" //
|
||||||
|
+ "prod=\"S 41\" \n" //
|
||||||
|
+ "depStation=\"Berlin Sonnenallee\"\n" //
|
||||||
|
+ "delayReason=\" \"\n" //
|
||||||
|
+ "/>");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void coarseDepartureWithInvalidClosingBracket()
|
||||||
|
{
|
||||||
|
assertCoarseDepartures("" //
|
||||||
|
+ "<Journey fpTime=\"17:45\" fpDate=\"02.10.10\" \n" //
|
||||||
|
+ "delay=\"k.A\" \n" //
|
||||||
|
+ "platform =\"1\" \n" //
|
||||||
|
+ "targetLoc=\"Berlin Südkreuz (S)\" \n" //
|
||||||
|
+ "prod=\"S 41\" \n" //
|
||||||
|
+ "dir=\"Ringbahn ->\"\n" //
|
||||||
|
+ "depStation=\"Berlin Sonnenallee\"\n" //
|
||||||
|
+ "delayReason=\" \"\n" //
|
||||||
|
+ "/>\n");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void connectionUebergang()
|
public void connectionUebergang()
|
||||||
{
|
{
|
||||||
|
@ -54,7 +97,7 @@ public class BahnProviderTest
|
||||||
assertNotNull(m.group(9)); // message
|
assertNotNull(m.group(9)); // message
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertFineConnectionDetails(String s)
|
private void assertFineConnectionDetails(final String s)
|
||||||
{
|
{
|
||||||
Matcher m = BahnProvider.P_CONNECTION_DETAILS_FINE.matcher(s);
|
Matcher m = BahnProvider.P_CONNECTION_DETAILS_FINE.matcher(s);
|
||||||
assertTrue(m.matches());
|
assertTrue(m.matches());
|
||||||
|
@ -62,7 +105,16 @@ public class BahnProviderTest
|
||||||
// ParserUtils.printGroups(m);
|
// ParserUtils.printGroups(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Matcher assertFineDepartures(String s)
|
private Matcher assertCoarseDepartures(final String s)
|
||||||
|
{
|
||||||
|
Matcher m = BahnProvider.P_DEPARTURES_COARSE.matcher(s);
|
||||||
|
assertTrue(m.find());
|
||||||
|
assertFineDepartures(m.group(1));
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Matcher assertFineDepartures(final String s)
|
||||||
{
|
{
|
||||||
Matcher m = BahnProvider.P_DEPARTURES_FINE.matcher(s);
|
Matcher m = BahnProvider.P_DEPARTURES_FINE.matcher(s);
|
||||||
assertTrue(m.matches());
|
assertTrue(m.matches());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue