mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-24 03:28:08 +08:00
增加测试用例
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.yomahub.liteflow.test.absoluteConfigPath;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
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.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/absoluteConfigPath/application.xml")
|
||||
public class AbsoluteConfigPathSpringTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Test
|
||||
public void testAbsoluteConfig(){
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.absoluteConfigPath.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("a")
|
||||
public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("ACmp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.absoluteConfigPath.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("b")
|
||||
public class BCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("BCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.absoluteConfigPath.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("CCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yomahub.liteflow.test.aop;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
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.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 切面场景单元测试
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/aop/application-global.xml")
|
||||
public class CustomAOPSpringTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//测试自定义AOP,串行场景
|
||||
@Test
|
||||
public void testCustomAopS() {
|
||||
LiteflowResponse<DefaultSlot> response= flowExecutor.execute2Resp("chain1", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("a"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("b"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("c"));
|
||||
}
|
||||
|
||||
//测试自定义AOP,并行场景
|
||||
@Test
|
||||
public void testCustomAopP() {
|
||||
LiteflowResponse<DefaultSlot> response= flowExecutor.execute2Resp("chain2", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("a"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("b"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("c"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yomahub.liteflow.test.aop;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 切面场景单元测试
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/aop/application-global.xml")
|
||||
public class GlobalAOPSpringTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//测试全局AOP,串行场景
|
||||
@Test
|
||||
public void testGlobalAopS() {
|
||||
LiteflowResponse<DefaultSlot> response= flowExecutor.execute2Resp("chain1", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("a"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("b"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("c"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("d"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("e"));
|
||||
}
|
||||
|
||||
//测试全局AOP,并行场景
|
||||
@Test
|
||||
public void testGlobalAopP() {
|
||||
LiteflowResponse<DefaultSlot> response= flowExecutor.execute2Resp("chain2", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("a"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("b"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("c"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("d"));
|
||||
Assert.assertEquals("before_after", response.getSlot().getData("e"));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanScanCache(){
|
||||
BaseTest.cleanScanCache();
|
||||
ComponentScanner.cmpAroundAspect = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yomahub.liteflow.test.aop.aspect;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.aop.ICmpAroundAspect;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
|
||||
public class CmpAspect implements ICmpAroundAspect {
|
||||
@Override
|
||||
public void beforeProcess(String nodeId, Slot slot) {
|
||||
slot.setData(nodeId, "before");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterProcess(String nodeId, Slot slot) {
|
||||
slot.setData(nodeId, StrUtil.format("{}_{}", slot.getData(nodeId), "after"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.yomahub.liteflow.test.aop.aspect;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
|
||||
@Aspect
|
||||
public class CustomAspect {
|
||||
|
||||
@Pointcut("execution(* com.yomahub.liteflow.test.aop.cmp1.*.process())")
|
||||
public void cut() {
|
||||
}
|
||||
|
||||
@Around("cut()")
|
||||
public Object around(ProceedingJoinPoint jp) throws Throwable {
|
||||
NodeComponent cmp = (NodeComponent) jp.getThis();
|
||||
Slot slot = cmp.getSlot();
|
||||
slot.setData(cmp.getNodeId(), "before");
|
||||
Object returnObj = jp.proceed();
|
||||
slot.setData(cmp.getNodeId(), StrUtil.format("{}_{}", slot.getData(cmp.getNodeId()), "after"));
|
||||
return returnObj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.aop.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("a")
|
||||
public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("Acomp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.aop.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("b")
|
||||
public class BCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("Bcomp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.aop.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("Ccomp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.aop.cmp2;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("d")
|
||||
public class DCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("Dcomp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.aop.cmp2;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("e")
|
||||
public class ECmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("Ecomp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.yomahub.liteflow.test.asyncNode;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import com.yomahub.liteflow.test.asyncNode.exception.TestException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 测试隐式调用子流程
|
||||
* 单元测试
|
||||
*
|
||||
* @author ssss
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/asyncNode/application.xml")
|
||||
public class AsyncNodeSpringTest extends BaseTest {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
/*****
|
||||
* 标准chain 嵌套选择 嵌套子chain进行执行
|
||||
* 验证了when情况下 多个node是并行执行
|
||||
* 验证了默认参数情况下 when可以加载执行
|
||||
* **/
|
||||
@Test
|
||||
public void testAsyncFlow1() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "it's a base request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
System.out.println(response.getSlot().getExecuteStepStr());
|
||||
}
|
||||
|
||||
//这个和test1有点类似,只不过进一步验证了步骤
|
||||
@Test
|
||||
public void testAsyncFlow2() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "it's a base request");
|
||||
Assert.assertTrue(ListUtil.toList("b==>j==>g==>f==>h","b==>j==>g==>h==>f",
|
||||
"b==>j==>h==>g==>f","b==>j==>h==>f==>g",
|
||||
"b==>j==>f==>h==>g","b==>j==>f==>g==>h"
|
||||
).contains(response.getSlot().getExecuteStepStr()));
|
||||
}
|
||||
|
||||
//测试errorResume,默认的errorResume为false,这里测试默认的
|
||||
@Test
|
||||
public void testAsyncFlow3_1() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3-1", "it's a base request");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class);
|
||||
}
|
||||
|
||||
//测试errorResume,默认的errorResume为false,这里设置为true
|
||||
@Test
|
||||
public void testAsyncFlow3_2() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3-2", "it's a base request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
//相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错
|
||||
@Test
|
||||
public void testAsyncFlow4() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain4", "it's a base request");
|
||||
//因为不记录错误,所以最终结果是true
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
//因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下
|
||||
Integer count = response.getSlot().getData("count");
|
||||
Assert.assertEquals(new Integer(2), count);
|
||||
//因为配置了不抛错,所以response里的cause应该为null
|
||||
Assert.assertNull(response.getCause());
|
||||
}
|
||||
|
||||
//相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错
|
||||
@Test
|
||||
public void testAsyncFlow5() throws Exception {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain5", "it's a base request");
|
||||
//整个并行组是报错的,所以最终结果是false
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
//因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下
|
||||
Integer count = response.getSlot().getData("count");
|
||||
Assert.assertEquals(new Integer(2), count);
|
||||
//因为第一个when配置了会报错,所以response里的cause里应该会有TestException
|
||||
Assert.assertEquals(TestException.class, response.getCause().getClass());
|
||||
}
|
||||
|
||||
//不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行
|
||||
@Test
|
||||
public void testAsyncFlow6() throws Exception {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain6", "it's a base request");
|
||||
//第一个when会抛错,所以最终结果是false
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
//因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍
|
||||
Integer count = response.getSlot().getData("count");
|
||||
Assert.assertEquals(new Integer(1), count);
|
||||
//第一个when会报错,所以最终response的cause里应该会有TestException
|
||||
Assert.assertEquals(TestException.class, response.getCause().getClass());
|
||||
}
|
||||
|
||||
//不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错
|
||||
@Test
|
||||
public void testAsyncFlow7() throws Exception {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain7", "it's a base request");
|
||||
//第二个when会抛错,所以最终结果是false
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
// 传递了slotIndex,则set的size==2
|
||||
Integer count = response.getSlot().getData("count");
|
||||
Assert.assertEquals(new Integer(2), count);
|
||||
//第一个when会报错,所以最终response的cause里应该会有TestException
|
||||
Assert.assertEquals(TestException.class, response.getCause().getClass());
|
||||
}
|
||||
|
||||
//测试任意异步一个执行完即继续的场景
|
||||
//d g h并行,配置了any=true,其中d耗时1秒,g耗时0.5秒,其他都不设耗时
|
||||
//最终执行效果应该是h先返回,然后执行abc,最后gd
|
||||
//这里要注意的是,由于step是先加入,所以step的打印顺序并不是这样的。但是实际执行是正确的
|
||||
@Test
|
||||
public void testAsyncFlow8() throws Exception {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain8", "it's a base request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertTrue(response.getSlot().getData("check").toString().startsWith("habc"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("a")
|
||||
public class ACmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
Slot slot = this.getSlot();
|
||||
synchronized (NodeComponent.class){
|
||||
if (slot.hasData("check")){
|
||||
String str = slot.getData("check");
|
||||
str += this.getNodeId();
|
||||
slot.setData("check", str);
|
||||
}else{
|
||||
slot.setData("check", this.getNodeId());
|
||||
}
|
||||
}
|
||||
System.out.println("Acomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("b")
|
||||
public class BCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
Slot slot = this.getSlot();
|
||||
synchronized (NodeComponent.class){
|
||||
if (slot.hasData("check")){
|
||||
String str = slot.getData("check");
|
||||
str += this.getNodeId();
|
||||
slot.setData("check", str);
|
||||
}else{
|
||||
slot.setData("check", this.getNodeId());
|
||||
}
|
||||
}
|
||||
System.out.println("Bcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
Slot slot = this.getSlot();
|
||||
synchronized (NodeComponent.class){
|
||||
if (slot.hasData("check")){
|
||||
String str = slot.getData("check");
|
||||
str += this.getNodeId();
|
||||
slot.setData("check", str);
|
||||
}else{
|
||||
slot.setData("check", this.getNodeId());
|
||||
}
|
||||
}
|
||||
System.out.println("Ccomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("d")
|
||||
public class DCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
Thread.sleep(1000);
|
||||
Slot slot = this.getSlot();
|
||||
synchronized (NodeComponent.class){
|
||||
if (slot.hasData("check")){
|
||||
String str = slot.getData("check");
|
||||
str += this.getNodeId();
|
||||
slot.setData("check", str);
|
||||
}else{
|
||||
slot.setData("check", this.getNodeId());
|
||||
}
|
||||
}
|
||||
System.out.println("Dcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeCondComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("e")
|
||||
public class ECmp extends NodeCondComponent {
|
||||
|
||||
@Override
|
||||
public String processCond() throws Exception {
|
||||
System.out.println("Ecomp executed!");
|
||||
return "g";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("f")
|
||||
public class FCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("Fcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("g")
|
||||
public class GCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
Thread.sleep(500);
|
||||
Slot slot = this.getSlot();
|
||||
synchronized (NodeComponent.class){
|
||||
if (slot.hasData("check")){
|
||||
String str = slot.getData("check");
|
||||
str += this.getNodeId();
|
||||
slot.setData("check", str);
|
||||
}else{
|
||||
slot.setData("check", this.getNodeId());
|
||||
}
|
||||
}
|
||||
System.out.println("Gcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("h")
|
||||
public class HCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
Slot slot = this.getSlot();
|
||||
synchronized (NodeComponent.class){
|
||||
if (slot.hasData("check")){
|
||||
String str = slot.getData("check");
|
||||
str += this.getNodeId();
|
||||
slot.setData("check", str);
|
||||
}else{
|
||||
slot.setData("check", this.getNodeId());
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Hcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import com.yomahub.liteflow.test.asyncNode.exception.TestException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("i")
|
||||
public class ICmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
Slot slot = this.getSlot();
|
||||
if (slot.hasData("count")){
|
||||
Integer count = slot.getData("count");
|
||||
slot.setData("count", ++count);
|
||||
} else{
|
||||
slot.setData("count", 1);
|
||||
}
|
||||
System.out.println("Icomp executed! throw Exception!");
|
||||
throw new TestException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yomahub.liteflow.test.asyncNode.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeCondComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("j")
|
||||
public class JCmp extends NodeCondComponent {
|
||||
|
||||
@Override
|
||||
public String processCond() throws Exception {
|
||||
System.out.println("Jcomp executed!");
|
||||
return "chain3";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yomahub.liteflow.test.base;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
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.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/base/application.xml")
|
||||
public class BaseCommonSpringTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Test
|
||||
public void testBaseCommon(){
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b==>c==>d", response.getSlot().getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.base.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("a")
|
||||
public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("ACmp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.base.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("b")
|
||||
public class BCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("BCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.base.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("CCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.base.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("d")
|
||||
public class DCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("CCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.yomahub.liteflow.test.config;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.exception.ConfigErrorException;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 无spring环境下参数单元测试
|
||||
* @author zendwang
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public class LiteflowConfigNoSpringTest extends BaseTest {
|
||||
|
||||
@Test(expected = ConfigErrorException.class)
|
||||
public void testNoConfig() {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
executor.init();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfig() {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("config/flow.json");
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
LiteflowResponse<DefaultSlot> response = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals(15, config.getWhenMaxWaitSeconds().intValue());
|
||||
Assert.assertEquals(200, config.getQueueLimit().intValue());
|
||||
Assert.assertEquals(300000L, config.getDelay().longValue());
|
||||
Assert.assertEquals(300000L, config.getPeriod().longValue());
|
||||
Assert.assertFalse(config.getEnableLog());
|
||||
Assert.assertEquals(Runtime.getRuntime().availableProcessors() * 2, config.getWhenMaxWorkers().longValue());
|
||||
Assert.assertEquals(100, config.getWhenQueueLimit().longValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* rule source支持的通配符
|
||||
* 匹配的文件
|
||||
* config/nospringgroup0/flow0.xml
|
||||
* config/nospringgroup1/flow.xml
|
||||
*/
|
||||
@Test
|
||||
public void testLocalXmlRuleSourcePatternMatch() {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("config/nospring*/flow*.xml");
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
LiteflowResponse<DefaultSlot> response0 = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertEquals("a==>b==>c", response0.getSlot().getExecuteStepStr());
|
||||
|
||||
LiteflowResponse<DefaultSlot> response1 = executor.execute2Resp("chain3", "arg");
|
||||
Assert.assertEquals("a==>c==>f==>g", response1.getSlot().getExecuteStepStr());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* rule source支持的通配符
|
||||
* 匹配的文件
|
||||
* config/nospringgroup0/flow0.json
|
||||
* config/nospringgroup1/flow0.json
|
||||
*/
|
||||
@Test
|
||||
public void testLocalJsonRuleSourcePatternMatch() {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("config/nospring*/flow*.json");
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
LiteflowResponse<DefaultSlot> response0 = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertEquals("a==>b==>c", response0.getSlot().getExecuteStepStr());
|
||||
LiteflowResponse<DefaultSlot> response1 = executor.execute2Resp("chain3", "arg");
|
||||
Assert.assertEquals("a==>c==>f==>g", response1.getSlot().getExecuteStepStr());
|
||||
}
|
||||
|
||||
/**
|
||||
* rule source支持的通配符
|
||||
* 匹配的文件
|
||||
* config/nospringgroup0/flow0.yml
|
||||
* config/nospringgroup1/flow.yml
|
||||
*/
|
||||
@Test
|
||||
public void testLocalYmlRuleSourcePatternMatch() {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("config/nospring*/flow*.yml");
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
LiteflowResponse<DefaultSlot> response0 = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertEquals("a==>b==>c", response0.getSlot().getExecuteStepStr());
|
||||
LiteflowResponse<DefaultSlot> response = executor.execute2Resp("chain3", "arg");
|
||||
Assert.assertEquals("a==>c==>f==>g", response.getSlot().getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.absoluteConfigPath.cmp" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="/usr/local/flow.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.aop.cmp1,com.yomahub.liteflow.test.aop.cmp2" />
|
||||
|
||||
<bean class="com.yomahub.liteflow.test.aop.aspect.CustomAspect"/>
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="aop/flow.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.aop.cmp1,com.yomahub.liteflow.test.aop.cmp2" />
|
||||
|
||||
<bean class="com.yomahub.liteflow.test.aop.aspect.CmpAspect"/>
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="aop/flow.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c,d,e"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
<then value="a,b,c"/>
|
||||
<when value="d,e"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.asyncNode.cmp" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="asyncNode/flow.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<!-- base test -->
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c"/> <!-- a b c 串联执行-->
|
||||
<when value="d,e(f|g)"/> <!-- e d 并联执行-->
|
||||
<then value="chain2"/>
|
||||
</chain>
|
||||
<chain name="chain2">
|
||||
<then value="b,j(a|chain3)"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
<when value="g,f,h"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain3-1">
|
||||
<when value="f,g,i" group="1"/>
|
||||
<when value="h" group="2"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain3-2">
|
||||
<when value="f,g,i" errorResume="true" group="1"/>
|
||||
<when value="h" group="2"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
<then value="a,b,c"/> <!-- a b c 串联执行-->
|
||||
<when value="d,i" errorResume="true"/> <!-- d i 并联执行-->
|
||||
<when value="g,i,h" errorResume="false"/><!-- 此时 g i h 与 d i并联执行 并且默认异常不抛出-->
|
||||
</chain>
|
||||
|
||||
<chain name="chain5">
|
||||
<then value="a,b,c"/> <!-- a b c 串联执行-->
|
||||
<when value="d,i" errorResume="false"/> <!-- d i 并联执行-->
|
||||
<when value="g,i,h" errorResume="true"/><!-- 此时 g i h 与 d i并联执行 并且默认异常抛出-->
|
||||
</chain>
|
||||
|
||||
<chain name="chain6">
|
||||
<then value="a,b,c"/> <!-- a b c 串联执行-->
|
||||
<when value="d,i" errorResume="false" group="1"/> <!-- d i 并联执行-->
|
||||
<when value="g,i,h" errorResume="true" group="2"/><!-- 此时 g i h 与 d i并联执行 并且默认异常抛出-->
|
||||
</chain>
|
||||
|
||||
<chain name="chain7">
|
||||
<then value="a,b,c"/> <!-- a b c 串联执行-->
|
||||
<when value="d,i" errorResume="true" group="1"/> <!-- d i 并联执行-->
|
||||
<when value="g,i,h" errorResume="false" group="2"/><!-- 此时 g i h 与 d i并联执行 并且默认异常抛出-->
|
||||
</chain>
|
||||
|
||||
<chain name="chain8">
|
||||
<when value="d,g,h" any="true"/> <!-- a b c 串联执行-->
|
||||
<then value="a,b,c"/> <!-- d g h 并联执行,任意一个执行完毕即结束-->
|
||||
</chain>
|
||||
|
||||
</flow>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.base.cmp" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="base/flow.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c,d"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"flow": {
|
||||
"nodes": {
|
||||
"node": [
|
||||
{
|
||||
"id": "a",
|
||||
"class": "com.yomahub.liteflow.test.config.cmp.ACmp"
|
||||
},
|
||||
{
|
||||
"id": "b",
|
||||
"class": "com.yomahub.liteflow.test.config.cmp.BCmp"
|
||||
},
|
||||
{
|
||||
"id": "c",
|
||||
"class": "com.yomahub.liteflow.test.config.cmp.CCmp"
|
||||
}
|
||||
]
|
||||
},
|
||||
"chain": [
|
||||
{
|
||||
"name": "chain1",
|
||||
"condition": [
|
||||
{"type": "then", "value": "a,b,c"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<nodes>
|
||||
<node id="a" class="com.yomahub.liteflow.test.config.cmp.ACmp"/>
|
||||
<node id="b" class="com.yomahub.liteflow.test.config.cmp.BCmp"/>
|
||||
<node id="c" class="com.yomahub.liteflow.test.config.cmp.CCmp"/>
|
||||
<node id="d" class="com.yomahub.liteflow.test.config.cmp.DCmp"/>
|
||||
<node id="e" class="com.yomahub.liteflow.test.config.cmp.ECmp"/>
|
||||
<node id="f" class="com.yomahub.liteflow.test.config.cmp.FCmp"/>
|
||||
<node id="g" class="com.yomahub.liteflow.test.config.cmp.GCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -1,14 +0,0 @@
|
||||
flow:
|
||||
nodes:
|
||||
node:
|
||||
- id: a
|
||||
class: com.yomahub.liteflow.test.config.cmp.ACmp
|
||||
- id: b
|
||||
class: com.yomahub.liteflow.test.config.cmp.BCmp
|
||||
- id: c
|
||||
class: com.yomahub.liteflow.test.config.cmp.CCmp
|
||||
chain:
|
||||
- name: chain1
|
||||
condition:
|
||||
- type: then
|
||||
value: 'a,b,c'
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"flow": {
|
||||
"nodes": {
|
||||
"node": [
|
||||
{
|
||||
"id": "d",
|
||||
"class": "com.yomahub.liteflow.test.config.cmp.DCmp"
|
||||
},
|
||||
{
|
||||
"id": "e",
|
||||
"class": "com.yomahub.liteflow.test.config.cmp.ECmp"
|
||||
},
|
||||
{
|
||||
"id": "f",
|
||||
"class": "com.yomahub.liteflow.test.config.cmp.FCmp"
|
||||
},
|
||||
{
|
||||
"id": "g",
|
||||
"class": "com.yomahub.liteflow.test.config.cmp.GCmp"
|
||||
}
|
||||
]
|
||||
},
|
||||
"chain": [
|
||||
{
|
||||
"name": "chain3",
|
||||
"condition": [
|
||||
{"type": "then", "value": "a,c,f,g"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<nodes>
|
||||
<node id="a" class="com.yomahub.liteflow.test.parser.cmp.ACmp"/>
|
||||
<node id="b" class="com.yomahub.liteflow.test.parser.cmp.BCmp"/>
|
||||
<node id="c" class="com.yomahub.liteflow.test.parser.cmp.CCmp"/>
|
||||
<node id="d" class="com.yomahub.liteflow.test.parser.cmp.DCmp"/>
|
||||
<node id="e" class="com.yomahub.liteflow.test.parser.cmp.ECmp"/>
|
||||
<node id="f" class="com.yomahub.liteflow.test.parser.cmp.FCmp"/>
|
||||
<node id="g" class="com.yomahub.liteflow.test.parser.cmp.GCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain3">
|
||||
<then value="a,c"/>
|
||||
<then value="f,g"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -1,16 +0,0 @@
|
||||
flow:
|
||||
nodes:
|
||||
node:
|
||||
- id: d
|
||||
class: com.yomahub.liteflow.test.config.cmp.DCmp
|
||||
- id: e
|
||||
class: com.yomahub.liteflow.test.config.cmp.ECmp
|
||||
- id: f
|
||||
class: com.yomahub.liteflow.test.config.cmp.FCmp
|
||||
- id: g
|
||||
class: com.yomahub.liteflow.test.config.cmp.GCmp
|
||||
chain:
|
||||
- name: chain3
|
||||
condition:
|
||||
- type: then
|
||||
value: 'a,c,f,g'
|
||||
Reference in New Issue
Block a user