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);
  }
 @Test
 public void testNavigationFileParserListener() throws IOException {
   final NavigationFormat[] found = new NavigationFormat[1];
   found[0] = null;
   NavigationFormatParserListener listener =
       new NavigationFormatParserListener() {
         public void reading(NavigationFormat<BaseRoute> format) {
           found[0] = format;
         }
       };
   try {
     parser.addNavigationFileParserListener(listener);
     read(TEST_PATH + "from.itn");
     assertEquals(TomTom5RouteFormat.class, found[0].getClass());
     found[0] = null;
     parser.removeNavigationFileParserListener(listener);
     read(TEST_PATH + "from.itn");
     assertNull(found[0]);
   } finally {
     parser.removeNavigationFileParserListener(listener);
   }
 }