Reputation: 33
I have a method:
@Retry(retryOn = SomeException.class, maxRetries = 5, delay = 180000, maxDuration = 360000)
public void checkIfSomethingIsReady() {
if (something != ready) {
throw new SomeException();
} else {
// do stuff
}
}
I'm trying to do some boundary testing on a method like this without having to wait or retry. Is there a way to override this configuration solely for tests?
Upvotes: 2
Views: 1347
Reputation: 8393
Yes you can,
MicroProfile Fault Tolerance also allows configuration using MicroProfile Config. For example:
com.example.MyService/hello/Retry/delay=5
For the following code example:
@Singleton
public class MyService {
@Retry(maxRetries = 10, delay = 180000, retryOn = IOException.class)
public String hello() {
...
}
}
Therefore it would be packagePath.ClassName/methodName/Retry/delay=yourNumber
For tests, just have a different properties file with a different value.
Official Documentation: https://download.eclipse.org/microprofile/microprofile-fault-tolerance-3.0/microprofile-fault-tolerance-spec-3.0.html#_config_fault_tolerance_parameters
https://smallrye.io/docs/smallrye-fault-tolerance/5.0.0/usage/basic.html#_configuration
Upvotes: 5