use of org.springframework.boot.env.YamlPropertySourceLoader in project cloudbreak by hortonworks.
the class AppConfig method init.
@PostConstruct
public void init() throws IOException {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
ResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
PropertySourceLoader load = new YamlPropertySourceLoader();
for (Resource resource : patternResolver.getResources("classpath*:*-images.yml")) {
environment.getPropertySources().addLast(load.load(resource.getFilename(), resource, null));
}
for (Resource resource : loadEtcResources()) {
environment.getPropertySources().addFirst(load.load(resource.getFilename(), resource, null));
}
}
use of org.springframework.boot.env.YamlPropertySourceLoader in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerPropertiesValidationTest method bindMinimumValidYaml.
@Test
public void bindMinimumValidYaml() throws Exception {
this.context.register(ServiceBrokerPropertiesConfiguration.class);
Resource resource = context.getResource("classpath:catalog-minimal.yml");
YamlPropertySourceLoader sourceLoader = new YamlPropertySourceLoader();
List<PropertySource<?>> properties = sourceLoader.load("catalog", resource);
context.getEnvironment().getPropertySources().addFirst(properties.get(0));
validateMinimumCatalog();
}
use of org.springframework.boot.env.YamlPropertySourceLoader in project spring-boot by spring-projects.
the class StandardConfigDataLoaderTests method loadWhenLocationResultsInMultiplePropertySourcesAddsAllToConfigData.
@Test
void loadWhenLocationResultsInMultiplePropertySourcesAddsAllToConfigData() throws IOException {
ClassPathResource resource = new ClassPathResource("configdata/yaml/application.yml");
StandardConfigDataReference reference = new StandardConfigDataReference(ConfigDataLocation.of("classpath:configdata/yaml/application.yml"), null, "classpath:configdata/yaml/application", null, "yml", new YamlPropertySourceLoader());
StandardConfigDataResource location = new StandardConfigDataResource(reference, resource);
ConfigData configData = this.loader.load(this.loaderContext, location);
assertThat(configData.getPropertySources().size()).isEqualTo(2);
PropertySource<?> source1 = configData.getPropertySources().get(0);
PropertySource<?> source2 = configData.getPropertySources().get(1);
assertThat(source1.getName()).isEqualTo("Config resource 'class path resource [configdata/yaml/application.yml]' " + "via location 'classpath:configdata/yaml/application.yml' (document #0)");
assertThat(source1.getProperty("foo")).isEqualTo("bar");
assertThat(source2.getName()).isEqualTo("Config resource 'class path resource [configdata/yaml/application.yml]' " + "via location 'classpath:configdata/yaml/application.yml' (document #1)");
assertThat(source2.getProperty("hello")).isEqualTo("world");
}
use of org.springframework.boot.env.YamlPropertySourceLoader in project syndesis by syndesisio.
the class SyndesisCommand method createContext.
private AbstractApplicationContext createContext() {
final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
final YamlPropertySourceLoader propertySourceLoader = new YamlPropertySourceLoader();
final PropertySource<?> propertySource;
try {
propertySource = propertySourceLoader.load(name, context.getResource("classpath:" + name + ".yml"), null);
} catch (final IOException e) {
throw new IllegalStateException(e);
}
final StandardEnvironment environment = new StandardEnvironment();
final MutablePropertySources propertySources = environment.getPropertySources();
propertySources.addFirst(new MapPropertySource("parameters", parameters));
propertySources.addLast(propertySource);
context.setEnvironment(environment);
final String packageName = getClass().getPackage().getName();
context.scan(packageName);
context.refresh();
return context;
}
use of org.springframework.boot.env.YamlPropertySourceLoader in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerPropertiesBindingTest method bindMinimumValidYaml.
@Test
void bindMinimumValidYaml() throws Exception {
this.context.register(ServiceBrokerPropertiesConfiguration.class);
Resource resource = context.getResource("classpath:catalog-minimal.yml");
YamlPropertySourceLoader sourceLoader = new YamlPropertySourceLoader();
List<PropertySource<?>> properties = sourceLoader.load("catalog", resource);
context.getEnvironment().getPropertySources().addFirst(properties.get(0));
validateMinimumCatalog();
}
Aggregations