use of org.springframework.core.env.StandardEnvironment in project spring-boot by spring-projects.
the class AbstractApplicationEnvironmentTests method propertyResolverIsOptimizedForConfigurationProperties.
@Test
void propertyResolverIsOptimizedForConfigurationProperties() {
StandardEnvironment environment = createEnvironment();
ConfigurablePropertyResolver expected = ConfigurationPropertySources.createPropertyResolver(new MutablePropertySources());
assertThat(environment).extracting("propertyResolver").hasSameClassAs(expected);
}
use of org.springframework.core.env.StandardEnvironment in project spring-boot by spring-projects.
the class EnvironmentConverterTests method servletPropertySourcesAreNotCopiedOverIfNotWebEnvironment.
@Test
void servletPropertySourcesAreNotCopiedOverIfNotWebEnvironment() {
StandardServletEnvironment standardServletEnvironment = new StandardServletEnvironment();
StandardEnvironment convertedEnvironment = this.environmentConverter.convertEnvironmentIfNecessary(standardServletEnvironment, StandardEnvironment.class);
assertThat(convertedEnvironment).isNotSameAs(standardServletEnvironment);
Set<String> names = new HashSet<>();
for (PropertySource<?> propertySource : convertedEnvironment.getPropertySources()) {
names.add(propertySource.getName());
}
assertThat(names).doesNotContain(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME);
}
use of org.springframework.core.env.StandardEnvironment in project spring-boot by spring-projects.
the class EnvironmentConverterTests method servletPropertySourcesArePresentWhenTypeToConvertIsWeb.
@Test
void servletPropertySourcesArePresentWhenTypeToConvertIsWeb() {
StandardEnvironment standardEnvironment = new StandardEnvironment();
StandardEnvironment convertedEnvironment = this.environmentConverter.convertEnvironmentIfNecessary(standardEnvironment, StandardServletEnvironment.class);
assertThat(convertedEnvironment).isNotSameAs(standardEnvironment);
Set<String> names = new HashSet<>();
for (PropertySource<?> propertySource : convertedEnvironment.getPropertySources()) {
names.add(propertySource.getName());
}
assertThat(names).contains(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME);
}
use of org.springframework.core.env.StandardEnvironment in project spring-boot by spring-projects.
the class EnvironmentConverterTests method envClassSameShouldReturnEnvironmentUnconverted.
@Test
void envClassSameShouldReturnEnvironmentUnconverted() {
StandardEnvironment standardEnvironment = new StandardEnvironment();
StandardEnvironment convertedEnvironment = this.environmentConverter.convertEnvironmentIfNecessary(standardEnvironment, StandardEnvironment.class);
assertThat(convertedEnvironment).isSameAs(standardEnvironment);
}
use of org.springframework.core.env.StandardEnvironment in project spring-boot by spring-projects.
the class EnvironmentConverterTests method standardServletEnvironmentIsConverted.
@Test
void standardServletEnvironmentIsConverted() {
StandardServletEnvironment standardServletEnvironment = new StandardServletEnvironment();
StandardEnvironment convertedEnvironment = this.environmentConverter.convertEnvironmentIfNecessary(standardServletEnvironment, StandardEnvironment.class);
assertThat(convertedEnvironment).isNotSameAs(standardServletEnvironment);
}
Aggregations