Skip to content

Commit 105df82

Browse files
committed
Polish
1 parent 2cdceb9 commit 105df82

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
import static org.assertj.core.api.Assertions.assertThat;
8484
import static org.assertj.core.api.Assertions.assertThatCode;
8585
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
86+
import static org.assertj.core.api.Assertions.assertThatIOException;
8687
import static org.assertj.core.api.Assertions.fail;
8788
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
8889
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@@ -186,7 +187,7 @@ void unhandledError() {
186187
void streamingError() throws Exception {
187188
MvcResult result = this.mvc.perform(get("/api/c1/streamingError")).andExpect(request().asyncStarted())
188189
.andReturn();
189-
this.mvc.perform(asyncDispatch(result)).andExpect(status().isOk());
190+
assertThatIOException().isThrownBy(() -> this.mvc.perform(asyncDispatch(result)).andReturn());
190191
assertThat(this.registry.get("http.server.requests").tags("exception", "IOException").timer().count())
191192
.isEqualTo(1L);
192193
}

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsIntegrationTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@
4444
import org.springframework.web.bind.annotation.RestController;
4545
import org.springframework.web.context.WebApplicationContext;
4646
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
47+
import org.springframework.web.util.NestedServletException;
4748

4849
import static org.assertj.core.api.Assertions.assertThat;
50+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
4951
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
5052
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
5153

@@ -84,7 +86,8 @@ void handledExceptionIsRecordedInMetricTag() throws Exception {
8486

8587
@Test
8688
void rethrownExceptionIsRecordedInMetricTag() throws Exception {
87-
this.mvc.perform(get("/api/rethrownError")).andExpect(status().is5xxServerError());
89+
assertThatExceptionOfType(NestedServletException.class)
90+
.isThrownBy(() -> this.mvc.perform(get("/api/rethrownError")).andReturn());
8891
assertThat(this.registry.get("http.server.requests").tags("exception", "Exception2", "status", "500").timer()
8992
.count()).isEqualTo(1L);
9093
}

0 commit comments

Comments
 (0)