use of org.springframework.mock.web.MockHttpServletRequest in project spring-boot by spring-projects.
the class LogFileMvcEndpointTests method notAvailableIfDisabled.
@Test
public void notAvailableIfDisabled() throws Exception {
this.environment.setProperty("logging.file", this.logFile.getAbsolutePath());
this.mvc.setEnabled(false);
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest(HttpMethod.HEAD.name(), "/logfile");
this.mvc.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-boot by spring-projects.
the class LogFileMvcEndpointTests method availableWithLogFile.
@Test
public void availableWithLogFile() throws Exception {
this.environment.setProperty("logging.file", this.logFile.getAbsolutePath());
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest(HttpMethod.HEAD.name(), "/logfile");
this.mvc.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-boot by spring-projects.
the class LogFileMvcEndpointTests method invokeGetsContentExternalFile.
@Test
public void invokeGetsContentExternalFile() throws Exception {
this.mvc.setExternalFile(this.logFile);
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest(HttpMethod.GET.name(), "/logfile");
this.mvc.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat("--TEST--").isEqualTo(response.getContentAsString());
}
use of org.springframework.mock.web.MockHttpServletRequest 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.MockHttpServletRequest in project spring-boot by spring-projects.
the class NoSpringSecurityHealthMvcEndpointIntegrationTests method getRequestPostProcessor.
private RequestPostProcessor getRequestPostProcessor() {
return new RequestPostProcessor() {
@Override
public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
Principal principal = mock(Principal.class);
request.setUserPrincipal(principal);
return request;
}
};
}
Aggregations