use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.
the class MongoDataAutoConfigurationTests method backsOffIfMongoClientBeanIsNotPresent.
@Test
void backsOffIfMongoClientBeanIsNotPresent() {
ApplicationContextRunner runner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(MongoDataAutoConfiguration.class));
runner.run((context) -> assertThat(context).doesNotHaveBean(MongoTemplate.class));
}
use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.
the class MongoReactiveDataAutoConfigurationTests method backsOffIfMongoClientBeanIsNotPresent.
@Test
void backsOffIfMongoClientBeanIsNotPresent() {
ApplicationContextRunner runner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class));
runner.run((context) -> assertThat(context).doesNotHaveBean(MongoReactiveDataAutoConfiguration.class));
}
use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointProxyTests method testWithProxyClass.
@Test
void testWithProxyClass() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class, SqlExecutor.class);
contextRunner.run((context) -> {
ApplicationConfigurationProperties applicationProperties = context.getBean(ConfigurationPropertiesReportEndpoint.class).configurationProperties();
assertThat(applicationProperties.getContexts().get(context.getId()).getBeans().values().stream().map(ConfigurationPropertiesBeanDescriptor::getPrefix).filter("executor.sql"::equals).findFirst()).isNotEmpty();
});
}
use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointProxyTests method proxiedConstructorBoundPropertiesShouldBeAvailableInReport.
@Test
void proxiedConstructorBoundPropertiesShouldBeAvailableInReport() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(ValidatedConfiguration.class).withPropertyValues("validated.name=baz");
contextRunner.run((context) -> {
ApplicationConfigurationProperties applicationProperties = context.getBean(ConfigurationPropertiesReportEndpoint.class).configurationProperties();
Map<String, Object> properties = applicationProperties.getContexts().get(context.getId()).getBeans().values().stream().map(ConfigurationPropertiesBeanDescriptor::getProperties).findFirst().get();
assertThat(properties.get("name")).isEqualTo("baz");
});
}
use of org.springframework.boot.test.context.runner.ApplicationContextRunner 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");
});
}
Aggregations