Polish "Do not auto-configure ViewResolver if spring-webmvc is absent"

See gh-44259
This commit is contained in:
Stéphane Nicoll
2025-02-17 11:01:23 +01:00
parent ac73766f9b
commit 6aa0055e5e

View File

@@ -46,7 +46,6 @@ import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.boot.testsupport.BuildOutput;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
import org.springframework.context.annotation.Bean;
@@ -61,6 +60,7 @@ import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
import org.springframework.web.servlet.support.RequestContext;
import org.springframework.web.servlet.view.AbstractCachingViewResolver;
import static org.assertj.core.api.Assertions.assertThat;
@@ -338,9 +338,8 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
@ClassPathExclusions("spring-webmvc-*.jar")
void missingAbstractCachingViewResolver() {
this.contextRunner
this.contextRunner.withClassLoader(new FilteredClassLoader(AbstractCachingViewResolver.class))
.run((context) -> assertThat(context).hasNotFailed().doesNotHaveBean("thymeleafViewResolver"));
}