Polish "Align prefix match in BufferCounterService with DefaultCounterService"
See gh-10278
This commit is contained in:
parent
dcb81a3da5
commit
aca30950cf
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,12 +21,10 @@ import org.junit.Test;
|
||||||
import org.springframework.boot.actuate.metrics.CounterService;
|
import org.springframework.boot.actuate.metrics.CounterService;
|
||||||
import org.springframework.boot.actuate.metrics.Metric;
|
import org.springframework.boot.actuate.metrics.Metric;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard tests for {@link BufferCounterService}.
|
* Tests for {@link BufferCounterService}.
|
||||||
*
|
*
|
||||||
* @author Venil Noronha
|
* @author Venil Noronha
|
||||||
*/
|
*/
|
||||||
|
|
@ -36,56 +34,52 @@ public class BufferCounterServiceTests {
|
||||||
|
|
||||||
private CounterService service = new BufferCounterService(this.counters);
|
private CounterService service = new BufferCounterService(this.counters);
|
||||||
|
|
||||||
private BufferMetricReader reader = new BufferMetricReader(this.counters, new GaugeBuffers());
|
private BufferMetricReader reader = new BufferMetricReader(this.counters,
|
||||||
|
new GaugeBuffers());
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void matchExtendedPrefix() {
|
public void matchExtendedPrefix() {
|
||||||
this.service.increment("foo");
|
this.service.increment("foo");
|
||||||
Metric<?> fooMetric = this.reader.findOne("foo");
|
assertThat(this.reader.findOne("foo")).isNull();
|
||||||
Metric<?> counterFooMetric = this.reader.findOne("counter.foo");
|
Metric<?> counterFooMetric = this.reader.findOne("counter.foo");
|
||||||
assertNull(fooMetric);
|
assertThat(counterFooMetric).isNotNull();
|
||||||
assertNotNull(counterFooMetric);
|
assertThat(counterFooMetric.getValue()).isEqualTo(1L);
|
||||||
assertEquals(1L, counterFooMetric.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void matchCounterPrefix() {
|
public void matchCounterPrefix() {
|
||||||
this.service.increment("counterfoo");
|
this.service.increment("counterfoo");
|
||||||
Metric<?> counterfooMetric = this.reader.findOne("counterfoo");
|
assertThat(this.reader.findOne("counterfoo")).isNull();
|
||||||
Metric<?> counterCounterfooMetric = this.reader.findOne("counter.counterfoo");
|
Metric<?> counterCounterfooMetric = this.reader.findOne("counter.counterfoo");
|
||||||
assertNull(counterfooMetric);
|
assertThat(counterCounterfooMetric).isNotNull();
|
||||||
assertNotNull(counterCounterfooMetric);
|
assertThat(counterCounterfooMetric.getValue()).isEqualTo(1L);
|
||||||
assertEquals(1L, counterCounterfooMetric.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void matchCounterDotPrefix() {
|
public void matchCounterDotPrefix() {
|
||||||
this.service.increment("counter.foo");
|
this.service.increment("counter.foo");
|
||||||
|
assertThat(this.reader.findOne("counter.counter.foo")).isNull();
|
||||||
Metric<?> counterFooMetric = this.reader.findOne("counter.foo");
|
Metric<?> counterFooMetric = this.reader.findOne("counter.foo");
|
||||||
Metric<?> counterCounterFooMetric = this.reader.findOne("counter.counter.foo");
|
assertThat(counterFooMetric).isNotNull();
|
||||||
assertNull(counterCounterFooMetric);
|
assertThat(counterFooMetric.getValue()).isEqualTo(1L);
|
||||||
assertNotNull(counterFooMetric);
|
|
||||||
assertEquals(1L, counterFooMetric.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void matchMeterPrefix() {
|
public void matchMeterPrefix() {
|
||||||
this.service.increment("meterfoo");
|
this.service.increment("meterfoo");
|
||||||
Metric<?> meterfooMetric = this.reader.findOne("meterfoo");
|
assertThat(this.reader.findOne("meterfoo")).isNull();
|
||||||
Metric<?> counterMeterfooMetric = this.reader.findOne("counter.meterfoo");
|
Metric<?> counterMeterfooMetric = this.reader.findOne("counter.meterfoo");
|
||||||
assertNull(meterfooMetric);
|
assertThat(counterMeterfooMetric).isNotNull();
|
||||||
assertNotNull(counterMeterfooMetric);
|
assertThat(counterMeterfooMetric.getValue()).isEqualTo(1L);
|
||||||
assertEquals(1L, counterMeterfooMetric.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void matchMeterDotPrefix() {
|
public void matchMeterDotPrefix() {
|
||||||
this.service.increment("meter.foo");
|
this.service.increment("meter.foo");
|
||||||
|
assertThat(this.reader.findOne("counter.meter.foo")).isNull();
|
||||||
Metric<?> meterFooMetric = this.reader.findOne("meter.foo");
|
Metric<?> meterFooMetric = this.reader.findOne("meter.foo");
|
||||||
Metric<?> counterMeterFooMetric = this.reader.findOne("counter.meter.foo");
|
assertThat(meterFooMetric).isNotNull();
|
||||||
assertNull(counterMeterFooMetric);
|
assertThat(meterFooMetric.getValue()).isEqualTo(1L);
|
||||||
assertNotNull(meterFooMetric);
|
|
||||||
assertEquals(1L, meterFooMetric.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue