修复一些测试用例

This commit is contained in:
everywhere.z 2023-02-15 17:10:24 +08:00
parent 77d130716e
commit a5c39f724c
17 changed files with 3 additions and 94 deletions

View File

@ -52,22 +52,13 @@ public class MonitorFile {
public void create() {
for (String filePath : CollUtil.distinct(PATH_LIST)) {
// 这里只监听两种类型文件修改和文件覆盖
WatchMonitor.createAll(filePath, new DelayWatcher(new SimpleWatcher() {
WatchMonitor.createAll(filePath, new SimpleWatcher(){
@Override
public void onModify(WatchEvent<?> event, Path currentPath) {
logger.info("file modify,filePath={}", filePath);
FlowExecutorHolder.loadInstance().reloadRule();
}
@Override
public void onOverflow(WatchEvent<?> event, Path currentPath) {
logger.info("file over flow,filePath={}", filePath);
FlowExecutorHolder.loadInstance().reloadRule();
}
// 在监听目录或文件时如果这个文件有修改操作JDK会多次触发modify方法为了解决这个问题
// 合并 500 毫秒内相同的变化
}, 500)).start();
}).start();
}
}

View File

@ -33,9 +33,6 @@ public class MonitorFileELDeclMultiSpringbootTest extends BaseTest {
String content = FileUtil.readUtf8String(absolutePath);
String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);");
FileUtil.writeString(newContent,new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
Thread.sleep(1500);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>c==>b", response.getExecuteStepStr());

View File

@ -12,31 +12,15 @@ public class CmpConfig {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS,nodeId = "a")
public void processA(NodeComponent bindCmp) {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("ACmp executed!");
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS,nodeId = "b")
public void processB(NodeComponent bindCmp) {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("BCmp executed!");
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS,nodeId = "c")
public void process(NodeComponent bindCmp) {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("BCmp executed!");
}
}

View File

@ -33,9 +33,6 @@ public class MonitorFileELDeclSpringbootTest extends BaseTest {
String content = FileUtil.readUtf8String(absolutePath);
String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);");
FileUtil.writeString(newContent,new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
Thread.sleep(1500);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>c==>b", response.getExecuteStepStr());
}

View File

@ -19,12 +19,6 @@ public class ACmp{
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("ACmp executed!");
}
}

View File

@ -19,11 +19,6 @@ public class BCmp{
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("BCmp executed!");
}

View File

@ -19,11 +19,6 @@ public class CCmp{
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("CCmp executed!");
}

View File

@ -27,14 +27,11 @@ public class LiteflowMonitorFileTest extends BaseTest {
}
@Test
public void testMultipleType() throws InterruptedException {
public void testMonitor() throws InterruptedException {
String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath();
String content = FileUtil.readUtf8String(absolutePath);
String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);");
FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
Thread.sleep(1000);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>c==>b", response.getExecuteStepStr());
}

View File

@ -35,9 +35,6 @@ public class MonitorFileGroovyELTest extends BaseTest {
String content = FileUtil.readUtf8String(absolutePath);
String newContent = content.replace("a=3", "a=2");
FileUtil.writeString(newContent,new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
Thread.sleep(1500);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());

View File

@ -28,9 +28,6 @@ public class MonitorFileELSpringbootTest extends BaseTest {
String content = FileUtil.readUtf8String(absolutePath);
String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);");
FileUtil.writeString(newContent,new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
Thread.sleep(1500);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>c==>b", response.getExecuteStepStr());
}

View File

@ -17,12 +17,6 @@ public class ACmp extends NodeComponent {
@Override
public void process() {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("ACmp executed!");
}
}

View File

@ -17,11 +17,6 @@ public class BCmp extends NodeComponent {
@Override
public void process() {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("BCmp executed!");
}

View File

@ -17,11 +17,6 @@ public class CCmp extends NodeComponent {
@Override
public void process() {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("CCmp executed!");
}

View File

@ -34,9 +34,6 @@ public class MonitorFileELSpringbootTest extends BaseTest {
String content = FileUtil.readUtf8String(absolutePath);
String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);");
FileUtil.writeString(newContent,new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
Thread.sleep(1500);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>c==>b", response.getExecuteStepStr());
}

View File

@ -17,12 +17,6 @@ public class ACmp extends NodeComponent {
@Override
public void process() {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("ACmp executed!");
}
}

View File

@ -17,11 +17,6 @@ public class BCmp extends NodeComponent {
@Override
public void process() {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("BCmp executed!");
}

View File

@ -17,11 +17,6 @@ public class CCmp extends NodeComponent {
@Override
public void process() {
try {
Thread.sleep(new Random().nextInt(2000));
}catch (Exception e){
e.printStackTrace();
}
System.out.println("CCmp executed!");
}