Skip to content

Commit 5eb1e26

Browse files
committed
Add HttpEncodingAutoConfiguration to WebMvcTest
Prior to this commit, tests using the `@WebMvcTest` annotation would not include the `HttpEncodingAutoConfiguration`. This means that, even if configured, the encoding filter would not be configured in MVC tests, resulting in an inconsistency with `@SpringBootTest` tests. This commit ensures that the `HttpEncodingAutoConfiguration` is included when `@WebMvcTest` is used. Fixes gh-23749
1 parent a601901 commit 5eb1e26

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration,\
152152
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
153153
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
154154
org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration,\
155+
org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration,\
155156
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
156157

157158
# DefaultTestExecutionListenersPostProcessors

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestAutoConfigurationIntegrationTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration;
2525
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
2626
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
27+
import org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration;
2728
import org.springframework.context.ApplicationContext;
2829
import org.springframework.core.task.AsyncTaskExecutor;
2930
import org.springframework.test.util.ReflectionTestUtils;
@@ -76,4 +77,9 @@ void asyncTaskExecutorWithApplicationTaskExecutor() {
7677
"taskExecutor")).isSameAs(this.applicationContext.getBean("applicationTaskExecutor"));
7778
}
7879

80+
@Test
81+
void httpEncodingAutoConfigurationWasImported() {
82+
assertThat(this.applicationContext).has(importedAutoConfiguration(HttpEncodingAutoConfiguration.class));
83+
}
84+
7985
}

0 commit comments

Comments
 (0)