Add error rendering support with @WebFluxTest

See gh-16266
This commit is contained in:
Ali Dehghani
2019-03-19 21:48:17 +03:30
committed by Stephane Nicoll
parent 62d9c0a8b3
commit 53e7484d87
3 changed files with 14 additions and 1 deletions

View File

@@ -100,7 +100,8 @@ org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration,\
org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration,\
org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration
# AutoConfigureMockMvc auto-configuration imports
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc=\

View File

@@ -18,6 +18,8 @@ package org.springframework.boot.test.autoconfigure.web.reactive.webclient;
import reactor.core.publisher.Mono;
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
@@ -27,8 +29,10 @@ import org.springframework.web.server.WebExceptionHandler;
* Example {@link WebExceptionHandler} used with {@link WebFluxTest} tests.
*
* @author Madhura Bhave
* @author Ali Dehghani
*/
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class ExampleWebExceptionHandler implements WebExceptionHandler {
@Override

View File

@@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfigura
import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration;
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;
@@ -37,6 +38,7 @@ import static org.springframework.boot.test.autoconfigure.AutoConfigurationImpor
*
* @author Stephane Nicoll
* @author Artsiom Yudovin
* @author Ali Dehghani
*/
@RunWith(SpringRunner.class)
@WebFluxTest
@@ -75,4 +77,10 @@ public class WebFluxTestAutoConfigurationIntegrationTests {
.has(importedAutoConfiguration(ThymeleafAutoConfiguration.class));
}
@Test
public void errorWebFluxAutoConfigurationIsImported() {
assertThat(this.applicationContext)
.has(importedAutoConfiguration(ErrorWebFluxAutoConfiguration.class));
}
}