Align default for OPTIONS request dispatching with Spring Framework 4.3
Closes gh-5965
This commit is contained in:
@@ -59,7 +59,7 @@ public class WebMvcProperties {
|
||||
/**
|
||||
* Dispatch OPTIONS requests to the FrameworkServlet doService method.
|
||||
*/
|
||||
private boolean dispatchOptionsRequest = false;
|
||||
private boolean dispatchOptionsRequest = true;
|
||||
|
||||
/**
|
||||
* If the content of the "default" model should be ignored during redirect scenarios.
|
||||
|
||||
@@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Tests for {@link DispatcherServletAutoConfiguration}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class DispatcherServletAutoConfigurationTests {
|
||||
|
||||
@@ -146,21 +147,38 @@ public class DispatcherServletAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dispatcherServletConfig() {
|
||||
public void dispatcherServletDefaultConfig() {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(ServerPropertiesAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
DispatcherServlet bean = this.context.getBean(DispatcherServlet.class);
|
||||
assertThat(bean).extracting("throwExceptionIfNoHandlerFound")
|
||||
.containsExactly(false);
|
||||
assertThat(bean).extracting("dispatchOptionsRequest").containsExactly(true);
|
||||
assertThat(bean).extracting("dispatchTraceRequest").containsExactly(false);
|
||||
assertThat(new DirectFieldAccessor(
|
||||
this.context.getBean("dispatcherServletRegistration"))
|
||||
.getPropertyValue("loadOnStartup")).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dispatcherServletCustomConfig() {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.setServletContext(new MockServletContext());
|
||||
this.context.register(ServerPropertiesAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class);
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.mvc.throw-exception-if-no-handler-found:true",
|
||||
"spring.mvc.dispatch-options-request:true",
|
||||
"spring.mvc.dispatch-options-request:false",
|
||||
"spring.mvc.dispatch-trace-request:true",
|
||||
"spring.mvc.servlet.load-on-startup=5");
|
||||
this.context.refresh();
|
||||
DispatcherServlet bean = this.context.getBean(DispatcherServlet.class);
|
||||
assertThat(bean).extracting("throwExceptionIfNoHandlerFound")
|
||||
.containsExactly(true);
|
||||
assertThat(bean).extracting("dispatchOptionsRequest").containsExactly(true);
|
||||
assertThat(bean).extracting("dispatchOptionsRequest").containsExactly(false);
|
||||
assertThat(bean).extracting("dispatchTraceRequest").containsExactly(true);
|
||||
assertThat(new DirectFieldAccessor(
|
||||
this.context.getBean("dispatcherServletRegistration"))
|
||||
|
||||
Reference in New Issue
Block a user