From 8045ce0ff9203c226140f918098b5d28e6323310 Mon Sep 17 00:00:00 2001 From: george510257 Date: Mon, 6 May 2019 19:40:14 +0800 Subject: [PATCH] add spring-cloud-incubator/spring-cloud-alibaba/#626 test cases --- .../alibaba/sentinel/SentinelFeignTests.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/spring-cloud-alibaba-sentinel/src/test/java/org/springframework/cloud/alibaba/sentinel/SentinelFeignTests.java b/spring-cloud-alibaba-sentinel/src/test/java/org/springframework/cloud/alibaba/sentinel/SentinelFeignTests.java index b7d03670f..accd536fe 100644 --- a/spring-cloud-alibaba-sentinel/src/test/java/org/springframework/cloud/alibaba/sentinel/SentinelFeignTests.java +++ b/spring-cloud-alibaba-sentinel/src/test/java/org/springframework/cloud/alibaba/sentinel/SentinelFeignTests.java @@ -60,6 +60,9 @@ public class SentinelFeignTests { @Autowired private BarService barService; + @Autowired + private BazService bazService; + @Before public void setUp() { FlowRule rule1 = new FlowRule(); @@ -83,7 +86,14 @@ public class SentinelFeignTests { rule3.setLimitApp("default"); rule3.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT); rule3.setStrategy(RuleConstant.STRATEGY_DIRECT); - FlowRuleManager.loadRules(Arrays.asList(rule1, rule2, rule3)); + FlowRule rule4 = new FlowRule(); + rule4.setGrade(RuleConstant.FLOW_GRADE_QPS); + rule4.setCount(0); + rule4.setResource("GET:http://baz-service/baz"); + rule4.setLimitApp("default"); + rule4.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT); + rule4.setStrategy(RuleConstant.STRATEGY_DIRECT); + FlowRuleManager.loadRules(Arrays.asList(rule1, rule2, rule3,rule4)); } @Test @@ -101,6 +111,9 @@ public class SentinelFeignTests { assertThatExceptionOfType(Exception.class).isThrownBy(() -> { barService.bar(); }); + assertThatExceptionOfType(Exception.class).isThrownBy(() -> { + bazService.baz(); + }); assertNotEquals("ToString method invoke was not in SentinelInvocationHandler", echoService.toString(), fooService.toString()); @@ -146,6 +159,15 @@ public class SentinelFeignTests { String bar(); } + public interface BazService { + @RequestMapping(path = "baz") + String baz(); + } + + @FeignClient(value = "baz-service") + public interface BazClient extends BazService { + } + public static class EchoServiceFallback implements EchoService { @Override