BAEL-20262: Migrate spring-scheduling module to the com.baeldung package

This commit is contained in:
Krzysztof Woyke
2019-12-20 12:47:57 +01:00
parent 5c883d3d11
commit e738f59ea7
23 changed files with 29 additions and 40 deletions

View File

@@ -0,0 +1,40 @@
package com.baeldung.springretry;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.support.RetryTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import java.sql.SQLException;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = AppConfig.class, loader = AnnotationConfigContextLoader.class)
public class SpringRetryIntegrationTest {
@Autowired
private MyService myService;
@Autowired
private RetryTemplate retryTemplate;
@Test(expected = RuntimeException.class)
public void givenRetryService_whenCallWithException_thenRetry() {
myService.retryService();
}
@Test
public void givenRetryServiceWithRecovery_whenCallWithException_thenRetryRecover() throws SQLException {
myService.retryServiceWithRecovery(null);
}
@Test(expected = RuntimeException.class)
public void givenTemplateRetryService_whenCallWithException_thenRetry() {
retryTemplate.execute(arg0 -> {
myService.templateRetryService();
return null;
});
}
}