优化绝对路径的测试用例
This commit is contained in:
parent
daf51793fc
commit
f137700bab
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.absoluteConfigPath;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
|
@ -22,6 +23,7 @@ import org.springframework.test.context.TestPropertySource;
|
|||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* springboot环境下异步线程超时日志打印测试
|
||||
|
@ -35,6 +37,8 @@ import javax.annotation.Resource;
|
|||
@ComponentScan({ "com.yomahub.liteflow.test.absoluteConfigPath.cmp" })
|
||||
public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest {
|
||||
|
||||
private static String rootDir;
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
|
@ -42,7 +46,7 @@ public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest {
|
|||
public void testAbsoluteConfig() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Test/a/b/c/flow.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/a/flow1.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -52,7 +56,7 @@ public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest {
|
|||
public void testAbsolutePathMatch() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Tes*/**/c/*.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/**/*.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -60,15 +64,24 @@ public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest {
|
|||
|
||||
@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);
|
||||
rootDir = Objects.requireNonNull(AbsoluteConfigPathELDeclMultiSpringbootTest.class.getResource("/")).getPath();
|
||||
|
||||
String path1 = StrUtil.format("{}/sub/a", rootDir);
|
||||
String path2 = StrUtil.format("{}/sub/b", rootDir);
|
||||
|
||||
FileUtil.mkdir(path1);
|
||||
FileUtil.mkdir(path2);
|
||||
|
||||
String content1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain1\">WHEN(a, b, c);</chain></flow>";
|
||||
String content2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain2\">THEN(c, chain1);</chain></flow>";
|
||||
|
||||
FileUtil.writeString(content1, path1 + "/flow1.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
FileUtil.writeString(content2, path2 + "/flow2.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeFiles() {
|
||||
FileUtil.del("C:/LiteFlow");
|
||||
FileUtil.del(StrUtil.format("{}/sub", rootDir));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--这里只是内容,文件目录支持绝对路径的模糊匹配-->
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
WHEN(a,b,c);
|
||||
</chain>
|
||||
</flow>
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.absoluteConfigPath;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
|
@ -22,6 +23,7 @@ import org.springframework.test.context.TestPropertySource;
|
|||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* springboot环境下异步线程超时日志打印测试
|
||||
|
@ -35,6 +37,8 @@ import javax.annotation.Resource;
|
|||
@ComponentScan({ "com.yomahub.liteflow.test.absoluteConfigPath.cmp" })
|
||||
public class AbsoluteConfigPathELDeclSpringbootTest extends BaseTest {
|
||||
|
||||
private static String rootDir;
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
|
@ -42,7 +46,7 @@ public class AbsoluteConfigPathELDeclSpringbootTest extends BaseTest {
|
|||
public void testAbsoluteConfig() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Test/a/b/c/flow.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/a/flow1.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -52,7 +56,7 @@ public class AbsoluteConfigPathELDeclSpringbootTest extends BaseTest {
|
|||
public void testAbsolutePathMatch() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Tes*/**/c/*.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/**/*.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -60,15 +64,24 @@ public class AbsoluteConfigPathELDeclSpringbootTest extends BaseTest {
|
|||
|
||||
@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);
|
||||
rootDir = Objects.requireNonNull(AbsoluteConfigPathELDeclSpringbootTest.class.getResource("/")).getPath();
|
||||
|
||||
String path1 = StrUtil.format("{}/sub/a", rootDir);
|
||||
String path2 = StrUtil.format("{}/sub/b", rootDir);
|
||||
|
||||
FileUtil.mkdir(path1);
|
||||
FileUtil.mkdir(path2);
|
||||
|
||||
String content1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain1\">WHEN(a, b, c);</chain></flow>";
|
||||
String content2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain2\">THEN(c, chain1);</chain></flow>";
|
||||
|
||||
FileUtil.writeString(content1, path1 + "/flow1.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
FileUtil.writeString(content2, path2 + "/flow2.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeFiles() {
|
||||
FileUtil.del("C:/LiteFlow");
|
||||
FileUtil.del(StrUtil.format("{}/sub", rootDir));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--这里只是内容,文件目录支持绝对路径的模糊匹配-->
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
WHEN(a,b,c);
|
||||
</chain>
|
||||
</flow>
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.absoluteConfigPath;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
|
@ -13,6 +14,8 @@ import org.junit.jupiter.api.Assertions;
|
|||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 非spring环境下异步线程超时日志打印测试
|
||||
*
|
||||
|
@ -21,15 +24,17 @@ import org.junit.jupiter.api.Test;
|
|||
*/
|
||||
public class AbsoluteConfigPathTest extends BaseTest {
|
||||
|
||||
private static String rootDir;
|
||||
|
||||
private static FlowExecutor flowExecutor;
|
||||
|
||||
|
||||
@Test
|
||||
public void testAbsoluteConfig() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Test/a/b/c/flow.el.xml");
|
||||
flowExecutor.reloadRule();
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource(StrUtil.format("{}/sub/a/flow1.xml",rootDir));
|
||||
flowExecutor = FlowExecutorHolder.loadInstance(config);
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
}
|
||||
|
@ -37,37 +42,32 @@ public class AbsoluteConfigPathTest extends BaseTest {
|
|||
@Test
|
||||
public void testAbsolutePathMatch() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Tes*/**/c/*.el.xml");
|
||||
flowExecutor.reloadRule();
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource(StrUtil.format("{}/sub/**/*.xml",rootDir));
|
||||
flowExecutor = FlowExecutorHolder.loadInstance(config);
|
||||
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\"?>\n" +
|
||||
"<flow>\n" +
|
||||
"<nodes>\n" +
|
||||
" <node id=\"a\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.ACmp\"/>\n" +
|
||||
" <node id=\"b\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.BCmp\"/>\n" +
|
||||
" <node id=\"c\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.CCmp\"/>\n" +
|
||||
"</nodes>\n" +
|
||||
"\n" +
|
||||
"<chain name=\"chain1\">\n" +
|
||||
" WHEN(a,b,c);\n" +
|
||||
"</chain>\n" +
|
||||
"</flow>";
|
||||
FileUtil.mkdir(filePath);
|
||||
FileUtil.writeString(content, filePath + "/flow.el.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("absoluteConfigPath/flow.el.xml");
|
||||
flowExecutor = FlowExecutorHolder.loadInstance(config);
|
||||
rootDir = Objects.requireNonNull(AbsoluteConfigPathTest.class.getResource("/")).getPath();
|
||||
|
||||
String path1 = StrUtil.format("{}/sub/a", rootDir);
|
||||
String path2 = StrUtil.format("{}/sub/b", rootDir);
|
||||
|
||||
FileUtil.mkdir(path1);
|
||||
FileUtil.mkdir(path2);
|
||||
|
||||
String content1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><nodes><node id=\"a\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.ACmp\"/><node id=\"b\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.BCmp\"/><node id=\"c\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.CCmp\"/></nodes><chain name=\"chain1\">WHEN(a, b, c);</chain></flow>";
|
||||
String content2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><nodes><node id=\"a\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.ACmp\"/><node id=\"b\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.BCmp\"/><node id=\"c\" class=\"com.yomahub.liteflow.test.absoluteConfigPath.cmp.CCmp\"/></nodes><chain name=\"chain2\">THEN(c, chain1);</chain></flow>";
|
||||
|
||||
FileUtil.writeString(content1, path1 + "/flow1.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
FileUtil.writeString(content2, path2 + "/flow2.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeFiles() {
|
||||
FileUtil.del("C:/LiteFlow");
|
||||
FileUtil.del(StrUtil.format("{}/sub", rootDir));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--这里只是内容,文件目录支持绝对路径的模糊匹配-->
|
||||
<flow>
|
||||
<nodes>
|
||||
<node id="a" class="com.yomahub.liteflow.test.absoluteConfigPath.cmp.ACmp"/>
|
||||
<node id="b" class="com.yomahub.liteflow.test.absoluteConfigPath.cmp.BCmp"/>
|
||||
<node id="c" class="com.yomahub.liteflow.test.absoluteConfigPath.cmp.CCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
WHEN(a,b,c);
|
||||
</chain>
|
||||
</flow>
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.absoluteConfigPath;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
|
@ -18,6 +19,8 @@ import org.noear.solon.test.annotation.TestPropertySource;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* springboot环境下异步线程超时日志打印测试
|
||||
*
|
||||
|
@ -27,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
|||
@ExtendWith(SolonJUnit5Extension.class)
|
||||
public class AbsoluteConfigPathELSpringbootTest extends BaseTest {
|
||||
|
||||
private static String rootDir;
|
||||
|
||||
@Inject
|
||||
private FlowExecutor flowExecutor;
|
||||
|
@ -35,7 +39,7 @@ public class AbsoluteConfigPathELSpringbootTest extends BaseTest {
|
|||
public void testAbsoluteConfig() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Test/a/b/c/flow.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/a/flow1.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -45,7 +49,7 @@ public class AbsoluteConfigPathELSpringbootTest extends BaseTest {
|
|||
public void testAbsolutePathMatch() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Tes*/**/c/*.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/**/*.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -53,15 +57,24 @@ public class AbsoluteConfigPathELSpringbootTest extends BaseTest {
|
|||
|
||||
@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);
|
||||
rootDir = Objects.requireNonNull(AbsoluteConfigPathELSpringbootTest.class.getResource("/")).getPath();
|
||||
|
||||
String path1 = StrUtil.format("{}/sub/a", rootDir);
|
||||
String path2 = StrUtil.format("{}/sub/b", rootDir);
|
||||
|
||||
FileUtil.mkdir(path1);
|
||||
FileUtil.mkdir(path2);
|
||||
|
||||
String content1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain1\">WHEN(a, b, c);</chain></flow>";
|
||||
String content2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain2\">THEN(c, chain1);</chain></flow>";
|
||||
|
||||
FileUtil.writeString(content1, path1 + "/flow1.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
FileUtil.writeString(content2, path2 + "/flow2.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeFiles() {
|
||||
FileUtil.del("C:/LiteFlow");
|
||||
FileUtil.del(StrUtil.format("{}/sub", rootDir));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--这里只是内容,文件目录支持绝对路径的模糊匹配-->
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
WHEN(a,b,c);
|
||||
</chain>
|
||||
</flow>
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.absoluteConfigPath;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
|
@ -19,6 +20,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* springboot环境下异步线程超时日志打印测试
|
||||
|
@ -32,6 +34,8 @@ import javax.annotation.Resource;
|
|||
public class AbsoluteConfigPathELSpringbootTest extends BaseTest {
|
||||
|
||||
|
||||
private static String rootDir;
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
|
@ -39,7 +43,7 @@ public class AbsoluteConfigPathELSpringbootTest extends BaseTest {
|
|||
public void testAbsoluteConfig() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Test/a/b/c/flow.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/a/flow1.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -49,23 +53,32 @@ public class AbsoluteConfigPathELSpringbootTest extends BaseTest {
|
|||
public void testAbsolutePathMatch() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Tes*/**/c/*.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/**/*.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
return flowExecutor.execute2Resp("chain2", "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);
|
||||
rootDir = Objects.requireNonNull(AbsoluteConfigPathELSpringbootTest.class.getResource("/")).getPath();
|
||||
|
||||
String path1 = StrUtil.format("{}/sub/a", rootDir);
|
||||
String path2 = StrUtil.format("{}/sub/b", rootDir);
|
||||
|
||||
FileUtil.mkdir(path1);
|
||||
FileUtil.mkdir(path2);
|
||||
|
||||
String content1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain1\">WHEN(a, b, c);</chain></flow>";
|
||||
String content2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain2\">THEN(c, chain1);</chain></flow>";
|
||||
|
||||
FileUtil.writeString(content1, path1 + "/flow1.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
FileUtil.writeString(content2, path2 + "/flow2.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeFiles() {
|
||||
FileUtil.del("C:/LiteFlow");
|
||||
FileUtil.del(StrUtil.format("{}/sub", rootDir));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class MonitorFileELSpringbootTest extends BaseTest {
|
|||
*/
|
||||
@Test
|
||||
public void testMonitorAbsolutePath() throws Exception {
|
||||
String absolutePath = "/your/path/dir";
|
||||
String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath();
|
||||
FileUtil.writeString("<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain1\">THEN(a, b, c);</chain></flow>", new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
|
||||
String content = FileUtil.readUtf8String(absolutePath);
|
||||
String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);");
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--这里只是内容,文件目录支持绝对路径的模糊匹配-->
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
WHEN(a,b,c);
|
||||
</chain>
|
||||
</flow>
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.absoluteConfigPath;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
|
@ -16,6 +17,7 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* spring环境下,规则配置文件通过绝对路径获取
|
||||
|
@ -27,6 +29,8 @@ import javax.annotation.Resource;
|
|||
@ContextConfiguration("classpath:/absoluteConfigPath/application.xml")
|
||||
public class AbsoluteConfigPathELSpringTest extends BaseTest {
|
||||
|
||||
private static String rootDir;
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
|
@ -34,7 +38,7 @@ public class AbsoluteConfigPathELSpringTest extends BaseTest {
|
|||
public void testAbsoluteConfig() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Test/a/b/c/flow.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/a/flow1.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -44,7 +48,7 @@ public class AbsoluteConfigPathELSpringTest extends BaseTest {
|
|||
public void testAbsolutePathMatch() throws Exception {
|
||||
Assertions.assertTrue(() -> {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("C:/LiteFlow/Tes*/**/c/*.el.xml");
|
||||
config.setRuleSource(StrUtil.format("{}/sub/**/*.xml",rootDir));
|
||||
flowExecutor.reloadRule();
|
||||
return flowExecutor.execute2Resp("chain1", "arg").isSuccess();
|
||||
});
|
||||
|
@ -52,15 +56,24 @@ public class AbsoluteConfigPathELSpringTest extends BaseTest {
|
|||
|
||||
@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);
|
||||
rootDir = Objects.requireNonNull(AbsoluteConfigPathELSpringTest.class.getResource("/")).getPath();
|
||||
|
||||
String path1 = StrUtil.format("{}/sub/a", rootDir);
|
||||
String path2 = StrUtil.format("{}/sub/b", rootDir);
|
||||
|
||||
FileUtil.mkdir(path1);
|
||||
FileUtil.mkdir(path2);
|
||||
|
||||
String content1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain1\">WHEN(a, b, c);</chain></flow>";
|
||||
String content2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flow><chain name=\"chain2\">THEN(c, chain1);</chain></flow>";
|
||||
|
||||
FileUtil.writeString(content1, path1 + "/flow1.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
FileUtil.writeString(content2, path2 + "/flow2.xml", CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeFiles() {
|
||||
FileUtil.del("C:/LiteFlow");
|
||||
FileUtil.del(StrUtil.format("{}/sub", rootDir));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="C:/LiteFlow/Test/a/b/c/flow.el.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--这里只是内容,文件目录支持绝对路径的模糊匹配-->
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
WHEN(a,b,c);
|
||||
</chain>
|
||||
</flow>
|
Loading…
Reference in New Issue