Polish
This commit is contained in:
parent
2cdceb92bf
commit
105df823ee
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue