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));
}
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("******");
});
}
Aggregations