From bd4c43bf53e74970a6e73845e6fef8ee6b84f185 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 15 Jan 2026 11:28:02 +0000 Subject: [PATCH] Make s-b-restclient test autoconfigs package-private Fixes gh-48820 --- module/spring-boot-resttestclient/build.gradle | 4 ++-- .../autoconfigure/AutoConfigureRestTestClient.java | 1 - ...tion.java => RestTestClientTestAutoConfiguration.java} | 6 +++--- ...on.java => TestRestTemplateTestAutoConfiguration.java} | 6 +++--- ...ient.autoconfigure.AutoConfigureRestTestClient.imports | 2 +- ...nt.autoconfigure.AutoConfigureTestRestTemplate.imports | 2 +- ...java => RestTestClientTestAutoConfigurationTests.java} | 8 ++++---- ...va => TestRestTemplateTestAutoConfigurationTests.java} | 8 ++++---- 8 files changed, 18 insertions(+), 19 deletions(-) rename module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/{RestTestClientAutoConfiguration.java => RestTestClientTestAutoConfiguration.java} (95%) rename module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/{TestRestTemplateAutoConfiguration.java => TestRestTemplateTestAutoConfiguration.java} (93%) rename module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/{RestTestClientAutoConfigurationTests.java => RestTestClientTestAutoConfigurationTests.java} (95%) rename module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/{TestRestTemplateAutoConfigurationTests.java => TestRestTemplateTestAutoConfigurationTests.java} (90%) diff --git a/module/spring-boot-resttestclient/build.gradle b/module/spring-boot-resttestclient/build.gradle index 475deeb79eb..42a8714dbfc 100644 --- a/module/spring-boot-resttestclient/build.gradle +++ b/module/spring-boot-resttestclient/build.gradle @@ -50,7 +50,7 @@ tasks.named("compileTestJava") { tasks.named("checkAutoConfigurationClasses") { omittedFromImports = [ - "org.springframework.boot.resttestclient.autoconfigure.RestTestClientAutoConfiguration", - "org.springframework.boot.resttestclient.autoconfigure.TestRestTemplateAutoConfiguration" + "org.springframework.boot.resttestclient.autoconfigure.RestTestClientTestAutoConfiguration", + "org.springframework.boot.resttestclient.autoconfigure.TestRestTemplateTestAutoConfiguration" ] } diff --git a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/AutoConfigureRestTestClient.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/AutoConfigureRestTestClient.java index fdb74a35138..8fa722d6a33 100644 --- a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/AutoConfigureRestTestClient.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/AutoConfigureRestTestClient.java @@ -31,7 +31,6 @@ import org.springframework.test.web.servlet.client.RestTestClient; * * @author Stephane Nicoll * @since 4.0.0 - * @see RestTestClientAutoConfiguration */ @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) diff --git a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientAutoConfiguration.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientTestAutoConfiguration.java similarity index 95% rename from module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientAutoConfiguration.java rename to module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientTestAutoConfiguration.java index cd7958f055c..c8c11b49b72 100644 --- a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientAutoConfiguration.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientTestAutoConfiguration.java @@ -33,16 +33,16 @@ import org.springframework.web.client.RestClient; import org.springframework.web.context.WebApplicationContext; /** - * Auto-configuration for {@link RestTestClient}. + * Test auto-configuration for {@link RestTestClient}. * * @author Stephane Nicoll * @author Andy Wilkinson * @author Phillip Webb - * @since 4.0.0 + * @see AutoConfigureRestTestClient */ @AutoConfiguration @ConditionalOnClass({ RestClient.class, RestTestClient.class, ClientHttpMessageConvertersCustomizer.class }) -public final class RestTestClientAutoConfiguration { +final class RestTestClientTestAutoConfiguration { @Bean SpringBootRestTestClientBuilderCustomizer springBootRestTestClientBuilderCustomizer( diff --git a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateAutoConfiguration.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateTestAutoConfiguration.java similarity index 93% rename from module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateAutoConfiguration.java rename to module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateTestAutoConfiguration.java index 6245b33f8f2..453b45314f0 100644 --- a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateAutoConfiguration.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateTestAutoConfiguration.java @@ -28,13 +28,13 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; /** - * Auto-configuration for {@link TestRestTemplate}. + * Test auto-configuration for {@link TestRestTemplate}. * * @author Andy Wilkinson - * @since 4.0.0 + * @see AutoConfigureTestRestTemplate */ @AutoConfiguration -public final class TestRestTemplateAutoConfiguration { +final class TestRestTemplateTestAutoConfiguration { @Bean(name = "org.springframework.boot.resttestclient.TestRestTemplate") @ConditionalOnMissingBean diff --git a/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient.imports b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient.imports index b5a18919215..f31d4368261 100644 --- a/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient.imports +++ b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient.imports @@ -1 +1 @@ -org.springframework.boot.resttestclient.autoconfigure.RestTestClientAutoConfiguration +org.springframework.boot.resttestclient.autoconfigure.RestTestClientTestAutoConfiguration diff --git a/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate.imports b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate.imports index 00823e465a8..b0990ca31dd 100644 --- a/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate.imports +++ b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate.imports @@ -1 +1 @@ -org.springframework.boot.resttestclient.autoconfigure.TestRestTemplateAutoConfiguration +org.springframework.boot.resttestclient.autoconfigure.TestRestTemplateTestAutoConfiguration diff --git a/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientAutoConfigurationTests.java b/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientTestAutoConfigurationTests.java similarity index 95% rename from module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientAutoConfigurationTests.java rename to module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientTestAutoConfigurationTests.java index 1282790372b..063ff81f5f9 100644 --- a/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientAutoConfigurationTests.java +++ b/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/RestTestClientTestAutoConfigurationTests.java @@ -43,15 +43,15 @@ import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; /** - * Tests for {@link RestTestClientAutoConfiguration}. + * Tests for {@link RestTestClientTestAutoConfiguration}. * * @author Andy Wilkinson * @author Phillip Webb */ -class RestTestClientAutoConfigurationTests { +class RestTestClientTestAutoConfigurationTests { private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(RestTestClientAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(RestTestClientTestAutoConfiguration.class)); @Test void registersRestTestClient() { @@ -78,7 +78,7 @@ class RestTestClientAutoConfigurationTests { @WithResource(name = "META-INF/spring.factories", content = """ org.springframework.boot.test.http.server.LocalTestWebServer$Provider=\ - org.springframework.boot.resttestclient.autoconfigure.RestTestClientAutoConfigurationTests$TestLocalTestWebServerProvider + org.springframework.boot.resttestclient.autoconfigure.RestTestClientTestAutoConfigurationTests$TestLocalTestWebServerProvider """) void shouldDefineRestTestClientBoundToWebServer() { this.contextRunner.run((context) -> { diff --git a/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateAutoConfigurationTests.java b/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateTestAutoConfigurationTests.java similarity index 90% rename from module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateAutoConfigurationTests.java rename to module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateTestAutoConfigurationTests.java index 378b0ed781e..1951b5c0551 100644 --- a/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateAutoConfigurationTests.java +++ b/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/resttestclient/autoconfigure/TestRestTemplateTestAutoConfigurationTests.java @@ -31,14 +31,14 @@ import org.springframework.boot.testsupport.classpath.resources.WithResource; import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link TestRestTemplateAutoConfiguration}. + * Tests for {@link TestRestTemplateTestAutoConfiguration}. * * @author Stephane Nicoll */ -class TestRestTemplateAutoConfigurationTests { +class TestRestTemplateTestAutoConfigurationTests { private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(TestRestTemplateAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(TestRestTemplateTestAutoConfiguration.class)); @Test void shouldFailTotRegisterTestRestTemplateWithoutWebServer() { @@ -51,7 +51,7 @@ class TestRestTemplateAutoConfigurationTests { @WithResource(name = "META-INF/spring.factories", content = """ org.springframework.boot.test.http.server.LocalTestWebServer$Provider=\ - org.springframework.boot.resttestclient.autoconfigure.TestRestTemplateAutoConfigurationTests$TestLocalTestWebServerProvider + org.springframework.boot.resttestclient.autoconfigure.TestRestTemplateTestAutoConfigurationTests$TestLocalTestWebServerProvider """) void shouldDefineTestRestTemplateBoundToWebServer() { this.contextRunner.run((context) -> {