Add ResponseEntity test

This commit is contained in:
Rossen Stoyanchev 2016-11-04 13:18:53 +02:00
parent c430402872
commit 475b876f08
1 changed files with 17 additions and 0 deletions

View File

@ -289,6 +289,23 @@ public class ResponseEntityResultHandlerTests {
assertResponseBody("\"body\"");
}
@Test // SPR-14877
public void handleMonoWithWildcardBodyTypeAndNullBody() throws Exception {
this.exchange.getAttributes().put(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE,
Collections.singleton(MediaType.APPLICATION_JSON));
HandlerResult result = new HandlerResult(new TestController(), Mono.just(notFound().build()),
ResolvableMethod.onClass(TestController.class)
.name("monoResponseEntityWildcard")
.resolveReturnType());
this.resultHandler.handleResult(this.exchange, result).block(Duration.ofSeconds(5));
assertEquals(HttpStatus.NOT_FOUND, this.response.getStatusCode());
assertNull(this.response.getBody());
}
private void testHandle(Object returnValue, ResolvableType type) {
HandlerResult result = handlerResult(returnValue, type);