|
|
|
@ -128,45 +128,59 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void personResponseBody() throws Exception { |
|
|
|
public void personResponseBody() throws Exception { |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
assertEquals(expected, performGet("/person-response/person", JSON, Person.class).getBody()); |
|
|
|
ResponseEntity<Person> responseEntity = performGet("/person-response/person", JSON, Person.class); |
|
|
|
|
|
|
|
assertEquals(17, responseEntity.getHeaders().getContentLength()); |
|
|
|
|
|
|
|
assertEquals(expected, responseEntity.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void personResponseBodyWithCompletableFuture() throws Exception { |
|
|
|
public void personResponseBodyWithCompletableFuture() throws Exception { |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
assertEquals(expected, performGet("/person-response/completable-future", JSON, Person.class).getBody()); |
|
|
|
ResponseEntity<Person> responseEntity = performGet("/person-response/completable-future", JSON, Person.class); |
|
|
|
|
|
|
|
assertEquals(17, responseEntity.getHeaders().getContentLength()); |
|
|
|
|
|
|
|
assertEquals(expected, responseEntity.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void personResponseBodyWithMono() throws Exception { |
|
|
|
public void personResponseBodyWithMono() throws Exception { |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
assertEquals(expected, performGet("/person-response/mono", JSON, Person.class).getBody()); |
|
|
|
ResponseEntity<Person> responseEntity = performGet("/person-response/mono", JSON, Person.class); |
|
|
|
|
|
|
|
assertEquals(17, responseEntity.getHeaders().getContentLength()); |
|
|
|
|
|
|
|
assertEquals(expected, responseEntity.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void personResponseBodyWithMonoDeclaredAsObject() throws Exception { |
|
|
|
public void personResponseBodyWithMonoDeclaredAsObject() throws Exception { |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
assertEquals(expected, performGet("/person-response/mono-declared-as-object", JSON, Person.class).getBody()); |
|
|
|
ResponseEntity<Person> entity = performGet("/person-response/mono-declared-as-object", JSON, Person.class); |
|
|
|
|
|
|
|
assertEquals(17, entity.getHeaders().getContentLength()); |
|
|
|
|
|
|
|
assertEquals(expected, entity.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void personResponseBodyWithSingle() throws Exception { |
|
|
|
public void personResponseBodyWithSingle() throws Exception { |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
assertEquals(expected, performGet("/person-response/single", JSON, Person.class).getBody()); |
|
|
|
ResponseEntity<Person> entity = performGet("/person-response/single", JSON, Person.class); |
|
|
|
|
|
|
|
assertEquals(17, entity.getHeaders().getContentLength()); |
|
|
|
|
|
|
|
assertEquals(expected, entity.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void personResponseBodyWithMonoResponseEntity() throws Exception { |
|
|
|
public void personResponseBodyWithMonoResponseEntity() throws Exception { |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
Person expected = new Person("Robert"); |
|
|
|
assertEquals(expected, performGet("/person-response/mono-response-entity", JSON, Person.class).getBody()); |
|
|
|
ResponseEntity<Person> entity = performGet("/person-response/mono-response-entity", JSON, Person.class); |
|
|
|
|
|
|
|
assertEquals(17, entity.getHeaders().getContentLength()); |
|
|
|
|
|
|
|
assertEquals(expected, entity.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // SPR-16172
|
|
|
|
@Test // SPR-16172
|
|
|
|
public void personResponseBodyWithMonoResponseEntityXml() throws Exception { |
|
|
|
public void personResponseBodyWithMonoResponseEntityXml() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
String actual = performGet("/person-response/mono-response-entity-xml", |
|
|
|
String url = "/person-response/mono-response-entity-xml"; |
|
|
|
new HttpHeaders(), String.class).getBody(); |
|
|
|
ResponseEntity<String> entity = performGet(url, new HttpHeaders(), String.class); |
|
|
|
|
|
|
|
String actual = entity.getBody(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(91, entity.getHeaders().getContentLength()); |
|
|
|
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + |
|
|
|
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + |
|
|
|
"<person><name>Robert</name></person>", actual); |
|
|
|
"<person><name>Robert</name></person>", actual); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -174,13 +188,17 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void personResponseBodyWithList() throws Exception { |
|
|
|
public void personResponseBodyWithList() throws Exception { |
|
|
|
List<?> expected = asList(new Person("Robert"), new Person("Marie")); |
|
|
|
List<?> expected = asList(new Person("Robert"), new Person("Marie")); |
|
|
|
assertEquals(expected, performGet("/person-response/list", JSON, PERSON_LIST).getBody()); |
|
|
|
ResponseEntity<List<Person>> entity = performGet("/person-response/list", JSON, PERSON_LIST); |
|
|
|
|
|
|
|
assertEquals(36, entity.getHeaders().getContentLength()); |
|
|
|
|
|
|
|
assertEquals(expected, entity.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void personResponseBodyWithPublisher() throws Exception { |
|
|
|
public void personResponseBodyWithPublisher() throws Exception { |
|
|
|
List<?> expected = asList(new Person("Robert"), new Person("Marie")); |
|
|
|
List<?> expected = asList(new Person("Robert"), new Person("Marie")); |
|
|
|
assertEquals(expected, performGet("/person-response/publisher", JSON, PERSON_LIST).getBody()); |
|
|
|
ResponseEntity<List<Person>> entity = performGet("/person-response/publisher", JSON, PERSON_LIST); |
|
|
|
|
|
|
|
assertEquals(-1, entity.getHeaders().getContentLength()); |
|
|
|
|
|
|
|
assertEquals(expected, entity.getBody()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
|