package org.skyscreamer.nevado.jms.util;

import org.junit.Assert;
import org.junit.Test;

/**
 * Tests the BackoffSleeper.
 *
 * @author Carter Page <carter@skyscreamer.org>
 */
public class BackoffSleeperTest {
    // Cloudbees needs coarse resolution because their boxes have heavy contention
    public static final int ACCEPTABLE_DELTA_MS = 50;

    @Test
    public void testBackoffSleeper() throws InterruptedException {
        BackoffSleeper sleeper = new BackoffSleeper(50, 230, 2.0);
        long now = System.currentTimeMillis();
        sleeper.sleep();
        Assert.assertEquals(now + 50, System.currentTimeMillis(), ACCEPTABLE_DELTA_MS);
        sleeper.sleep();
        Assert.assertEquals(now + 150, System.currentTimeMillis(), ACCEPTABLE_DELTA_MS);
        sleeper.sleep();
        Assert.assertEquals(now + 350, System.currentTimeMillis(), ACCEPTABLE_DELTA_MS);
        sleeper.sleep();
        Assert.assertEquals(now + 580, System.currentTimeMillis(), ACCEPTABLE_DELTA_MS);
        sleeper.sleep();
        Assert.assertEquals(now + 810, System.currentTimeMillis(), ACCEPTABLE_DELTA_MS);
        sleeper.reset();
        Assert.assertEquals(now + 810, System.currentTimeMillis(), ACCEPTABLE_DELTA_MS);
        sleeper.sleep();
        Assert.assertEquals(now + 860, System.currentTimeMillis(), ACCEPTABLE_DELTA_MS);
    }
}

@@ -210,146 +210,8 @@
 t %7B%0A
-    // Cloudbees needs coarse resolution because their boxes have heavy contention%0A    public static final int ACCEPTABLE_DELTA_MS = 50;%0A%0A
     
@@ -488,35 +488,18 @@
 llis(), 
-ACCEPTABLE_DELTA_MS
+50
 );%0A     
@@ -585,35 +585,19 @@
 llis(), 
-ACCEPTABLE_DELTA_MS
+100
 );%0A     
@@ -683,35 +683,19 @@
 llis(), 
-ACCEPTABLE_DELTA_MS
+100
 );%0A     
@@ -781,35 +781,19 @@
 llis(), 
-ACCEPTABLE_DELTA_MS
+100
 );%0A     
@@ -879,35 +879,19 @@
 llis(), 
-ACCEPTABLE_DELTA_MS
+100
 );%0A     
@@ -977,35 +977,19 @@
 llis(), 
-ACCEPTABLE_DELTA_MS
+100
 );%0A     
@@ -1079,27 +1079,11 @@
 (), 
-ACCEPTABLE_DELTA_MS
+100
 );%0A 

Update BackoffSleeperTest.java