Browse Source

Pull up method to ConfiugrableMockMvcBuilder

See gh-19647
pull/25621/head
Rossen Stoyanchev 4 years ago
parent
commit
4116e6dd18
  1. 1
      spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java
  2. 16
      spring-test/src/main/java/org/springframework/test/web/servlet/setup/ConfigurableMockMvcBuilder.java

1
spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java

@ -107,6 +107,7 @@ public abstract class AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B> @@ -107,6 +107,7 @@ public abstract class AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B>
return self();
}
@Override
public final <T extends B> T addDispatcherServletCustomizer(DispatcherServletCustomizer customizer) {
this.dispatcherServletCustomizers.add(customizer);
return self();

16
spring-test/src/main/java/org/springframework/test/web/servlet/setup/ConfigurableMockMvcBuilder.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -18,6 +18,7 @@ package org.springframework.test.web.servlet.setup; @@ -18,6 +18,7 @@ package org.springframework.test.web.servlet.setup;
import javax.servlet.Filter;
import org.springframework.test.web.servlet.DispatcherServletCustomizer;
import org.springframework.test.web.servlet.MockMvcBuilder;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.ResultHandler;
@ -37,7 +38,7 @@ public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder @@ -37,7 +38,7 @@ public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder
* <pre class="code">
* mockMvcBuilder.addFilters(springSecurityFilterChain);
* </pre>
* <p>is the equivalent of the following web.xml configuration:
* <p>It is the equivalent of the following web.xml configuration:
* <pre class="code">
* &lt;filter-mapping&gt;
* &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
@ -52,9 +53,9 @@ public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder @@ -52,9 +53,9 @@ public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder
/**
* Add a filter mapped to a specific set of patterns. For example:
* <pre class="code">
* mockMvcBuilder.addFilters(myResourceFilter, "/resources/*");
* mockMvcBuilder.addFilter(myResourceFilter, "/resources/*");
* </pre>
* <p>is the equivalent of:
* <p>It is the equivalent of:
* <pre class="code">
* &lt;filter-mapping&gt;
* &lt;filter-name&gt;myResourceFilter&lt;/filter-name&gt;
@ -105,6 +106,13 @@ public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder @@ -105,6 +106,13 @@ public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder
*/
<T extends B> T dispatchOptions(boolean dispatchOptions);
/**
* A more advanced variant of {@link #dispatchOptions(boolean)} that allows
* customizing any {@link org.springframework.web.servlet.DispatcherServlet}
* property.
*/
<T extends B> T addDispatcherServletCustomizer(DispatcherServletCustomizer customizer);
/**
* Add a {@code MockMvcConfigurer} that automates MockMvc setup and
* configures it for some specific purpose (e.g. security).

Loading…
Cancel
Save