This commit is contained in:
bryan31
2021-12-10 19:06:14 +08:00
parent 331660a820
commit 94760b9f21
8 changed files with 19 additions and 11 deletions

View File

@@ -73,7 +73,7 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest {
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(1000L);
Thread.sleep(2000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.json");
//进行刷新
@@ -83,7 +83,7 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest {
}
}).start();
for (int i = 0; i < 500; i++) {
for (int i = 0; i < 300; i++) {
LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);

View File

@@ -73,7 +73,7 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest {
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(1000L);
Thread.sleep(2000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.xml");
//进行刷新
@@ -83,7 +83,7 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest {
}
}).start();
for (int i = 0; i < 500; i++) {
for (int i = 0; i < 300; i++) {
LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);

View File

@@ -72,7 +72,7 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest {
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(1000L);
Thread.sleep(2000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.json");
//进行刷新
@@ -82,7 +82,7 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest {
}
}).start();
for (int i = 0; i < 500; i++) {
for (int i = 0; i < 300; i++) {
LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);

View File

@@ -72,7 +72,7 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest {
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(1000L);
Thread.sleep(2000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.xml");
//进行刷新
@@ -82,7 +82,7 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest {
}
}).start();
for (int i = 0; i < 500; i++) {
for (int i = 0; i < 300; i++) {
LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);

View File

@@ -1,12 +1,15 @@
package com.yomahub.liteflow.test.whenTimeOut;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.entity.data.DefaultSlot;
import com.yomahub.liteflow.entity.data.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
@@ -27,12 +30,17 @@ import javax.annotation.Resource;
@ComponentScan({"com.yomahub.liteflow.test.whenTimeOut.cmp"})
public class WhenTimeOutSpringbootTest extends BaseTest {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Resource
private FlowExecutor flowExecutor;
@Test
public void testWhenTimeOut() throws Exception{
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
if (!response.isSuccess()){
log.error(response.getMessage(),response.getCause());
}
Assert.assertTrue(response.isSuccess());
}
}

View File

@@ -16,7 +16,7 @@ public class BCmp extends NodeComponent {
@Override
public void process() {
try {
Thread.sleep(6000);
Thread.sleep(4000);
}catch (Exception ignored){
}

View File

@@ -16,7 +16,7 @@ public class CCmp extends NodeComponent {
@Override
public void process() {
try {
Thread.sleep(8000);
Thread.sleep(3500);
}catch (Exception ignored){
}

View File

@@ -1,2 +1,2 @@
liteflow.rule-source=whenTimeOut/flow.xml
liteflow.when-max-wait-seconds=5
liteflow.when-max-wait-seconds=3