use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties 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.ContextConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointFilteringTests method filterByPrefixSingleMatch.
@Test
void filterByPrefixSingleMatch() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class).withPropertyValues("foo.primary.name:foo1", "foo.secondary.name:foo2", "only.bar.name:solo1");
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationPropertiesWithPrefix("only.bar");
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
assertThat(contextProperties.getBeans().values()).singleElement().hasFieldOrPropertyWithValue("prefix", "only.bar");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointFilteringTests method filterByPrefixMultipleMatches.
@Test
void filterByPrefixMultipleMatches() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class).withPropertyValues("foo.primary.name:foo1", "foo.secondary.name:foo2", "only.bar.name:solo1");
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationPropertiesWithPrefix("foo.");
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
assertThat(contextProperties.getBeans()).containsOnlyKeys("primaryFoo", "secondaryFoo");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointFilteringTests method filterByPrefixNoMatches.
@Test
void filterByPrefixNoMatches() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class).withPropertyValues("foo.primary.name:foo1", "foo.secondary.name:foo2", "only.bar.name:solo1");
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationPropertiesWithPrefix("foo.third");
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
assertThat(contextProperties.getBeans()).isEmpty();
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointMethodAnnotationsTests method prefixFromBeanMethodConfigurationPropertiesCanOverridePrefixOnClass.
@Test
void prefixFromBeanMethodConfigurationPropertiesCanOverridePrefixOnClass() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(OverriddenPrefix.class).withPropertyValues("other.name:foo");
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
ConfigurationPropertiesBeanDescriptor bar = contextProperties.getBeans().get("bar");
assertThat(bar).isNotNull();
assertThat(bar.getPrefix()).isEqualTo("other");
assertThat(bar.getProperties()).isNotNull();
assertThat(bar.getProperties()).isNotEmpty();
});
}
Aggregations