mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Add nullability annotations to tests in module/spring-boot-liquibase
See gh-47263
This commit is contained in:
@@ -56,3 +56,11 @@ dependencies {
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
testRuntimeOnly("org.postgresql:postgresql")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
tasks.named("compileDockerTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+4
-2
@@ -20,6 +20,7 @@ import javax.sql.DataSource;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import liquibase.integration.spring.SpringLiquibase;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
@@ -40,6 +41,7 @@ class LiquibaseChangelogMissingFailureAnalyzerTests {
|
||||
@Test
|
||||
void changelogParseExceptionDueToChangelogNotPresent() {
|
||||
FailureAnalysis analysis = performAnalysis();
|
||||
assertThat(analysis).isNotNull();
|
||||
assertThat(analysis.getDescription())
|
||||
.isEqualTo("Liquibase failed to start because no changelog could be found at '"
|
||||
+ "classpath:/db/changelog/db.changelog-master.yaml'.");
|
||||
@@ -47,13 +49,13 @@ class LiquibaseChangelogMissingFailureAnalyzerTests {
|
||||
.isEqualTo("Make sure a Liquibase changelog is present at the configured path.");
|
||||
}
|
||||
|
||||
private FailureAnalysis performAnalysis() {
|
||||
private @Nullable FailureAnalysis performAnalysis() {
|
||||
BeanCreationException failure = createFailure();
|
||||
assertThat(failure).isNotNull();
|
||||
return new LiquibaseChangelogMissingFailureAnalyzer().analyze(failure);
|
||||
}
|
||||
|
||||
private BeanCreationException createFailure() {
|
||||
private @Nullable BeanCreationException createFailure() {
|
||||
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
LiquibaseConfiguration.class)) {
|
||||
return null;
|
||||
|
||||
+7
-2
@@ -25,6 +25,7 @@ import java.lang.annotation.Target;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Driver;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -334,7 +335,9 @@ class LiquibaseAutoConfigurationTests {
|
||||
.run(assertLiquibase((liquibase) -> {
|
||||
SimpleDriverDataSource dataSource = (SimpleDriverDataSource) liquibase.getDataSource();
|
||||
assertThat(dataSource.getUrl()).isEqualTo(jdbcUrl);
|
||||
assertThat(dataSource.getDriver().getClass().getName()).isEqualTo("org.h2.Driver");
|
||||
Driver driver = dataSource.getDriver();
|
||||
assertThat(driver).isNotNull();
|
||||
assertThat(driver.getClass().getName()).isEqualTo("org.h2.Driver");
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -349,7 +352,9 @@ class LiquibaseAutoConfigurationTests {
|
||||
.run(assertLiquibase((liquibase) -> {
|
||||
SimpleDriverDataSource dataSource = (SimpleDriverDataSource) liquibase.getDataSource();
|
||||
assertThat(dataSource.getUrl()).isEqualTo(jdbcUrl);
|
||||
assertThat(dataSource.getDriver().getClass().getName()).isEqualTo(driverClassName);
|
||||
Driver driver = dataSource.getDriver();
|
||||
assertThat(driver).isNotNull();
|
||||
assertThat(driver.getClass().getName()).isEqualTo(driverClassName);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user