Package org.springframework.retry

Examples of org.springframework.retry.RetryContext


public class NeverRetryPolicyTests {

  @Test
  public void testSimpleOperations() throws Exception {
    NeverRetryPolicy policy = new NeverRetryPolicy();
    RetryContext context = policy.open(null);
    assertNotNull(context);
    // We can retry until the first exception is registered...
    assertTrue(policy.canRetry(context));
    assertTrue(policy.canRetry(context));
    policy.registerThrowable(context, null);
View Full Code Here


  }

  @Test
  public void testRetryCount() throws Exception {
    NeverRetryPolicy policy = new NeverRetryPolicy();
    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

  }

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

public class CompositeRetryPolicyTests {

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

  @Test
  public void testTrivialPolicies() throws Exception {
    CompositeRetryPolicy policy = new CompositeRetryPolicy();
    policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport(), new MockRetryPolicySupport() });
    RetryContext context = policy.open(null);
    assertNotNull(context);
    assertTrue(policy.canRetry(context));
  }
View Full Code Here

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

      public void registerThrowable(RetryContext context, Throwable throwable) {
        errorRegistered = true;
      }
    } });
    RetryContext context = policy.open(null);
    assertNotNull(context);
    assertTrue(policy.canRetry(context));
    policy.registerThrowable(context, null);
    assertFalse("Should be still able to retry", policy.canRetry(context));
  }
View Full Code Here

    }, new MockRetryPolicySupport() {
      public void close(RetryContext context) {
        list.add("2");
      }
    } });
    RetryContext context = policy.open(null);
    assertNotNull(context);
    policy.close(context);
    assertEquals(2, list.size());
  }
View Full Code Here

    }, new MockRetryPolicySupport() {
      public void close(RetryContext context) {
        list.add("2");
      }
    } });
    RetryContext context = policy.open(null);
    assertNotNull(context);
    try {
      policy.close(context);
      fail("Expected RuntimeException");
    } catch (RuntimeException e) {
View Full Code Here

  @Test
  public void testRetryCount() throws Exception {
    CompositeRetryPolicy policy = new CompositeRetryPolicy();
    policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport(), new MockRetryPolicySupport() });
    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

TOP

Related Classes of org.springframework.retry.RetryContext

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.