Browse Source

Move `RestTestClientBuilderCustomizer` to `spring-boot-test`

Relocate `RestTestClientBuilderCustomizer` to `spring-boot-test`
and break the direct link to web-server by making use of
`spring.factories` and the new `BaseUrlProviders` class.

See gh-46356
pull/47381/head
Phillip Webb 3 months ago
parent
commit
bba56ffc8b
  1. 84
      core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/BaseUrlUriBuilderFactory.java
  2. 15
      core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientBuilderCustomizer.java
  3. 56
      core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizer.java
  4. 2
      core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerFactory.java
  5. 24
      core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/package-info.java
  6. 5
      core/spring-boot-test/src/main/resources/META-INF/spring.factories
  7. 2
      documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc
  8. 2
      documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-utilities.adoc
  9. 2
      documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.java
  10. 2
      documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java
  11. 2
      documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java
  12. 2
      documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt
  13. 2
      documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt
  14. 2
      documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt
  15. 3
      integration-test/spring-boot-test-integration-tests/build.gradle
  16. 2
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/NoTestRestTemplateBeanChecker.java
  17. 2
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerIntegrationTests.java
  18. 4
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerTests.java
  19. 4
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerWithFactoryBeanTests.java
  20. 2
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerWithOverrideIntegrationTests.java
  21. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/scan/SimpleFactoryBean.java
  22. 3
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/LocalHostUriTemplateHandlerTests.java
  23. 2
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/NoRestTestClientBeanChecker.java
  24. 6
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerIntegrationTests.java
  25. 4
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerTests.java
  26. 6
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithCustomContextPathIntegrationTests.java
  27. 6
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithOverridePathIntegrationTests.java
  28. 2
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/TestWebMvcConfiguration.java
  29. 2
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests.java
  30. 2
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestWebServerWebEnvironmentTests.java
  31. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/LocalManagementPortTests.java
  32. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/LocalServerPortTests.java
  33. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestRandomPortEnvironmentPostProcessorTests.java
  34. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentDefinedPortTests.java
  35. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentRandomPortTests.java
  36. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentUserDefinedTestRestTemplateTests.java
  37. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestUserDefinedTestRestTemplateTests.java
  38. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentContextHierarchyTests.java
  39. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentDefinedPortTests.java
  40. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentRandomPortCustomPortTests.java
  41. 0
      integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentRandomPortTests.java
  42. 3
      module/spring-boot-devtools/build.gradle
  43. 2
      module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java
  44. 2
      module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsWithLazyInitializationIntegrationTests.java
  45. 1
      module/spring-boot-mustache/build.gradle
  46. 2
      module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationServletIntegrationTests.java
  47. 7
      module/spring-boot-restclient-test/build.gradle
  48. 9
      module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplate.java
  49. 31
      module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizer.java
  50. 2
      module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerFactory.java
  51. 2
      module/spring-boot-restclient-test/src/main/kotlin/org/springframework/boot/restclient/test/TestRestTemplateExtensions.kt
  52. 4
      module/spring-boot-restclient-test/src/main/resources/META-INF/spring.factories
  53. 23
      module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateTests.java
  54. 1
      module/spring-boot-security/build.gradle
  55. 2
      module/spring-boot-security/src/test/java/org/springframework/boot/security/autoconfigure/servlet/SecurityFilterAutoConfigurationEarlyInitializationTests.java
  56. 2
      module/spring-boot-web-server-test/build.gradle
  57. 2
      module/spring-boot-web-server-test/src/main/resources/META-INF/spring.factories
  58. 3
      module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/reactive/context/ReactiveWebServerApplicationContextBaseUrlProvider.java
  59. 3
      module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/servlet/context/ServletWebServerApplicationContextBaseUrlProvider.java
  60. 2
      module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java
  61. 1
      module/spring-boot-webmvc/build.gradle
  62. 2
      module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WelcomePageIntegrationTests.java
  63. 2
      module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java
  64. 2
      module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/RemappedErrorViewIntegrationTests.java
  65. 2
      smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java
  66. 2
      smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/CorsSampleActuatorApplicationTests.java
  67. 2
      smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortAndPathSampleActuatorApplicationTests.java
  68. 2
      smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/ManagementPortCustomServletPathSampleActuatorTests.java
  69. 2
      smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java
  70. 2
      smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java
  71. 2
      smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java
  72. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/AbstractManagementPortAndPathSampleActuatorApplicationTests.java
  73. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/CorsSampleActuatorApplicationTests.java
  74. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java
  75. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementAddressActuatorApplicationTests.java
  76. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java
  77. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java
  78. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPathSampleActuatorApplicationTests.java
  79. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortSampleActuatorApplicationTests.java
  80. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortWithLazyInitializationTests.java
  81. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/NoManagementSampleActuatorApplicationTests.java
  82. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperFalseTests.java
  83. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperTrueTests.java
  84. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationTests.java
  85. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ServletPathSampleActuatorApplicationTests.java
  86. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ShutdownSampleActuatorApplicationTests.java
  87. 2
      smoke-test/spring-boot-smoke-test-devtools/src/test/java/smoketest/devtools/SampleDevToolsApplicationIntegrationTests.java
  88. 2
      smoke-test/spring-boot-smoke-test-hateoas/src/test/java/smoketest/hateoas/SampleHateoasApplicationTests.java
  89. 2
      smoke-test/spring-boot-smoke-test-jetty-jsp/src/test/java/smoketest/jetty/jsp/SampleWebJspApplicationTests.java
  90. 2
      smoke-test/spring-boot-smoke-test-jetty-ssl/src/test/java/smoketest/jetty/ssl/SampleJettySslApplicationTests.java
  91. 2
      smoke-test/spring-boot-smoke-test-jetty/src/test/java/smoketest/jetty/SampleJettyApplicationTests.java
  92. 2
      smoke-test/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java
  93. 2
      smoke-test/spring-boot-smoke-test-oauth2-client/src/test/java/smoketest/oauth2/client/SampleOAuth2ClientApplicationTests.java
  94. 2
      smoke-test/spring-boot-smoke-test-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleOauth2ResourceServerApplicationTests.java
  95. 2
      smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java
  96. 2
      smoke-test/spring-boot-smoke-test-quartz/src/test/java/smoketest/quartz/SampleQuartzApplicationWebTests.java
  97. 2
      smoke-test/spring-boot-smoke-test-saml2-service-provider/src/test/java/smoketest/saml2/serviceprovider/SampleSaml2RelyingPartyApplicationTests.java
  98. 2
      smoke-test/spring-boot-smoke-test-servlet/src/test/java/smoketest/servlet/SampleServletApplicationTests.java
  99. 2
      smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java
  100. 2
      smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java
  101. Some files were not shown because too many files have changed in this diff Show More

