@@ -0,0 +1,1949 @@
+/*%0A * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0%0A * (the %22License%22). You may not use this work except in compliance with the License, which is%0A * available at www.apache.org/licenses/LICENSE-2.0%0A *%0A * This software is distributed on an %22AS IS%22 basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,%0A * either express or implied, as more fully set forth in the License.%0A *%0A * See the NOTICE file distributed with this work for information regarding copyright ownership.%0A */%0A%0Apackage alluxio.retry;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0A/**%0A * Tests for the %7B@link TimeoutRetry%7D class.%0A */%0Apublic class TimeoutRetryTest %7B%0A%0A  /**%0A   * Tests that the provided timeout is respected.%0A   */%0A  @Test%0A  public void timeout() %7B%0A    final long timeoutMs = 1000;%0A    int attempts = 0;%0A    TimeoutRetry timeoutRetry = new TimeoutRetry(timeoutMs, 0);%0A    Assert.assertEquals(0, timeoutRetry.getRetryCount());%0A    long startMs = System.currentTimeMillis();%0A    while (timeoutRetry.attemptRetry()) %7B%0A      attempts++;%0A    %7D%0A    long endMs = System.currentTimeMillis();%0A    Assert.assertTrue(attempts %3E 0);%0A    Assert.assertTrue((endMs - startMs) %3E= timeoutMs);%0A    Assert.assertEquals(attempts, timeoutRetry.getRetryCount());%0A  %7D%0A%0A  /**%0A   * Tests the sleep parameter between attempts.%0A   */%0A  @Test%0A  public void sleep() %7B%0A    final long timeoutMs = 1000;%0A    final int sleepMs = 100;%0A    int attempts = 0;%0A    TimeoutRetry timeoutRetry = new TimeoutRetry(timeoutMs, sleepMs);%0A    Assert.assertEquals(0, timeoutRetry.getRetryCount());%0A    long startMs = System.currentTimeMillis();%0A    while (timeoutRetry.attemptRetry()) %7B%0A      attempts++;%0A    %7D%0A    long endMs = System.currentTimeMillis();%0A    Assert.assertTrue(attempts %3E 0);%0A    Assert.assertTrue((endMs - startMs) %3E= timeoutMs);%0A    Assert.assertEquals(attempts, timeoutRetry.getRetryCount());%0A    Assert.assertTrue(attempts %3C= timeoutMs / sleepMs);%0A  %7D%0A%7D%0A

Add test for TimeoutRetry