Browse Source

Polish

pull/17778/head
Phillip Webb 7 years ago
parent
commit
105df823ee
  1. 3
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java
  2. 5
      spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsIntegrationTests.java

3
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; @@ -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 { @@ -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);
}

5
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; @@ -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 { @@ -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…
Cancel
Save