diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/BaseUrlUriBuilderFactory.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/BaseUrlUriBuilderFactory.java similarity index 97% rename from core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/BaseUrlUriBuilderFactory.java rename to core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/BaseUrlUriBuilderFactory.java index 663f9885502..1a1efc8d224 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/BaseUrlUriBuilderFactory.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/BaseUrlUriBuilderFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.web.servlet.client; +package org.springframework.boot.test.http.client; import java.net.URI; import java.util.Map; diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizer.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizer.java deleted file mode 100644 index 931b974b344..00000000000 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizer.java +++ /dev/null @@ -1,181 +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.web.servlet.client; - -import java.util.ArrayList; -import java.util.List; - -import org.jspecify.annotations.Nullable; - -import org.springframework.aot.AotDetector; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.BeanFactoryUtils; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; -import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.http.server.BaseUrl; -import org.springframework.boot.test.http.server.BaseUrlProviders; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.ConfigurationClassPostProcessor; -import org.springframework.core.Ordered; -import org.springframework.core.io.support.SpringFactoriesLoader; -import org.springframework.core.io.support.SpringFactoriesLoader.ArgumentResolver; -import org.springframework.test.context.ContextCustomizer; -import org.springframework.test.context.MergedContextConfiguration; -import org.springframework.test.context.TestContextAnnotationUtils; -import org.springframework.test.web.servlet.client.RestTestClient; -import org.springframework.util.Assert; - -/** - * {@link ContextCustomizer} for {@link RestTestClient}. - * - * @author Stephane Nicoll - * @author Phillip Webb - */ -class RestTestClientContextCustomizer implements ContextCustomizer { - - @Override - public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) { - if (AotDetector.useGeneratedArtifacts()) { - return; - } - SpringBootTest springBootTest = TestContextAnnotationUtils.findMergedAnnotation(mergedConfig.getTestClass(), - SpringBootTest.class); - Assert.state(springBootTest != null, "'springBootTest' must not be null"); - if (springBootTest.webEnvironment().isEmbedded()) { - registerRestTestClient(context); - } - } - - private void registerRestTestClient(ConfigurableApplicationContext context) { - ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); - if (beanFactory instanceof BeanDefinitionRegistry registry) { - registerRestTestClient(registry); - } - } - - private void registerRestTestClient(BeanDefinitionRegistry registry) { - RootBeanDefinition definition = new RootBeanDefinition(RestTestClientRegistrar.class); - definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); - registry.registerBeanDefinition(RestTestClientRegistrar.class.getName(), definition); - } - - @Override - public boolean equals(@Nullable Object obj) { - return (obj != null) && (obj.getClass() == getClass()); - } - - @Override - public int hashCode() { - return getClass().hashCode(); - } - - /** - * {@link BeanDefinitionRegistryPostProcessor} that runs after the - * {@link ConfigurationClassPostProcessor} and add a {@link RestTestClientFactory} - * bean definition when a {@link RestTestClient} hasn't already been registered. - */ - static class RestTestClientRegistrar implements BeanDefinitionRegistryPostProcessor, Ordered, BeanFactoryAware { - - private @Nullable BeanFactory beanFactory; - - @Override - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.beanFactory = beanFactory; - } - - @Override - public int getOrder() { - return Ordered.LOWEST_PRECEDENCE; - } - - @Override - public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { - if (this.beanFactory == null || AotDetector.useGeneratedArtifacts()) { - return; - } - if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) this.beanFactory, - RestTestClient.class, false, false).length == 0) { - registry.registerBeanDefinition(RestTestClient.class.getName(), - new RootBeanDefinition(RestTestClientFactory.class)); - } - - } - - } - - /** - * {@link FactoryBean} used to create and configure a {@link RestTestClient}. - */ - public static class RestTestClientFactory implements FactoryBean, ApplicationContextAware { - - private @Nullable ApplicationContext applicationContext; - - private @Nullable RestTestClient object; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - - @Override - public Class getObjectType() { - return RestTestClient.class; - } - - @Override - public RestTestClient getObject() { - if (this.object == null) { - this.object = createRestTestClient(); - } - return this.object; - } - - private RestTestClient createRestTestClient() { - Assert.state(this.applicationContext != null, "ApplicationContext not injected"); - RestTestClient.Builder builder = RestTestClient.bindToServer(); - customizeRestTestClientBuilder(builder); - BaseUrl baseUrl = new BaseUrlProviders(this.applicationContext).getBaseUrl(); - return builder.uriBuilderFactory(BaseUrlUriBuilderFactory.get(baseUrl)).build(); - } - - private void customizeRestTestClientBuilder(RestTestClient.Builder clientBuilder) { - Assert.state(this.applicationContext != null, "ApplicationContext not injected"); - getRestTestClientBuilderCustomizers(this.applicationContext) - .forEach((customizer) -> customizer.customize(clientBuilder)); - } - - private List getRestTestClientBuilderCustomizers(ApplicationContext context) { - List customizers = new ArrayList<>(); - customizers.addAll(SpringFactoriesLoader.forDefaultResourceLocation(context.getClassLoader()) - .load(RestTestClientBuilderCustomizer.class, ArgumentResolver.of(ApplicationContext.class, context))); - customizers.addAll(context.getBeansOfType(RestTestClientBuilderCustomizer.class).values()); - return customizers; - } - - } - -} diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerFactory.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerFactory.java deleted file mode 100644 index ab89be4980e..00000000000 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerFactory.java +++ /dev/null @@ -1,52 +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.web.servlet.client; - -import java.util.List; - -import org.jspecify.annotations.Nullable; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ContextConfigurationAttributes; -import org.springframework.test.context.ContextCustomizer; -import org.springframework.test.context.ContextCustomizerFactory; -import org.springframework.test.context.TestContextAnnotationUtils; -import org.springframework.util.ClassUtils; - -/** - * {@link ContextCustomizerFactory} for {@code RestTestClient}. - * - * @author Stephane Nicoll - */ -class RestTestClientContextCustomizerFactory implements ContextCustomizerFactory { - - private static final boolean restClientPresent; - - static { - ClassLoader loader = RestTestClientContextCustomizerFactory.class.getClassLoader(); - restClientPresent = ClassUtils.isPresent("org.springframework.web.client.RestClient", loader); - } - - @Override - public @Nullable ContextCustomizer createContextCustomizer(Class testClass, - List configAttributes) { - SpringBootTest springBootTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, - SpringBootTest.class); - return (springBootTest != null && restClientPresent) ? new RestTestClientContextCustomizer() : null; - } - -} 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 58c6ded1dbe..8a9b2c7d141 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 @@ -5,8 +5,7 @@ org.springframework.boot.test.context.PropertyMappingContextCustomizerFactory,\ org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizerFactory,\ org.springframework.boot.test.context.filter.annotation.TypeExcludeFiltersContextCustomizerFactory,\ org.springframework.boot.test.http.client.DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory,\ -org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory,\ -org.springframework.boot.test.web.servlet.client.RestTestClientContextCustomizerFactory +org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory # Application Context Initializers org.springframework.context.ApplicationContextInitializer=\ diff --git a/core/spring-boot-test/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerTests.java b/core/spring-boot-test/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerTests.java deleted file mode 100644 index b3d9204e8a5..00000000000 --- a/core/spring-boot-test/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerTests.java +++ /dev/null @@ -1,92 +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.web.servlet.client; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.test.web.servlet.client.RestTestClientContextCustomizer.RestTestClientRegistrar; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.test.context.MergedContextConfiguration; -import org.springframework.test.web.servlet.client.RestTestClient; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - -/** - * Tests for {@link RestTestClientContextCustomizer}. - * - * @author Moritz Halbritter - */ -class RestTestClientContextCustomizerTests { - - @Test - void whenContextIsNotABeanDefinitionRegistryRestTestClientIsRegistered() { - new ApplicationContextRunner(TestApplicationContext::new) - .withInitializer(this::applyRestTestClientContextCustomizer) - .run((context) -> assertThat(context).hasSingleBean(RestTestClient.class)); - } - - @Test - void whenUsingAotGeneratedArtifactsRestTestClientIsNotRegistered() { - new ApplicationContextRunner().withSystemProperties("spring.aot.enabled:true") - .withInitializer(this::applyRestTestClientContextCustomizer) - .run((context) -> { - assertThat(context).doesNotHaveBean(RestTestClientRegistrar.class); - assertThat(context).doesNotHaveBean(RestTestClient.class); - }); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - void applyRestTestClientContextCustomizer(ConfigurableApplicationContext context) { - MergedContextConfiguration configuration = mock(MergedContextConfiguration.class); - given(configuration.getTestClass()).willReturn((Class) TestClass.class); - new RestTestClientContextCustomizer().customizeContext(context, configuration); - } - - @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) - static class TestClass { - - } - - static class TestApplicationContext extends AbstractApplicationContext { - - private final ConfigurableListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - - @Override - protected void refreshBeanFactory() { - } - - @Override - protected void closeBeanFactory() { - - } - - @Override - public ConfigurableListableBeanFactory getBeanFactory() { - return this.beanFactory; - } - - } - -} diff --git a/documentation/spring-boot-docs/build.gradle b/documentation/spring-boot-docs/build.gradle index 1a4f4624fc1..12ffdb60994 100644 --- a/documentation/spring-boot-docs/build.gradle +++ b/documentation/spring-boot-docs/build.gradle @@ -124,6 +124,7 @@ dependencies { implementation(project(path: ":module:spring-boot-reactor-netty")) implementation(project(path: ":module:spring-boot-restclient")) implementation(project(path: ":module:spring-boot-restclient-test")) + implementation(project(path: ":module:spring-boot-resttestclient")) implementation(project(path: ":module:spring-boot-security")) implementation(project(path: ":module:spring-boot-tomcat")) implementation(project(path: ":module:spring-boot-webclient")) @@ -133,6 +134,7 @@ dependencies { implementation(project(path: ":module:spring-boot-webmvc-test")) implementation(project(path: ":module:spring-boot-webservices")) implementation(project(path: ":module:spring-boot-webservices-test")) + implementation(project(path: ":module:spring-boot-webtestclient")) implementation("ch.qos.logback:logback-classic") implementation("com.redis:testcontainers-redis") implementation("com.zaxxer:HikariCP") diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.java index 9ba584cf2ce..e2c96ef270f 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.java @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringrestdocs.withwebtestclient; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer; +import org.springframework.boot.webtestclient.WebTestClientBuilderCustomizer; import org.springframework.context.annotation.Bean; import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java index 1bf58b9d808..d06aa53c2ee 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient; import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.servlet.MockMvc; @@ -33,6 +34,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest @AutoConfigureMockMvc +@AutoConfigureRestTestClient class MyMockMvcTests { @Test diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java index 6afdafa4e84..307d5da2e87 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.test.web.reactive.server.WebTestClient; @SpringBootTest diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortRestTestClientTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortRestTestClientTests.java index d551814b9ae..e1acf967ef5 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortRestTestClientTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortRestTestClientTests.java @@ -21,9 +21,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient; import org.springframework.test.web.servlet.client.RestTestClient; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@AutoConfigureRestTestClient class MyRandomPortRestTestClientTests { @Test diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.java index 87a21aa96a7..ce82ef43b13 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.java @@ -19,9 +19,9 @@ package org.springframework.boot.docs.testing.springbootapplications.withrunning import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; import static org.assertj.core.api.Assertions.assertThat; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java index dbbd71dd79d..d905ee93391 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java @@ -22,11 +22,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpHeaders; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java index 08c9871f982..0fdc81deda5 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java @@ -18,7 +18,7 @@ package org.springframework.boot.docs.testing.utilities.testresttemplate; import org.junit.jupiter.api.Test; -import org.springframework.boot.restclient.test.TestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.ResponseEntity; import static org.assertj.core.api.Assertions.assertThat; diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.kt index 30825160813..92c8f5de315 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringrestdocs.withwebtestclient import org.springframework.boot.test.context.TestConfiguration -import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer +import org.springframework.boot.webtestclient.WebTestClientBuilderCustomizer import org.springframework.context.annotation.Bean import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation import org.springframework.test.web.reactive.server.WebTestClient diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt index 18c92969fa1..4cf817fb706 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt @@ -20,6 +20,7 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.test.web.reactive.server.expectBody @@ -29,6 +30,7 @@ import org.springframework.test.web.servlet.client.expectBody @SpringBootTest @AutoConfigureMockMvc +@AutoConfigureRestTestClient class MyMockMvcTests { @Test diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt index decfb1ce537..02b4b5d4195 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.withmockenv import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.test.web.reactive.server.expectBody diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt index 4c9a48e10b9..90193af365c 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt @@ -19,9 +19,9 @@ package org.springframework.boot.docs.testing.springbootapplications.withrunning import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.restclient.test.TestRestTemplate import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.SpringBootTest.WebEnvironment +import org.springframework.boot.testrestclient.TestRestTemplate @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) class MyRandomPortTestRestTemplateTests { diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt index e06f1d204e8..e1ebfade889 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt @@ -23,8 +23,8 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.SpringBootTest.WebEnvironment import org.springframework.boot.test.context.TestConfiguration import org.springframework.boot.restclient.RestTemplateBuilder -import org.springframework.boot.restclient.test.TestRestTemplate -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate +import org.springframework.boot.testrestclient.TestRestTemplate +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate import org.springframework.context.annotation.Bean import java.time.Duration diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt index 7fc903dd0e9..40dd2760fee 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt @@ -18,7 +18,7 @@ package org.springframework.boot.docs.testing.utilities.testresttemplate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.springframework.boot.restclient.test.TestRestTemplate +import org.springframework.boot.testrestclient.TestRestTemplate class MyTests { diff --git a/integration-test/spring-boot-test-integration-tests/build.gradle b/integration-test/spring-boot-test-integration-tests/build.gradle index 81a8370369e..ebee6fad6e7 100644 --- a/integration-test/spring-boot-test-integration-tests/build.gradle +++ b/integration-test/spring-boot-test-integration-tests/build.gradle @@ -27,10 +27,15 @@ dependencies { testImplementation(project(":test-support:spring-boot-test-support")) testImplementation(project(":module:spring-boot-http-codec")) testImplementation(project(":module:spring-boot-restclient-test")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(project(":module:spring-boot-tomcat")) testImplementation(project(":module:spring-boot-webflux-test")) + testImplementation(project(":module:spring-boot-webmvc-test")) + testImplementation(project(":module:spring-boot-webtestclient")) testImplementation(project(":module:spring-boot-web-server")) testImplementation("io.projectreactor.netty:reactor-netty-http") testImplementation("org.springframework:spring-webmvc") testImplementation("org.springframework:spring-webflux") + + testRuntimeOnly("ch.qos.logback:logback-classic") } diff --git a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/scan/SimpleFactoryBean.java b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/scan/SimpleFactoryBean.java deleted file mode 100644 index 7ec174fa154..00000000000 --- a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/scan/SimpleFactoryBean.java +++ /dev/null @@ -1,58 +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.restclient.test.scan; - -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -/** - * A simple factory bean with no generics. Used to test early initialization doesn't - * occur. - * - * @author Madhura Bhave - */ -@Component -@SuppressWarnings("rawtypes") -public class SimpleFactoryBean implements FactoryBean { - - private static boolean isInitializedEarly = false; - - public SimpleFactoryBean() { - isInitializedEarly = true; - throw new RuntimeException(); - } - - @Autowired - public SimpleFactoryBean(ApplicationContext context) { - if (isInitializedEarly) { - throw new RuntimeException(); - } - } - - @Override - public Object getObject() { - return new Object(); - } - - @Override - public Class getObjectType() { - return Object.class; - } - -} diff --git a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/NoRestTestClientBeanChecker.java b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/NoRestTestClientBeanChecker.java deleted file mode 100644 index 23d1d2a0791..00000000000 --- a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/NoRestTestClientBeanChecker.java +++ /dev/null @@ -1,47 +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.web.servlet.client; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.BeanFactoryUtils; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.context.annotation.ImportSelector; -import org.springframework.core.type.AnnotationMetadata; -import org.springframework.test.web.servlet.client.RestTestClient; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * {@link ImportSelector} to check no {@link RestTestClient} definition is registered when - * config classes are processed. - */ -class NoRestTestClientBeanChecker implements ImportSelector, BeanFactoryAware { - - @Override - public void setBeanFactory(BeanFactory beanFactory) { - assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory, - RestTestClient.class)) - .isEmpty(); - } - - @Override - public String[] selectImports(AnnotationMetadata importingClassMetadata) { - return new String[0]; - } - -} diff --git a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerIntegrationTests.java b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerIntegrationTests.java deleted file mode 100644 index 0e51c2f4782..00000000000 --- a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerIntegrationTests.java +++ /dev/null @@ -1,74 +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.web.servlet.client; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.web.servlet.client.RestTestClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.then; -import static org.mockito.Mockito.mock; - -/** - * Integration test for {@link RestTestClientContextCustomizer}. - * - * @author Stephane Nicoll - */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DirtiesContext -class RestTestClientContextCustomizerIntegrationTests { - - @Autowired - private RestTestClient restClient; - - @Autowired - private RestTestClientBuilderCustomizer clientBuilderCustomizer; - - @Test - void test() { - then(this.clientBuilderCustomizer).should().customize(any(RestTestClient.Builder.class)); - this.restClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello"); - } - - @Configuration(proxyBeanMethods = false) - @Import({ TestWebMvcConfiguration.class, NoRestTestClientBeanChecker.class }) - @RestController - static class TestConfig { - - @GetMapping("/") - String root() { - return "hello"; - } - - @Bean - RestTestClientBuilderCustomizer clientBuilderCustomizer() { - return mock(RestTestClientBuilderCustomizer.class); - } - - } - -} diff --git a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithCustomContextPathIntegrationTests.java b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithCustomContextPathIntegrationTests.java deleted file mode 100644 index 6b75158c0f2..00000000000 --- a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithCustomContextPathIntegrationTests.java +++ /dev/null @@ -1,88 +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.web.servlet.client; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory; -import org.springframework.boot.web.server.servlet.ServletWebServerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.servlet.client.RestTestClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.DispatcherServlet; - -/** - * Integration test for {@link RestTestClientContextCustomizer} with a custom context - * path. - * - * @author Stephane Nicoll - */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(properties = "server.servlet.context-path=/test") -class RestTestClientContextCustomizerWithCustomContextPathIntegrationTests { - - @Autowired - private RestTestClient restClient; - - @Test - void test() { - this.restClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello"); - } - - @Configuration(proxyBeanMethods = false) - @Import(NoRestTestClientBeanChecker.class) - @RestController - static class TestConfig { - - @Value("${server.port:8080}") - private int port = 8080; - - @Bean - DispatcherServlet dispatcherServlet() { - return new DispatcherServlet(); - } - - @Bean - ServletWebServerFactory webServerFactory() { - TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); - factory.setPort(this.port); - factory.setContextPath("/test"); - return factory; - } - - @Bean - static PropertySourcesPlaceholderConfigurer propertyPlaceholder() { - return new PropertySourcesPlaceholderConfigurer(); - } - - @GetMapping("/") - String root() { - return "hello"; - } - - } - -} diff --git a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithOverridePathIntegrationTests.java b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithOverridePathIntegrationTests.java deleted file mode 100644 index 3fe41e511b4..00000000000 --- a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithOverridePathIntegrationTests.java +++ /dev/null @@ -1,71 +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.web.servlet.client; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.web.servlet.client.RestTestClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -/** - * Integration test for {@link RestTestClientContextCustomizer} with a custom client. - * - * @author Stephane Nicoll - */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class RestTestClientContextCustomizerWithOverridePathIntegrationTests { - - @Autowired - private RestTestClient restClient; - - @Test - void test() { - assertThat(this.restClient).isInstanceOf(CustomRestTestClient.class); - } - - @Configuration(proxyBeanMethods = false) - @Import({ TestWebMvcConfiguration.class, NoRestTestClientBeanChecker.class }) - @RestController - static class TestConfig { - - @GetMapping("/") - String root() { - return "hello"; - } - - @Bean - CustomRestTestClient customRestTestClient() { - return mock(CustomRestTestClient.class); - } - - } - - interface CustomRestTestClient extends RestTestClient { - - } - -} diff --git a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/TestWebMvcConfiguration.java b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/TestWebMvcConfiguration.java deleted file mode 100644 index a83d752b289..00000000000 --- a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/TestWebMvcConfiguration.java +++ /dev/null @@ -1,52 +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.web.servlet.client; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory; -import org.springframework.boot.web.server.servlet.ServletWebServerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.web.servlet.DispatcherServlet; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; - -@Configuration(proxyBeanMethods = false) -@EnableWebMvc -class TestWebMvcConfiguration { - - @Value("${server.port:8080}") - private int port = 8080; - - @Bean - DispatcherServlet dispatcherServlet() { - return new DispatcherServlet(); - } - - @Bean - ServletWebServerFactory webServerFactory() { - TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); - factory.setPort(this.port); - return factory; - } - - @Bean - static PropertySourcesPlaceholderConfigurer propertyPlaceholder() { - return new PropertySourcesPlaceholderConfigurer(); - } - -} diff --git a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests.java b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests.java index 8456d1f8193..6a3f5502de3 100644 --- a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests.java +++ b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests.java @@ -23,14 +23,14 @@ import reactor.core.publisher.Mono; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.tomcat.reactive.TomcatReactiveWebServerFactory; import org.springframework.boot.web.context.reactive.ReactiveWebApplicationContext; import org.springframework.boot.web.server.reactive.ReactiveWebServerFactory; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestWebServerWebEnvironmentTests.java b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestWebServerWebEnvironmentTests.java index 04775f71b76..4e1126ba6d9 100644 --- a/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestWebServerWebEnvironmentTests.java +++ b/integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestWebServerWebEnvironmentTests.java @@ -21,15 +21,17 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory; import org.springframework.boot.web.server.servlet.ServletWebServerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.test.web.servlet.client.RestTestClient; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.client.RestTemplate; import org.springframework.web.context.WebApplicationContext; @@ -45,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb * @author Andy Wilkinson */ +@AutoConfigureRestTestClient @AutoConfigureTestRestTemplate abstract class AbstractSpringBootTestWebServerWebEnvironmentTests { @@ -63,6 +66,9 @@ abstract class AbstractSpringBootTestWebServerWebEnvironmentTests { @Autowired private TestRestTemplate restTemplate; + @Autowired + private RestTestClient restClient; + WebApplicationContext getContext() { return this.context; } @@ -84,6 +90,11 @@ abstract class AbstractSpringBootTestWebServerWebEnvironmentTests { assertThat(body).isEqualTo("Hello World"); } + @Test + void injectRestTestClient() { + this.restClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("Hello World"); + } + @Test void annotationAttributesOverridePropertiesFile() { assertThat(this.value).isEqualTo(123); diff --git a/module/spring-boot-devtools/build.gradle b/module/spring-boot-devtools/build.gradle index 12544996635..4b4e3cee45c 100644 --- a/module/spring-boot-devtools/build.gradle +++ b/module/spring-boot-devtools/build.gradle @@ -55,7 +55,7 @@ dependencies { intTestImplementation(project(":core:spring-boot-autoconfigure")) intTestImplementation(project(":core:spring-boot-test")) intTestImplementation(project(":module:spring-boot-restclient")) - intTestImplementation(project(":module:spring-boot-restclient-test")) + intTestImplementation(project(":module:spring-boot-resttestclient")) intTestImplementation(project(":test-support:spring-boot-test-support")) intTestImplementation("org.apache.httpcomponents.client5:httpclient5") intTestImplementation("net.bytebuddy:byte-buddy") diff --git a/module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java b/module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java index e69dae1916a..443a94657e5 100644 --- a/module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java +++ b/module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java @@ -26,7 +26,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; diff --git a/module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsWithLazyInitializationIntegrationTests.java b/module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsWithLazyInitializationIntegrationTests.java index 312a5fcad8e..a9350738390 100644 --- a/module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsWithLazyInitializationIntegrationTests.java +++ b/module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsWithLazyInitializationIntegrationTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.devtools.tests; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.springframework.boot.restclient.test.TestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.HttpStatus; import static org.assertj.core.api.Assertions.assertThat; diff --git a/module/spring-boot-graphql-test/build.gradle b/module/spring-boot-graphql-test/build.gradle index b6b2e0e31b9..e0d05d08f1e 100644 --- a/module/spring-boot-graphql-test/build.gradle +++ b/module/spring-boot-graphql-test/build.gradle @@ -33,8 +33,8 @@ dependencies { optional(project(":core:spring-boot-autoconfigure")) optional(project(":module:spring-boot-validation")) optional(project(":module:spring-boot-webclient")) - optional(project(":module:spring-boot-webflux-test")) optional(project(":module:spring-boot-webmvc-test")) + optional(project(":module:spring-boot-webtestclient")) optional(project(":module:spring-boot-web-server")) optional("jakarta.servlet:jakarta.servlet-api") optional("org.junit.jupiter:junit-jupiter-api") diff --git a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureHttpGraphQlTester.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureHttpGraphQlTester.java index 00eb69b6fbc..57290ec69bb 100644 --- a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureHttpGraphQlTester.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureHttpGraphQlTester.java @@ -24,8 +24,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.graphql.test.tester.HttpGraphQlTester; /** diff --git a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/HttpGraphQlTesterAutoConfiguration.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/HttpGraphQlTesterAutoConfiguration.java index a80425904fd..544a6e0810b 100644 --- a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/HttpGraphQlTesterAutoConfiguration.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/HttpGraphQlTesterAutoConfiguration.java @@ -33,7 +33,7 @@ import org.springframework.web.reactive.function.client.WebClient; * @author Brian Clozel * @since 4.0.0 */ -@AutoConfiguration(afterName = { "org.springframework.boot.webflux.test.autoconfigure.WebTestClientAutoConfiguration", +@AutoConfiguration(afterName = { "org.springframework.boot.webtestclient.WebTestClientAutoConfiguration", "org.springframework.boot.webmvc.test.autoconfigure.MockMvcAutoConfiguration" }) @ConditionalOnClass({ WebClient.class, WebTestClient.class, WebGraphQlTester.class }) public final class HttpGraphQlTesterAutoConfiguration { diff --git a/module/spring-boot-http-codec/src/main/java/org/springframework/boot/http/codec/CodecWebTestClientBuilderCustomizer.java b/module/spring-boot-http-codec/src/main/java/org/springframework/boot/http/codec/CodecWebTestClientBuilderCustomizer.java deleted file mode 100644 index 1d946ef79de..00000000000 --- a/module/spring-boot-http-codec/src/main/java/org/springframework/boot/http/codec/CodecWebTestClientBuilderCustomizer.java +++ /dev/null @@ -1,55 +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.http.codec; - -import java.util.Collection; -import java.util.function.Consumer; - -import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer; -import org.springframework.context.ApplicationContext; -import org.springframework.http.codec.ClientCodecConfigurer; -import org.springframework.test.web.reactive.server.WebTestClient.Builder; -import org.springframework.util.CollectionUtils; -import org.springframework.web.reactive.function.client.ExchangeStrategies; - -/** - * {@link WebTestClientBuilderCustomizer} to apply {@link CodecCustomizer} beans. - * - * @author Phillip Webb - */ -class CodecWebTestClientBuilderCustomizer implements WebTestClientBuilderCustomizer { - - private final ApplicationContext context; - - CodecWebTestClientBuilderCustomizer(ApplicationContext context) { - this.context = context; - } - - @Override - public void customize(Builder builder) { - Collection customizers = this.context.getBeansOfType(CodecCustomizer.class).values(); - if (!CollectionUtils.isEmpty(customizers)) { - ExchangeStrategies strategies = ExchangeStrategies.builder().codecs(apply(customizers)).build(); - builder.exchangeStrategies(strategies); - } - } - - private Consumer apply(Collection customizers) { - return (codecs) -> customizers.forEach((customizer) -> customizer.customize(codecs)); - } - -} diff --git a/module/spring-boot-http-codec/src/main/resources/META-INF/spring.factories b/module/spring-boot-http-codec/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 48faac4bcbd..00000000000 --- a/module/spring-boot-http-codec/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# WebTestClient Builder Customizers -org.springframework.boot.test.web.reactive.server.WebTestClientBuilderCustomizer=\ -org.springframework.boot.http.codec.CodecWebTestClientBuilderCustomizer diff --git a/module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/ClientHttpMessageConvertersCustomizer.java b/module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/ClientHttpMessageConvertersCustomizer.java index b46b121cbb3..9abcecdf215 100644 --- a/module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/ClientHttpMessageConvertersCustomizer.java +++ b/module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/ClientHttpMessageConvertersCustomizer.java @@ -30,7 +30,8 @@ import org.springframework.http.converter.HttpMessageConverters.ClientBuilder; public interface ClientHttpMessageConvertersCustomizer { /** - * Callback to customize a {@link HttpMessageConverters.ClientBuilder} instance. + * Callback to customize a {@link ClientBuilder HttpMessageConverters.ClientBuilder} + * instance. * @param builder the builder to customize */ void customize(ClientBuilder builder); diff --git a/module/spring-boot-mustache/build.gradle b/module/spring-boot-mustache/build.gradle index 32730a38abd..62b0ecb8af9 100644 --- a/module/spring-boot-mustache/build.gradle +++ b/module/spring-boot-mustache/build.gradle @@ -38,7 +38,7 @@ dependencies { testImplementation(project(":module:spring-boot-reactor-netty")) testImplementation(project(":module:spring-boot-restclient")) testImplementation(project(":module:spring-boot-reactor-netty")) - testImplementation(project(":module:spring-boot-restclient-test")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(project(":module:spring-boot-tomcat")) testImplementation(project(":module:spring-boot-webflux-test")) testImplementation(project(":module:spring-boot-webmvc-test")) diff --git a/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationReactiveIntegrationTests.java b/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationReactiveIntegrationTests.java index 481af352ca5..f40613ed114 100644 --- a/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationReactiveIntegrationTests.java +++ b/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationReactiveIntegrationTests.java @@ -31,7 +31,7 @@ import org.springframework.boot.mustache.reactive.view.MustacheViewResolver; import org.springframework.boot.reactor.netty.autoconfigure.NettyReactiveWebServerAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationServletIntegrationTests.java b/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationServletIntegrationTests.java index 4edcd9b165b..feab12b70a9 100644 --- a/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationServletIntegrationTests.java +++ b/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationServletIntegrationTests.java @@ -30,9 +30,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.mustache.servlet.view.MustacheView; import org.springframework.boot.mustache.servlet.view.MustacheViewResolver; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/module/spring-boot-restclient-test/build.gradle b/module/spring-boot-restclient-test/build.gradle index 496841603df..77e71c54e80 100644 --- a/module/spring-boot-restclient-test/build.gradle +++ b/module/spring-boot-restclient-test/build.gradle @@ -15,9 +15,7 @@ */ plugins { - id "dev.adamko.dokkatoo-html" id "java-library" - id "org.jetbrains.kotlin.jvm" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" id "org.springframework.boot.test-slice" @@ -33,8 +31,6 @@ dependencies { optional(project(":module:spring-boot-jackson")) optional(project(":module:spring-boot-restclient")) optional("org.apache.httpcomponents.client5:httpclient5") - optional("org.jetbrains.kotlin:kotlin-stdlib") - optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.junit.jupiter:junit-jupiter-api") optional("org.springframework:spring-test") 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/AutoConfigureRestClient.java similarity index 62% rename from module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClient.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureRestClient.java index 5377cd319df..2c2a4b74030 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/AutoConfigureRestClient.java @@ -25,32 +25,20 @@ import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; -import org.springframework.boot.test.context.PropertyMapping; -import org.springframework.web.client.RestTemplate; +import org.springframework.web.client.RestClient.Builder; /** - * Annotation that can be applied to a test class to enable and configure - * auto-configuration of web clients. + * Annotation that can be applied to a test class to enable auto-configuration of a + * {@link Builder RestClient.Builder} and a {@link RestTemplateBuilder}. * - * @author Stephane Nicoll - * @author Phillip Webb + * @author Andy Wilkinson * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited -@AutoConfigureJson @ImportAutoConfiguration -@PropertyMapping("spring.test.webclient") -public @interface AutoConfigureWebClient { - - /** - * If a {@link RestTemplate} bean should be registered. Defaults to {@code false} with - * the assumption that the {@link RestTemplateBuilder} will be used. - * @return if a {@link RestTemplate} bean should be added. - */ - boolean registerRestTemplate() default false; +public @interface AutoConfigureRestClient { } diff --git a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTest.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTest.java index 39f2bcc6a0e..bf73c303a47 100644 --- a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTest.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTest.java @@ -37,7 +37,6 @@ import org.springframework.test.context.BootstrapWith; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestClient.Builder; -import org.springframework.web.client.RestTemplate; /** * Annotation for a Spring rest client test that focuses only on beans @@ -59,10 +58,6 @@ import org.springframework.web.client.RestTemplate; * {@link AutoConfigureMockRestServiceServer @AutoConfigureMockRestServiceServer} * annotation can be used. *

