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