Examples of RetryContext


Examples of org.springframework.retry.RetryContext

import org.springframework.retry.RetryContext;

public class ClassifierSimpleRetryPolicyTest {
    @Test
    public void test_classify() {
        RetryContext context = Mockito.mock(RetryContext.class);
        Classifier<Throwable, Boolean> classifier = Mockito.mock(Classifier.class);
        ClassifierSimpleRetryPolicy policy = new ClassifierSimpleRetryPolicy(classifier);
        Mockito.when(context.getLastThrowable()).thenReturn(new RuntimeException());
        Mockito.when(classifier.classify(Mockito.any(Throwable.class))).thenReturn(true);
        Assert.assertTrue(policy.canRetry(context));
        Assert.assertSame(classifier, policy.getClassifier());
    }
View Full Code Here

Examples of org.springframework.retry.RetryContext

        Assert.assertSame(classifier, policy.getClassifier());
    }

    @Test
    public void test_classify_nullClassifier() {
        RetryContext context = Mockito.mock(RetryContext.class);
        ClassifierSimpleRetryPolicy policy = new ClassifierSimpleRetryPolicy(null);
        Mockito.when(context.getLastThrowable()).thenReturn(new RuntimeException());
        Assert.assertFalse(policy.canRetry(context));
    }
View Full Code Here

Examples of org.springframework.retry.RetryContext

        Assert.assertFalse(policy.canRetry(context));
    }

    @Test
    public void test_classify_nullClassifier2() {
        RetryContext context = Mockito.mock(RetryContext.class);
        ClassifierSimpleRetryPolicy policy = new ClassifierSimpleRetryPolicy();
        Mockito.when(context.getLastThrowable()).thenReturn(new RuntimeException());
        Assert.assertFalse(policy.canRetry(context));
    }
View Full Code Here

Examples of org.springframework.retry.RetryContext

        Assert.assertFalse(policy.canRetry(context));
    }

    @Test
    public void test_classify_nullClassifier3() {
        RetryContext context = Mockito.mock(RetryContext.class);
        ClassifierSimpleRetryPolicy policy = new ClassifierSimpleRetryPolicy(4);
        Mockito.when(context.getLastThrowable()).thenReturn(new RuntimeException());
        Assert.assertFalse(policy.canRetry(context));
    }
View Full Code Here

Examples of org.springframework.retry.RetryContext

    // Always rethrow if the retry is exhausted
    SimpleRetryExceptionHandler handler = new SimpleRetryExceptionHandler(retryPolicy,
        new SimpleLimitExceptionHandler(0), fatalExceptions);

    // Simulate a failed retry...
    RetryContext retryContext = retryPolicy.open(null);
    retryPolicy.registerThrowable(retryContext, ex);
    handler.close(retryContext, null, ex);
    return handler;
  }
View Full Code Here

Examples of org.springframework.retry.RetryContext

      try {
        batchRetryTemplate.execute(retryCallback, recoveryCallback, new DefaultRetryState(inputs,
            rollbackClassifier));
      }
      catch (Exception e) {
        RetryContext context = contextHolder.get();
        if (!batchRetryTemplate.canRetry(context)) {
          /*
           * BATCH-1761: we need advance warning of the scan about to
           * start in the next transaction, so we can change the
           * processing behaviour.
View Full Code Here

Examples of org.springframework.retry.RetryContext

      BatchRetryState batchState = (BatchRetryState) state;
      BatchRetryContext batchContext = (BatchRetryContext) context;

      Iterator<RetryContext> contextIterator = batchContext.contexts.iterator();
      for (RetryState retryState : batchState.keys) {
        RetryContext nextContext = contextIterator.next();
        super.registerThrowable(retryPolicy, retryState, nextContext, e);
      }

    }
View Full Code Here

Examples of org.springframework.retry.RetryContext

      BatchRetryState batchState = (BatchRetryState) state;
      BatchRetryContext batchContext = (BatchRetryContext) context;

      Iterator<RetryContext> contextIterator = batchContext.contexts.iterator();
      for (RetryState retryState : batchState.keys) {
        RetryContext nextContext = contextIterator.next();
        super.close(retryPolicy, nextContext, retryState, succeeded);
      }

    }
View Full Code Here

Examples of org.springframework.retry.RetryContext

      ExhaustedRetryException exhausted = null;

      Iterator<RetryContext> contextIterator = batchContext.contexts.iterator();
      for (RetryState retryState : batchState.keys) {

        RetryContext nextContext = contextIterator.next();

        try {
          super.handleRetryExhausted(null, nextContext, retryState);
        }
        catch (ExhaustedRetryException e) {
View Full Code Here

Examples of org.springframework.retry.RetryContext

  private List<String> list = new ArrayList<String>();

  @Test
  public void testOpenSunnyDay() throws Exception {
    RetryContext context = retryTemplate.open(new NeverRetryPolicy(), new DefaultRetryState("foo"));
    assertNotNull(context);
    // we haven't called the processor yet...
    assertEquals(0, count);
  }
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.