ore robust hystrix test
This commit is contained in:
@@ -34,9 +34,9 @@ public class HystrixApplication {
|
||||
@RequestMapping("/fail")
|
||||
public String fail(@RequestHeader(name = "X-No-Fail", required = false) String noFail) {
|
||||
if (noFail != null) {
|
||||
return this.myService.ok();
|
||||
return this.myService.fail(false);
|
||||
}
|
||||
return this.myService.fail();
|
||||
return this.myService.fail(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -13,11 +13,15 @@ public class MyService {
|
||||
}
|
||||
|
||||
@HystrixCommand(fallbackMethod = "fallback")
|
||||
public String fail() {
|
||||
throw new RuntimeException("fail now");
|
||||
public String fail(boolean throwSomething) {
|
||||
if(throwSomething)
|
||||
throw new RuntimeException("fail now");
|
||||
else
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
public String fallback() {
|
||||
public String fallback(boolean throwSomething) {
|
||||
return "from the fallback";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user