check null before use this.content

Resolves #1192
Resolves #1193
This commit is contained in:
Nicolas PETERS
2024-10-21 23:45:54 +02:00
committed by Oleg Zhurakousky
parent 3930cad5df
commit 5f767f65e0
2 changed files with 25 additions and 1 deletions

View File

@@ -149,6 +149,21 @@ public class RequestResponseTests {
assertThat(pet.getName()).isNotEmpty();
}
@Test
public void validatePostWithoutBody() throws Exception {
ServerlessHttpServletRequest request = new ServerlessHttpServletRequest(null, "POST", "/pets/");
request.setContentType("application/json");
ServerlessHttpServletResponse response = new ServerlessHttpServletResponse();
try {
mvc.service(request, response);
}
catch (jakarta.servlet.ServletException e) {
assertThat(e.getCause()).isNotInstanceOf(NullPointerException.class);
}
assertThat(response.getStatus()).isEqualTo(400); // application fail because the pet is empty ;)
}
@Test
public void validatePostAsyncWithBody() throws Exception {
// System.setProperty("spring.main.banner-mode", "off");