补充测试用例

This commit is contained in:
bryan31
2022-03-07 11:42:18 +08:00
parent 77dca4f5ac
commit c54e1a9cdc
5 changed files with 104 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package com.yomahub.liteflow.test.reload;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.entity.data.DefaultSlot;
import com.yomahub.liteflow.entity.data.LiteflowResponse;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* 非spring环境下重新加载规则测试
* @author Bryan.Zhang
* @since 2.5.0
*/
public class ReloadTest extends BaseTest {
private static FlowExecutor flowExecutor;
@BeforeClass
public static void init(){
LiteflowConfig config = new LiteflowConfig();
config.setRuleSource("reload/flow.xml");
flowExecutor = FlowExecutor.loadInstance(config);
}
//用reloadRule去重新加载这里如果配置是放在本地。如果想修改则要去修改target下面的flow.xml
//这里的测试手动打断点然后去修改是ok的。但是整个测试暂且只是为了测试这个功能是否能正常运行
@Test
public void testReload() throws Exception{
flowExecutor.reloadRule();
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
}
}

View File

@@ -0,0 +1,18 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.reload.cmp;
import com.yomahub.liteflow.core.NodeComponent;
public class ACmp extends NodeComponent {
@Override
public void process() {
System.out.println("ACmp executed!");
}
}

View File

@@ -0,0 +1,19 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.reload.cmp;
import com.yomahub.liteflow.core.NodeComponent;
public class BCmp extends NodeComponent {
@Override
public void process() {
System.out.println("BCmp executed!");
}
}

View File

@@ -0,0 +1,19 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.reload.cmp;
import com.yomahub.liteflow.core.NodeComponent;
public class CCmp extends NodeComponent {
@Override
public void process() {
System.out.println("CCmp executed!");
}
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<nodes>
<node id="a" class="com.yomahub.liteflow.test.reload.cmp.ACmp"/>
<node id="b" class="com.yomahub.liteflow.test.reload.cmp.BCmp"/>
<node id="c" class="com.yomahub.liteflow.test.reload.cmp.CCmp"/>
</nodes>
<chain name="chain1">
<then value="a,b,c"/>
</chain>
</flow>