In my application, I need to call an external endpoint, and if it is too slow, the reserve is activated.
The following code is an example of what my application looks like:
@FeignClient(name = "${config.name}", url = "${config.url:}", fallback = ExampleFallback.class)
public interface Example {
@RequestMapping(method = RequestMethod.GET, value = "/endpoint", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
MyReturnObject find(@RequestParam("myParam") String myParam);
}
And its fallback implementation:
@Component
public Class ExampleFallback implements Example {
private final FallbackService fallback;
@Autowired
public ExampleFallback(final FallbackService fallback) {
this.fallback = fallback;
}
@Override
public MyReturnObject find(final String myParam) {
return fallback.find(myParam);
}
In addition, the configured timeout for the circuit breaker is:
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000
How can I implement an integration test to check if my circuit break works, i.e. if my endpoint (mocks in this case) is slow or if it returns an error, for example 4xx or 5xx?
I am using Spring Boot 1.5.3 with Spring Cloud (Feign + Hystrix)
source
share