84
core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/BaseUrlUriBuilderFactory.java

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
/*
* 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.net.URI;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.test.http.server.BaseUrl;
import org.springframework.util.Assert;
import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriBuilder;
import org.springframework.web.util.UriBuilderFactory;
import org.springframework.web.util.UriComponentsBuilder;
/**
* {@link UriBuilderFactory} to support {@link BaseUrl}.
*
* @author Phillip Webb
* @since 4.0.0
*/
public class BaseUrlUriBuilderFactory implements UriBuilderFactory {
private final UriBuilderFactory delegate;
private final BaseUrl baseUrl;
/**
* Create a new {@link BaseUrlUriBuilderFactory} instance.
* @param delegate the delegate {@link UriBuilderFactory}
* @param baseUrl the base URL to use
*/
public BaseUrlUriBuilderFactory(UriBuilderFactory delegate, BaseUrl baseUrl) {
Assert.notNull(delegate, "'delegate' must not be null");
Assert.notNull(baseUrl, "'baseUrl' must not be null");
this.delegate = delegate;
this.baseUrl = baseUrl;
}
@Override
public UriBuilder uriString(String uriTemplate) {
return UriComponentsBuilder.fromUriString(apply(uriTemplate));
}
@Override
public UriBuilder builder() {
return UriComponentsBuilder.newInstance();
}
@Override
public URI expand(String uriTemplate, Map<String, ?> uriVariables) {
return this.delegate.expand(apply(uriTemplate), uriVariables);
}
@Override
public URI expand(String uriTemplate, @Nullable Object... uriVariables) {
return this.delegate.expand(apply(uriTemplate), uriVariables);
}
String apply(String uriTemplate) {
return (uriTemplate.startsWith("/")) ? this.baseUrl.resolve(uriTemplate) : uriTemplate;
}
public static UriBuilderFactory get(@Nullable BaseUrl baseUrl) {
DefaultUriBuilderFactory delegate = new DefaultUriBuilderFactory();
return (baseUrl != null) ? new BaseUrlUriBuilderFactory(delegate, baseUrl) : delegate;
}
}

15
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/client/RestTestClientBuilderCustomizer.java → core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientBuilderCustomizer.java

@ -14,14 +14,17 @@ @@ -14,14 +14,17 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
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-tine its auto-configuration before a
* {@link RestTestClient} is created.
* A customizer that can be implemented by beans wishing to customize the {@link 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}.
*
* @author Stephane Nicoll
* @since 4.0.0
@ -30,9 +33,9 @@ import org.springframework.test.web.servlet.client.RestTestClient; @@ -30,9 +33,9 @@ import org.springframework.test.web.servlet.client.RestTestClient;
public interface RestTestClientBuilderCustomizer {
/**
* Customize the given {@link RestTestClient.Builder Builder}.
* Customize the given {@link Builder Builder}.
* @param builder the builder
*/
void customize(RestTestClient.Builder<?> builder);
void customize(Builder<?> builder);
}

56
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/client/RestTestClientContextCustomizer.java → core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizer.java

