diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java index 4d967751378..438ab654521 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java @@ -83,6 +83,7 @@ import org.springframework.web.util.NestedServletException; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIOException; import static org.assertj.core.api.Assertions.fail; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -186,7 +187,7 @@ class WebMvcMetricsFilterTests { void streamingError() throws Exception { MvcResult result = this.mvc.perform(get("/api/c1/streamingError")).andExpect(request().asyncStarted()) .andReturn(); - this.mvc.perform(asyncDispatch(result)).andExpect(status().isOk()); + assertThatIOException().isThrownBy(() -> this.mvc.perform(asyncDispatch(result)).andReturn()); assertThat(this.registry.get("http.server.requests").tags("exception", "IOException").timer().count()) .isEqualTo(1L); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsIntegrationTests.java index 974654153e2..b604bd30803 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsIntegrationTests.java @@ -44,8 +44,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.util.NestedServletException; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -84,7 +86,8 @@ class WebMvcMetricsIntegrationTests { @Test void rethrownExceptionIsRecordedInMetricTag() throws Exception { - this.mvc.perform(get("/api/rethrownError")).andExpect(status().is5xxServerError()); + assertThatExceptionOfType(NestedServletException.class) + .isThrownBy(() -> this.mvc.perform(get("/api/rethrownError")).andReturn()); assertThat(this.registry.get("http.server.requests").tags("exception", "Exception2", "status", "500").timer() .count()).isEqualTo(1L); }