From c67cce1563913f7cb6746edf1abfe6b2a01e27f7 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 19 Nov 2015 11:35:40 -0500 Subject: [PATCH] INT-3892: Make ExpRatioTests Thread.sleep()-free JIRA: https://jira.spring.io/browse/INT-3892 **Cherry-pick to 4.2.x** --- .../management/ExponentialMovingAverageRatioTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRatioTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRatioTests.java index b7fcabfb76..cfc32c8ac3 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRatioTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/management/ExponentialMovingAverageRatioTests.java @@ -26,6 +26,8 @@ import org.junit.Test; /** * @author Dave Syer + * @author Gary Russell + * @author Artem Bilan * */ public class ExponentialMovingAverageRatioTests { @@ -42,8 +44,7 @@ public class ExponentialMovingAverageRatioTests { @Test public void testGetTimeSinceLastMeasurement() throws Exception { - history.success(); - Thread.sleep(20L); + history.success(System.nanoTime() - 20000000); assertThat(history.getTimeSinceLastMeasurement(), Matchers.greaterThan(0.)); } @@ -63,8 +64,7 @@ public class ExponentialMovingAverageRatioTests { @Test public void testDecayedMean() throws Exception { - history.failure(); - Thread.sleep(200L); + history.failure(System.nanoTime() - 200000000); assertEquals(average(0, Math.exp(-0.4)), history.getMean(), 0.01); }