|
18 | 18 |
|
19 | 19 | import static org.assertj.core.api.Assertions.assertThat;
|
20 | 20 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
| 21 | +import static org.awaitility.Awaitility.await; |
21 | 22 | import static org.mockito.ArgumentMatchers.any;
|
22 | 23 | import static org.mockito.ArgumentMatchers.anyMap;
|
23 | 24 | import static org.mockito.ArgumentMatchers.anyString;
|
|
166 | 167 |
|
167 | 168 | import io.micrometer.core.instrument.ImmutableTag;
|
168 | 169 | import io.micrometer.core.instrument.MeterRegistry;
|
| 170 | +import io.micrometer.core.instrument.Timer; |
| 171 | +import io.micrometer.core.instrument.search.MeterNotFoundException; |
169 | 172 | import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
170 | 173 |
|
171 | 174 | /**
|
@@ -563,23 +566,41 @@ public void testNulls() throws Exception {
|
563 | 566 | this.kafkaJsonTemplate.send("annotated12", null, null);
|
564 | 567 | assertThat(this.listener.latch8.await(60, TimeUnit.SECONDS)).isTrue();
|
565 | 568 |
|
566 |
| - assertThat(this.meterRegistry.get("spring.kafka.template") |
567 |
| - .tag("name", "kafkaJsonTemplate") |
568 |
| - .tag("extraTag", "bar") |
569 |
| - .tag("topic", "annotated12") |
570 |
| - .tag("result", "success") |
571 |
| - .timer() |
572 |
| - .count()) |
573 |
| - .isGreaterThan(0L); |
574 |
| - |
575 |
| - assertThat(this.meterRegistry.get("spring.kafka.listener") |
576 |
| - .tag("name", "quux-0") |
577 |
| - .tag("extraTag", "foo") |
578 |
| - .tag("topic", "annotated12") |
579 |
| - .tag("result", "success") |
580 |
| - .timer() |
581 |
| - .count()) |
582 |
| - .isGreaterThan(0L); |
| 569 | + await().untilAsserted(() -> { |
| 570 | + Timer timer = null; |
| 571 | + try { |
| 572 | + timer = this.meterRegistry.get("spring.kafka.template") |
| 573 | + .tag("name", "kafkaJsonTemplate") |
| 574 | + .tag("extraTag", "bar") |
| 575 | + .tag("topic", "annotated12") |
| 576 | + .tag("result", "success") |
| 577 | + .timer(); |
| 578 | + } |
| 579 | + catch (MeterNotFoundException ex) { |
| 580 | + } |
| 581 | + assertThat(timer) |
| 582 | + .describedAs("Timer not found in " + ((SimpleMeterRegistry) this.meterRegistry).getMetersAsString()) |
| 583 | + .isNotNull(); |
| 584 | + assertThat(timer.count()).isGreaterThan(0L); |
| 585 | + }); |
| 586 | + |
| 587 | + await().untilAsserted(() -> { |
| 588 | + Timer timer = null; |
| 589 | + try { |
| 590 | + timer = this.meterRegistry.get("spring.kafka.listener") |
| 591 | + .tag("name", "quux-0") |
| 592 | + .tag("extraTag", "foo") |
| 593 | + .tag("topic", "annotated12") |
| 594 | + .tag("result", "success") |
| 595 | + .timer(); |
| 596 | + } |
| 597 | + catch (MeterNotFoundException ex) { |
| 598 | + } |
| 599 | + assertThat(timer) |
| 600 | + .describedAs("Timer not found in " + ((SimpleMeterRegistry) this.meterRegistry).getMetersAsString()) |
| 601 | + .isNotNull(); |
| 602 | + assertThat(timer.count()).isGreaterThan(0L); |
| 603 | + }); |
583 | 604 | }
|
584 | 605 |
|
585 | 606 | @Test
|
|
0 commit comments