/* * 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.assertNull; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import java.util.regex.Matcher; import org.junit.Ignore; import org.junit.Test; /** * @author Andreas Schildbach */ public class MvvProviderTest { @Test public void trip() { final Matcher m = assertFineConnectionDetails("" // + "ab 04:27 Machern (Sachs) Gleis 2
\n" // + "\n" // + "\n" // + "\"Zug\"\n" // + "\n" // + "\n" // + "MRB 88040 Mitteldeutsche Regiobahn
Richtung Leipzig Hbf\n" // + " \n" // + "an 04:47 Leipzig Hbf Gleis 19\n"); assertNotNull(m.group(1)); // departureTime assertNotNull(m.group(2)); // departure assertNotNull(m.group(3)); // product } @Test public void trip2() { final Matcher m = assertFineConnectionDetails("" // + "ab 09:04 Hauptbahnhof Haupthalle Gleis 26 \"Karte\"\n" // + "
\n" // + "\n" // + "\n" // + "\"Zug\"\n" // + "\n" // + "\n" // + "RE 4006 RegionalExpress
Richtung Nürnberg Hbf\n" // + " \n" // + "an 10:47 Nürnberg Hbf Gleis 12\n"); assertNotNull(m.group(1)); // departureTime assertNotNull(m.group(2)); // departure assertNotNull(m.group(3)); // product } @Test @Ignore("deactivated because there is no time") public void tripWithoutTime() { final Matcher m = assertFineConnectionDetails("" // + "ab Neufahrn \"Karte\"\n" // + "
\n" // + "\n" // + "\n" // + "\"Sitzenbleiber\"\n" // + "\n" // + "\n" // + "nicht umsteigen\n" // + " \n" // + "an Neufahrn \"Karte\"\n" // + "\n"); assertNotNull(m.group(2)); // departure assertNotNull(m.group(3)); // product } @Test public void tripWithoutProduct() { final Matcher m = assertFineConnectionDetails("" // + "ab 07:46 Niederstraub. Abzw.Krottenthal \"Karte\"\n" // + "
\n" // + "\n" // + "\n" // + "\n" // + "MVV-Ruftaxi 5621
Richtung Taufkirchen (Vils) Busbahnhof\n" // + " \n" // + "an 07:49 Dickarting \"Karte\"\n" // + "\n"); assertNotNull(m.group(1)); // departureTime assertNotNull(m.group(2)); // departure assertNull(m.group(3)); // product } @Test public void footway() { final Matcher m = assertFineConnectionDetails("" // + "ab München Infanteriestraße 7  \"Karte\"\n" // + "
\n" // + "\n" // + "\n" // + "\"Fussweg\"\n" // + "\n" // + "\n" // + "Fußweg\n" // + " (ca. 3 Minuten)\n" // + " \n" // + " \n" // + "an Infanteriestraße Süd  \"Karte\"\n" // + "\n"); assertNotNull(m.group(8)); // departure } @Test public void footway2() { final Matcher m = assertFineConnectionDetails("" // + "ab Weimar Gleis 1
\n" // + "\n" // + "\n" // + "\"Fussweg\"\n" // + "\n" // + "\n" // + "Fußweg\n" // + "(ca. 2 Minuten)\n" // + "\n" // + " \n" // + "an Weimar Gleis 2\n"); assertNotNull(m.group(8)); // departure } private Matcher assertFineConnectionDetails(String s) { Matcher m = MvvProvider.P_CONNECTION_DETAILS_FINE.matcher(s); assertTrue(m.matches()); // ParserUtils.printGroups(m); return m; } }