@ -14,7 +14,10 @@ @@ -14,7 +14,10 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import java.util.ArrayList;
import java.util.List;
import org.jspecify.annotations.Nullable;
@ -25,20 +28,21 @@ import org.springframework.beans.factory.BeanFactoryAware; @@ -25,20 +28,21 @@ 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.NoSuchBeanDefinitionException;
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.restclient.RootUriBuilderFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.reactive.AbstractReactiveWebServerFactory;
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;
@ -49,6 +53,7 @@ import org.springframework.util.Assert; @@ -49,6 +53,7 @@ import org.springframework.util.Assert;
* {@link ContextCustomizer} for {@link RestTestClient}.
*
* @author Stephane Nicoll
* @author Phillip Webb
*/
class RestTestClientContextCustomizer implements ContextCustomizer {
@ -95,8 +100,7 @@ class RestTestClientContextCustomizer implements ContextCustomizer { @@ -95,8 +100,7 @@ class RestTestClientContextCustomizer implements ContextCustomizer {
*/
static class RestTestClientRegistrar implements BeanDefinitionRegistryPostProcessor, Ordered, BeanFactoryAware {
@SuppressWarnings("NullAway.Init")
private BeanFactory beanFactory;
private @Nullable BeanFactory beanFactory;
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
@ -110,7 +114,7 @@ class RestTestClientContextCustomizer implements ContextCustomizer { @@ -110,7 +114,7 @@ class RestTestClientContextCustomizer implements ContextCustomizer {
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
if (AotDetector.useGeneratedArtifacts()) {
if (this.beanFactory == null || AotDetector.useGeneratedArtifacts()) {
return;
}
if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) this.beanFactory,
@ -132,8 +136,7 @@ class RestTestClientContextCustomizer implements ContextCustomizer { @@ -132,8 +136,7 @@ class RestTestClientContextCustomizer implements ContextCustomizer {
*/
public static class RestTestClientFactory implements FactoryBean<RestTestClient>, ApplicationContextAware {
@SuppressWarnings("NullAway.Init")
private ApplicationContext applicationContext;
private @Nullable ApplicationContext applicationContext;
private @Nullable RestTestClient object;
@ -161,32 +164,27 @@ class RestTestClientContextCustomizer implements ContextCustomizer { @@ -161,32 +164,27 @@ class RestTestClientContextCustomizer implements ContextCustomizer {
}
private RestTestClient createRestTestClient() {
boolean sslEnabled = isSslEnabled(this.applicationContext);
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(
this.applicationContext.getEnvironment(), sslEnabled ? "https" : "http");
Assert.state(this.applicationContext != null, "ApplicationContext not injected");
RestTestClient.Builder<?> builder = RestTestClient.bindToServer();
customizeRestTestClientBuilder(builder, this.applicationContext);
return builder.uriBuilderFactory(new RootUriBuilderFactory(handler.getRootUri(), handler)).build();
}
private boolean isSslEnabled(ApplicationContext context) {
try {
AbstractReactiveWebServerFactory webServerFactory = context
.getBean(AbstractReactiveWebServerFactory.class);
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
}
catch (NoSuchBeanDefinitionException ex) {
return false;
}
BaseUrl baseUrl = new BaseUrlProviders(this.applicationContext).getBaseUrl();
return builder.uriBuilderFactory(BaseUrlUriBuilderFactory.get(baseUrl)).build();
}
private void customizeRestTestClientBuilder(RestTestClient.Builder<?> clientBuilder,
ApplicationContext context) {
for (RestTestClientBuilderCustomizer customizer : context
.getBeansOfType(RestTestClientBuilderCustomizer.class)
.values()) {
customizer.customize(clientBuilder);
}
Assert.state(this.applicationContext != null, "ApplicationContext not injected");
getRestTestClientBuilderCustomizers(this.applicationContext)
.forEach((customizer) -> customizer.customize(clientBuilder));
}
private List<RestTestClientBuilderCustomizer> getRestTestClientBuilderCustomizers(ApplicationContext context) {
List<RestTestClientBuilderCustomizer> customizers = new ArrayList<>();
SpringFactoriesLoader.forDefaultResourceLocation(context.getClassLoader())
.load(RestTestClientBuilderCustomizer.class, ArgumentResolver.of(ApplicationContext.class, context))
.forEach(customizers::add);
context.getBeansOfType(RestTestClientBuilderCustomizer.class).values().forEach(customizers::add);
return customizers;
}
}

2
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/client/RestTestClientContextCustomizerFactory.java → core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerFactory.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import java.util.List;

24
core/spring-boot-test/src/main/java/org/springframework/boot/test/web/servlet/client/package-info.java

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
/*
* 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.
*/
/**
* Spring Boot support for testing Spring Servlet server endpoints via
* {@link org.springframework.test.web.servlet.client.RestTestClient}.
*/
@NullMarked
package org.springframework.boot.test.web.servlet.client;
import org.jspecify.annotations.NullMarked;

5
core/spring-boot-test/src/main/resources/META-INF/spring.factories

@ -5,8 +5,9 @@ org.springframework.boot.test.context.PropertyMappingContextCustomizerFactory,\ @@ -5,8 +5,9 @@ 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.json.DuplicateJsonObjectContextCustomizerFactory,\
org.springframework.boot.test.web.reactive.client.WebTestClientContextCustomizerFactory
org.springframework.boot.test.web.reactive.client.WebTestClientContextCustomizerFactory,\
org.springframework.boot.test.web.servlet.client.RestTestClientContextCustomizerFactory
# Application Context Initializers
org.springframework.context.ApplicationContextInitializer=\
org.springframework.boot.test.context.filter.ExcludeFilterApplicationContextInitializer
org.springframework.boot.test.context.filter.ExcludeFilterApplicationContextInitializer

2
documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc

@ -189,7 +189,7 @@ include-code::MyRandomPortWebTestClientTests[] @@ -189,7 +189,7 @@ include-code::MyRandomPortWebTestClientTests[]
TIP: javadoc:org.springframework.test.web.reactive.server.WebTestClient[] can also used with a xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-mock-environment[mock environment], removing the need for a running server, by annotating your test class with javadoc:org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient[format=annotation] from `spring-boot-webflux-test`.
The `spring-boot-web-server-test` modules also provides a javadoc:org.springframework.boot.web.server.test.client.TestRestTemplate[] facility:
The `spring-boot-retclient-test` modules also provides a javadoc:org.springframework.boot.restclient.test.TestRestTemplate[] facility:
include-code::MyRandomPortTestRestTemplateTests[]

2
documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-utilities.adoc

@ -43,6 +43,8 @@ include-code::MyOutputCaptureTests[] @@ -43,6 +43,8 @@ include-code::MyOutputCaptureTests[]
== TestRestTemplate
javadoc:org.springframework.boot.test.web.client.TestRestTemplate[] is a convenience alternative to Spring's javadoc:org.springframework.web.client.RestTemplate[] that is useful in integration tests.
It's provided by the `spring-boot-restclient-test` module.
You can get a vanilla template or one that sends Basic HTTP authentication (with a username and password).
In either case, the template is fault tolerant.
This means that it behaves in a test-friendly way by not throwing exceptions on 4xx and 5xx errors.

2
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 @@ -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.web.server.test.client.TestRestTemplate;
import static org.assertj.core.api.Assertions.assertThat;

2
documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java

@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; @@ -22,10 +22,10 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpHeaders;

2
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; @@ -18,7 +18,7 @@ package org.springframework.boot.docs.testing.utilities.testresttemplate;
import org.junit.jupiter.api.Test;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.boot.restclient.test.TestRestTemplate;
import org.springframework.http.ResponseEntity;
import static org.assertj.core.api.Assertions.assertThat;

2
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 @@ -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.web.server.test.client.TestRestTemplate
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
class MyRandomPortTestRestTemplateTests {

2
documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt

@ -22,8 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired @@ -22,8 +22,8 @@ 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.test.context.TestConfiguration
import org.springframework.boot.web.server.test.client.TestRestTemplate
import org.springframework.boot.restclient.RestTemplateBuilder
import org.springframework.boot.restclient.test.TestRestTemplate
import org.springframework.context.annotation.Bean
import java.time.Duration

2
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 @@ -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.web.server.test.client.TestRestTemplate
import org.springframework.boot.restclient.test.TestRestTemplate
class MyTests {

3
integration-test/spring-boot-test-integration-tests/build.gradle

@ -22,11 +22,14 @@ plugins { @@ -22,11 +22,14 @@ plugins {
description = "Spring Boot Test Integration Tests"
dependencies {
testImplementation(project(":core:spring-boot-autoconfigure"))
testImplementation(project(":core:spring-boot-test"))
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-tomcat"))
testImplementation(project(":module:spring-boot-web-server"))
testImplementation(project(":module:spring-boot-web-server-test"))
testImplementation("io.projectreactor.netty:reactor-netty-http")
testImplementation("org.springframework:spring-webmvc")
testImplementation("org.springframework:spring-webflux")

2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/NoTestRestTemplateBeanChecker.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/NoTestRestTemplateBeanChecker.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/TestRestTemplateContextCustomizerIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerIntegrationTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import java.io.IOException;
import java.io.PrintWriter;

4
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/TestRestTemplateContextCustomizerTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerTests.java

@ -14,16 +14,16 @@ @@ -14,16 +14,16 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.restclient.test.TestRestTemplateContextCustomizer.TestRestTemplateRegistrar;
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.web.server.test.client.TestRestTemplateContextCustomizer.TestRestTemplateRegistrar;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.test.context.MergedContextConfiguration;

4
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/TestRestTemplateContextCustomizerWithFactoryBeanTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerWithFactoryBeanTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import org.junit.jupiter.api.Test;
@ -49,7 +49,7 @@ class TestRestTemplateContextCustomizerWithFactoryBeanTests { @@ -49,7 +49,7 @@ class TestRestTemplateContextCustomizerWithFactoryBeanTests {
}
@Configuration(proxyBeanMethods = false)
@ComponentScan("org.springframework.boot.test.web.client.scan")
@ComponentScan("org.springframework.boot.test.scan")
static class TestClassWithFactoryBean {
@Bean

2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/TestRestTemplateContextCustomizerWithOverrideIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerWithOverrideIntegrationTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import java.io.IOException;
import java.io.PrintWriter;

0
module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/scan/SimpleFactoryBean.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/restclient/test/scan/SimpleFactoryBean.java

3
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/LocalHostUriTemplateHandlerTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/LocalHostUriTemplateHandlerTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import java.net.URI;
import java.util.HashMap;
@ -22,6 +22,7 @@ import java.util.Map; @@ -22,6 +22,7 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.boot.web.server.test.client.LocalHostUriTemplateHandler;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.web.util.UriTemplateHandler;

2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/NoRestTestClientBeanChecker.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/NoRestTestClientBeanChecker.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

6
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/RestTestClientContextCustomizerIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerIntegrationTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import org.junit.jupiter.api.Test;
@ -43,7 +43,7 @@ import static org.mockito.Mockito.mock; @@ -43,7 +43,7 @@ import static org.mockito.Mockito.mock;
class RestTestClientContextCustomizerIntegrationTests {
@Autowired
private RestTestClient webClient;
private RestTestClient restClient;
@Autowired
private RestTestClientBuilderCustomizer clientBuilderCustomizer;
@ -51,7 +51,7 @@ class RestTestClientContextCustomizerIntegrationTests { @@ -51,7 +51,7 @@ class RestTestClientContextCustomizerIntegrationTests {
@Test
void test() {
then(this.clientBuilderCustomizer).should().customize(any(RestTestClient.Builder.class));
this.webClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello");
this.restClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello");
}
@Configuration(proxyBeanMethods = false)

4
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/RestTestClientContextCustomizerTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import org.junit.jupiter.api.Test;
@ -23,7 +23,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -23,7 +23,7 @@ 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.web.server.test.client.RestTestClientContextCustomizer.RestTestClientRegistrar;
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;

6
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/RestTestClientContextCustomizerWithCustomContextPathIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithCustomContextPathIntegrationTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import org.junit.jupiter.api.Test;
@ -45,11 +45,11 @@ import org.springframework.web.servlet.DispatcherServlet; @@ -45,11 +45,11 @@ import org.springframework.web.servlet.DispatcherServlet;
class RestTestClientContextCustomizerWithCustomContextPathIntegrationTests {
@Autowired
private RestTestClient webClient;
private RestTestClient restClient;
@Test
void test() {
this.webClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello");
this.restClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello");
}
@Configuration(proxyBeanMethods = false)

6
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/RestTestClientContextCustomizerWithOverridePathIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/RestTestClientContextCustomizerWithOverridePathIntegrationTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import org.junit.jupiter.api.Test;
@ -40,11 +40,11 @@ import static org.mockito.Mockito.mock; @@ -40,11 +40,11 @@ import static org.mockito.Mockito.mock;
class RestTestClientContextCustomizerWithOverridePathIntegrationTests {
@Autowired
private RestTestClient webClient;
private RestTestClient restClient;
@Test
void test() {
assertThat(this.webClient).isInstanceOf(CustomRestTestClient.class);
assertThat(this.restClient).isInstanceOf(CustomRestTestClient.class);
}
@Configuration(proxyBeanMethods = false)

2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/TestWebMvcConfiguration.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/servlet/client/TestWebMvcConfiguration.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.test.web.servlet.client;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory;

2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests.java

@ -23,11 +23,11 @@ import reactor.core.publisher.Mono; @@ -23,11 +23,11 @@ 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.test.context.SpringBootTest;
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.web.server.test.client.TestRestTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestWebServerWebEnvironmentTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/AbstractSpringBootTestWebServerWebEnvironmentTests.java

@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test; @@ -21,10 +21,10 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.servlet.ServletWebServerFactory;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/LocalManagementPortTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/LocalManagementPortTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/LocalServerPortTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/LocalServerPortTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestRandomPortEnvironmentPostProcessorTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestRandomPortEnvironmentPostProcessorTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentDefinedPortTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentDefinedPortTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentRandomPortTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentRandomPortTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentUserDefinedTestRestTemplateTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestReactiveWebEnvironmentUserDefinedTestRestTemplateTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestUserDefinedTestRestTemplateTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestUserDefinedTestRestTemplateTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentContextHierarchyTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentContextHierarchyTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentDefinedPortTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentDefinedPortTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentRandomPortCustomPortTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentRandomPortCustomPortTests.java

0
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentRandomPortTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/web/server/test/SpringBootTestWebEnvironmentRandomPortTests.java

3
module/spring-boot-devtools/build.gradle

@ -55,8 +55,9 @@ dependencies { @@ -55,8 +55,9 @@ dependencies {
intTestImplementation(project(":core:spring-boot-autoconfigure"))
intTestImplementation(project(":core:spring-boot-test"))
intTestImplementation(project(":module:spring-boot-restclient"))
intTestImplementation(project(":test-support:spring-boot-test-support"))
intTestImplementation(project(":module:spring-boot-restclient-test"))
intTestImplementation(project(":module:spring-boot-web-server-test"))
intTestImplementation(project(":test-support:spring-boot-test-support"))
intTestImplementation("org.apache.httpcomponents.client5:httpclient5")
intTestImplementation("net.bytebuddy:byte-buddy")

2
module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java

@ -26,7 +26,7 @@ import org.junit.jupiter.params.ParameterizedTest; @@ -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.web.server.test.client.TestRestTemplate;
import org.springframework.boot.restclient.test.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;

2
module/spring-boot-devtools/src/intTest/java/org/springframework/boot/devtools/tests/DevToolsWithLazyInitializationIntegrationTests.java

@ -19,7 +19,7 @@ package org.springframework.boot.devtools.tests; @@ -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.web.server.test.client.TestRestTemplate;
import org.springframework.boot.restclient.test.TestRestTemplate;
import org.springframework.http.HttpStatus;
import static org.assertj.core.api.Assertions.assertThat;

1
module/spring-boot-mustache/build.gradle

@ -38,6 +38,7 @@ dependencies { @@ -38,6 +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-tomcat"))
testImplementation(project(":module:spring-boot-webflux-test"))
testImplementation(project(":module:spring-boot-webmvc-test"))

2
module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheAutoConfigurationServletIntegrationTests.java

@ -30,11 +30,11 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -30,11 +30,11 @@ 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.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

7
module/spring-boot-restclient-test/build.gradle

@ -15,7 +15,9 @@ @@ -15,7 +15,9 @@
*/
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"
@ -24,12 +26,15 @@ plugins { @@ -24,12 +26,15 @@ plugins {
description = "Spring Boot RestClient Test"
dependencies {
api(project(":core:spring-boot"))
api(project(":core:spring-boot-test-autoconfigure"))
api(project(":module:spring-boot-restclient"))
optional(project(":core:spring-boot-autoconfigure"))
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")

9
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/client/TestRestTemplate.java → module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplate.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import java.net.URI;
import java.security.KeyManagementException;
@ -1006,11 +1006,10 @@ public class TestRestTemplate { @@ -1006,11 +1006,10 @@ public class TestRestTemplate {
}
private URI applyRootUriIfNecessary(URI uri) {
UriTemplateHandler uriTemplateHandler = this.restTemplate.getUriTemplateHandler();
if ((uriTemplateHandler instanceof RootUriTemplateHandler rootHandler) && uri.toString().startsWith("/")) {
return URI.create(rootHandler.getRootUri() + uri);
if (!uri.toString().startsWith("/")) {
return uri;
}
return uri;
return URI.create(this.restTemplate.getUriTemplateHandler().expand("/") + uri.toString().substring(1));
}
private URI resolveUri(RequestEntity<?> entity) {

31
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/client/TestRestTemplateContextCustomizer.java → module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizer.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import org.jspecify.annotations.Nullable;
@ -32,9 +32,11 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -32,9 +32,11 @@ 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.restclient.RestTemplateBuilder;
import org.springframework.boot.restclient.test.TestRestTemplate.HttpClientOption;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory;
import org.springframework.boot.web.server.test.client.TestRestTemplate.HttpClientOption;
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.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
@ -120,7 +122,6 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer { @@ -120,7 +122,6 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer {
registry.registerBeanDefinition(TestRestTemplate.class.getName(),
new RootBeanDefinition(TestRestTemplateFactory.class));
}
}
@Override
@ -144,24 +145,10 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer { @@ -144,24 +145,10 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer {
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
RestTemplateBuilder builder = getRestTemplateBuilder(applicationContext);
boolean sslEnabled = isSslEnabled(applicationContext);
TestRestTemplate template = new TestRestTemplate(builder, null, null,
sslEnabled ? SSL_OPTIONS : DEFAULT_OPTIONS);
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(applicationContext.getEnvironment(),
sslEnabled ? "https" : "http");
template.setUriTemplateHandler(handler);
this.template = template;
}
private boolean isSslEnabled(ApplicationContext context) {
try {
AbstractConfigurableWebServerFactory webServerFactory = context
.getBean(AbstractConfigurableWebServerFactory.class);
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
}
catch (NoSuchBeanDefinitionException ex) {
return false;
}
BaseUrl baseUrl = new BaseUrlProviders(applicationContext).getBaseUrlOrDefault();
boolean sslEnabled = baseUrl != null && baseUrl.isHttps();
this.template = new TestRestTemplate(builder, null, null, sslEnabled ? SSL_OPTIONS : DEFAULT_OPTIONS);
this.template.setUriTemplateHandler(BaseUrlUriBuilderFactory.get(baseUrl));
}
private RestTemplateBuilder getRestTemplateBuilder(ApplicationContext applicationContext) {

2
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/client/TestRestTemplateContextCustomizerFactory.java → module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/TestRestTemplateContextCustomizerFactory.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import java.util.List;

2
module/spring-boot-web-server-test/src/main/kotlin/org/springframework/boot/web/server/test/client/TestRestTemplateExtensions.kt → module/spring-boot-restclient-test/src/main/kotlin/org/springframework/boot/restclient/test/TestRestTemplateExtensions.kt

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client
package org.springframework.boot.restclient.test
import org.springframework.core.ParameterizedTypeReference
import org.springframework.http.HttpEntity

4
module/spring-boot-restclient-test/src/main/resources/META-INF/spring.factories

@ -1,3 +1,7 @@ @@ -1,3 +1,7 @@
# Spring Test Execution Listeners
org.springframework.test.context.TestExecutionListener=\
org.springframework.boot.restclient.test.autoconfigure.MockRestServiceServerResetTestExecutionListener
# Spring Test Context Customizer Factories
org.springframework.test.context.ContextCustomizerFactory=\
org.springframework.boot.restclient.test.TestRestTemplateContextCustomizerFactory

23
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/TestRestTemplateTests.java → module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/TestRestTemplateTests.java

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.web.server.test.client;
package org.springframework.boot.restclient.test;
import java.io.IOException;
import java.lang.reflect.Method;
@ -36,7 +36,9 @@ import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; @@ -36,7 +36,9 @@ 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.web.server.test.client.TestRestTemplate.HttpClientOption;
import org.springframework.boot.restclient.test.TestRestTemplate.HttpClientOption;
import org.springframework.boot.test.http.server.BaseUrl;
import org.springframework.boot.test.web.servlet.client.BaseUrlUriBuilderFactory;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@ -48,7 +50,6 @@ import org.springframework.http.client.ClientHttpRequestFactory; @@ -48,7 +50,6 @@ import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.mock.http.client.MockClientHttpResponse;
import org.springframework.test.util.ReflectionTestUtils;
@ -118,16 +119,6 @@ class TestRestTemplateTests { @@ -118,16 +119,6 @@ class TestRestTemplateTests {
assertThat(new TestRestTemplate(delegate).getRootUri()).isEqualTo(rootUri);
}
@Test
void getRootUriRootUriSetViaLocalHostUriTemplateHandler() {
String rootUri = "https://example.com";
TestRestTemplate template = new TestRestTemplate();
LocalHostUriTemplateHandler templateHandler = mock(LocalHostUriTemplateHandler.class);
given(templateHandler.getRootUri()).willReturn(rootUri);
template.setUriTemplateHandler(templateHandler);
assertThat(template.getRootUri()).isEqualTo(rootUri);
}
@Test
void getRootUriRootUriNotSet() {
assertThat(new TestRestTemplate().getRootUri()).isEmpty();
@ -348,8 +339,7 @@ class TestRestTemplateTests { @@ -348,8 +339,7 @@ class TestRestTemplateTests {
URI absoluteUri = URI.create("http://localhost:8080/a/b/c.txt");
given(requestFactory.createRequest(eq(absoluteUri), eq(HttpMethod.GET))).willReturn(request);
template.getRestTemplate().setRequestFactory(requestFactory);
LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment());
template.setUriTemplateHandler(uriTemplateHandler);
template.setUriTemplateHandler(BaseUrlUriBuilderFactory.get(BaseUrl.of("http://localhost:8080")));
template.exchange(entity, String.class);
then(requestFactory).should().createRequest(eq(absoluteUri), eq(HttpMethod.GET));
}
@ -464,8 +454,7 @@ class TestRestTemplateTests { @@ -464,8 +454,7 @@ class TestRestTemplateTests {
given(requestFactory.createRequest(eq(absoluteUri), any(HttpMethod.class))).willReturn(request);
TestRestTemplate template = new TestRestTemplate();
template.getRestTemplate().setRequestFactory(requestFactory);
LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment());
template.setUriTemplateHandler(uriTemplateHandler);
template.setUriTemplateHandler(BaseUrlUriBuilderFactory.get(BaseUrl.of("http://localhost:8080")));
callback.doWithTestRestTemplate(template, URI.create("/a/b/c.txt?param=%7Bsomething%7D"));
then(requestFactory).should().createRequest(eq(absoluteUri), any(HttpMethod.class));
}

1
module/spring-boot-security/build.gradle

@ -35,6 +35,7 @@ dependencies { @@ -35,6 +35,7 @@ dependencies {
optional(project(":module:spring-boot-actuator-autoconfigure"))
optional(project(":module:spring-boot-h2console"))
optional(project(":module:spring-boot-reactor"))
optional(project(":module:spring-boot-restclient-test"))
optional(project(":module:spring-boot-rsocket"))
optional(project(":module:spring-boot-webflux"))
optional(project(":module:spring-boot-webmvc"))

2
module/spring-boot-security/src/test/java/org/springframework/boot/security/autoconfigure/servlet/SecurityFilterAutoConfigurationEarlyInitializationTests.java

@ -31,6 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; @@ -31,6 +31,7 @@ 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;
@ -38,7 +39,6 @@ import org.springframework.boot.testsupport.classpath.ClassPathExclusions; @@ -38,7 +39,6 @@ import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories;
import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration;
import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;

2
module/spring-boot-web-server-test/build.gradle

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
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-auto-configuration"
@ -35,7 +34,6 @@ dependencies { @@ -35,7 +34,6 @@ dependencies {
optional(project(":module:spring-boot-web-server"))
optional(project(":module:spring-boot-webclient"))
optional("jakarta.servlet:jakarta.servlet-api")
optional("org.apache.httpcomponents.client5:httpclient5")
optional("org.htmlunit:htmlunit")
optional("org.jetbrains.kotlin:kotlin-reflect")
optional("org.jetbrains.kotlin:kotlin-stdlib")

2
module/spring-boot-web-server-test/src/main/resources/META-INF/spring.factories

@ -4,6 +4,4 @@ org.springframework.boot.web.server.test.SpringBootTestRandomPortEnvironmentPost @@ -4,6 +4,4 @@ org.springframework.boot.web.server.test.SpringBootTestRandomPortEnvironmentPost
# Spring Test Context Customizer Factories
org.springframework.test.context.ContextCustomizerFactory=\
org.springframework.boot.web.server.test.client.RestTestClientContextCustomizerFactory,\
org.springframework.boot.web.server.test.client.TestRestTemplateContextCustomizerFactory,\
org.springframework.boot.web.server.test.reactor.netty.DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory

3
module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/reactive/context/ReactiveWebServerApplicationContextBaseUrlProvider.java

@ -22,7 +22,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -22,7 +22,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.test.http.server.BaseUrl;
import org.springframework.boot.test.http.server.BaseUrlProvider;
import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory;
import org.springframework.boot.web.server.reactive.AbstractReactiveWebServerFactory;
import org.springframework.context.ApplicationContext;
/**
@ -65,7 +64,7 @@ class ReactiveWebServerApplicationContextBaseUrlProvider implements BaseUrlProvi @@ -65,7 +64,7 @@ class ReactiveWebServerApplicationContextBaseUrlProvider implements BaseUrlProvi
private boolean isSslEnabled(ReactiveWebServerApplicationContext context) {
try {
AbstractConfigurableWebServerFactory webServerFactory = context
.getBean(AbstractReactiveWebServerFactory.class);
.getBean(AbstractConfigurableWebServerFactory.class);
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
}
catch (NoSuchBeanDefinitionException ex) {

3
module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/servlet/context/ServletWebServerApplicationContextBaseUrlProvider.java

@ -22,7 +22,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -22,7 +22,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.test.http.server.BaseUrl;
import org.springframework.boot.test.http.server.BaseUrlProvider;
import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory;
import org.springframework.boot.web.server.reactive.AbstractReactiveWebServerFactory;
import org.springframework.context.ApplicationContext;
/**
@ -65,7 +64,7 @@ class ServletWebServerApplicationContextBaseUrlProvider implements BaseUrlProvid @@ -65,7 +64,7 @@ class ServletWebServerApplicationContextBaseUrlProvider implements BaseUrlProvid
private boolean isSslEnabled(ServletWebServerApplicationContext context) {
try {
AbstractConfigurableWebServerFactory webServerFactory = context
.getBean(AbstractReactiveWebServerFactory.class);
.getBean(AbstractConfigurableWebServerFactory.class);
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
}
catch (NoSuchBeanDefinitionException ex) {

2
module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java

@ -22,7 +22,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -22,7 +22,7 @@ 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.web.server.test.client.RestTestClientBuilderCustomizer;
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;

1
module/spring-boot-webmvc/build.gradle

@ -53,6 +53,7 @@ dependencies { @@ -53,6 +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-tomcat"))
testImplementation(project(":module:spring-boot-web-server-test"))
testImplementation(project(":test-support:spring-boot-test-support"))

2
module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/WelcomePageIntegrationTests.java

@ -23,12 +23,12 @@ import org.junit.jupiter.api.Test; @@ -23,12 +23,12 @@ 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.testsupport.classpath.resources.WithResource;
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
import org.springframework.boot.web.server.context.WebServerApplicationContext;
import org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;

2
module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java

@ -40,11 +40,11 @@ import org.springframework.boot.SpringApplication; @@ -40,11 +40,11 @@ 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.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.error.ErrorAttributeOptions.Include;
import org.springframework.boot.web.server.autoconfigure.ServerProperties;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration;
import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration;
import org.springframework.boot.webmvc.error.ErrorAttributes;

2
module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/RemappedErrorViewIntegrationTests.java

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test; @@ -21,6 +21,7 @@ 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.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
@ -28,7 +29,6 @@ import org.springframework.boot.web.error.ErrorPage; @@ -28,7 +29,6 @@ import org.springframework.boot.web.error.ErrorPage;
import org.springframework.boot.web.error.ErrorPageRegistrar;
import org.springframework.boot.web.error.ErrorPageRegistry;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration;
import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Configuration;

2
smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java

@ -20,8 +20,8 @@ import java.util.Map; @@ -20,8 +20,8 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.boot.restclient.test.TestRestTemplate;
import org.springframework.boot.web.server.test.client.LocalHostUriTemplateHandler;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/CorsSampleActuatorApplicationTests.java

@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test; @@ -24,9 +24,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.web.server.test.client.LocalHostUriTemplateHandler;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity;

2
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; @@ -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.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
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; @@ -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.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java

@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test; @@ -22,10 +22,10 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.LocalHostUriTemplateHandler;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java

@ -21,11 +21,11 @@ import java.util.Map; @@ -21,11 +21,11 @@ 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.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java

@ -22,9 +22,9 @@ import java.util.Map; @@ -22,9 +22,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.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/AbstractManagementPortAndPathSampleActuatorApplicationTests.java

@ -21,9 +21,9 @@ import java.util.Map; @@ -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.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/CorsSampleActuatorApplicationTests.java

@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test; @@ -24,9 +24,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.web.server.test.client.LocalHostUriTemplateHandler;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java

@ -21,9 +21,9 @@ import java.util.Map; @@ -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.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementAddressActuatorApplicationTests.java

@ -20,11 +20,11 @@ import java.util.Map; @@ -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.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java

@ -18,9 +18,9 @@ package smoketest.actuator; @@ -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.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java

@ -18,9 +18,9 @@ package smoketest.actuator; @@ -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.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPathSampleActuatorApplicationTests.java

@ -21,9 +21,9 @@ import java.util.Map; @@ -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.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortSampleActuatorApplicationTests.java

@ -22,12 +22,12 @@ import org.junit.jupiter.api.Test; @@ -22,12 +22,12 @@ 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.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.boot.webmvc.error.DefaultErrorAttributes;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpStatus;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementPortWithLazyInitializationTests.java

@ -18,9 +18,9 @@ package smoketest.actuator; @@ -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.web.server.test.LocalManagementPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/NoManagementSampleActuatorApplicationTests.java

@ -21,9 +21,9 @@ import java.util.Map; @@ -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.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperFalseTests.java

@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test; @@ -20,9 +20,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperTrueTests.java

@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test; @@ -20,9 +20,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/SampleActuatorApplicationTests.java

@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test; @@ -24,9 +24,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ServletPathSampleActuatorApplicationTests.java

@ -21,9 +21,9 @@ import java.util.Map; @@ -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.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ShutdownSampleActuatorApplicationTests.java

@ -21,9 +21,9 @@ import java.util.Map; @@ -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.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

2
smoke-test/spring-boot-smoke-test-devtools/src/test/java/smoketest/devtools/SampleDevToolsApplicationIntegrationTests.java

@ -19,9 +19,9 @@ package smoketest.devtools; @@ -19,9 +19,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-hateoas/src/test/java/smoketest/hateoas/SampleHateoasApplicationTests.java

@ -21,9 +21,9 @@ import java.util.Arrays; @@ -21,9 +21,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;

2
smoke-test/spring-boot-smoke-test-jetty-jsp/src/test/java/smoketest/jetty/jsp/SampleWebJspApplicationTests.java

@ -19,9 +19,9 @@ package smoketest.jetty.jsp; @@ -19,9 +19,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-jetty-ssl/src/test/java/smoketest/jetty/ssl/SampleJettySslApplicationTests.java

@ -19,10 +19,10 @@ package smoketest.jetty.ssl; @@ -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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-jetty/src/test/java/smoketest/jetty/SampleJettyApplicationTests.java

@ -21,9 +21,9 @@ import smoketest.jetty.util.StringUtil; @@ -21,9 +21,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;

2
smoke-test/spring-boot-smoke-test-oauth2-authorization-server/src/test/java/smoketest/oauth2/server/SampleOAuth2AuthorizationServerApplicationTests.java

@ -25,9 +25,9 @@ import org.junit.jupiter.api.Test; @@ -25,9 +25,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;

2
smoke-test/spring-boot-smoke-test-oauth2-client/src/test/java/smoketest/oauth2/client/SampleOAuth2ClientApplicationTests.java

@ -22,9 +22,9 @@ import org.junit.jupiter.api.Test; @@ -22,9 +22,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-oauth2-resource-server/src/test/java/smoketest/oauth2/resource/SampleOauth2ResourceServerApplicationTests.java

@ -25,8 +25,8 @@ import org.junit.jupiter.api.BeforeAll; @@ -25,8 +25,8 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;

2
smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java

@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test; @@ -20,9 +20,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;

2
smoke-test/spring-boot-smoke-test-quartz/src/test/java/smoketest/quartz/SampleQuartzApplicationWebTests.java

@ -29,11 +29,11 @@ import org.junit.jupiter.api.Test; @@ -29,11 +29,11 @@ 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.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.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-saml2-service-provider/src/test/java/smoketest/saml2/serviceprovider/SampleSaml2RelyingPartyApplicationTests.java

@ -22,9 +22,9 @@ import org.junit.jupiter.api.Test; @@ -22,9 +22,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

2
smoke-test/spring-boot-smoke-test-servlet/src/test/java/smoketest/servlet/SampleServletApplicationTests.java

@ -21,9 +21,9 @@ import java.util.Collections; @@ -21,9 +21,9 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;

2
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; @@ -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.test.context.SpringBootTest;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.boot.testsupport.container.TestImage;
import org.springframework.boot.web.server.test.LocalServerPort;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;

2
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; @@ -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.test.context.SpringBootTest;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.boot.testsupport.container.TestImage;
import org.springframework.boot.web.server.test.client.TestRestTemplate;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save