Fix batch metrics test
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
This commit is contained in:
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
|
||||
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;
|
||||
@@ -42,11 +41,13 @@ import org.springframework.context.annotation.Bean;
|
||||
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
|
||||
@@ -60,7 +61,7 @@ public class BatchMetricsTests {
|
||||
// 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")
|
||||
|
||||
Reference in New Issue
Block a user