Skip to content

Commit

Permalink
Add test for failed poll scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Apr 14, 2021
1 parent 17024fb commit bd41978
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@

import static java.util.Collections.singletonList;
import static java.util.stream.IntStream.range;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.assertj.core.api.Assertions.*;

/**
* Tests for {@link StatsdMeterRegistry}.
Expand Down Expand Up @@ -543,6 +542,17 @@ void stopTrackingMetersThatAreRemoved() {
assertThat(lines.get("functioncounter")).isEqualTo(1);
}

@Test
void pollFailureNotFatal() {
registry = StatsdMeterRegistry.builder(StatsdConfig.DEFAULT).build();
Gauge.builder("fails", "", o -> {
throw new RuntimeException();
}).register(registry);
Gauge.builder("works", () -> 42).register(registry);

assertThatCode(() -> registry.poll()).doesNotThrowAnyException();
}

private UnicastProcessor<String> lineProcessor() {
return UnicastProcessor.create(Queues.<String>unboundedMultiproducer().get());
}
Expand Down

0 comments on commit bd41978

Please sign in to comment.