Package org.springframework.retry.policy

Examples of org.springframework.retry.policy.SimpleRetryPolicy$SimpleRetryContext


  }

  @Test
  public void testCacheCapacity() throws Throwable {

    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
    retryTemplate.setRetryContextCache(new MapRetryContextCache(1));

    RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
      public Object doWithRetry(RetryContext context) throws Exception {
View Full Code Here


  }

  @Test
  public void testCacheCapacityNotReachedIfRecovered() throws Throwable {

    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(1, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
    retryTemplate.setRetryPolicy(retryPolicy);
    retryTemplate.setRetryContextCache(new MapRetryContextCache(2));
    final StringHolder item = new StringHolder("foo");
    RetryState state = new DefaultRetryState(item);
View Full Code Here

public class RetrySimulationTests {

  @Test
  public void testSimulatorExercisesFixedBackoff() {
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
    retryPolicy.setMaxAttempts(5);

    FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
    backOffPolicy.setBackOffPeriod(400);

    RetrySimulator simulator = new RetrySimulator(backOffPolicy, retryPolicy);
View Full Code Here

    assertEquals(400d, simulation.getPercentile(0.5),0.1);
  }

  @Test
  public void testSimulatorExercisesExponentialBackoff() {
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
    retryPolicy.setMaxAttempts(5);

    ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
    backOffPolicy.setMultiplier(2);
    backOffPolicy.setMaxInterval(30000);
    backOffPolicy.setInitialInterval(100);
View Full Code Here

    assertEquals(300d, simulation.getPercentile(0.5f), 0.1);
  }

  @Test
  public void testSimulatorExercisesRandomExponentialBackoff() {
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
    retryPolicy.setMaxAttempts(5);

    ExponentialBackOffPolicy backOffPolicy = new ExponentialRandomBackOffPolicy();
    backOffPolicy.setMultiplier(2);
    backOffPolicy.setMaxInterval(30000);
    backOffPolicy.setInitialInterval(100);
View Full Code Here

  }

  @Test
  public void testDefaultInterceptorWithRecovery() throws Exception {
    RetryTemplate template = new RetryTemplate();
    template.setRetryPolicy(new SimpleRetryPolicy(1, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
    interceptor.setRetryOperations(template);
    interceptor.setRecoverer(new MethodInvocationRecoverer<Void>() {
      public Void recover(Object[] args, Throwable cause) {
        return null;
View Full Code Here

        list.add("chain");
        return invocation.proceed();
      }
    });
    RetryTemplate template = new RetryTemplate();
    template.setRetryPolicy(new SimpleRetryPolicy(2, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
    interceptor.setRetryOperations(template);
    service.service();
    assertEquals(2, count);
    assertEquals(2, list.size());
View Full Code Here

        list.add("chain");
        return invocation.proceed();
      }
    });
    interceptor.setRetryOperations(retryTemplate);
    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
    try {
      service.service("foo");
      fail("Expected Exception.");
    }
View Full Code Here

  @Test
  public void testTransformerWithSuccessfulRetry() throws Exception {
    ((Advised) transformer).addAdvice(interceptor);
    interceptor.setRetryOperations(retryTemplate);
    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
    try {
      transformer.transform("foo");
      fail("Expected Exception.");
    }
View Full Code Here

  }

  @Test
  public void testWitCustomRetryPolicyTraverseCause() {
    StatefulRetryOperationsInterceptor interceptor = RetryInterceptorBuilder.stateful()
        .retryPolicy(new SimpleRetryPolicy(15, Collections
            .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true), true))
        .build();
    assertEquals(15, TestUtils.getPropertyValue(interceptor, "retryOperations.retryPolicy.maxAttempts"));
  }
View Full Code Here

TOP

Related Classes of org.springframework.retry.policy.SimpleRetryPolicy$SimpleRetryContext

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.