mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
支持绝对路径的模糊匹配
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
package com.yomahub.liteflow.test.absoluteConfigPath;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
@@ -19,18 +25,43 @@ import org.slf4j.LoggerFactory;
|
||||
* @since 2.6.4
|
||||
*/
|
||||
@ExtendWith(SolonJUnit5Extension.class)
|
||||
@TestPropertySource("classpath:/absoluteConfigPath/application.properties")
|
||||
public class AbsoluteConfigPathELSpringbootTest extends BaseTest {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Inject
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Test
|
||||
public void testAbsoluteConfig() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assertions.assertTrue(response.isSuccess());
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Test/a/b/c/flow.el.xml");
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbsolutePathMatch() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Tes*/**/c/*.el.xml");
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void createFiles() {
|
||||
String filePath = "C:/LiteFlow/Test/a/b/c";
|
||||
String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain1\">WHEN(a, b, c);</chain></flow>";
|
||||
FileUtil.mkdir(filePath);
|
||||
FileUtil.writeString(content, filePath + "/flow.el.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeFiles() {
|
||||
FileUtil.del("C:/LiteFlow");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
liteflow.rule-source=/usr/local/flow.el.xml
|
||||
#liteflow.rule-source=/usr/**/*.xml
|
||||
liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--这里只是内容,在这个测试用例中这个文件请移到/usr/local/flow.xml中,文件目录支持绝对路径的模糊匹配,也可以将此文件移入任意/usr/**/*.xml中-->
|
||||
<!--这里只是内容,文件目录支持绝对路径的模糊匹配-->
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
WHEN(a,b,c);
|
||||
|
||||
Reference in New Issue
Block a user