From 17e655b7e517cfd0cc2abd1651b0af57ff79bbbf Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 25 Sep 2025 12:26:20 -0700 Subject: [PATCH] Relocate `@PropertyMapping` to spring-boot-test Move `@PropertyMapping` and supporting code from the `spring-boot-test-autoconfigure` module to `spring-boot-test` since it's generally applicable. See gh-46356 See gh-47322 --- .../context}/AnnotationsPropertySource.java | 28 ++++++------- .../boot/test/context}/PropertyMapping.java | 28 +++++++++++-- .../PropertyMappingContextCustomizer.java | 2 +- ...opertyMappingContextCustomizerFactory.java | 2 +- .../boot/test/context/package-info.java | 3 +- .../main/resources/META-INF/spring.factories | 2 + .../AnnotationsPropertySourceTests.java | 17 ++++---- .../boot/test/context}/ExampleMapping.java | 2 +- ...yMappingContextCustomizerFactoryTests.java | 2 +- .../test/context}/PropertyMappingTests.java | 2 +- .../autoconfigure/AutoConfigureCache.java | 2 +- .../jpa/test/autoconfigure/DataJpaTest.java | 2 +- .../AutoConfigureTestDatabase.java | 6 +-- .../AutoConfigureJsonTesters.java | 2 +- .../AutoConfigureMockRestServiceServer.java | 2 +- .../autoconfigure/AutoConfigureWebClient.java | 2 +- .../autoconfigure/AutoConfigureRestDocs.java | 2 +- .../properties/SkipPropertyMapping.java | 42 ------------------- .../properties/package-info.java | 23 ---------- .../main/resources/META-INF/spring.factories | 3 +- .../boot/test/autoconfigure/ExampleTest.java | 2 +- .../AutoConfigureWebTestClient.java | 2 +- .../autoconfigure/AutoConfigureMockMvc.java | 6 +-- .../AutoConfigureMockWebServiceServer.java | 2 +- .../client/AutoConfigureWebServiceClient.java | 2 +- 25 files changed, 72 insertions(+), 116 deletions(-) rename {module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties => core/spring-boot-test/src/main/java/org/springframework/boot/test/context}/AnnotationsPropertySource.java (86%) rename {module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties => core/spring-boot-test/src/main/java/org/springframework/boot/test/context}/PropertyMapping.java (86%) rename {module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties => core/spring-boot-test/src/main/java/org/springframework/boot/test/context}/PropertyMappingContextCustomizer.java (98%) rename {module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties => core/spring-boot-test/src/main/java/org/springframework/boot/test/context}/PropertyMappingContextCustomizerFactory.java (95%) rename {module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties => core/spring-boot-test/src/test/java/org/springframework/boot/test/context}/AnnotationsPropertySourceTests.java (94%) rename {module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties => core/spring-boot-test/src/test/java/org/springframework/boot/test/context}/ExampleMapping.java (93%) rename {module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties => core/spring-boot-test/src/test/java/org/springframework/boot/test/context}/PropertyMappingContextCustomizerFactoryTests.java (98%) rename {module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties => core/spring-boot-test/src/test/java/org/springframework/boot/test/context}/PropertyMappingTests.java (95%) delete mode 100644 module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/SkipPropertyMapping.java delete mode 100644 module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/package-info.java diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotationsPropertySource.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java rename to core/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotationsPropertySource.java index 0b52b6e4a24..b5c320e1b55 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotationsPropertySource.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.properties; +package org.springframework.boot.test.context; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @@ -27,6 +27,7 @@ import java.util.regex.Pattern; import org.jspecify.annotations.Nullable; +import org.springframework.boot.test.context.PropertyMapping.Skip; import org.springframework.core.annotation.MergedAnnotation; import org.springframework.core.annotation.MergedAnnotationPredicates; import org.springframework.core.annotation.MergedAnnotations; @@ -42,19 +43,18 @@ import org.springframework.util.StringUtils; * * @author Phillip Webb * @author Andy Wilkinson - * @since 1.4.0 */ -public class AnnotationsPropertySource extends EnumerablePropertySource> { +class AnnotationsPropertySource extends EnumerablePropertySource> { private static final Pattern CAMEL_CASE_PATTERN = Pattern.compile("([^A-Z-])([A-Z])"); private final Map properties; - public AnnotationsPropertySource(Class source) { + AnnotationsPropertySource(Class source) { this("Annotations", source); } - public AnnotationsPropertySource(String name, Class source) { + AnnotationsPropertySource(String name, Class source) { super(name, source); this.properties = getProperties(source); } @@ -74,8 +74,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource MergedAnnotation typeMapping = MergedAnnotations.from(type) .get(PropertyMapping.class, MergedAnnotation::isDirectlyPresent); String prefix = typeMapping.getValue(MergedAnnotation.VALUE, String.class).orElse(""); - SkipPropertyMapping defaultSkip = typeMapping.getValue("skip", SkipPropertyMapping.class) - .orElse(SkipPropertyMapping.YES); + Skip defaultSkip = typeMapping.getValue("skip", Skip.class).orElse(Skip.YES); for (Method attribute : type.getDeclaredMethods()) { collectProperties(prefix, defaultSkip, annotation, attribute, properties); } @@ -85,18 +84,18 @@ public class AnnotationsPropertySource extends EnumerablePropertySource } } - private void collectProperties(String prefix, SkipPropertyMapping skip, MergedAnnotation annotation, - Method attribute, Map properties) { + private void collectProperties(String prefix, Skip skip, MergedAnnotation annotation, Method attribute, + Map properties) { MergedAnnotation attributeMapping = MergedAnnotations.from(attribute).get(PropertyMapping.class); - skip = attributeMapping.getValue("skip", SkipPropertyMapping.class).orElse(skip); - if (skip == SkipPropertyMapping.YES) { + skip = attributeMapping.getValue("skip", Skip.class).orElse(skip); + if (skip == Skip.YES) { return; } Optional value = annotation.getValue(attribute.getName()); if (value.isEmpty()) { return; } - if (skip == SkipPropertyMapping.ON_DEFAULT_VALUE) { + if (skip == Skip.ON_DEFAULT_VALUE) { if (ObjectUtils.nullSafeEquals(value.get(), annotation.getDefaultValue(attribute.getName()).orElse(null))) { return; } @@ -130,8 +129,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource return postfix; } - private void putProperties(String name, SkipPropertyMapping defaultSkip, Object value, - Map properties) { + private void putProperties(String name, Skip defaultSkip, Object value, Map properties) { if (ObjectUtils.isArray(value)) { Object[] array = ObjectUtils.toObjectArray(value); for (int i = 0; i < array.length; i++) { @@ -163,7 +161,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource return StringUtils.toStringArray(this.properties.keySet()); } - public boolean isEmpty() { + boolean isEmpty() { return this.properties.isEmpty(); } diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMapping.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMapping.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMapping.java rename to core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMapping.java index 3b3fe00280a..ba1741dd5f8 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMapping.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMapping.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.properties; +package org.springframework.boot.test.context; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -45,7 +45,7 @@ import org.springframework.test.context.TestPropertySource; *

* * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 * @see AnnotationsPropertySource * @see TestPropertySource */ @@ -68,6 +68,28 @@ public @interface PropertyMapping { * overrides the type-level default. * @return if mapping should be skipped */ - SkipPropertyMapping skip() default SkipPropertyMapping.NO; + Skip skip() default Skip.NO; + + /** + * Controls when mapping is skipped. + */ + enum Skip { + + /** + * Skip mapping the property. + */ + YES, + + /** + * Skip mapping the property when the default attribute value is specified. + */ + ON_DEFAULT_VALUE, + + /** + * Don't skip mapping the property. + */ + NO + + } } diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMappingContextCustomizer.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java rename to core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMappingContextCustomizer.java index 8c0a430dfde..206c83d2268 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMappingContextCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.properties; +package org.springframework.boot.test.context; import java.util.Set; import java.util.stream.Collectors; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactory.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMappingContextCustomizerFactory.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactory.java rename to core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMappingContextCustomizerFactory.java index db8d3357de0..ad519cab44b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactory.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/PropertyMappingContextCustomizerFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.properties; +package org.springframework.boot.test.context; import java.util.List; diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/package-info.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/package-info.java index cd1fee7aaf9..2e08d585342 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/package-info.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/context/package-info.java @@ -15,8 +15,7 @@ */ /** - * Classes and annotations related to configuring Spring's {@code ApplicationContext} for - * tests. + * Support for mapping annotation attribute values in the Spring {@code Environment}. */ @NullMarked package org.springframework.boot.test.context; diff --git a/core/spring-boot-test/src/main/resources/META-INF/spring.factories b/core/spring-boot-test/src/main/resources/META-INF/spring.factories index b6141e873a9..acf2470a65d 100644 --- a/core/spring-boot-test/src/main/resources/META-INF/spring.factories +++ b/core/spring-boot-test/src/main/resources/META-INF/spring.factories @@ -1,9 +1,11 @@ # Spring Test Context Customizer Factories org.springframework.test.context.ContextCustomizerFactory=\ org.springframework.boot.test.context.ImportsContextCustomizerFactory,\ +org.springframework.boot.test.context.PropertyMappingContextCustomizerFactory,\ org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizerFactory,\ org.springframework.boot.test.context.filter.annotation.TypeExcludeFiltersContextCustomizerFactory + # Application Context Initializers org.springframework.context.ApplicationContextInitializer=\ org.springframework.boot.test.context.filter.ExcludeFilterApplicationContextInitializer diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySourceTests.java b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/AnnotationsPropertySourceTests.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySourceTests.java rename to core/spring-boot-test/src/test/java/org/springframework/boot/test/context/AnnotationsPropertySourceTests.java index acdc020796e..adddbc0e177 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySourceTests.java +++ b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/AnnotationsPropertySourceTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.properties; +package org.springframework.boot.test.context; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -22,10 +22,11 @@ import java.lang.annotation.RetentionPolicy; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.properties.AnnotationsPropertySourceTests.DeeplyNestedAnnotations.Level1; -import org.springframework.boot.test.autoconfigure.properties.AnnotationsPropertySourceTests.DeeplyNestedAnnotations.Level2; -import org.springframework.boot.test.autoconfigure.properties.AnnotationsPropertySourceTests.EnclosingClass.PropertyMappedAnnotationOnEnclosingClass; -import org.springframework.boot.test.autoconfigure.properties.AnnotationsPropertySourceTests.NestedAnnotations.Entry; +import org.springframework.boot.test.context.AnnotationsPropertySourceTests.DeeplyNestedAnnotations.Level1; +import org.springframework.boot.test.context.AnnotationsPropertySourceTests.DeeplyNestedAnnotations.Level2; +import org.springframework.boot.test.context.AnnotationsPropertySourceTests.EnclosingClass.PropertyMappedAnnotationOnEnclosingClass; +import org.springframework.boot.test.context.AnnotationsPropertySourceTests.NestedAnnotations.Entry; +import org.springframework.boot.test.context.PropertyMapping.Skip; import org.springframework.core.annotation.AliasFor; import static org.assertj.core.api.Assertions.assertThat; @@ -268,7 +269,7 @@ class AnnotationsPropertySourceTests { } @Retention(RetentionPolicy.RUNTIME) - @PropertyMapping(skip = SkipPropertyMapping.YES) + @PropertyMapping(skip = Skip.YES) @interface NotMappedAtTypeLevelAnnotation { @PropertyMapping @@ -289,7 +290,7 @@ class AnnotationsPropertySourceTests { String value(); - @PropertyMapping(skip = SkipPropertyMapping.YES) + @PropertyMapping(skip = Skip.YES) String ignore() default "xyz"; } @@ -423,7 +424,7 @@ class AnnotationsPropertySourceTests { @PropertyMapping("testenum") @interface EnumAnnotation { - @PropertyMapping(skip = SkipPropertyMapping.ON_DEFAULT_VALUE) + @PropertyMapping(skip = Skip.ON_DEFAULT_VALUE) EnumItem value() default EnumItem.DEFAULT; } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/ExampleMapping.java b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/ExampleMapping.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/ExampleMapping.java rename to core/spring-boot-test/src/test/java/org/springframework/boot/test/context/ExampleMapping.java index 6ef46cbaaea..630aca2a292 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/ExampleMapping.java +++ b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/ExampleMapping.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.properties; +package org.springframework.boot.test.context; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/PropertyMappingContextCustomizerFactoryTests.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java rename to core/spring-boot-test/src/test/java/org/springframework/boot/test/context/PropertyMappingContextCustomizerFactoryTests.java index 03e407cdcc7..be3a41d9780 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizerFactoryTests.java +++ b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/PropertyMappingContextCustomizerFactoryTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.properties; +package org.springframework.boot.test.context; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingTests.java b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/PropertyMappingTests.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingTests.java rename to core/spring-boot-test/src/test/java/org/springframework/boot/test/context/PropertyMappingTests.java index 2b20d956d7c..babd2bac1c9 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingTests.java +++ b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/PropertyMappingTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.properties; +package org.springframework.boot.test.context; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCache.java b/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCache.java index 7e0afe4b051..10f8bb4b31c 100644 --- a/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCache.java +++ b/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCache.java @@ -25,7 +25,7 @@ import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.cache.CacheType; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.cache.CacheManager; import org.springframework.cache.support.NoOpCacheManager; diff --git a/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTest.java b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTest.java index 8882d5035c4..fdbc5b82aba 100644 --- a/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTest.java +++ b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTest.java @@ -31,7 +31,7 @@ import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureJdbc; import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; import org.springframework.boot.jpa.test.autoconfigure.AutoConfigureTestEntityManager; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.filter.annotation.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; diff --git a/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabase.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabase.java index 5bf8dda2b23..d1151235bab 100644 --- a/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabase.java +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabase.java @@ -28,8 +28,8 @@ import javax.sql.DataSource; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.container.ContainerImageMetadata; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; -import org.springframework.boot.test.autoconfigure.properties.SkipPropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping.Skip; import org.springframework.context.annotation.Primary; import org.springframework.test.context.DynamicPropertySource; @@ -55,7 +55,7 @@ public @interface AutoConfigureTestDatabase { * Determines what type of existing DataSource bean can be replaced. * @return the type of existing DataSource to replace */ - @PropertyMapping(skip = SkipPropertyMapping.ON_DEFAULT_VALUE) + @PropertyMapping(skip = Skip.ON_DEFAULT_VALUE) Replace replace() default Replace.NON_TEST; /** diff --git a/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJsonTesters.java b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJsonTesters.java index e70ec8e658a..7357f8ae368 100644 --- a/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJsonTesters.java +++ b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJsonTesters.java @@ -28,7 +28,7 @@ import org.springframework.boot.json.test.BasicJsonTester; import org.springframework.boot.json.test.GsonTester; import org.springframework.boot.json.test.JacksonTester; import org.springframework.boot.json.test.JsonbTester; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; /** * Annotation that can be applied to a test class to enable and configure diff --git a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServer.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServer.java index 94e853b4fd6..b96c45cac75 100644 --- a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServer.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServer.java @@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.restclient.RestTemplateBuilder; import org.springframework.boot.restclient.test.MockServerRestClientCustomizer; import org.springframework.boot.restclient.test.MockServerRestTemplateCustomizer; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestClient.Builder; diff --git a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClient.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClient.java index 69be8b0a4c0..269a34db3bb 100644 --- a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClient.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClient.java @@ -26,7 +26,7 @@ import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.json.test.autoconfigure.AutoConfigureJson; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.web.client.RestTemplate; /** diff --git a/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/AutoConfigureRestDocs.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/AutoConfigureRestDocs.java index e133a5cf4f2..8c01d8ed96c 100644 --- a/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/AutoConfigureRestDocs.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/AutoConfigureRestDocs.java @@ -26,7 +26,7 @@ import java.lang.annotation.Target; import io.restassured.RestAssured; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.context.annotation.Import; import org.springframework.core.annotation.AliasFor; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/SkipPropertyMapping.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/SkipPropertyMapping.java deleted file mode 100644 index 6dd1d8e3c6a..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/SkipPropertyMapping.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -package org.springframework.boot.test.autoconfigure.properties; - -/** - * Enum used to control when {@link PropertyMapping @PropertyMapping} is skipped. - * - * @author Phillip Webb - * @since 1.4.0 - */ -public enum SkipPropertyMapping { - - /** - * Skip mapping the property. - */ - YES, - - /** - * Skip mapping the property when the default attribute value is specified. - */ - ON_DEFAULT_VALUE, - - /** - * Don't skip mapping the property. - */ - NO - -} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/package-info.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/package-info.java deleted file mode 100644 index bf72f37d108..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ - -/** - * Support for mapping annotation attribute values in the Spring {@code Environment}. - */ -@NullMarked -package org.springframework.boot.test.autoconfigure.properties; - -import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories index 0a5f9ec4c3f..9c25e015222 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories @@ -1,5 +1,4 @@ # Spring Test Context Customizer Factories org.springframework.test.context.ContextCustomizerFactory=\ org.springframework.boot.test.autoconfigure.OnFailureConditionReportContextCustomizerFactory,\ -org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory,\ -org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizerFactory +org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTest.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTest.java index bb7d86971f6..ff3b20518ba 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTest.java +++ b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTest.java @@ -26,7 +26,7 @@ import java.lang.annotation.Target; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.test.context.BootstrapWith; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java index 09e4a9fe570..f88f406ddb7 100644 --- a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java @@ -25,7 +25,7 @@ import java.lang.annotation.Target; import java.time.Duration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.context.ApplicationContext; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureMockMvc.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureMockMvc.java index dbd2dc099d0..e252452b579 100644 --- a/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureMockMvc.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureMockMvc.java @@ -27,8 +27,8 @@ import org.htmlunit.WebClient; import org.openqa.selenium.WebDriver; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; -import org.springframework.boot.test.autoconfigure.properties.SkipPropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping.Skip; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.assertj.MockMvcTester; @@ -62,7 +62,7 @@ public @interface AutoConfigureMockMvc { * How {@link MvcResult} information should be printed after each MockMVC invocation. * @return how information is printed */ - @PropertyMapping(skip = SkipPropertyMapping.ON_DEFAULT_VALUE) + @PropertyMapping(skip = Skip.ON_DEFAULT_VALUE) MockMvcPrint print() default MockMvcPrint.DEFAULT; /** diff --git a/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServer.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServer.java index 938b7007449..bc0e83231a8 100644 --- a/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServer.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServer.java @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.ws.test.client.MockWebServiceServer; /** diff --git a/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClient.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClient.java index ea40958cb31..1dab814551b 100644 --- a/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClient.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClient.java @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.boot.test.context.PropertyMapping; import org.springframework.boot.webservices.client.WebServiceTemplateBuilder; import org.springframework.ws.client.core.WebServiceTemplate;