Skip to content

Commit 475b876

Browse files
committed
Add ResponseEntity test
1 parent c430402 commit 475b876

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,23 @@ public void handleMonoWithWildcardBodyType() throws Exception {
289289
assertResponseBody("\"body\"");
290290
}
291291

292+
@Test // SPR-14877
293+
public void handleMonoWithWildcardBodyTypeAndNullBody() throws Exception {
294+
295+
this.exchange.getAttributes().put(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE,
296+
Collections.singleton(MediaType.APPLICATION_JSON));
297+
298+
HandlerResult result = new HandlerResult(new TestController(), Mono.just(notFound().build()),
299+
ResolvableMethod.onClass(TestController.class)
300+
.name("monoResponseEntityWildcard")
301+
.resolveReturnType());
302+
303+
this.resultHandler.handleResult(this.exchange, result).block(Duration.ofSeconds(5));
304+
305+
assertEquals(HttpStatus.NOT_FOUND, this.response.getStatusCode());
306+
assertNull(this.response.getBody());
307+
}
308+
292309

293310
private void testHandle(Object returnValue, ResolvableType type) {
294311
HandlerResult result = handlerResult(returnValue, type);

0 commit comments

Comments
 (0)