Код: Выделить всё
import org.eclipse.microprofile.faulttolerance.Retry;
import jakarta.enterprise.context.ApplicationScoped;
import lombok.SneakyThrows;
@ApplicationScoped
public class MyService {
private int retryCount = 0;
@SneakyThrows
private void throwConnectException() {
throw new ConnectException("Test");
}
public void call_testRetryMethod() {
testRetryMethod();
}
@Retry(maxRetries = 5)
public void testRetryMethod() {
LOGGER.info("testRetryMethod: {}", retryCount++);
throwConnectException();
}
}
< /code>
Теперь снаружи я вводил переменную MyService в модульные тесты: < /p>
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
class MyServiceTest {
@Inject MyService myService;
@Test
public void testMyService() {
myService.testRetryMethod(); // This does retries for 6 times.
myService.call_testRetryMethod(); // This does not!
}
}
Не могли бы вы подтвердить?
>
Подробнее здесь: https://stackoverflow.com/questions/795 ... nfirmation