Skip to content

Commit

Permalink
Fix batch metrics test
Browse files Browse the repository at this point in the history
Micrometer's global registry might contain other metrics than
those from Spring Batch. This commit updates the test to expect
at least those from Spring Batch to be registered.

Issue BATCH-2774
  • Loading branch information
fmbenhassine committed Apr 15, 2019
1 parent b24a05d commit 3bc00a7
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -20,7 +20,6 @@

import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.Metrics;
import org.hamcrest.Matchers;
import org.junit.Test;

import org.springframework.batch.core.ExitStatus;
Expand All @@ -42,11 +41,13 @@
import org.springframework.context.annotation.Configuration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class BatchMetricsTests {

private static final int EXPECTED_SPRING_BATCH_METRICS = 6;

@Test
public void testBatchMetrics() throws Exception {
// given
Expand All @@ -60,7 +61,7 @@ public void testBatchMetrics() throws Exception {
// then
assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
List<Meter> meters = Metrics.globalRegistry.getMeters();
assertThat(meters, Matchers.hasSize(7));
assertTrue(meters.size() >= EXPECTED_SPRING_BATCH_METRICS);

try {
Metrics.globalRegistry.get("spring.batch.job")
Expand Down

0 comments on commit 3bc00a7

Please sign in to comment.