I created a basic set-up to try out Spring Retry, but it's not working for some reason. I think I have all of the annotations needed so I'm not sure what's wrong here. Any help would be appreciated.
In AppConfig.java:
@SpringBootApplication
@EnableRetry
public class AppConfig {
//run the spring application
}
In SomeClass.java:
@Component
public class SomeClass{
public SomeClass() { }
int counter = 0;
@Retryable(value = { SomeException.class }, maxAttempts = 3)
public void someMethod(){
counter++;
System.out.println(counter);
throw new SomeException("An exception was thrown!");
}
}
In TestSomeClass.java:
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes=AppConfig.class)
public class TestSomeClass {
@Test
public void test() {
SomeClass obj = new SomeClass();
obj.someMethod();
}
}
When I run the test the counter will only print '1' and the exception is thrown, so it's not being re-run as expected.