@Test public void testReadWithFormatList() throws IOException { NavigationFileParser parser = new NavigationFileParser(); List<NavigationFormat> formats = new ArrayList<NavigationFormat>(); assertFalse(parser.read(new File(TEST_PATH + "from.itn"), formats)); formats.add(new TomTom8RouteFormat()); assertFalse(parser.read(new File(TEST_PATH + "from.itn"), formats)); formats.add(new TomTom5RouteFormat()); assertTrue(parser.read(new File(TEST_PATH + "from.itn"), formats)); }
@Test public void testNavigationFileParserListener() throws IOException { final NavigationFormat[] found = new NavigationFormat[1]; found[0] = null; NavigationFileParserListener listener = new NavigationFileParserListener() { public void reading(NavigationFormat<BaseRoute> format) { found[0] = format; } }; try { parser.addNavigationFileParserListener(listener); read(TEST_PATH + "from.itn"); assertTrue(found[0] instanceof TomTomRouteFormat); found[0] = null; parser.removeNavigationFileParserListener(listener); read(TEST_PATH + "from.itn"); assertNull(found[0]); } finally { parser.removeNavigationFileParserListener(listener); } }
void read(String testFileName) throws IOException { File source = new File(testFileName); assertTrue(parser.read(source)); assertNotNull(parser.getFormat()); assertNotNull(parser.getAllRoutes()); assertTrue(parser.getAllRoutes().size() > 0); assertNotNull("Cannot read route from " + source, parser.getTheRoute()); assertTrue(parser.getTheRoute().getPositionCount() > 0); }
void readRouteCharacteristics( String testFileName, RouteCharacteristics characteristics, int characteristicsCount, int[] positionCount) throws IOException { read(testFileName); List<BaseRoute> routes = parser.getRouteCharacteristics(characteristics); if (characteristicsCount == 0) { assertNull(routes); } else { assertEquals(characteristicsCount, routes.size()); for (int i = 0; i < routes.size(); i++) { BaseRoute route = routes.get(i); assertEquals(characteristics, route.getCharacteristics()); assertEquals(positionCount[i], route.getPositionCount()); } } }