PropertyFileDependencyLoader extends AbstractConfigFileDependencyLoader { @Override protected List<Dependency> load(Path filePath, Properties properties, Logger logger) throws LifecycleExecutionException { List<Dependency> dependencyList = 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.dependency.")) { dependencyList.add(build(props.getProperty(name), properties, logger)); } } } catch (IOException e) { throw new LifecycleExecutionException("Failed to load properties from dependency configuration file", e); } return dependencyList; }    }
@Test public void shouldLoadFromPropertyFile() throws LifecycleExecutionException, URISyntaxException { List<Dependency> dependencyList = loader.load(TestHelper.getClasspathResource("yaks.properties"), properties, logger); TestHelper.verifyDependencies(dependencyList); }
@Test public void shouldHandleNonExistingFile() { Assertions.assertThatExceptionOfType(LifecycleExecutionException.class) .isThrownBy(() -> loader.load(Paths.get("doesNotExist"), properties, logger)); }