pom, ut method names

This commit is contained in:
Diane Duan 2017-01-17 09:56:45 +08:00
parent ccd3e5b728
commit 63d20dc1b1
6 changed files with 16 additions and 13 deletions

View File

@ -15,6 +15,8 @@
<properties>
<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>
<dependencies>
@ -41,12 +43,13 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<version>${dep.ver.servlet}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>${dep.ver.junit}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -5,6 +5,6 @@ import com.codahale.metrics.health.HealthCheck;
public class DatabaseHealthCheck extends HealthCheck {
@Override
protected Result check() throws Exception {
return HealthCheck.Result.healthy();
return Result.healthy();
}
}

View File

@ -14,7 +14,7 @@ import com.codahale.metrics.*;
public class MetricsTest {
@Test
public void testMeter() throws InterruptedException {
public void whenMarkMeter_thenCorrectRates() throws InterruptedException {
Meter meter = new Meter();
long initCount = meter.getCount();
@ -38,13 +38,13 @@ public class MetricsTest {
}
@Test
public void testRatioGauge() {
public void whenInitRatioGauge_thenCorrectRatio() {
Gauge<Double> ratioGauge = new AttendanceRatioGauge(15, 20);
assertThat(ratioGauge.getValue(), equalTo(0.75));
}
@Test
public void testCacheGauge() {
public void whenUseCacheGauge_thenCorrectGauge() {
Gauge<List<Long>> activeUsersGauge = new ActiveUsersGauge(15, TimeUnit.MINUTES);
List<Long> expected = new ArrayList<Long>();
expected.add(12L);
@ -52,14 +52,14 @@ public class MetricsTest {
}
@Test
public void testDerivativeGauge() {
public void whenUseDerivativeGauge_thenCorrectGaugeFromBase() {
Gauge<List<Long>> activeUsersGauge = new ActiveUsersGauge(15, TimeUnit.MINUTES);
Gauge<Integer> activeUserCountGauge = new ActiveUserCountGauge(activeUsersGauge);
assertThat(activeUserCountGauge.getValue(), equalTo(1));
}
@Test
public void testCounter() {
public void whenIncDecCounter_thenCorrectCount() {
Counter counter = new Counter();
long initCount = counter.getCount();
@ -79,7 +79,7 @@ public class MetricsTest {
}
@Test
public void testHistogram() {
public void whenUpdateHistogram_thenCorrectDistributionData() {
Histogram histogram = new Histogram(new UniformReservoir());
histogram.update(5);
@ -119,7 +119,7 @@ public class MetricsTest {
}
@Test
public void testTimer() throws InterruptedException {
public void whenUseTimer_thenCorrectTimerContexts() throws InterruptedException {
Timer timer = new Timer();
Timer.Context context1 = timer.time();

View File

@ -8,7 +8,7 @@ import com.codahale.metrics.*;
public class ReporterTest {
@Test
public void testConsoleReporter() {
public void whenConsoleReporter_thenOutputReport() {
MetricRegistry metricRegistry = new MetricRegistry();
Meter meter = metricRegistry.meter("meter");

View File

@ -12,7 +12,7 @@ import com.codahale.metrics.health.HealthCheckRegistry;
public class HealthCheckTest {
@Test
public void testHealthCheck() {
public void whenUseHealthCheck_thenHealthChecked() {
HealthCheckRegistry healthCheckRegistry = new HealthCheckRegistry();
healthCheckRegistry.register("db", new DatabaseHealthCheck());

View File

@ -74,6 +74,7 @@
<module>lombok</module>
<module>mapstruct</module>
<module>metrics</module>
<module>mockito</module>
<module>mocks</module>
@ -173,7 +174,6 @@
<module>xml</module>
<module>xmlunit2</module>
<module>xstream</module>
<module>metrics</module>
</modules>
</project>