ResponseEntity headers builder casts body to any type

Issue: SPR-14939
This commit is contained in:
Rossen Stoyanchev
2016-11-28 17:22:24 -05:00
parent 9755ae3cbe
commit dd3b9c7c35
2 changed files with 16 additions and 7 deletions

View File

@@ -96,6 +96,15 @@ public class ResponseEntityTests {
assertNull(responseEntity.getBody());
}
@Test // SPR-14939
public void acceptedNoBodyWithAlternativeBodyType() throws URISyntaxException {
ResponseEntity<String> responseEntity = ResponseEntity.accepted().build();
assertNotNull(responseEntity);
assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
assertNull(responseEntity.getBody());
}
@Test
public void noContent() throws URISyntaxException {
ResponseEntity<Void> responseEntity = ResponseEntity.noContent().build();
@@ -203,7 +212,7 @@ public class ResponseEntityTests {
@Test
public void emptyCacheControl() {
Integer entity = new Integer(42);
Integer entity = 42;
ResponseEntity<Integer> responseEntity =
ResponseEntity.status(HttpStatus.OK)
@@ -218,7 +227,7 @@ public class ResponseEntityTests {
@Test
public void cacheControl() {
Integer entity = new Integer(42);
Integer entity = 42;
ResponseEntity<Integer> responseEntity =
ResponseEntity.status(HttpStatus.OK)
@@ -236,7 +245,7 @@ public class ResponseEntityTests {
@Test
public void cacheControlNoCache() {
Integer entity = new Integer(42);
Integer entity = 42;
ResponseEntity<Integer> responseEntity =
ResponseEntity.status(HttpStatus.OK)
@@ -254,7 +263,7 @@ public class ResponseEntityTests {
@Test
public void statusCodeAsInt() {
Integer entity = new Integer(42);
Integer entity = 42;
ResponseEntity<Integer> responseEntity = ResponseEntity.status(200).body(entity);
assertEquals(200, responseEntity.getStatusCode().value());
@@ -263,7 +272,7 @@ public class ResponseEntityTests {
@Test
public void customStatusCode() {
Integer entity = new Integer(42);
Integer entity = 42;
ResponseEntity<Integer> responseEntity = ResponseEntity.status(299).body(entity);
assertEquals(299, responseEntity.getStatusCodeValue());