Examples of RetryContext


Examples of org.springframework.retry.RetryContext

  }

  @Test
  public void testParent() throws Exception {
    CompositeRetryPolicy policy = new CompositeRetryPolicy();
    RetryContext context = policy.open(null);
    RetryContext child = policy.open(context);
    assertNotSame(child, context);
    assertSame(context, child.getParent());
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

    policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport() {
      public boolean canRetry(RetryContext context) {
        return false;
      }
    }, new MockRetryPolicySupport() });
    RetryContext context = policy.open(null);
    assertNotNull(context);
    assertTrue(policy.canRetry(context));
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

public class SimpleRetryPolicyTests {

  @Test
  public void testCanRetryIfNoException() throws Exception {
    SimpleRetryPolicy policy = new SimpleRetryPolicy();
    RetryContext context = policy.open(null);
    assertTrue(policy.canRetry(context));
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

  public void testEmptyExceptionsNeverRetry() throws Exception {

    // We can't retry any exceptions...
    SimpleRetryPolicy policy = new SimpleRetryPolicy(3, Collections
        .<Class<? extends Throwable>, Boolean> emptyMap());
    RetryContext context = policy.open(null);

    // ...so we can't retry this one...
    policy.registerThrowable(context, new IllegalStateException());
    assertFalse(policy.canRetry(context));
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

  }

  @Test
  public void testRetryLimitInitialState() throws Exception {
    SimpleRetryPolicy policy = new SimpleRetryPolicy();
    RetryContext context = policy.open(null);
    assertTrue(policy.canRetry(context));
    policy.setMaxAttempts(0);
    context = policy.open(null);
    assertFalse(policy.canRetry(context));
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

  }

  @Test
  public void testRetryLimitSubsequentState() throws Exception {
    SimpleRetryPolicy policy = new SimpleRetryPolicy();
    RetryContext context = policy.open(null);
    policy.setMaxAttempts(2);
    assertTrue(policy.canRetry(context));
    policy.registerThrowable(context, new Exception());
    assertTrue(policy.canRetry(context));
    policy.registerThrowable(context, new Exception());
View Full Code Here

Examples of org.springframework.retry.RetryContext

  }

  @Test
  public void testRetryCount() throws Exception {
    SimpleRetryPolicy policy = new SimpleRetryPolicy();
    RetryContext context = policy.open(null);
    assertNotNull(context);
    policy.registerThrowable(context, null);
    assertEquals(0, context.getRetryCount());
    policy.registerThrowable(context, new RuntimeException("foo"));
    assertEquals(1, context.getRetryCount());
    assertEquals("foo", context.getLastThrowable().getMessage());
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

  public void testFatalOverridesRetryable() throws Exception {
    Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
    map.put(Exception.class, false);
    map.put(RuntimeException.class, true);
    SimpleRetryPolicy policy = new SimpleRetryPolicy(3, map);
    RetryContext context = policy.open(null);
    assertNotNull(context);
    policy.registerThrowable(context, new RuntimeException("foo"));
    assertTrue(policy.canRetry(context));
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

  @Test
  public void testRetryableWithCause() throws Exception {
    Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
    map.put(RuntimeException.class, true);
    SimpleRetryPolicy policy = new SimpleRetryPolicy(3, map, true);
    RetryContext context = policy.open(null);
    assertNotNull(context);
    policy.registerThrowable(context, new Exception(new RuntimeException("foo")));
    assertTrue(policy.canRetry(context));
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

  }

  @Test
  public void testParent() throws Exception {
    SimpleRetryPolicy policy = new SimpleRetryPolicy();
    RetryContext context = policy.open(null);
    RetryContext child = policy.open(context);
    assertNotSame(child, context);
    assertSame(context, child.getParent());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.