private ConfigurationSourceProvider buildConfigurationSourceProvider(String baseFilename) { final Class<?> klass = getClass(); return new MergingSourceProvider(new ConfigurationSourceProvider() { @Override public InputStream open(String path) throws IOException { final InputStream stream = klass.getResourceAsStream(path); if (stream == null) { throw new FileNotFoundException("File " + path + " not found in test resources directory"); } return stream; } }, baseFilename, objectMapper, YAML_FACTORY); }
private ConfigurationSourceProvider buildConfigSourceProvider(String baseFileName) { final Class<?> klass = this.getClass(); return new MergingConfigProvider(new ConfigurationSourceProvider() { @Override public InputStream open(String path) throws IOException { InputStream inputStream = klass.getResourceAsStream(path); if (inputStream == null) { throw new FileNotFoundException(String.format("File %s not found in test resources directory", path)); } else { return inputStream; } } }, baseFileName, objectMapper, YAML_FACTORY); }
public MergingSourceProvider(ConfigurationSourceProvider delegate, String defaultConfigurationPath, ObjectMapper objectMapper, YAMLFactory yamlFactory) { this.delegate = delegate; this.defaultConfigurationPath = defaultConfigurationPath; this.objectMapper = objectMapper; this.yamlFactory = yamlFactory; }
public MergingConfigProvider(ConfigurationSourceProvider delegate, String defaultConfigPath, ObjectMapper objectMapper, YAMLFactory yamlFactory) { this.delegate = delegate; this.defaultConfigPath = defaultConfigPath; this.objectMapper = objectMapper; this.yamlFactory = yamlFactory; }
/** * Loads, parses, binds, and validates a configuration object. * * @param provider the provider to to use for reading configuration files * @param path the path of the configuration file * @return a validated configuration object * @throws IOException if there is an error reading the file * @throws ConfigurationException if there is an error parsing or validating the file */ public T build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { return build(loadConfiguration(provider, path), path); }