use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class ViewResolutionResultHandlerTests method doesNotSupport.
@Test
public void doesNotSupport() throws Exception {
MethodParameter returnType = on(TestController.class).resolveReturnType(Integer.class);
ViewResolutionResultHandler resultHandler = resultHandler(mock(ViewResolver.class));
HandlerResult handlerResult = new HandlerResult(new Object(), null, returnType, this.bindingContext);
assertFalse(resultHandler.supports(handlerResult));
}
use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class ResponseEntityResultHandlerTests method statusCode.
@Test
public void statusCode() throws Exception {
ResponseEntity<Void> value = ResponseEntity.noContent().build();
MethodParameter returnType = on(TestController.class).resolveReturnType(entity(Void.class));
HandlerResult result = handlerResult(value, returnType);
MockServerWebExchange exchange = get("/path").toExchange();
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
assertEquals(HttpStatus.NO_CONTENT, exchange.getResponse().getStatusCode());
assertEquals(0, exchange.getResponse().getHeaders().size());
assertResponseBodyIsEmpty(exchange);
}
use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class ResponseBodyResultHandlerTests method supports.
@Test
public void supports() throws NoSuchMethodException {
Object controller = new TestController();
Method method;
method = on(TestController.class).annotPresent(ResponseBody.class).resolveMethod();
testSupports(controller, method);
method = on(TestController.class).annotNotPresent(ResponseBody.class).resolveMethod();
HandlerResult handlerResult = getHandlerResult(controller, method);
assertFalse(this.resultHandler.supports(handlerResult));
}
use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class ResponseEntityResultHandlerTests method handleReturnValueETagAndLastModified.
@Test
public void handleReturnValueETagAndLastModified() throws Exception {
String eTag = "\"deadb33f8badf00d\"";
Instant currentTime = Instant.now().truncatedTo(ChronoUnit.SECONDS);
Instant oneMinAgo = currentTime.minusSeconds(60);
MockServerWebExchange exchange = get("/path").ifNoneMatch(eTag).ifModifiedSince(currentTime.toEpochMilli()).toExchange();
ResponseEntity<String> entity = ok().eTag(eTag).lastModified(oneMinAgo.toEpochMilli()).body("body");
MethodParameter returnType = on(TestController.class).resolveReturnType(entity(String.class));
HandlerResult result = handlerResult(entity, returnType);
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
assertConditionalResponse(exchange, HttpStatus.NOT_MODIFIED, null, eTag, oneMinAgo);
}
use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class ResponseEntityResultHandlerTests method handleReturnValueLastModified.
@Test
public void handleReturnValueLastModified() throws Exception {
Instant currentTime = Instant.now().truncatedTo(ChronoUnit.SECONDS);
Instant oneMinAgo = currentTime.minusSeconds(60);
MockServerWebExchange exchange = get("/path").ifModifiedSince(currentTime.toEpochMilli()).toExchange();
ResponseEntity<String> entity = ok().lastModified(oneMinAgo.toEpochMilli()).body("body");
MethodParameter returnType = on(TestController.class).resolveReturnType(entity(String.class));
HandlerResult result = handlerResult(entity, returnType);
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
assertConditionalResponse(exchange, HttpStatus.NOT_MODIFIED, null, null, oneMinAgo);
}
Aggregations