Skip to content

Commit

Permalink
remove some test code to make test clearer
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Ivarsson <patrik.ivarsson@avanza.se>
  • Loading branch information
pativa committed Feb 15, 2025
1 parent 4ae7d09 commit d1e8546
Showing 1 changed file with 0 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,20 +373,6 @@ void bindingTwiceToSameRegistry_doesNotDoubleCount() {
void programmaticallyAddedLoggerConfigShouldBeCounted() {
LoggerContext context = new LoggerContext("test");

AtomicInteger newLoggerUpdatedWithLoggerFilter = new AtomicInteger();

// checks that updateLoggers() is called after MetricsFilter is added to the
// programmatically added logger
context.addPropertyChangeListener(event -> {
if (event.getNewValue() instanceof Configuration) {
Configuration newConfiguration = (Configuration) event.getNewValue();
LoggerConfig loggerConfig = newConfiguration.getLoggerConfig("com.test");
if (!loggerConfig.isAdditive() && loggerConfig.getFilter() instanceof Log4j2Metrics.MetricsFilter) {
newLoggerUpdatedWithLoggerFilter.incrementAndGet();
}
}
});

Log4j2Metrics metrics = new Log4j2Metrics(emptyList(), context);
metrics.bindTo(registry);

Expand All @@ -403,7 +389,6 @@ void programmaticallyAddedLoggerConfigShouldBeCounted() {
context.updateLoggers(configuration);

assertThat(addedLoggerConfig.getFilter()).isInstanceOf(Log4j2Metrics.MetricsFilter.class);
assertThat(newLoggerUpdatedWithLoggerFilter).hasValue(1);

logger.debug("test");
assertThat(registry.get("log4j2.events").tags("level", "debug").counter().count()).isEqualTo(1);
Expand Down

0 comments on commit d1e8546

Please # to comment.