Package org.springframework.retry

Examples of org.springframework.retry.RetryContext


  @Test
  public void testRegisterThrowable() {
    NeverRetryPolicy retryPolicy = new NeverRetryPolicy();
    RetryState state = new DefaultRetryState("foo");
    RetryContext context = retryTemplate.open(retryPolicy, state);
    assertNotNull(context);
    retryTemplate.registerThrowable(retryPolicy, state, context, new Exception());
    assertFalse(retryPolicy.canRetry(context));
  }
View Full Code Here


  @Test
  public void testClose() throws Exception {
    NeverRetryPolicy retryPolicy = new NeverRetryPolicy();
    RetryState state = new DefaultRetryState("foo");
    RetryContext context = retryTemplate.open(retryPolicy, state);
    assertNotNull(context);
    retryTemplate.registerThrowable(retryPolicy, state, context, new Exception());
    assertFalse(retryPolicy.canRetry(context));
    retryTemplate.close(retryPolicy, context, state, true);
    // still can't retry, even if policy is closed
View Full Code Here

    }
    catch (ExhaustedRetryException e) {
      // expected
    }

    RetryContext context = retryTemplate.open(retryPolicy, state);
    // True after exhausted - the history is reset...
    assertTrue(retryPolicy.canRetry(context));
  }
View Full Code Here

    catch (RetryException ex) {
      String message = ex.getMessage();
      assertTrue("Message doesn't contain 'inconsistent': " + message, message.contains("inconsistent"));
    }

    RetryContext context = retryTemplate.open(retryPolicy, state);
    // True after exhausted - the history is reset...
    assertEquals(0, context.getRetryCount());

  }
View Full Code Here

    catch (RuntimeException e) {
      assertEquals("Barf!", e.getMessage());
    }
    retryTemplate.execute(callback, recoveryCallback, state);

    RetryContext context = retryTemplate.open(retryPolicy, state);
    // True after exhausted - the history is reset...
    assertEquals(0, context.getRetryCount());

  }
View Full Code Here

  RetryTemplate template = new RetryTemplate();

  @Before
  public void setUp() throws Exception {
    RetrySynchronizationManagerTests.clearAll();
    RetryContext status = RetrySynchronizationManager.getContext();
    assertNull(status);
  }
View Full Code Here

  }

  @Test
  public void testStatusIsStoredByTemplate() throws Throwable {

    RetryContext status = RetrySynchronizationManager.getContext();
    assertNull(status);

    template.execute(new RetryCallback<Object, Exception>() {
      public Object doWithRetry(RetryContext status) throws Exception {
        RetryContext global = RetrySynchronizationManager.getContext();
        assertNotNull(status);
        assertEquals(global, status);
        return null;
      }
    });
View Full Code Here

    assertNull(status);
  }

  @Test
  public void testStatusRegistration() throws Exception {
    RetryContext status = new RetryContextSupport(null);
    RetryContext value = RetrySynchronizationManager.register(status);
    assertNull(value);
    value = RetrySynchronizationManager.register(status);
    assertEquals(status, value);
  }
View Full Code Here

    assertEquals(status, value);
  }

  @Test
  public void testClear() throws Exception {
    RetryContext status = new RetryContextSupport(null);
    RetryContext value = RetrySynchronizationManager.register(status);
    assertNull(value);
    RetrySynchronizationManager.clear();
    value = RetrySynchronizationManager.register(status);
    assertNull(value);
  }
View Full Code Here

    assertNull(value);
  }

  @Test
  public void testParent() throws Exception {
    RetryContext parent = new RetryContextSupport(null);
    RetryContext child = new RetryContextSupport(parent);
    assertSame(parent, child.getParent());
  }
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.