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

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

Loading…
Cancel
Save