use of org.springframework.mock.web.MockServletContext in project spring-boot by spring-projects.
the class DispatcherServletAutoConfigurationTests method registrationNonServletBean.
@Test
public void registrationNonServletBean() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(NonServletConfiguration.class, DispatcherServletAutoConfiguration.class);
this.context.setServletContext(new MockServletContext());
this.context.refresh();
assertThat(this.context.getBeanNamesForType(ServletRegistrationBean.class).length).isEqualTo(0);
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length).isEqualTo(0);
}
use of org.springframework.mock.web.MockServletContext in project spring-boot by spring-projects.
the class MvcEndpointCorsIntegrationTests method createContext.
@Before
public void createContext() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(JacksonAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, AuditAutoConfiguration.class, JolokiaAutoConfiguration.class, WebMvcAutoConfiguration.class);
}
use of org.springframework.mock.web.MockServletContext in project spring-boot by spring-projects.
the class MvcEndpointSecurityInterceptorTests method setup.
@Before
public void setup() throws Exception {
this.roles = Arrays.asList("SUPER_HERO");
this.securityInterceptor = new MvcEndpointSecurityInterceptor(true, this.roles);
this.endpoint = new TestEndpoint("a");
this.mvcEndpoint = new TestMvcEndpoint(this.endpoint);
this.handlerMethod = new HandlerMethod(this.mvcEndpoint, "invoke");
this.servletContext = new MockServletContext();
this.request = new MockHttpServletRequest(this.servletContext);
this.response = mock(HttpServletResponse.class);
}
use of org.springframework.mock.web.MockServletContext in project spring-boot by spring-projects.
the class NoSpringSecurityHealthMvcEndpointIntegrationTests method healthWhenRightRoleNotPresentShouldNotExposeHealthDetails.
@Test
public void healthWhenRightRoleNotPresentShouldNotExposeHealthDetails() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class);
this.context.refresh();
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
mockMvc.perform(get("/health").with(getRequestPostProcessor())).andExpect(status().isOk()).andExpect(content().string("{\"status\":\"UP\"}"));
}
use of org.springframework.mock.web.MockServletContext in project spring-boot by spring-projects.
the class NoSpringSecurityMvcEndpointSecurityInterceptorTests method setup.
@Before
public void setup() throws Exception {
this.roles = Arrays.asList("SUPER_HERO");
this.securityInterceptor = new MvcEndpointSecurityInterceptor(true, this.roles);
this.endpoint = new TestEndpoint("a");
this.mvcEndpoint = new TestMvcEndpoint(this.endpoint);
this.handlerMethod = new HandlerMethod(this.mvcEndpoint, "invoke");
this.servletContext = new MockServletContext();
this.request = new MockHttpServletRequest(this.servletContext);
this.response = mock(HttpServletResponse.class);
}
Aggregations