From e5f6eb37c78edd160a898ba790ce666b83ffc682 Mon Sep 17 00:00:00 2001 From: bryan31 Date: Thu, 24 Feb 2022 19:07:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/monitor/MonitorSpringbootTest.java | 11 +++- .../test/monitor/MonitorSpringTest.java | 44 +++++++++++++ .../liteflow/test/monitor/cmp/ACmp.java | 28 ++++++++ .../liteflow/test/monitor/cmp/BCmp.java | 28 ++++++++ .../liteflow/test/monitor/cmp/CCmp.java | 28 ++++++++ .../LiteflowMultipleTypeSpringTest.java | 36 +++++++++++ .../liteflow/test/multipleType/cmp/ACmp.java | 20 ++++++ .../liteflow/test/multipleType/cmp/BCmp.java | 21 ++++++ .../liteflow/test/multipleType/cmp/CCmp.java | 21 ++++++ .../CustomerDefaultNodeExecutor.java | 19 ++++++ .../nodeExecutor/CustomerNodeExecutor.java | 20 ++++++ .../CustomerNodeExecutorAndCustomRetry.java | 29 +++++++++ .../LiteflowNodeExecutorSpringbootTest.java | 63 ++++++++++++++++++ .../liteflow/test/nodeExecutor/cmp/ACmp.java | 22 +++++++ .../liteflow/test/nodeExecutor/cmp/BCmp.java | 27 ++++++++ .../liteflow/test/nodeExecutor/cmp/CCmp.java | 29 +++++++++ .../liteflow/test/nodeExecutor/cmp/DCmp.java | 31 +++++++++ .../PreAndFinallySpringTest.java | 58 +++++++++++++++++ .../liteflow/test/preAndFinally/cmp/ACmp.java | 20 ++++++ .../liteflow/test/preAndFinally/cmp/BCmp.java | 21 ++++++ .../liteflow/test/preAndFinally/cmp/CCmp.java | 21 ++++++ .../liteflow/test/preAndFinally/cmp/DCmp.java | 22 +++++++ .../test/preAndFinally/cmp/Finally1Cmp.java | 20 ++++++ .../test/preAndFinally/cmp/Finally2Cmp.java | 20 ++++++ .../test/preAndFinally/cmp/Finally3Cmp.java | 28 ++++++++ .../test/preAndFinally/cmp/Pre1Cmp.java | 20 ++++++ .../test/preAndFinally/cmp/Pre2Cmp.java | 20 ++++++ .../PrivateDeliverySpringTest.java | 35 ++++++++++ .../test/privateDelivery/cmp/ACmp.java | 30 +++++++++ .../test/privateDelivery/cmp/BCmp.java | 26 ++++++++ .../test/privateDelivery/cmp/CCmp.java | 21 ++++++ .../test/privateDelivery/cmp/DCmp.java | 21 ++++++ .../refreshRule/RefreshRuleSpringTest.java | 64 +++++++++++++++++++ .../liteflow/test/refreshRule/cmp/ACmp.java | 20 ++++++ .../liteflow/test/refreshRule/cmp/BCmp.java | 21 ++++++ .../liteflow/test/refreshRule/cmp/CCmp.java | 21 ++++++ .../test/resources/monitor/application.xml | 31 +++++++++ .../src/test/resources/monitor/flow.xml | 8 +++ .../resources/multipleType/application.xml | 24 +++++++ .../src/test/resources/multipleType/flow.xml | 10 +++ .../src/test/resources/multipleType/flow.yml | 6 ++ .../resources/nodeExecutor/application.xml | 26 ++++++++ .../src/test/resources/nodeExecutor/flow.xml | 18 ++++++ .../resources/preAndFinally/application.xml | 23 +++++++ .../src/test/resources/preAndFinally/flow.xml | 26 ++++++++ .../resources/privateDelivery/application.xml | 23 +++++++ .../test/resources/privateDelivery/flow.xml | 18 ++++++ .../resources/refreshRule/application.xml | 23 +++++++ .../src/test/resources/refreshRule/flow.xml | 6 ++ .../resources/refreshRule/flow_update.xml | 6 ++ 50 files changed, 1233 insertions(+), 1 deletion(-) create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringTest.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/ACmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/BCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/CCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringTest.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/ACmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/BCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/CCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/ACmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/BCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringTest.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/ACmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/BCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/CCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/DCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally1Cmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally2Cmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre1Cmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre2Cmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringTest.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/CCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/DCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringTest.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/ACmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/BCmp.java create mode 100644 liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/CCmp.java create mode 100644 liteflow-testcase-springnative/src/test/resources/monitor/application.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/monitor/flow.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/multipleType/application.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/multipleType/flow.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/multipleType/flow.yml create mode 100644 liteflow-testcase-springnative/src/test/resources/nodeExecutor/application.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/nodeExecutor/flow.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/preAndFinally/application.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/preAndFinally/flow.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/privateDelivery/application.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/privateDelivery/flow.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/refreshRule/application.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/refreshRule/flow.xml create mode 100644 liteflow-testcase-springnative/src/test/resources/refreshRule/flow_update.xml 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 e07a53ff9..11147d10c 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 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 000000000..2aa85721a --- /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 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 000000000..d5f2438af --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/ACmp.java @@ -0,0 +1,28 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..a5a3f44e0 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/BCmp.java @@ -0,0 +1,28 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..6a44bb60a --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/cmp/CCmp.java @@ -0,0 +1,28 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..cb5e628a0 --- /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 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 000000000..343dd85e8 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/ACmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..65ac7a70f --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/BCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..dff3388b9 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/cmp/CCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..84b60247a --- /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 000000000..247bc3d47 --- /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 000000000..46792852a --- /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 000000000..0d384129e --- /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 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 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 response = flowExecutor.execute2Resp("chain3", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("c", response.getSlot().getExecuteStepStr()); + } + + //自定义执行器测试+全局重试配置测试 + @Test + public void testCustomExecutorForRetry() { + LiteflowResponse 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 000000000..8fd765bb1 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/ACmp.java @@ -0,0 +1,22 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * + * @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 000000000..6e737879e --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/BCmp.java @@ -0,0 +1,27 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..f7ad8f770 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java @@ -0,0 +1,29 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 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 000000000..b80d2e0af --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java @@ -0,0 +1,31 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * + * @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 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 000000000..d70b3509e --- /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 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 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 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 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 000000000..1dcd75200 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/ACmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..ac7b830ef --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/BCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..9219d67ac --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/CCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..3f1216a7a --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/DCmp.java @@ -0,0 +1,22 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..f826fb5ed --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally1Cmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..92157678a --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally2Cmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..97f9a0415 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java @@ -0,0 +1,28 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..741e15d49 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre1Cmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..43cd71f17 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Pre2Cmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..c446227ed --- /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 response = flowExecutor.execute2Resp("chain1", "arg"); + Set 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 000000000..6415a130f --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java @@ -0,0 +1,30 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..73bea692c --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java @@ -0,0 +1,26 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 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 000000000..8d79eb1bc --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/CCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..a17ad9bb6 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/DCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..1191c2c27 --- /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 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 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 000000000..96d599a5b --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/ACmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..8930ff9d0 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/BCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..b15889a00 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/cmp/CCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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 000000000..4dc968fac --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/monitor/application.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 000000000..e8ea83f95 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/monitor/flow.xml @@ -0,0 +1,8 @@ + + + + + + + + \ 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 000000000..d5edf439b --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/multipleType/application.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + \ 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 000000000..38b703214 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/multipleType/flow.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ 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 000000000..4c1d8375a --- /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 000000000..4f1904159 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/nodeExecutor/application.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + \ 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 000000000..6b867c5bc --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/nodeExecutor/flow.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ 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 000000000..5a7c33062 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/preAndFinally/application.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + \ 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 000000000..5dac9fb0a --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/preAndFinally/flow.xml @@ -0,0 +1,26 @@ + + + +
+        
+        
+    
+
+    
+        
+        
+        
+        
+    
+
+    
+        
+        
+        
+    
+
+    
+        
+        
+    
+
\ 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 000000000..aeefbfc46
--- /dev/null
+++ b/liteflow-testcase-springnative/src/test/resources/privateDelivery/application.xml
@@ -0,0 +1,23 @@
+
+
+
+    
+
+    
+
+    
+
+    
+        
+    
+
+    
+        
+    
+
\ 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 000000000..bf7146217
--- /dev/null
+++ b/liteflow-testcase-springnative/src/test/resources/privateDelivery/flow.xml
@@ -0,0 +1,18 @@
+
+
+    
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+    
+
\ 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 000000000..8572a661a
--- /dev/null
+++ b/liteflow-testcase-springnative/src/test/resources/refreshRule/application.xml
@@ -0,0 +1,23 @@
+
+
+
+    
+
+    
+
+    
+
+    
+        
+    
+
+    
+        
+    
+
\ 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 000000000..22870d94f
--- /dev/null
+++ b/liteflow-testcase-springnative/src/test/resources/refreshRule/flow.xml
@@ -0,0 +1,6 @@
+
+
+    
+        
+    
+
\ 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 000000000..29090f04a
--- /dev/null
+++ b/liteflow-testcase-springnative/src/test/resources/refreshRule/flow_update.xml
@@ -0,0 +1,6 @@
+
+
+    
+        
+    
+
\ No newline at end of file