use of org.springframework.web.server.WebExceptionHandler in project spring-framework by spring-projects.
the class ExceptionHandlingHttpHandlerTests method unresolvedException.
@Test
public void unresolvedException() throws Exception {
WebExceptionHandler exceptionHandler = new UnresolvedExceptionHandler();
createWebHandler(exceptionHandler).handle(this.exchange).block();
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, this.exchange.getResponse().getStatusCode());
}
use of org.springframework.web.server.WebExceptionHandler in project spring-framework by spring-projects.
the class ExceptionHandlingHttpHandlerTests method handleErrorSignal.
@Test
public void handleErrorSignal() throws Exception {
WebExceptionHandler exceptionHandler = new BadRequestExceptionHandler();
createWebHandler(exceptionHandler).handle(this.exchange).block();
assertEquals(HttpStatus.BAD_REQUEST, this.exchange.getResponse().getStatusCode());
}
use of org.springframework.web.server.WebExceptionHandler in project spring-framework by spring-projects.
the class ExceptionHandlingHttpHandlerTests method thrownExceptionBecomesErrorSignal.
@Test
public void thrownExceptionBecomesErrorSignal() throws Exception {
WebExceptionHandler exceptionHandler = new BadRequestExceptionHandler();
createWebHandler(exceptionHandler).handle(this.exchange).block();
assertEquals(HttpStatus.BAD_REQUEST, this.exchange.getResponse().getStatusCode());
}
use of org.springframework.web.server.WebExceptionHandler in project spring-framework by spring-projects.
the class DispatcherHandlerErrorTests method webExceptionHandler.
@Test
public void webExceptionHandler() throws Exception {
ServerWebExchange exchange = MockServerHttpRequest.get("/unknown-argument-type").toExchange();
List<WebExceptionHandler> handlers = Collections.singletonList(new ServerError500ExceptionHandler());
WebHandler webHandler = new ExceptionHandlingWebHandler(this.dispatcherHandler, handlers);
webHandler.handle(exchange).block(Duration.ofSeconds(5));
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, exchange.getResponse().getStatusCode());
}
Aggregations