ParserResult read(String testFileName) throws IOException {
   File source = new File(testFileName);
   ParserResult result = parser.read(source);
   assertNotNull(result.getFormat());
   assertNotNull(result.getAllRoutes());
   assertTrue(result.getAllRoutes().size() > 0);
   assertNotNull("Cannot read route from " + source, result.getTheRoute());
   assertTrue(result.getTheRoute().getPositionCount() > 0);
   return result;
 }
  @Test
  public void testReadWithFormatList() throws IOException {
    List<NavigationFormat> formats = new ArrayList<>();
    ParserResult result1 = parser.read(new File(TEST_PATH + "from.itn"), formats);
    assertFalse(result1.isSuccessful());

    formats.add(new TomTom8RouteFormat());
    ParserResult result2 = parser.read(new File(TEST_PATH + "from.itn"), formats);
    assertTrue(result2.isSuccessful());
    assertEquals(0, result2.getTheRoute().getPositions().size());
    assertEquals(1, result2.getAllRoutes().size());
    assertEquals(result2.getFormat().getClass(), TomTom8RouteFormat.class);

    formats.add(new TomTom5RouteFormat());
    ParserResult result3 = parser.read(new File(TEST_PATH + "from.itn"), formats);
    assertTrue(result3.isSuccessful());
    assertEquals(46, result3.getTheRoute().getPositions().size());
    assertEquals(1, result3.getAllRoutes().size());
    assertEquals(result3.getFormat().getClass(), TomTom5RouteFormat.class);
  }
 void readRouteCharacteristics(
     String testFileName,
     RouteCharacteristics characteristics,
     int characteristicsCount,
     int[] positionCount)
     throws IOException {
   ParserResult result = read(testFileName);
   List<BaseRoute> routes = getRouteCharacteristics(result.getAllRoutes(), characteristics);
   if (routes == null || 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());
     }
   }
 }