Package org.springframework.util.backoff

Examples of org.springframework.util.backoff.FixedBackOff


    }
    return true;
  }

  private FixedBackOff createDefaultBackOff(long interval) {
    return new FixedBackOff(interval, Long.MAX_VALUE);
  }
View Full Code Here


    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
  }

  @Test
  public void toStringContent() {
    FixedBackOff backOff = new FixedBackOff(200L, 10);
    BackOffExecution execution = backOff.start();
    assertEquals("FixedBackOff{interval=200, currentAttempts=0, maxAttempts=10}", execution.toString());
    execution.nextBackOff();
    assertEquals("FixedBackOff{interval=200, currentAttempts=1, maxAttempts=10}", execution.toString());
    execution.nextBackOff();
    assertEquals("FixedBackOff{interval=200, currentAttempts=2, maxAttempts=10}", execution.toString());
View Full Code Here

*/
public class FixedBackOffTests {

  @Test
  public void defaultInstance() {
    FixedBackOff backOff = new FixedBackOff();
    BackOffExecution execution = backOff.start();
    for (int i = 0; i < 100; i++) {
      assertEquals(FixedBackOff.DEFAULT_INTERVAL, execution.nextBackOff());
    }
  }
View Full Code Here

    }
  }

  @Test
  public void noAttemptAtAll() {
    FixedBackOff backOff = new FixedBackOff(100L, 0L);
    BackOffExecution execution = backOff.start();
    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
  }
View Full Code Here

    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
  }

  @Test
  public void maxAttemptsReached() {
    FixedBackOff backOff = new FixedBackOff(200L, 2);
    BackOffExecution execution = backOff.start();
    assertEquals(200l, execution.nextBackOff());
    assertEquals(200l, execution.nextBackOff());
    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
  }
View Full Code Here

    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
  }

  @Test
  public void startReturnDifferentInstances() {
    FixedBackOff backOff = new FixedBackOff(100L, 1);
    BackOffExecution execution = backOff.start();
    BackOffExecution execution2 = backOff.start();

    assertEquals(100l, execution.nextBackOff());
    assertEquals(100l, execution2.nextBackOff());
    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
    assertEquals(BackOffExecution.STOP, execution2.nextBackOff());
View Full Code Here

    assertEquals(BackOffExecution.STOP, execution2.nextBackOff());
  }

  @Test
  public void liveUpdate() {
    FixedBackOff backOff = new FixedBackOff(100L, 1);
    BackOffExecution execution = backOff.start();
    assertEquals(100l, execution.nextBackOff());

    backOff.setInterval(200l);
    backOff.setMaxAttempts(2);

    assertEquals(200l, execution.nextBackOff());
    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
  }
View Full Code Here

  }

  @Test
  public void backOffOverridesRecoveryInterval() {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    BackOff backOff = new FixedBackOff();
    factory.setBackOff(backOff);
    factory.setRecoveryInterval(2000L);

    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
View Full Code Here

TOP

Related Classes of org.springframework.util.backoff.FixedBackOff

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.