mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Update SentinelAutoConfigurationTests
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
5b2f68e292
commit
1eec33fb00
@ -28,8 +28,6 @@ import com.alibaba.csp.sentinel.config.SentinelConfig;
|
||||
import com.alibaba.csp.sentinel.log.LogBase;
|
||||
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
||||
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
|
||||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
|
||||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
|
||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
|
||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
|
||||
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
||||
@ -116,13 +114,6 @@ public class SentinelAutoConfigurationTests {
|
||||
rule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
|
||||
rule.setStrategy(RuleConstant.STRATEGY_DIRECT);
|
||||
FlowRuleManager.loadRules(Arrays.asList(rule));
|
||||
|
||||
DegradeRule degradeRule = new DegradeRule();
|
||||
degradeRule.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
|
||||
degradeRule.setResource("GET:" + degradeUrl);
|
||||
degradeRule.setCount(0);
|
||||
degradeRule.setTimeWindow(60);
|
||||
DegradeRuleManager.loadRules(Arrays.asList(degradeRule));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -208,7 +199,7 @@ public class SentinelAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowRestTemplate() {
|
||||
public void testRestTemplateBlockHandler() {
|
||||
|
||||
assertThat(restTemplate.getInterceptors().size()).isEqualTo(2);
|
||||
assertThat(restTemplateWithBlockClass.getInterceptors().size()).isEqualTo(1);
|
||||
@ -236,15 +227,6 @@ public class SentinelAutoConfigurationTests {
|
||||
}).isInstanceOf(RestClientException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFallbackRestTemplate() {
|
||||
ResponseEntity responseEntity = restTemplateWithFallbackClass
|
||||
.getForEntity(degradeUrl, String.class);
|
||||
|
||||
assertThat(responseEntity.getBody()).isEqualTo("Oops fallback");
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class SentinelTestConfiguration {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user