- * If you are testing a bean that doesn't use {@link RestTemplateBuilder} but instead - * injects a {@link RestTemplate} directly, you can add - * {@code @AutoConfigureWebClient(registerRestTemplate=true)}. - *

* When using JUnit 4, this annotation should be used in combination with * {@code @RunWith(SpringRunner.class)}. * @@ -79,8 +74,8 @@ import org.springframework.web.client.RestTemplate; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(RestClientTypeExcludeFilter.class) -@AutoConfigureWebClient @AutoConfigureMockRestServiceServer +@AutoConfigureRestClient @ImportAutoConfiguration public @interface RestClientTest { diff --git a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/WebClientRestTemplateAutoConfiguration.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/WebClientRestTemplateAutoConfiguration.java deleted file mode 100644 index e7f4665ae21..00000000000 --- a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/WebClientRestTemplateAutoConfiguration.java +++ /dev/null @@ -1,44 +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.restclient.test.autoconfigure; - -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.web.client.RestTemplate; - -/** - * Auto-configuration for a web-client {@link RestTemplate}. Used when - * {@link AutoConfigureWebClient#registerRestTemplate()} is {@code true}. - * - * @author Phillip Webb - * @since 4.0.0 - * @see AutoConfigureMockRestServiceServer - */ -@AutoConfiguration(afterName = "org.springframework.boot.restclient.autoconfigure.RestTemplateAutoConfiguration") -@ConditionalOnBooleanProperty("spring.test.webclient.register-rest-template") -@ConditionalOnClass(RestTemplateBuilder.class) -public final class WebClientRestTemplateAutoConfiguration { - - @Bean - RestTemplate restTemplate(RestTemplateBuilder builder) { - return builder.build(); - } - -} diff --git a/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureRestClient.imports b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureRestClient.imports new file mode 100644 index 00000000000..4a805dea506 --- /dev/null +++ b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureRestClient.imports @@ -0,0 +1,3 @@ +org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration +org.springframework.boot.restclient.autoconfigure.RestClientAutoConfiguration +org.springframework.boot.restclient.autoconfigure.RestTemplateAutoConfiguration diff --git a/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate.imports b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate.imports deleted file mode 100644 index a8511314095..00000000000 --- a/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate.imports +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.restclient.test.autoconfigure.TestRestTemplateAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureWebClient.imports b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureWebClient.imports deleted file mode 100644 index 165c5e9b42f..00000000000 --- a/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureWebClient.imports +++ /dev/null @@ -1,6 +0,0 @@ -org.springframework.boot.restclient.test.autoconfigure.WebClientRestTemplateAutoConfiguration -optional:org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration -optional:org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration -optional:org.springframework.boot.restclient.autoconfigure.RestClientAutoConfiguration -optional:org.springframework.boot.restclient.autoconfigure.RestTemplateAutoConfiguration -optional:org.springframework.boot.webclient.WebClientAutoConfiguration diff --git a/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClientWithRestTemplateIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClientWithRestTemplateIntegrationTests.java deleted file mode 100644 index e896e0db503..00000000000 --- a/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClientWithRestTemplateIntegrationTests.java +++ /dev/null @@ -1,64 +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.restclient.test.autoconfigure; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.test.web.client.MockRestServiceServer; -import org.springframework.web.client.RestTemplate; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; - -/** - * Tests for {@link AutoConfigureWebClient @AutoConfigureWebClient} with - * {@code registerRestTemplate=true}. - * - * @author Phillip Webb - */ -@SpringBootTest -@AutoConfigureWebClient(registerRestTemplate = true) -@AutoConfigureMockRestServiceServer -class AutoConfigureWebClientWithRestTemplateIntegrationTests { - - @Autowired - private RestTemplate restTemplate; - - @Autowired - private MockRestServiceServer server; - - @Test - void restTemplateTest() { - this.server.expect(requestTo("/test")).andRespond(withSuccess("hello", MediaType.TEXT_HTML)); - ResponseEntity entity = this.restTemplate.getForEntity("/test", String.class); - assertThat(entity.getBody()).isEqualTo("hello"); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - static class Config { - - } - -} diff --git a/module/spring-boot-restclient/src/main/java/org/springframework/boot/restclient/autoconfigure/package-info.java b/module/spring-boot-restclient/src/main/java/org/springframework/boot/restclient/autoconfigure/package-info.java index df2c8997689..eeaf83c61e8 100644 --- a/module/spring-boot-restclient/src/main/java/org/springframework/boot/restclient/autoconfigure/package-info.java +++ b/module/spring-boot-restclient/src/main/java/org/springframework/boot/restclient/autoconfigure/package-info.java @@ -15,7 +15,7 @@ */ /** - * Auto-configuration for RestClient and RestTemplate. + * Auto-configuration for RestClient. */ @NullMarked package org.springframework.boot.restclient.autoconfigure; diff --git a/module/spring-boot-restdocs/build.gradle b/module/spring-boot-restdocs/build.gradle index ab3ac77f591..d054be93e75 100644 --- a/module/spring-boot-restdocs/build.gradle +++ b/module/spring-boot-restdocs/build.gradle @@ -29,13 +29,13 @@ dependencies { optional(project(":core:spring-boot-autoconfigure")) optional(project(":core:spring-boot-test-autoconfigure")) + optional(project(":module:spring-boot-webflux-test")) optional(project(":module:spring-boot-webmvc-test")) optional("org.springframework.restdocs:spring-restdocs-mockmvc") optional("org.springframework.restdocs:spring-restdocs-restassured") optional("org.springframework.restdocs:spring-restdocs-webtestclient") testImplementation(project(":test-support:spring-boot-test-support")) - testImplementation(project(":module:spring-boot-webflux-test")) testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":module:spring-boot-hateoas")) testImplementation("org.springframework.security:spring-security-test") diff --git a/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsAutoConfiguration.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsAutoConfiguration.java index 6c4e76fcbcf..fabc84132aa 100644 --- a/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsAutoConfiguration.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsAutoConfiguration.java @@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.webtestclient.WebTestClientBuilderCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.restdocs.RestDocumentationContextProvider; @@ -103,7 +104,7 @@ public final class RestDocsAutoConfiguration { } @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(WebTestClientRestDocumentation.class) + @ConditionalOnClass({ WebTestClientRestDocumentation.class, WebTestClientBuilderCustomizer.class }) @ConditionalOnWebApplication(type = Type.REACTIVE) @EnableConfigurationProperties(RestDocsProperties.class) static class RestDocsWebTestClientConfiguration { diff --git a/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientBuilderCustomizer.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientBuilderCustomizer.java index e09e5263ff8..370c1fa7c32 100644 --- a/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientBuilderCustomizer.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientBuilderCustomizer.java @@ -18,7 +18,7 @@ package org.springframework.boot.restdocs.test.autoconfigure; import org.jspecify.annotations.Nullable; -import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer; +import org.springframework.boot.webtestclient.WebTestClientBuilderCustomizer; import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentationConfigurer; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.util.StringUtils; diff --git a/module/spring-boot-resttestclient/build.gradle b/module/spring-boot-resttestclient/build.gradle new file mode 100644 index 00000000000..9e6f4056f2b --- /dev/null +++ b/module/spring-boot-resttestclient/build.gradle @@ -0,0 +1,45 @@ +/* + * 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. + */ + +plugins { + id "dev.adamko.dokkatoo-html" + id "java-library" + id "org.jetbrains.kotlin.jvm" + id "org.springframework.boot.auto-configuration" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" +} + +description = "Spring Boot RestTestClient" + +dependencies { + api(project(":core:spring-boot-test")) + api(project(":module:spring-boot-http-converter")) + api(project(":module:spring-boot-restclient")) + api("org.springframework:spring-web") + + optional(project(":core:spring-boot-autoconfigure")) + optional("org.apache.httpcomponents.client5:httpclient5") + optional("org.jetbrains.kotlin:kotlin-stdlib") + optional("org.jetbrains.kotlin:kotlin-reflect") + + testImplementation(project(":core:spring-boot-test")) + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation("jakarta.servlet:jakarta.servlet-api") + testImplementation("org.springframework:spring-webmvc") + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplate.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/TestRestTemplate.java similarity index 99% rename from module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplate.java rename to module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/TestRestTemplate.java index fd2195bba92..8cc67069ca5 100644 --- a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplate.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/TestRestTemplate.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.restclient.test; +package org.springframework.boot.testrestclient; import java.net.URI; import java.security.KeyManagementException; diff --git a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/AutoConfigureRestTestClient.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/AutoConfigureRestTestClient.java new file mode 100644 index 00000000000..3be59de7cdd --- /dev/null +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/AutoConfigureRestTestClient.java @@ -0,0 +1,43 @@ +/* + * 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.testrestclient.autoconfigure; + +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; + +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.test.web.servlet.client.RestTestClient; + +/** + * Annotation that can be applied to a test class to enable a {@link RestTestClient}. + * + * @author Stephane Nicoll + * @since 4.0.0 + * @see RestTestClientAutoConfiguration + */ +@Target({ ElementType.TYPE, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@ImportAutoConfiguration +public @interface AutoConfigureRestTestClient { + +} diff --git a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureTestRestTemplate.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/AutoConfigureTestRestTemplate.java similarity index 90% rename from module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureTestRestTemplate.java rename to module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/AutoConfigureTestRestTemplate.java index 7daae032acf..2295a0bd6f0 100644 --- a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureTestRestTemplate.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/AutoConfigureTestRestTemplate.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.restclient.test.autoconfigure; +package org.springframework.boot.testrestclient.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.restclient.test.TestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate; /** * Annotation that can be applied to a test class to enable auto-configuration of a diff --git a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientAutoConfiguration.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientAutoConfiguration.java new file mode 100644 index 00000000000..5b2d50ab1b2 --- /dev/null +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientAutoConfiguration.java @@ -0,0 +1,85 @@ +/* + * 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.testrestclient.autoconfigure; + +import java.util.List; + +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.http.converter.autoconfigure.ClientHttpMessageConvertersCustomizer; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; +import org.springframework.boot.test.http.server.BaseUrl; +import org.springframework.boot.test.http.server.BaseUrlProviders; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.client.RestTestClient; +import org.springframework.web.client.RestClient; +import org.springframework.web.context.WebApplicationContext; + +/** + * Auto-configuration for {@link RestTestClient}. + * + * @author Stephane Nicoll + * @author Andy Wilkinson + * @author Phillip Webb + * @since 4.0.0 + */ +@AutoConfiguration +@ConditionalOnClass({ RestClient.class, RestTestClient.class, ClientHttpMessageConvertersCustomizer.class }) +public final class RestTestClientAutoConfiguration { + + @Bean + SpringBootRestTestClientBuilderCustomizer springBootRestTestClientBuilderCustomizer( + ObjectProvider httpMessageConverterCustomizers) { + return new SpringBootRestTestClientBuilderCustomizer(httpMessageConverterCustomizers.orderedStream().toList()); + } + + @Bean + @ConditionalOnMissingBean + RestTestClient restTestClient(WebApplicationContext applicationContext, + List customizers) { + RestTestClient.Builder builder = getBuilder(applicationContext); + customizers.forEach((customizer) -> customizer.customize(builder)); + return builder.build(); + } + + private RestTestClient.Builder getBuilder(WebApplicationContext applicationContext) { + BaseUrl baseUrl = new BaseUrlProviders(applicationContext).getBaseUrl(); + if (baseUrl != null) { + return RestTestClient.bindToServer().uriBuilderFactory(BaseUrlUriBuilderFactory.get(baseUrl)); + } + if (hasBean(applicationContext, MockMvc.class)) { + return RestTestClient.bindTo(applicationContext.getBean(MockMvc.class)); + } + return RestTestClient.bindToApplicationContext(applicationContext); + } + + private boolean hasBean(ApplicationContext applicationContext, Class type) { + try { + applicationContext.getBean(type); + return true; + } + catch (NoSuchBeanDefinitionException ex) { + return false; + } + } + +} diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientBuilderCustomizer.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientBuilderCustomizer.java similarity index 70% rename from core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientBuilderCustomizer.java rename to module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientBuilderCustomizer.java index 47915c284d7..fed2c5ad5c7 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientBuilderCustomizer.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientBuilderCustomizer.java @@ -14,16 +14,15 @@ * limitations under the License. */ -package org.springframework.boot.test.web.servlet.client; +package org.springframework.boot.testrestclient.autoconfigure; -import org.springframework.context.ApplicationContext; import org.springframework.test.web.servlet.client.RestTestClient; +import org.springframework.test.web.servlet.client.RestTestClient.Builder; /** - * A customizer that can be implemented by beans wishing to customize the - * {@link RestTestClient.Builder} to fine-tune its auto-configuration before a - * {@link RestTestClient} is created. Implementations can be registered in the - * {@link ApplicationContext} or {@code spring.factories}. + * A customizer that can be implemented by beans wishing to customize the {@link Builder + * RestTestClient.Builder} to fine-tune its auto-configuration before a + * {@link RestTestClient} is created. * * @author Stephane Nicoll * @since 4.0.0 @@ -32,7 +31,7 @@ import org.springframework.test.web.servlet.client.RestTestClient; public interface RestTestClientBuilderCustomizer { /** - * Customize the given {@link RestTestClient.Builder Builder}. + * Customize the given {@link Builder RestTestClient.Builder}. * @param builder the builder */ void customize(RestTestClient.Builder builder); diff --git a/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/SpringBootRestTestClientBuilderCustomizer.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/SpringBootRestTestClientBuilderCustomizer.java new file mode 100644 index 00000000000..6aed2c47fa1 --- /dev/null +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/SpringBootRestTestClientBuilderCustomizer.java @@ -0,0 +1,58 @@ +/* + * 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.testrestclient.autoconfigure; + +import java.util.Collection; + +import org.springframework.boot.http.converter.autoconfigure.ClientHttpMessageConvertersCustomizer; +import org.springframework.test.web.servlet.client.RestTestClient; + +/** + * {@link RestTestClientBuilderCustomizer} for a typical Spring Boot application. Usually + * applied automatically via + * {@link AutoConfigureRestTestClient @AutoConfigureRestTestClient}, but may also be used + * directly. + * + * @author Andy Wilkinson + * @since 4.0.0 + */ +public class SpringBootRestTestClientBuilderCustomizer implements RestTestClientBuilderCustomizer { + + private final Collection messageConverterCustomizers; + + /** + * Create a new {@code SpringBootRestTestClientBuilderCustomizer} that will configure + * the builder's message converters using the given + * {@code messageConverterCustomizers}. + * @param messageConverterCustomizers the message converter customizers + */ + public SpringBootRestTestClientBuilderCustomizer( + Collection messageConverterCustomizers) { + this.messageConverterCustomizers = messageConverterCustomizers; + + } + + @Override + public void customize(RestTestClient.Builder builder) { + if (this.messageConverterCustomizers.isEmpty()) { + return; + } + builder.configureMessageConverters((configurer) -> this.messageConverterCustomizers + .forEach((customizer) -> customizer.customize(configurer))); + } + +} diff --git a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/TestRestTemplateAutoConfiguration.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/TestRestTemplateAutoConfiguration.java similarity index 84% rename from module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/TestRestTemplateAutoConfiguration.java rename to module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/TestRestTemplateAutoConfiguration.java index 0e0e5438040..820af9a720d 100644 --- a/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/TestRestTemplateAutoConfiguration.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/TestRestTemplateAutoConfiguration.java @@ -14,17 +14,17 @@ * limitations under the License. */ -package org.springframework.boot.restclient.test.autoconfigure; +package org.springframework.boot.testrestclient.autoconfigure; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.TestRestTemplate.HttpClientOption; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; import org.springframework.boot.test.http.server.BaseUrl; import org.springframework.boot.test.http.server.BaseUrlProviders; -import org.springframework.boot.test.web.servlet.client.BaseUrlUriBuilderFactory; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate.HttpClientOption; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -41,7 +41,7 @@ public final class TestRestTemplateAutoConfiguration { private static final HttpClientOption[] SSL_OPTIONS = { HttpClientOption.SSL }; - @Bean(name = "org.springframework.boot.restclient.test.TestRestTemplate") + @Bean(name = "org.springframework.boot.testrestclient.TestRestTemplate") @ConditionalOnMissingBean TestRestTemplate testRestTemplate(ObjectProvider builderProvider, ApplicationContext applicationContext) { diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/package-info.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/package-info.java similarity index 77% rename from core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/package-info.java rename to module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/package-info.java index 3a49edcd998..e558950f787 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/package-info.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/autoconfigure/package-info.java @@ -15,10 +15,9 @@ */ /** - * Spring Boot support for testing Spring Servlet server endpoints via - * {@link org.springframework.test.web.servlet.client.RestTestClient}. + * Auto-configuration for RestTestClient and TestRestTemplate. */ @NullMarked -package org.springframework.boot.test.web.servlet.client; +package org.springframework.boot.testrestclient.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/client/package-info.java b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/package-info.java similarity index 77% rename from core/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/client/package-info.java rename to module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/package-info.java index 76a491a8095..eaca4cf33cc 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/client/package-info.java +++ b/module/spring-boot-resttestclient/src/main/java/org/springframework/boot/testrestclient/package-info.java @@ -15,10 +15,10 @@ */ /** - * Spring Boot support for testing Spring WebFlux server endpoints via - * {@link org.springframework.test.web.reactive.server.WebTestClient}. + * Test support classes that use {@link org.springframework.web.client.RestClient} and + * {@link org.springframework.web.client.RestTemplate}. */ @NullMarked -package org.springframework.boot.test.web.reactive.client; +package org.springframework.boot.testrestclient; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-restclient-test/src/main/kotlin/org/springframework/boot/restclient/test/TestRestTemplateExtensions.kt b/module/spring-boot-resttestclient/src/main/kotlin/org/springframework/boot/testrestclient/TestRestTemplateExtensions.kt similarity index 99% rename from module/spring-boot-restclient-test/src/main/kotlin/org/springframework/boot/restclient/test/TestRestTemplateExtensions.kt rename to module/spring-boot-resttestclient/src/main/kotlin/org/springframework/boot/testrestclient/TestRestTemplateExtensions.kt index 37a45a3fdcc..1e886c44291 100644 --- a/module/spring-boot-restclient-test/src/main/kotlin/org/springframework/boot/restclient/test/TestRestTemplateExtensions.kt +++ b/module/spring-boot-resttestclient/src/main/kotlin/org/springframework/boot/testrestclient/TestRestTemplateExtensions.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.restclient.test +package org.springframework.boot.testrestclient import org.springframework.core.ParameterizedTypeReference import org.springframework.http.HttpEntity diff --git a/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000000..e69de29bb2d diff --git a/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient.imports b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient.imports new file mode 100644 index 00000000000..008d61b6eab --- /dev/null +++ b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient.imports @@ -0,0 +1 @@ +org.springframework.boot.testrestclient.autoconfigure.RestTestClientAutoConfiguration diff --git a/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate.imports b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate.imports new file mode 100644 index 00000000000..7e9d92cb991 --- /dev/null +++ b/module/spring-boot-resttestclient/src/main/resources/META-INF/spring/org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate.imports @@ -0,0 +1 @@ +org.springframework.boot.testrestclient.autoconfigure.TestRestTemplateAutoConfiguration diff --git a/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateTests.java b/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateTests.java similarity index 98% rename from module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateTests.java rename to module/spring-boot-resttestclient/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateTests.java index b2669b6e0eb..4589436c8a9 100644 --- a/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateTests.java +++ b/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateTests.java @@ -36,9 +36,10 @@ import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; import org.springframework.boot.http.client.HttpRedirects; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate.HttpClientOption; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; import org.springframework.boot.test.http.server.BaseUrl; -import org.springframework.boot.test.web.servlet.client.BaseUrlUriBuilderFactory; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate.HttpClientOption; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; diff --git a/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientAutoConfigurationTests.java b/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientAutoConfigurationTests.java new file mode 100644 index 00000000000..37cf106b34f --- /dev/null +++ b/module/spring-boot-resttestclient/src/test/java/org/springframework/boot/testrestclient/autoconfigure/RestTestClientAutoConfigurationTests.java @@ -0,0 +1,108 @@ +/* + * 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.testrestclient.autoconfigure; + +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Test; + +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.test.context.FilteredClassLoader; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; +import org.springframework.boot.test.http.server.BaseUrl; +import org.springframework.boot.test.http.server.BaseUrlProvider; +import org.springframework.boot.testsupport.classpath.resources.WithResource; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.web.servlet.client.RestTestClient; +import org.springframework.web.client.RestClient; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.mock; + +/** + * Tests for {@link RestTestClientAutoConfiguration}. + * + * @author Andy Wilkinson + * @author Phillip Webb + */ +class RestTestClientAutoConfigurationTests { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(RestTestClientAutoConfiguration.class)); + + @Test + void registersRestTestClient() { + this.contextRunner.run((context) -> assertThat(context).hasSingleBean(RestTestClient.class)); + } + + @Test + void shouldNotRegisterRestTestClientIfRestClientIsMissing() { + this.contextRunner.withClassLoader(new FilteredClassLoader(RestClient.class)) + .run((context) -> assertThat(context).doesNotHaveBean(RestTestClient.class)); + } + + @Test + void shouldApplyRestTestClientCustomizers() { + this.contextRunner.withUserConfiguration(RestTestClientCustomConfig.class).run((context) -> { + assertThat(context).hasSingleBean(RestTestClient.class); + assertThat(context).hasBean("myRestTestClientCustomizer"); + then(context.getBean("myRestTestClientCustomizer", RestTestClientBuilderCustomizer.class)).should() + .customize(any(RestTestClient.Builder.class)); + }); + } + + @Test + @WithResource(name = "META-INF/spring.factories", + content = """ + org.springframework.boot.test.http.server.BaseUrlProvider=\ + org.springframework.boot.testrestclient.autoconfigure.RestTestClientAutoConfigurationTests.TestBaseUrlProvider + """) + void shouldDefineWebTestClientBoundToWebServer() { + this.contextRunner.run((context) -> { + assertThat(context).hasSingleBean(RestTestClient.class); + assertThat(context).hasBean("restTestClient"); + RestTestClient client = context.getBean(RestTestClient.class); + assertThat(client).extracting("restTestClientBuilder") + .extracting("restClientBuilder") + .extracting("uriBuilderFactory") + .isInstanceOf(BaseUrlUriBuilderFactory.class); + }); + } + + @Configuration(proxyBeanMethods = false) + static class RestTestClientCustomConfig { + + @Bean + RestTestClientBuilderCustomizer myRestTestClientCustomizer() { + return mock(RestTestClientBuilderCustomizer.class); + } + + } + + static class TestBaseUrlProvider implements BaseUrlProvider { + + @Override + public @Nullable BaseUrl getBaseUrl() { + return BaseUrl.of("https://localhost:8080"); + } + + } + +} diff --git a/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports b/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports similarity index 100% rename from module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports rename to module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports diff --git a/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports b/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports similarity index 50% rename from module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports rename to module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports index 8c05e4f3924..6eca008c3d5 100644 --- a/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports +++ b/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports @@ -1 +1 @@ -org.springframework.boot.security.oauth2.server.resource.autoconfigure.reactive.ReactiveOAuth2ResourceServerAutoconfiguration +org.springframework.boot.security.oauth2.server.resource.autoconfigure.reactive.ReactiveOAuth2ResourceServerAutoConfiguration diff --git a/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports b/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports similarity index 100% rename from module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports rename to module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports diff --git a/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webflux/WebTestClientSecurityIntegrationTests.java b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webflux/WebTestClientSecurityIntegrationTests.java index 5df865afe50..c470714c97d 100644 --- a/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webflux/WebTestClientSecurityIntegrationTests.java +++ b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webflux/WebTestClientSecurityIntegrationTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.webflux.test.autoconfigure.WebTestClientAutoConfiguration; +import org.springframework.boot.webtestclient.WebTestClientAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.util.ReflectionTestUtils; diff --git a/module/spring-boot-security/build.gradle b/module/spring-boot-security/build.gradle index 7adb336db0d..9ffec08b869 100644 --- a/module/spring-boot-security/build.gradle +++ b/module/spring-boot-security/build.gradle @@ -53,6 +53,7 @@ dependencies { testImplementation(project(":module:spring-boot-http-converter")) testImplementation(project(":module:spring-boot-jackson")) testImplementation(project(":module:spring-boot-restclient")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(project(":module:spring-boot-rsocket")) testImplementation(project(":module:spring-boot-tomcat")) testImplementation(project(":test-support:spring-boot-test-support")) diff --git a/module/spring-boot-security/src/test/java/org/springframework/boot/security/autoconfigure/servlet/SecurityFilterAutoConfigurationEarlyInitializationTests.java b/module/spring-boot-security/src/test/java/org/springframework/boot/security/autoconfigure/servlet/SecurityFilterAutoConfigurationEarlyInitializationTests.java index 6ad51800156..01c20ff70e3 100644 --- a/module/spring-boot-security/src/test/java/org/springframework/boot/security/autoconfigure/servlet/SecurityFilterAutoConfigurationEarlyInitializationTests.java +++ b/module/spring-boot-security/src/test/java/org/springframework/boot/security/autoconfigure/servlet/SecurityFilterAutoConfigurationEarlyInitializationTests.java @@ -31,10 +31,10 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.test.util.TestPropertyValues; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.boot.testsupport.classpath.ClassPathExclusions; import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories; import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory; diff --git a/module/spring-boot-webflux-test/build.gradle b/module/spring-boot-webflux-test/build.gradle index 1a429a904b1..03c1d3c614e 100644 --- a/module/spring-boot-webflux-test/build.gradle +++ b/module/spring-boot-webflux-test/build.gradle @@ -26,6 +26,7 @@ description = "Spring Boot WebFlux Test" dependencies { api(project(":core:spring-boot-test-autoconfigure")) api(project(":module:spring-boot-webflux")) + api(project(":module:spring-boot-webtestclient")) optional(project(":core:spring-boot-autoconfigure")) optional(project(":module:spring-boot-http-codec")) diff --git a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTest.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTest.java index 1720ee42285..95303628468 100644 --- a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTest.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTest.java @@ -31,6 +31,7 @@ import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.filter.annotation.TypeExcludeFilters; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; import org.springframework.core.annotation.AliasFor; diff --git a/module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports b/module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports deleted file mode 100644 index 4fe476f62fe..00000000000 --- a/module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.webflux.test.autoconfigure.WebTestClientAutoConfiguration diff --git a/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java deleted file mode 100644 index 67fc4284520..00000000000 --- a/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java +++ /dev/null @@ -1,114 +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.webflux.test.autoconfigure; - -import java.time.Duration; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.http.codec.CodecCustomizer; -import org.springframework.boot.test.context.FilteredClassLoader; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.codec.CodecConfigurer; -import org.springframework.test.web.reactive.server.WebTestClient; -import org.springframework.web.server.WebHandler; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.then; -import static org.mockito.Mockito.mock; - -/** - * Tests for {@link WebTestClientAutoConfiguration} - * - * @author Brian Clozel - * @author Stephane Nicoll - */ -class WebTestClientAutoConfigurationTests { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(WebTestClientAutoConfiguration.class)); - - @Test - void shouldNotBeConfiguredWithoutWebHandler() { - this.contextRunner.run((context) -> { - assertThat(context).hasNotFailed(); - assertThat(context).doesNotHaveBean(WebTestClient.class); - }); - } - - @Test - void shouldCustomizeClientCodecs() { - this.contextRunner.withUserConfiguration(CodecConfiguration.class).run((context) -> { - assertThat(context).hasSingleBean(WebTestClient.class); - assertThat(context).hasSingleBean(CodecCustomizer.class); - then(context.getBean(CodecCustomizer.class)).should().customize(any(CodecConfigurer.class)); - }); - } - - @Test - void shouldHaveConsistentDefaultTimeout() { - this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> { - WebTestClient webTestClient = context.getBean(WebTestClient.class); - assertThat(webTestClient).hasFieldOrPropertyWithValue("responseTimeout", Duration.ofSeconds(5)); - }); - } - - @Test - void shouldCustomizeTimeout() { - this.contextRunner.withUserConfiguration(BaseConfiguration.class) - .withPropertyValues("spring.test.webtestclient.timeout=15m") - .run((context) -> { - WebTestClient webTestClient = context.getBean(WebTestClient.class); - assertThat(webTestClient).hasFieldOrPropertyWithValue("responseTimeout", Duration.ofMinutes(15)); - }); - } - - @Test - void shouldBackOffWithoutCodecCustomizer() { - FilteredClassLoader classLoader = new FilteredClassLoader(CodecCustomizer.class); - this.contextRunner.withUserConfiguration(BaseConfiguration.class) - .withClassLoader(classLoader) - .run((context) -> assertThat(context).doesNotHaveBean(WebTestClient.class)); - } - - @Configuration(proxyBeanMethods = false) - static class BaseConfiguration { - - @Bean - WebHandler webHandler() { - return mock(WebHandler.class); - } - - } - - @Configuration(proxyBeanMethods = false) - @Import(BaseConfiguration.class) - static class CodecConfiguration { - - @Bean - CodecCustomizer myCodecCustomizer() { - return mock(CodecCustomizer.class); - } - - } - -} diff --git a/module/spring-boot-webmvc-test/build.gradle b/module/spring-boot-webmvc-test/build.gradle index b9d2dd7df86..bdde6299137 100644 --- a/module/spring-boot-webmvc-test/build.gradle +++ b/module/spring-boot-webmvc-test/build.gradle @@ -37,7 +37,6 @@ dependencies { optional(project(":core:spring-boot-test-autoconfigure")) optional(project(":module:spring-boot-jackson")) optional(project(":module:spring-boot-validation")) - optional(project(":module:spring-boot-webflux")) optional("org.junit.jupiter:junit-jupiter-api") optional("org.seleniumhq.selenium:htmlunit3-driver") { exclude(group: "com.sun.activation", module: "jakarta.activation") @@ -45,6 +44,7 @@ dependencies { optional("org.seleniumhq.selenium:selenium-api") testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testImplementation("jakarta.servlet:jakarta.servlet-api") testImplementation("org.junit.platform:junit-platform-engine") diff --git a/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java index b70016d4764..0704d376cd6 100644 --- a/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java @@ -16,29 +16,18 @@ package org.springframework.boot.webmvc.test.autoconfigure; -import java.util.List; - import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer; -import org.springframework.boot.test.web.servlet.client.RestTestClientBuilderCustomizer; import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.webmvc.autoconfigure.DispatcherServletPath; import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration; import org.springframework.boot.webmvc.autoconfigure.WebMvcProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.client.MockMvcWebTestClient; -import org.springframework.test.web.servlet.client.RestTestClient; -import org.springframework.web.client.RestClient; -import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.servlet.DispatcherServlet; /** @@ -69,36 +58,4 @@ public final class MockMvcAutoConfiguration { return mockMvc.getDispatcherServlet(); } - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass({ WebClient.class, WebTestClient.class }) - static class WebTestClientMockMvcConfiguration { - - @Bean - @ConditionalOnMissingBean - WebTestClient webTestClient(MockMvc mockMvc, List customizers) { - WebTestClient.Builder builder = MockMvcWebTestClient.bindTo(mockMvc); - for (WebTestClientBuilderCustomizer customizer : customizers) { - customizer.customize(builder); - } - return builder.build(); - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass({ RestClient.class, RestTestClient.class }) - static class RestTestClientMockMvcConfiguration { - - @Bean - @ConditionalOnMissingBean - RestTestClient restTestClient(MockMvc mockMvc, List customizers) { - RestTestClient.Builder builder = RestTestClient.bindTo(mockMvc); - for (RestTestClientBuilderCustomizer customizer : customizers) { - customizer.customize(builder); - } - return builder.build(); - } - - } - } diff --git a/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureRestTestClient.imports b/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureRestTestClient.imports new file mode 100644 index 00000000000..008d61b6eab --- /dev/null +++ b/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureRestTestClient.imports @@ -0,0 +1 @@ +org.springframework.boot.testrestclient.autoconfigure.RestTestClientAutoConfiguration diff --git a/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java index 7f697185748..801327f0d87 100644 --- a/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java @@ -21,17 +21,9 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer; -import org.springframework.boot.test.web.servlet.client.RestTestClientBuilderCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.RequestBuilder; import org.springframework.test.web.servlet.assertj.MockMvcTester; -import org.springframework.test.web.servlet.client.RestTestClient; -import org.springframework.web.client.RestClient; -import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.servlet.DispatcherServlet; import static org.assertj.core.api.Assertions.assertThat; @@ -82,66 +74,4 @@ class MockMvcAutoConfigurationTests { }); } - @Test - void registersWebTestClient() { - this.contextRunner.run((context) -> assertThat(context).hasSingleBean(WebTestClient.class)); - } - - @Test - void shouldNotRegisterWebTestClientIfWebFluxMissing() { - this.contextRunner.withClassLoader(new FilteredClassLoader(WebClient.class)) - .run((context) -> assertThat(context).doesNotHaveBean(WebTestClient.class)); - } - - @Test - void shouldApplyWebTestClientCustomizers() { - this.contextRunner.withUserConfiguration(WebTestClientCustomConfig.class).run((context) -> { - assertThat(context).hasSingleBean(WebTestClient.class); - assertThat(context).hasBean("myWebTestClientCustomizer"); - then(context.getBean("myWebTestClientCustomizer", WebTestClientBuilderCustomizer.class)).should() - .customize(any(WebTestClient.Builder.class)); - }); - } - - @Test - void registersRestTestClient() { - this.contextRunner.run((context) -> assertThat(context).hasSingleBean(RestTestClient.class)); - } - - @Test - void shouldNotRegisterRestTestClientIfRestClientIsMissing() { - this.contextRunner.withClassLoader(new FilteredClassLoader(RestClient.class)) - .run((context) -> assertThat(context).doesNotHaveBean(RestTestClient.class)); - } - - @Test - void shouldApplyRestTestClientCustomizers() { - this.contextRunner.withUserConfiguration(RestTestClientCustomConfig.class).run((context) -> { - assertThat(context).hasSingleBean(RestTestClient.class); - assertThat(context).hasBean("myRestTestClientCustomizer"); - then(context.getBean("myRestTestClientCustomizer", RestTestClientBuilderCustomizer.class)).should() - .customize(any(RestTestClient.Builder.class)); - }); - } - - @Configuration(proxyBeanMethods = false) - static class WebTestClientCustomConfig { - - @Bean - WebTestClientBuilderCustomizer myWebTestClientCustomizer() { - return mock(WebTestClientBuilderCustomizer.class); - } - - } - - @Configuration(proxyBeanMethods = false) - static class RestTestClientCustomConfig { - - @Bean - RestTestClientBuilderCustomizer myRestTestClientCustomizer() { - return mock(RestTestClientBuilderCustomizer.class); - } - - } - } diff --git a/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcSpringBootTestIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcSpringBootTestIntegrationTests.java index 2e0a6ded020..e373dd8be8d 100644 --- a/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcSpringBootTestIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcSpringBootTestIntegrationTests.java @@ -23,11 +23,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient; import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.webmvc.test.autoconfigure.MockMvcPrint; import org.springframework.context.ApplicationContext; import org.springframework.test.context.bean.override.mockito.MockitoBean; -import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.client.RestTestClient; @@ -47,6 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @SpringBootTest @AutoConfigureMockMvc(print = MockMvcPrint.SYSTEM_ERR, printOnlyOnFailure = false) +@AutoConfigureRestTestClient @ExtendWith(OutputCaptureExtension.class) class MockMvcSpringBootTestIntegrationTests { @@ -80,11 +81,6 @@ class MockMvcSpringBootTestIntegrationTests { assertThat(this.applicationContext.getBean(ExampleRealService.class)).isNotNull(); } - @Test - void shouldTestWithWebTestClient(@Autowired WebTestClient webTestClient) { - webTestClient.get().uri("/one").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("one"); - } - @Test void shouldTestWithRestTestClient(@Autowired RestTestClient restTestClient) { restTestClient.get().uri("/one").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("one"); diff --git a/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java index 5fccc3bb0f4..eccaee62250 100644 --- a/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java @@ -23,11 +23,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureRestTestClient; import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.webmvc.test.autoconfigure.MockMvcPrint; import org.springframework.context.ApplicationContext; import org.springframework.test.context.bean.override.mockito.MockitoBean; -import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.servlet.assertj.MockMvcTester; import org.springframework.test.web.servlet.client.RestTestClient; @@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @SpringBootTest @AutoConfigureMockMvc(print = MockMvcPrint.SYSTEM_ERR, printOnlyOnFailure = false) +@AutoConfigureRestTestClient @ExtendWith(OutputCaptureExtension.class) class MockMvcTesterSpringBootTestIntegrationTests { @@ -76,11 +77,6 @@ class MockMvcTesterSpringBootTestIntegrationTests { assertThat(this.applicationContext.getBean(ExampleRealService.class)).isNotNull(); } - @Test - void shouldTestWithWebTestClient(@Autowired WebTestClient webTestClient) { - webTestClient.get().uri("/one").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("one"); - } - @Test void shouldTestWithRestTestClient(@Autowired RestTestClient restTestClient) { restTestClient.get().uri("/one").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("one"); diff --git a/module/spring-boot-webmvc/build.gradle b/module/spring-boot-webmvc/build.gradle index 6d8f325ee29..4b2706d1da8 100644 --- a/module/spring-boot-webmvc/build.gradle +++ b/module/spring-boot-webmvc/build.gradle @@ -53,7 +53,7 @@ dependencies { testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-jackson")) testImplementation(project(":module:spring-boot-restclient")) - testImplementation(project(":module:spring-boot-restclient-test")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(project(":module:spring-boot-tomcat")) testImplementation(project(":test-support:spring-boot-test-support")) testImplementation(testFixtures(project(":module:spring-boot-actuator-autoconfigure"))) diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WelcomePageIntegrationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WelcomePageIntegrationTests.java index 4cc4c9f4452..54ee32a5162 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WelcomePageIntegrationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WelcomePageIntegrationTests.java @@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.boot.testsupport.classpath.resources.WithResource; import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; import org.springframework.boot.web.server.context.WebServerApplicationContext; diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java index 568d8a1f28e..0827583dc6e 100755 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java @@ -40,7 +40,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.restclient.test.TestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.error.ErrorAttributeOptions.Include; diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/RemappedErrorViewIntegrationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/RemappedErrorViewIntegrationTests.java index fc80a307213..526b228d465 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/RemappedErrorViewIntegrationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/RemappedErrorViewIntegrationTests.java @@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; import org.springframework.boot.web.error.ErrorPage; import org.springframework.boot.web.error.ErrorPageRegistrar; diff --git a/module/spring-boot-webtestclient/build.gradle b/module/spring-boot-webtestclient/build.gradle new file mode 100644 index 00000000000..105fd23f329 --- /dev/null +++ b/module/spring-boot-webtestclient/build.gradle @@ -0,0 +1,39 @@ +/* + * 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. + */ + +plugins { + id "java-library" + id "org.springframework.boot.auto-configuration" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" +} + +description = "Spring Boot WebTestClient" + +dependencies { + api(project(":core:spring-boot-test")) + api(project(":module:spring-boot-http-codec")) + api("org.springframework:spring-webflux") + + optional(project(":core:spring-boot-autoconfigure")) + + testImplementation(project(":core:spring-boot-test")) + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("jakarta.servlet:jakarta.servlet-api") + testRuntimeOnly("org.springframework:spring-webmvc") +} diff --git a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/AutoConfigureWebTestClient.java similarity index 81% rename from module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java rename to module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/AutoConfigureWebTestClient.java index f88f406ddb7..90a91319e84 100644 --- a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java +++ b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/AutoConfigureWebTestClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.webflux.test.autoconfigure; +package org.springframework.boot.webtestclient; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -26,18 +26,14 @@ import java.time.Duration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.test.context.PropertyMapping; -import org.springframework.context.ApplicationContext; import org.springframework.test.web.reactive.server.WebTestClient; /** - * Annotation that can be applied to a test class to enable a {@link WebTestClient} that - * is bound directly to the application. Tests do not rely upon an HTTP server and use - * mock requests and responses. At the moment, only WebFlux applications are supported. + * Annotation that can be applied to a test class to enable a {@link WebTestClient}. * * @author Stephane Nicoll * @since 4.0.0 * @see WebTestClientAutoConfiguration - * @see WebTestClient#bindToApplicationContext(ApplicationContext) */ @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) diff --git a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/SpringBootWebTestClientBuilderCustomizer.java b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/SpringBootWebTestClientBuilderCustomizer.java similarity index 94% rename from module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/SpringBootWebTestClientBuilderCustomizer.java rename to module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/SpringBootWebTestClientBuilderCustomizer.java index 0b211c2d041..e1dfa56af45 100644 --- a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/SpringBootWebTestClientBuilderCustomizer.java +++ b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/SpringBootWebTestClientBuilderCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.webflux.test.autoconfigure; +package org.springframework.boot.webtestclient; import java.time.Duration; import java.util.Collection; @@ -23,7 +23,6 @@ import java.util.function.Consumer; import org.jspecify.annotations.Nullable; import org.springframework.boot.http.codec.CodecCustomizer; -import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer; import org.springframework.http.codec.ClientCodecConfigurer; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.reactive.server.WebTestClient.Builder; diff --git a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfiguration.java b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/WebTestClientAutoConfiguration.java similarity index 54% rename from module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfiguration.java rename to module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/WebTestClientAutoConfiguration.java index 6188e58b42c..d13f543724a 100644 --- a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfiguration.java +++ b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/WebTestClientAutoConfiguration.java @@ -14,26 +14,31 @@ * limitations under the License. */ -package org.springframework.boot.webflux.test.autoconfigure; +package org.springframework.boot.webtestclient; import java.util.List; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.http.codec.CodecCustomizer; +import org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; import org.springframework.boot.test.http.server.BaseUrl; import org.springframework.boot.test.http.server.BaseUrlProviders; -import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer; -import org.springframework.boot.test.web.servlet.client.BaseUrlUriBuilderFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.test.web.reactive.server.MockServerConfigurer; import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.test.web.reactive.server.WebTestClient.MockServerSpec; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.client.MockMvcWebTestClient; +import org.springframework.util.ClassUtils; +import org.springframework.web.context.WebApplicationContext; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.server.WebHandler; @@ -42,38 +47,15 @@ import org.springframework.web.server.WebHandler; * * @author Stephane Nicoll * @author Andy Wilkinson + * @author Phillip Webb * @since 4.0.0 */ -@AutoConfiguration(afterName = { "org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration", - "org.springframework.boot.webflux.autoconfigure.WebFluxAutoConfiguration" }) +@AutoConfiguration(after = CodecsAutoConfiguration.class) @ConditionalOnClass({ CodecCustomizer.class, WebClient.class, WebTestClient.class }) @EnableConfigurationProperties public final class WebTestClientAutoConfiguration { - @Bean - @ConditionalOnMissingBean - @ConditionalOnBean(WebHandler.class) - WebTestClient webTestClient(ApplicationContext applicationContext, List customizers, - List configurers) { - WebTestClient.Builder builder = prepareBuilder(applicationContext, configurers); - for (WebTestClientBuilderCustomizer customizer : customizers) { - customizer.customize(builder); - } - return builder.build(); - } - - private WebTestClient.Builder prepareBuilder(ApplicationContext applicationContext, - List configurers) { - BaseUrl baseUrl = new BaseUrlProviders(applicationContext).getBaseUrlOrDefault(); - if (baseUrl == BaseUrl.DEFAULT) { - WebTestClient.MockServerSpec mockServerSpec = WebTestClient.bindToApplicationContext(applicationContext); - for (MockServerConfigurer configurer : configurers) { - mockServerSpec.apply(configurer); - } - return mockServerSpec.configureClient(); - } - return WebTestClient.bindToServer().uriBuilderFactory(BaseUrlUriBuilderFactory.get(baseUrl)); - } + private static final String WEB_APPLICATION_CONTEXT_CLASS = "org.springframework.web.context.WebApplicationContext"; @Bean @ConfigurationProperties("spring.test.webtestclient") @@ -82,4 +64,46 @@ public final class WebTestClientAutoConfiguration { return new SpringBootWebTestClientBuilderCustomizer(codecCustomizers.orderedStream().toList()); } + @Bean + @ConditionalOnMissingBean + WebTestClient webTestClient(ApplicationContext applicationContext, List customizers, + List configurers) { + WebTestClient.Builder builder = getBuilder(applicationContext, configurers); + customizers.forEach((customizer) -> customizer.customize(builder)); + return builder.build(); + } + + private WebTestClient.Builder getBuilder(ApplicationContext applicationContext, + List configurers) { + BaseUrl baseUrl = new BaseUrlProviders(applicationContext).getBaseUrl(); + if (baseUrl != null) { + return WebTestClient.bindToServer().uriBuilderFactory(BaseUrlUriBuilderFactory.get(baseUrl)); + } + if (hasBean(applicationContext, WebHandler.class)) { + MockServerSpec spec = WebTestClient.bindToApplicationContext(applicationContext); + configurers.forEach(spec::apply); + return spec.configureClient(); + } + if (ClassUtils.isPresent(WEB_APPLICATION_CONTEXT_CLASS, applicationContext.getClassLoader())) { + if (hasBean(applicationContext, MockMvc.class)) { + return MockMvcWebTestClient.bindTo(applicationContext.getBean(MockMvc.class)); + } + if (applicationContext instanceof WebApplicationContext webApplicationContext) { + return MockMvcWebTestClient.bindToApplicationContext(webApplicationContext).configureClient(); + } + } + throw new IllegalStateException( + "Mock WebTestClient support requires a WebHandler or MockMvc bean and neither was present"); + } + + private boolean hasBean(ApplicationContext applicationContext, Class type) { + try { + applicationContext.getBean(type); + return true; + } + catch (NoSuchBeanDefinitionException ex) { + return false; + } + } + } diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/client/WebTestClientBuilderCustomizer.java b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/WebTestClientBuilderCustomizer.java similarity index 75% rename from core/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/client/WebTestClientBuilderCustomizer.java rename to module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/WebTestClientBuilderCustomizer.java index e40b503c25c..9d419ea947f 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/client/WebTestClientBuilderCustomizer.java +++ b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/WebTestClientBuilderCustomizer.java @@ -14,16 +14,15 @@ * limitations under the License. */ -package org.springframework.boot.test.web.reactive.client; +package org.springframework.boot.webtestclient; -import org.springframework.context.ApplicationContext; import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.test.web.reactive.server.WebTestClient.Builder; /** - * A customizer that can be implemented by beans wishing to customize the - * {@link WebTestClient.Builder} to fine-tune its auto-configuration before a - * {@link WebTestClient} is created. Implementations can be registered in the - * {@link ApplicationContext} or {@code spring.factories}. + * A customizer that can be implemented by beans wishing to customize the {@link Builder + * WebTestClient.Builder} to fine-tune its auto-configuration before a + * {@link WebTestClient} is created. * * @author Andy Wilkinson * @since 4.0.0 diff --git a/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/package-info.java b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/package-info.java new file mode 100644 index 00000000000..7dd07ee3430 --- /dev/null +++ b/module/spring-boot-webtestclient/src/main/java/org/springframework/boot/webtestclient/package-info.java @@ -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 WebTestClient. + */ +@NullMarked +package org.springframework.boot.webtestclient; + +import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000000..e69de29bb2d diff --git a/module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports b/module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports new file mode 100644 index 00000000000..692a3da0338 --- /dev/null +++ b/module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports @@ -0,0 +1 @@ +org.springframework.boot.webtestclient.WebTestClientAutoConfiguration diff --git a/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController1.java b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController1.java new file mode 100644 index 00000000000..9eb6668cdb1 --- /dev/null +++ b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController1.java @@ -0,0 +1,43 @@ +/* + * 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.webflux.test.autoconfigure; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Example {@link Controller @Controller} used with tests. + * + * @author Stephane Nicoll + */ +@RestController +public class ExampleController1 { + + @GetMapping("/one") + public Mono one() { + return Mono.just("one"); + } + + @GetMapping("/one/error") + public Mono error() { + throw new RuntimeException("foo"); + } + +} diff --git a/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController2.java b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController2.java new file mode 100644 index 00000000000..303613c0931 --- /dev/null +++ b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController2.java @@ -0,0 +1,44 @@ +/* + * 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.webflux.test.autoconfigure; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * Example {@link Controller @Controller} used with tests. + * + * @author Stephane Nicoll + */ +@RestController +public class ExampleController2 { + + @GetMapping("/two") + public Mono two() { + return Mono.just("two"); + } + + @GetMapping("/two/{id}") + public Mono two(@PathVariable ExampleId id) { + return Mono.just(id.getId() + "two"); + } + +} diff --git a/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleId.java b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleId.java new file mode 100644 index 00000000000..b65fb527e8b --- /dev/null +++ b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleId.java @@ -0,0 +1,40 @@ +/* + * 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.webflux.test.autoconfigure; + +import java.util.UUID; + +import org.springframework.core.convert.converter.Converter; + +/** + * An example attribute that requires a {@link Converter}. + * + * @author Stephane Nicoll + */ +public class ExampleId { + + private final UUID id; + + ExampleId(UUID id) { + this.id = id; + } + + public UUID getId() { + return this.id; + } + +} diff --git a/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleRealService.java b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleRealService.java new file mode 100644 index 00000000000..858b8538c45 --- /dev/null +++ b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleRealService.java @@ -0,0 +1,31 @@ +/* + * 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.webflux.test.autoconfigure; + +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; +import org.springframework.stereotype.Service; + +/** + * Example {@link Service @Service} used with + * {@link AutoConfigureWebTestClient @AutoConfigureWebTestClient} tests. + * + * @author Stephane Nicoll + */ +@Service +public class ExampleRealService { + +} diff --git a/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebTestClientApplication.java b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebTestClientApplication.java new file mode 100644 index 00000000000..69d66eaa525 --- /dev/null +++ b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebTestClientApplication.java @@ -0,0 +1,31 @@ +/* + * 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.webflux.test.autoconfigure; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; + +/** + * Example {@link SpringBootApplication @SpringBootApplication} used with + * {@link AutoConfigureWebTestClient @AutoConfigureWebTestClient} tests. + * + * @author Stephane Nicoll + */ +@SpringBootApplication +public class ExampleWebTestClientApplication { + +} diff --git a/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java new file mode 100644 index 00000000000..e2ef494a75e --- /dev/null +++ b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java @@ -0,0 +1,209 @@ +/* + * 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.webflux.test.autoconfigure; + +import java.time.Duration; + +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Test; + +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.http.codec.CodecCustomizer; +import org.springframework.boot.test.context.FilteredClassLoader; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.test.http.server.BaseUrl; +import org.springframework.boot.test.http.server.BaseUrlProvider; +import org.springframework.boot.testsupport.classpath.resources.WithResource; +import org.springframework.boot.webtestclient.WebTestClientAutoConfiguration; +import org.springframework.boot.webtestclient.WebTestClientBuilderCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.http.client.reactive.JdkClientHttpConnector; +import org.springframework.http.codec.CodecConfigurer; +import org.springframework.test.web.reactive.server.HttpHandlerConnector; +import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.client.MockMvcHttpConnector; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.server.WebHandler; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.mock; + +/** + * Tests for {@link WebTestClientAutoConfiguration} + * + * @author Brian Clozel + * @author Stephane Nicoll + * @author Andy Wilkinson + * @author Phillip Webb + */ +class WebTestClientAutoConfigurationTests { + + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(WebTestClientAutoConfiguration.class)); + + @Test + void shouldDefineWebTestClientBoundToHttpHandler() { + this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> { + assertThat(context).hasSingleBean(WebTestClient.class); + assertThat(context).hasBean("webTestClient"); + assertThat(context.getBean(WebTestClient.class)).extracting("wiretapConnector") + .extracting("delegate") + .isInstanceOf(HttpHandlerConnector.class); + }); + } + + @Test + @WithResource(name = "META-INF/spring.factories", content = """ + org.springframework.boot.test.http.server.BaseUrlProvider=\ + org.springframework.boot.webflux.test.autoconfigure.WebTestClientAutoConfigurationTests$TestBaseUrlProvider + """) + void shouldDefineWebTestClientBoundToWebServer() { + this.contextRunner.run((context) -> { + assertThat(context).hasSingleBean(WebTestClient.class); + assertThat(context).hasBean("webTestClient"); + assertThat(context.getBean(WebTestClient.class)).extracting("wiretapConnector") + .extracting("delegate") + .isInstanceOf(JdkClientHttpConnector.class); + }); + } + + @Test + void failsWithMockBaseUrlAndNoWebHandlerOrMockMvcBean() { + this.contextRunner.run((context) -> { + assertThat(context).hasFailed(); + assertThat(context).getFailure() + .rootCause() + .isInstanceOf(RuntimeException.class) + .hasMessageStartingWith("Mock WebTestClient support requires"); + }); + } + + @Test + void shouldCustomizeClientCodecs() { + this.contextRunner.withUserConfiguration(CodecConfiguration.class).run((context) -> { + assertThat(context).hasSingleBean(WebTestClient.class); + assertThat(context).hasSingleBean(CodecCustomizer.class); + then(context.getBean(CodecCustomizer.class)).should().customize(any(CodecConfigurer.class)); + }); + } + + @Test + void shouldHaveConsistentDefaultTimeout() { + this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> { + WebTestClient webTestClient = context.getBean(WebTestClient.class); + assertThat(webTestClient).hasFieldOrPropertyWithValue("responseTimeout", Duration.ofSeconds(5)); + }); + } + + @Test + void shouldCustomizeTimeout() { + this.contextRunner.withUserConfiguration(BaseConfiguration.class) + .withPropertyValues("spring.test.webtestclient.timeout=15m") + .run((context) -> { + WebTestClient webTestClient = context.getBean(WebTestClient.class); + assertThat(webTestClient).hasFieldOrPropertyWithValue("responseTimeout", Duration.ofMinutes(15)); + }); + } + + @Test + void shouldBackOffWithoutCodecCustomizer() { + FilteredClassLoader classLoader = new FilteredClassLoader(CodecCustomizer.class); + this.contextRunner.withUserConfiguration(BaseConfiguration.class) + .withClassLoader(classLoader) + .run((context) -> assertThat(context).doesNotHaveBean(WebTestClient.class)); + } + + @Test + void shouldCreateMockMvcBasedWebTestClientWhenMockMvcBeanIsPresent() { + this.contextRunner.withBean(MockMvc.class, () -> mock(MockMvc.class)) + .withUserConfiguration(WebTestClientCustomConfig.class) + .run((context) -> { + assertThat(context).hasSingleBean(WebTestClient.class); + assertThat(context).hasBean("webTestClient"); + assertThat(context).hasBean("myWebTestClientCustomizer"); + then(context.getBean("myWebTestClientCustomizer", WebTestClientBuilderCustomizer.class)).should() + .customize(any(WebTestClient.Builder.class)); + WebTestClient webTestClient = context.getBean(WebTestClient.class); + assertThat(webTestClient).extracting("builder") + .extracting("connector") + .isInstanceOf(MockMvcHttpConnector.class); + }); + } + + @Test + @WithResource(name = "META-INF/spring.factories", content = """ + org.springframework.boot.test.http.server.BaseUrlProvider=\ + org.springframework.boot.webflux.test.autoconfigure.WebTestClientAutoConfigurationTests$TestBaseUrlProvider + """) + void shouldWorkWithoutServletStack() { + ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader(); + this.contextRunner.withClassLoader(new FilteredClassLoader(parentClassLoader, WebApplicationContext.class)) + .run((context) -> { + assertThat(context).hasSingleBean(WebTestClient.class); + assertThat(context).hasBean("webTestClient"); + assertThat(context.getBean(WebTestClient.class)).extracting("wiretapConnector") + .extracting("delegate") + .isInstanceOf(JdkClientHttpConnector.class); + }); + } + + @Configuration(proxyBeanMethods = false) + static class WebTestClientCustomConfig { + + @Bean + WebTestClientBuilderCustomizer myWebTestClientCustomizer() { + return mock(WebTestClientBuilderCustomizer.class); + } + + } + + @Configuration(proxyBeanMethods = false) + static class BaseConfiguration { + + @Bean + WebHandler webHandler() { + return mock(WebHandler.class); + } + + } + + @Configuration(proxyBeanMethods = false) + @Import(BaseConfiguration.class) + static class CodecConfiguration { + + @Bean + CodecCustomizer myCodecCustomizer() { + return mock(CodecCustomizer.class); + } + + } + + static class TestBaseUrlProvider implements BaseUrlProvider { + + @Override + public @Nullable BaseUrl getBaseUrl() { + return BaseUrl.of("https://localhost:8080"); + } + + } + +} diff --git a/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java similarity index 85% rename from module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java rename to module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java index 4eede12363e..502ad372120 100644 --- a/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java +++ b/module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java @@ -20,8 +20,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Import; import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.web.reactive.config.EnableWebFlux; import static org.assertj.core.api.Assertions.assertThat; @@ -33,8 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll */ @SpringBootTest(properties = { "spring.main.web-application-type=reactive", "debug=true" }, - classes = ExampleWebFluxApplication.class) + classes = ExampleWebTestClientApplication.class) @AutoConfigureWebTestClient +@EnableWebFlux +@Import({ ExampleController1.class, ExampleController2.class }) class WebTestClientSpringBootTestIntegrationTests { @Autowired diff --git a/platform/spring-boot-dependencies/build.gradle b/platform/spring-boot-dependencies/build.gradle index 432feb33b9e..07613c3df6e 100644 --- a/platform/spring-boot-dependencies/build.gradle +++ b/platform/spring-boot-dependencies/build.gradle @@ -2068,6 +2068,7 @@ bom { "spring-boot-reactor-netty", "spring-boot-restclient", "spring-boot-restclient-test", + "spring-boot-resttestclient", "spring-boot-rsocket", "spring-boot-rsocket-test", "spring-boot-security", @@ -2266,6 +2267,7 @@ bom { "spring-boot-webservices", "spring-boot-webservices-test", "spring-boot-websocket", + "spring-boot-webtestclient", "spring-boot-zipkin", "spring-boot-starter-zipkin-test" ] diff --git a/settings.gradle b/settings.gradle index 378512d317e..3d94e667c85 100644 --- a/settings.gradle +++ b/settings.gradle @@ -165,6 +165,7 @@ include "module:spring-boot-reactor-netty" include "module:spring-boot-restclient" include "module:spring-boot-restclient-test" include "module:spring-boot-restdocs" +include "module:spring-boot-resttestclient" include "module:spring-boot-rsocket" include "module:spring-boot-rsocket-test" include "module:spring-boot-security" @@ -192,6 +193,7 @@ include "module:spring-boot-webflux" include "module:spring-boot-webflux-test" include "module:spring-boot-webmvc" include "module:spring-boot-webmvc-test" +include "module:spring-boot-webtestclient" include "module:spring-boot-webservices" include "module:spring-boot-webservices-test" include "module:spring-boot-websocket" diff --git a/smoke-test/spring-boot-smoke-test-actuator-custom-security/build.gradle b/smoke-test/spring-boot-smoke-test-actuator-custom-security/build.gradle index d4439662495..6cae3245b3a 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-custom-security/build.gradle +++ b/smoke-test/spring-boot-smoke-test-actuator-custom-security/build.gradle @@ -26,7 +26,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-security")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) testRuntimeOnly("org.apache.httpcomponents.client5:httpclient5") diff --git a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java index b7d6700b31e..9b50dbbae81 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java @@ -20,10 +20,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; -import org.springframework.boot.restclient.test.TestRestTemplate; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; import org.springframework.boot.test.http.server.BaseUrl; import org.springframework.boot.test.http.server.BaseUrlProviders; -import org.springframework.boot.test.web.servlet.client.BaseUrlUriBuilderFactory; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/CorsSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/CorsSampleActuatorApplicationTests.java index 9a738793604..a3482b4e664 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/CorsSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/CorsSampleActuatorApplicationTests.java @@ -24,12 +24,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; import org.springframework.boot.test.http.server.BaseUrl; import org.springframework.boot.test.http.server.BaseUrlProviders; -import org.springframework.boot.test.web.servlet.client.BaseUrlUriBuilderFactory; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.http.RequestEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortAndPathSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortAndPathSampleActuatorApplicationTests.java index 7b6c186f8aa..339363f1822 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortAndPathSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortAndPathSampleActuatorApplicationTests.java @@ -19,11 +19,11 @@ package smoketest.actuator.customsecurity; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortCustomServletPathSampleActuatorTests.java b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortCustomServletPathSampleActuatorTests.java index fc4a9c5d892..c511e4c4b47 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortCustomServletPathSampleActuatorTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortCustomServletPathSampleActuatorTests.java @@ -19,10 +19,10 @@ package smoketest.actuator.customsecurity; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator-extension/build.gradle b/smoke-test/spring-boot-smoke-test-actuator-extension/build.gradle index f2fab75bd7f..de4200be38a 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-extension/build.gradle +++ b/smoke-test/spring-boot-smoke-test-actuator-extension/build.gradle @@ -24,6 +24,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-actuator")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } \ No newline at end of file diff --git a/smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java index 37f9ce16ade..538919b0e06 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java @@ -22,13 +22,13 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; import org.springframework.boot.test.http.server.BaseUrl; import org.springframework.boot.test.http.server.BaseUrlProviders; -import org.springframework.boot.test.web.servlet.client.BaseUrlUriBuilderFactory; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator-ui/build.gradle b/smoke-test/spring-boot-smoke-test-actuator-ui/build.gradle index a67516bf54e..5c25c582ca7 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-ui/build.gradle +++ b/smoke-test/spring-boot-smoke-test-actuator-ui/build.gradle @@ -26,6 +26,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-security")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } \ No newline at end of file diff --git a/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java b/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java index 2e20d590c04..bbefe96aa6a 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java @@ -21,12 +21,12 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java index 8e604d32d5e..f4eb11b826b 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java @@ -22,10 +22,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-actuator/build.gradle b/smoke-test/spring-boot-smoke-test-actuator/build.gradle index fdfebdd44db..a7a03596435 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/build.gradle +++ b/smoke-test/spring-boot-smoke-test-actuator/build.gradle @@ -30,7 +30,7 @@ dependencies { runtimeOnly("com.h2database:h2") - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) testRuntimeOnly("org.apache.httpcomponents.client5:httpclient5") } \ No newline at end of file diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/AbstractManagementPortAndPathSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/AbstractManagementPortAndPathSampleActuatorApplicationTests.java index 3bc0bf58571..afff3e7cd57 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/AbstractManagementPortAndPathSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/AbstractManagementPortAndPathSampleActuatorApplicationTests.java @@ -21,9 +21,9 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.core.env.Environment; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/CorsSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/CorsSampleActuatorApplicationTests.java index 6f53c9518c2..2350e5dd44b 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/CorsSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/CorsSampleActuatorApplicationTests.java @@ -24,12 +24,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.http.client.BaseUrlUriBuilderFactory; import org.springframework.boot.test.http.server.BaseUrl; import org.springframework.boot.test.http.server.BaseUrlProviders; -import org.springframework.boot.test.web.servlet.client.BaseUrlUriBuilderFactory; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.http.RequestEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java index e79c08cbb4e..e8374f63b52 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementAddressActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementAddressActuatorApplicationTests.java index 16834883600..978ea25ce10 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementAddressActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementAddressActuatorApplicationTests.java @@ -20,11 +20,11 @@ import java.util.Map; import org.junit.jupiter.api.Test; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java index 3aae425b3db..9db76b93524 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java @@ -18,9 +18,9 @@ package smoketest.actuator; import org.junit.jupiter.api.Test; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalManagementPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java index a5ab7f1fbce..2f041842411 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java @@ -18,9 +18,9 @@ package smoketest.actuator; import org.junit.jupiter.api.Test; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalManagementPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPathSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPathSampleActuatorApplicationTests.java index 21889826b30..e067c5913ba 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPathSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPathSampleActuatorApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortSampleActuatorApplicationTests.java index 0cbebdcc40e..a277968b287 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortSampleActuatorApplicationTests.java @@ -22,11 +22,11 @@ import org.junit.jupiter.api.Test; import smoketest.actuator.ManagementPortSampleActuatorApplicationTests.CustomErrorAttributes; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.webmvc.error.DefaultErrorAttributes; import org.springframework.context.annotation.Import; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortWithLazyInitializationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortWithLazyInitializationTests.java index 83b02c29d77..40d209df78d 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortWithLazyInitializationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortWithLazyInitializationTests.java @@ -18,9 +18,9 @@ package smoketest.actuator; import org.junit.jupiter.api.Test; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalManagementPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/NoManagementSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/NoManagementSampleActuatorApplicationTests.java index 5faab55ab34..306ed797b8d 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/NoManagementSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/NoManagementSampleActuatorApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperFalseTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperFalseTests.java index 95427efc4e3..00333af5e2b 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperFalseTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperFalseTests.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import tools.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperTrueTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperTrueTests.java index 3904d103c7f..4362f9a0bad 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperTrueTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperTrueTests.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import tools.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationTests.java index 380b75e5f83..c0a9412c035 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationTests.java @@ -24,10 +24,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ServletPathSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ServletPathSampleActuatorApplicationTests.java index 4a89d551f8d..3c741cead90 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ServletPathSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ServletPathSampleActuatorApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ShutdownSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ShutdownSampleActuatorApplicationTests.java index 919f9d54202..e96dcc5153d 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ShutdownSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ShutdownSampleActuatorApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; diff --git a/smoke-test/spring-boot-smoke-test-data-r2dbc/src/test/java/smoketest/data/r2dbc/SampleR2dbcApplicationTests.java b/smoke-test/spring-boot-smoke-test-data-r2dbc/src/test/java/smoketest/data/r2dbc/SampleR2dbcApplicationTests.java index a1e334b8013..257a0d808a5 100644 --- a/smoke-test/spring-boot-smoke-test-data-r2dbc/src/test/java/smoketest/data/r2dbc/SampleR2dbcApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-r2dbc/src/test/java/smoketest/data/r2dbc/SampleR2dbcApplicationTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.context.ApplicationContext; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/smoke-test/spring-boot-smoke-test-devtools/build.gradle b/smoke-test/spring-boot-smoke-test-devtools/build.gradle index ea05e46c5fe..900277aaced 100644 --- a/smoke-test/spring-boot-smoke-test-devtools/build.gradle +++ b/smoke-test/spring-boot-smoke-test-devtools/build.gradle @@ -30,6 +30,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-devtools/src/test/java/smoketest/devtools/SampleDevToolsApplicationIntegrationTests.java b/smoke-test/spring-boot-smoke-test-devtools/src/test/java/smoketest/devtools/SampleDevToolsApplicationIntegrationTests.java index e2bdd292f98..b6a57ce413e 100644 --- a/smoke-test/spring-boot-smoke-test-devtools/src/test/java/smoketest/devtools/SampleDevToolsApplicationIntegrationTests.java +++ b/smoke-test/spring-boot-smoke-test-devtools/src/test/java/smoketest/devtools/SampleDevToolsApplicationIntegrationTests.java @@ -19,10 +19,10 @@ package smoketest.devtools; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-graphql/build.gradle b/smoke-test/spring-boot-smoke-test-graphql/build.gradle index 3e3ef9a68dd..79065935e70 100644 --- a/smoke-test/spring-boot-smoke-test-graphql/build.gradle +++ b/smoke-test/spring-boot-smoke-test-graphql/build.gradle @@ -27,6 +27,7 @@ dependencies { testImplementation(project(":module:spring-boot-graphql-test")) testImplementation(project(":module:spring-boot-webmvc-test")) + testImplementation(project(":module:spring-boot-webtestclient")) testImplementation(project(":starter:spring-boot-starter-test")) testRuntimeOnly("org.springframework:spring-webflux") diff --git a/smoke-test/spring-boot-smoke-test-hateoas/build.gradle b/smoke-test/spring-boot-smoke-test-hateoas/build.gradle index e9b57263700..885b5ee5aca 100644 --- a/smoke-test/spring-boot-smoke-test-hateoas/build.gradle +++ b/smoke-test/spring-boot-smoke-test-hateoas/build.gradle @@ -23,6 +23,6 @@ description = "Spring Boot HATEOAS smoke test" dependencies { implementation(project(":starter:spring-boot-starter-hateoas")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-hateoas-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-hateoas/src/test/java/smoketest/hateoas/SampleHateoasApplicationTests.java b/smoke-test/spring-boot-smoke-test-hateoas/src/test/java/smoketest/hateoas/SampleHateoasApplicationTests.java index 2e5a3a850fa..0478e82e3fc 100644 --- a/smoke-test/spring-boot-smoke-test-hateoas/src/test/java/smoketest/hateoas/SampleHateoasApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-hateoas/src/test/java/smoketest/hateoas/SampleHateoasApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-jetty-jsp/build.gradle b/smoke-test/spring-boot-smoke-test-jetty-jsp/build.gradle index b93b42cb39c..f96c8bf8f68 100644 --- a/smoke-test/spring-boot-smoke-test-jetty-jsp/build.gradle +++ b/smoke-test/spring-boot-smoke-test-jetty-jsp/build.gradle @@ -38,6 +38,6 @@ dependencies { runtimeOnly("org.glassfish.web:jakarta.servlet.jsp.jstl") testImplementation(project(":starter:spring-boot-starter-jetty")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) } diff --git a/smoke-test/spring-boot-smoke-test-jetty-jsp/src/test/java/smoketest/jetty/jsp/SampleWebJspApplicationTests.java b/smoke-test/spring-boot-smoke-test-jetty-jsp/src/test/java/smoketest/jetty/jsp/SampleWebJspApplicationTests.java index 3b675748006..5e310fe4c2c 100644 --- a/smoke-test/spring-boot-smoke-test-jetty-jsp/src/test/java/smoketest/jetty/jsp/SampleWebJspApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-jetty-jsp/src/test/java/smoketest/jetty/jsp/SampleWebJspApplicationTests.java @@ -19,10 +19,10 @@ package smoketest.jetty.jsp; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-jetty-ssl/build.gradle b/smoke-test/spring-boot-smoke-test-jetty-ssl/build.gradle index 70834ec2abd..976f7d82619 100644 --- a/smoke-test/spring-boot-smoke-test-jetty-ssl/build.gradle +++ b/smoke-test/spring-boot-smoke-test-jetty-ssl/build.gradle @@ -26,8 +26,8 @@ dependencies { exclude module: "spring-boot-starter-tomcat" } - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testRuntimeOnly("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-jetty-ssl/src/test/java/smoketest/jetty/ssl/SampleJettySslApplicationTests.java b/smoke-test/spring-boot-smoke-test-jetty-ssl/src/test/java/smoketest/jetty/ssl/SampleJettySslApplicationTests.java index 4dccc7d14d8..2e3d7932d36 100644 --- a/smoke-test/spring-boot-smoke-test-jetty-ssl/src/test/java/smoketest/jetty/ssl/SampleJettySslApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-jetty-ssl/src/test/java/smoketest/jetty/ssl/SampleJettySslApplicationTests.java @@ -19,10 +19,10 @@ package smoketest.jetty.ssl; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-jetty/build.gradle b/smoke-test/spring-boot-smoke-test-jetty/build.gradle index af1333a51be..c2bd91baebf 100644 --- a/smoke-test/spring-boot-smoke-test-jetty/build.gradle +++ b/smoke-test/spring-boot-smoke-test-jetty/build.gradle @@ -26,6 +26,6 @@ dependencies { } implementation(project(":starter:spring-boot-starter-jetty")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) } diff --git a/smoke-test/spring-boot-smoke-test-jetty/src/test/java/smoketest/jetty/SampleJettyApplicationTests.java b/smoke-test/spring-boot-smoke-test-jetty/src/test/java/smoketest/jetty/SampleJettyApplicationTests.java index fffa8a7962a..909eb6862dc 100644 --- a/smoke-test/spring-boot-smoke-test-jetty/src/test/java/smoketest/jetty/SampleJettyApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-jetty/src/test/java/smoketest/jetty/SampleJettyApplicationTests.java @@ -21,10 +21,10 @@ import smoketest.jetty.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-oauth2-authorization-server/build.gradle b/smoke-test/spring-boot-smoke-test-oauth2-authorization-server/build.gradle index d86065259d5..ad5aac85e4a 100644 --- a/smoke-test/spring-boot-smoke-test-oauth2-authorization-server/build.gradle +++ b/smoke-test/spring-boot-smoke-test-oauth2-authorization-server/build.gradle @@ -23,7 +23,7 @@ description = "Spring Boot OAuth2 Authorization Server smoke test" dependencies { implementation(project(":starter:spring-boot-starter-security-oauth2-authorization-server")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-security-oauth2-authorization-server-test")) testImplementation(project(":starter:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java b/smoke-test/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java index 9c0d6401d1d..348147273e6 100644 --- a/smoke-test/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java @@ -25,10 +25,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.http.client.HttpRedirects; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; diff --git a/smoke-test/spring-boot-smoke-test-oauth2-client/build.gradle b/smoke-test/spring-boot-smoke-test-oauth2-client/build.gradle index a085ab3421f..af0dad869ea 100644 --- a/smoke-test/spring-boot-smoke-test-oauth2-client/build.gradle +++ b/smoke-test/spring-boot-smoke-test-oauth2-client/build.gradle @@ -24,7 +24,8 @@ dependencies { implementation(project(":starter:spring-boot-starter-security-oauth2-client")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-security-oauth2-client-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-oauth2-client/src/test/java/smoketest/oauth2/client/SampleOAuth2ClientApplicationTests.java b/smoke-test/spring-boot-smoke-test-oauth2-client/src/test/java/smoketest/oauth2/client/SampleOAuth2ClientApplicationTests.java index 2fb06d93c1c..7cea6d36c7f 100644 --- a/smoke-test/spring-boot-smoke-test-oauth2-client/src/test/java/smoketest/oauth2/client/SampleOAuth2ClientApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-oauth2-client/src/test/java/smoketest/oauth2/client/SampleOAuth2ClientApplicationTests.java @@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.http.client.HttpRedirects; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-oauth2-resource-server/build.gradle b/smoke-test/spring-boot-smoke-test-oauth2-resource-server/build.gradle index 6604e64c573..5642cc0660e 100644 --- a/smoke-test/spring-boot-smoke-test-oauth2-resource-server/build.gradle +++ b/smoke-test/spring-boot-smoke-test-oauth2-resource-server/build.gradle @@ -24,7 +24,8 @@ dependencies { implementation(project(":starter:spring-boot-starter-security-oauth2-resource-server")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-security-oauth2-resource-server-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("com.squareup.okhttp3:mockwebserver") } diff --git a/smoke-test/spring-boot-smoke-test-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleOauth2ResourceServerApplicationTests.java b/smoke-test/spring-boot-smoke-test-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleOauth2ResourceServerApplicationTests.java index 5e4dfbcd85b..5e8998942e5 100644 --- a/smoke-test/spring-boot-smoke-test-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleOauth2ResourceServerApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleOauth2ResourceServerApplicationTests.java @@ -25,9 +25,9 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-prometheus/build.gradle b/smoke-test/spring-boot-smoke-test-prometheus/build.gradle index 0e0bfd7bdca..2a7c6204efd 100644 --- a/smoke-test/spring-boot-smoke-test-prometheus/build.gradle +++ b/smoke-test/spring-boot-smoke-test-prometheus/build.gradle @@ -28,6 +28,6 @@ dependencies { runtimeOnly('io.micrometer:micrometer-registry-prometheus') testImplementation(project(":module:spring-boot-micrometer-metrics-test")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) } diff --git a/smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java b/smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java index f1b0c598216..f4668f3d86b 100644 --- a/smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java @@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-quartz/build.gradle b/smoke-test/spring-boot-smoke-test-quartz/build.gradle index 61f39a5b1d5..8032a5cc5cc 100644 --- a/smoke-test/spring-boot-smoke-test-quartz/build.gradle +++ b/smoke-test/spring-boot-smoke-test-quartz/build.gradle @@ -28,7 +28,7 @@ dependencies { runtimeOnly("com.h2database:h2") - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) testImplementation("org.awaitility:awaitility") } diff --git a/smoke-test/spring-boot-smoke-test-quartz/src/test/java/smoketest/quartz/SampleQuartzApplicationWebTests.java b/smoke-test/spring-boot-smoke-test-quartz/src/test/java/smoketest/quartz/SampleQuartzApplicationWebTests.java index 2317f376030..76b427da542 100644 --- a/smoke-test/spring-boot-smoke-test-quartz/src/test/java/smoketest/quartz/SampleQuartzApplicationWebTests.java +++ b/smoke-test/spring-boot-smoke-test-quartz/src/test/java/smoketest/quartz/SampleQuartzApplicationWebTests.java @@ -29,12 +29,12 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-reactive-oauth2-client/src/test/java/smoketest/oauth2/client/SampleReactiveOAuth2ClientApplicationTests.java b/smoke-test/spring-boot-smoke-test-reactive-oauth2-client/src/test/java/smoketest/oauth2/client/SampleReactiveOAuth2ClientApplicationTests.java index 6656bd4156f..cc9ec74d62b 100644 --- a/smoke-test/spring-boot-smoke-test-reactive-oauth2-client/src/test/java/smoketest/oauth2/client/SampleReactiveOAuth2ClientApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-reactive-oauth2-client/src/test/java/smoketest/oauth2/client/SampleReactiveOAuth2ClientApplicationTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.test.web.reactive.server.WebTestClient; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-reactive-oauth2-resource-server/build.gradle b/smoke-test/spring-boot-smoke-test-reactive-oauth2-resource-server/build.gradle index 417f1a6d789..b04beca88ec 100644 --- a/smoke-test/spring-boot-smoke-test-reactive-oauth2-resource-server/build.gradle +++ b/smoke-test/spring-boot-smoke-test-reactive-oauth2-resource-server/build.gradle @@ -26,5 +26,7 @@ dependencies { testImplementation(project(":starter:spring-boot-starter-test")) testImplementation(project(":starter:spring-boot-starter-webflux-test")) + testImplementation(project(":starter:spring-boot-starter-security-oauth2-resource-server")) + testImplementation(project(":starter:spring-boot-starter-security-oauth2-resource-server-test")) testImplementation("com.squareup.okhttp3:mockwebserver") } diff --git a/smoke-test/spring-boot-smoke-test-reactive-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleReactiveOAuth2ResourceServerApplicationTests.java b/smoke-test/spring-boot-smoke-test-reactive-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleReactiveOAuth2ResourceServerApplicationTests.java index f4d7f45b303..84f9cd2e173 100644 --- a/smoke-test/spring-boot-smoke-test-reactive-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleReactiveOAuth2ResourceServerApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-reactive-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleReactiveOAuth2ResourceServerApplicationTests.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/smoke-test/spring-boot-smoke-test-saml2-service-provider/build.gradle b/smoke-test/spring-boot-smoke-test-saml2-service-provider/build.gradle index df60e2b52a8..a11b01229df 100644 --- a/smoke-test/spring-boot-smoke-test-saml2-service-provider/build.gradle +++ b/smoke-test/spring-boot-smoke-test-saml2-service-provider/build.gradle @@ -24,7 +24,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-security-saml2")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-saml2-service-provider/src/test/java/smoketest/saml2/serviceprovider/SampleSaml2RelyingPartyApplicationTests.java b/smoke-test/spring-boot-smoke-test-saml2-service-provider/src/test/java/smoketest/saml2/serviceprovider/SampleSaml2RelyingPartyApplicationTests.java index 5a8b328da02..076724f5e43 100644 --- a/smoke-test/spring-boot-smoke-test-saml2-service-provider/src/test/java/smoketest/saml2/serviceprovider/SampleSaml2RelyingPartyApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-saml2-service-provider/src/test/java/smoketest/saml2/serviceprovider/SampleSaml2RelyingPartyApplicationTests.java @@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.http.client.HttpRedirects; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/CorsSampleActuatorApplicationTests.java b/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/CorsSampleActuatorApplicationTests.java index b659ea679a1..0bf21800c27 100644 --- a/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/CorsSampleActuatorApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/CorsSampleActuatorApplicationTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/ManagementPortSampleSecureWebFluxTests.java b/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/ManagementPortSampleSecureWebFluxTests.java index 656b37ed4a1..509dfed46d0 100644 --- a/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/ManagementPortSampleSecureWebFluxTests.java +++ b/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/ManagementPortSampleSecureWebFluxTests.java @@ -28,7 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalManagementPort; import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.web.server.ServerHttpSecurity; diff --git a/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxApplicationTests.java b/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxApplicationTests.java index 6ac240a3580..96ce85bcd4e 100644 --- a/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxApplicationTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxCustomSecurityTests.java b/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxCustomSecurityTests.java index b6a73c944eb..3de1cbe9e51 100644 --- a/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxCustomSecurityTests.java +++ b/smoke-test/spring-boot-smoke-test-secure-webflux/src/test/java/smoketest/secure/webflux/SampleSecureWebFluxCustomSecurityTests.java @@ -25,7 +25,7 @@ import org.springframework.boot.actuate.web.mappings.MappingsEndpoint; import org.springframework.boot.security.autoconfigure.actuate.reactive.EndpointRequest; import org.springframework.boot.security.autoconfigure.reactive.PathRequest; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; diff --git a/smoke-test/spring-boot-smoke-test-servlet/build.gradle b/smoke-test/spring-boot-smoke-test-servlet/build.gradle index fbff2765134..b483b15f6ab 100644 --- a/smoke-test/spring-boot-smoke-test-servlet/build.gradle +++ b/smoke-test/spring-boot-smoke-test-servlet/build.gradle @@ -25,7 +25,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-security")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(project(":starter:spring-boot-starter-test")) testRuntimeOnly(project(":starter:spring-boot-starter-tomcat")) diff --git a/smoke-test/spring-boot-smoke-test-servlet/src/test/java/smoketest/servlet/SampleServletApplicationTests.java b/smoke-test/spring-boot-smoke-test-servlet/src/test/java/smoketest/servlet/SampleServletApplicationTests.java index 6aa634e5ed0..5207db59c02 100644 --- a/smoke-test/spring-boot-smoke-test-servlet/src/test/java/smoketest/servlet/SampleServletApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-servlet/src/test/java/smoketest/servlet/SampleServletApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Collections; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-session-data-mongodb/build.gradle b/smoke-test/spring-boot-smoke-test-session-data-mongodb/build.gradle index fe49c1cbe52..a131f5a2583 100644 --- a/smoke-test/spring-boot-smoke-test-session-data-mongodb/build.gradle +++ b/smoke-test/spring-boot-smoke-test-session-data-mongodb/build.gradle @@ -29,8 +29,8 @@ dependencies { dockerTestImplementation(project(":core:spring-boot-testcontainers")) dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) - dockerTestImplementation(project(":starter:spring-boot-starter-restclient-test")) dockerTestImplementation(project(":starter:spring-boot-starter-test")) + dockerTestImplementation(project(":starter:spring-boot-starter-webmvc-test")) dockerTestImplementation("org.testcontainers:junit-jupiter") dockerTestImplementation("org.testcontainers:mongodb") } diff --git a/smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java b/smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java index 32ae192c0c0..8f4931b7468 100644 --- a/smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java @@ -27,11 +27,11 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.testsupport.container.TestImage; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; diff --git a/smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle b/smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle index bf3b3905327..0d05682eec5 100644 --- a/smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle +++ b/smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle @@ -29,7 +29,7 @@ dependencies { dockerTestImplementation(project(":core:spring-boot-testcontainers")) dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) - dockerTestImplementation(project(":starter:spring-boot-starter-restclient-test")) + dockerTestImplementation(project(":starter:spring-boot-starter-webmvc-test")) dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation("com.redis:testcontainers-redis") dockerTestImplementation("org.testcontainers:junit-jupiter") diff --git a/smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java b/smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java index 29668043e65..91c51919bc0 100644 --- a/smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java @@ -27,10 +27,10 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.testsupport.container.TestImage; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; diff --git a/smoke-test/spring-boot-smoke-test-session-hazelcast/build.gradle b/smoke-test/spring-boot-smoke-test-session-hazelcast/build.gradle index f08103dffd2..f280c138506 100644 --- a/smoke-test/spring-boot-smoke-test-session-hazelcast/build.gradle +++ b/smoke-test/spring-boot-smoke-test-session-hazelcast/build.gradle @@ -26,6 +26,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-session-hazelcast")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java b/smoke-test/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java index 8969a264a8b..c1143d19f79 100644 --- a/smoke-test/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-session-hazelcast/src/test/java/smoketest/session/hazelcast/SampleSessionHazelcastApplicationTests.java @@ -25,9 +25,9 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; diff --git a/smoke-test/spring-boot-smoke-test-session-jdbc/build.gradle b/smoke-test/spring-boot-smoke-test-session-jdbc/build.gradle index d9c04a71686..c3b418fdb9d 100644 --- a/smoke-test/spring-boot-smoke-test-session-jdbc/build.gradle +++ b/smoke-test/spring-boot-smoke-test-session-jdbc/build.gradle @@ -29,6 +29,6 @@ dependencies { runtimeOnly(project(":starter:spring-boot-starter-jdbc")) runtimeOnly("com.h2database:h2") - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-session-jdbc/src/test/java/smoketest/session/SampleSessionJdbcApplicationTests.java b/smoke-test/spring-boot-smoke-test-session-jdbc/src/test/java/smoketest/session/SampleSessionJdbcApplicationTests.java index 91cb9d8b9e2..4f9010b1097 100644 --- a/smoke-test/spring-boot-smoke-test-session-jdbc/src/test/java/smoketest/session/SampleSessionJdbcApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-session-jdbc/src/test/java/smoketest/session/SampleSessionJdbcApplicationTests.java @@ -28,10 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; import org.springframework.boot.http.client.HttpRedirects; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; diff --git a/smoke-test/spring-boot-smoke-test-test/build.gradle b/smoke-test/spring-boot-smoke-test-test/build.gradle index 42d6ed4e220..1985fec71ff 100644 --- a/smoke-test/spring-boot-smoke-test-test/build.gradle +++ b/smoke-test/spring-boot-smoke-test-test/build.gradle @@ -27,11 +27,10 @@ dependencies { runtimeOnly("com.h2database:h2") + testImplementation(project(":starter:spring-boot-starter-data-jpa-test")) + testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) - testImplementation(project(":module:spring-boot-data-jpa-test")) - testImplementation(project(":module:spring-boot-jdbc-test")) - testImplementation(project(":module:spring-boot-restclient-test")) - testImplementation(project(":module:spring-boot-webmvc-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.htmlunit:htmlunit") testImplementation("org.mockito:mockito-junit-jupiter") testImplementation("org.seleniumhq.selenium:selenium-api") diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/SampleTestApplicationWebIntegrationTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/SampleTestApplicationWebIntegrationTests.java index 7c52bc4f166..41e02d62228 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/SampleTestApplicationWebIntegrationTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/SampleTestApplicationWebIntegrationTests.java @@ -24,10 +24,10 @@ import smoketest.test.service.VehicleDetailsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.test.context.bean.override.mockito.MockitoBean; diff --git a/smoke-test/spring-boot-smoke-test-testng/build.gradle b/smoke-test/spring-boot-smoke-test-testng/build.gradle index 5bd02ee9b69..5a949798b99 100644 --- a/smoke-test/spring-boot-smoke-test-testng/build.gradle +++ b/smoke-test/spring-boot-smoke-test-testng/build.gradle @@ -23,12 +23,12 @@ description = "Spring Boot TestNG smoke test" dependencies { implementation(platform(project(":platform:spring-boot-dependencies"))) implementation(project(":starter:spring-boot-starter")) - implementation(project(":starter:spring-boot-starter-tomcat")) - implementation(project(":module:spring-boot-webmvc")) + implementation(project(":starter:spring-boot-starter-webmvc")) + testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-restclient")) testImplementation(project(":module:spring-boot-restclient-test")) - testImplementation(project(":core:spring-boot-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.assertj:assertj-core") testImplementation("org.springframework:spring-test") testImplementation("org.testng:testng:6.8.13") diff --git a/smoke-test/spring-boot-smoke-test-testng/src/test/java/smoketest/testng/SampleTestNGApplicationTests.java b/smoke-test/spring-boot-smoke-test-testng/src/test/java/smoketest/testng/SampleTestNGApplicationTests.java index d2a39f14d4d..902f77cfb63 100644 --- a/smoke-test/spring-boot-smoke-test-testng/src/test/java/smoketest/testng/SampleTestNGApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-testng/src/test/java/smoketest/testng/SampleTestNGApplicationTests.java @@ -19,10 +19,10 @@ package smoketest.testng; import org.testng.annotations.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; diff --git a/smoke-test/spring-boot-smoke-test-tomcat-jsp/build.gradle b/smoke-test/spring-boot-smoke-test-tomcat-jsp/build.gradle index 937468d3cd8..8e6f57ce647 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat-jsp/build.gradle +++ b/smoke-test/spring-boot-smoke-test-tomcat-jsp/build.gradle @@ -33,6 +33,6 @@ dependencies { providedRuntime("org.glassfish.web:jakarta.servlet.jsp.jstl") providedRuntime("org.apache.tomcat.embed:tomcat-embed-jasper") - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) } diff --git a/smoke-test/spring-boot-smoke-test-tomcat-jsp/src/test/java/smoketest/tomcat/jsp/SampleWebJspApplicationTests.java b/smoke-test/spring-boot-smoke-test-tomcat-jsp/src/test/java/smoketest/tomcat/jsp/SampleWebJspApplicationTests.java index fb957a8b666..998791fedb5 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat-jsp/src/test/java/smoketest/tomcat/jsp/SampleWebJspApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-tomcat-jsp/src/test/java/smoketest/tomcat/jsp/SampleWebJspApplicationTests.java @@ -19,10 +19,10 @@ package smoketest.tomcat.jsp; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-tomcat-multi-connectors/build.gradle b/smoke-test/spring-boot-smoke-test-tomcat-multi-connectors/build.gradle index 35230fcd5ec..a5c731de6b1 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat-multi-connectors/build.gradle +++ b/smoke-test/spring-boot-smoke-test-tomcat-multi-connectors/build.gradle @@ -23,7 +23,7 @@ description = "Spring Boot Tomcat multi-connectors smoke test" dependencies { implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-tomcat-multi-connectors/src/test/java/smoketest/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java b/smoke-test/spring-boot-smoke-test-tomcat-multi-connectors/src/test/java/smoketest/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java index bb601294ded..3360b69bd50 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat-multi-connectors/src/test/java/smoketest/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-tomcat-multi-connectors/src/test/java/smoketest/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java @@ -22,12 +22,12 @@ import org.junit.jupiter.api.Test; import smoketest.tomcat.multiconnector.SampleTomcatTwoConnectorsApplicationTests.Ports; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.tomcat.TomcatWebServer; import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory; import org.springframework.boot.web.server.context.WebServerInitializedEvent; diff --git a/smoke-test/spring-boot-smoke-test-tomcat-ssl/build.gradle b/smoke-test/spring-boot-smoke-test-tomcat-ssl/build.gradle index e48a0283af2..ac9f90a1d01 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat-ssl/build.gradle +++ b/smoke-test/spring-boot-smoke-test-tomcat-ssl/build.gradle @@ -24,7 +24,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-webmvc")) implementation(project(":starter:spring-boot-starter-actuator")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-tomcat-ssl/src/test/java/smoketest/tomcat/ssl/SampleTomcatSslApplicationTests.java b/smoke-test/spring-boot-smoke-test-tomcat-ssl/src/test/java/smoketest/tomcat/ssl/SampleTomcatSslApplicationTests.java index 7ee30b4d41a..a696574f55f 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat-ssl/src/test/java/smoketest/tomcat/ssl/SampleTomcatSslApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-tomcat-ssl/src/test/java/smoketest/tomcat/ssl/SampleTomcatSslApplicationTests.java @@ -19,10 +19,10 @@ package smoketest.tomcat.ssl; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-tomcat/build.gradle b/smoke-test/spring-boot-smoke-test-tomcat/build.gradle index 510d3d0e7bf..f8d7ac4d22e 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat/build.gradle +++ b/smoke-test/spring-boot-smoke-test-tomcat/build.gradle @@ -23,6 +23,6 @@ description = "Spring Boot Tomcat smoke test" dependencies { implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java b/smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java index ece98166e65..71dbe53e54f 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java @@ -24,10 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration; import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration; diff --git a/smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/SampleTomcatApplicationTests.java b/smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/SampleTomcatApplicationTests.java index 6bf121d543b..59e1d30a349 100644 --- a/smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/SampleTomcatApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/SampleTomcatApplicationTests.java @@ -31,13 +31,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.tomcat.TomcatWebServer; import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext; import org.springframework.context.ApplicationContext; diff --git a/smoke-test/spring-boot-smoke-test-traditional/build.gradle b/smoke-test/spring-boot-smoke-test-traditional/build.gradle index b5fc3229e03..29d90356512 100644 --- a/smoke-test/spring-boot-smoke-test-traditional/build.gradle +++ b/smoke-test/spring-boot-smoke-test-traditional/build.gradle @@ -33,7 +33,7 @@ dependencies { providedRuntime(project(":starter:spring-boot-starter-tomcat")) providedRuntime("org.apache.tomcat.embed:tomcat-embed-jasper") - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(project(":starter:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-traditional/src/test/java/smoketest/traditional/SampleTraditionalApplicationTests.java b/smoke-test/spring-boot-smoke-test-traditional/src/test/java/smoketest/traditional/SampleTraditionalApplicationTests.java index 852874cd1f5..79bf2171538 100644 --- a/smoke-test/spring-boot-smoke-test-traditional/src/test/java/smoketest/traditional/SampleTraditionalApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-traditional/src/test/java/smoketest/traditional/SampleTraditionalApplicationTests.java @@ -19,10 +19,10 @@ package smoketest.traditional; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-web-freemarker/build.gradle b/smoke-test/spring-boot-smoke-test-web-freemarker/build.gradle index 56720d996c0..64ea750f111 100644 --- a/smoke-test/spring-boot-smoke-test-web-freemarker/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-freemarker/build.gradle @@ -24,6 +24,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-freemarker")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-freemarker/src/test/java/smoketest/freemarker/SampleWebFreeMarkerApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-freemarker/src/test/java/smoketest/freemarker/SampleWebFreeMarkerApplicationTests.java index 56588958760..ebad048e7ab 100644 --- a/smoke-test/spring-boot-smoke-test-web-freemarker/src/test/java/smoketest/freemarker/SampleWebFreeMarkerApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-freemarker/src/test/java/smoketest/freemarker/SampleWebFreeMarkerApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-web-groovy-templates/build.gradle b/smoke-test/spring-boot-smoke-test-web-groovy-templates/build.gradle index 20708d29210..539b4e1e1cc 100644 --- a/smoke-test/spring-boot-smoke-test-web-groovy-templates/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-groovy-templates/build.gradle @@ -26,7 +26,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-webmvc")) implementation("jakarta.xml.bind:jakarta.xml.bind-api") - testImplementation(project(":module:spring-boot-webmvc-test")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-groovy-templates/src/test/java/smoketest/groovytemplates/SampleGroovyTemplateApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-groovy-templates/src/test/java/smoketest/groovytemplates/SampleGroovyTemplateApplicationTests.java index 6cf682070b3..d86015f47a5 100644 --- a/smoke-test/spring-boot-smoke-test-web-groovy-templates/src/test/java/smoketest/groovytemplates/SampleGroovyTemplateApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-groovy-templates/src/test/java/smoketest/groovytemplates/SampleGroovyTemplateApplicationTests.java @@ -21,11 +21,11 @@ import java.net.URI; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.util.LinkedMultiValueMap; diff --git a/smoke-test/spring-boot-smoke-test-web-jsp/build.gradle b/smoke-test/spring-boot-smoke-test-web-jsp/build.gradle index 58f37da0f99..14464762d26 100644 --- a/smoke-test/spring-boot-smoke-test-web-jsp/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-jsp/build.gradle @@ -33,6 +33,6 @@ dependencies { providedRuntime("org.glassfish.web:jakarta.servlet.jsp.jstl") providedRuntime("org.apache.tomcat.embed:tomcat-embed-jasper") - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-jsp/src/test/java/smoketest/jsp/SampleWebJspApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-jsp/src/test/java/smoketest/jsp/SampleWebJspApplicationTests.java index c9c41bc9587..b838de23991 100644 --- a/smoke-test/spring-boot-smoke-test-web-jsp/src/test/java/smoketest/jsp/SampleWebJspApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-jsp/src/test/java/smoketest/jsp/SampleWebJspApplicationTests.java @@ -22,10 +22,10 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; diff --git a/smoke-test/spring-boot-smoke-test-web-method-security/build.gradle b/smoke-test/spring-boot-smoke-test-web-method-security/build.gradle index baad36adc6f..d5c24bdfbdc 100644 --- a/smoke-test/spring-boot-smoke-test-web-method-security/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-method-security/build.gradle @@ -25,6 +25,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-security")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java index 6d353cd664c..b7ee5783c3c 100644 --- a/smoke-test/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java @@ -21,11 +21,11 @@ import java.util.Collections; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-web-mustache/build.gradle b/smoke-test/spring-boot-smoke-test-web-mustache/build.gradle index 1779535abed..da1a265bc3c 100644 --- a/smoke-test/spring-boot-smoke-test-web-mustache/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-mustache/build.gradle @@ -24,6 +24,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-mustache")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-mustache/src/test/java/smoketest/mustache/SampleWebMustacheApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-mustache/src/test/java/smoketest/mustache/SampleWebMustacheApplicationTests.java index fc3270c5869..d599a4e1eef 100644 --- a/smoke-test/spring-boot-smoke-test-web-mustache/src/test/java/smoketest/mustache/SampleWebMustacheApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-mustache/src/test/java/smoketest/mustache/SampleWebMustacheApplicationTests.java @@ -21,10 +21,10 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-web-secure-custom/build.gradle b/smoke-test/spring-boot-smoke-test-web-secure-custom/build.gradle index dfdc6c2d08c..d63e028f28a 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure-custom/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-secure-custom/build.gradle @@ -24,7 +24,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-security")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-web-secure-custom/src/test/java/smoketest/web/secure/custom/SampleWebSecureCustomApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-secure-custom/src/test/java/smoketest/web/secure/custom/SampleWebSecureCustomApplicationTests.java index fba5e85a934..fb57830c82b 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure-custom/src/test/java/smoketest/web/secure/custom/SampleWebSecureCustomApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure-custom/src/test/java/smoketest/web/secure/custom/SampleWebSecureCustomApplicationTests.java @@ -22,11 +22,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.http.client.HttpRedirects; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle b/smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle index 644dd152b57..fd358486631 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-secure-jdbc/build.gradle @@ -27,7 +27,7 @@ dependencies { runtimeOnly("com.h2database:h2") - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java index 31431712b43..db9e164e87b 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure-jdbc/src/test/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplicationTests.java @@ -22,11 +22,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.http.client.HttpRedirects; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/smoke-test/spring-boot-smoke-test-web-secure/build.gradle b/smoke-test/spring-boot-smoke-test-web-secure/build.gradle index 01dd72d0fcd..95140a5e62c 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-secure/build.gradle @@ -24,7 +24,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-security")) implementation(project(":starter:spring-boot-starter-webmvc")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation("org.apache.httpcomponents.client5:httpclient5") } diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractErrorPageTests.java index 9f99aff6c80..46f1a5dd297 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractErrorPageTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test; import tools.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractUnauthenticatedErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractUnauthenticatedErrorPageTests.java index 40f4d8ac45e..7fc24ab40a1 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractUnauthenticatedErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractUnauthenticatedErrorPageTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test; import tools.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/SampleWebSecureApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/SampleWebSecureApplicationTests.java index 8a6a6eaa4b4..a4e6db78ed8 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/SampleWebSecureApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/SampleWebSecureApplicationTests.java @@ -23,11 +23,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.http.client.HttpRedirects; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; diff --git a/smoke-test/spring-boot-smoke-test-web-static/build.gradle b/smoke-test/spring-boot-smoke-test-web-static/build.gradle index fcc13e4ae79..b1f5921363c 100644 --- a/smoke-test/spring-boot-smoke-test-web-static/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-static/build.gradle @@ -34,6 +34,6 @@ dependencies { runtimeOnly("org.webjars:bootstrap:3.0.3") runtimeOnly("org.webjars:jquery:2.0.3-1") - testImplementation(project(":starter:spring-boot-starter-restclient-test")) testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-static/src/test/java/smoketest/web/staticcontent/SampleWebStaticApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-static/src/test/java/smoketest/web/staticcontent/SampleWebStaticApplicationTests.java index 0a468cf3806..94d65e2156f 100644 --- a/smoke-test/spring-boot-smoke-test-web-static/src/test/java/smoketest/web/staticcontent/SampleWebStaticApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-static/src/test/java/smoketest/web/staticcontent/SampleWebStaticApplicationTests.java @@ -19,10 +19,10 @@ package smoketest.web.staticcontent; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-web-thymeleaf/build.gradle b/smoke-test/spring-boot-smoke-test-web-thymeleaf/build.gradle index f9f2c3bbfb6..84a1ccffbdf 100644 --- a/smoke-test/spring-boot-smoke-test-web-thymeleaf/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-thymeleaf/build.gradle @@ -26,6 +26,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-validation")) testImplementation(project(":module:spring-boot-webmvc-test")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":starter:spring-boot-starter-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-thymeleaf/src/test/java/smoketest/web/thymeleaf/SampleWebUiApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-thymeleaf/src/test/java/smoketest/web/thymeleaf/SampleWebUiApplicationTests.java index 8ce9e878dba..49658924c32 100644 --- a/smoke-test/spring-boot-smoke-test-web-thymeleaf/src/test/java/smoketest/web/thymeleaf/SampleWebUiApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-thymeleaf/src/test/java/smoketest/web/thymeleaf/SampleWebUiApplicationTests.java @@ -21,11 +21,11 @@ import java.net.URI; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.restclient.test.TestRestTemplate; -import org.springframework.boot.restclient.test.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.boot.testrestclient.TestRestTemplate; +import org.springframework.boot.testrestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.util.LinkedMultiValueMap; diff --git a/smoke-test/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt b/smoke-test/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt index 8db5abd9d49..f268ec97796 100644 --- a/smoke-test/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt +++ b/smoke-test/spring-boot-smoke-test-webflux-coroutines/src/test/kotlin/smoketest/coroutines/CoroutinesControllerTests.kt @@ -23,7 +23,7 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment import org.springframework.http.MediaType import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.test.web.reactive.server.expectBody -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @AutoConfigureWebTestClient diff --git a/smoke-test/spring-boot-smoke-test-webflux/build.gradle b/smoke-test/spring-boot-smoke-test-webflux/build.gradle index d2b360abe64..c90977d2a5d 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/build.gradle +++ b/smoke-test/spring-boot-smoke-test-webflux/build.gradle @@ -25,7 +25,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-mustache")) implementation(project(":starter:spring-boot-starter-webflux")) - testImplementation(project(":starter:spring-boot-starter-restclient-test")) + testImplementation(project(":module:spring-boot-resttestclient")) testImplementation(project(":starter:spring-boot-starter-test")) testImplementation(project(":starter:spring-boot-starter-webflux-test")) testImplementation("io.projectreactor:reactor-test") diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorDifferentPortTests.java b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorDifferentPortTests.java index 224b18fd7d8..80e14021063 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorDifferentPortTests.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorDifferentPortTests.java @@ -18,9 +18,9 @@ package smoketest.webflux; import org.junit.jupiter.api.Test; -import org.springframework.boot.restclient.test.TestRestTemplate; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalManagementPort; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorIsolatedObjectMapperFalseTests.java b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorIsolatedObjectMapperFalseTests.java index 9fe9e6a0312..e08400b8b13 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorIsolatedObjectMapperFalseTests.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorIsolatedObjectMapperFalseTests.java @@ -21,7 +21,7 @@ import tools.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorIsolatedObjectMapperTrueTests.java b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorIsolatedObjectMapperTrueTests.java index b68fe3c2264..1d9fa0afe74 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorIsolatedObjectMapperTrueTests.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationActuatorIsolatedObjectMapperTrueTests.java @@ -23,7 +23,7 @@ import tools.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.web.reactive.server.EntityExchangeResult; diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java index 92887e5ede8..61315cecc90 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java @@ -22,7 +22,7 @@ import reactor.core.publisher.Mono; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.AutoConfigureWebTestClient; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/starter/spring-boot-starter-webflux-test/build.gradle b/starter/spring-boot-starter-webflux-test/build.gradle index 4bc373d066d..82f992842ab 100644 --- a/starter/spring-boot-starter-webflux-test/build.gradle +++ b/starter/spring-boot-starter-webflux-test/build.gradle @@ -26,4 +26,5 @@ dependencies { api(project(":starter:spring-boot-starter-webflux")) api(project(":module:spring-boot-webflux-test")) + api(project(":module:spring-boot-webtestclient")) } diff --git a/starter/spring-boot-starter-webmvc-test/build.gradle b/starter/spring-boot-starter-webmvc-test/build.gradle index c76114cb402..47884c6f29c 100644 --- a/starter/spring-boot-starter-webmvc-test/build.gradle +++ b/starter/spring-boot-starter-webmvc-test/build.gradle @@ -26,4 +26,5 @@ dependencies { api(project(":starter:spring-boot-starter-webmvc")) api(project(":module:spring-boot-webmvc-test")) + api(project(":module:spring-boot-resttestclient")) } diff --git a/system-test/spring-boot-deployment-system-tests/build.gradle b/system-test/spring-boot-deployment-system-tests/build.gradle index fc2fe7657ac..4d0d6bf79b2 100644 --- a/system-test/spring-boot-deployment-system-tests/build.gradle +++ b/system-test/spring-boot-deployment-system-tests/build.gradle @@ -41,7 +41,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-actuator")) systemTestImplementation(enforcedPlatform(project(path: ":platform:spring-boot-internal-dependencies"))) - systemTestImplementation(project(":starter:spring-boot-starter-restclient-test")) + systemTestImplementation(project(":module:spring-boot-resttestclient")) systemTestImplementation(project(":starter:spring-boot-starter-test")) systemTestImplementation(project(":test-support:spring-boot-test-support")) systemTestImplementation("org.apache.httpcomponents.client5:httpclient5") diff --git a/system-test/spring-boot-deployment-system-tests/src/systemTest/java/org/springframework/boot/deployment/AbstractDeploymentTests.java b/system-test/spring-boot-deployment-system-tests/src/systemTest/java/org/springframework/boot/deployment/AbstractDeploymentTests.java index a0de6e87a3c..32e6405b2c2 100644 --- a/system-test/spring-boot-deployment-system-tests/src/systemTest/java/org/springframework/boot/deployment/AbstractDeploymentTests.java +++ b/system-test/spring-boot-deployment-system-tests/src/systemTest/java/org/springframework/boot/deployment/AbstractDeploymentTests.java @@ -32,7 +32,7 @@ import org.testcontainers.images.builder.ImageFromDockerfile; import org.testcontainers.images.builder.dockerfile.DockerfileBuilder; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.restclient.test.TestRestTemplate; +import org.springframework.boot.testrestclient.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;