Browse Source

Fix codec customization with AutoConfigureWebTestClient

Fixes gh-47697
pull/47747/head
Andy Wilkinson 2 months ago
parent
commit
c069e924fc
  1. 3
      module/spring-boot-webtestclient/build.gradle
  2. 0
      module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  3. 1
      module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports
  4. 53
      module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClientIntegrationTests.java

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

@ -16,9 +16,9 @@ @@ -16,9 +16,9 @@
plugins {
id "java-library"
id "org.springframework.boot.auto-configuration"
id "org.springframework.boot.deployed"
id "org.springframework.boot.optional-dependencies"
id "org.springframework.boot.test-auto-configuration"
}
description = "Spring Boot WebTestClient"
@ -32,6 +32,7 @@ dependencies { @@ -32,6 +32,7 @@ dependencies {
testImplementation(project(":core:spring-boot-test"))
testImplementation(project(":test-support:spring-boot-test-support"))
testImplementation(testFixtures(project(":core:spring-boot-autoconfigure")))
testRuntimeOnly("ch.qos.logback:logback-classic")
testRuntimeOnly("jakarta.servlet:jakarta.servlet-api")

0
module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

1
module/spring-boot-webtestclient/src/main/resources/META-INF/spring/org.springframework.boot.webtestclient.AutoConfigureWebTestClient.imports

@ -1 +1,2 @@ @@ -1 +1,2 @@
org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration
org.springframework.boot.webtestclient.WebTestClientAutoConfiguration

53
module/spring-boot-webtestclient/src/test/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClientIntegrationTests.java

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.webflux.test.autoconfigure;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webtestclient.AutoConfigureWebTestClient;
import org.springframework.context.ApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration;
/**
* Integration tests for {@link AutoConfigureWebTestClient @AutoConfigureWebTestClient}.
*
* @author Andy Wilkinson
*/
@SpringBootTest
@AutoConfigureWebTestClient
class AutoConfigureWebTestClientIntegrationTests {
@Autowired
private ApplicationContext applicationContext;
@Test
void codecsAutoConfigurationIsImported() {
assertThat(this.applicationContext).has(importedAutoConfiguration(CodecsAutoConfiguration.class));
}
@SpringBootConfiguration
static class TestConfiguration {
}
}
Loading…
Cancel
Save