use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint in project spring-cloud-stream by spring-cloud.
the class BinderPropertiesTests method testSerializationWithNonStringValues.
@SuppressWarnings("unchecked")
@Test
public void testSerializationWithNonStringValues() {
StaticApplicationContext context = new StaticApplicationContext();
DefaultListableBeanFactory bf = (DefaultListableBeanFactory) context.getBeanFactory();
BindingServiceProperties bindingServiceProperties = new BindingServiceProperties();
bindingServiceProperties.setApplicationContext(context);
bf.registerSingleton("bindingServiceProperties", bindingServiceProperties);
BindingServiceProperties bsp = context.getBean(BindingServiceProperties.class);
bsp.setApplicationContext(context);
BinderProperties bp = new BinderProperties();
bsp.setBinders(Collections.singletonMap("testBinder", bp));
bp.getEnvironment().put("spring.rabbitmq.connection-timeout", 2345);
bp.getEnvironment().put("foo", Collections.singletonMap("bar", "hello"));
// using Spring Boot class to ensure that reliance on the same ObjectMapper configuration
ConfigurationPropertiesReportEndpoint endpoint = new ConfigurationPropertiesReportEndpoint();
endpoint.setApplicationContext(context);
ContextConfigurationProperties configurationProperties = endpoint.configurationProperties().getContexts().values().iterator().next();
Map<String, Object> properties = configurationProperties.getBeans().get("bindingServiceProperties").getProperties();
assertFalse(properties.containsKey("error"));
assertTrue(properties.containsKey("binders"));
Map<String, Object> testBinder = (Map<String, Object>) ((Map<String, Object>) properties.get("binders")).get("testBinder");
Map<String, Object> environment = (Map<String, Object>) testBinder.get("environment");
assertTrue(environment.get("spring.rabbitmq.connection-timeout") instanceof Integer);
assertTrue(environment.get("foo") instanceof Map);
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointAutoConfiguration method configurationPropertiesReportEndpoint.
@Bean
@ConditionalOnMissingBean
public ConfigurationPropertiesReportEndpoint configurationPropertiesReportEndpoint(ConfigurationPropertiesReportEndpointProperties properties, ObjectProvider<SanitizingFunction> sanitizingFunctions) {
ConfigurationPropertiesReportEndpoint endpoint = new ConfigurationPropertiesReportEndpoint(sanitizingFunctions);
String[] keysToSanitize = properties.getKeysToSanitize();
if (keysToSanitize != null) {
endpoint.setKeysToSanitize(keysToSanitize);
}
String[] additionalKeysToSanitize = properties.getAdditionalKeysToSanitize();
if (additionalKeysToSanitize != null) {
endpoint.keysToSanitize(additionalKeysToSanitize);
}
return endpoint;
}
Aggregations