forked from spring-projects/spring-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix DefaultMockMvcBuilder fluent API generic type
Changed upper bound of generic parameter for DefaultMockMvcBuilder from MockMvcBuilder to DefaultMockMvcBuilder to allow for ongoing method chaining in the fluent API style. Issue: SPR-10277
- Loading branch information
1 parent
c611083
commit fbac428
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
spring-test-mvc/src/test/java/org/springframework/test/web/servlet/setup/Spr10277Tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.springframework.test.web.servlet.setup; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
import org.springframework.web.context.WebApplicationContext; | ||
import org.springframework.web.filter.CharacterEncodingFilter; | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
|
||
/** | ||
* Test for SPR-10277 (Multiple method chaining when building MockMvc). | ||
* | ||
* @author Wesley Hall | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@WebAppConfiguration | ||
@ContextConfiguration | ||
public class Spr10277Tests { | ||
|
||
@Autowired | ||
private WebApplicationContext wac; | ||
|
||
@Test | ||
public void chainMultiple() { | ||
MockMvcBuilders | ||
.webAppContextSetup(wac) | ||
.addFilter(new CharacterEncodingFilter() ) | ||
.defaultRequest(get("/").contextPath("/mywebapp")) | ||
.build(); | ||
} | ||
|
||
@Configuration | ||
@EnableWebMvc | ||
static class WebConfig extends WebMvcConfigurerAdapter { | ||
} | ||
} |