Use more flexible SpringFactoriesLoader
Closes gh-30235 Co-authored-by: Madhura Bhave <bhavem@vmware.com> Co-authored-by: Stephane Nicoll <snicoll@vmware.com>
This commit is contained in:
@@ -54,7 +54,7 @@ class BatchAutoConfigurationWithoutJpaTests {
|
||||
void jdbcWithDefaultSettings() {
|
||||
this.contextRunner.withUserConfiguration(DefaultConfiguration.class, EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.datasource.generate-unique-name=true")
|
||||
.withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)).run((context) -> {
|
||||
.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO)).run((context) -> {
|
||||
assertThat(context).hasSingleBean(JobLauncher.class);
|
||||
assertThat(context).hasSingleBean(JobExplorer.class);
|
||||
assertThat(context).hasSingleBean(JobRepository.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -123,8 +123,8 @@ class ConditionEvaluationReportLoggingListenerTests {
|
||||
@Test
|
||||
void listenerWithInfoLevelShouldLogAtInfo(CapturedOutput output) {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
ConditionEvaluationReportLoggingListener initializer = new ConditionEvaluationReportLoggingListener(
|
||||
LogLevel.INFO);
|
||||
ConditionEvaluationReportLoggingListener initializer = ConditionEvaluationReportLoggingListener
|
||||
.forLogLevel(LogLevel.INFO);
|
||||
initializer.initialize(context);
|
||||
context.register(Config.class);
|
||||
context.refresh();
|
||||
@@ -135,7 +135,7 @@ class ConditionEvaluationReportLoggingListenerTests {
|
||||
@Test
|
||||
void listenerSupportsOnlyInfoAndDebug() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new ConditionEvaluationReportLoggingListener(LogLevel.TRACE))
|
||||
.isThrownBy(() -> ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.TRACE))
|
||||
.withMessageContaining("LogLevel must be INFO or DEBUG");
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class SqlInitializationAutoConfigurationTests {
|
||||
@Test
|
||||
void whenConnectionFactoryIsAvailableAndModeIsNeverThenInitializerIsNotAutoConfigured() {
|
||||
this.contextRunner.withConfiguration(AutoConfigurations.of(R2dbcAutoConfiguration.class))
|
||||
.withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO))
|
||||
.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO))
|
||||
.withPropertyValues("spring.sql.init.mode:never")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(AbstractScriptDatabaseInitializer.class));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user