pom, ut method names
This commit is contained in:
parent
ccd3e5b728
commit
63d20dc1b1
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<dep.ver.metrics>3.1.0</dep.ver.metrics>
|
<dep.ver.metrics>3.1.0</dep.ver.metrics>
|
||||||
|
<dep.ver.servlet>3.1.0</dep.ver.servlet>
|
||||||
|
<dep.ver.junit>4.12</dep.ver.junit>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -41,12 +43,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>${dep.ver.servlet}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>${dep.ver.junit}</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -5,6 +5,6 @@ import com.codahale.metrics.health.HealthCheck;
|
||||||
public class DatabaseHealthCheck extends HealthCheck {
|
public class DatabaseHealthCheck extends HealthCheck {
|
||||||
@Override
|
@Override
|
||||||
protected Result check() throws Exception {
|
protected Result check() throws Exception {
|
||||||
return HealthCheck.Result.healthy();
|
return Result.healthy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import com.codahale.metrics.*;
|
||||||
|
|
||||||
public class MetricsTest {
|
public class MetricsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMeter() throws InterruptedException {
|
public void whenMarkMeter_thenCorrectRates() throws InterruptedException {
|
||||||
Meter meter = new Meter();
|
Meter meter = new Meter();
|
||||||
|
|
||||||
long initCount = meter.getCount();
|
long initCount = meter.getCount();
|
||||||
|
@ -38,13 +38,13 @@ public class MetricsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRatioGauge() {
|
public void whenInitRatioGauge_thenCorrectRatio() {
|
||||||
Gauge<Double> ratioGauge = new AttendanceRatioGauge(15, 20);
|
Gauge<Double> ratioGauge = new AttendanceRatioGauge(15, 20);
|
||||||
assertThat(ratioGauge.getValue(), equalTo(0.75));
|
assertThat(ratioGauge.getValue(), equalTo(0.75));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCacheGauge() {
|
public void whenUseCacheGauge_thenCorrectGauge() {
|
||||||
Gauge<List<Long>> activeUsersGauge = new ActiveUsersGauge(15, TimeUnit.MINUTES);
|
Gauge<List<Long>> activeUsersGauge = new ActiveUsersGauge(15, TimeUnit.MINUTES);
|
||||||
List<Long> expected = new ArrayList<Long>();
|
List<Long> expected = new ArrayList<Long>();
|
||||||
expected.add(12L);
|
expected.add(12L);
|
||||||
|
@ -52,14 +52,14 @@ public class MetricsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDerivativeGauge() {
|
public void whenUseDerivativeGauge_thenCorrectGaugeFromBase() {
|
||||||
Gauge<List<Long>> activeUsersGauge = new ActiveUsersGauge(15, TimeUnit.MINUTES);
|
Gauge<List<Long>> activeUsersGauge = new ActiveUsersGauge(15, TimeUnit.MINUTES);
|
||||||
Gauge<Integer> activeUserCountGauge = new ActiveUserCountGauge(activeUsersGauge);
|
Gauge<Integer> activeUserCountGauge = new ActiveUserCountGauge(activeUsersGauge);
|
||||||
assertThat(activeUserCountGauge.getValue(), equalTo(1));
|
assertThat(activeUserCountGauge.getValue(), equalTo(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCounter() {
|
public void whenIncDecCounter_thenCorrectCount() {
|
||||||
Counter counter = new Counter();
|
Counter counter = new Counter();
|
||||||
|
|
||||||
long initCount = counter.getCount();
|
long initCount = counter.getCount();
|
||||||
|
@ -79,7 +79,7 @@ public class MetricsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHistogram() {
|
public void whenUpdateHistogram_thenCorrectDistributionData() {
|
||||||
Histogram histogram = new Histogram(new UniformReservoir());
|
Histogram histogram = new Histogram(new UniformReservoir());
|
||||||
|
|
||||||
histogram.update(5);
|
histogram.update(5);
|
||||||
|
@ -119,7 +119,7 @@ public class MetricsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTimer() throws InterruptedException {
|
public void whenUseTimer_thenCorrectTimerContexts() throws InterruptedException {
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
|
|
||||||
Timer.Context context1 = timer.time();
|
Timer.Context context1 = timer.time();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.codahale.metrics.*;
|
||||||
|
|
||||||
public class ReporterTest {
|
public class ReporterTest {
|
||||||
@Test
|
@Test
|
||||||
public void testConsoleReporter() {
|
public void whenConsoleReporter_thenOutputReport() {
|
||||||
MetricRegistry metricRegistry = new MetricRegistry();
|
MetricRegistry metricRegistry = new MetricRegistry();
|
||||||
|
|
||||||
Meter meter = metricRegistry.meter("meter");
|
Meter meter = metricRegistry.meter("meter");
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.codahale.metrics.health.HealthCheckRegistry;
|
||||||
|
|
||||||
public class HealthCheckTest {
|
public class HealthCheckTest {
|
||||||
@Test
|
@Test
|
||||||
public void testHealthCheck() {
|
public void whenUseHealthCheck_thenHealthChecked() {
|
||||||
HealthCheckRegistry healthCheckRegistry = new HealthCheckRegistry();
|
HealthCheckRegistry healthCheckRegistry = new HealthCheckRegistry();
|
||||||
|
|
||||||
healthCheckRegistry.register("db", new DatabaseHealthCheck());
|
healthCheckRegistry.register("db", new DatabaseHealthCheck());
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -74,6 +74,7 @@
|
||||||
<module>lombok</module>
|
<module>lombok</module>
|
||||||
|
|
||||||
<module>mapstruct</module>
|
<module>mapstruct</module>
|
||||||
|
<module>metrics</module>
|
||||||
<module>mockito</module>
|
<module>mockito</module>
|
||||||
<module>mocks</module>
|
<module>mocks</module>
|
||||||
|
|
||||||
|
@ -173,7 +174,6 @@
|
||||||
<module>xml</module>
|
<module>xml</module>
|
||||||
<module>xmlunit2</module>
|
<module>xmlunit2</module>
|
||||||
<module>xstream</module>
|
<module>xstream</module>
|
||||||
<module>metrics</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue