Search in sources :

Example 1 with ConfigurationPropertiesReportEndpoint

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);
}
Also used : ContextConfigurationProperties(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) ConfigurationPropertiesReportEndpoint(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) Map(java.util.Map) Test(org.junit.Test)

Example 2 with ConfigurationPropertiesReportEndpoint

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;
}
Also used : ConfigurationPropertiesReportEndpoint(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ConfigurationPropertiesReportEndpoint (org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint)2 Map (java.util.Map)1 Test (org.junit.Test)1 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)1 ContextConfigurationProperties (org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1