@Test public final void testRetrieveAll() { Ini iniFile = null; try { final Reader reader = new BufferedReader(new FileReader(CITIES_DAT_PATH)); iniFile = new Ini(reader); reader.close(); } catch (final Exception e) { fail("Loading of cities failed with message " + e.getMessage()); } final int totalCities = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_CITIES_KEY)); final City[] cities = dao.retrieveAll(); assertEquals(totalCities,cities.length); }
@Override public City[] retrieveAll() { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(citiesFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { LOGGER.error("Cities loading failed!", e); throw new RuntimeException(e); } int totalCities = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_CITIES_KEY)); City[] cities = new City[totalCities]; for (int i = 1; i <= totalCities; i++) { cities[i - 1] = loadCity(i, iniFile); } return cities; }
CityDAOIni implements CityDAO { @Override public City[] retrieveAll() { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(citiesFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { LOGGER.error("Cities loading failed!", e); throw new RuntimeException(e); } int totalCities = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_CITIES_KEY)); City[] cities = new City[totalCities]; for (int i = 1; i <= totalCities; i++) { cities[i - 1] = loadCity(i, iniFile); } return cities; } }
CityDAOIni implements CityDAO { @Override public City[] retrieveAll() { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(citiesFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { LOGGER.error("Cities loading failed!", e); throw new RuntimeException(e); } int totalCities = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_CITIES_KEY)); City[] cities = new City[totalCities]; for (int i = 1; i <= totalCities; i++) { cities[i - 1] = loadCity(i, iniFile); } return cities; } @Inject  CityDAOIni(@Named("citiesFilePath") String citiesFilePath); }
CityDAOIni implements CityDAO { @Override public City[] retrieveAll() { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(citiesFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { LOGGER.error("Cities loading failed!", e); throw new RuntimeException(e); } int totalCities = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_CITIES_KEY)); City[] cities = new City[totalCities]; for (int i = 1; i <= totalCities; i++) { cities[i - 1] = loadCity(i, iniFile); } return cities; } @Inject  CityDAOIni(@Named("citiesFilePath") String citiesFilePath); @Override City[] retrieveAll(); }
CityDAOIni implements CityDAO { @Override public City[] retrieveAll() { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(citiesFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { LOGGER.error("Cities loading failed!", e); throw new RuntimeException(e); } int totalCities = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_CITIES_KEY)); City[] cities = new City[totalCities]; for (int i = 1; i <= totalCities; i++) { cities[i - 1] = loadCity(i, iniFile); } return cities; } @Inject  CityDAOIni(@Named("citiesFilePath") String citiesFilePath); @Override City[] retrieveAll();  }