mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-06-10 11:17:00 +08:00
feature #IC2F4F 完善单测
This commit is contained in:
@@ -4,9 +4,8 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.resource.ClassPathResource;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.exception.ChainNotFoundException;
|
||||
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.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -19,8 +18,6 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -34,21 +31,22 @@ public class MonitorFileELSpringbootTest2 extends BaseTest {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
// 测试监听新增文件
|
||||
// 测试模糊路径下监听新增文件
|
||||
@Test
|
||||
public void testMonitorAddFile() throws Exception {
|
||||
// 文件新增前
|
||||
LiteflowResponse liteflowResponse = flowExecutor.execute2Resp("chain2", "arg");
|
||||
LiteflowResponse liteflowResponse = flowExecutor.execute2Resp("chain_add", "arg");
|
||||
Assertions.assertFalse(liteflowResponse.isSuccess());
|
||||
Assertions.assertTrue(liteflowResponse.getCause() instanceof ChainNotFoundException);
|
||||
|
||||
// 文件新增
|
||||
String flowPath = new ClassPathResource("classpath:monitorFile").getAbsolutePath();
|
||||
Path newFilePath = Paths.get(flowPath, "test", "flow.el.2.xml");
|
||||
FileUtil.writeString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<flow><chain id=\"chain2\">THEN(a);</chain></flow>",
|
||||
"<flow><chain id=\"chain_add\">THEN(a);</chain></flow>",
|
||||
newFilePath.toFile(), CharsetUtil.CHARSET_UTF_8);
|
||||
Thread.sleep(1000);
|
||||
liteflowResponse = flowExecutor.execute2Resp("chain2", "arg");
|
||||
liteflowResponse = flowExecutor.execute2Resp("chain_add", "arg");
|
||||
Assertions.assertTrue(liteflowResponse.isSuccess());
|
||||
Assertions.assertEquals("a", liteflowResponse.getExecuteStepStr());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user