|
@@ -1,9 +1,15 @@
|
|
package com.yomahub.liteflow.test.absoluteConfigPath;
|
|
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.FlowExecutor;
|
|
import com.yomahub.liteflow.flow.LiteflowResponse;
|
|
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 com.yomahub.liteflow.test.BaseTest;
|
|
|
|
+import org.junit.jupiter.api.AfterAll;
|
|
import org.junit.jupiter.api.Assertions;
|
|
import org.junit.jupiter.api.Assertions;
|
|
|
|
+import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
@@ -24,21 +30,45 @@ import javax.annotation.Resource;
|
|
* @since 2.6.4
|
|
* @since 2.6.4
|
|
*/
|
|
*/
|
|
@ExtendWith(SpringExtension.class)
|
|
@ExtendWith(SpringExtension.class)
|
|
-@TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties")
|
|
|
|
@SpringBootTest(classes = AbsoluteConfigPathELDeclMultiSpringbootTest.class)
|
|
@SpringBootTest(classes = AbsoluteConfigPathELDeclMultiSpringbootTest.class)
|
|
@EnableAutoConfiguration
|
|
@EnableAutoConfiguration
|
|
@ComponentScan({ "com.yomahub.liteflow.test.absoluteConfigPath.cmp" })
|
|
@ComponentScan({ "com.yomahub.liteflow.test.absoluteConfigPath.cmp" })
|
|
public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest {
|
|
public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest {
|
|
|
|
|
|
- private final Logger log = LoggerFactory.getLogger(this.getClass());
|
|
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
private FlowExecutor flowExecutor;
|
|
private FlowExecutor flowExecutor;
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testAbsoluteConfig() throws Exception {
|
|
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");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|