pull/11811/head
Phillip Webb 7 years ago
parent 53b0f0db60
commit 5767350380

@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.MockClock;
import io.micrometer.core.instrument.Timer;
import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.logging.LogbackMetrics;
@ -128,9 +129,10 @@ public class MetricsAutoConfigurationIntegrationTests {
MockClock.clock(this.registry).addSeconds(2);
this.cyclicBarrier.await();
backgroundRequest.join();
assertThat(this.registry.find("http.server.requests").tags("uri", "/api/async")
.timer()).matches(t -> t.count() == 1)
.matches(t -> t.totalTime(TimeUnit.SECONDS) == 2);
Timer timer = this.registry.get("http.server.requests").tags("uri", "/api/async")
.timer();
assertThat(timer.count()).isEqualTo(1);
assertThat(timer.totalTime(TimeUnit.SECONDS)).isEqualTo(2);
}
@Configuration

@ -64,9 +64,7 @@ public class MetricsRestTemplateCustomizerTests {
@Test
public void interceptRestTemplate() {
MockRestServiceServer mockServer = MockRestServiceServer
.createServer(this.restTemplate);
mockServer.expect(MockRestRequestMatchers.requestTo("/test/123"))
this.mockServer.expect(MockRestRequestMatchers.requestTo("/test/123"))
.andExpect(MockRestRequestMatchers.method(HttpMethod.GET))
.andRespond(MockRestResponseCreators.withSuccess("OK",
MediaType.APPLICATION_JSON));
@ -79,7 +77,7 @@ public class MetricsRestTemplateCustomizerTests {
.tags("method", "GET", "uri", "/test/{id}", "status", "200").timer()
.count()).isEqualTo(1);
assertThat(result).isEqualTo("OK");
mockServer.verify();
this.mockServer.verify();
}
@Test

Loading…
Cancel
Save