コード例 #1
0
 @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));
 }
コード例 #2
0
 @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);
   }
 }
コード例 #3
0
 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);
 }
コード例 #4
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());
     }
   }
 }