Add support for POSTing a single POJO

You need to cache the request body so it can be read twice, once
to see if it's an array, and again to turn it into a POJO.
This commit is contained in:
Dave Syer
2017-05-16 10:26:10 +01:00
parent ff78bfc438
commit 120d2da496
2 changed files with 22 additions and 8 deletions

View File

@@ -273,6 +273,16 @@ public class RestApplicationTests {
.isEqualTo("[{\"value\":\"FOO\"},{\"value\":\"BAR\"}]");
}
@Test
public void uppercaseFoo() throws Exception {
// Single Foo can be parsed
ResponseEntity<String> result = rest.exchange(RequestEntity
.post(new URI("/upFoos")).contentType(MediaType.APPLICATION_JSON)
.body("{\"value\":\"foo\"}"), String.class);
assertThat(result.getBody())
.isEqualTo("[{\"value\":\"FOO\"}]");
}
@Test
public void bareUppercase() throws Exception {
ResponseEntity<String> result = rest.exchange(RequestEntity