Search in sources :

Example 56 with StandardEnvironment

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);
}
Also used : ConfigurablePropertyResolver(org.springframework.core.env.ConfigurablePropertyResolver) MutablePropertySources(org.springframework.core.env.MutablePropertySources) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 57 with StandardEnvironment

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);
}
Also used : StandardServletEnvironment(org.springframework.web.context.support.StandardServletEnvironment) StandardEnvironment(org.springframework.core.env.StandardEnvironment) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 58 with StandardEnvironment

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);
}
Also used : StandardEnvironment(org.springframework.core.env.StandardEnvironment) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 59 with StandardEnvironment

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);
}
Also used : StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 60 with 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);
}
Also used : StandardServletEnvironment(org.springframework.web.context.support.StandardServletEnvironment) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Aggregations

StandardEnvironment (org.springframework.core.env.StandardEnvironment)146 Test (org.junit.jupiter.api.Test)63 MapPropertySource (org.springframework.core.env.MapPropertySource)52 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)42 Test (org.junit.Test)39 HashMap (java.util.HashMap)37 URI (java.net.URI)23 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)23 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)21 MutablePropertySources (org.springframework.core.env.MutablePropertySources)18 ProtobufMessageSerDe (com.kixeye.chassis.transport.serde.converter.ProtobufMessageSerDe)15 RestTemplate (org.springframework.web.client.RestTemplate)15 ServiceError (com.kixeye.chassis.transport.dto.ServiceError)14 JsonJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.JsonJacksonMessageSerDe)14 XmlMessageSerDe (com.kixeye.chassis.transport.serde.converter.XmlMessageSerDe)14 YamlJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.YamlJacksonMessageSerDe)14 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)13 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)13 QueuingWebSocketListener (com.kixeye.chassis.transport.websocket.QueuingWebSocketListener)9 WebSocketMessageRegistry (com.kixeye.chassis.transport.websocket.WebSocketMessageRegistry)9