File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
main/java/org/springframework/test/web/servlet/setup
test/java/org/springframework/test/web/servlet/setup Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 4242 * @author Rob Winch
4343 * @since 3.2
4444 */
45- public class DefaultMockMvcBuilder <Self extends MockMvcBuilder > extends MockMvcBuilderSupport
45+ public class DefaultMockMvcBuilder <Self extends DefaultMockMvcBuilder > extends MockMvcBuilderSupport
4646 implements MockMvcBuilder {
4747
4848 private final WebApplicationContext webAppContext ;
Original file line number Diff line number Diff line change 1+ package org .springframework .test .web .servlet .setup ;
2+
3+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
4+
5+ import org .junit .Test ;
6+ import org .junit .runner .RunWith ;
7+ import org .springframework .beans .factory .annotation .Autowired ;
8+ import org .springframework .context .annotation .Configuration ;
9+ import org .springframework .test .context .ContextConfiguration ;
10+ import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
11+ import org .springframework .test .context .web .WebAppConfiguration ;
12+ import org .springframework .web .context .WebApplicationContext ;
13+ import org .springframework .web .filter .CharacterEncodingFilter ;
14+ import org .springframework .web .servlet .config .annotation .EnableWebMvc ;
15+ import org .springframework .web .servlet .config .annotation .WebMvcConfigurerAdapter ;
16+
17+ /**
18+ * Test for SPR-10277 (Multiple method chaining when building MockMvc).
19+ *
20+ * @author Wesley Hall
21+ */
22+ @ RunWith (SpringJUnit4ClassRunner .class )
23+ @ WebAppConfiguration
24+ @ ContextConfiguration
25+ public class Spr10277Tests {
26+
27+ @ Autowired
28+ private WebApplicationContext wac ;
29+
30+ @ Test
31+ public void chainMultiple () {
32+ MockMvcBuilders
33+ .webAppContextSetup (wac )
34+ .addFilter (new CharacterEncodingFilter () )
35+ .defaultRequest (get ("/" ).contextPath ("/mywebapp" ))
36+ .build ();
37+ }
38+
39+ @ Configuration
40+ @ EnableWebMvc
41+ static class WebConfig extends WebMvcConfigurerAdapter {
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments