Skip to content

Commit 7e21308

Browse files
committed
Add test for suppressed warnings; clarify some test method names
1 parent e40fcd6 commit 7e21308

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

metrics/providers/micrometer/src/test/java/io/helidon/metrics/providers/micrometer/TestMultipleRegistryLogging.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.PrintStream;
2121

2222
import io.helidon.metrics.api.Metrics;
23+
import io.helidon.metrics.api.MetricsConfig;
2324
import io.helidon.metrics.api.MetricsFactory;
2425

2526
import org.junit.jupiter.api.AfterAll;
@@ -33,6 +34,7 @@
3334
import static org.hamcrest.Matchers.isEmptyString;
3435

3536
import static org.hamcrest.MatcherAssert.assertThat;
37+
import static org.hamcrest.Matchers.not;
3638

3739
class TestMultipleRegistryLogging {
3840

@@ -65,15 +67,15 @@ static void afterAll() {
6567
}
6668

6769
@Test
68-
void testSingleRegistration() throws IOException {
70+
void testSingleRegistry() throws IOException {
6971
Metrics.globalRegistry();
7072
testPrintStream.flush();
7173
String output = baos.toString();
7274
assertThat("Single meter registry", output, isEmptyString());
7375
}
7476

7577
@Test
76-
void testTwoRegistrations() throws IOException {
78+
void testTwoRegistries() throws IOException {
7779
Metrics.globalRegistry();
7880
Metrics.createMeterRegistry();
7981
testPrintStream.flush();
@@ -86,7 +88,7 @@ void testTwoRegistrations() throws IOException {
8688
}
8789

8890
@Test
89-
void testThreeRegistrations() throws IOException {
91+
void testThreeRegistries() throws IOException {
9092
Metrics.globalRegistry();
9193
Metrics.createMeterRegistry();
9294
Metrics.createMeterRegistry();
@@ -100,4 +102,20 @@ void testThreeRegistrations() throws IOException {
100102
containsString("Unexpected additional instantiation")));
101103
}
102104

105+
@Test
106+
void testTwoRegistriesWithWarningDisabled() {
107+
MetricsConfig configWithWarningsSuppressed = MetricsConfig.builder().warnOnMultipleRegistries(false).build();
108+
Metrics.createMeterRegistry(configWithWarningsSuppressed);
109+
Metrics.createMeterRegistry(configWithWarningsSuppressed);
110+
testPrintStream.flush();
111+
112+
String output = baos.toString();
113+
assertThat("Two meter registrations with warnings suppressed", output, allOf(
114+
not(containsString("Unexpected duplicate")),
115+
not(containsString("Original instantiation")),
116+
not(containsString("Additional instantiation")),
117+
not(containsString("Unexpected additional instantiation"))));
118+
119+
}
120+
103121
}

0 commit comments

Comments
 (0)