From e8b0a648722d8cf45745cbcb0c28c6648882ce6a Mon Sep 17 00:00:00 2001 From: sebastiankirsch Date: Sat, 5 Nov 2016 13:27:26 +0100 Subject: [PATCH 1/2] Add @Inherited to all AutoConfigure* classes See gh-7326 --- .../boot/test/autoconfigure/core/AutoConfigureCache.java | 2 ++ .../boot/test/autoconfigure/json/AutoConfigureJson.java | 2 ++ .../boot/test/autoconfigure/json/AutoConfigureJsonTesters.java | 2 ++ .../boot/test/autoconfigure/orm/jpa/AutoConfigureDataJpa.java | 2 ++ .../test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java | 2 ++ .../autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java | 2 ++ .../boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java | 2 ++ .../web/client/AutoConfigureMockRestServiceServer.java | 2 ++ .../test/autoconfigure/web/client/AutoConfigureWebClient.java | 2 ++ .../test/autoconfigure/web/servlet/AutoConfigureMockMvc.java | 2 ++ .../test/autoconfigure/web/servlet/AutoConfigureWebMvc.java | 2 ++ 11 files changed, 22 insertions(+) diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java index 23e04fa5ae..6d75b08e5c 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.core; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -36,6 +37,7 @@ import org.springframework.cache.support.NoOpCacheManager; * @since 1.4.0 */ @Documented +@Inherited @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @ImportAutoConfiguration diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJson.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJson.java index 555d445d2c..e291bfc8dc 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJson.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJson.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.json; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -36,6 +37,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented +@Inherited @ImportAutoConfiguration public @interface AutoConfigureJson { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java index 48f851a5f1..ea48f3c07b 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.json; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -38,6 +39,7 @@ import org.springframework.boot.test.json.JacksonTester; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented +@Inherited @ImportAutoConfiguration @PropertyMapping("spring.test.jsontesters") public @interface AutoConfigureJsonTesters { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureDataJpa.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureDataJpa.java index febc304189..57d8de1a26 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureDataJpa.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureDataJpa.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.orm.jpa; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -37,6 +38,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented +@Inherited @ImportAutoConfiguration public @interface AutoConfigureDataJpa { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java index ec728cdfaa..257ea81f32 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.orm.jpa; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -36,6 +37,7 @@ import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; * @see TestDatabaseAutoConfiguration */ @Documented +@Inherited @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE, ElementType.METHOD }) @ImportAutoConfiguration diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java index 979766700d..1e9b94526e 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.orm.jpa; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -32,6 +33,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * @see TestEntityManagerAutoConfiguration */ @Documented +@Inherited @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE, ElementType.METHOD }) @ImportAutoConfiguration diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java index 901107d84d..efcb762c73 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.restdocs; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -39,6 +40,7 @@ import org.springframework.core.annotation.AliasFor; * @see RestDocsMockMvcConfigurationCustomizer */ @Documented +@Inherited @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @ImportAutoConfiguration diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServer.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServer.java index 66867bb6ff..060c91fc30 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServer.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServer.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.web.client; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -44,6 +45,7 @@ import org.springframework.test.web.client.MockRestServiceServer; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented +@Inherited @ImportAutoConfiguration @PropertyMapping("spring.test.webclient.mockrestserviceserver") public @interface AutoConfigureMockRestServiceServer { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClient.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClient.java index 8ea63db86b..e54b2808c5 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClient.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClient.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.web.client; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -38,6 +39,7 @@ import org.springframework.web.client.RestTemplate; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented +@Inherited @ImportAutoConfiguration @PropertyMapping("spring.test.webclient") public @interface AutoConfigureWebClient { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java index aebfcbfe9f..1d7ba10456 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.web.servlet; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -41,6 +42,7 @@ import org.springframework.test.web.servlet.MvcResult; * @see SpringBootMockMvcBuilderCustomizer */ @Documented +@Inherited @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE, ElementType.METHOD }) @ImportAutoConfiguration diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureWebMvc.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureWebMvc.java index 79cab3dcc9..4ea3dccf9c 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureWebMvc.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureWebMvc.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.web.servlet; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -37,6 +38,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented +@Inherited @ImportAutoConfiguration public @interface AutoConfigureWebMvc { From ebfd86ea2670a5818ef5f82927652118721bca0a Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sun, 6 Nov 2016 11:42:45 +0100 Subject: [PATCH 2/2] Polish contribution Closes gh-7326 --- .../boot/test/autoconfigure/core/AutoConfigureCache.java | 4 ++-- .../test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java | 4 ++-- .../autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java | 4 ++-- .../test/autoconfigure/restdocs/AutoConfigureRestDocs.java | 4 ++-- .../test/autoconfigure/web/servlet/AutoConfigureMockMvc.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java index 6d75b08e5c..3388552b50 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java @@ -36,10 +36,10 @@ import org.springframework.cache.support.NoOpCacheManager; * @author Phillip Webb * @since 1.4.0 */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) @ImportAutoConfiguration public @interface AutoConfigureCache { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java index 257ea81f32..79661049dd 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java @@ -36,10 +36,10 @@ import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; * @author Phillip Webb * @see TestDatabaseAutoConfiguration */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) @ImportAutoConfiguration @PropertyMapping("spring.test.database") public @interface AutoConfigureTestDatabase { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java index 1e9b94526e..ec9c9dab18 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java @@ -32,10 +32,10 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * @author Phillip Webb * @see TestEntityManagerAutoConfiguration */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) @ImportAutoConfiguration public @interface AutoConfigureTestEntityManager { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java index efcb762c73..e027fadf8d 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java @@ -39,10 +39,10 @@ import org.springframework.core.annotation.AliasFor; * @see RestDocsAutoConfiguration * @see RestDocsMockMvcConfigurationCustomizer */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) @ImportAutoConfiguration @Import(RestDocumentationContextProviderRegistrar.class) @PropertyMapping("spring.test.restdocs") diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java index 1d7ba10456..a1ec5565a4 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java @@ -41,10 +41,10 @@ import org.springframework.test.web.servlet.MvcResult; * @see MockMvcAutoConfiguration * @see SpringBootMockMvcBuilderCustomizer */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) @ImportAutoConfiguration @PropertyMapping("spring.test.mockmvc") public @interface AutoConfigureMockMvc {