private MockMvc doCreateMockMvc(MockMvcConfigurer... configurers) { this.context.setServletContext(new MockServletContext()); this.context.refresh(); DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.context); for (MockMvcConfigurer configurer : configurers) { builder.apply(configurer); } return builder.build(); }
protected MockMvcHtmlUnitDriverBuilder(WebApplicationContext context, MockMvcConfigurer configurer) { super(context, configurer); }
protected MockMvcWebClientBuilder(WebApplicationContext context, MockMvcConfigurer configurer) { super(context, configurer); }
/** * Create a new {@code MockMvcHtmlUnitDriverBuilder} based on the supplied * {@link WebApplicationContext} and {@link MockMvcConfigurer}. * @param context the {@code WebApplicationContext} to create a {@link MockMvc} * instance from; never {@code null} * @param configurer the {@code MockMvcConfigurer} to apply; never {@code null} * @return the MockMvcHtmlUnitDriverBuilder to customize */ public static MockMvcHtmlUnitDriverBuilder webAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer) { Assert.notNull(context, "WebApplicationContext must not be null"); Assert.notNull(configurer, "MockMvcConfigurer must not be null"); return new MockMvcHtmlUnitDriverBuilder(context, configurer); }
/** * Create a new {@code MockMvcWebClientBuilder} based on the supplied * {@link WebApplicationContext} and {@link MockMvcConfigurer}. * @param context the {@code WebApplicationContext} to create a {@link MockMvc} * instance from; never {@code null} * @param configurer the {@code MockMvcConfigurer} to apply; never {@code null} * @return the MockMvcWebClientBuilder to customize */ public static MockMvcWebClientBuilder webAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer) { Assert.notNull(context, "WebApplicationContext must not be null"); Assert.notNull(configurer, "MockMvcConfigurer must not be null"); return new MockMvcWebClientBuilder(context, configurer); }
/** * Create a new instance using the supplied {@link WebApplicationContext} * and {@link MockMvcConfigurer}. * @param context the {@code WebApplicationContext} to create a {@code MockMvc} * instance from; never {@code null} * @param configurer the MockMvcConfigurer to apply; never {@code null} */ protected MockMvcWebConnectionBuilderSupport(WebApplicationContext context, MockMvcConfigurer configurer) { this(MockMvcBuilders.webAppContextSetup(context).apply(configurer).build()); }