PropertyFileRepositoryLoader extends AbstractConfigFileRepositoryLoader { @Override protected List<Repository> load(Path filePath, Logger logger) throws LifecycleExecutionException { List<Repository> repositoryList = new ArrayList<>(); try { Properties props = new Properties(); props.load(new StringReader(new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8))); for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); ) { String name = (String) e.nextElement(); if (name.startsWith("yaks.repository.")) { repositoryList.add(build(name.substring("yaks.repository.".length()), props.getProperty(name), logger)); } } } catch (IOException e) { throw new LifecycleExecutionException("Failed to load properties from repository configuration file", e); } return repositoryList; }    }
@Test public void shouldLoadFromPropertyFile() throws LifecycleExecutionException, URISyntaxException { List<Repository> repositoryList = loader.load(TestHelper.getClasspathResource("yaks.properties"), logger); TestHelper.verifyRepositories(repositoryList); }
@Test public void shouldHandleNonExistingFile() { Assertions.assertThatExceptionOfType(LifecycleExecutionException.class) .isThrownBy(() -> loader.load(Paths.get("doesNotExist"), logger)); }