You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2017/02/09 12:47:19 UTC

svn commit: r1782321 - /jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java

Author: sebb
Date: Thu Feb  9 12:47:19 2017
New Revision: 1782321

URL: http://svn.apache.org/viewvc?rev=1782321&view=rev
Log:
Allow for actual delay when calculating correct response

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java

Modified: jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java?rev=1782321&r1=1782320&r2=1782321&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java Thu Feb  9 12:47:19 2017
@@ -39,10 +39,14 @@ public class ConstantThroughputTimerTest
         ConstantThroughputTimer timer = new ConstantThroughputTimer();
         assertEquals(0,timer.getCalcMode());// Assume this thread only
         timer.setThroughput(60.0);// 1 per second
+        long start = System.currentTimeMillis();
         long delay = timer.delay(); // Initialise
         assertEquals(0,delay);
         Thread.sleep(500);
-        assertEquals("Expected delay of approx 500", 500, timer.delay(), 50);
+        long elapsed = System.currentTimeMillis() - start;
+        long expected = 1000-elapsed; // 1 second less what has already elapsed
+        if (expected < 0) expected = 0;
+        assertEquals("Expected delay of approx 500", expected, timer.delay(), 50);
     }
 
     @Test