in junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/LauncherConfigurationParameters.java [191:223]
private static Properties loadClasspathResource(String configFileName) {
Properties props = new Properties();
try {
ClassLoader classLoader = ClassLoaderUtils.getDefaultClassLoader();
Set<URL> resources = new LinkedHashSet<>(Collections.list(classLoader.getResources(configFileName)));
if (!resources.isEmpty()) {
if (resources.size() > 1) {
logger.warn(() -> String.format(
"Discovered %d '%s' configuration files in the classpath; only the first will be used.",
resources.size(), configFileName));
}
URL configFileUrl = resources.iterator().next(); // same as List#get(0)
logger.info(() -> String.format(
"Loading JUnit Platform configuration parameters from classpath resource [%s].", configFileUrl));
URLConnection urlConnection = configFileUrl.openConnection();
urlConnection.setUseCaches(false);
try (InputStream inputStream = urlConnection.getInputStream()) {
props.load(inputStream);
}
}
}
catch (Exception ex) {
logger.warn(ex,
() -> String.format(
"Failed to load JUnit Platform configuration parameters from classpath resource [%s].",
configFileName));
}
return props;
}