From f2005b658bdfd533bf55fc0ed94ad56020ed1d57 Mon Sep 17 00:00:00 2001 From: Patrik Ivarsson Date: Fri, 17 Jan 2025 13:33:54 +0100 Subject: [PATCH] small test cleanup Signed-off-by: Patrik Ivarsson --- .../instrument/binder/logging/Log4j2MetricsTest.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/logging/Log4j2MetricsTest.java b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/logging/Log4j2MetricsTest.java index 77b774d723..1b3ca36eae 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/logging/Log4j2MetricsTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/logging/Log4j2MetricsTest.java @@ -187,9 +187,8 @@ void asyncLogShouldNotBeDuplicated() throws IOException { @Issue("#5756") @Test void rebindsMetricsWhenConfigurationIsReloaded() { - MeterRegistry registry = new SimpleMeterRegistry(); - LoggerContext context = (LoggerContext) LogManager.getContext(false); - Logger logger = context.getLogger(getClass()); + LoggerContext context = new LoggerContext("test"); + Logger logger = context.getLogger("com.test"); try (Log4j2Metrics metrics = new Log4j2Metrics(emptyList(), context)) { metrics.bindTo(registry); @@ -208,9 +207,8 @@ void rebindsMetricsWhenConfigurationIsReloaded() { @Test void shouldNotRebindMetricsIfBinderIsClosed() { - MeterRegistry registry = new SimpleMeterRegistry(); - LoggerContext context = (LoggerContext) LogManager.getContext(false); - Logger logger = context.getLogger(getClass()); + LoggerContext context = new LoggerContext("test"); + Logger logger = context.getLogger("com.test"); try (Log4j2Metrics metrics = new Log4j2Metrics(emptyList(), context)) { metrics.bindTo(registry);