Package org.springframework.retry.policy

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


    if (includes.length == 0) {
      includes = retryable.include();
    }
    Class<? extends Throwable>[] excludes = retryable.exclude();
    if (includes.length == 0 && excludes.length == 0) {
      SimpleRetryPolicy simple = new SimpleRetryPolicy();
      simple.setMaxAttempts(retryable.maxAttempts());
      return simple;
    }
    Map<Class<? extends Throwable>, Boolean> policyMap = new HashMap<Class<? extends Throwable>, Boolean>();
    for (Class<? extends Throwable> type : includes) {
      policyMap.put(type, true);
    }
    for (Class<? extends Throwable> type : excludes) {
      policyMap.put(type, false);
    }
    return new SimpleRetryPolicy(retryable.maxAttempts(), policyMap, true);
  }
View Full Code Here


        org.springframework.retry.support.RetryTemplate template =
                new org.springframework.retry.support.RetryTemplate();
        Map<Class<? extends Throwable>, Boolean> exceptionMap = new HashMap<Class<? extends Throwable>, Boolean>();
        exceptionMap.put(RuntimeException.class, Boolean.TRUE);
        template.setRetryPolicy(new SimpleRetryPolicy(1, exceptionMap));

        Mockito.doReturn(template).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);
        Mockito.doReturn(recoveryCallback).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE_RECOVERY, RecoveryCallback.class);
View Full Code Here

    public void testRetryExceptionWithoutRecovery() throws Throwable {
        org.springframework.retry.support.RetryTemplate template =
                new org.springframework.retry.support.RetryTemplate();
        Map<Class<? extends Throwable>, Boolean> exceptionMap = new HashMap<Class<? extends Throwable>, Boolean>();
        exceptionMap.put(RuntimeException.class, Boolean.TRUE);
        template.setRetryPolicy(new SimpleRetryPolicy(1, exceptionMap));

        Mockito.doReturn(template).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);
        Mockito.doReturn(null).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE_RECOVERY, RecoveryCallback.class);
View Full Code Here

    public void testRetryErrorWithoutRecovery() throws Throwable {
        org.springframework.retry.support.RetryTemplate template =
                new org.springframework.retry.support.RetryTemplate();
        Map<Class<? extends Throwable>, Boolean> exceptionMap = new HashMap<Class<? extends Throwable>, Boolean>();
        exceptionMap.put(RuntimeException.class, Boolean.TRUE);
        template.setRetryPolicy(new SimpleRetryPolicy(1, exceptionMap));

        Mockito.doReturn(template).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);
        Mockito.doReturn(null).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE_RECOVERY, RecoveryCallback.class);
View Full Code Here

    public void testRetryThrowableWithoutRecovery() throws Throwable {
        org.springframework.retry.support.RetryTemplate template =
                new org.springframework.retry.support.RetryTemplate();
        Map<Class<? extends Throwable>, Boolean> exceptionMap = new HashMap<Class<? extends Throwable>, Boolean>();
        exceptionMap.put(RuntimeException.class, Boolean.TRUE);
        template.setRetryPolicy(new SimpleRetryPolicy(1, exceptionMap));

        Mockito.doReturn(template).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);
        Mockito.doReturn(null).when(beanFactory)
                .getBean(TEST_RETRY_TEMPLATE_RECOVERY, RecoveryCallback.class);
View Full Code Here

  @Test
  public void testRetryPolicyElement() throws Exception {
    @SuppressWarnings("resource")
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/batch/core/configuration/xml/ChunkElementRetryPolicyParserTests-context.xml");
    SimpleRetryPolicy policy = (SimpleRetryPolicy) getPolicy("s2", context,
        "tasklet.chunkProcessor.batchRetryTemplate.regular.retryPolicy.exceptionClassifier");
    assertEquals(2, policy.getMaxAttempts());
  }
View Full Code Here

    assertEquals(1, stepExecution.getReadCount());
  }

  @Test
  public void testRetryPolicy() throws Exception {
    factory.setRetryPolicy(new SimpleRetryPolicy(4, Collections
        .<Class<? extends Throwable>, Boolean> singletonMap(
            Exception.class, true)));
    factory.setSkipLimit(0);
    ItemReader<String> provider = new ListItemReader<String>(
        Arrays.asList("b")) {
View Full Code Here

    assertEquals("[foo, bar, foo, bar]", writeError.toString());
  }

  @Test
  public void testWriteRetryOnException() throws Exception {
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
    retryPolicy.setMaxAttempts(2);
    batchRetryTemplate.setRetryPolicy(retryPolicy);
    processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
    processor.setItemWriter(new ItemWriter<String>() {
      @Override
      public void write(List<? extends String> items) throws Exception {
View Full Code Here

    assertEquals(0, contribution.getFilterCount());
  }

  @Test
  public void testWriteRetryOnTwoExceptions() throws Exception {
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
    retryPolicy.setMaxAttempts(2);
    batchRetryTemplate.setRetryPolicy(retryPolicy);
    processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
    processor.setItemWriter(new ItemWriter<String>() {
      @Override
      public void write(List<? extends String> items) throws Exception {
View Full Code Here

  }

  @Test
  // BATCH-1804
  public void testWriteRetryOnNonSkippableException() throws Exception {
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
    retryPolicy.setMaxAttempts(2);
    batchRetryTemplate.setRetryPolicy(retryPolicy);
    processor.setWriteSkipPolicy(new LimitCheckingItemSkipPolicy(1,
        Collections.<Class<? extends Throwable>, Boolean> singletonMap(
            IllegalArgumentException.class, true)));
    processor.setItemWriter(new ItemWriter<String>() {
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.