INT-1508: add reset()
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Ignore;
|
||||
@@ -74,4 +75,17 @@ public class ExponentialMovingAverageRateTests {
|
||||
assertTrue("Standard deviation should be non-zero: " + history, history.getStandardDeviation() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testReset() throws Exception {
|
||||
assertEquals(0, history.getStandardDeviation(), 0.01);
|
||||
history.increment();
|
||||
Thread.sleep(30L);
|
||||
history.increment();
|
||||
assertFalse(0==history.getStandardDeviation());
|
||||
history.reset();
|
||||
assertEquals(0, history.getStandardDeviation(), 0.01);
|
||||
assertEquals("[[N=0, min=0.000000, max=0.000000, mean=0.000000, sigma=0.000000], timeSinceLast=0.000000]", history.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -104,6 +105,17 @@ public class ExponentialMovingAverageRatioTests {
|
||||
assertEquals(0, history.getStandardDeviation(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReset() throws Exception {
|
||||
assertEquals(0, history.getStandardDeviation(), 0.01);
|
||||
history.success();
|
||||
history.failure();
|
||||
assertFalse(0==history.getStandardDeviation());
|
||||
history.reset();
|
||||
assertEquals(0, history.getStandardDeviation(), 0.01);
|
||||
assertEquals("[[N=0, min=0.000000, max=0.000000, mean=1.000000, sigma=0.000000], timeSinceLast=0.000000]", history.toString());
|
||||
}
|
||||
|
||||
private double average(double... values) {
|
||||
int count = 0;
|
||||
double sum = 0;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.integration.monitor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -50,4 +51,15 @@ public class ExponentialMovingAverageTests {
|
||||
assertEquals(0, history.getStandardDeviation(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReset() throws Exception {
|
||||
assertEquals(0, history.getStandardDeviation(), 0.01);
|
||||
history.append(1);
|
||||
history.append(2);
|
||||
assertFalse(0==history.getStandardDeviation());
|
||||
history.reset();
|
||||
assertEquals(0, history.getStandardDeviation(), 0.01);
|
||||
assertEquals("[N=0, min=0.000000, max=0.000000, mean=0.000000, sigma=0.000000]", history.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user