use of org.springframework.core.env.PropertySources in project spring-boot by spring-projects.
the class SpringBootTestContextBootstrapper method getConfiguredWebApplicationType.
private WebApplicationType getConfiguredWebApplicationType(MergedContextConfiguration configuration) {
PropertySources sources = convertToPropertySources(configuration.getPropertySourceProperties());
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(new PropertySourcesPropertyResolver(sources), "spring.main.");
String property = resolver.getProperty("web-application-type");
return (property != null ? WebApplicationType.valueOf(property.toUpperCase()) : null);
}
use of org.springframework.core.env.PropertySources in project spring-boot by spring-projects.
the class SpringBootContextLoader method hasCustomServerPort.
private boolean hasCustomServerPort(List<String> properties) {
PropertySources sources = convertToPropertySources(properties);
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(new PropertySourcesPropertyResolver(sources), "server.");
return resolver.containsProperty("port");
}
use of org.springframework.core.env.PropertySources in project spring-boot by spring-projects.
the class PropertySourcesDeducerTests method getPropertySourcesWhenHasNoPropertySourcesPlaceholderConfigurerReturnsEnvironmentSources.
@Test
void getPropertySourcesWhenHasNoPropertySourcesPlaceholderConfigurerReturnsEnvironmentSources() {
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(EmptyConfiguration.class);
ConfigurableEnvironment environment = (ConfigurableEnvironment) applicationContext.getEnvironment();
environment.getPropertySources().addFirst(new TestPropertySource());
PropertySourcesDeducer deducer = new PropertySourcesDeducer(applicationContext);
PropertySources propertySources = deducer.getPropertySources();
assertThat(propertySources.get("test")).isInstanceOf(TestPropertySource.class);
}
use of org.springframework.core.env.PropertySources in project kylo by Teradata.
the class Inspections method inspect.
public Object inspect(String path, String inspectionsPath, String isDevMode, String projectVersion) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
Configuration config = new DefaultConfiguration(path, inspectionsPath, isDevMode, projectVersion);
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
ppc.setLocation(new FileSystemResource(config.getServicesConfigLocation()));
ppc.setIgnoreUnresolvablePlaceholders(true);
ppc.setIgnoreResourceNotFound(false);
ppc.postProcessBeanFactory(ctx.getBeanFactory());
ppc.setEnvironment(ctx.getEnvironment());
PropertySources sources = ppc.getAppliedPropertySources();
sources.forEach(source -> ctx.getEnvironment().getPropertySources().addLast(source));
ctx.scan("com.thinkbiganalytics.install.inspector.inspection", "com.thinkbiganalytics.hive.config", "com.thinkbiganalytics.spring");
ctx.refresh();
InspectionService service = ctx.getBean(InspectionService.class);
return service.inspect(config);
}
use of org.springframework.core.env.PropertySources in project spring-boot by spring-projects.
the class PropertySourcesDeducerTests method getPropertySourcesWhenHasMultiplePropertySourcesPlaceholderConfigurerReturnsEnvironmentSources.
@Test
void getPropertySourcesWhenHasMultiplePropertySourcesPlaceholderConfigurerReturnsEnvironmentSources() {
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MultiplePropertySourcesPlaceholderConfigurerConfiguration.class);
ConfigurableEnvironment environment = (ConfigurableEnvironment) applicationContext.getEnvironment();
environment.getPropertySources().addFirst(new TestPropertySource());
PropertySourcesDeducer deducer = new PropertySourcesDeducer(applicationContext);
PropertySources propertySources = deducer.getPropertySources();
assertThat(propertySources.get("test")).isInstanceOf(TestPropertySource.class);
}
Aggregations