|
|
|
@ -141,7 +141,6 @@ class DispatcherServletAutoConfigurationTests {
|
|
|
|
|
void dispatcherServletDefaultConfig() {
|
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
DispatcherServlet dispatcherServlet = context.getBean(DispatcherServlet.class);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("throwExceptionIfNoHandlerFound").isEqualTo(false);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("dispatchOptionsRequest").isEqualTo(true);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("dispatchTraceRequest").isEqualTo(false);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("enableLoggingRequestDetails").isEqualTo(false);
|
|
|
|
@ -151,15 +150,24 @@ class DispatcherServletAutoConfigurationTests {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@Deprecated(since = "3.2.0", forRemoval = true)
|
|
|
|
|
void dispatcherServletThrowExceptionIfNoHandlerFoundDefaultConfig() {
|
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
DispatcherServlet dispatcherServlet = context.getBean(DispatcherServlet.class);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("throwExceptionIfNoHandlerFound").isEqualTo(true);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void dispatcherServletCustomConfig() {
|
|
|
|
|
this.contextRunner
|
|
|
|
|
.withPropertyValues("spring.mvc.throw-exception-if-no-handler-found:true",
|
|
|
|
|
.withPropertyValues("spring.mvc.throw-exception-if-no-handler-found:false",
|
|
|
|
|
"spring.mvc.dispatch-options-request:false", "spring.mvc.dispatch-trace-request:true",
|
|
|
|
|
"spring.mvc.publish-request-handled-events:false", "spring.mvc.servlet.load-on-startup=5")
|
|
|
|
|
.run((context) -> {
|
|
|
|
|
DispatcherServlet dispatcherServlet = context.getBean(DispatcherServlet.class);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("throwExceptionIfNoHandlerFound").isEqualTo(true);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("throwExceptionIfNoHandlerFound").isEqualTo(false);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("dispatchOptionsRequest").isEqualTo(false);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("dispatchTraceRequest").isEqualTo(true);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("publishEvents").isEqualTo(false);
|
|
|
|
@ -168,6 +176,15 @@ class DispatcherServletAutoConfigurationTests {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@Deprecated(since = "3.2.0", forRemoval = true)
|
|
|
|
|
void dispatcherServletThrowExceptionIfNoHandlerFoundCustomConfig() {
|
|
|
|
|
this.contextRunner.withPropertyValues("spring.mvc.throw-exception-if-no-handler-found:false").run((context) -> {
|
|
|
|
|
DispatcherServlet dispatcherServlet = context.getBean(DispatcherServlet.class);
|
|
|
|
|
assertThat(dispatcherServlet).extracting("throwExceptionIfNoHandlerFound").isEqualTo(false);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
static class MultipartConfiguration {
|
|
|
|
|
|
|
|
|
|