use of com.alibaba.cloud.sentinel.SentinelProperties in project blade-tool by chillzhuang.
the class BladeSentinelFilterConfiguration method sentinelWebMvcConfig.
@Bean
public SentinelWebMvcConfig sentinelWebMvcConfig(SentinelProperties properties, Optional<UrlCleaner> urlCleanerOptional, Optional<BlockExceptionHandler> blockExceptionHandlerOptional, Optional<RequestOriginParser> requestOriginParserOptional) {
SentinelWebMvcConfig sentinelWebMvcConfig = new SentinelWebMvcConfig();
sentinelWebMvcConfig.setHttpMethodSpecify(properties.getHttpMethodSpecify());
sentinelWebMvcConfig.setWebContextUnify(properties.getWebContextUnify());
if (blockExceptionHandlerOptional.isPresent()) {
blockExceptionHandlerOptional.ifPresent(sentinelWebMvcConfig::setBlockExceptionHandler);
} else {
if (StringUtils.hasText(properties.getBlockPage())) {
sentinelWebMvcConfig.setBlockExceptionHandler(((request, response, e) -> response.sendRedirect(properties.getBlockPage())));
} else {
sentinelWebMvcConfig.setBlockExceptionHandler(new DefaultBlockExceptionHandler());
}
}
urlCleanerOptional.ifPresent(sentinelWebMvcConfig::setUrlCleaner);
requestOriginParserOptional.ifPresent(sentinelWebMvcConfig::setOriginParser);
return sentinelWebMvcConfig;
}
use of com.alibaba.cloud.sentinel.SentinelProperties in project spring-cloud-alibaba by alibaba.
the class SentinelHealthIndicatorTests method setUp.
@Before
public void setUp() {
beanFactory = mock(DefaultListableBeanFactory.class);
sentinelProperties = mock(SentinelProperties.class);
sentinelHealthIndicator = new SentinelHealthIndicator(beanFactory, sentinelProperties);
SentinelConfig.setConfig(TransportConfig.CONSOLE_SERVER, "");
heartbeatSender = mock(HeartbeatSender.class);
Field heartbeatSenderField = ReflectionUtils.findField(HeartbeatSenderProvider.class, "heartbeatSender");
heartbeatSenderField.setAccessible(true);
ReflectionUtils.setField(heartbeatSenderField, null, heartbeatSender);
}
Aggregations