From 70954b4ae2ad2cc8ec24658bee6e5e591baf0860 Mon Sep 17 00:00:00 2001 From: rain <672378783@qq.com> Date: Fri, 6 Oct 2023 15:38:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=BB=9D=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84=E6=A8=A1=E7=B3=8A=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spi/local/LocalPathContentParser.java | 8 +- .../yomahub/liteflow/util/PathMatchUtil.java | 73 +++++++++++++++ .../liteflow/solon/config/PathsUtils.java | 93 ++++++++++--------- .../spi/spring/SpringPathContentParser.java | 7 +- .../absoluteConfigPath/application.properties | 3 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- .../absoluteConfigPath/application.properties | 3 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- .../AbsoluteConfigPathTest.java | 1 + .../resources/absoluteConfigPath/flow.el.xml | 8 +- .../absoluteConfigPath/application.properties | 3 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- .../MonitorFileELSpringbootTest.java | 16 ++++ .../absoluteConfigPath/application.properties | 3 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- .../monitorFile/application.properties | 1 + .../absoluteConfigPath/application.xml | 4 + .../resources/absoluteConfigPath/flow.el.xml | 2 +- 18 files changed, 175 insertions(+), 58 deletions(-) create mode 100644 liteflow-core/src/main/java/com/yomahub/liteflow/util/PathMatchUtil.java diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java index e750468d..64a397f7 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java @@ -9,6 +9,7 @@ import cn.hutool.core.util.ClassLoaderUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.spi.PathContentParser; +import com.yomahub.liteflow.util.PathMatchUtil; import java.util.ArrayList; import java.util.List; @@ -24,10 +25,11 @@ public class LocalPathContentParser implements PathContentParser { if (CollectionUtil.isEmpty(pathList)) { throw new ConfigErrorException("rule source must not be null"); } + List absolutePathList = PathMatchUtil.searchAbsolutePath(pathList); List contentList = new ArrayList<>(); - for (String path : pathList) { + for (String path : absolutePathList) { if (FileUtil.isAbsolutePath(path) && FileUtil.isFile(path)) { path = FILE_URL_PREFIX + path; } @@ -50,10 +52,10 @@ public class LocalPathContentParser implements PathContentParser { if (CollectionUtil.isEmpty(pathList)) { throw new ConfigErrorException("rule source must not be null"); } - + List absolutePathList = PathMatchUtil.searchAbsolutePath(pathList); List result = new ArrayList<>(); - for (String path : pathList) { + for (String path : absolutePathList) { if (FileUtil.isAbsolutePath(path) && FileUtil.isFile(path)) { path = FILE_URL_PREFIX + path; result.add(new FileResource(path).getFile().getAbsolutePath()); diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/util/PathMatchUtil.java b/liteflow-core/src/main/java/com/yomahub/liteflow/util/PathMatchUtil.java new file mode 100644 index 00000000..31e9fbb3 --- /dev/null +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/util/PathMatchUtil.java @@ -0,0 +1,73 @@ +package com.yomahub.liteflow.util; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.text.AntPathMatcher; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 用于获取模糊匹配的路径 + * + * @author Rain + * @since 2.11.1 + */ +public class PathMatchUtil { + + public static List searchAbsolutePath(List pathList) { + + List absolutePathList = new ArrayList<>(); + + for (String path : pathList) { + // 只对绝对路径进行处理 + if(FileUtil.isAbsolutePath(path)) { + if(!path.contains("*")) { + absolutePathList.add(path); + } + else { + String[] pathSegments = path.split("/"); + StringBuilder baseDir = new StringBuilder(); + + // 找到最大基础路径 + for(int i = 0; i < pathSegments.length; i ++) { + if(!pathSegments[i].contains("*")) { + baseDir.append(pathSegments[i]).append(File.separator); + } else { + baseDir.deleteCharAt(baseDir.length() - 1); + searchAbsolutePath(baseDir.toString(), path, absolutePathList); + break; + } + } + } + } else { + absolutePathList.add(path); + } + } + // 路径去重 + List newAbsolutePathList = absolutePathList.stream() + .distinct() + .collect(Collectors.toList()); + return newAbsolutePathList; + } + + private static void searchAbsolutePath(String baseDir, String path, List absolutePathList) { + AntPathMatcher pathMatcher = new AntPathMatcher(); + File dir = new File(baseDir); + File[] files = dir.listFiles(); + + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + searchAbsolutePath(file.getAbsolutePath(), path, absolutePathList); + } else { + String absolutePath = file.getAbsolutePath().replace("\\", "/"); + if (pathMatcher.match(path, absolutePath)) { + absolutePathList.add(absolutePath); + } + } + } + } + } +} diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/PathsUtils.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/PathsUtils.java index 08e9d9fb..87932800 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/PathsUtils.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/PathsUtils.java @@ -1,8 +1,11 @@ package com.yomahub.liteflow.solon.config; +import cn.hutool.core.io.FileUtil; +import com.yomahub.liteflow.util.PathMatchUtil; import org.noear.solon.core.util.ScanUtil; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.regex.Pattern; @@ -17,51 +20,55 @@ public class PathsUtils { public static Collection resolvePaths(String pathExpr) { List paths = new ArrayList<>(); + if(!FileUtil.isAbsolutePath(pathExpr)) { + if (pathExpr.contains("/*") == false) { // 说明没有*符 + paths.add(pathExpr); + return paths; + } - if (pathExpr.contains("/*") == false) { // 说明没有*符 - paths.add(pathExpr); - return paths; + // 确定目录 + int dirIdx = pathExpr.indexOf("/*"); + String dir = pathExpr.substring(0, dirIdx); + + // 确定后缀 + int sufIdx = pathExpr.lastIndexOf("."); + String suf = null; + if (sufIdx > 0) { + suf = pathExpr.substring(sufIdx); + if (suf.contains("*")) { + sufIdx = -1; + suf = null; + } + } + + int sufIdx2 = sufIdx; + String suf2 = suf; + + // 匹配表达式 + String expr = pathExpr.replaceAll("/\\*\\.", "/[^\\.]*\\."); + expr = expr.replaceAll("/\\*\\*/", "(/[^/]*)*/"); + + Pattern pattern = Pattern.compile(expr); + + List finalPaths = paths; + ScanUtil.scan(dir, n -> { + // 进行后缀过滤,相对比较快 + if (sufIdx2 > 0) { + return n.endsWith(suf2); + } + else { + return true; + } + }).forEach(uri -> { + // 再进行表达式过滤 + if (pattern.matcher(uri).find()) { + finalPaths.add(uri); + } + }); + } else { + String[] pathExprs = pathExpr.split(","); + paths = PathMatchUtil.searchAbsolutePath(Arrays.asList(pathExprs)); } - - // 确定目录 - int dirIdx = pathExpr.indexOf("/*"); - String dir = pathExpr.substring(0, dirIdx); - - // 确定后缀 - int sufIdx = pathExpr.lastIndexOf("."); - String suf = null; - if (sufIdx > 0) { - suf = pathExpr.substring(sufIdx); - if (suf.contains("*")) { - sufIdx = -1; - suf = null; - } - } - - int sufIdx2 = sufIdx; - String suf2 = suf; - - // 匹配表达式 - String expr = pathExpr.replaceAll("/\\*\\.", "/[^\\.]*\\."); - expr = expr.replaceAll("/\\*\\*/", "(/[^/]*)*/"); - - Pattern pattern = Pattern.compile(expr); - - ScanUtil.scan(dir, n -> { - // 进行后缀过滤,相对比较快 - if (sufIdx2 > 0) { - return n.endsWith(suf2); - } - else { - return true; - } - }).forEach(uri -> { - // 再进行表达式过滤 - if (pattern.matcher(uri).find()) { - paths.add(uri); - } - }); - return paths; } diff --git a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringPathContentParser.java b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringPathContentParser.java index a3f6fc0b..13720854 100644 --- a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringPathContentParser.java +++ b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringPathContentParser.java @@ -10,6 +10,7 @@ import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.spi.PathContentParser; +import com.yomahub.liteflow.util.PathMatchUtil; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; @@ -26,7 +27,8 @@ public class SpringPathContentParser implements PathContentParser { @Override public List parseContent(List pathList) throws Exception { - List allResource = getResources(pathList); + List absolutePathList = PathMatchUtil.searchAbsolutePath(pathList); + List allResource = getResources(absolutePathList); // 转换成内容List List contentList = new ArrayList<>(); @@ -42,7 +44,8 @@ public class SpringPathContentParser implements PathContentParser { @Override public List getFileAbsolutePath(List pathList) throws Exception { - List allResource = getResources(pathList); + List absolutePathList = PathMatchUtil.searchAbsolutePath(pathList); + List allResource = getResources(absolutePathList); return StreamUtil.of(allResource) // 过滤非 file 类型 Resource diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/application.properties index 348a63af..cfd4db49 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/application.properties @@ -1 +1,2 @@ -liteflow.rule-source=/usr/local/flow.el.xml \ No newline at end of file +liteflow.rule-source=/usr/local/flow.el.xml +#liteflow.rule-source=/usr/**/*.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/flow.el.xml index 0d670c77..2fda05e6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/application.properties index 348a63af..cfd4db49 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/application.properties @@ -1 +1,2 @@ -liteflow.rule-source=/usr/local/flow.el.xml \ No newline at end of file +liteflow.rule-source=/usr/local/flow.el.xml +#liteflow.rule-source=/usr/**/*.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/flow.el.xml index 0d670c77..2fda05e6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java index 120c3984..3d0ffef5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java @@ -23,6 +23,7 @@ public class AbsoluteConfigPathTest extends BaseTest { public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("/usr/local/flow2.xml"); +// config.setRuleSource("/usr/**/*.xml"); flowExecutor = FlowExecutorHolder.loadInstance(config); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/absoluteConfigPath/flow.el.xml index 0d670c77..9920ec54 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,6 +1,12 @@ - + + + + + + + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/application.properties index 348a63af..cfd4db49 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/application.properties @@ -1 +1,2 @@ -liteflow.rule-source=/usr/local/flow.el.xml \ No newline at end of file +liteflow.rule-source=/usr/local/flow.el.xml +#liteflow.rule-source=/usr/**/*.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/flow.el.xml index 0d670c77..2fda05e6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELSpringbootTest.java index ecc1f9e9..3b7194f9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELSpringbootTest.java @@ -38,6 +38,22 @@ public class MonitorFileELSpringbootTest extends BaseTest { Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } + /** + * 对绝对路径模糊匹配功能的测试 + */ + @Test + public void testMonitorAbsolutePath() throws Exception { + String absolutePath = "/your/path/dir"; + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + String content = FileUtil.readUtf8String(absolutePath); + String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); + Thread.sleep(1000); + FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + Thread.sleep(3000); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); + } + /** * 测试文件变更,但是 EL 规则错误情况 * 输出 ERROR 日志异常信息,但是不会停止监听线程,当下一次变更正确后替换为新规则 diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/application.properties index 348a63af..cfd4db49 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/application.properties @@ -1 +1,2 @@ -liteflow.rule-source=/usr/local/flow.el.xml \ No newline at end of file +liteflow.rule-source=/usr/local/flow.el.xml +#liteflow.rule-source=/usr/**/*.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/flow.el.xml index 0d670c77..2fda05e6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/monitorFile/application.properties b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/monitorFile/application.properties index 361f7e90..a292d344 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/monitorFile/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/monitorFile/application.properties @@ -1,2 +1,3 @@ liteflow.rule-source=monitorFile/flow.el.xml +#liteflow.rule-source=/usr/**/*.xml liteflow.enable-monitor-file=true \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/application.xml b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/application.xml index 3a5cc59d..c3e5fe36 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/application.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/application.xml @@ -17,6 +17,10 @@ + + + + diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/flow.el.xml index fd7d34c7..507e19d6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); From 4742ffea2827274277f99e9ef7b7cdd71d02df93 Mon Sep 17 00:00:00 2001 From: rain <672378783@qq.com> Date: Mon, 9 Oct 2023 16:11:29 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=BB=9D=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84=E6=A8=A1=E7=B3=8A=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...teConfigPathELDeclMultiSpringbootTest.java | 40 ++++++++++++-- .../absoluteConfigPath/application.properties | 3 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- ...bsoluteConfigPathELDeclSpringbootTest.java | 40 ++++++++++++-- .../absoluteConfigPath/application.properties | 3 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- .../AbsoluteConfigPathTest.java | 55 ++++++++++++++++--- .../resources/absoluteConfigPath/flow.el.xml | 2 +- .../AbsoluteConfigPathELSpringbootTest.java | 39 +++++++++++-- .../absoluteConfigPath/application.properties | 3 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- .../AbsoluteConfigPathELSpringbootTest.java | 39 +++++++++++-- .../absoluteConfigPath/application.properties | 3 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- .../AbsoluteConfigPathELSpringTest.java | 39 ++++++++++++- .../absoluteConfigPath/application.xml | 6 +- .../resources/absoluteConfigPath/flow.el.xml | 2 +- 17 files changed, 233 insertions(+), 49 deletions(-) diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclMultiSpringbootTest.java index 293b56d8..e04dbc45 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclMultiSpringbootTest.java @@ -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.springframework.test.context.junit.jupiter.SpringExtension; @@ -24,21 +30,45 @@ import javax.annotation.Resource; * @since 2.6.4 */ @ExtendWith(SpringExtension.class) -@TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties") @SpringBootTest(classes = AbsoluteConfigPathELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.absoluteConfigPath.cmp" }) public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest { - private final Logger log = LoggerFactory.getLogger(this.getClass()); - @Resource 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 = "WHEN(a, b, c);"; + FileUtil.mkdir(filePath); + FileUtil.writeString(content, filePath + "/flow.el.xml", CharsetUtil.CHARSET_UTF_8); + } + + @AfterAll + public static void removeFiles() { + FileUtil.del("C:/LiteFlow"); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/application.properties index cfd4db49..93a30df7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/application.properties @@ -1,2 +1 @@ -liteflow.rule-source=/usr/local/flow.el.xml -#liteflow.rule-source=/usr/**/*.xml \ No newline at end of file +liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/flow.el.xml index 2fda05e6..4871fa66 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclSpringbootTest.java index 55c90007..c59dbe1a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclSpringbootTest.java @@ -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.springframework.test.context.junit.jupiter.SpringExtension; @@ -24,21 +30,45 @@ import javax.annotation.Resource; * @since 2.6.4 */ @ExtendWith(SpringExtension.class) -@TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties") @SpringBootTest(classes = AbsoluteConfigPathELDeclSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.absoluteConfigPath.cmp" }) public class AbsoluteConfigPathELDeclSpringbootTest extends BaseTest { - private final Logger log = LoggerFactory.getLogger(this.getClass()); - @Resource 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 = "WHEN(a, b, c);"; + FileUtil.mkdir(filePath); + FileUtil.writeString(content, filePath + "/flow.el.xml", CharsetUtil.CHARSET_UTF_8); + } + + @AfterAll + public static void removeFiles() { + FileUtil.del("C:/LiteFlow"); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/application.properties index cfd4db49..93a30df7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/application.properties @@ -1,2 +1 @@ -liteflow.rule-source=/usr/local/flow.el.xml -#liteflow.rule-source=/usr/**/*.xml \ No newline at end of file +liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/flow.el.xml index 2fda05e6..4871fa66 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java index 3d0ffef5..f9c1c313 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java @@ -1,10 +1,14 @@ 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.core.FlowExecutorHolder; 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; @@ -19,18 +23,51 @@ public class AbsoluteConfigPathTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeAll - public static void init() { - LiteflowConfig config = new LiteflowConfig(); - config.setRuleSource("/usr/local/flow2.xml"); -// config.setRuleSource("/usr/**/*.xml"); - flowExecutor = FlowExecutorHolder.loadInstance(config); - } @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 = "\n" + + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n" + + "\n" + + " WHEN(a,b,c);\n" + + "\n" + + ""; + 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); + } + + @AfterAll + public static void removeFiles() { + FileUtil.del("C:/LiteFlow"); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/absoluteConfigPath/flow.el.xml index 9920ec54..59b01c85 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java index 8e8897b8..0ae3c55b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java @@ -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 = "WHEN(a, b, c);"; + FileUtil.mkdir(filePath); + FileUtil.writeString(content, filePath + "/flow.el.xml", CharsetUtil.CHARSET_UTF_8); + } + + @AfterAll + public static void removeFiles() { + FileUtil.del("C:/LiteFlow"); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/application.properties index cfd4db49..93a30df7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/application.properties @@ -1,2 +1 @@ -liteflow.rule-source=/usr/local/flow.el.xml -#liteflow.rule-source=/usr/**/*.xml \ No newline at end of file +liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/flow.el.xml index 2fda05e6..4871fa66 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java index ca844f9c..5bf77bb7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java @@ -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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,21 +26,46 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties") @SpringBootTest(classes = AbsoluteConfigPathELSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.absoluteConfigPath.cmp" }) public class AbsoluteConfigPathELSpringbootTest extends BaseTest { - private final Logger log = LoggerFactory.getLogger(this.getClass()); @Resource 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 = "WHEN(a, b, c);"; + FileUtil.mkdir(filePath); + FileUtil.writeString(content, filePath + "/flow.el.xml", CharsetUtil.CHARSET_UTF_8); + } + + @AfterAll + public static void removeFiles() { + FileUtil.del("C:/LiteFlow"); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/application.properties index cfd4db49..93a30df7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/application.properties @@ -1,2 +1 @@ -liteflow.rule-source=/usr/local/flow.el.xml -#liteflow.rule-source=/usr/**/*.xml \ No newline at end of file +liteflow.rule-source=C:/LiteFlow/Test/a/b/c/flow.el.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/flow.el.xml index 2fda05e6..4871fa66 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringTest.java index 5a662976..447d6e96 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringTest.java @@ -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.springframework.test.context.ContextConfiguration; @@ -25,9 +31,36 @@ public class AbsoluteConfigPathELSpringTest extends BaseTest { private FlowExecutor flowExecutor; @Test - public void testAbsoluteConfig() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assertions.assertTrue(response.isSuccess()); + public void testAbsoluteConfig() throws Exception { + 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 = "WHEN(a, b, c);"; + FileUtil.mkdir(filePath); + FileUtil.writeString(content, filePath + "/flow.el.xml", CharsetUtil.CHARSET_UTF_8); + } + + @AfterAll + public static void removeFiles() { + FileUtil.del("C:/LiteFlow"); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/application.xml b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/application.xml index c3e5fe36..a27805f4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/application.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/application.xml @@ -14,13 +14,9 @@ - + - - - - diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/flow.el.xml index 507e19d6..4871fa66 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/absoluteConfigPath/flow.el.xml @@ -1,5 +1,5 @@ - + WHEN(a,b,c); From 4e6f19dd6024d32c732d4c1dc6a47cf2ef555d5e Mon Sep 17 00:00:00 2001 From: rain <672378783@qq.com> Date: Mon, 9 Oct 2023 16:11:57 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=BB=9D=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84=E6=A8=A1=E7=B3=8A=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yomahub/liteflow/parser/factory/LocalParserFactory.java | 2 +- liteflow-testcase-el/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/LocalParserFactory.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/LocalParserFactory.java index 53ef7cfb..2a8e6b65 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/LocalParserFactory.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/LocalParserFactory.java @@ -1,6 +1,6 @@ package com.yomahub.liteflow.parser.factory; -import com.yomahub.liteflow.parser.*; +//import com.yomahub.liteflow.parser.*; import com.yomahub.liteflow.parser.el.*; /** diff --git a/liteflow-testcase-el/pom.xml b/liteflow-testcase-el/pom.xml index 3aacdd52..fa9ba90e 100644 --- a/liteflow-testcase-el/pom.xml +++ b/liteflow-testcase-el/pom.xml @@ -46,7 +46,7 @@ maven-deploy-plugin 2.8.2 - true + false From 7deb548d105aa102d11699020dde02b079638baf Mon Sep 17 00:00:00 2001 From: rain <672378783@qq.com> Date: Mon, 9 Oct 2023 16:14:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=BB=9D=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84=E6=A8=A1=E7=B3=8A=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yomahub/liteflow/parser/factory/LocalParserFactory.java | 2 +- liteflow-testcase-el/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/LocalParserFactory.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/LocalParserFactory.java index 2a8e6b65..53ef7cfb 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/LocalParserFactory.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/factory/LocalParserFactory.java @@ -1,6 +1,6 @@ package com.yomahub.liteflow.parser.factory; -//import com.yomahub.liteflow.parser.*; +import com.yomahub.liteflow.parser.*; import com.yomahub.liteflow.parser.el.*; /** diff --git a/liteflow-testcase-el/pom.xml b/liteflow-testcase-el/pom.xml index fa9ba90e..3aacdd52 100644 --- a/liteflow-testcase-el/pom.xml +++ b/liteflow-testcase-el/pom.xml @@ -46,7 +46,7 @@ maven-deploy-plugin 2.8.2 - false + true