Browse Source

Relocate `@AutoConfigureDataSourceInitialization`

Relocate `@AutoConfigureDataSourceInitialization` from
`spring-jdbc-test` to `spring-boot-test-autoconfigure`. This change
allows Flyway and Liquibase to respond to the annotation without
the user needing to remember the `spring-jdbc-test` dependency.

This is especially important for R2DB applications which may
still be using Flyway or Liquibase for migrations and will
want them to apply during tests.

See gh-46356
See gh-47322
pull/47381/head
Phillip Webb 3 months ago
parent
commit
155e3bd5e6
  1. 2
      core/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureDataSourceInitialization.java
  2. 23
      core/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/package-info.java
  3. 1
      module/spring-boot-data-r2dbc-test/build.gradle
  4. 2
      module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/AutoConfigureDataR2dbc.java
  5. 2
      module/spring-boot-flyway/build.gradle
  6. 0
      module/spring-boot-flyway/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports
  7. 2
      module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigureDataSourceInitializationTests.java
  8. 1
      module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureJdbc.java
  9. 2
      module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports
  10. 2
      module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/AutoConfigureJooq.java
  11. 2
      module/spring-boot-liquibase/build.gradle
  12. 0
      module/spring-boot-liquibase/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports
  13. 2
      module/spring-boot-liquibase/src/test/java/org/springframework/boot/liquibase/autoconfigure/LiquibaseAutoConfigureDataSourceInitializationTests.java
  14. 1
      smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle
  15. 1
      smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle

2
module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureDataSourceInitialization.java → core/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureDataSourceInitialization.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.jdbc.test.autoconfigure;
package org.springframework.boot.test.autoconfigure.jdbc;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

23
core/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/package-info.java

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
/*
* Copyright 2012-present 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Auto-configuration for core JDBC test concerns.
*/
@NullMarked
package org.springframework.boot.test.autoconfigure.jdbc;
import org.jspecify.annotations.NullMarked;

1
module/spring-boot-data-r2dbc-test/build.gradle

@ -28,7 +28,6 @@ dependencies { @@ -28,7 +28,6 @@ dependencies {
api(project(":module:spring-boot-data-r2dbc"))
optional(project(":core:spring-boot-testcontainers"))
optional(project(":module:spring-boot-jdbc-test"))
optional("org.junit.jupiter:junit-jupiter-api")
testImplementation(project(":test-support:spring-boot-test-support"))

2
module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/AutoConfigureDataR2dbc.java

@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
/**
* {@link ImportAutoConfiguration Auto-configuration imports} for typical Data R2DBC

2
module/spring-boot-flyway/build.gradle

@ -33,8 +33,8 @@ dependencies { @@ -33,8 +33,8 @@ dependencies {
optional(project(":core:spring-boot-autoconfigure"))
optional(project(":core:spring-boot-docker-compose"))
optional(project(":module:spring-boot-jdbc-test"))
optional(project(":core:spring-boot-testcontainers"))
optional(project(":core:spring-boot-test-autoconfigure"))
optional(project(":module:spring-boot-actuator-autoconfigure"))
optional("org.flywaydb:flyway-database-oracle")
optional("org.flywaydb:flyway-database-postgresql")

0
module/spring-boot-flyway/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports → module/spring-boot-flyway/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports

2
module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigureDataSourceInitializationTests.java

@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;

1
module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureJdbc.java

@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy; @@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
/**
* {@link ImportAutoConfiguration Auto-configuration imports} for typical JDBC tests. Most

2
module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports → module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports

@ -1 +1 @@ @@ -1 +1 @@
org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration
org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration

2
module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/AutoConfigureJooq.java

@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
/**
* {@link ImportAutoConfiguration Auto-configuration imports} for typical jOOQ tests. Most

2
module/spring-boot-liquibase/build.gradle

@ -36,8 +36,8 @@ dependencies { @@ -36,8 +36,8 @@ dependencies {
optional(project(":core:spring-boot-autoconfigure"))
optional(project(":core:spring-boot-docker-compose"))
optional(project(":core:spring-boot-testcontainers"))
optional(project(":core:spring-boot-test-autoconfigure"))
optional(project(":module:spring-boot-actuator-autoconfigure"))
optional(project(":module:spring-boot-jdbc-test"))
optional("org.testcontainers:jdbc")
dockerTestImplementation(project(":core:spring-boot-test"))

0
module/spring-boot-liquibase/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports → module/spring-boot-liquibase/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports

2
module/spring-boot-liquibase/src/test/java/org/springframework/boot/liquibase/autoconfigure/LiquibaseAutoConfigureDataSourceInitializationTests.java

@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;

1
smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle

@ -32,7 +32,6 @@ dependencies { @@ -32,7 +32,6 @@ dependencies {
dockerTestImplementation(project(":core:spring-boot-testcontainers"))
dockerTestImplementation(project(":module:spring-boot-data-r2dbc-test"))
dockerTestImplementation(project(":module:spring-boot-jdbc-test"))
dockerTestImplementation(project(":starter:spring-boot-starter-test"))
dockerTestImplementation(project(":test-support:spring-boot-docker-test-support"))
dockerTestImplementation("io.projectreactor:reactor-test")

1
smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle

@ -30,7 +30,6 @@ dependencies { @@ -30,7 +30,6 @@ dependencies {
dockerTestImplementation(project(":core:spring-boot-testcontainers"))
dockerTestImplementation(project(":module:spring-boot-data-r2dbc-test"))
dockerTestImplementation(project(":module:spring-boot-jdbc-test"))
dockerTestImplementation(project(":starter:spring-boot-starter-test"))
dockerTestImplementation(project(":test-support:spring-boot-docker-test-support"))
dockerTestImplementation("io.projectreactor:reactor-test")

Loading…
Cancel
Save