ResponseEntity headers builder casts body to any type
Issue: SPR-14939
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user