@@ -0,0 +1,2454 @@
+/*%0A * Copyright 2017-present Open Networking Laboratory%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage io.atomix.utils.concurrent;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A/**%0A * Retrying function test.%0A */%0Apublic class RetryingFunctionTest %7B%0A  private int round;%0A%0A  @Before%0A  public void setUp() %7B%0A    round = 1;%0A  %7D%0A%0A  @After%0A  public void tearDown() %7B%0A    round = 0;%0A  %7D%0A%0A  @Test(expected = RetryableException.class)%0A  public void testNoRetries() %7B%0A    new RetryingFunction%3C%3E(this::succeedAfterOneFailure, RetryableException.class, 0, 10).apply(null);%0A  %7D%0A%0A  @Test%0A  public void testSuccessAfterOneRetry() %7B%0A    new RetryingFunction%3C%3E(this::succeedAfterOneFailure, RetryableException.class, 1, 10).apply(null);%0A  %7D%0A%0A  @Test(expected = RetryableException.class)%0A  public void testFailureAfterOneRetry() %7B%0A    new RetryingFunction%3C%3E(this::succeedAfterTwoFailures, RetryableException.class, 1, 10).apply(null);%0A  %7D%0A%0A  @Test%0A  public void testFailureAfterTwoRetries() %7B%0A    new RetryingFunction%3C%3E(this::succeedAfterTwoFailures, RetryableException.class, 2, 10).apply(null);%0A  %7D%0A%0A  @Test(expected = NonRetryableException.class)%0A  public void testFailureWithNonRetryableFailure() %7B%0A    new RetryingFunction%3C%3E(this::failCompletely, RetryableException.class, 2, 10).apply(null);%0A  %7D%0A%0A  private String succeedAfterOneFailure(String input) %7B%0A    if (round++ %3C= 1) %7B%0A      throw new RetryableException();%0A    %7D else %7B%0A      return %22pass%22;%0A    %7D%0A  %7D%0A%0A  private String succeedAfterTwoFailures(String input) %7B%0A    if (round++ %3C= 2) %7B%0A      throw new RetryableException();%0A    %7D else %7B%0A      return %22pass%22;%0A    %7D%0A  %7D%0A%0A  private String failCompletely(String input) %7B%0A    if (round++ %3C= 1) %7B%0A      throw new NonRetryableException();%0A    %7D else %7B%0A      return %22pass%22;%0A    %7D%0A  %7D%0A%0A  private class RetryableException extends RuntimeException %7B%0A  %7D%0A%0A  private class NonRetryableException extends RuntimeException %7B%0A  %7D%0A%7D%0A

Add retrying function test.