org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder Java Examples

The following examples show how to use org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnitTestBase.java    From gemini with Apache License 2.0 5 votes vote down vote up
public void setupWebMockMvc(ConfigurableApplicationContext wApp) {
    webApp = wApp;
    DefaultMockMvcBuilder mockMvcBuilder = webAppContextSetup((WebApplicationContext) wApp);
    if (initializeSecurity())
        mockMvcBuilder = mockMvcBuilder.apply(springSecurity());
    mockMvc = mockMvcBuilder.build();
}
 
Example #2
Source File: SuiteTestWebApiINIT.java    From gemini with Apache License 2.0 5 votes vote down vote up
public static void setupWebMockMvc(ConfigurableApplicationContext wApp) {
    webApp = wApp;
    DefaultMockMvcBuilder mockMvcBuilder = webAppContextSetup((WebApplicationContext) wApp);
  /*  if (USE_SECURITY)
        mockMvcBuilder = mockMvcBuilder.apply(springSecurity());*/
    MockMVCUtils.mockMvc = mockMvcBuilder.build();
}
 
Example #3
Source File: AbstractMvcIntegrationTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
  InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
  viewResolver.setPrefix("/WEB-INF/jsp/view/");
  viewResolver.setSuffix(".jsp");
  DefaultMockMvcBuilder mockMvcBuilder =
      MockMvcBuilders.webAppContextSetup(this.webApplicationContext);
  configureMockMvcBuilder(mockMvcBuilder);
  this.mockMvc = mockMvcBuilder.build();
}
 
Example #4
Source File: AbstractMvcIntegrationTest.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setup() {
	DefaultMockMvcBuilder mockMvcBuilder = MockMvcBuilders
			.webAppContextSetup(this.webApplicationContext);
	configureMockMvcBuilder(mockMvcBuilder);
	this.mockMvc = mockMvcBuilder.build();
}
 
Example #5
Source File: SuiteTestAuth.java    From gemini with Apache License 2.0 4 votes vote down vote up
public static void setupWebMockMvc(ConfigurableApplicationContext wApp) {
    webApp = wApp;
    DefaultMockMvcBuilder mockMvcBuilder = webAppContextSetup((WebApplicationContext) wApp);
    mockMvcBuilder = mockMvcBuilder.apply(springSecurity());
    MockMVCUtils.mockMvc = mockMvcBuilder.build();
}
 
Example #6
Source File: GrafanaAuthenticationTest.java    From Insights with Apache License 2.0 4 votes vote down vote up
private MockMvc getMacMvc() {
	DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.wac)
			.addFilter(springSecurityFilterChain);
	return builder.build();
}
 
Example #7
Source File: GroupsAndUserTest.java    From Insights with Apache License 2.0 4 votes vote down vote up
private MockMvc getMacMvc() {
	DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.wac);
	return builder.build();
}
 
Example #8
Source File: HttpServletFilterIntegrationTests.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
@Override
protected void configureMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) {
  mockMvcBuilder.addFilters(this.httpServletFilter);
}
 
Example #9
Source File: SpringBootWrapper.java    From funcatron with Apache License 2.0 4 votes vote down vote up
protected MockMvc getMockMvc() {
        DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(applicationContext);
return builder.build();
    }
 
Example #10
Source File: CorsTest.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Before
public void setup() {
    final DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(context)
            .apply(SecurityMockMvcConfigurers.springSecurity()).dispatchOptions(true);
    mvc = builder.build();
}
 
Example #11
Source File: DosFilterTest.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) {
    return super.createMvcWebAppContext(context).addFilter(new DosFilter(null, 10, 10,
            "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)", "X-Forwarded-For"));
}
 
Example #12
Source File: TraceFilterIntegrationTests.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
@Override
protected void configureMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) {
	mockMvcBuilder.addFilters(this.traceFilter, this.myFilter);
}
 
Example #13
Source File: AbstractMvcIntegrationTest.java    From opencensus-java with Apache License 2.0 2 votes vote down vote up
/**
 * Override in a subclass to modify mockMvcBuilder configuration (e.g. add filter).
 *
 * <p>The method from super class should be called.
 */
protected void configureMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) {}
 
Example #14
Source File: AbstractMvcIntegrationTest.java    From spring-cloud-sleuth with Apache License 2.0 2 votes vote down vote up
/**
 * Override in a subclass to modify mockMvcBuilder configuration (e.g. add filter).
 * <p>
 * The method from super class should be called.
 * @param mockMvcBuilder builder to configure
 */
protected void configureMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) {
}