diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java index e07a53ff..11147d10 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java @@ -3,7 +3,10 @@ package com.yomahub.liteflow.test.monitor; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.entity.data.DefaultSlot; import com.yomahub.liteflow.entity.data.LiteflowResponse; +import com.yomahub.liteflow.monitor.MonitorBus; +import com.yomahub.liteflow.spi.holder.ContextAwareHolder; import com.yomahub.liteflow.test.BaseTest; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,7 +38,13 @@ public class MonitorSpringbootTest extends BaseTest { LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Thread.sleep(20000); + Thread.sleep(10000); + } + + @AfterClass + public static void clean(){ + MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class); + monitorBus.closeScheduler(); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringTest.java new file mode 100644 index 00000000..2aa85721 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringTest.java @@ -0,0 +1,44 @@ +package com.yomahub.liteflow.test.monitor; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.entity.data.DefaultSlot; +import com.yomahub.liteflow.entity.data.LiteflowResponse; +import com.yomahub.liteflow.monitor.MonitorBus; +import com.yomahub.liteflow.spi.holder.ContextAwareHolder; +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; + +/** + * springboot环境最普通的例子测试 + * @author Bryan.Zhang + * @since 2.6.4 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration("classpath:/monitor/application.xml") +public class MonitorSpringTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testMonitor() throws Exception{ + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + + Thread.sleep(10000); + } + + @AfterClass + public static void clean(){ + MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class); + monitorBus.closeScheduler(); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/ACmp.java new file mode 100644 index 00000000..d5f2438a --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/ACmp.java @@ -0,0 +1,28 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.monitor.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +import java.util.Random; + +@Component("a") +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!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/BCmp.java new file mode 100644 index 00000000..a5a3f44e --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/BCmp.java @@ -0,0 +1,28 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.monitor.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +import java.util.Random; + +@Component("b") +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!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/CCmp.java new file mode 100644 index 00000000..6a44bb60 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/CCmp.java @@ -0,0 +1,28 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.monitor.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +import java.util.Random; + +@Component("c") +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!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringTest.java new file mode 100644 index 00000000..cb5e628a --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringTest.java @@ -0,0 +1,36 @@ +package com.yomahub.liteflow.test.multipleType; + +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.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + + +/** + * 测试springboot下混合格式规则的场景 + * @author Bryan.Zhang + * @since 2.5.10 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration("classpath:/multipleType/application.xml") +public class LiteflowMultipleTypeSpringTest extends BaseTest { + + @Autowired + private FlowExecutor flowExecutor; + + @Test + public void testConfig() { + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>b==>c==>b==>a", response.getSlot().getExecuteStepStr()); + response = flowExecutor.execute2Resp("chain3", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>b==>c", response.getSlot().getExecuteStepStr()); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/ACmp.java new file mode 100644 index 00000000..343dd85e --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/ACmp.java @@ -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.multipleType.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!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/BCmp.java new file mode 100644 index 00000000..65ac7a70 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/BCmp.java @@ -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.multipleType.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!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/CCmp.java new file mode 100644 index 00000000..dff3388b --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/CCmp.java @@ -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.multipleType.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!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java new file mode 100644 index 00000000..84b60247 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java @@ -0,0 +1,19 @@ +package com.yomahub.liteflow.test.nodeExecutor; + +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.entity.data.DataBus; +import com.yomahub.liteflow.entity.data.Slot; +import com.yomahub.liteflow.entity.executor.NodeExecutor; + +/** + * 自定义默认的节点执行器 + */ +public class CustomerDefaultNodeExecutor extends NodeExecutor { + @Override + public void execute(NodeComponent instance) throws Exception { + Slot slot = DataBus.getSlot(instance.getSlotIndex()); + LOG.info("使用customerDefaultNodeExecutor进行执行"); + slot.setData("customerDefaultNodeExecutor", this.getClass()); + super.execute(instance); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java new file mode 100644 index 00000000..247bc3d4 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java @@ -0,0 +1,20 @@ +package com.yomahub.liteflow.test.nodeExecutor; + +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.entity.data.DataBus; +import com.yomahub.liteflow.entity.data.Slot; +import com.yomahub.liteflow.entity.executor.NodeExecutor; + +/** + * 自定义节点执行器 + */ +public class CustomerNodeExecutor extends NodeExecutor { + @Override + public void execute(NodeComponent instance) throws Exception { + Slot slot = DataBus.getSlot(instance.getSlotIndex()); + LOG.info("使用customerNodeExecutor进行执行"); + slot.setData("customerNodeExecutor", this.getClass()); + super.execute(instance); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java new file mode 100644 index 00000000..46792852 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java @@ -0,0 +1,29 @@ +package com.yomahub.liteflow.test.nodeExecutor; + +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.entity.data.DataBus; +import com.yomahub.liteflow.entity.data.Slot; +import com.yomahub.liteflow.entity.executor.NodeExecutor; + +import java.util.concurrent.TimeUnit; + +/** + * 自定义节点执行器 + */ +public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { + @Override + public void execute(NodeComponent instance) throws Exception { + Slot slot = DataBus.getSlot(instance.getSlotIndex()); + LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); + slot.setData("customerNodeExecutorAndCustomRetry", this.getClass()); + super.execute(instance); + } + + @Override + protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { + TimeUnit.MICROSECONDS.sleep(20L); + Slot slot = DataBus.getSlot(instance.getSlotIndex()); + slot.setData("retryLogic", this.getClass()); + super.retry(instance, currentRetryCount); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java new file mode 100644 index 00000000..0d384129 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java @@ -0,0 +1,63 @@ +package com.yomahub.liteflow.test.nodeExecutor; + +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; + + +/** + * 测试springboot下的组件重试 + * + * @author Bryan.Zhang + * @since 2.5.10 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration("classpath:/nodeExecutor/application.xml") +public class LiteflowNodeExecutorSpringbootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + // 默认执行器测试 + @Test + public void testCustomerDefaultNodeExecutor() { + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals("a", response.getSlot().getExecuteStepStr()); + } + + //默认执行器测试+全局重试配置测试 + @Test + public void testDefaultExecutorForRetry() { + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals("b==>b==>b", response.getSlot().getExecuteStepStr()); + } + + //自定义执行器测试 + @Test + public void testCustomerExecutor() { + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("c", response.getSlot().getExecuteStepStr()); + } + + //自定义执行器测试+全局重试配置测试 + @Test + public void testCustomExecutorForRetry() { + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain4", "arg"); + Assert.assertFalse(response.isSuccess()); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getSlot().getData("retryLogic")); + Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getSlot().getExecuteStepStr()); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/ACmp.java new file mode 100644 index 00000000..8fd765bb --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/ACmp.java @@ -0,0 +1,22 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.nodeExecutor.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/BCmp.java new file mode 100644 index 00000000..6e737879 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/BCmp.java @@ -0,0 +1,27 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.nodeExecutor.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("b") +public class BCmp extends NodeComponent { + + private int flag = 0; + + @Override + public void process() { + System.out.println("BCmp executed!"); + if (flag < 2){ + flag++; + throw new RuntimeException("demo exception"); + } + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java new file mode 100644 index 00000000..f7ad8f77 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java @@ -0,0 +1,29 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.nodeExecutor.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.annotation.LiteflowRetry; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.entity.executor.NodeExecutor; +import com.yomahub.liteflow.test.nodeExecutor.CustomerNodeExecutor; + +@LiteflowComponent("c") +@LiteflowRetry(5) +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + + @Override + public Class<? extends NodeExecutor> getNodeExecutorClass() { + return CustomerNodeExecutor.class; + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java new file mode 100644 index 00000000..b80d2e0a --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java @@ -0,0 +1,31 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.nodeExecutor.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.annotation.LiteflowRetry; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.entity.executor.NodeExecutor; +import com.yomahub.liteflow.test.nodeExecutor.CustomerNodeExecutorAndCustomRetry; + +@LiteflowComponent("d") +@LiteflowRetry(retry = 5, forExceptions = {NullPointerException.class}) +public class DCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("DCmp executed!"); + throw new NullPointerException("demo exception"); + } + + @Override + public Class<? extends NodeExecutor> getNodeExecutorClass() { + return CustomerNodeExecutorAndCustomRetry.class; + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringTest.java new file mode 100644 index 00000000..d70b3509 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringTest.java @@ -0,0 +1,58 @@ +package com.yomahub.liteflow.test.preAndFinally; + +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; + +/** + * springboot环境下pre节点和finally节点的测试 + * @author Bryan.Zhang + * @since 2.6.4 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration("classpath:/preAndFinally/application.xml") +public class PreAndFinallySpringTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + //测试普通的pre和finally节点 + @Test + public void testPreAndFinally1() throws Exception{ + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getSlot().getExecuteStepStr()); + } + + //测试pre和finally节点不放在开头和结尾的情况 + @Test + public void testPreAndFinally2() throws Exception{ + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getSlot().getExecuteStepStr()); + } + + //测试有节点报错是否还执行finally节点的情况,其中d节点会报错,但依旧执行f1,f2节点 + @Test + public void testPreAndFinally3() throws Exception{ + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3", "arg"); + Assert.assertFalse(response.isSuccess()); + Assert.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getSlot().getExecuteStepStr()); + } + + //测试在finally节点里是否能获取exception + @Test + public void testPreAndFinally4() throws Exception{ + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain4", "arg"); + Assert.assertFalse(response.isSuccess()); + Assert.assertTrue(response.getSlot().getData("hasEx")); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/ACmp.java new file mode 100644 index 00000000..1dcd7520 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/ACmp.java @@ -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.preAndFinally.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!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/BCmp.java new file mode 100644 index 00000000..ac7b830e --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/BCmp.java @@ -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.preAndFinally.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!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/CCmp.java new file mode 100644 index 00000000..9219d67a --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/CCmp.java @@ -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.preAndFinally.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!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/DCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/DCmp.java new file mode 100644 index 00000000..3f1216a7 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/DCmp.java @@ -0,0 +1,22 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.preAndFinally.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!"); + int i = 1/0; + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally1Cmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally1Cmp.java new file mode 100644 index 00000000..f826fb5e --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally1Cmp.java @@ -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.preAndFinally.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("f1") +public class Finally1Cmp extends NodeComponent { + + @Override + public void process() { + System.out.println("Finally1Cmp executed!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally2Cmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally2Cmp.java new file mode 100644 index 00000000..92157678 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally2Cmp.java @@ -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.preAndFinally.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("f2") +public class Finally2Cmp extends NodeComponent { + + @Override + public void process() { + System.out.println("Finally2Cmp executed!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java new file mode 100644 index 00000000..97f9a041 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java @@ -0,0 +1,28 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.preAndFinally.cmp; + +import cn.hutool.core.util.ObjectUtil; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.entity.data.Slot; +import org.springframework.stereotype.Component; + +@Component("f3") +public class Finally3Cmp extends NodeComponent { + + @Override + public void process() throws Exception{ + Slot slot = this.getSlot(); + if (ObjectUtil.isNull(slot.getException())){ + slot.setData("hasEx", false); + }else{ + slot.setData("hasEx", true); + } + System.out.println("Finally3Cmp executed!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre1Cmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre1Cmp.java new file mode 100644 index 00000000..741e15d4 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre1Cmp.java @@ -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.preAndFinally.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("p1") +public class Pre1Cmp extends NodeComponent { + + @Override + public void process() { + System.out.println("Pre1Cmp executed!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre2Cmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre2Cmp.java new file mode 100644 index 00000000..43cd71f1 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre2Cmp.java @@ -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.preAndFinally.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("p2") +public class Pre2Cmp extends NodeComponent { + + @Override + public void process() { + System.out.println("Pre2Cmp executed!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringTest.java new file mode 100644 index 00000000..c446227e --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringTest.java @@ -0,0 +1,35 @@ +package com.yomahub.liteflow.test.privateDelivery; + +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; +import java.util.Set; + +/** + * springboot环境下隐私投递的测试 + * @author Bryan.Zhang + * @since 2.5.0 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration("classpath:/privateDelivery/application.xml") +public class PrivateDeliverySpringTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testPrivateDelivery() throws Exception{ + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg"); + Set<Integer> set = response.getSlot().getData("testSet"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals(100, set.size()); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java new file mode 100644 index 00000000..6415a130 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java @@ -0,0 +1,30 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.privateDelivery.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.entity.data.Slot; + +import java.util.HashSet; + +@LiteflowComponent("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + Slot slot = getSlot(); + slot.setData("testSet", new HashSet<>()); + + for (int i = 0; i < 100; i++) { + this.sendPrivateDeliveryData("b",i+1); + } + } +} + diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java new file mode 100644 index 00000000..73bea692 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java @@ -0,0 +1,26 @@ +/** + * <p>Title: liteflow</p> + * <p>Description: 轻量级的组件式流程框架</p> + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.privateDelivery.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +import java.util.Set; + +@LiteflowComponent("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + Integer value = this.getPrivateDeliveryData(); + Set<Integer> testSet = this.getSlot().getData("testSet"); + testSet.add(value); + } +} + diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/CCmp.java new file mode 100644 index 00000000..8d79eb1b --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/CCmp.java @@ -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.privateDelivery.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/DCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/DCmp.java new file mode 100644 index 00000000..a17ad9bb --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/DCmp.java @@ -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.privateDelivery.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringTest.java new file mode 100644 index 00000000..1191c2c2 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringTest.java @@ -0,0 +1,64 @@ +package com.yomahub.liteflow.test.refreshRule; + +import cn.hutool.core.io.resource.ResourceUtil; +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.entity.data.DefaultSlot; +import com.yomahub.liteflow.entity.data.LiteflowResponse; +import com.yomahub.liteflow.enums.FlowParserTypeEnum; +import com.yomahub.liteflow.flow.FlowBus; +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; + +/** + * springboot环境下重新加载规则测试 + * @author Bryan.Zhang + * @since 2.6.4 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration("classpath:/refreshRule/application.xml") +public class RefreshRuleSpringTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + //测试普通刷新流程的场景 + @Test + public void testRefresh1() throws Exception{ + String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.xml"); + FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, content); + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + } + + //测试优雅刷新的场景 + @Test + public void testRefresh2() throws Exception{ + new Thread(() -> { + try { + Thread.sleep(3000L); + String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.xml"); + FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, content); + } catch (Exception e) { + e.printStackTrace(); + } + + }).start(); + + for (int i = 0; i < 500; i++) { + LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + try { + Thread.sleep(10L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/ACmp.java new file mode 100644 index 00000000..96d599a5 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/ACmp.java @@ -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.refreshRule.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!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/BCmp.java new file mode 100644 index 00000000..8930ff9d --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/BCmp.java @@ -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.refreshRule.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!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/CCmp.java new file mode 100644 index 00000000..b15889a0 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/CCmp.java @@ -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.refreshRule.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!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/resources/monitor/application.xml b/liteflow-testcase-springnative/src/test/resources/monitor/application.xml new file mode 100644 index 00000000..4dc968fa --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/monitor/application.xml @@ -0,0 +1,31 @@ +<?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.monitor.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="monitor/flow.xml"/> + <property name="enableLog" value="true"/> + <property name="queueLimit" value="200"/> + <property name="delay" value="5000"/> + <property name="period" value="5000"/> + </bean> + + <bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor"> + <property name="liteflowConfig" ref="liteflowConfig"/> + </bean> + + <bean class="com.yomahub.liteflow.monitor.MonitorBus"> + <constructor-arg name="liteflowConfig" ref="liteflowConfig"/> + </bean> +</beans> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/monitor/flow.xml b/liteflow-testcase-springnative/src/test/resources/monitor/flow.xml new file mode 100644 index 00000000..e8ea83f9 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/monitor/flow.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<flow> + <chain name="chain1"> + <then value="a"/> + <when value="b,c"/> + </chain> + +</flow> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/multipleType/application.xml b/liteflow-testcase-springnative/src/test/resources/multipleType/application.xml new file mode 100644 index 00000000..d5edf439 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/multipleType/application.xml @@ -0,0 +1,24 @@ +<?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.multipleType.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="multipleType/flow.xml,multipleType/flow.yml"/> + <property name="supportMultipleType" value="true"/> + </bean> + + <bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor"> + <property name="liteflowConfig" ref="liteflowConfig"/> + </bean> +</beans> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/multipleType/flow.xml b/liteflow-testcase-springnative/src/test/resources/multipleType/flow.xml new file mode 100644 index 00000000..38b70321 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/multipleType/flow.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<flow> + <chain name="chain1"> + <then value="a,b,chain2"/> + </chain> + + <chain name="chain2"> + <then value="c,b,a"/> + </chain> +</flow> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/multipleType/flow.yml b/liteflow-testcase-springnative/src/test/resources/multipleType/flow.yml new file mode 100644 index 00000000..4c1d8375 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/multipleType/flow.yml @@ -0,0 +1,6 @@ +flow: + chain: + - name: chain3 + condition: + - type: then + value: 'a,b,c' diff --git a/liteflow-testcase-springnative/src/test/resources/nodeExecutor/application.xml b/liteflow-testcase-springnative/src/test/resources/nodeExecutor/application.xml new file mode 100644 index 00000000..4f190415 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/nodeExecutor/application.xml @@ -0,0 +1,26 @@ +<?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.nodeExecutor.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="nodeExecutor/flow.xml"/> + <property name="retryCount" value="3"/> + <property name="slotSize" value="512"/> + <property name="nodeExecutorClass" value="com.yomahub.liteflow.test.nodeExecutor.CustomerDefaultNodeExecutor"/> + </bean> + + <bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor"> + <property name="liteflowConfig" ref="liteflowConfig"/> + </bean> +</beans> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/nodeExecutor/flow.xml b/liteflow-testcase-springnative/src/test/resources/nodeExecutor/flow.xml new file mode 100644 index 00000000..6b867c5b --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/nodeExecutor/flow.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<flow> + <chain name="chain1"> + <then value="a"/> + </chain> + + <chain name="chain2"> + <then value="b"/> + </chain> + + <chain name="chain3"> + <then value="c"/> + </chain> + + <chain name="chain4"> + <then value="d"/> + </chain> +</flow> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/preAndFinally/application.xml b/liteflow-testcase-springnative/src/test/resources/preAndFinally/application.xml new file mode 100644 index 00000000..5a7c3306 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/preAndFinally/application.xml @@ -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.preAndFinally.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="preAndFinally/flow.xml"/> + </bean> + + <bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor"> + <property name="liteflowConfig" ref="liteflowConfig"/> + </bean> +</beans> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/preAndFinally/flow.xml b/liteflow-testcase-springnative/src/test/resources/preAndFinally/flow.xml new file mode 100644 index 00000000..5dac9fb0 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/preAndFinally/flow.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<flow> + <chain name="chain1"> + <pre value="p1,p2"/> + <then value="a,b,c"/> + <finally value="f1,f2"/> + </chain> + + <chain name="chain2"> + <then value="a"/> + <pre value="p1,p2"/> + <finally value="f1,f2"/> + <then value="b,c"/> + </chain> + + <chain name="chain3"> + <pre value="p1,p2"/> + <then value="a,d,c"/> + <finally value="f1,f2"/> + </chain> + + <chain name="chain4"> + <then value="a,d,c"/> + <finally value="f3"/> + </chain> +</flow> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/privateDelivery/application.xml b/liteflow-testcase-springnative/src/test/resources/privateDelivery/application.xml new file mode 100644 index 00000000..aeefbfc4 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/privateDelivery/application.xml @@ -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.privateDelivery.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="privateDelivery/flow.xml"/> + </bean> + + <bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor"> + <property name="liteflowConfig" ref="liteflowConfig"/> + </bean> +</beans> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/privateDelivery/flow.xml b/liteflow-testcase-springnative/src/test/resources/privateDelivery/flow.xml new file mode 100644 index 00000000..bf714621 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/privateDelivery/flow.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<flow> + <chain name="chain1"> + <then value="a"/> + <!-- 100个b组件并发 --> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <when value="b,b,b,b,b,b,b,b,b,b"/> + <then value="c"/> + </chain> +</flow> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/refreshRule/application.xml b/liteflow-testcase-springnative/src/test/resources/refreshRule/application.xml new file mode 100644 index 00000000..8572a661 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/refreshRule/application.xml @@ -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.refreshRule.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="refreshRule/flow.xml"/> + </bean> + + <bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor"> + <property name="liteflowConfig" ref="liteflowConfig"/> + </bean> +</beans> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/refreshRule/flow.xml b/liteflow-testcase-springnative/src/test/resources/refreshRule/flow.xml new file mode 100644 index 00000000..22870d94 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/refreshRule/flow.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<flow> + <chain name="chain1"> + <then value="a,b,c"/> + </chain> +</flow> \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/resources/refreshRule/flow_update.xml b/liteflow-testcase-springnative/src/test/resources/refreshRule/flow_update.xml new file mode 100644 index 00000000..29090f04 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/refreshRule/flow_update.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<flow> + <chain name="chain1"> + <then value="c,b,a"/> + </chain> +</flow> \ No newline at end of file