Refactor SpringRetryTest
This commit is contained in:
parent
8734c956bb
commit
f60ae3be29
@ -1,17 +1,15 @@
|
||||
package org.baeldung.springretry;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.retry.RetryCallback;
|
||||
import org.springframework.retry.RetryContext;
|
||||
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 SpringRetryTest {
|
||||
@ -34,12 +32,9 @@ public class SpringRetryTest {
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void givenTemplateRetryService_whenCallWithException_thenRetry() {
|
||||
retryTemplate.execute(new RetryCallback<Void, RuntimeException>() {
|
||||
@Override
|
||||
public Void doWithRetry(RetryContext arg0) {
|
||||
retryTemplate.execute(arg0 -> {
|
||||
myService.templateRetryService();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user