Search in sources :

Example 16 with EnvironmentDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method propertyWithPrimitiveOrWrapperTypeIsHandledCorrectly.

@Test
void propertyWithPrimitiveOrWrapperTypeIsHandledCorrectly() {
    ConfigurableEnvironment environment = emptyEnvironment();
    Map<String, Object> map = new LinkedHashMap<>();
    map.put("char", 'a');
    map.put("integer", 100);
    map.put("boolean", true);
    map.put("biginteger", BigInteger.valueOf(200));
    environment.getPropertySources().addFirst(new MapPropertySource("test", map));
    EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
    Map<String, PropertyValueDescriptor> properties = propertySources(descriptor).get("test").getProperties();
    assertThat(properties.get("char").getValue()).isEqualTo('a');
    assertThat(properties.get("integer").getValue()).isEqualTo(100);
    assertThat(properties.get("boolean").getValue()).isEqualTo(true);
    assertThat(properties.get("biginteger").getValue()).isEqualTo(BigInteger.valueOf(200));
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) PropertyValueDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor) MapPropertySource(org.springframework.core.env.MapPropertySource) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Example 17 with EnvironmentDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointAutoConfigurationTests method sanitizingFunctionsCanBeConfiguredViaTheEnvironment.

@Test
void sanitizingFunctionsCanBeConfiguredViaTheEnvironment() {
    this.contextRunner.withUserConfiguration(SanitizingFunctionConfiguration.class).withPropertyValues("management.endpoints.web.exposure.include=env").withSystemProperties("custom=123456", "password=123456").run((context) -> {
        assertThat(context).hasSingleBean(EnvironmentEndpoint.class);
        EnvironmentEndpoint endpoint = context.getBean(EnvironmentEndpoint.class);
        EnvironmentDescriptor env = endpoint.environment(null);
        Map<String, PropertyValueDescriptor> systemProperties = getSource("systemProperties", env).getProperties();
        assertThat(systemProperties.get("custom").getValue()).isEqualTo("$$$");
        assertThat(systemProperties.get("password").getValue()).isEqualTo("******");
    });
}
Also used : EnvironmentEndpoint(org.springframework.boot.actuate.env.EnvironmentEndpoint) PropertyValueDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)17 EnvironmentDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor)17 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)12 PropertyValueDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor)7 StandardEnvironment (org.springframework.core.env.StandardEnvironment)5 PropertySourceDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor)3 MapPropertySource (org.springframework.core.env.MapPropertySource)2 LinkedHashMap (java.util.LinkedHashMap)1 EnvironmentEndpoint (org.springframework.boot.actuate.env.EnvironmentEndpoint)1 CompositePropertySource (org.springframework.core.env.CompositePropertySource)1