Browse Source
Relocate `WebTestClientBuilderCustomizer` to `spring-boot-test` and break the direct link to web-server and http-codec by making use of `spring.factories` and the new `BaseUrlProviders` class. A new `spring-boot-test-integration-test` module has also been added to ensure hold the previous tests. See gh-46356pull/47381/head
28 changed files with 151 additions and 127 deletions
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
/* |
||||
* Copyright 2012-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the License); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
|
||||
plugins { |
||||
id "java-library" |
||||
} |
||||
|
||||
description = "Spring Boot Test Integration Tests" |
||||
|
||||
dependencies { |
||||
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-tomcat")) |
||||
testImplementation(project(":module:spring-boot-web-server")) |
||||
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/reactive/WebTestClientContextCustomizerIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerIntegrationTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerIntegrationTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerTcfCacheContextPausingTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerTcfCacheContextPausingTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerTcfCacheContextPausingTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerTcfCacheContextPausingTests.java
4
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerTests.java
4
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerWithCustomBasePathTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerWithCustomBasePathTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerWithCustomBasePathTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerWithCustomBasePathTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerWithCustomContextPathTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerWithCustomContextPathTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerWithCustomContextPathTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerWithCustomContextPathTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerWithOverrideIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerWithOverrideIntegrationTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerWithOverrideIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerWithOverrideIntegrationTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerWithoutWebfluxIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerWithoutWebfluxIntegrationTests.java
2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/client/reactive/WebTestClientContextCustomizerWithoutWebfluxIntegrationTests.java → integration-test/spring-boot-test-integration-tests/src/test/java/org/springframework/boot/test/web/reactive/client/WebTestClientContextCustomizerWithoutWebfluxIntegrationTests.java
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
/* |
||||
* Copyright 2012-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.http.codec; |
||||
|
||||
import java.util.Collection; |
||||
import java.util.function.Consumer; |
||||
|
||||
import org.springframework.boot.test.web.reactive.client.WebTestClientBuilderCustomizer; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.http.codec.ClientCodecConfigurer; |
||||
import org.springframework.test.web.reactive.server.WebTestClient.Builder; |
||||
import org.springframework.util.CollectionUtils; |
||||
import org.springframework.web.reactive.function.client.ExchangeStrategies; |
||||
|
||||
/** |
||||
* {@link WebTestClientBuilderCustomizer} to apply {@link CodecCustomizer} beans. |
||||
* |
||||
* @author Phillip Webb |
||||
*/ |
||||
class CodecWebTestClientBuilderCustomizer implements WebTestClientBuilderCustomizer { |
||||
|
||||
private final ApplicationContext context; |
||||
|
||||
CodecWebTestClientBuilderCustomizer(ApplicationContext context) { |
||||
this.context = context; |
||||
} |
||||
|
||||
@Override |
||||
public void customize(Builder builder) { |
||||
Collection<CodecCustomizer> customizers = this.context.getBeansOfType(CodecCustomizer.class).values(); |
||||
if (!CollectionUtils.isEmpty(customizers)) { |
||||
ExchangeStrategies strategies = ExchangeStrategies.builder().codecs(apply(customizers)).build(); |
||||
builder.exchangeStrategies(strategies); |
||||
} |
||||
} |
||||
|
||||
private Consumer<ClientCodecConfigurer> apply(Collection<CodecCustomizer> customizers) { |
||||
return (codecs) -> customizers.forEach((customizer) -> customizer.customize(codecs)); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
# WebTestClient Builder Customizers |
||||
org.springframework.boot.test.web.reactive.server.WebTestClientBuilderCustomizer=\ |
||||
org.springframework.boot.http.codec.CodecWebTestClientBuilderCustomizer |
||||
Loading…
Reference in new issue