From e5b21d6245437bcf97e6d3e5bd31cabc01dac1d6 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Sun, 9 Jul 2023 16:05:54 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=88=902.10.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 24e9535d1..3b025c401 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ - 2.10.5 + 2.10.6 UTF-8 UTF-8 8 From de34fd83e00b0c055d8fdaab375d80984f5588bb Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Tue, 11 Jul 2023 16:16:16 +0800 Subject: [PATCH 2/9] =?UTF-8?q?enhancement=20#I7K3T1=20=E8=87=AA=E5=B8=A6A?= =?UTF-8?q?OP=E6=8B=A6=E6=88=AA=E9=9C=80=E8=A6=81=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E8=8E=B7=E5=8F=96tag=E7=AD=89=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yomahub/liteflow/aop/ICmpAroundAspect.java | 15 +++------------ .../com/yomahub/liteflow/core/NodeComponent.java | 4 ++-- .../com/yomahub/liteflow/spi/CmpAroundAspect.java | 5 +++-- .../liteflow/spi/local/LocalCmpAroundAspect.java | 5 +++-- .../liteflow/spi/solon/SolonCmpAroundAspect.java | 9 +++++---- .../spi/spring/SpringCmpAroundAspect.java | 9 +++++---- .../liteflow/test/aop/aspect/CmpAspect.java | 13 +++++++------ .../liteflow/test/aop/aspect/CmpAspect.java | 13 +++++++------ .../liteflow/test/aop/aspect/CmpAspect.java | 13 +++++++------ .../liteflow/test/aop/aspect/CmpAspect.java | 13 +++++++------ 10 files changed, 49 insertions(+), 50 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/aop/ICmpAroundAspect.java b/liteflow-core/src/main/java/com/yomahub/liteflow/aop/ICmpAroundAspect.java index d8bff0d2b..091e39f88 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/aop/ICmpAroundAspect.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/aop/ICmpAroundAspect.java @@ -8,6 +8,7 @@ */ package com.yomahub.liteflow.aop; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.Slot; /** @@ -17,18 +18,8 @@ import com.yomahub.liteflow.slot.Slot; */ public interface ICmpAroundAspect { - /** - * 前置处理 - * @param nodeId 节点ID - * @param slot - */ - void beforeProcess(String nodeId, Slot slot); + void beforeProcess(NodeComponent cmp); - /** - * 后置处理 - * @param nodeId 节点ID - * @param slot - */ - void afterProcess(String nodeId, Slot slot); + void afterProcess(NodeComponent cmp); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java index 3e6274877..bf064af25 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java @@ -142,7 +142,7 @@ public abstract class NodeComponent { public void beforeProcess() { // 全局切面只在spring体系下生效,这里用了spi机制取到相应环境下的实现类 // 非spring环境下,全局切面为空实现 - CmpAroundAspectHolder.loadCmpAroundAspect().beforeProcess(nodeId, this.getSlot()); + CmpAroundAspectHolder.loadCmpAroundAspect().beforeProcess(this.self); } public abstract void process() throws Exception; @@ -156,7 +156,7 @@ public abstract class NodeComponent { } public void afterProcess() { - CmpAroundAspectHolder.loadCmpAroundAspect().afterProcess(nodeId, this.getSlot()); + CmpAroundAspectHolder.loadCmpAroundAspect().afterProcess(this.self); } // 是否进入该节点 diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/CmpAroundAspect.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/CmpAroundAspect.java index a89664d8c..3fe938217 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/CmpAroundAspect.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/CmpAroundAspect.java @@ -1,5 +1,6 @@ package com.yomahub.liteflow.spi; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.Slot; /** @@ -10,8 +11,8 @@ import com.yomahub.liteflow.slot.Slot; */ public interface CmpAroundAspect extends SpiPriority { - void beforeProcess(String nodeId, Slot slot); + void beforeProcess(NodeComponent cmp); - void afterProcess(String nodeId, Slot slot); + void afterProcess(NodeComponent cmp); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalCmpAroundAspect.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalCmpAroundAspect.java index 598c971da..c783985ba 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalCmpAroundAspect.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalCmpAroundAspect.java @@ -1,5 +1,6 @@ package com.yomahub.liteflow.spi.local; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.spi.CmpAroundAspect; @@ -12,12 +13,12 @@ import com.yomahub.liteflow.spi.CmpAroundAspect; public class LocalCmpAroundAspect implements CmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { + public void beforeProcess(NodeComponent cmp) { // 无spring环境下为空实现 } @Override - public void afterProcess(String nodeId, Slot slot) { + public void afterProcess(NodeComponent cmp) { // 无spring环境下为空实现 } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonCmpAroundAspect.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonCmpAroundAspect.java index 2e5a2a2c2..9b3f88f5a 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonCmpAroundAspect.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonCmpAroundAspect.java @@ -2,6 +2,7 @@ package com.yomahub.liteflow.spi.solon; import cn.hutool.core.util.ObjectUtil; import com.yomahub.liteflow.aop.ICmpAroundAspect; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.spi.CmpAroundAspect; import org.noear.solon.Solon; @@ -23,16 +24,16 @@ public class SolonCmpAroundAspect implements CmpAroundAspect { } @Override - public void beforeProcess(String nodeId, Slot slot) { + public void beforeProcess(NodeComponent cmp) { if (ObjectUtil.isNotNull(cmpAroundAspect)) { - cmpAroundAspect.beforeProcess(nodeId, slot); + cmpAroundAspect.beforeProcess(cmp); } } @Override - public void afterProcess(String nodeId, Slot slot) { + public void afterProcess(NodeComponent cmp) { if (ObjectUtil.isNotNull(cmpAroundAspect)) { - cmpAroundAspect.afterProcess(nodeId, slot); + cmpAroundAspect.afterProcess(cmp); } } diff --git a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringCmpAroundAspect.java b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringCmpAroundAspect.java index 9e7ff129b..b2686ca33 100644 --- a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringCmpAroundAspect.java +++ b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringCmpAroundAspect.java @@ -1,6 +1,7 @@ package com.yomahub.liteflow.spi.spring; import cn.hutool.core.util.ObjectUtil; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.spi.CmpAroundAspect; import com.yomahub.liteflow.spring.ComponentScanner; @@ -14,16 +15,16 @@ import com.yomahub.liteflow.spring.ComponentScanner; public class SpringCmpAroundAspect implements CmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { + public void beforeProcess(NodeComponent cmp) { if (ObjectUtil.isNotNull(ComponentScanner.cmpAroundAspect)) { - ComponentScanner.cmpAroundAspect.beforeProcess(nodeId, slot); + ComponentScanner.cmpAroundAspect.beforeProcess(cmp); } } @Override - public void afterProcess(String nodeId, Slot slot) { + public void afterProcess(NodeComponent cmp) { if (ObjectUtil.isNotNull(ComponentScanner.cmpAroundAspect)) { - ComponentScanner.cmpAroundAspect.afterProcess(nodeId, slot); + ComponentScanner.cmpAroundAspect.afterProcess(cmp); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java index e38846222..82a3464f9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java @@ -2,21 +2,22 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.aop.ICmpAroundAspect; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class CmpAspect implements ICmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getFirstContextBean(); - context.setData(nodeId, "before"); + public void beforeProcess(NodeComponent cmp) { + DefaultContext context = cmp.getFirstContextBean(); + context.setData(cmp.getNodeId(), "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getFirstContextBean(); - context.setData(nodeId, StrUtil.format("{}_{}", context.getData(nodeId), "after")); + public void afterProcess(NodeComponent cmp) { + DefaultContext context = cmp.getFirstContextBean(); + context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java index e38846222..82a3464f9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java @@ -2,21 +2,22 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.aop.ICmpAroundAspect; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class CmpAspect implements ICmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getFirstContextBean(); - context.setData(nodeId, "before"); + public void beforeProcess(NodeComponent cmp) { + DefaultContext context = cmp.getFirstContextBean(); + context.setData(cmp.getNodeId(), "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getFirstContextBean(); - context.setData(nodeId, StrUtil.format("{}_{}", context.getData(nodeId), "after")); + public void afterProcess(NodeComponent cmp) { + DefaultContext context = cmp.getFirstContextBean(); + context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java index e38846222..82a3464f9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java @@ -2,21 +2,22 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.aop.ICmpAroundAspect; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class CmpAspect implements ICmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getFirstContextBean(); - context.setData(nodeId, "before"); + public void beforeProcess(NodeComponent cmp) { + DefaultContext context = cmp.getFirstContextBean(); + context.setData(cmp.getNodeId(), "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getFirstContextBean(); - context.setData(nodeId, StrUtil.format("{}_{}", context.getData(nodeId), "after")); + public void afterProcess(NodeComponent cmp) { + DefaultContext context = cmp.getFirstContextBean(); + context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java index e38846222..82a3464f9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java @@ -2,21 +2,22 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.aop.ICmpAroundAspect; +import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class CmpAspect implements ICmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getFirstContextBean(); - context.setData(nodeId, "before"); + public void beforeProcess(NodeComponent cmp) { + DefaultContext context = cmp.getFirstContextBean(); + context.setData(cmp.getNodeId(), "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getFirstContextBean(); - context.setData(nodeId, StrUtil.format("{}_{}", context.getData(nodeId), "after")); + public void afterProcess(NodeComponent cmp) { + DefaultContext context = cmp.getFirstContextBean(); + context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); } } From 27febdedd7e990ace0501ddf5b4fb897f9d40ae4 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Tue, 11 Jul 2023 16:17:03 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BC=98=E5=8C=96LFLog=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9A=84=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yomahub/liteflow/core/FlowExecutor.java | 30 +++++++------- .../yomahub/liteflow/flow/element/Node.java | 9 +--- .../java/com/yomahub/liteflow/log/LFLog.java | 41 ++++++++++++++----- .../com/yomahub/liteflow/slot/DataBus.java | 4 +- 4 files changed, 50 insertions(+), 34 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java index 730f08b2b..fd0815ce2 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java @@ -343,13 +343,10 @@ public class FlowExecutor { else { slotIndex = DataBus.offerSlotByBean(ListUtil.toList(contextBeanArray)); } - if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) { - LOG.info("slot[{}] offered", slotIndex); - } - } - if (slotIndex == -1) { - throw new NoAvailableSlotException("there is no available slot"); + if (slotIndex == -1) { + throw new NoAvailableSlotException("there is no available slot"); + } } Slot slot = DataBus.getSlot(slotIndex); @@ -357,14 +354,6 @@ public class FlowExecutor { throw new NoAvailableSlotException(StrUtil.format("the slot[{}] is not exist", slotIndex)); } - // 如果是隐式流程,事先把subException给置空,然后把隐式流程的chainId放入slot元数据中 - // 我知道这在多线程调用隐式流程中会有问题。但是考虑到这种场景的不会多,也有其他的转换方式。 - // 所以暂且这么做,以后再优化 - if (!innerChainType.equals(InnerChainTypeEnum.NONE)) { - slot.removeSubException(chainId); - slot.addSubChain(chainId); - } - //如果传入了用户的RequestId,则用这个请求Id,如果没传入,则进行生成 if (StrUtil.isNotBlank(requestId)){ slot.putRequestId(requestId); @@ -375,6 +364,19 @@ public class FlowExecutor { LOG.info("requestId has generated"); } + if (innerChainType.equals(InnerChainTypeEnum.NONE)) { + LOG.info("slot[{}] offered", slotIndex); + } + + // 如果是隐式流程,事先把subException给置空,然后把隐式流程的chainId放入slot元数据中 + // 我知道这在多线程调用隐式流程中会有问题。但是考虑到这种场景的不会多,也有其他的转换方式。 + // 所以暂且这么做,以后再优化 + if (!innerChainType.equals(InnerChainTypeEnum.NONE)) { + slot.removeSubException(chainId); + slot.addSubChain(chainId); + } + + if (ObjectUtil.isNotNull(param)) { if (innerChainType.equals(InnerChainTypeEnum.NONE)) { slot.setRequestData(param); diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java index 63b1ed1ac..843d0f962 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java @@ -133,10 +133,7 @@ public class Node implements Executable, Cloneable{ // 判断是否可执行,所以isAccess经常作为一个组件进入的实际判断要素,用作检查slot里的参数的完备性 if (instance.isAccess()) { - // 根据配置判断是否打印执行中的日志 - if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) { - LOG.info("[O]start component[{}] execution", instance.getDisplayName()); - } + LOG.info("[O]start component[{}] execution", instance.getDisplayName()); // 这里开始进行重试的逻辑和主逻辑的运行 NodeExecutor nodeExecutor = NodeExecutorHelper.loadInstance() @@ -145,9 +142,7 @@ public class Node implements Executable, Cloneable{ nodeExecutor.execute(instance); } else { - if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) { - LOG.info("[X]skip component[{}] execution", instance.getDisplayName()); - } + LOG.info("[X]skip component[{}] execution", instance.getDisplayName()); } // 如果组件覆盖了isEnd方法,或者在在逻辑中主要调用了setEnd(true)的话,流程就会立马结束 if (instance.isEnd()) { diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/log/LFLog.java b/liteflow-core/src/main/java/com/yomahub/liteflow/log/LFLog.java index 760ee9240..83665f269 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/log/LFLog.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/log/LFLog.java @@ -342,27 +342,38 @@ public class LFLog implements Logger{ @Override public void error(String s) { - this.log.error(getRId() + s); + if (isPrint()) { + this.log.error(getRId() + s); + } } @Override public void error(String s, Object o) { - this.log.error(getRId() + s, o); + if (isPrint()) { + this.log.error(getRId() + s, o); + } } @Override public void error(String s, Object o, Object o1) { - this.log.error(getRId() + s, o, o1); + if (isPrint()) { + this.log.error(getRId() + s, o, o1); + } + } @Override public void error(String s, Object... objects) { - this.log.error(getRId() + s, objects); + if (isPrint()) { + this.log.error(getRId() + s, objects); + } } @Override public void error(String s, Throwable throwable) { - this.log.error(getRId() + s, throwable); + if (isPrint()) { + this.log.error(getRId() + s, throwable); + } } @Override @@ -372,26 +383,36 @@ public class LFLog implements Logger{ @Override public void error(Marker marker, String s) { - this.log.error(marker, getRId() + s); + if (isPrint()) { + this.log.error(marker, getRId() + s); + } } @Override public void error(Marker marker, String s, Object o) { - this.log.error(marker, getRId() + s, o); + if (isPrint()) { + this.log.error(marker, getRId() + s, o); + } } @Override public void error(Marker marker, String s, Object o, Object o1) { - this.log.error(marker, getRId() + s, o, o1); + if (isPrint()) { + this.log.error(marker, getRId() + s, o, o1); + } } @Override public void error(Marker marker, String s, Object... objects) { - this.log.error(marker, getRId() + s, objects); + if (isPrint()) { + this.log.error(marker, getRId() + s, objects); + } } @Override public void error(Marker marker, String s, Throwable throwable) { - this.log.error(marker, getRId() + s, throwable); + if (isPrint()) { + this.log.error(marker, getRId() + s, throwable); + } } } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java index a7214995e..00bc9e681 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java @@ -136,9 +136,7 @@ public class DataBus { public static void releaseSlot(int slotIndex) { LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); if (ObjectUtil.isNotNull(SLOTS.get(slotIndex))) { - if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) { - LOG.info("slot[{}] released", slotIndex); - } + LOG.info("slot[{}] released", slotIndex); SLOTS.remove(slotIndex); QUEUE.add(slotIndex); OCCUPY_COUNT.decrementAndGet(); From 628009622c679e5052e69b4efee67e901aca895d Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Tue, 11 Jul 2023 19:00:08 +0800 Subject: [PATCH 4/9] =?UTF-8?q?enhancement=20#I7JZ4D=20=E5=B8=8C=E6=9C=9B?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E6=9C=89=E4=B8=8E=E6=88=96=E9=9D=9E=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E7=9A=84=E7=9B=B8=E5=85=B3=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/flow/element/condition/AndOrCondition.java | 8 +++++--- .../liteflow/flow/element/condition/NotCondition.java | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/AndOrCondition.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/AndOrCondition.java index 61a65df54..3c70b6b83 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/AndOrCondition.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/AndOrCondition.java @@ -1,21 +1,22 @@ package com.yomahub.liteflow.flow.element.condition; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.enums.ConditionTypeEnum; import com.yomahub.liteflow.exception.AndOrConditionException; import com.yomahub.liteflow.flow.element.Condition; import com.yomahub.liteflow.flow.element.Executable; +import com.yomahub.liteflow.log.LFLog; +import com.yomahub.liteflow.log.LFLoggerManager; import com.yomahub.liteflow.slot.DataBus; import com.yomahub.liteflow.slot.Slot; import java.util.List; public class AndOrCondition extends Condition { + private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); + private BooleanConditionTypeEnum booleanConditionType; @Override @@ -34,6 +35,7 @@ public class AndOrCondition extends Condition { item.setCurrChainId(this.getCurrChainId()); item.execute(slotIndex); booleanArray[i] = item.getItemResultMetaValue(slotIndex); + LOG.info("the result of boolean component [{}] is [{}]", item.getId(), booleanArray[i]); } BooleanConditionTypeEnum booleanConditionType = this.getBooleanConditionType(); diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/NotCondition.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/NotCondition.java index a4b22614a..5e53f8434 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/NotCondition.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/NotCondition.java @@ -4,11 +4,15 @@ import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.enums.ConditionTypeEnum; import com.yomahub.liteflow.flow.element.Condition; import com.yomahub.liteflow.flow.element.Executable; +import com.yomahub.liteflow.log.LFLog; +import com.yomahub.liteflow.log.LFLoggerManager; import com.yomahub.liteflow.slot.DataBus; import com.yomahub.liteflow.slot.Slot; public class NotCondition extends Condition { + private final LFLog LOG = LFLoggerManager.getLogger(this.getClass()); + @Override public void executeCondition(Integer slotIndex) throws Exception { Executable item = this.getItem(); @@ -17,6 +21,8 @@ public class NotCondition extends Condition { item.execute(slotIndex); boolean flag = item.getItemResultMetaValue(slotIndex); + LOG.info("the result of boolean component [{}] is [{}]", item.getId(), flag); + Slot slot = DataBus.getSlot(slotIndex); String resultKey = StrUtil.format("{}_{}",this.getClass().getName(),this.hashCode()); From 269e1ec1455bf9b947973d5fec8b8c1d8f54381c Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Tue, 11 Jul 2023 23:35:49 +0800 Subject: [PATCH 5/9] =?UTF-8?q?bug=20#I7HTR4=20=E5=90=8C=E4=B8=80=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E5=90=8Ctag=EF=BC=8C=E5=8F=96step=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/flow/LiteflowResponse.java | 18 ++++++++++------ .../cmpStep/CmpStepELDeclSpringbootTest.java | 21 ++++++++----------- .../cmpStep/CmpStepELDeclSpringbootTest.java | 21 ++++++++----------- .../liteflow/test/cmpStep/CmpStepTest.java | 21 ++++++++----------- .../test/cmpStep/CmpStepELSpringbootTest.java | 21 ++++++++----------- .../test/cmpStep/CmpStepELSpringbootTest.java | 21 ++++++++----------- .../test/cmpStep/CmpStepELSpringTest.java | 21 ++++++++----------- 7 files changed, 66 insertions(+), 78 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java index cbef4b7ec..37a87e565 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java @@ -1,13 +1,13 @@ package com.yomahub.liteflow.flow; +import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.exception.LiteFlowException; import com.yomahub.liteflow.flow.entity.CmpStep; import com.yomahub.liteflow.slot.Slot; import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.Queue; +import java.util.*; +import java.util.function.Consumer; /** * 执行结果封装类 @@ -101,9 +101,15 @@ public class LiteflowResponse { return this.getSlot().getContextBean(contextBeanClazz); } - public Map getExecuteSteps() { - Map map = new HashMap<>(); - this.getSlot().getExecuteSteps().forEach(cmpStep -> map.put(cmpStep.getNodeId(), cmpStep)); + public Map> getExecuteSteps() { + Map> map = new LinkedHashMap<>(); + this.getSlot().getExecuteSteps().forEach(cmpStep -> { + if (map.containsKey(cmpStep.getNodeId())){ + map.get(cmpStep.getNodeId()).add(cmpStep); + }else{ + map.put(cmpStep.getNodeId(), ListUtil.toList(cmpStep)); + } + }); return map; } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java index 753261b22..6ffd2e57c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java @@ -14,10 +14,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -import java.util.HashSet; -import java.util.Map; -import java.util.Queue; -import java.util.Set; +import java.util.*; /** * springboot环境最普通的例子测试 @@ -39,13 +36,13 @@ public class CmpStepELDeclSpringbootTest extends BaseTest { public void testStep() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass()); + Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test @@ -59,7 +56,7 @@ public class CmpStepELDeclSpringbootTest extends BaseTest { public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); - Map stepMap = response.getExecuteSteps(); + Map> stepMap = response.getExecuteSteps(); Assert.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); Assert.assertEquals(5, queue.size()); diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java index 753261b22..6ffd2e57c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java @@ -14,10 +14,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -import java.util.HashSet; -import java.util.Map; -import java.util.Queue; -import java.util.Set; +import java.util.*; /** * springboot环境最普通的例子测试 @@ -39,13 +36,13 @@ public class CmpStepELDeclSpringbootTest extends BaseTest { public void testStep() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass()); + Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test @@ -59,7 +56,7 @@ public class CmpStepELDeclSpringbootTest extends BaseTest { public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); - Map stepMap = response.getExecuteSteps(); + Map> stepMap = response.getExecuteSteps(); Assert.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); Assert.assertEquals(5, queue.size()); diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java index 07e65f864..de3306efc 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java @@ -10,10 +10,7 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import java.util.HashSet; -import java.util.Map; -import java.util.Queue; -import java.util.Set; +import java.util.*; public class CmpStepTest extends BaseTest { @@ -30,13 +27,13 @@ public class CmpStepTest extends BaseTest { public void testStep1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass()); + Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test @@ -50,7 +47,7 @@ public class CmpStepTest extends BaseTest { public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); - Map stepMap = response.getExecuteSteps(); + Map> stepMap = response.getExecuteSteps(); Assert.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); Assert.assertEquals(5, queue.size()); diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java index c1b0d6d84..531a19dae 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java @@ -11,10 +11,7 @@ import org.noear.solon.annotation.Inject; import org.noear.solon.test.SolonJUnit4ClassRunner; import org.noear.solon.test.annotation.TestPropertySource; -import java.util.HashSet; -import java.util.Map; -import java.util.Queue; -import java.util.Set; +import java.util.*; /** * springboot环境step的测试例子 @@ -35,13 +32,13 @@ public class CmpStepELSpringbootTest extends BaseTest { public void testStep1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass()); + Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test @@ -55,7 +52,7 @@ public class CmpStepELSpringbootTest extends BaseTest { public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); - Map stepMap = response.getExecuteSteps(); + Map> stepMap = response.getExecuteSteps(); Assert.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); Assert.assertEquals(5, queue.size()); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java index ed9084d40..0157e3b9c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java @@ -14,10 +14,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -import java.util.HashSet; -import java.util.Map; -import java.util.Queue; -import java.util.Set; +import java.util.*; import java.util.function.Consumer; import java.util.function.Predicate; @@ -43,13 +40,13 @@ public class CmpStepELSpringbootTest extends BaseTest { public void testStep1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass()); + Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test @@ -63,7 +60,7 @@ public class CmpStepELSpringbootTest extends BaseTest { public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); - Map stepMap = response.getExecuteSteps(); + Map> stepMap = response.getExecuteSteps(); Assert.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); Assert.assertEquals(5, queue.size()); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringTest.java index 5a5536e0b..789f8b2b3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringTest.java @@ -11,10 +11,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -import java.util.HashSet; -import java.util.Map; -import java.util.Queue; -import java.util.Set; +import java.util.*; @RunWith(SpringRunner.class) @ContextConfiguration("classpath:/cmpStep/application.xml") @@ -27,13 +24,13 @@ public class CmpStepELSpringTest extends BaseTest { public void testStep1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").getException().getClass()); + Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test @@ -47,7 +44,7 @@ public class CmpStepELSpringTest extends BaseTest { public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); - Map stepMap = response.getExecuteSteps(); + Map> stepMap = response.getExecuteSteps(); Assert.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); Assert.assertEquals(5, queue.size()); From fb87a1b06a1d1555ec98655382105676559595f2 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Wed, 12 Jul 2023 23:51:36 +0800 Subject: [PATCH 6/9] =?UTF-8?q?enhancement=20#I7KR2F=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E5=85=A8=E9=9D=A2=E6=9B=B4=E6=96=B0=E4=B8=BA?= =?UTF-8?q?junit5=20enhancement=20#I7J59V=20java17=E4=B8=8B=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=AE=8C=E6=95=B4=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/LiteFlowExecutorPoolShutdown.java | 2 - .../liteflow-script-javascript/pom.xml | 4 ++ .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../apollo/ApolloWithXmlELSpringbootTest.java | 31 ++++----- .../com/yomahub/liteflow/test/BaseTest.java | 6 +- ...teConfigPathELDeclMultiSpringbootTest.java | 11 ++-- .../GlobalAOPELDeclMultiSpringbootTest.java | 48 +++++++------- .../AsyncNodeELDeclMultiSpringbootTest.java | 47 +++++++------- .../base/BaseELDeclMultiSpringbootTest.java | 11 ++-- .../BuilderELDeclMultiSpringbootTest1.java | 21 +++--- .../BuilderELDeclMultiSpringbootTest2.java | 13 ++-- ...iteflowRetryELDeclMultiSpringbootTest.java | 23 +++---- .../cmpStep/CmpStepELDeclSpringbootTest.java | 37 +++++------ ...LiteflowNodeELDeclMultiSpringbootTest.java | 13 ++-- .../ComplexELDeclMultiSpringbootTest1.java | 13 ++-- .../ComplexELDeclMultiSpringbootTest2.java | 13 ++-- ...FlowExecutorELDeclMultiSpringbootTest.java | 44 +++++++------ ...omMethodNameELDeclMultiSpringbootTest.java | 11 ++-- .../CustomNodesELDeclMultiSpringbootTest.java | 13 ++-- ...enThreadPoolELDeclMultiSpringbootTest.java | 21 +++--- .../event/EventELDeclMultiSpringbootTest.java | 29 +++++---- .../Exception1ELDeclMultiSpringBootTest.java | 49 ++++++++------ .../Exception2ELDeclMultiSpringBootTest.java | 48 +++++++------- ...cutor2FutureELDeclMultiSpringbootTest.java | 11 ++-- .../CmpExtendELDeclMultiSpringbootTest.java | 11 ++-- ...GetChainNameELDeclMultiSpringbootTest.java | 41 ++++++------ .../IfElseELDeclMultiSpringbootTest.java | 37 +++++------ .../IteratorELDeclMultiSpringbootTest.java | 17 ++--- .../lazy/LazyELDeclMultiSpringbootTest.java | 4 +- ...lowComponentELDeclMultiSpringbootTest.java | 13 ++-- .../loop/LoopELDeclMultiSpringbootTest.java | 43 +++++++------ .../MixDefineELDeclMultiSpringbootTest.java | 11 ++-- .../MonitorELDeclMultiSpringbootTest.java | 17 +++-- .../MonitorFileELDeclMultiSpringbootTest.java | 11 ++-- ...MultiContextELDeclMultiSpringbootTest.java | 30 +++++---- ...MultipleTypeELDeclMultiSpringbootTest.java | 17 ++--- ...NodeExecutorELDeclMultiSpringbootTest.java | 31 ++++----- ...omParserJsonELDeclMultiSpringbootTest.java | 11 ++-- ...tomParserXmlELDeclMultiSpringbootTest.java | 11 ++-- .../JsonParserELDeclMultiSpringbootTest.java | 11 ++-- ...ingELSupportELDeclMultiSpringbootTest.java | 11 ++-- .../XmlParserELDeclMultiSpringbootTest.java | 11 ++-- .../YmlParserELDeclMultiSpringbootTest.java | 11 ++-- ...reAndFinallyELDeclMultiSpringbootTest.java | 29 +++++---- ...vateDeliveryELDeclMultiSpringbootTest.java | 13 ++-- .../RefreshRuleELDeclMultiSpringbootTest.java | 13 ++-- .../ReloadELDeclMultiSpringbootTest.java | 11 ++-- ...lowRequestIdELDeclMultiSpringbootTest.java | 13 ++-- ...licitSubFlowELDeclMultiSpringbootTest.java | 23 +++---- ...ferentConfigELDeclMultiSpringbootTest.java | 23 ++++--- .../SubflowJsonELDeclMultiSpringBootTest.java | 13 ++-- .../SubflowXMLELDeclMultiSpringBootTest.java | 13 ++-- .../SubflowYmlELDeclMultiSpringBootTest.java | 13 ++-- .../SwitchELDeclMultiSpringbootTest.java | 29 +++++---- .../NodeTagELDeclMultiSpringbootJsonTest.java | 25 ++++---- .../NodeTagELDeclMultiSpringbootXmlTest.java | 25 ++++---- ...UseTTLInWhenELDeclMultiSpringbootTest.java | 19 +++--- ...WhenTimeOutELDeclMultiSpringbootTest1.java | 13 ++-- ...WhenTimeOutELDeclMultiSpringbootTest2.java | 11 ++-- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- ...bsoluteConfigPathELDeclSpringbootTest.java | 11 ++-- .../aop/CustomAOPELDeclSpringbootTest.java | 14 ++-- .../aop/GlobalAOPELDeclSpringbootTest.java | 47 +++++++------- .../AsyncNodeELDeclSpringbootTest.java | 47 +++++++------- .../test/base/BaseELDeclSpringbootTest.java | 11 ++-- .../builder/BuilderELDeclSpringbootTest1.java | 17 ++--- .../builder/BuilderELDeclSpringbootTest2.java | 13 ++-- .../LiteflowRetryELDeclSpringbootTest.java | 23 +++---- .../cmpStep/CmpStepELDeclSpringbootTest.java | 37 +++++------ .../LiteflowNodeELSpringbootTest.java | 13 ++-- .../complex/ComplexELDeclSpringbootTest1.java | 13 ++-- .../complex/ComplexELDeclSpringbootTest2.java | 13 ++-- .../FlowExecutorELDeclSpringbootTest.java | 42 ++++++------ .../CustomMethodNameELDeclSpringbootTest.java | 11 ++-- .../CustomNodesELDeclSpringbootTest.java | 13 ++-- ...tomWhenThreadPoolELDeclSpringbootTest.java | 21 +++--- .../test/event/EventELDeclSpringbootTest.java | 29 +++++---- .../Exception1ELDeclSpringBootTest.java | 47 ++++++++------ .../Exception2ELDeclSpringBootTest.java | 52 ++++++++------- .../Executor2FutureELDeclSpringbootTest.java | 11 ++-- .../extend/CmpExtendELDeclSpringbootTest.java | 11 ++-- .../GetChainNameELDeclSpringbootTest.java | 41 ++++++------ .../ifelse/IfElseELDeclSpringbootTest.java | 37 +++++------ .../IteratorELDeclSpringbootTest.java | 17 ++--- .../test/lazy/LazyELDeclSpringbootTest.java | 11 ++-- ...LiteflowComponentELDeclSpringbootTest.java | 13 ++-- .../test/loop/LoopELDeclSpringbootTest.java | 43 +++++++------ .../monitor/MonitorELDeclSpringbootTest.java | 16 +++-- .../MonitorFileELDeclSpringbootTest.java | 11 ++-- .../MultiContextELDeclSpringbootTest.java | 29 +++++---- ...eflowMultipleTypeELDeclSpringbootTest.java | 17 ++--- ...eflowNodeExecutorELDeclSpringbootTest.java | 31 ++++----- .../CustomParserJsonELDeclSpringbootTest.java | 11 ++-- .../CustomParserXmlELDeclSpringbootTest.java | 11 ++-- .../JsonParserELDeclSpringbootTest.java | 11 ++-- .../SpringELSupportELDeclSpringbootTest.java | 11 ++-- .../parser/XmlParserELDeclSpringbootTest.java | 11 ++-- .../parser/YmlParserELDeclSpringbootTest.java | 11 ++-- .../PreAndFinallyELDeclSpringbootTest.java | 29 +++++---- .../PrivateDeliveryELDeclSpringbootTest.java | 13 ++-- .../RefreshRuleELDeclSpringbootTest.java | 13 ++-- .../reload/ReloadELDeclSpringbootTest.java | 11 ++-- ...LiteflowRequestIdELDeclSpringbootTest.java | 13 ++-- .../ImplicitSubFlowELDeclSpringbootTest.java | 23 +++---- ...InDifferentConfigELDeclSpringbootTest.java | 23 ++++--- .../SubflowJsonELDeclSpringBootTest.java | 13 ++-- .../SubflowXMLELDeclSpringBootTest.java | 13 ++-- .../SubflowYmlELDeclSpringBootTest.java | 13 ++-- .../SuperClassDefineELDeclSpringbootTest.java | 15 +++-- .../SwitchELDeclSpringbootTest.java | 29 +++++---- .../tag/NodeTagELDeclSpringbootJsonTest.java | 25 ++++---- .../tag/NodeTagELDeclSpringbootXmlTest.java | 25 ++++---- .../UseTTLInWhenELDeclSpringbootTest.java | 19 +++--- .../WhenTimeOutELDeclSpringbootTest1.java | 13 ++-- .../WhenTimeOutELDeclSpringbootTest2.java | 11 ++-- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../etcd/EtcdWithXmlELSpringbootTest.java | 31 +++++---- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../nacos/NacosWithXmlELSpringbootTest.java | 25 +++----- .../liteflow-testcase-el-nospring/pom.xml | 5 +- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../AbsoluteConfigPathTest.java | 10 +-- .../test/asyncNode/AsyncNodeTest.java | 46 ++++++------- .../liteflow/test/base/BaseCommonTest.java | 10 +-- .../liteflow/test/builder/BuilderTest.java | 20 +++--- .../test/cmpRetry/LiteflowRetryTest.java | 22 +++---- .../liteflow/test/cmpStep/CmpStepTest.java | 36 +++++------ .../test/comments/LiteflowNodeTest.java | 12 ++-- .../test/component/FlowExecutorTest.java | 42 ++++++------ .../test/config/LiteflowConfigTest1.java | 30 ++++----- .../CustomWhenThreadPoolTest.java | 20 +++--- .../liteflow/test/event/EventTest.java | 28 ++++---- .../test/exception/Exception1Test.java | 36 ++++++----- .../test/exception/Exception2Test.java | 64 +++++++++++-------- .../execute2Future/Executor2FutureTest.java | 10 +-- .../liteflow/test/flowmeta/FlowMetaTest.java | 12 ++-- .../test/getChainName/GetChainNameELTest.java | 40 ++++++------ .../liteflow/test/ifelse/IfElseTest.java | 36 +++++------ .../liteflow/test/iterator/IteratorTest.java | 16 ++--- .../yomahub/liteflow/test/loop/LoopTest.java | 42 ++++++------ .../monitorFile/LiteflowMonitorFileTest.java | 10 +-- .../LiteflowMultipleTypeTest.java | 16 ++--- .../LiteflowNodeExecutorTest.java | 30 ++++----- .../test/nullParam/NullParamTest.java | 13 ++-- .../parsecustom/CustomParserJsonTest.java | 10 +-- .../test/parsecustom/CustomParserXmlTest.java | 10 +-- .../liteflow/test/parser/JsonParserTest.java | 10 +-- .../liteflow/test/parser/XmlParserTest.java | 10 +-- .../liteflow/test/parser/YmlParserTest.java | 10 +-- .../test/preAndFinally/PreAndFinallyTest.java | 28 ++++---- .../privateDelivery/PrivateDeliveryTest.java | 12 ++-- .../test/refreshRule/RefreshRuleTest.java | 12 ++-- .../liteflow/test/reload/ReloadTest.java | 10 +-- .../test/removeChain/RemoveChainTest.java | 12 ++-- .../LiteflowRequestIdSpringbootTest.java | 12 ++-- .../test/resizeSlot/ResizeSlotTest.java | 12 ++-- .../test/subflow/ImplicitSubFlowTest.java | 22 +++---- .../subflow/SubflowInDifferentConfigTest.java | 22 ++++--- .../test/subflow/SubflowJsonTest.java | 12 ++-- .../liteflow/test/subflow/SubflowXMLTest.java | 12 ++-- .../liteflow/test/subflow/SubflowYmlTest.java | 12 ++-- .../liteflow/test/switchcase/SwitchTest.java | 28 ++++---- .../liteflow/test/tag/NodeTagJsonTest.java | 24 +++---- .../liteflow/test/tag/NodeTagXmlTest.java | 24 +++---- .../test/useTTLInWhen/UseTTLInWhenTest.java | 18 +++--- .../test/whenTimeOut/WhenTimeOutTest1.java | 12 ++-- .../test/whenTimeOut/WhenTimeOutTest2.java | 10 +-- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../common/ScriptAviatorCommonELTest.java | 15 ++--- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../common/LiteflowXmlScriptCommonELTest.java | 13 ++-- .../LiteFlowScriptContextbeanGraaljsTest.java | 19 +++--- .../LiteFlowXmlScriptIfelseJsELTest.java | 37 +++++------ .../loop/LiteFlowXmlScriptLoopJsELTest.java | 27 ++++---- .../meta/LiteflowXmlScriptMetaELTest.java | 17 ++--- .../LiteflowXmlScriptJsRefreshELTest.java | 17 ++--- .../LiteFlowScriptScriptbeanJsELTest.java | 17 ++--- .../LiteFlowScriptScripMethodJsELTest.java | 17 ++--- .../sw/LiteflowXmlScriptJsSwitchELTest.java | 13 ++-- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../groovy/cmpdata/CmpDataGroovyELTest.java | 13 ++-- .../LiteFlowXmlScriptBuilderGroovyELTest.java | 23 +++---- .../LiteflowJsonScriptFileGroovyELTest.java | 27 ++++---- .../LiteflowJsonScriptGroovyELTest.java | 25 ++++---- .../LiteflowXmlScriptFileGroovyELTest.java | 27 ++++---- .../common/LiteflowXmlScriptGroovyELTest.java | 29 +++++---- ...LiteFlowScriptContextbeanGroovyELTest.java | 19 +++--- .../LiteFlowXmlScriptIfelseGroovyELTest.java | 37 +++++------ .../LiteFlowXmlScriptLoopGroovyELTest.java | 33 +++++----- .../LiteflowScriptOrderGroovyELTest.java | 11 ++-- .../LiteFlowScriptScriptbeanGroovyELTest.java | 37 +++++------ ...iteFlowScriptScriptMethodGroovyELTest.java | 17 ++--- .../ThrowExceptionScriptGroovyELTest.java | 13 ++-- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../LiteflowXmlScriptJsCommonELTest.java | 13 ++-- ...teFlowScriptContextbeanJavaScriptTest.java | 19 +++--- .../LiteFlowXmlScriptIfelseJsELTest.java | 37 +++++------ .../loop/LiteFlowXmlScriptLoopJsELTest.java | 27 ++++---- .../LiteflowXmlScriptJsRefreshELTest.java | 17 ++--- .../LiteFlowScriptScriptbeanJsELTest.java | 17 ++--- .../LiteFlowScriptScriptMethodJsELTest.java | 17 ++--- .../sw/LiteflowXmlScriptJsSwitchELTest.java | 13 ++-- .../ThrowExceptionScriptJsCommonELTest.java | 11 ++-- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../lua/common/ScriptLuaCommonELTest.java | 13 ++-- .../LiteFlowScriptContextbeanLuaTest.java | 19 +++--- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../multi/language/MultiLanguageELTest.java | 20 +++--- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../common/ScriptPythonCommonELTest.java | 15 +++-- .../LiteFlowScriptContextbeanPythonTest.java | 19 +++--- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- ...teFlowXmlScriptBuilderQLExpressELTest.java | 17 ++--- ...iteFlowXmlScriptIfelseQLExpressELTest.java | 37 +++++------ ...LiteflowJsonScriptFileQLExpressELTest.java | 27 ++++---- .../LiteflowJsonScriptQLExpressELTest.java | 25 ++++---- .../LiteflowXmlScriptFileQLExpressELTest.java | 27 ++++---- .../LiteflowXmlScriptQLExpressELTest.java | 25 ++++---- ...iteFlowScriptContextbeanQLExpressTest.java | 19 +++--- .../LiteFlowXmlScriptLoopQLExpressELTest.java | 27 ++++---- ...teFlowScriptScriptbeanQLExpressELTest.java | 17 ++--- ...FlowScriptScriptMethodQLExpressELTest.java | 17 ++--- .../liteflow-testcase-el-solon/pom.xml | 2 +- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../AbsoluteConfigPathELSpringbootTest.java | 12 ++-- .../asyncNode/AsyncNodeELSpringbootTest.java | 48 +++++++------- .../test/base/BaseELSpringbootTest.java | 20 +++--- .../builder/BuilderELSpringbootTest1.java | 22 +++---- .../builder/BuilderELSpringbootTest2.java | 14 ++-- .../test/cmpData/CmpDataELSpringbootTest.java | 18 +++--- .../LiteflowRetryELSpringbootTest.java | 25 ++++---- .../test/cmpStep/CmpStepELSpringbootTest.java | 38 +++++------ .../LiteflowNodeELSpringbootTest.java | 14 ++-- .../complex/ComplexELSpringbootTest1.java | 14 ++-- .../complex2/ComplexELSpringbootTest2.java | 14 ++-- .../FlowExecutorELSpringbootTest.java | 32 +++++----- .../CustomNodesELSpringbootTest.java | 14 ++-- .../CustomWhenThreadPoolELSpringbootTest.java | 22 +++---- .../test/event/EventELSpringbootTest.java | 30 ++++----- .../exception/Exception1ELSpringBootTest.java | 49 ++++++++------ .../exception/Exception2ELSpringBootTest.java | 52 ++++++++------- .../Executor2FutureELSpringbootTest.java | 12 ++-- .../GetChainNameELSpringbootTest.java | 42 ++++++------ .../test/ifelse/IfELSpringbootTest.java | 38 +++++------ .../LiteflowComponentELSpringbootTest.java | 14 ++-- .../test/loop/LoopELSpringbootTest.java | 44 ++++++------- .../test/monitor/MonitorELSpringbootTest.java | 17 ++--- .../MonitorFileSpringbootTest.java | 12 ++-- .../MultiContextELSpringbootTest.java | 36 ++++++----- .../LiteflowMultipleTypeELSpringbootTest.java | 18 +++--- .../LiteflowNodeExecutorELSpringbootTest.java | 32 +++++----- .../nullParam/NullParamELSpringbootTest.java | 12 ++-- .../CustomParserJsonELSpringbootTest.java | 12 ++-- .../CustomParserXmlELSpringbootTest.java | 12 ++-- .../CustomParserYmlELSpringbootTest.java | 12 ++-- .../parser/JsonParserELSpringbootTest.java | 12 ++-- .../SpringELSupportELSpringbootTest.java | 12 ++-- .../parser/XmlParserELSpringbootTest.java | 12 ++-- .../parser/YmlParserELSpringbootTest.java | 12 ++-- .../PreAndFinallyELSpringbootTest.java | 36 +++++------ .../PrivateDeliveryELSpringbootTest.java | 14 ++-- .../RefreshRuleELSpringbootTest.java | 14 ++-- .../test/reload/ReloadELSpringbootTest.java | 12 ++-- .../RemoveChainELSpringbootTest.java | 14 ++-- .../LiteflowRequestIdELSpringbootTest.java | 14 ++-- .../ImplicitSubFlowELSpringbootTest.java | 26 ++++---- ...flowInDifferentConfigELSpringbootTest.java | 24 +++---- .../subflow/SubflowXMLELSpringBootTest.java | 14 ++-- .../subflow/SubflowYmlELSpringBootTest.java | 14 ++-- .../subflow2/SubflowJsonELSpringBootTest.java | 14 ++-- .../SubstituteSpringbootTest.java | 16 ++--- .../switchcase/SwitchELSpringbootTest.java | 38 +++++------ .../test/tag/NodeTagELSpringbootJsonTest.java | 26 ++++---- .../test/tag/NodeTagELSpringbootXmlTest.java | 30 ++++----- .../UseTTLInWhenELSpringbootTest.java | 20 +++--- .../ValidateRuleELSpringbootTest.java | 14 ++-- .../WhenTimeOutELSpringbootTest1.java | 14 ++-- .../WhenTimeOutELSpringbootTest2.java | 12 ++-- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../AbsoluteConfigPathELSpringbootTest.java | 9 +-- .../test/aop/CustomAOPELSpringbootTest.java | 23 +++---- .../test/aop/GlobalAOPELSpringbootTest.java | 45 ++++++------- .../asyncNode/AsyncNodeELSpringbootTest.java | 47 +++++++------- .../test/base/BaseELSpringbootTest.java | 17 ++--- .../BooleanOptELSpringbootTest.java | 27 ++++---- .../builder/BuilderELSpringbootTest1.java | 19 +++--- .../builder/BuilderELSpringbootTest2.java | 11 ++-- .../test/catchcase/CatchELSpringbootTest.java | 29 ++++----- .../test/cmpData/CmpDataELSpringbootTest.java | 25 +++----- .../LiteflowRetryELSpringbootTest.java | 21 +++--- .../test/cmpStep/CmpStepELSpringbootTest.java | 38 +++++------ .../LiteflowNodeELSpringbootTest.java | 13 ++-- .../complex/ComplexELSpringbootTest1.java | 11 ++-- .../complex/ComplexELSpringbootTest2.java | 11 ++-- .../FlowExecutorELSpringbootTest.java | 43 ++++++------- .../CustomNodesELSpringbootTest.java | 11 ++-- .../CustomWhenThreadPoolELSpringbootTest.java | 19 +++--- .../test/event/EventELSpringbootTest.java | 27 ++++---- .../exception/Exception1ELSpringBootTest.java | 51 ++++++++------- .../exception/Exception2ELSpringBootTest.java | 54 ++++++++-------- .../Executor2FutureELSpringbootTest.java | 9 +-- .../GetChainNameELSpringbootTest.java | 40 ++++++------ .../test/ifelse/IfELSpringbootTest.java | 39 ++++++----- .../iterator/IteratorELSpringbootTest.java | 18 ++---- .../test/lazy/LazyELSpringbootTest.java | 3 - .../LiteflowComponentELSpringbootTest.java | 11 ++-- .../test/loop/LoopELSpringbootTest.java | 51 +++++++-------- .../test/monitor/MonitorELSpringbootTest.java | 13 ++-- .../MonitorFileELSpringbootTest.java | 8 +-- .../MultiContextELSpringbootTest.java | 33 +++++----- .../LiteflowMultipleTypeELSpringbootTest.java | 15 ++--- .../LiteflowNodeExecutorELSpringbootTest.java | 29 ++++----- .../nullParam/NullParamELSpringbootTest.java | 9 +-- .../CustomParserJsonELSpringbootTest.java | 9 +-- .../CustomParserXmlELSpringbootTest.java | 10 +-- .../CustomParserYmlELSpringbootTest.java | 9 +-- .../parser/JsonParserELSpringbootTest.java | 9 +-- .../SpringELSupportELSpringbootTest.java | 9 +-- .../parser/XmlParserELSpringbootTest.java | 9 +-- .../parser/YmlParserELSpringbootTest.java | 9 +-- .../PreAndFinallyELSpringbootTest.java | 33 +++++----- .../PrivateDeliveryELSpringbootTest.java | 10 ++- .../RefreshRuleELSpringbootTest.java | 12 ++-- .../test/reload/ReloadELSpringbootTest.java | 9 +-- .../RemoveChainELSpringbootTest.java | 11 ++-- .../LiteflowRequestIdELSpringbootTest.java | 15 ++--- .../slotOffer/SlotOfferELSpringbootTest.java | 21 ++---- .../ImplicitSubFlowELSpringbootTest.java | 24 +++---- ...flowInDifferentConfigELSpringbootTest.java | 22 +++---- .../subflow/SubflowJsonELSpringBootTest.java | 12 ++-- .../subflow/SubflowXMLELSpringBootTest.java | 11 ++-- .../subflow/SubflowYmlELSpringBootTest.java | 12 ++-- .../SubstituteSpringbootTest.java | 13 ++-- .../switchcase/SwitchELSpringbootTest.java | 49 +++++++------- .../test/tag/NodeTagELSpringbootJsonTest.java | 23 +++---- .../test/tag/NodeTagELSpringbootXmlTest.java | 27 ++++---- .../url/LiteflowNodeELSpringbootTest.java | 13 ++-- .../UseTTLInWhenELSpringbootTest.java | 17 ++--- .../ValidateRuleELSpringbootTest.java | 20 ++---- .../WhenTimeOutELSpringbootTest1.java | 11 ++-- .../WhenTimeOutELSpringbootTest2.java | 9 +-- .../liteflow-testcase-el-springnative/pom.xml | 8 ++- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../AbsoluteConfigPathELSpringTest.java | 12 ++-- .../test/aop/CustomAOPELSpringTest.java | 26 ++++---- .../test/aop/GlobalAOPELSpringTest.java | 48 +++++++------- .../test/asyncNode/AsyncNodeELSpringTest.java | 49 +++++++------- .../test/base/BaseCommonELSpringTest.java | 14 ++-- .../test/builder/BuilderELSpringTest1.java | 17 ++--- .../test/builder/BuilderELSpringTest2.java | 14 ++-- .../cmpRetry/LiteflowRetryELSpringTest.java | 23 +++---- .../test/cmpStep/CmpStepELSpringTest.java | 38 +++++------ .../LiteflowNodeELSpringbootTest.java | 13 ++-- .../test/component/ComponentELSpringTest.java | 44 +++++++------ .../config/LiteflowConfigELSpringTest.java | 31 +++++---- ...calRuleSourcePatternMatchELSpringTest.java | 15 ++--- .../customNodes/CustomNodesELSpringTest.java | 15 ++--- .../CustomWhenThreadPoolELSpringTest.java | 22 +++---- .../enable/LiteflowEnableELSpringTest.java | 15 ++--- .../test/event/EventELSpringTest.java | 31 +++++---- .../exception/Exception1ELSpringTest.java | 49 ++++++++------ .../exception/Exception2ELSpringTest.java | 49 +++++++------- .../Executor2FutureELSpringTest.java | 13 ++-- .../test/flowmeta/FlowMetaELSpringTest.java | 13 ++-- .../GetChainNameELSpringTest.java | 43 ++++++------- .../test/ifelse/IfElseELSpringTest.java | 37 +++++------ .../test/iterator/IteratorELSpringTest.java | 17 ++--- .../LiteflowComponentELSpringTest.java | 15 ++--- .../liteflow/test/loop/LoopELSpringTest.java | 43 +++++++------ .../test/monitor/MonitorELSpringTest.java | 17 +++-- .../LiteflowMultipleTypeELSpringTest.java | 19 +++--- .../LiteflowNodeExecutorELSpringTest.java | 33 +++++----- .../test/nullParam/NullParamTest.java | 14 ++-- .../CustomParserJsonELSpringTest.java | 13 ++-- .../test/parser/LFParserJsonELSpringTest.java | 13 ++-- .../test/parser/LFParserJsonNoSpringTest.java | 6 +- .../test/parser/LFParserXmlELSpringTest.java | 14 ++-- .../test/parser/LFParserXmlNoSpringTest.java | 6 +- .../test/parser/LFParserYmlELSpringTest.java | 14 ++-- .../test/parser/LFParserYmlNoSpringTest.java | 6 +- .../PreAndFinallyELSpringTest.java | 30 ++++----- .../PrivateDeliveryELSpringTest.java | 16 ++--- .../refreshRule/RefreshRuleELSpringTest.java | 15 ++--- .../test/reload/ReloadELSpringTest.java | 13 ++-- .../removeChain/RemoveChainELSpringTest.java | 16 ++--- .../LiteflowRequestIdELSpringTest.java | 14 ++-- .../resizeSlot/ResizeSlotELSpringTest.java | 15 ++--- .../subflow/ImplicitSubFlowELSpringTest.java | 25 ++++---- .../SubflowInDifferentConfigELSpringTest.java | 24 +++---- .../test/subflow/SubflowJsonELSpringTest.java | 15 ++--- .../test/subflow/SubflowXMLELSpringTest.java | 15 ++--- .../test/subflow/SubflowYmlELSpringTest.java | 15 ++--- .../test/switchcase/SwitchELSpringTest.java | 30 ++++----- .../test/tag/NodeTagELSpringJsonTest.java | 26 ++++---- .../test/tag/NodeTagELSpringXmlTest.java | 26 ++++---- .../UseTTLInWhenELSpringTest.java | 21 +++--- .../whenTimeOut/WhenTimeOutELSpringTest1.java | 14 ++-- .../whenTimeOut/WhenTimeOutELSpringTest2.java | 13 ++-- .../pom.xml | 2 +- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- ...LWithXmlELMultiLanguageSpringbootTest.java | 14 ++-- .../test/sql/SQLWithXmlELSpringbootTest.java | 21 +++--- .../com/yomahub/liteflow/test/BaseTest.java | 4 +- .../ZkClusterWithXmlELSpringbootTest.java | 25 ++++---- .../ZkNodeWithXmlELSpringbootTest.java | 30 ++++----- pom.xml | 28 ++++++-- 406 files changed, 4073 insertions(+), 4052 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/util/LiteFlowExecutorPoolShutdown.java b/liteflow-core/src/main/java/com/yomahub/liteflow/util/LiteFlowExecutorPoolShutdown.java index ce72a17f5..34d048be6 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/util/LiteFlowExecutorPoolShutdown.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/util/LiteFlowExecutorPoolShutdown.java @@ -5,7 +5,6 @@ import com.yomahub.liteflow.log.LFLoggerManager; import com.yomahub.liteflow.spi.holder.ContextAwareHolder; import com.yomahub.liteflow.thread.ExecutorHelper; -import javax.annotation.PreDestroy; import java.util.concurrent.ExecutorService; /** @@ -17,7 +16,6 @@ public class LiteFlowExecutorPoolShutdown { private static final LFLog LOG = LFLoggerManager.getLogger(LiteFlowExecutorPoolShutdown.class); - @PreDestroy public void destroy() throws Exception { ExecutorService executorService = ContextAwareHolder.loadContextAware().getBean("whenExecutors"); diff --git a/liteflow-script-plugin/liteflow-script-javascript/pom.xml b/liteflow-script-plugin/liteflow-script-javascript/pom.xml index 2796eeefc..1df6fc7fc 100644 --- a/liteflow-script-plugin/liteflow-script-javascript/pom.xml +++ b/liteflow-script-plugin/liteflow-script-javascript/pom.xml @@ -19,5 +19,9 @@ ${revision} provided + + org.openjdk.nashorn + nashorn-core + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 785bc391b..c83a47308 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,7 +6,7 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; /** * @Description: @@ -15,7 +15,7 @@ import org.junit.AfterClass; */ public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/ApolloWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/ApolloWithXmlELSpringbootTest.java index 8837f3ac1..d41153647 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/ApolloWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/ApolloWithXmlELSpringbootTest.java @@ -1,27 +1,25 @@ package com.yomahub.liteflow.test.apollo; -import cn.hutool.core.util.StrUtil; import com.ctrip.framework.apollo.Config; -import com.ctrip.framework.apollo.ConfigService; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.MockitoAnnotations; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.event.annotation.AfterTestClass; +import org.springframework.test.context.event.annotation.BeforeTestClass; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; -import java.util.List; import java.util.Set; import static org.mockito.Mockito.*; @@ -31,7 +29,7 @@ import static org.mockito.Mockito.*; * @Author: zhanghua * @Date: 2022/12/3 15:22 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/apollo/application-xml.properties") @SpringBootTest(classes = ApolloWithXmlELSpringbootTest.class) @EnableAutoConfiguration @@ -47,16 +45,10 @@ public class ApolloWithXmlELSpringbootTest { @Resource private FlowExecutor flowExecutor; - @Before + @BeforeEach public void setUp() { MockitoAnnotations.initMocks(this); } - - @After - public void after() { - FlowBus.cleanCache(); - } - @Test public void testApolloWithXml1() { Set chainNameList = Sets.newHashSet("chain1"); @@ -70,7 +62,6 @@ public class ApolloWithXmlELSpringbootTest { when(scriptConfig.getProperty(anyString(), anyString())).thenReturn(scriptNodeValue); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>b==>c==>s1[脚本s1]", response.getExecuteStepStrWithoutTime()); + Assertions.assertEquals("a==>b==>c==>s1[脚本s1]", response.getExecuteStepStrWithoutTime()); } - } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..f7e94e50d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,13 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.springframework.test.context.event.annotation.AfterTestClass; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclMultiSpringbootTest.java index 241105e09..293b56d83 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties") @SpringBootTest(classes = AbsoluteConfigPathELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -37,7 +38,7 @@ public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest { @Test public void testAbsoluteConfig() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELDeclMultiSpringbootTest.java index 7e6c56d4f..781088820 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELDeclMultiSpringbootTest.java @@ -6,10 +6,12 @@ import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.aop.aspect.CmpAspect; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.event.annotation.AfterTestClass; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +26,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/aop/application.properties") @SpringBootTest(classes = GlobalAOPELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -40,12 +42,12 @@ public class GlobalAOPELDeclMultiSpringbootTest extends BaseTest { public void testGlobalAopS() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("d")); - Assert.assertEquals("before_after", context.getData("e")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("d")); + Assertions.assertEquals("before_after", context.getData("e")); } // 测试全局AOP,并行场景 @@ -53,26 +55,26 @@ public class GlobalAOPELDeclMultiSpringbootTest extends BaseTest { public void testGlobalAopP() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("d")); - Assert.assertEquals("before_after", context.getData("e")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("d")); + Assertions.assertEquals("before_after", context.getData("e")); } @Test public void testGlobalAopException() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("f")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("f")); } - @AfterClass + @AfterAll public static void cleanScanCache() { BaseTest.cleanScanCache(); ComponentScanner.cmpAroundAspect = null; diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELDeclMultiSpringbootTest.java index 796302a2e..f0b658aed 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELDeclMultiSpringbootTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * * @author ssss */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/asyncNode/application.properties") @SpringBootTest(classes = AsyncNodeELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -38,7 +39,7 @@ public class AsyncNodeELDeclMultiSpringbootTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -46,7 +47,7 @@ public class AsyncNodeELDeclMultiSpringbootTest extends BaseTest { @Test public void testAsyncFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); - Assert.assertTrue( + Assertions.assertTrue( ListUtil .toList("b==>j==>g==>f==>h", "b==>j==>g==>h==>f", "b==>j==>h==>g==>f", "b==>j==>h==>f==>g", "b==>j==>f==>h==>g", "b==>j==>f==>g==>h") @@ -57,15 +58,15 @@ public class AsyncNodeELDeclMultiSpringbootTest extends BaseTest { @Test public void testAsyncFlow3_1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(response.getSlot().getException().getClass(), TestException.class); } // 测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @@ -74,12 +75,12 @@ public class AsyncNodeELDeclMultiSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 因为不记录错误,所以最终结果是true - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 因为配置了不抛错,所以response里的cause应该为null - Assert.assertNull(response.getCause()); + Assertions.assertNull(response.getCause()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @@ -88,12 +89,12 @@ public class AsyncNodeELDeclMultiSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 整个并行组是报错的,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 因为第一个when配置了会报错,所以response里的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @@ -102,12 +103,12 @@ public class AsyncNodeELDeclMultiSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 第一个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(1), count); + Assertions.assertEquals(1, count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @@ -116,12 +117,12 @@ public class AsyncNodeELDeclMultiSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 第二个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 测试任意异步一个执行完即继续的场景 @@ -132,8 +133,8 @@ public class AsyncNodeELDeclMultiSpringbootTest extends BaseTest { public void testAsyncFlow8() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("check").toString().startsWith("habc")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELDeclMultiSpringbootTest.java index 31978fd0f..1b32cc918 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/base/application.properties") @SpringBootTest(classes = BaseELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -33,7 +34,7 @@ public class BaseELDeclMultiSpringbootTest extends BaseTest { @Test public void testBase() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclMultiSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclMultiSpringbootTest1.java index 9221bfed4..992a57bd2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclMultiSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclMultiSpringbootTest1.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.enums.NodeTypeEnum; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.builder.cmp1.*; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -19,7 +20,7 @@ import javax.annotation.Resource; //基于builder模式的单元测试 //这里只是最基本的builder模式的测试,只是为了验证在springboot模式下的正常性 //更详细的builder模式测试用例会单独拉testcase去做 -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = BuilderELDeclMultiSpringbootTest1.class) @EnableAutoConfiguration public class BuilderELDeclMultiSpringbootTest1 extends BaseTest { @@ -81,8 +82,8 @@ public class BuilderELDeclMultiSpringbootTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } // 基于普通组件的builder模式测试 @@ -139,8 +140,8 @@ public class BuilderELDeclMultiSpringbootTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @Test @@ -173,8 +174,8 @@ public class BuilderELDeclMultiSpringbootTest1 extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(a1,c2,a2,c1)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclMultiSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclMultiSpringbootTest2.java index 88b3e73d3..3816eee17 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclMultiSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclMultiSpringbootTest2.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -16,7 +17,7 @@ import javax.annotation.Resource; //基于builder模式的单元测试 //这里测试的是通过spring去扫描,但是通过代码去构建chain的用例 -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = BuilderELDeclMultiSpringbootTest2.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.builder.cmp2" }) @@ -31,8 +32,8 @@ public class BuilderELDeclMultiSpringbootTest2 extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(h, i, j)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("h==>i==>j", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("h==>i==>j", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELDeclMultiSpringbootTest.java index 9b655b1b4..c6e4c4535 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/cmpRetry/application.properties") @SpringBootTest(classes = LiteflowRetryELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,31 +35,31 @@ public class LiteflowRetryELDeclMultiSpringbootTest extends BaseTest { @Test public void testRetry1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } // 单个组件重试配置测试 @Test public void testRetry2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } // 单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); } // 单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java index 6ffd2e57c..2cd4394f4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.entity.CmpStep; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import java.util.*; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/cmpStep/application.properties") @SpringBootTest(classes = CmpStepELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -35,31 +36,31 @@ public class CmpStepELDeclSpringbootTest extends BaseTest { @Test public void testStep() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test public void testStep2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } @Test public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Map> stepMap = response.getExecuteSteps(); - Assert.assertEquals(2, stepMap.size()); + Assertions.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); - Assert.assertEquals(5, queue.size()); + Assertions.assertEquals(5, queue.size()); Set tagSet = new HashSet<>(); response.getExecuteStepQueue() @@ -67,7 +68,7 @@ public class CmpStepELDeclSpringbootTest extends BaseTest { .filter(cmpStep -> cmpStep.getNodeId().equals("a")) .forEach(cmpStep -> tagSet.add(cmpStep.getTag())); - Assert.assertEquals(3, tagSet.size()); + Assertions.assertEquals(3, tagSet.size()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELDeclMultiSpringbootTest.java index acfa4bcca..bbaae8870 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/comments/application.properties") @SpringBootTest(classes = LiteflowNodeELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -29,8 +30,8 @@ public class LiteflowNodeELDeclMultiSpringbootTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); } } \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclMultiSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclMultiSpringbootTest1.java index 1327e75ba..193748524 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclMultiSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclMultiSpringbootTest1.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.complex; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/complex/application1.properties") @SpringBootTest(classes = ComplexELDeclMultiSpringbootTest1.class) @EnableAutoConfiguration @@ -35,7 +36,7 @@ public class ComplexELDeclMultiSpringbootTest1 extends BaseTest { @Test public void testComplex1_1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1_1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试复杂例子,优化后 @@ -44,7 +45,7 @@ public class ComplexELDeclMultiSpringbootTest1 extends BaseTest { @Test public void testComplex1_2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1_2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclMultiSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclMultiSpringbootTest2.java index 12c0c7653..edd35207f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclMultiSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclMultiSpringbootTest2.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.complex; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/complex/application2.properties") @SpringBootTest(classes = ComplexELDeclMultiSpringbootTest2.class) @EnableAutoConfiguration @@ -35,7 +36,7 @@ public class ComplexELDeclMultiSpringbootTest2 extends BaseTest { @Test public void testComplex2_1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2_1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试复杂例子,优化后 @@ -44,7 +45,7 @@ public class ComplexELDeclMultiSpringbootTest2 extends BaseTest { @Test public void testComplex2_2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2_2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELDeclMultiSpringbootTest.java index c99a08421..997d938ce 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELDeclMultiSpringbootTest.java @@ -3,9 +3,11 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.function.Executable; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -22,7 +24,7 @@ import javax.annotation.Resource; * * @author donguo.tao */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/component/application.properties") @SpringBootTest(classes = FlowExecutorELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -38,56 +40,58 @@ public class FlowExecutorELDeclMultiSpringbootTest extends BaseTest { @Test public void testIsAccess() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); - Assert.assertTrue(response.isSuccess()); - Assert.assertNotNull(response.getSlot().getResponseData()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNotNull(response.getSlot().getResponseData()); } // 组件抛错的功能点测试 - @Test(expected = ArithmeticException.class) + @Test public void testComponentException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("/ by zero", response.getMessage()); - ReflectionUtils.rethrowException(response.getCause()); + Assertions.assertThrows(ArithmeticException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("/ by zero", response.getMessage()); + ReflectionUtils.rethrowException(response.getCause()); + }); } // isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCause()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCause()); } // isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d", response.getExecuteStepStr()); } // setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("e", response.getExecuteStepStr()); } // 条件组件的功能点测试 @Test public void testNodeCondComponent() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameELDeclMultiSpringbootTest.java index f349416f2..f9d5894be 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.customMethodName; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.7.2 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/customMethodName/application.properties") @SpringBootTest(classes = CustomMethodNameELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -33,7 +34,7 @@ public class CustomMethodNameELDeclMultiSpringbootTest extends BaseTest { @Test public void testCustomMethodName() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELDeclMultiSpringbootTest.java index 9a66e2be4..8a5af9263 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.customNodes; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/customNodes/application.properties") @SpringBootTest(classes = CustomNodesELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -37,9 +38,9 @@ public class CustomNodesELDeclMultiSpringbootTest extends BaseTest { @Test public void testCustomNodes() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclMultiSpringbootTest.java index a4ea53ff8..bf5435e2a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/customWhenThreadPool/application.properties") @SpringBootTest(classes = CustomWhenThreadPoolELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -42,8 +43,8 @@ public class CustomWhenThreadPoolELDeclMultiSpringbootTest extends BaseTest { public void testGlobalThreadPool() { LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -53,8 +54,8 @@ public class CustomWhenThreadPoolELDeclMultiSpringbootTest extends BaseTest { public void testGlobalAndCustomWhenThreadPool() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response1.getFirstContextBean(); - Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } /** @@ -67,8 +68,8 @@ public class CustomWhenThreadPoolELDeclMultiSpringbootTest extends BaseTest { // chain配置同一个thead1 LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response2.getFirstContextBean(); - Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response2.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELDeclMultiSpringbootTest.java index 634ea3b74..be58bd1e1 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/event/application.properties") @SpringBootTest(classes = EventELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -36,8 +37,8 @@ public class EventELDeclMultiSpringbootTest extends BaseTest { public void testEvent1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("abc", context.getData("test")); } // 测试组件失败事件 @@ -45,10 +46,10 @@ public class EventELDeclMultiSpringbootTest extends BaseTest { public void testEvent2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", context.getData("test")); - Assert.assertEquals("error:d", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("ab", context.getData("test")); + Assertions.assertEquals("error:d", context.getData("error")); } // 测试组件失败事件本身抛出异常 @@ -56,10 +57,10 @@ public class EventELDeclMultiSpringbootTest extends BaseTest { public void testEvent3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", context.getData("test")); - Assert.assertEquals("error:e", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("a", context.getData("test")); + Assertions.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELDeclMultiSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELDeclMultiSpringBootTest.java index 6ffc613dd..12dd77f22 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELDeclMultiSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELDeclMultiSpringBootTest.java @@ -4,14 +4,18 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.exception.ChainDuplicateException; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.exception.FlowExecutorNotInitException; +import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.ReflectionUtils; import javax.annotation.Resource; @@ -20,7 +24,7 @@ import javax.annotation.Resource; * * @author zendwang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = Exception1ELDeclMultiSpringBootTest.class) @EnableAutoConfiguration public class Exception1ELDeclMultiSpringBootTest extends BaseTest { @@ -31,31 +35,38 @@ public class Exception1ELDeclMultiSpringBootTest extends BaseTest { /** * 验证 chain 节点重复的异常 */ - @Test(expected = ChainDuplicateException.class) + @Test public void testChainDuplicateException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-exception.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(ChainDuplicateException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-exception.el.xml"); + flowExecutor.reloadRule(); + }); } - @Test(expected = ConfigErrorException.class) + @Test public void testConfigErrorException() { - flowExecutor.setLiteflowConfig(null); - flowExecutor.reloadRule(); + Assertions.assertThrows(ConfigErrorException.class, () -> { + flowExecutor.setLiteflowConfig(null); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testFlowExecutorNotInitException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("error/flow.txt"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("error/flow.txt"); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testNoConditionInChainException() throws Exception { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-blank.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-blank.el.xml"); + flowExecutor.reloadRule(); + }); } - } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELDeclMultiSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELDeclMultiSpringBootTest.java index a0b8bd03e..d6cc11e0d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELDeclMultiSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELDeclMultiSpringBootTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.exception.LiteFlowException; import com.yomahub.liteflow.exception.NoSwitchTargetNodeException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * * @author zendwang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/exception/application.properties") @SpringBootTest(classes = Exception2ELDeclMultiSpringBootTest.class) @EnableAutoConfiguration @@ -32,46 +33,49 @@ public class Exception2ELDeclMultiSpringBootTest extends BaseTest { @Resource private FlowExecutor flowExecutor; - @Test(expected = ChainNotFoundException.class) + @Test public void testChainNotFoundException() throws Exception { - flowExecutor.execute("chain0", "it's a request"); + Assertions.assertThrows(ChainNotFoundException.class, () -> flowExecutor.execute("chain0", "it's a request")); + } - @Test(expected = RuntimeException.class) + @Test public void testComponentCustomException() throws Exception { - flowExecutor.execute("chain1", "exception"); + Assertions.assertThrows(RuntimeException.class, () -> flowExecutor.execute("chain1", "exception")); } @Test public void testGetSlotFromResponseWhenException() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); - Assert.assertFalse(response.isSuccess()); - Assert.assertNotNull(response.getCause()); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertNotNull(response.getSlot()); } - @Test(expected = NoSwitchTargetNodeException.class) + @Test public void testNoTargetFindException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); - Assert.assertFalse(response.isSuccess()); - throw response.getCause(); + Assertions.assertThrows(NoSwitchTargetNodeException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); + Assertions.assertFalse(response.isSuccess()); + throw response.getCause(); + }); } @Test public void testInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "custom-stateful-exception"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("300", response.getCode()); - Assert.assertNotNull(response.getCause()); - Assert.assertTrue(response.getCause() instanceof LiteFlowException); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("300", response.getCode()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertTrue(response.getCause() instanceof LiteFlowException); + Assertions.assertNotNull(response.getSlot()); } @Test public void testNotInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "test"); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCode()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCode()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELDeclMultiSpringbootTest.java index 06c9866de..a360b125a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import java.util.concurrent.Future; * @author Bryan.Zhang * @since 2.6.13 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/execute2Future/application.properties") @SpringBootTest(classes = Executor2FutureELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +37,7 @@ public class Executor2FutureELDeclMultiSpringbootTest extends BaseTest { public void testFuture() throws Exception { Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); LiteflowResponse response = future.get(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendELDeclMultiSpringbootTest.java index 768d603f9..54048c83e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.extend; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.7.1 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/extend/application.properties") @SpringBootTest(classes = CmpExtendELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -33,7 +34,7 @@ public class CmpExtendELDeclMultiSpringbootTest extends BaseTest { @Test public void testExtend() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELDeclMultiSpringbootTest.java index 407016896..666e124d0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/getChainName/application.properties") @SpringBootTest(classes = GetChainNameELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,28 +35,28 @@ public class GetChainNameELDeclMultiSpringbootTest extends BaseTest { public void testGetChainName1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); } @Test public void testGetChainName2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("chain2", context.getData("g")); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); - Assert.assertEquals("sub5", context.getData("f")); - Assert.assertEquals("sub5_chain2", context.getData("e")); - Assert.assertEquals("sub6", context.getData("h")); - Assert.assertEquals("sub6", context.getData("j")); - Assert.assertNull(context.getData("k")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("chain2", context.getData("g")); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); + Assertions.assertEquals("sub5", context.getData("f")); + Assertions.assertEquals("sub5_chain2", context.getData("e")); + Assertions.assertEquals("sub6", context.getData("h")); + Assertions.assertEquals("sub6", context.getData("j")); + Assertions.assertNull(context.getData("k")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELDeclMultiSpringbootTest.java index 41094404b..ec9b9bda9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.ifelse; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/ifelse/application.properties") @SpringBootTest(classes = IfElseELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,56 +35,56 @@ public class IfElseELDeclMultiSpringbootTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELDeclMultiSpringbootTest.java index a9eac1195..db2615d0e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELDeclMultiSpringbootTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +24,7 @@ import java.util.List; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/iterator/application.properties") @SpringBootTest(classes = IteratorELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -38,10 +39,10 @@ public class IteratorELDeclMultiSpringbootTest extends BaseTest { public void testIt1() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain1", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("123", str); + Assertions.assertEquals("123", str); } // 迭代器带break @@ -49,10 +50,10 @@ public class IteratorELDeclMultiSpringbootTest extends BaseTest { public void testIt2() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("12", str); + Assertions.assertEquals("12", str); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELDeclMultiSpringbootTest.java index fa1fd1cff..0072210f3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELDeclMultiSpringbootTest.java @@ -3,7 +3,7 @@ package com.yomahub.liteflow.test.lazy; import com.yomahub.liteflow.test.BaseTest; //spring的延迟加载在el表达形式模式下不起作用 -/*@RunWith(SpringRunner.class) +/*@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/lazy/application.properties") @SpringBootTest(classes = LazyELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -15,7 +15,7 @@ public class LazyELDeclMultiSpringbootTest extends BaseTest { * * @Test public void testLazy() throws Exception{ LiteflowResponse response = * flowExecutor.execute2Resp("chain1", "arg"); - * Assert.assertTrue(response.isSuccess()); } + * Assertions.assertTrue(response.isSuccess()); } */ } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELDeclMultiSpringbootTest.java index ddfb1fac0..29c189faa 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.lfCmpAnno; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -19,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/lfCmpAnno/application.properties") @SpringBootTest(classes = LiteflowComponentELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -32,8 +33,8 @@ public class LiteflowComponentELDeclMultiSpringbootTest extends BaseTest { @Test public void testConfig() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELDeclMultiSpringbootTest.java index 98f6706bd..6db534bb4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/loop/application.properties") @SpringBootTest(classes = LoopELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -35,31 +36,31 @@ public class LoopELDeclMultiSpringbootTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -67,8 +68,8 @@ public class LoopELDeclMultiSpringbootTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } @@ -77,10 +78,10 @@ public class LoopELDeclMultiSpringbootTest extends BaseTest { public void testLoop6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } // 测试WHILE循环中的index @@ -88,10 +89,10 @@ public class LoopELDeclMultiSpringbootTest extends BaseTest { public void testLoop7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/mixDefine/MixDefineELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/mixDefine/MixDefineELDeclMultiSpringbootTest.java index ee4c8ad6e..4758e345d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/mixDefine/MixDefineELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/mixDefine/MixDefineELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.mixDefine; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/mixDefine/application.properties") @SpringBootTest(classes = MixDefineELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +35,7 @@ public class MixDefineELDeclMultiSpringbootTest extends BaseTest { @Test public void testMixDefine1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELDeclMultiSpringbootTest.java index 1ca5b55ee..0db20cda5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELDeclMultiSpringbootTest.java @@ -5,10 +5,12 @@ import com.yomahub.liteflow.flow.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.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.event.annotation.AfterTestClass; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/monitor/application.properties") @SpringBootTest(classes = MonitorELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -36,13 +38,14 @@ public class MonitorELDeclMultiSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Thread.sleep(10000); } - @AfterClass + @AfterAll public static void clean() { + BaseTest.cleanScanCache(); MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class); monitorBus.closeScheduler(); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclMultiSpringbootTest.java index 24c8602cb..8a88f4b16 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclMultiSpringbootTest.java @@ -6,9 +6,10 @@ import cn.hutool.core.util.CharsetUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -18,7 +19,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.io.File; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/monitorFile/application.properties") @SpringBootTest(classes = MonitorFileELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +37,7 @@ public class MonitorFileELDeclMultiSpringbootTest extends BaseTest { FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); Thread.sleep(3000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>c==>b", response.getExecuteStepStr()); + Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELDeclMultiSpringbootTest.java index 2279d9ca1..d9d5c9c6b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELDeclMultiSpringbootTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.exception.NoSuchContextBeanException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/multiContext/application.properties") @SpringBootTest(classes = MultiContextELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -38,18 +39,19 @@ public class MultiContextELDeclMultiSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("987XYZ", checkContext.getSign()); - Assert.assertEquals(95, checkContext.getRandomId()); - Assert.assertEquals("SO12345", orderContext.getOrderNo()); - Assert.assertEquals(2, orderContext.getOrderType()); - Assert.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("987XYZ", checkContext.getSign()); + Assertions.assertEquals(95, checkContext.getRandomId()); + Assertions.assertEquals("SO12345", orderContext.getOrderNo()); + Assertions.assertEquals(2, orderContext.getOrderType()); + Assertions.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); } - @Test(expected = NoSuchContextBeanException.class) + @Test public void testMultiContext2() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); - DefaultContext context = response.getContextBean(DefaultContext.class); + Assertions.assertThrows(NoSuchContextBeanException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); + DefaultContext context = response.getContextBean(DefaultContext.class); + }); } - } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELDeclMultiSpringbootTest.java index 26c17b9d4..a2cf815c0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -19,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/multipleType/application.properties") @SpringBootTest(classes = LiteflowMultipleTypeELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -32,11 +33,11 @@ public class LiteflowMultipleTypeELDeclMultiSpringbootTest extends BaseTest { @Test public void testMultipleType() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELDeclMultiSpringbootTest.java index 7e3b298ee..666e23f52 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/nodeExecutor/application.properties") @SpringBootTest(classes = LiteflowNodeExecutorELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -36,9 +37,9 @@ public class LiteflowNodeExecutorELDeclMultiSpringbootTest extends BaseTest { public void testCustomerDefaultNodeExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("a", response.getExecuteStepStr()); } // 默认执行器测试+全局重试配置测试 @@ -46,17 +47,17 @@ public class LiteflowNodeExecutorELDeclMultiSpringbootTest extends BaseTest { public void testDefaultExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("b==>b==>b", response.getExecuteStepStr()); } // 自定义执行器测试 @Test public void testCustomerExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("c", response.getExecuteStepStr()); } // 自定义执行器测试+全局重试配置测试 @@ -64,9 +65,9 @@ public class LiteflowNodeExecutorELDeclMultiSpringbootTest extends BaseTest { public void testCustomExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); - Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); + Assertions.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELDeclMultiSpringbootTest.java index 58a522741..0b7dc1b5b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author dongguo.tao * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parsecustom/application-custom-json.properties") @SpringBootTest(classes = CustomParserJsonELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +35,7 @@ public class CustomParserJsonELDeclMultiSpringbootTest extends BaseTest { @Test public void testJsonCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELDeclMultiSpringbootTest.java index 444b67bac..dcca7597d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author bryan.zhang * @since 2.5.7 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parsecustom/application-custom-xml.properties") @SpringBootTest(classes = CustomParserXmlELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +35,7 @@ public class CustomParserXmlELDeclMultiSpringbootTest extends BaseTest { @Test public void testXmlCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELDeclMultiSpringbootTest.java index f94b292c8..6507ec3b1 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parser/application-json.properties") @SpringBootTest(classes = JsonParserELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +35,7 @@ public class JsonParserELDeclMultiSpringbootTest extends BaseTest { @Test public void testJsonParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELDeclMultiSpringbootTest.java index 262e3f150..1a5a2a562 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parser/application-springEL.properties") @SpringBootTest(classes = SpringELSupportELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -28,7 +29,7 @@ public class SpringELSupportELDeclMultiSpringbootTest extends BaseTest { @Test public void testSpringELParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELDeclMultiSpringbootTest.java index dbdb47bba..726fc70dd 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parser/application-xml.properties") @SpringBootTest(classes = XmlParserELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +35,7 @@ public class XmlParserELDeclMultiSpringbootTest extends BaseTest { @Test public void testXmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELDeclMultiSpringbootTest.java index 01fd8d6c3..155e9dce3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parser/application-yml.properties") @SpringBootTest(classes = YmlParserELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +35,7 @@ public class YmlParserELDeclMultiSpringbootTest extends BaseTest { @Test public void testYmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELDeclMultiSpringbootTest.java index 76faa8331..cfba172ab 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/preAndFinally/application.properties") @SpringBootTest(classes = PreAndFinallyELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -35,24 +36,24 @@ public class PreAndFinallyELDeclMultiSpringbootTest extends BaseTest { @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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } // 测试在finally节点里是否能获取exception @@ -60,15 +61,15 @@ public class PreAndFinallyELDeclMultiSpringbootTest extends BaseTest { public void testPreAndFinally4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(context.getData("hasEx")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue((Boolean) context.getData("hasEx")); } @Test public void testPreAndFinally5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELDeclMultiSpringbootTest.java index a47628d8c..ea68295f7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELDeclMultiSpringbootTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/privateDelivery/application.properties") @SpringBootTest(classes = PrivateDeliveryELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -37,8 +38,8 @@ public class PrivateDeliveryELDeclMultiSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); ConcurrentHashSet set = context.getData("testSet"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(100, set.size()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(100, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELDeclMultiSpringbootTest.java index 21222419c..4a0c23330 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELDeclMultiSpringbootTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/refreshRule/application.properties") @SpringBootTest(classes = RefreshRuleELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -39,7 +40,7 @@ public class RefreshRuleELDeclMultiSpringbootTest extends BaseTest { String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.el.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, content); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试优雅刷新的场景 @@ -59,7 +60,7 @@ public class RefreshRuleELDeclMultiSpringbootTest extends BaseTest { for (int i = 0; i < 500; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); try { Thread.sleep(10L); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELDeclMultiSpringbootTest.java index cdb72ce01..e71b65bbc 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/reload/application.properties") @SpringBootTest(classes = ReloadELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +37,7 @@ public class ReloadELDeclMultiSpringbootTest extends BaseTest { public void testReload() throws Exception { flowExecutor.reloadRule(); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELDeclMultiSpringbootTest.java index 3154263fd..57a7e1fb8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.requestId; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -17,7 +18,7 @@ import javax.annotation.Resource; /** * @author tangkc */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/requestId/application.properties") @SpringBootTest(classes = LiteflowRequestIdELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -30,8 +31,8 @@ public class LiteflowRequestIdELDeclMultiSpringbootTest extends BaseTest { @Test public void testRequestId() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1", response.getSlot().getRequestId()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1", response.getSlot().getRequestId()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELDeclMultiSpringbootTest.java index 322888266..884441ea3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import java.util.Set; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-implicit.properties") @SpringBootTest(classes = ImplicitSubFlowELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -39,15 +40,15 @@ public class ImplicitSubFlowELDeclMultiSpringbootTest extends BaseTest { public void testImplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); // 传递了slotIndex,则set的size==1 - Assert.assertEquals(1, RUN_TIME_SLOT.size()); + Assertions.assertEquals(1, RUN_TIME_SLOT.size()); // set中第一次设置的requestId和response中的requestId一致 - Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); + Assertions.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); // requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); + Assertions.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } // 在p里多线程调用q 10次,每个q取到的参数都是不同的。 @@ -55,12 +56,12 @@ public class ImplicitSubFlowELDeclMultiSpringbootTest extends BaseTest { public void testImplicitSubFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("c1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Set set = context.getData("test"); // requestData的取值正确 - Assert.assertEquals(10, set.size()); + Assertions.assertEquals(10, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELDeclMultiSpringbootTest.java index 8459e6afe..da047c27e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELDeclMultiSpringbootTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.exception.MultipleParsersException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-subInDifferentConfig1.properties") @SpringBootTest(classes = SubflowInDifferentConfigELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -37,19 +38,21 @@ public class SubflowInDifferentConfigELDeclMultiSpringbootTest extends BaseTest @Test public void testExplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } @Autowired private ApplicationContext context; // 主要测试有不同的配置类型后会不会报出既定的错误 - @Test(expected = MultipleParsersException.class) + @Test public void testExplicitSubFlow2() { - LiteflowConfig config = context.getBean(LiteflowConfig.class); - config.setRuleSource("subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.yml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(MultipleParsersException.class, () -> { + LiteflowConfig config = context.getBean(LiteflowConfig.class); + config.setRuleSource("subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.yml"); + flowExecutor.reloadRule(); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELDeclMultiSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELDeclMultiSpringBootTest.java index 35a8a96de..1e6cc049a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELDeclMultiSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELDeclMultiSpringBootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-json.properties") @SpringBootTest(classes = SubflowJsonELDeclMultiSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +34,8 @@ public class SubflowJsonELDeclMultiSpringBootTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELDeclMultiSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELDeclMultiSpringBootTest.java index b25b21150..7cb779f57 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELDeclMultiSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELDeclMultiSpringBootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-xml.properties") @SpringBootTest(classes = SubflowXMLELDeclMultiSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +34,8 @@ public class SubflowXMLELDeclMultiSpringBootTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELDeclMultiSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELDeclMultiSpringBootTest.java index 76cc3be91..ea9ed68e5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELDeclMultiSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELDeclMultiSpringBootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-yml.properties") @SpringBootTest(classes = SubflowYmlELDeclMultiSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +34,8 @@ public class SubflowYmlELDeclMultiSpringBootTest extends BaseTest { @Test public void testExplicitSubFlowYml() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java index 08f9e0a6a..314f9bf57 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.switchcase; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/switchcase/application.properties") @SpringBootTest(classes = SwitchELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -33,36 +34,36 @@ public class SwitchELDeclMultiSpringbootTest extends BaseTest { @Test public void testSwitch1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); } @Test public void testSwitch2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d", response.getExecuteStepStr()); } @Test public void testSwitch3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>f==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>f==>b", response.getExecuteStepStr()); } @Test public void testSwitch4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>g==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>g==>d", response.getExecuteStepStr()); } @Test public void testSwitch5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>h==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclMultiSpringbootJsonTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclMultiSpringbootJsonTest.java index 28cce58ad..5cd386cf1 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclMultiSpringbootJsonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclMultiSpringbootJsonTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/tag/application-json.properties") @SpringBootTest(classes = NodeTagELDeclMultiSpringbootJsonTest.class) @EnableAutoConfiguration @@ -36,15 +37,15 @@ public class NodeTagELDeclMultiSpringbootJsonTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -54,9 +55,9 @@ public class NodeTagELDeclMultiSpringbootJsonTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -64,8 +65,8 @@ public class NodeTagELDeclMultiSpringbootJsonTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclMultiSpringbootXmlTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclMultiSpringbootXmlTest.java index 9e4b2f403..ea0987bdb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclMultiSpringbootXmlTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclMultiSpringbootXmlTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/tag/application-xml.properties") @SpringBootTest(classes = NodeTagELDeclMultiSpringbootXmlTest.class) @EnableAutoConfiguration @@ -36,15 +37,15 @@ public class NodeTagELDeclMultiSpringbootXmlTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -54,9 +55,9 @@ public class NodeTagELDeclMultiSpringbootXmlTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -64,8 +65,8 @@ public class NodeTagELDeclMultiSpringbootXmlTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELDeclMultiSpringbootTest.java index 1a736d3c6..018f6db1a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELDeclMultiSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.3 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/useTTLInWhen/application.properties") @SpringBootTest(classes = UseTTLInWhenELDeclMultiSpringbootTest.class) @EnableAutoConfiguration @@ -35,11 +36,11 @@ public class UseTTLInWhenELDeclMultiSpringbootTest extends BaseTest { public void testUseTTLInWhen() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,b", context.getData("b")); - Assert.assertEquals("hello,c", context.getData("c")); - Assert.assertEquals("hello,d", context.getData("d")); - Assert.assertEquals("hello,e", context.getData("e")); - Assert.assertEquals("hello,f", context.getData("f")); + Assertions.assertEquals("hello,b", context.getData("b")); + Assertions.assertEquals("hello,c", context.getData("c")); + Assertions.assertEquals("hello,d", context.getData("d")); + Assertions.assertEquals("hello,e", context.getData("e")); + Assertions.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclMultiSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclMultiSpringbootTest1.java index f0116e0f8..0b892b71b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclMultiSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclMultiSpringbootTest1.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.exception.WhenTimeoutException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/whenTimeOut/application1.properties") @SpringBootTest(classes = WhenTimeOutELDeclMultiSpringbootTest1.class) @EnableAutoConfiguration @@ -39,8 +40,8 @@ public class WhenTimeOutELDeclMultiSpringbootTest1 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclMultiSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclMultiSpringbootTest2.java index 2f1b8beab..49b1d3b5f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclMultiSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclMultiSpringbootTest2.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/whenTimeOut/application2.properties") @SpringBootTest(classes = WhenTimeOutELDeclMultiSpringbootTest2.class) @EnableAutoConfiguration @@ -38,7 +39,7 @@ public class WhenTimeOutELDeclMultiSpringbootTest2 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclSpringbootTest.java index 7270c2ca6..55c900075 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties") @SpringBootTest(classes = AbsoluteConfigPathELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -37,7 +38,7 @@ public class AbsoluteConfigPathELDeclSpringbootTest extends BaseTest { @Test public void testAbsoluteConfig() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELDeclSpringbootTest.java index 3f18688ff..0d68fb5db 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELDeclSpringbootTest.java @@ -9,7 +9,7 @@ import com.yomahub.liteflow.test.BaseTest; * @author Bryan.Zhang */ /* - * @RunWith(SpringRunner.class) + * @ExtendWith(SpringExtension.class) * * @TestPropertySource(value = "classpath:/aop/application.properties") * @@ -31,17 +31,17 @@ public class CustomAOPELDeclSpringbootTest extends BaseTest { * * @Test public void testCustomAopS() { LiteflowResponse response= * flowExecutor.execute2Resp("chain1", "it's a request"); - * Assert.assertTrue(response.isSuccess()); Assert.assertEquals("before_after", - * response.getContextBean.getData("a")); Assert.assertEquals("before_after", - * context.getData("b")); Assert.assertEquals("before_after", context.getData("c")); } + * Assertions.assertTrue(response.isSuccess()); Assertions.assertEquals("before_after", + * response.getContextBean.getData("a")); Assertions.assertEquals("before_after", + * context.getData("b")); Assertions.assertEquals("before_after", context.getData("c")); } * * //测试自定义AOP,并行场景 * * @Test public void testCustomAopP() { LiteflowResponse response= * flowExecutor.execute2Resp("chain2", "it's a request"); - * Assert.assertTrue(response.isSuccess()); Assert.assertEquals("before_after", - * context.getData("a")); Assert.assertEquals("before_after", context.getData("b")); - * Assert.assertEquals("before_after", context.getData("c")); } + * Assertions.assertTrue(response.isSuccess()); Assertions.assertEquals("before_after", + * context.getData("a")); Assertions.assertEquals("before_after", context.getData("b")); + * Assertions.assertEquals("before_after", context.getData("c")); } */ } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELDeclSpringbootTest.java index f3ee21e5d..aa85b864f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELDeclSpringbootTest.java @@ -6,10 +6,11 @@ import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.aop.aspect.CmpAspect; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/aop/application.properties") @SpringBootTest(classes = GlobalAOPELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -40,12 +41,12 @@ public class GlobalAOPELDeclSpringbootTest extends BaseTest { public void testGlobalAopS() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("d")); - Assert.assertEquals("before_after", context.getData("e")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("d")); + Assertions.assertEquals("before_after", context.getData("e")); } // 测试全局AOP,并行场景 @@ -53,26 +54,26 @@ public class GlobalAOPELDeclSpringbootTest extends BaseTest { public void testGlobalAopP() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("d")); - Assert.assertEquals("before_after", context.getData("e")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("d")); + Assertions.assertEquals("before_after", context.getData("e")); } @Test public void testGlobalAopException() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("f")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("f")); } - @AfterClass + @AfterAll public static void cleanScanCache() { BaseTest.cleanScanCache(); ComponentScanner.cmpAroundAspect = null; diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELDeclSpringbootTest.java index 3d9c34b33..b9960c2fc 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELDeclSpringbootTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * * @author ssss */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/asyncNode/application.properties") @SpringBootTest(classes = AsyncNodeELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -38,7 +39,7 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -46,7 +47,7 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest { @Test public void testAsyncFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); - Assert.assertTrue( + Assertions.assertTrue( ListUtil .toList("b==>j==>g==>f==>h", "b==>j==>g==>h==>f", "b==>j==>h==>g==>f", "b==>j==>h==>f==>g", "b==>j==>f==>h==>g", "b==>j==>f==>g==>h") @@ -57,15 +58,15 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest { @Test public void testAsyncFlow3_1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(response.getSlot().getException().getClass(), TestException.class); } // 测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @@ -74,12 +75,12 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 因为不记录错误,所以最终结果是true - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(new Integer(2), count); // 因为配置了不抛错,所以response里的cause应该为null - Assert.assertNull(response.getCause()); + Assertions.assertNull(response.getCause()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @@ -88,12 +89,12 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 整个并行组是报错的,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(new Integer(2), count); // 因为第一个when配置了会报错,所以response里的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @@ -102,12 +103,12 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 第一个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(1), count); + Assertions.assertEquals(new Integer(1), count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @@ -116,12 +117,12 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 第二个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(new Integer(2), count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 测试任意异步一个执行完即继续的场景 @@ -132,8 +133,8 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest { public void testAsyncFlow8() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("check").toString().startsWith("habc")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELDeclSpringbootTest.java index 13705781b..af10a6746 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/base/application.properties") @SpringBootTest(classes = BaseELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -33,7 +34,7 @@ public class BaseELDeclSpringbootTest extends BaseTest { @Test public void testBase() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclSpringbootTest1.java index 01fc730b4..7f8b8714b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclSpringbootTest1.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.base.BaseELDeclSpringbootTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; //基于builder模式的单元测试 //这里只是最基本的builder模式的测试,只是为了验证在springboot模式下的正常性 //更详细的builder模式测试用例会单独拉testcase去做 -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = BuilderELDeclSpringbootTest1.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.builder.cmp1" }) @@ -39,8 +40,8 @@ public class BuilderELDeclSpringbootTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>e==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>e==>c==>d", response.getExecuteStepStrWithoutTime()); } // 基于普通组件的builder模式测试 @@ -54,8 +55,8 @@ public class BuilderELDeclSpringbootTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>e==>c==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>e==>c==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclSpringbootTest2.java index 22f938a17..49cbc7caf 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELDeclSpringbootTest2.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -16,7 +17,7 @@ import javax.annotation.Resource; //基于builder模式的单元测试 //这里测试的是通过spring去扫描,但是通过代码去构建chain的用例 -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = BuilderELDeclSpringbootTest2.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.builder.cmp2" }) @@ -31,8 +32,8 @@ public class BuilderELDeclSpringbootTest2 extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(h, i, j)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("h==>i==>j", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("h==>i==>j", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELDeclSpringbootTest.java index e110847f1..9dd1bfa26 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/cmpRetry/application.properties") @SpringBootTest(classes = LiteflowRetryELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -34,31 +35,31 @@ public class LiteflowRetryELDeclSpringbootTest extends BaseTest { @Test public void testRetry1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } // 单个组件重试配置测试 @Test public void testRetry2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } // 单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); } // 单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java index 6ffd2e57c..2cd4394f4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.entity.CmpStep; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import java.util.*; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/cmpStep/application.properties") @SpringBootTest(classes = CmpStepELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -35,31 +36,31 @@ public class CmpStepELDeclSpringbootTest extends BaseTest { @Test public void testStep() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test public void testStep2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } @Test public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Map> stepMap = response.getExecuteSteps(); - Assert.assertEquals(2, stepMap.size()); + Assertions.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); - Assert.assertEquals(5, queue.size()); + Assertions.assertEquals(5, queue.size()); Set tagSet = new HashSet<>(); response.getExecuteStepQueue() @@ -67,7 +68,7 @@ public class CmpStepELDeclSpringbootTest extends BaseTest { .filter(cmpStep -> cmpStep.getNodeId().equals("a")) .forEach(cmpStep -> tagSet.add(cmpStep.getTag())); - Assert.assertEquals(3, tagSet.size()); + Assertions.assertEquals(3, tagSet.size()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java index 287f26265..456cb42e8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java @@ -4,9 +4,10 @@ import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/comments/application.properties") @SpringBootTest(classes = LiteflowNodeELSpringbootTest.class) @EnableAutoConfiguration @@ -29,8 +30,8 @@ public class LiteflowNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); } } \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclSpringbootTest1.java index 9b94331b9..ccc1a9a9f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclSpringbootTest1.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.complex; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/complex/application1.properties") @SpringBootTest(classes = ComplexELDeclSpringbootTest1.class) @EnableAutoConfiguration @@ -35,7 +36,7 @@ public class ComplexELDeclSpringbootTest1 extends BaseTest { @Test public void testComplex1_1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1_1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试复杂例子,优化后 @@ -44,7 +45,7 @@ public class ComplexELDeclSpringbootTest1 extends BaseTest { @Test public void testComplex1_2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1_2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclSpringbootTest2.java index 9ca148eff..6b1cdfc15 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELDeclSpringbootTest2.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.complex; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/complex/application2.properties") @SpringBootTest(classes = ComplexELDeclSpringbootTest2.class) @EnableAutoConfiguration @@ -35,7 +36,7 @@ public class ComplexELDeclSpringbootTest2 extends BaseTest { @Test public void testComplex2_1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2_1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试复杂例子,优化后 @@ -44,7 +45,7 @@ public class ComplexELDeclSpringbootTest2 extends BaseTest { @Test public void testComplex2_2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2_2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELDeclSpringbootTest.java index 28206f8c0..5b79fd4f3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * * @author donguo.tao */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/component/application.properties") @SpringBootTest(classes = FlowExecutorELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -38,56 +39,57 @@ public class FlowExecutorELDeclSpringbootTest extends BaseTest { @Test public void testIsAccess() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); - Assert.assertTrue(response.isSuccess()); - Assert.assertNotNull(response.getSlot().getResponseData()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNotNull(response.getSlot().getResponseData()); } // 组件抛错的功能点测试 - @Test(expected = ArithmeticException.class) public void testComponentException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("/ by zero", response.getMessage()); - ReflectionUtils.rethrowException(response.getCause()); + Assertions.assertThrows(ArithmeticException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("/ by zero", response.getMessage()); + ReflectionUtils.rethrowException(response.getCause()); + }); } // isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCause()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCause()); } // isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d", response.getExecuteStepStr()); } // setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("e", response.getExecuteStepStr()); } // 条件组件的功能点测试 @Test public void testNodeCondComponent() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameELDeclSpringbootTest.java index c607c371d..3697244c7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.customMethodName; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.7.2 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/customMethodName/application.properties") @SpringBootTest(classes = CustomMethodNameELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -33,7 +34,7 @@ public class CustomMethodNameELDeclSpringbootTest extends BaseTest { @Test public void testCustomMethodName() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELDeclSpringbootTest.java index acff88e57..52797ee24 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.customNodes; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/customNodes/application.properties") @SpringBootTest(classes = CustomNodesELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -37,9 +38,9 @@ public class CustomNodesELDeclSpringbootTest extends BaseTest { @Test public void testCustomNodes() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclSpringbootTest.java index 7cd9996e7..9e13664fb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/customWhenThreadPool/application.properties") @SpringBootTest(classes = CustomWhenThreadPoolELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -42,8 +43,8 @@ public class CustomWhenThreadPoolELDeclSpringbootTest extends BaseTest { public void testGlobalThreadPool() { LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -53,8 +54,8 @@ public class CustomWhenThreadPoolELDeclSpringbootTest extends BaseTest { public void testGlobalAndCustomWhenThreadPool() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response1.getFirstContextBean(); - Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } /** @@ -67,8 +68,8 @@ public class CustomWhenThreadPoolELDeclSpringbootTest extends BaseTest { // chain配置同一个thead1 LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response2.getFirstContextBean(); - Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response2.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELDeclSpringbootTest.java index 479370591..097ca251b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/event/application.properties") @SpringBootTest(classes = EventELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -36,8 +37,8 @@ public class EventELDeclSpringbootTest extends BaseTest { public void testEvent1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("abc", context.getData("test")); } // 测试组件失败事件 @@ -45,10 +46,10 @@ public class EventELDeclSpringbootTest extends BaseTest { public void testEvent2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", context.getData("test")); - Assert.assertEquals("error:d", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("ab", context.getData("test")); + Assertions.assertEquals("error:d", context.getData("error")); } // 测试组件失败事件本身抛出异常 @@ -56,10 +57,10 @@ public class EventELDeclSpringbootTest extends BaseTest { public void testEvent3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", context.getData("test")); - Assert.assertEquals("error:e", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("a", context.getData("test")); + Assertions.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELDeclSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELDeclSpringBootTest.java index acdd913b5..d8e2ae4e8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELDeclSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELDeclSpringBootTest.java @@ -7,8 +7,10 @@ import com.yomahub.liteflow.exception.FlowExecutorNotInitException; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -20,7 +22,7 @@ import javax.annotation.Resource; * * @author zendwang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = Exception1ELDeclSpringBootTest.class) @EnableAutoConfiguration public class Exception1ELDeclSpringBootTest extends BaseTest { @@ -31,31 +33,38 @@ public class Exception1ELDeclSpringBootTest extends BaseTest { /** * 验证 chain 节点重复的异常 */ - @Test(expected = ChainDuplicateException.class) + @Test public void testChainDuplicateException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-exception.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(ChainDuplicateException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-exception.el.xml"); + flowExecutor.reloadRule(); + }); } - @Test(expected = ConfigErrorException.class) + @Test public void testConfigErrorException() { - flowExecutor.setLiteflowConfig(null); - flowExecutor.reloadRule(); + Assertions.assertThrows(ConfigErrorException.class, () -> { + flowExecutor.setLiteflowConfig(null); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testFlowExecutorNotInitException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("error/flow.txt"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("error/flow.txt"); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testNoConditionInChainException() throws Exception { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-blank.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-blank.el.xml"); + flowExecutor.reloadRule(); + }); } - } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELDeclSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELDeclSpringBootTest.java index c33486d87..c67912e04 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELDeclSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELDeclSpringBootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.exception.*; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * * @author zendwang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/exception/application.properties") @SpringBootTest(classes = Exception2ELDeclSpringBootTest.class) @EnableAutoConfiguration @@ -31,46 +32,53 @@ public class Exception2ELDeclSpringBootTest extends BaseTest { @Resource private FlowExecutor flowExecutor; - @Test(expected = ChainNotFoundException.class) + @Test public void testChainNotFoundException() throws Exception { - flowExecutor.execute("chain0", "it's a request"); + Assertions.assertThrows(ChainNotFoundException.class, () -> { + flowExecutor.execute("chain0", "it's a request"); + }); } - @Test(expected = RuntimeException.class) + @Test public void testComponentCustomException() throws Exception { - flowExecutor.execute("chain1", "exception"); + Assertions.assertThrows(RuntimeException.class, () -> { + flowExecutor.execute("chain1", "exception"); + }); } @Test public void testGetSlotFromResponseWhenException() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); - Assert.assertFalse(response.isSuccess()); - Assert.assertNotNull(response.getCause()); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertNotNull(response.getSlot()); } - @Test(expected = NoSwitchTargetNodeException.class) + @Test public void testNoTargetFindException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); - Assert.assertFalse(response.isSuccess()); - throw response.getCause(); + Assertions.assertThrows(NoSwitchTargetNodeException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); + Assertions.assertFalse(response.isSuccess()); + throw response.getCause(); + }); + } @Test public void testInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "custom-stateful-exception"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("300", response.getCode()); - Assert.assertNotNull(response.getCause()); - Assert.assertTrue(response.getCause() instanceof LiteFlowException); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("300", response.getCode()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertTrue(response.getCause() instanceof LiteFlowException); + Assertions.assertNotNull(response.getSlot()); } @Test public void testNotInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "test"); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCode()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCode()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELDeclSpringbootTest.java index e11931695..c3360a9dd 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import java.util.concurrent.Future; * @author Bryan.Zhang * @since 2.6.13 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/execute2Future/application.properties") @SpringBootTest(classes = Executor2FutureELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +37,7 @@ public class Executor2FutureELDeclSpringbootTest extends BaseTest { public void testFuture() throws Exception { Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); LiteflowResponse response = future.get(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendELDeclSpringbootTest.java index 2b0101d20..2a803ea3f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.extend; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.7.1 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/extend/application.properties") @SpringBootTest(classes = CmpExtendELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -33,7 +34,7 @@ public class CmpExtendELDeclSpringbootTest extends BaseTest { @Test public void testExtend() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELDeclSpringbootTest.java index 252156aa6..b1f97a9f5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/getChainName/application.properties") @SpringBootTest(classes = GetChainNameELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -34,28 +35,28 @@ public class GetChainNameELDeclSpringbootTest extends BaseTest { public void testGetChainName1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); } @Test public void testGetChainName2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("chain2", context.getData("g")); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); - Assert.assertEquals("sub5", context.getData("f")); - Assert.assertEquals("sub5_chain2", context.getData("e")); - Assert.assertEquals("sub6", context.getData("h")); - Assert.assertEquals("sub6", context.getData("j")); - Assert.assertNull(context.getData("k")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("chain2", context.getData("g")); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); + Assertions.assertEquals("sub5", context.getData("f")); + Assertions.assertEquals("sub5_chain2", context.getData("e")); + Assertions.assertEquals("sub6", context.getData("h")); + Assertions.assertEquals("sub6", context.getData("j")); + Assertions.assertNull(context.getData("k")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELDeclSpringbootTest.java index d30f7edd3..d3e5f5e8b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.ifelse; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/ifelse/application.properties") @SpringBootTest(classes = IfElseELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -34,56 +35,56 @@ public class IfElseELDeclSpringbootTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELDeclSpringbootTest.java index 715aba47f..ecde1aebe 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELDeclSpringbootTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +24,7 @@ import java.util.List; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/iterator/application.properties") @SpringBootTest(classes = IteratorELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -38,10 +39,10 @@ public class IteratorELDeclSpringbootTest extends BaseTest { public void testIt1() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain1", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("123", str); + Assertions.assertEquals("123", str); } // 迭代器带break @@ -49,10 +50,10 @@ public class IteratorELDeclSpringbootTest extends BaseTest { public void testIt2() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("12", str); + Assertions.assertEquals("12", str); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELDeclSpringbootTest.java index a83730d7b..36583df9f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.lazy; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; //spring的延迟加载在el表达形式模式下不起作用 -/*@RunWith(SpringRunner.class) +/*@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/lazy/application.properties") @SpringBootTest(classes = LazyELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -27,7 +28,7 @@ public class LazyELDeclSpringbootTest extends BaseTest { * * @Test public void testLazy() throws Exception{ LiteflowResponse response = * flowExecutor.execute2Resp("chain1", "arg"); - * Assert.assertTrue(response.isSuccess()); } + * Assertions.assertTrue(response.isSuccess()); } */ } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELDeclSpringbootTest.java index 0a4385e92..1384989db 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.lfCmpAnno; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -19,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/lfCmpAnno/application.properties") @SpringBootTest(classes = LiteflowComponentELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -32,8 +33,8 @@ public class LiteflowComponentELDeclSpringbootTest extends BaseTest { @Test public void testConfig() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELDeclSpringbootTest.java index c2b3d1968..80909b86d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/loop/application.properties") @SpringBootTest(classes = LoopELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -34,31 +35,31 @@ public class LoopELDeclSpringbootTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -66,8 +67,8 @@ public class LoopELDeclSpringbootTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } @@ -76,10 +77,10 @@ public class LoopELDeclSpringbootTest extends BaseTest { public void testLoop6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } // 测试WHILE循环中的index @@ -87,10 +88,10 @@ public class LoopELDeclSpringbootTest extends BaseTest { public void testLoop7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELDeclSpringbootTest.java index 7ce1c34fc..3a323bfb8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELDeclSpringbootTest.java @@ -5,10 +5,11 @@ import com.yomahub.liteflow.flow.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.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/monitor/application.properties") @SpringBootTest(classes = MonitorELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -36,13 +37,14 @@ public class MonitorELDeclSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Thread.sleep(10000); } - @AfterClass + @AfterAll public static void clean() { + BaseTest.cleanScanCache(); MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class); monitorBus.closeScheduler(); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclSpringbootTest.java index acf28f87d..b264ef59d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclSpringbootTest.java @@ -6,9 +6,10 @@ import cn.hutool.core.util.CharsetUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -18,7 +19,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.io.File; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/monitorFile/application.properties") @SpringBootTest(classes = MonitorFileELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +37,7 @@ public class MonitorFileELDeclSpringbootTest extends BaseTest { FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); Thread.sleep(3000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>c==>b", response.getExecuteStepStr()); + Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELDeclSpringbootTest.java index 2d5b76424..7da4b8ca7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELDeclSpringbootTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.exception.NoSuchContextBeanException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/multiContext/application.properties") @SpringBootTest(classes = MultiContextELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -38,18 +39,20 @@ public class MultiContextELDeclSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("987XYZ", checkContext.getSign()); - Assert.assertEquals(95, checkContext.getRandomId()); - Assert.assertEquals("SO12345", orderContext.getOrderNo()); - Assert.assertEquals(2, orderContext.getOrderType()); - Assert.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("987XYZ", checkContext.getSign()); + Assertions.assertEquals(95, checkContext.getRandomId()); + Assertions.assertEquals("SO12345", orderContext.getOrderNo()); + Assertions.assertEquals(2, orderContext.getOrderType()); + Assertions.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); } - @Test(expected = NoSuchContextBeanException.class) + @Test public void testMultiContext2() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); - DefaultContext context = response.getContextBean(DefaultContext.class); + Assertions.assertThrows(NoSuchContextBeanException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); + DefaultContext context = response.getContextBean(DefaultContext.class); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELDeclSpringbootTest.java index 983a4ab4f..832c9c976 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -19,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/multipleType/application.properties") @SpringBootTest(classes = LiteflowMultipleTypeELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -32,11 +33,11 @@ public class LiteflowMultipleTypeELDeclSpringbootTest extends BaseTest { @Test public void testMultipleType() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELDeclSpringbootTest.java index 10d68eb7c..66b0d8bc9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/nodeExecutor/application.properties") @SpringBootTest(classes = LiteflowNodeExecutorELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -36,9 +37,9 @@ public class LiteflowNodeExecutorELDeclSpringbootTest extends BaseTest { public void testCustomerDefaultNodeExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("a", response.getExecuteStepStr()); } // 默认执行器测试+全局重试配置测试 @@ -46,17 +47,17 @@ public class LiteflowNodeExecutorELDeclSpringbootTest extends BaseTest { public void testDefaultExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("b==>b==>b", response.getExecuteStepStr()); } // 自定义执行器测试 @Test public void testCustomerExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("c", response.getExecuteStepStr()); } // 自定义执行器测试+全局重试配置测试 @@ -64,9 +65,9 @@ public class LiteflowNodeExecutorELDeclSpringbootTest extends BaseTest { public void testCustomExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); - Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); + Assertions.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELDeclSpringbootTest.java index d91a89ef6..ab803996e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author dongguo.tao * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parsecustom/application-custom-json.properties") @SpringBootTest(classes = CustomParserJsonELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +35,7 @@ public class CustomParserJsonELDeclSpringbootTest extends BaseTest { @Test public void testJsonCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELDeclSpringbootTest.java index 43ca21898..09125227c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author bryan.zhang * @since 2.5.7 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parsecustom/application-custom-xml.properties") @SpringBootTest(classes = CustomParserXmlELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +35,7 @@ public class CustomParserXmlELDeclSpringbootTest extends BaseTest { @Test public void testXmlCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELDeclSpringbootTest.java index 32af794e6..9b7c996fd 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parser/application-json.properties") @SpringBootTest(classes = JsonParserELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -32,7 +33,7 @@ public class JsonParserELDeclSpringbootTest extends BaseTest { @Test public void testJsonParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELDeclSpringbootTest.java index 31c31aaae..d1e938319 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; @@ -13,7 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parser/application-springEL.properties") @SpringBootTest(classes = SpringELSupportELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -26,7 +27,7 @@ public class SpringELSupportELDeclSpringbootTest extends BaseTest { @Test public void testSpringELParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELDeclSpringbootTest.java index 3de6b0e07..1144405da 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parser/application-xml.properties") @SpringBootTest(classes = XmlParserELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -32,7 +33,7 @@ public class XmlParserELDeclSpringbootTest extends BaseTest { @Test public void testXmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELDeclSpringbootTest.java index 4966cfe5f..57259878d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/parser/application-yml.properties") @SpringBootTest(classes = YmlParserELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -32,7 +33,7 @@ public class YmlParserELDeclSpringbootTest extends BaseTest { @Test public void testYmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELDeclSpringbootTest.java index 7e3a0976b..24aeead6e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/preAndFinally/application.properties") @SpringBootTest(classes = PreAndFinallyELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -35,24 +36,24 @@ public class PreAndFinallyELDeclSpringbootTest extends BaseTest { @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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } // 测试在finally节点里是否能获取exception @@ -60,15 +61,15 @@ public class PreAndFinallyELDeclSpringbootTest extends BaseTest { public void testPreAndFinally4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(context.getData("hasEx")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue((Boolean) context.getData("hasEx")); } @Test public void testPreAndFinally5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELDeclSpringbootTest.java index c8114b848..5591ab832 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELDeclSpringbootTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/privateDelivery/application.properties") @SpringBootTest(classes = PrivateDeliveryELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -37,8 +38,8 @@ public class PrivateDeliveryELDeclSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); ConcurrentHashSet set = context.getData("testSet"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(100, set.size()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(100, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELDeclSpringbootTest.java index ccccbfb02..53ba46bf4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELDeclSpringbootTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.flow.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.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/refreshRule/application.properties") @SpringBootTest(classes = RefreshRuleELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -39,7 +40,7 @@ public class RefreshRuleELDeclSpringbootTest extends BaseTest { String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.el.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, content); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试优雅刷新的场景 @@ -59,7 +60,7 @@ public class RefreshRuleELDeclSpringbootTest extends BaseTest { for (int i = 0; i < 500; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); try { Thread.sleep(10L); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELDeclSpringbootTest.java index 16dc98249..3806eba99 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/reload/application.properties") @SpringBootTest(classes = ReloadELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +37,7 @@ public class ReloadELDeclSpringbootTest extends BaseTest { public void testReload() throws Exception { flowExecutor.reloadRule(); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELDeclSpringbootTest.java index cf56d27ec..9d996665a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.requestId; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -17,7 +18,7 @@ import javax.annotation.Resource; /** * @author tangkc */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/requestId/application.properties") @SpringBootTest(classes = LiteflowRequestIdELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -30,8 +31,8 @@ public class LiteflowRequestIdELDeclSpringbootTest extends BaseTest { @Test public void testRequestId() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1", response.getSlot().getRequestId()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1", response.getSlot().getRequestId()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELDeclSpringbootTest.java index a35ed55a7..818c973d7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import java.util.Set; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-implicit.properties") @SpringBootTest(classes = ImplicitSubFlowELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -39,15 +40,15 @@ public class ImplicitSubFlowELDeclSpringbootTest extends BaseTest { public void testImplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); // 传递了slotIndex,则set的size==1 - Assert.assertEquals(1, RUN_TIME_SLOT.size()); + Assertions.assertEquals(1, RUN_TIME_SLOT.size()); // set中第一次设置的requestId和response中的requestId一致 - Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); + Assertions.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); // requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); + Assertions.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } // 在p里多线程调用q 10次,每个q取到的参数都是不同的。 @@ -55,12 +56,12 @@ public class ImplicitSubFlowELDeclSpringbootTest extends BaseTest { public void testImplicitSubFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("c1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Set set = context.getData("test"); // requestData的取值正确 - Assert.assertEquals(10, set.size()); + Assertions.assertEquals(10, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELDeclSpringbootTest.java index 8c6f729ef..baa2c386b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELDeclSpringbootTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.MultipleParsersException; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-subInDifferentConfig1.properties") @SpringBootTest(classes = SubflowInDifferentConfigELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -37,19 +38,21 @@ public class SubflowInDifferentConfigELDeclSpringbootTest extends BaseTest { @Test public void testExplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } @Autowired private ApplicationContext context; // 主要测试有不同的配置类型后会不会报出既定的错误 - @Test(expected = MultipleParsersException.class) + @Test public void testExplicitSubFlow2() { - LiteflowConfig config = context.getBean(LiteflowConfig.class); - config.setRuleSource("subflow/flow-main.xml, subflow/flow-sub1.xml,subflow/flow-sub2.yml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(MultipleParsersException.class, () -> { + LiteflowConfig config = context.getBean(LiteflowConfig.class); + config.setRuleSource("subflow/flow-main.xml, subflow/flow-sub1.xml,subflow/flow-sub2.yml"); + flowExecutor.reloadRule(); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELDeclSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELDeclSpringBootTest.java index 457bfedd8..4a9b44043 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELDeclSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELDeclSpringBootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-json.properties") @SpringBootTest(classes = SubflowJsonELDeclSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +34,8 @@ public class SubflowJsonELDeclSpringBootTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELDeclSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELDeclSpringBootTest.java index 5fbd5a8d0..57c19686e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELDeclSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELDeclSpringBootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-xml.properties") @SpringBootTest(classes = SubflowXMLELDeclSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +34,8 @@ public class SubflowXMLELDeclSpringBootTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELDeclSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELDeclSpringBootTest.java index fffe03a46..e86dc7c94 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELDeclSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELDeclSpringBootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/subflow/application-yml.properties") @SpringBootTest(classes = SubflowYmlELDeclSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +34,8 @@ public class SubflowYmlELDeclSpringBootTest extends BaseTest { @Test public void testExplicitSubFlowYml() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/superClassDefine/SuperClassDefineELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/superClassDefine/SuperClassDefineELDeclSpringbootTest.java index 0b6faf33e..bfd2840da 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/superClassDefine/SuperClassDefineELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/superClassDefine/SuperClassDefineELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.9.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/superClassDefine/application.properties") @SpringBootTest(classes = SuperClassDefineELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -35,9 +36,9 @@ public class SuperClassDefineELDeclSpringbootTest extends BaseTest { public void testSuperClassDefine() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>d", response.getExecuteStepStr()); - Assert.assertTrue(context.getData("isAccess")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>d", response.getExecuteStepStr()); + Assertions.assertTrue((Boolean) context.getData("isAccess")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java index 22cc5f549..e65864e2e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.switchcase; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/switchcase/application.properties") @SpringBootTest(classes = SwitchELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -33,36 +34,36 @@ public class SwitchELDeclSpringbootTest extends BaseTest { @Test public void testSwitch1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); } @Test public void testSwitch2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d", response.getExecuteStepStr()); } @Test public void testSwitch3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>f==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>f==>b", response.getExecuteStepStr()); } @Test public void testSwitch4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>g==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>g==>d", response.getExecuteStepStr()); } @Test public void testSwitch5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>h==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclSpringbootJsonTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclSpringbootJsonTest.java index cf07233b9..5584dd229 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclSpringbootJsonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclSpringbootJsonTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/tag/application-json.properties") @SpringBootTest(classes = NodeTagELDeclSpringbootJsonTest.class) @EnableAutoConfiguration @@ -36,15 +37,15 @@ public class NodeTagELDeclSpringbootJsonTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -54,9 +55,9 @@ public class NodeTagELDeclSpringbootJsonTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -64,8 +65,8 @@ public class NodeTagELDeclSpringbootJsonTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclSpringbootXmlTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclSpringbootXmlTest.java index ea4d57e23..5392e4d80 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclSpringbootXmlTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELDeclSpringbootXmlTest.java @@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/tag/application-xml.properties") @SpringBootTest(classes = NodeTagELDeclSpringbootXmlTest.class) @EnableAutoConfiguration @@ -36,15 +37,15 @@ public class NodeTagELDeclSpringbootXmlTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -54,9 +55,9 @@ public class NodeTagELDeclSpringbootXmlTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -64,8 +65,8 @@ public class NodeTagELDeclSpringbootXmlTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELDeclSpringbootTest.java index 3664207ed..36d9c8c0f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELDeclSpringbootTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.3 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/useTTLInWhen/application.properties") @SpringBootTest(classes = UseTTLInWhenELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -35,11 +36,11 @@ public class UseTTLInWhenELDeclSpringbootTest extends BaseTest { public void testUseTTLInWhen() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,b", context.getData("b")); - Assert.assertEquals("hello,c", context.getData("c")); - Assert.assertEquals("hello,d", context.getData("d")); - Assert.assertEquals("hello,e", context.getData("e")); - Assert.assertEquals("hello,f", context.getData("f")); + Assertions.assertEquals("hello,b", context.getData("b")); + Assertions.assertEquals("hello,c", context.getData("c")); + Assertions.assertEquals("hello,d", context.getData("d")); + Assertions.assertEquals("hello,e", context.getData("e")); + Assertions.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclSpringbootTest1.java index c763a6388..370c13caa 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclSpringbootTest1.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.WhenTimeoutException; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/whenTimeOut/application1.properties") @SpringBootTest(classes = WhenTimeOutELDeclSpringbootTest1.class) @EnableAutoConfiguration @@ -39,8 +40,8 @@ public class WhenTimeOutELDeclSpringbootTest1 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclSpringbootTest2.java index 36f5c3b18..d632bb02b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELDeclSpringbootTest2.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -22,7 +23,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/whenTimeOut/application2.properties") @SpringBootTest(classes = WhenTimeOutELDeclSpringbootTest2.class) @EnableAutoConfiguration @@ -38,7 +39,7 @@ public class WhenTimeOutELDeclSpringbootTest2 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/java/com/yomahub/liteflow/test/etcd/EtcdWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/java/com/yomahub/liteflow/test/etcd/EtcdWithXmlELSpringbootTest.java index 33d61b6f3..64f6dfdcb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/java/com/yomahub/liteflow/test/etcd/EtcdWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/java/com/yomahub/liteflow/test/etcd/EtcdWithXmlELSpringbootTest.java @@ -7,16 +7,15 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.parser.etcd.EtcdClient; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.*; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.MockitoAnnotations; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.util.List; import static org.mockito.Mockito.*; @@ -24,7 +23,7 @@ import static org.mockito.Mockito.*; /** * springboot环境下的etcd 规则解析器 测试 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/etcd/application-xml-cluster.properties") @SpringBootTest(classes = EtcdWithXmlELSpringbootTest.class) @EnableAutoConfiguration @@ -43,12 +42,12 @@ public class EtcdWithXmlELSpringbootTest extends BaseTest { private static final String SCRIPT_PATH = "/liteflow/script"; - @Before + @BeforeEach public void setUp() { MockitoAnnotations.initMocks(this); } - @After + @AfterEach public void after() { FlowBus.cleanCache(); } @@ -66,9 +65,9 @@ public class EtcdWithXmlELSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>s1[脚本s1]", response.getExecuteStepStr()); - Assert.assertEquals("hello", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>s1[脚本s1]", response.getExecuteStepStr()); + Assertions.assertEquals("hello", context.getData("test")); } @Test @@ -88,17 +87,17 @@ public class EtcdWithXmlELSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>s1[脚本s1]", response.getExecuteStepStr()); - Assert.assertEquals("hello", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>s1[脚本s1]", response.getExecuteStepStr()); + Assertions.assertEquals("hello", context.getData("test")); flowExecutor.reloadRule(); LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context2 = response2.getFirstContextBean(); - Assert.assertTrue(response2.isSuccess()); - Assert.assertEquals("a==>b==>s1[脚本s1]", response2.getExecuteStepStr()); - Assert.assertEquals("hello world", context2.getData("test")); + Assertions.assertTrue(response2.isSuccess()); + Assertions.assertEquals("a==>b==>s1[脚本s1]", response2.getExecuteStepStr()); + Assertions.assertEquals("hello world", context2.getData("test")); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/nacos/NacosWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/nacos/NacosWithXmlELSpringbootTest.java index 1f5a97f2d..1e33174eb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/nacos/NacosWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/nacos/NacosWithXmlELSpringbootTest.java @@ -1,27 +1,22 @@ package com.yomahub.liteflow.test.nacos; import com.alibaba.nacos.client.config.NacosConfigService; -import com.alibaba.nacos.client.config.impl.LocalConfigInfoProcessor; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.parser.nacos.util.NacosParserHelper; -import com.yomahub.liteflow.parser.nacos.vo.NacosParserVO; import com.yomahub.liteflow.test.BaseTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; - import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.when; @@ -31,7 +26,7 @@ import static org.mockito.Mockito.when; * @author mll * @since 2.9.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/nacos/application-xml.properties") @SpringBootTest(classes = NacosWithXmlELSpringbootTest.class) @EnableAutoConfiguration @@ -44,7 +39,7 @@ public class NacosWithXmlELSpringbootTest extends BaseTest { @MockBean private NacosConfigService nacosConfigService; - @After + @AfterEach public void after() { FlowBus.cleanCache(); } @@ -55,7 +50,7 @@ public class NacosWithXmlELSpringbootTest extends BaseTest { when(nacosConfigService.getConfig(anyString(), anyString(), anyLong())).thenReturn(flowXml); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStrWithoutTime()); } @Test @@ -66,12 +61,12 @@ public class NacosWithXmlELSpringbootTest extends BaseTest { .thenReturn(changedFlowXml); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStrWithoutTime()); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, changedFlowXml); response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertEquals("a==>c", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-nospring/pom.xml index 01a8ffe63..4020d12a6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/pom.xml @@ -25,9 +25,8 @@ test - junit - junit - test + org.junit.jupiter + junit-jupiter org.apache.curator diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 1acabc13f..a9494a2aa 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { FlowBus.cleanCache(); ExecutorHelper.loadInstance().clearExecutorServiceMap(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java index 537fb9ceb..120c3984a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下异步线程超时日志打印测试 @@ -19,7 +19,7 @@ public class AbsoluteConfigPathTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("/usr/local/flow2.xml"); @@ -29,7 +29,7 @@ public class AbsoluteConfigPathTest extends BaseTest { @Test public void testAbsoluteConfig() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeTest.java index d538d1b74..a15432ec0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeTest.java @@ -8,9 +8,9 @@ import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试隐式调用子流程 单元测试 @@ -21,7 +21,7 @@ public class AsyncNodeTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("asyncNode/flow.el.xml"); @@ -34,7 +34,7 @@ public class AsyncNodeTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -42,7 +42,7 @@ public class AsyncNodeTest extends BaseTest { @Test public void testAsyncFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); - Assert.assertTrue( + Assertions.assertTrue( ListUtil .toList("b==>j==>g==>f==>h", "b==>j==>g==>h==>f", "b==>j==>h==>g==>f", "b==>j==>h==>f==>g", "b==>j==>f==>h==>g", "b==>j==>f==>g==>h") @@ -53,15 +53,15 @@ public class AsyncNodeTest extends BaseTest { @Test public void testAsyncFlow3_1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(response.getSlot().getException().getClass(), TestException.class); } // 测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @@ -70,12 +70,12 @@ public class AsyncNodeTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 因为不记录错误,所以最终结果是true - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 因为配置了不抛错,所以response里的cause应该为null - Assert.assertNull(response.getCause()); + Assertions.assertNull(response.getCause()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @@ -84,12 +84,12 @@ public class AsyncNodeTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 整个并行组是报错的,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 因为第一个when配置了会报错,所以response里的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @@ -98,12 +98,12 @@ public class AsyncNodeTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 第一个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(1), count); + Assertions.assertEquals(1, count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @@ -112,12 +112,12 @@ public class AsyncNodeTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 第二个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 测试任意异步一个执行完即继续的场景 @@ -128,8 +128,8 @@ public class AsyncNodeTest extends BaseTest { public void testAsyncFlow8() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("check").toString().startsWith("habc")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/base/BaseCommonTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/base/BaseCommonTest.java index e3f91c408..f19a20b06 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/base/BaseCommonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/base/BaseCommonTest.java @@ -5,15 +5,15 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class BaseCommonTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("base/flow.el.xml"); @@ -23,7 +23,7 @@ public class BaseCommonTest extends BaseTest { @Test public void testBase() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "test0"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/builder/BuilderTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/builder/BuilderTest.java index e3acc5f74..4f4eaffc6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/builder/BuilderTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/builder/BuilderTest.java @@ -10,15 +10,15 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.builder.cmp.*; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class BuilderTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); flowExecutor = FlowExecutorHolder.loadInstance(config); @@ -78,8 +78,8 @@ public class BuilderTest extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } // 基于普通组件的builder模式测试 @@ -136,8 +136,8 @@ public class BuilderTest extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } // 基于普通组件的builder模式测试 @@ -171,8 +171,8 @@ public class BuilderTest extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(a1,c2,a2,c1)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryTest.java index f8ed19cea..e1ee7b9cd 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试非spring下的节点执行器 @@ -19,7 +19,7 @@ public class LiteflowRetryTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("cmpRetry/flow.el.xml"); @@ -32,31 +32,31 @@ public class LiteflowRetryTest extends BaseTest { @Test public void testRetry1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } // 单个组件重试配置测试 @Test public void testRetry2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } // 单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); } // 单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java index de3306efc..07e933e24 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.entity.CmpStep; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.*; @@ -16,7 +16,7 @@ public class CmpStepTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("cmpStep/flow.el.xml"); @@ -26,31 +26,31 @@ public class CmpStepTest extends BaseTest { @Test public void testStep1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test public void testStep2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } @Test public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Map> stepMap = response.getExecuteSteps(); - Assert.assertEquals(2, stepMap.size()); + Assertions.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); - Assert.assertEquals(5, queue.size()); + Assertions.assertEquals(5, queue.size()); Set tagSet = new HashSet<>(); response.getExecuteStepQueue() @@ -58,7 +58,7 @@ public class CmpStepTest extends BaseTest { .filter(cmpStep -> cmpStep.getNodeId().equals("a")) .forEach(cmpStep -> tagSet.add(cmpStep.getTag())); - Assert.assertEquals(3, tagSet.size()); + Assertions.assertEquals(3, tagSet.size()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeTest.java index b48125f61..e2badc7f7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试注释 @@ -17,7 +17,7 @@ public class LiteflowNodeTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("comments/flow.el.xml"); @@ -28,8 +28,8 @@ public class LiteflowNodeTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java index de97af781..1914ceeba 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 组件功能点测试 单元测试 @@ -18,7 +18,7 @@ public class FlowExecutorTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("component/flow.el.xml"); @@ -29,56 +29,58 @@ public class FlowExecutorTest extends BaseTest { @Test public void testIsAccess() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); - Assert.assertTrue(response.isSuccess()); - Assert.assertNotNull(response.getSlot().getResponseData()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNotNull(response.getSlot().getResponseData()); } // 组件抛错的功能点测试 - @Test(expected = ArithmeticException.class) + @Test public void testComponentException() throws Throwable { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("/ by zero", response.getMessage()); - throw response.getCause(); + Assertions.assertThrows(ArithmeticException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("/ by zero", response.getMessage()); + throw response.getCause(); + }); } // isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Throwable { LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCause()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCause()); } // isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d", response.getExecuteStepStr()); } // setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("e", response.getExecuteStepStr()); } // 条件组件的功能点测试 @Test public void testNodeCondComponent() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigTest1.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigTest1.java index 6c7ba197c..e8364f4e8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigTest1.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.concurrent.TimeUnit; @@ -22,7 +22,7 @@ public class LiteflowConfigTest1 extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("config/flow.el.xml"); @@ -33,17 +33,17 @@ public class LiteflowConfigTest1 extends BaseTest { public void testConfig() { LiteflowConfig config = LiteflowConfigGetter.get(); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("config/flow.el.xml", config.getRuleSource()); - Assert.assertEquals(15000, config.getWhenMaxWaitTime().intValue()); - Assert.assertEquals(TimeUnit.MILLISECONDS, config.getWhenMaxWaitTimeUnit()); - Assert.assertEquals(200, config.getQueueLimit().intValue()); - Assert.assertEquals(300000L, config.getDelay().longValue()); - Assert.assertEquals(300000L, config.getPeriod().longValue()); - Assert.assertFalse(config.getEnableLog()); - Assert.assertEquals(16, config.getWhenMaxWorkers().longValue()); - Assert.assertEquals(512, config.getWhenQueueLimit().longValue()); - Assert.assertEquals(true, config.isParseOnStart()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("config/flow.el.xml", config.getRuleSource()); + Assertions.assertEquals(15000, config.getWhenMaxWaitTime().intValue()); + Assertions.assertEquals(TimeUnit.MILLISECONDS, config.getWhenMaxWaitTimeUnit()); + Assertions.assertEquals(200, config.getQueueLimit().intValue()); + Assertions.assertEquals(300000L, config.getDelay().longValue()); + Assertions.assertEquals(300000L, config.getPeriod().longValue()); + Assertions.assertFalse(config.getEnableLog()); + Assertions.assertEquals(16, config.getWhenMaxWorkers().longValue()); + Assertions.assertEquals(512, config.getWhenQueueLimit().longValue()); + Assertions.assertEquals(true, config.isParseOnStart()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolTest.java index 6a6ae34c5..32349e335 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * nospring环境下异步线程超时日志打印测试 @@ -20,7 +20,7 @@ public class CustomWhenThreadPoolTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("customWhenThreadPool/flow.el.xml"); @@ -34,8 +34,8 @@ public class CustomWhenThreadPoolTest extends BaseTest { public void testGlobalThreadPool() { LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -45,8 +45,8 @@ public class CustomWhenThreadPoolTest extends BaseTest { public void testGlobalAndCustomWhenThreadPool() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response1.getFirstContextBean(); - Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } /** @@ -59,8 +59,8 @@ public class CustomWhenThreadPoolTest extends BaseTest { // chain配置同一个thead1 LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response2.getFirstContextBean(); - Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response2.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java index 308e27e1f..df70cd1fa 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java @@ -6,15 +6,15 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class EventTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("event/flow.el.xml"); @@ -26,8 +26,8 @@ public class EventTest extends BaseTest { public void testEvent1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("abc", context.getData("test")); } // 测试组件失败事件 @@ -35,10 +35,10 @@ public class EventTest extends BaseTest { public void testEvent2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", context.getData("test")); - Assert.assertEquals("error:d", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("ab", context.getData("test")); + Assertions.assertEquals("error:d", context.getData("error")); } // 测试组件失败事件本身抛出异常 @@ -46,10 +46,10 @@ public class EventTest extends BaseTest { public void testEvent3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", context.getData("test")); - Assert.assertEquals("error:e", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("a", context.getData("test")); + Assertions.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception1Test.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception1Test.java index 3f5daab64..588eb0b7a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception1Test.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception1Test.java @@ -12,9 +12,9 @@ import com.yomahub.liteflow.exception.FlowExecutorNotInitException; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 流程执行异常 单元测试 @@ -25,7 +25,7 @@ public class Exception1Test extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("exception/flow.el.xml"); @@ -36,24 +36,30 @@ public class Exception1Test extends BaseTest { /** * 验证 chain 节点重复的异常 */ - @Test(expected = ChainDuplicateException.class) + @Test public void testChainDuplicateException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-exception.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(ChainDuplicateException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-exception.el.xml"); + flowExecutor.reloadRule(); + }); } - @Test(expected = ConfigErrorException.class) + @Test public void testConfigErrorException() { - flowExecutor.setLiteflowConfig(null); - flowExecutor.reloadRule(); + Assertions.assertThrows(ConfigErrorException.class, () -> { + flowExecutor.setLiteflowConfig(null); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testFlowExecutorNotInitException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("error/flow.txt"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("error/flow.txt"); + flowExecutor.reloadRule(); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception2Test.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception2Test.java index 69b9116cf..93204fd85 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception2Test.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception2Test.java @@ -10,9 +10,9 @@ import com.yomahub.liteflow.exception.NoSwitchTargetNodeException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 流程执行异常 单元测试 @@ -23,7 +23,7 @@ public class Exception2Test extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("exception/flow.el.xml"); @@ -31,55 +31,63 @@ public class Exception2Test extends BaseTest { flowExecutor = FlowExecutorHolder.loadInstance(config); } - @Test(expected = ChainNotFoundException.class) + @Test public void testChainNotFoundException() throws Exception { - flowExecutor.execute("chain0", "it's a request"); + Assertions.assertThrows(ChainNotFoundException.class, () -> { + flowExecutor.execute("chain0", "it's a request"); + }); } - @Test(expected = RuntimeException.class) + @Test public void testComponentCustomException() throws Exception { - flowExecutor.execute("chain1", "exception"); + Assertions.assertThrows(RuntimeException.class, () -> { + flowExecutor.execute("chain1", "exception"); + }); } - @Test(expected = FlowSystemException.class) + @Test public void testNoConditionInChainException() throws Throwable { - LiteFlowChainELBuilder.createChain().setChainId("chain2").build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "test"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("no conditionList in this chain[chain2]", response.getMessage()); - throw response.getCause(); + Assertions.assertThrows(FlowSystemException.class, () -> { + LiteFlowChainELBuilder.createChain().setChainId("chain2").build(); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "test"); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("no conditionList in this chain[chain2]", response.getMessage()); + throw response.getCause(); + }); } @Test public void testGetSlotFromResponseWhenException() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); - Assert.assertFalse(response.isSuccess()); - Assert.assertNotNull(response.getCause()); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertNotNull(response.getSlot()); } - @Test(expected = NoSwitchTargetNodeException.class) + @Test public void testNoTargetFindException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); - Assert.assertFalse(response.isSuccess()); - throw response.getCause(); + Assertions.assertThrows(NoSwitchTargetNodeException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); + Assertions.assertFalse(response.isSuccess()); + throw response.getCause(); + }); } @Test public void testInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "custom-stateful-exception"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("300", response.getCode()); - Assert.assertNotNull(response.getCause()); - Assert.assertTrue(response.getCause() instanceof LiteFlowException); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("300", response.getCode()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertTrue(response.getCause() instanceof LiteFlowException); + Assertions.assertNotNull(response.getSlot()); } @Test public void testNotInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "test"); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCode()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCode()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureTest.java index 14d1412f3..ffaac24fb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.concurrent.Future; @@ -22,7 +22,7 @@ public class Executor2FutureTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("execute2Future/flow.el.xml"); @@ -33,7 +33,7 @@ public class Executor2FutureTest extends BaseTest { public void testFuture() throws Exception { Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); LiteflowResponse response = future.get(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaTest.java index aa4d2e454..2f485178f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaTest.java @@ -8,15 +8,15 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.flowmeta.cmp2.DCmp; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class FlowMetaTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("flowmeta/flow.el.xml"); @@ -29,8 +29,8 @@ public class FlowMetaTest extends BaseTest { public void testFlowMeta() { FlowBus.addNode("d", "d组件", NodeTypeEnum.COMMON, DCmp.class); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>d[d组件]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>d[d组件]", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELTest.java index 038b996c4..4f5287506 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * nospring环境获取ChainName的测试 @@ -19,7 +19,7 @@ public class GetChainNameELTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("getChainName/flow.el.xml"); @@ -30,28 +30,28 @@ public class GetChainNameELTest extends BaseTest { public void testGetChainName1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); } @Test public void testGetChainName2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("chain2", context.getData("g")); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); - Assert.assertEquals("sub5", context.getData("f")); - Assert.assertEquals("sub5_chain2", context.getData("e")); - Assert.assertEquals("sub6", context.getData("h")); - Assert.assertEquals("sub6", context.getData("j")); - Assert.assertNull(context.getData("k")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("chain2", context.getData("g")); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); + Assertions.assertEquals("sub5", context.getData("f")); + Assertions.assertEquals("sub5_chain2", context.getData("e")); + Assertions.assertEquals("sub6", context.getData("h")); + Assertions.assertEquals("sub6", context.getData("j")); + Assertions.assertNull(context.getData("k")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseTest.java index c2a2d583c..ef70159e5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseTest.java @@ -5,15 +5,15 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class IfElseTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("ifelse/flow.el.xml"); @@ -24,56 +24,56 @@ public class IfElseTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/iterator/IteratorTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/iterator/IteratorTest.java index 884281ec7..4f452b2d7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/iterator/IteratorTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/iterator/IteratorTest.java @@ -7,9 +7,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.List; @@ -17,7 +17,7 @@ public class IteratorTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("iterator/flow.xml"); @@ -29,10 +29,10 @@ public class IteratorTest extends BaseTest { public void testIt1() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain1", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("123", str); + Assertions.assertEquals("123", str); } // 迭代器带break @@ -40,10 +40,10 @@ public class IteratorTest extends BaseTest { public void testIt2() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("12", str); + Assertions.assertEquals("12", str); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/loop/LoopTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/loop/LoopTest.java index a35bb9735..ec243a084 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/loop/LoopTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/loop/LoopTest.java @@ -6,15 +6,15 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class LoopTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("loop/flow.xml"); @@ -25,31 +25,31 @@ public class LoopTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -57,8 +57,8 @@ public class LoopTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } @@ -67,10 +67,10 @@ public class LoopTest extends BaseTest { public void testLoop6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } // 测试WHILE循环中的index @@ -78,10 +78,10 @@ public class LoopTest extends BaseTest { public void testLoop7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/LiteflowMonitorFileTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/LiteflowMonitorFileTest.java index 3ca2731f7..07e4a7f1a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/LiteflowMonitorFileTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/LiteflowMonitorFileTest.java @@ -8,9 +8,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.io.File; @@ -18,7 +18,7 @@ public class LiteflowMonitorFileTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("monitorFile/flow.el.xml"); @@ -34,7 +34,7 @@ public class LiteflowMonitorFileTest extends BaseTest { FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); Thread.sleep(3000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>c==>b", response.getExecuteStepStr()); + Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeTest.java index dfcbc6bcb..b0d0d522a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试非spring下混合格式规则的场景 @@ -19,7 +19,7 @@ public class LiteflowMultipleTypeTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("multipleType/flow.el.xml,multipleType/flow.el.yml"); @@ -30,11 +30,11 @@ public class LiteflowMultipleTypeTest extends BaseTest { @Test public void testMultipleType() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorTest.java index 0bdecdb97..9d09c8bdd 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试非spring环境下的自定义组件执行器 @@ -20,7 +20,7 @@ public class LiteflowNodeExecutorTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("nodeExecutor/flow.el.xml"); @@ -35,9 +35,9 @@ public class LiteflowNodeExecutorTest extends BaseTest { public void testCustomerDefaultNodeExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("a", response.getExecuteStepStr()); } // 默认执行器测试+全局重试配置测试 @@ -45,17 +45,17 @@ public class LiteflowNodeExecutorTest extends BaseTest { public void testDefaultExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("b==>b==>b", response.getExecuteStepStr()); } // 自定义执行器测试 @Test public void testCustomerExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("c", response.getExecuteStepStr()); } // 自定义执行器测试+全局重试配置测试 @@ -63,9 +63,9 @@ public class LiteflowNodeExecutorTest extends BaseTest { public void testCustomExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); - Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); + Assertions.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java index 2aac6e706..847fd48d4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import com.yomahub.liteflow.test.BaseTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 单元测试:传递null param导致NPE的优化代码 @@ -14,11 +15,11 @@ import org.junit.Test; * @author LeoLee * @since 2.6.6 */ -public class NullParamTest { +public class NullParamTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("nullParam/flow.el.xml"); @@ -31,7 +32,7 @@ public class NullParamTest { @Test public void testNullParam() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonTest.java index 6bd18a78d..4cf6f27ed 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境的自定义json parser单元测试 @@ -19,7 +19,7 @@ public class CustomParserJsonTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("com.yomahub.liteflow.test.parsecustom.parser.CustomJsonFlowParser"); @@ -30,7 +30,7 @@ public class CustomParserJsonTest extends BaseTest { @Test public void testJsonCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlTest.java index aaaf83d7e..df24bf390 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境的自定义xml parser单元测试 @@ -19,7 +19,7 @@ public class CustomParserXmlTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("com.yomahub.liteflow.test.parsecustom.parser.CustomXmlFlowParser"); @@ -30,7 +30,7 @@ public class CustomParserXmlTest extends BaseTest { @Test public void testXmlCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/JsonParserTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/JsonParserTest.java index 3aa7e4ac9..21410c9e8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/JsonParserTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/JsonParserTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境的json parser单元测试 @@ -19,7 +19,7 @@ public class JsonParserTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("parser/flow.el.json"); @@ -30,7 +30,7 @@ public class JsonParserTest extends BaseTest { @Test public void testJsonParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/XmlParserTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/XmlParserTest.java index 585b23e08..ab58e5b08 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/XmlParserTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/XmlParserTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境的xml parser单元测试 @@ -19,7 +19,7 @@ public class XmlParserTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("parser/flow.el.xml"); @@ -30,7 +30,7 @@ public class XmlParserTest extends BaseTest { @Test public void testXmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/YmlParserTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/YmlParserTest.java index 7d1a76000..43aa68ed4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/YmlParserTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/parser/YmlParserTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring下的yml parser测试用例 @@ -19,7 +19,7 @@ public class YmlParserTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("parser/flow.el.yml"); @@ -30,7 +30,7 @@ public class YmlParserTest extends BaseTest { @Test public void testYmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyTest.java index dc986bd1f..319cf45a7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下pre节点和finally节点的测试 @@ -20,7 +20,7 @@ public class PreAndFinallyTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("preAndFinally/flow.el.xml"); @@ -31,24 +31,24 @@ public class PreAndFinallyTest extends BaseTest { @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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } // 测试在finally节点里是否能获取exception @@ -56,15 +56,15 @@ public class PreAndFinallyTest extends BaseTest { public void testPreAndFinally4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(context.getData("hasEx")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue((Boolean) context.getData("hasEx")); } @Test public void testPreAndFinally5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryTest.java index 0e919db7e..d578e6eeb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryTest.java @@ -7,9 +7,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下隐私投递的测试 @@ -21,7 +21,7 @@ public class PrivateDeliveryTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("privateDelivery/flow.el.xml"); @@ -33,8 +33,8 @@ public class PrivateDeliveryTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); ConcurrentHashSet set = context.getData("testSet"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(100, set.size()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(100, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleTest.java index e219333c2..1af2def91 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleTest.java @@ -8,9 +8,9 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下重新加载规则测试 @@ -22,7 +22,7 @@ public class RefreshRuleTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("refreshRule/flow.el.xml"); @@ -35,7 +35,7 @@ public class RefreshRuleTest extends BaseTest { String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.el.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, content); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试优雅刷新的场景 @@ -55,7 +55,7 @@ public class RefreshRuleTest extends BaseTest { for (int i = 0; i < 500; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); try { Thread.sleep(10L); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/reload/ReloadTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/reload/ReloadTest.java index 92bb2ff80..2f32f1e9c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/reload/ReloadTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/reload/ReloadTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下重新加载规则测试 @@ -19,7 +19,7 @@ public class ReloadTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("reload/flow.el.xml"); @@ -32,7 +32,7 @@ public class ReloadTest extends BaseTest { public void testReload() throws Exception { flowExecutor.reloadRule(); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainTest.java index 2e3601e26..f0c24847b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainTest.java @@ -6,15 +6,15 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class RemoveChainTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("removeChain/flow.el.xml"); @@ -24,10 +24,10 @@ public class RemoveChainTest extends BaseTest { @Test public void testRemoveChain() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response1.isSuccess()); + Assertions.assertTrue(response1.isSuccess()); FlowBus.removeChain("chain1"); LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response2.isSuccess()); + Assertions.assertFalse(response2.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdSpringbootTest.java index 9aed59236..4d7fefd92 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdSpringbootTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * @author tangkc @@ -16,7 +16,7 @@ public class LiteflowRequestIdSpringbootTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("requestId/flow.el.xml"); @@ -27,8 +27,8 @@ public class LiteflowRequestIdSpringbootTest extends BaseTest { @Test public void testRequestId() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1", response.getSlot().getRequestId()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1", response.getSlot().getRequestId()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotTest.java index bc3fdbdcf..5e972ccec 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotTest.java @@ -7,9 +7,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DataBus; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.lang.reflect.Field; import java.util.ArrayList; @@ -29,7 +29,7 @@ public class ResizeSlotTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("resizeSlot/flow.el.xml"); @@ -49,7 +49,7 @@ public class ResizeSlotTest extends BaseTest { } for (Future future : futureList) { - Assert.assertTrue(future.get().isSuccess()); + Assertions.assertTrue(future.get().isSuccess()); } // 取到static的对象QUEUE @@ -60,7 +60,7 @@ public class ResizeSlotTest extends BaseTest { // 因为初始slotSize是4,按照0.75的扩容比,要满足100个线程,应该扩容5~6次,5次=65,6次=114 // 为什么不是直接114呢? // 因为在单测中根据机器的性能,在多线程情况下,有些机器跑的慢一点,也就是说65个就足够了。有些机器跑的快一点,是能真正扩容到114个的 - Assert.assertTrue(queue.size() > 4); + Assertions.assertTrue(queue.size() > 4); } catch (Exception e) { e.printStackTrace(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowTest.java index d53279edb..b95edc1c2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.HashSet; import java.util.Set; @@ -22,7 +22,7 @@ public class ImplicitSubFlowTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("subflow/flow-implicit.el.xml"); @@ -36,15 +36,15 @@ public class ImplicitSubFlowTest extends BaseTest { public void testImplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); // 传递了slotIndex,则set的size==1 - Assert.assertEquals(1, RUN_TIME_SLOT.size()); + Assertions.assertEquals(1, RUN_TIME_SLOT.size()); // set中第一次设置的requestId和response中的requestId一致 - Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); + Assertions.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); // requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); + Assertions.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } // 在p里多线程调用q 10次,每个q取到的参数都是不同的。 @@ -52,12 +52,12 @@ public class ImplicitSubFlowTest extends BaseTest { public void testImplicitSubFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("c1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Set set = context.getData("test"); // requestData的取值正确 - Assert.assertEquals(10, set.size()); + Assertions.assertEquals(10, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigTest.java index fca6e9a68..4e34267ae 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigTest.java @@ -7,9 +7,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试主流程与子流程在不同的配置文件的场景 @@ -20,7 +20,7 @@ public class SubflowInDifferentConfigTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("subflow/flow-main.el.xml,subflow/flow-sub1.el.xml,subflow/flow-sub2.el.xml"); @@ -31,16 +31,18 @@ public class SubflowInDifferentConfigTest extends BaseTest { @Test public void testExplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } // 主要测试有不同的配置类型后会不会报出既定的错误 - @Test(expected = MultipleParsersException.class) + @Test public void testExplicitSubFlow2() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.yml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(MultipleParsersException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.yml"); + flowExecutor.reloadRule(); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonTest.java index 0d523b3c0..596a84b47 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试显示调用子流程(json) 单元测试 @@ -18,7 +18,7 @@ public class SubflowJsonTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("subflow/flow.el.json"); @@ -29,8 +29,8 @@ public class SubflowJsonTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLTest.java index 63f394b09..b4a3411f0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试显示调用子流程(xml) 单元测试 @@ -18,7 +18,7 @@ public class SubflowXMLTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("subflow/flow.el.xml"); @@ -29,8 +29,8 @@ public class SubflowXMLTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlTest.java index deaae1534..ee526f59f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlTest.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 测试显示调用子流程(yml) 单元测试 @@ -18,7 +18,7 @@ public class SubflowYmlTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("subflow/flow.el.yml"); @@ -29,8 +29,8 @@ public class SubflowYmlTest extends BaseTest { @Test public void testExplicitSubFlowYml() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java index 8c0532551..f4065f214 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java @@ -5,15 +5,15 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class SwitchTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("switchcase/flow.el.xml"); @@ -23,36 +23,36 @@ public class SwitchTest extends BaseTest { @Test public void testSwitch1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); } @Test public void testSwitch2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d", response.getExecuteStepStr()); } @Test public void testSwitch3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>f==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>f==>b", response.getExecuteStepStr()); } @Test public void testSwitch4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>g==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>g==>d", response.getExecuteStepStr()); } @Test public void testSwitch5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>h==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagJsonTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagJsonTest.java index 5ae9809bb..5ff8ea017 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagJsonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagJsonTest.java @@ -7,9 +7,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下组件标签的测试 @@ -21,7 +21,7 @@ public class NodeTagJsonTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("tag/flow.el.json"); @@ -32,15 +32,15 @@ public class NodeTagJsonTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -50,9 +50,9 @@ public class NodeTagJsonTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -60,8 +60,8 @@ public class NodeTagJsonTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagXmlTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagXmlTest.java index 1dd75078d..bdb5ebc70 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagXmlTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagXmlTest.java @@ -7,9 +7,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下组件标签的测试 @@ -21,7 +21,7 @@ public class NodeTagXmlTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("tag/flow.el.xml"); @@ -32,15 +32,15 @@ public class NodeTagXmlTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -50,9 +50,9 @@ public class NodeTagXmlTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -60,8 +60,8 @@ public class NodeTagXmlTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenTest.java index 628b30e9d..054a3351e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenTest.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 在when异步节点的情况下去拿ThreadLocal里的测试场景 @@ -20,7 +20,7 @@ public class UseTTLInWhenTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("useTTLInWhen/flow.el.xml"); @@ -31,11 +31,11 @@ public class UseTTLInWhenTest extends BaseTest { public void testUseTTLInWhen() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,b", context.getData("b")); - Assert.assertEquals("hello,c", context.getData("c")); - Assert.assertEquals("hello,d", context.getData("d")); - Assert.assertEquals("hello,e", context.getData("e")); - Assert.assertEquals("hello,f", context.getData("f")); + Assertions.assertEquals("hello,b", context.getData("b")); + Assertions.assertEquals("hello,c", context.getData("c")); + Assertions.assertEquals("hello,d", context.getData("d")); + Assertions.assertEquals("hello,e", context.getData("e")); + Assertions.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest1.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest1.java index f81d73e33..85dff4fcb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest1.java @@ -6,9 +6,9 @@ import com.yomahub.liteflow.exception.WhenTimeoutException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下异步线程超时日志打印测试 @@ -20,7 +20,7 @@ public class WhenTimeOutTest1 extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("whenTimeOut/flow1.el.xml"); @@ -32,8 +32,8 @@ public class WhenTimeOutTest1 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest2.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest2.java index ad18b6753..67315416c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest2.java @@ -5,9 +5,9 @@ import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * 非spring环境下异步线程超时日志打印测试 @@ -19,7 +19,7 @@ public class WhenTimeOutTest2 extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("whenTimeOut/flow2.el.xml"); @@ -31,7 +31,7 @@ public class WhenTimeOutTest2 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-aviator-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-aviator-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-aviator-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-aviator-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-aviator-springboot/src/test/java/com/yomahub/liteflow/test/script/aviator/common/ScriptAviatorCommonELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-aviator-springboot/src/test/java/com/yomahub/liteflow/test/script/aviator/common/ScriptAviatorCommonELTest.java index 76067318b..8a4985bd0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-aviator-springboot/src/test/java/com/yomahub/liteflow/test/script/aviator/common/ScriptAviatorCommonELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-aviator-springboot/src/test/java/com/yomahub/liteflow/test/script/aviator/common/ScriptAviatorCommonELTest.java @@ -4,15 +4,14 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -21,7 +20,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.9.5 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/common/application.properties") @SpringBootTest(classes = ScriptAviatorCommonELTest.class) @EnableAutoConfiguration @@ -36,8 +35,8 @@ public class ScriptAviatorCommonELTest extends BaseTest { public void testCommon1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Long.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Long.valueOf(6), context.getData("s1")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/common/LiteflowXmlScriptCommonELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/common/LiteflowXmlScriptCommonELTest.java index 46013f8db..617a98598 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/common/LiteflowXmlScriptCommonELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/common/LiteflowXmlScriptCommonELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author zendwang * @since 2.9.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/common/application.properties") @SpringBootTest(classes = LiteflowXmlScriptCommonELTest.class) @EnableAutoConfiguration @@ -36,8 +37,8 @@ public class LiteflowXmlScriptCommonELTest extends BaseTest { public void testCommon1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(11), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(11), context.getData("s1")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/contextbean/LiteFlowScriptContextbeanGraaljsTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/contextbean/LiteFlowScriptContextbeanGraaljsTest.java index 13ecb6c1f..f7fefa6de 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/contextbean/LiteFlowScriptContextbeanGraaljsTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/contextbean/LiteFlowScriptContextbeanGraaljsTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.script.graaljs.contextbean.bean.CheckContext; import com.yomahub.liteflow.test.script.graaljs.contextbean.bean.Order2Context; import com.yomahub.liteflow.test.script.graaljs.contextbean.bean.OrderContext; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -17,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/contextbean/application.properties") @SpringBootTest(classes = LiteFlowScriptContextbeanGraaljsTest.class) @EnableAutoConfiguration @@ -32,13 +33,13 @@ public class LiteFlowScriptContextbeanGraaljsTest extends BaseTest { public void testContextBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class, Order2Context.class); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); Order2Context order2Context = response.getContextBean(Order2Context.class); - Assert.assertEquals("order1", orderContext.getOrderNo()); - Assert.assertEquals("d", checkContext.getSign()); - Assert.assertEquals("order2", order2Context.getOrderNo()); + Assertions.assertEquals("order1", orderContext.getOrderNo()); + Assertions.assertEquals("d", checkContext.getSign()); + Assertions.assertEquals("order2", order2Context.getOrderNo()); } @Test @@ -51,7 +52,7 @@ public class LiteFlowScriptContextbeanGraaljsTest extends BaseTest { orderContext2.setOrderNo("order2"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext, orderContext2); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/ifelse/LiteFlowXmlScriptIfelseJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/ifelse/LiteFlowXmlScriptIfelseJsELTest.java index 1468cebd8..57e62f50f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/ifelse/LiteFlowXmlScriptIfelseJsELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/ifelse/LiteFlowXmlScriptIfelseJsELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.graaljs.ifelse; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/ifelse/application.properties") @SpringBootTest(classes = LiteFlowXmlScriptIfelseJsELTest.class) @EnableAutoConfiguration @@ -28,56 +29,56 @@ public class LiteFlowXmlScriptIfelseJsELTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x0==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x0==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x0==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x0==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/loop/LiteFlowXmlScriptLoopJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/loop/LiteFlowXmlScriptLoopJsELTest.java index c80b8ebe7..8140a2d51 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/loop/LiteFlowXmlScriptLoopJsELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/loop/LiteFlowXmlScriptLoopJsELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.graaljs.loop; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/loop/application.properties") @SpringBootTest(classes = LiteFlowXmlScriptLoopJsELTest.class) @EnableAutoConfiguration @@ -28,31 +29,31 @@ public class LiteFlowXmlScriptLoopJsELTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -60,8 +61,8 @@ public class LiteFlowXmlScriptLoopJsELTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/meta/LiteflowXmlScriptMetaELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/meta/LiteflowXmlScriptMetaELTest.java index 7cf0e7e31..e101f4de7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/meta/LiteflowXmlScriptMetaELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/meta/LiteflowXmlScriptMetaELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author zendwang * @since 2.9.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/meta/application.properties") @SpringBootTest(classes = LiteflowXmlScriptMetaELTest.class) @EnableAutoConfiguration @@ -35,10 +36,10 @@ public class LiteflowXmlScriptMetaELTest extends BaseTest { public void testMeta() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("chain1", context.getData("currChainId")); - Assert.assertEquals("arg", context.getData("requestData")); - Assert.assertEquals("s1", context.getData("nodeId")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("chain1", context.getData("currChainId")); + Assertions.assertEquals("arg", context.getData("requestData")); + Assertions.assertEquals("s1", context.getData("nodeId")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/refresh/LiteflowXmlScriptJsRefreshELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/refresh/LiteflowXmlScriptJsRefreshELTest.java index ffd03d985..e78e3ebca 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/refresh/LiteflowXmlScriptJsRefreshELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/refresh/LiteflowXmlScriptJsRefreshELTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,7 +24,7 @@ import javax.annotation.Resource; * @author zendwang * @since 2.9.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/refresh/application.properties") @SpringBootTest(classes = LiteflowXmlScriptJsRefreshELTest.class) @EnableAutoConfiguration @@ -38,8 +39,8 @@ public class LiteflowXmlScriptJsRefreshELTest extends BaseTest { public void testRefresh1() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s1[选择脚本]==>a", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s1[选择脚本]==>a", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /refresh/flow_update.xml"); // 进行刷新 @@ -47,8 +48,8 @@ public class LiteflowXmlScriptJsRefreshELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s1[选择脚本_改]==>b==>s2[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s1[选择脚本_改]==>b==>s2[普通脚本_新增]", responseNew.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/scriptbean/LiteFlowScriptScriptbeanJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/scriptbean/LiteFlowScriptScriptbeanJsELTest.java index 4c086fd94..e3929ea9c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/scriptbean/LiteFlowScriptScriptbeanJsELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/scriptbean/LiteFlowScriptScriptbeanJsELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptbean/application.properties") @SpringBootTest(classes = LiteFlowScriptScriptbeanJsELTest.class) @EnableAutoConfiguration @@ -29,17 +30,17 @@ public class LiteFlowScriptScriptbeanJsELTest extends BaseTest { @Test public void testScriptBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.getData("demo")); + Assertions.assertEquals("hello", context.getData("demo")); } @Test public void testScriptBean2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/scriptmethod/LiteFlowScriptScripMethodJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/scriptmethod/LiteFlowScriptScripMethodJsELTest.java index bb9ff5487..52e4f770b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/scriptmethod/LiteFlowScriptScripMethodJsELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/scriptmethod/LiteFlowScriptScripMethodJsELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptmethod/application.properties") @SpringBootTest(classes = LiteFlowScriptScripMethodJsELTest.class) @EnableAutoConfiguration @@ -29,17 +30,17 @@ public class LiteFlowScriptScripMethodJsELTest extends BaseTest { @Test public void testScriptBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.getData("demo")); + Assertions.assertEquals("hello", context.getData("demo")); } @Test public void testScriptBean2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobekobe", context.getData("demo")); + Assertions.assertEquals("hello,kobekobe", context.getData("demo")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/sw/LiteflowXmlScriptJsSwitchELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/sw/LiteflowXmlScriptJsSwitchELTest.java index b4d229b57..7e518151d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/sw/LiteflowXmlScriptJsSwitchELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graaljs-springboot/src/test/java/com/yomahub/liteflow/test/script/graaljs/sw/LiteflowXmlScriptJsSwitchELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.graaljs.sw; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author zendwang * @since 2.9.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/sw/application.properties") @SpringBootTest(classes = LiteflowXmlScriptJsSwitchELTest.class) @EnableAutoConfiguration @@ -34,8 +35,8 @@ public class LiteflowXmlScriptJsSwitchELTest extends BaseTest { @Test public void testSw1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s1[选择脚本]==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s1[选择脚本]==>a", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/cmpdata/CmpDataGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/cmpdata/CmpDataGroovyELTest.java index 5fdb7043d..029b5b3bf 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/cmpdata/CmpDataGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/cmpdata/CmpDataGroovyELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/cmpdata/application.properties") @SpringBootTest(classes = CmpDataGroovyELTest.class) @EnableAutoConfiguration @@ -35,8 +36,8 @@ public class CmpDataGroovyELTest extends BaseTest { public void testCmpData1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1995-10-01", context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1995-10-01", context.getData("s1")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteFlowXmlScriptBuilderGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteFlowXmlScriptBuilderGroovyELTest.java index dcca3e7da..083feb54a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteFlowXmlScriptBuilderGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteFlowXmlScriptBuilderGroovyELTest.java @@ -8,9 +8,10 @@ import com.yomahub.liteflow.enums.NodeTypeEnum; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -18,7 +19,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.List; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = LiteFlowXmlScriptBuilderGroovyELTest.class) @EnableAutoConfiguration public class LiteFlowXmlScriptBuilderGroovyELTest extends BaseTest { @@ -61,8 +62,8 @@ public class LiteFlowXmlScriptBuilderGroovyELTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg1"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d[组件D]==>s2[条件脚本S2]==>a[组件A]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d[组件D]==>s2[条件脚本S2]==>a[组件A]", response.getExecuteStepStr()); } // 测试通过builder方式运行普通script节点,以脚本文本的方式运行 @@ -101,10 +102,10 @@ public class LiteFlowXmlScriptBuilderGroovyELTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg1"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); List resultList = context.getData("resultList"); - Assert.assertEquals(3, resultList.size()); + Assertions.assertEquals(3, resultList.size()); } // 测试通过builder方式运行普通script节点,以file的方式运行 @@ -139,8 +140,8 @@ public class LiteFlowXmlScriptBuilderGroovyELTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg1"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d[组件D]==>s2[条件脚本S2]==>a[组件A]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d[组件D]==>s2[条件脚本S2]==>a[组件A]", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowJsonScriptFileGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowJsonScriptFileGroovyELTest.java index d2bab54f3..07fad9009 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowJsonScriptFileGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowJsonScriptFileGroovyELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/json-script-file/application.properties") @SpringBootTest(classes = LiteflowJsonScriptFileGroovyELTest.class) @EnableAutoConfiguration @@ -39,16 +40,16 @@ public class LiteflowJsonScriptFileGroovyELTest extends BaseTest { public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试条件脚本节点 @Test public void testScript2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); } // 测试脚本的热重载 @@ -56,8 +57,8 @@ public class LiteflowJsonScriptFileGroovyELTest extends BaseTest { public void testScript3() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.el.json"); // 进行刷新 @@ -65,8 +66,8 @@ public class LiteflowJsonScriptFileGroovyELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } // 测试脚本&规则平滑重载刷新 @@ -87,7 +88,7 @@ public class LiteflowJsonScriptFileGroovyELTest extends BaseTest { for (int i = 0; i < 300; i++) { LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); + Assertions.assertTrue(responseNew.isSuccess()); Thread.sleep(10L); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowJsonScriptGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowJsonScriptGroovyELTest.java index d62c0b30d..430391a1b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowJsonScriptGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowJsonScriptGroovyELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/json-script/application.properties") @SpringBootTest(classes = LiteflowJsonScriptGroovyELTest.class) @EnableAutoConfiguration @@ -39,16 +40,16 @@ public class LiteflowJsonScriptGroovyELTest extends BaseTest { public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试条件脚本节点 @Test public void testScript2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); } // 测试脚本的热重载 @@ -56,8 +57,8 @@ public class LiteflowJsonScriptGroovyELTest extends BaseTest { public void testScript3() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /json-script/flow_update.el.json"); // 进行刷新 @@ -65,8 +66,8 @@ public class LiteflowJsonScriptGroovyELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowXmlScriptFileGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowXmlScriptFileGroovyELTest.java index 673b21350..1930f144e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowXmlScriptFileGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowXmlScriptFileGroovyELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/xml-script-file/application.properties") @SpringBootTest(classes = LiteflowXmlScriptFileGroovyELTest.class) @EnableAutoConfiguration @@ -39,16 +40,16 @@ public class LiteflowXmlScriptFileGroovyELTest extends BaseTest { public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试条件脚本节点 @Test public void testScript2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); } // 测试脚本的热重载 @@ -56,8 +57,8 @@ public class LiteflowXmlScriptFileGroovyELTest extends BaseTest { public void testScript3() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.el.xml"); // 进行刷新 @@ -65,8 +66,8 @@ public class LiteflowXmlScriptFileGroovyELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } // 测试脚本&规则平滑重载刷新 @@ -87,7 +88,7 @@ public class LiteflowXmlScriptFileGroovyELTest extends BaseTest { for (int i = 0; i < 300; i++) { LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); + Assertions.assertTrue(responseNew.isSuccess()); Thread.sleep(10L); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowXmlScriptGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowXmlScriptGroovyELTest.java index 6c1667154..57436b53e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowXmlScriptGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/common/LiteflowXmlScriptGroovyELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/xml-script/application.properties") @SpringBootTest(classes = LiteflowXmlScriptGroovyELTest.class) @EnableAutoConfiguration @@ -39,16 +40,16 @@ public class LiteflowXmlScriptGroovyELTest extends BaseTest { public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试选择脚本节点 @Test public void testScript2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s2[选择脚本]==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s2[选择脚本]==>a", response.getExecuteStepStr()); } // 测试脚本的热重载 @@ -56,8 +57,8 @@ public class LiteflowXmlScriptGroovyELTest extends BaseTest { public void testScript3() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s2[选择脚本]==>a", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s2[选择脚本]==>a", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script/flow_update.el.xml"); // 进行刷新 @@ -65,8 +66,8 @@ public class LiteflowXmlScriptGroovyELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } // 测试脚本中的requestData的引用 @@ -74,8 +75,8 @@ public class LiteflowXmlScriptGroovyELTest extends BaseTest { public void testScript4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("s4:arg", context.getData("s4")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("s4:arg", context.getData("s4")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/contextbean/LiteFlowScriptContextbeanGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/contextbean/LiteFlowScriptContextbeanGroovyELTest.java index 5c0700f2b..1d8a7b433 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/contextbean/LiteFlowScriptContextbeanGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/contextbean/LiteFlowScriptContextbeanGroovyELTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.script.groovy.contextbean.bean.CheckContext; import com.yomahub.liteflow.test.script.groovy.contextbean.bean.Order2Context; import com.yomahub.liteflow.test.script.groovy.contextbean.bean.OrderContext; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -17,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/contextbean/application.properties") @SpringBootTest(classes = LiteFlowScriptContextbeanGroovyELTest.class) @EnableAutoConfiguration @@ -32,13 +33,13 @@ public class LiteFlowScriptContextbeanGroovyELTest extends BaseTest { public void testContextBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class, Order2Context.class); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); Order2Context order2Context = response.getContextBean(Order2Context.class); - Assert.assertEquals("order1", orderContext.getOrderNo()); - Assert.assertEquals("sign1", checkContext.getSign()); - Assert.assertEquals("order2", order2Context.getOrderNo()); + Assertions.assertEquals("order1", orderContext.getOrderNo()); + Assertions.assertEquals("sign1", checkContext.getSign()); + Assertions.assertEquals("order2", order2Context.getOrderNo()); } @Test @@ -51,7 +52,7 @@ public class LiteFlowScriptContextbeanGroovyELTest extends BaseTest { orderContext2.setOrderNo("order2"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext, orderContext2); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/ifelse/LiteFlowXmlScriptIfelseGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/ifelse/LiteFlowXmlScriptIfelseGroovyELTest.java index 4d8cf9f35..f41a0b02a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/ifelse/LiteFlowXmlScriptIfelseGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/ifelse/LiteFlowXmlScriptIfelseGroovyELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.groovy.ifelse; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/ifelse/application.properties") @SpringBootTest(classes = LiteFlowXmlScriptIfelseGroovyELTest.class) @EnableAutoConfiguration @@ -28,56 +29,56 @@ public class LiteFlowXmlScriptIfelseGroovyELTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x0==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x0==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x0==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x0==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/loop/LiteFlowXmlScriptLoopGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/loop/LiteFlowXmlScriptLoopGroovyELTest.java index c7bb258f6..afae9794e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/loop/LiteFlowXmlScriptLoopGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/loop/LiteFlowXmlScriptLoopGroovyELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/loop/application.properties") @SpringBootTest(classes = LiteFlowXmlScriptLoopGroovyELTest.class) @EnableAutoConfiguration @@ -29,31 +30,31 @@ public class LiteFlowXmlScriptLoopGroovyELTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -61,8 +62,8 @@ public class LiteFlowXmlScriptLoopGroovyELTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } @@ -70,10 +71,10 @@ public class LiteFlowXmlScriptLoopGroovyELTest extends BaseTest { @Test public void testLoop6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("e==>w==>w==>w", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("e==>w==>w==>w", response.getExecuteStepStr()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("jack-tom-frank", context.getData("test")); + Assertions.assertEquals("jack-tom-frank", context.getData("test")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptOrder/LiteflowScriptOrderGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptOrder/LiteflowScriptOrderGroovyELTest.java index 7f3506e9d..b2f3813c2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptOrder/LiteflowScriptOrderGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptOrder/LiteflowScriptOrderGroovyELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptOrder/application.properties") @SpringBootTest(classes = LiteflowScriptOrderGroovyELTest.class) @EnableAutoConfiguration @@ -37,7 +38,7 @@ public class LiteflowScriptOrderGroovyELTest extends BaseTest { @Test public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptbean/LiteFlowScriptScriptbeanGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptbean/LiteFlowScriptScriptbeanGroovyELTest.java index b9c6520c3..2cf256c31 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptbean/LiteFlowScriptScriptbeanGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptbean/LiteFlowScriptScriptbeanGroovyELTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.script.ScriptBeanManager; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -19,7 +20,7 @@ import javax.annotation.Resource; import java.util.HashMap; import java.util.Map; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptbean/application.properties") @SpringBootTest(classes = LiteFlowScriptScriptbeanGroovyELTest.class) @EnableAutoConfiguration @@ -33,51 +34,51 @@ public class LiteFlowScriptScriptbeanGroovyELTest extends BaseTest { @Test public void testScriptBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.getData("demo")); + Assertions.assertEquals("hello", context.getData("demo")); } @Test public void testScriptBean2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } // 测试scriptBean includeMethodName配置包含情况下 @Test public void testScriptBean3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } // 测试scriptBean includeMethodName配置不包含情况下 @Test public void testScriptBean4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(ScriptBeanMethodInvokeException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(ScriptBeanMethodInvokeException.class, response.getCause().getClass()); } // 测试scriptBean excludeMethodName配置不包含情况下 @Test public void testScriptBean5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } // 测试scriptBean excludeMethodName配置包含情况下 @Test public void testScriptBean6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(ScriptBeanMethodInvokeException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(ScriptBeanMethodInvokeException.class, response.getCause().getClass()); } // 测试在ScriptBeanManager里放入上下文,实现自定义脚本引用名称 @@ -86,9 +87,9 @@ public class LiteFlowScriptScriptbeanGroovyELTest extends BaseTest { Map map = new HashMap<>(); ScriptBeanManager.addScriptBean("abcCx", map); LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg", map); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Map context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.get("demo")); + Assertions.assertEquals("hello", context.get("demo")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptmethod/LiteFlowScriptScriptMethodGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptmethod/LiteFlowScriptScriptMethodGroovyELTest.java index 6bfd95be7..80b606d9b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptmethod/LiteFlowScriptScriptMethodGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptmethod/LiteFlowScriptScriptMethodGroovyELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptmethod/application.properties") @SpringBootTest(classes = LiteFlowScriptScriptMethodGroovyELTest.class) @EnableAutoConfiguration @@ -29,17 +30,17 @@ public class LiteFlowScriptScriptMethodGroovyELTest extends BaseTest { @Test public void testScriptBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.getData("demo")); + Assertions.assertEquals("hello", context.getData("demo")); } @Test public void testScriptBean2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/throwException/ThrowExceptionScriptGroovyELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/throwException/ThrowExceptionScriptGroovyELTest.java index 712c85d3d..03d0a1eea 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/throwException/ThrowExceptionScriptGroovyELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/throwException/ThrowExceptionScriptGroovyELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.9.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/throwException/application.properties") @SpringBootTest(classes = ThrowExceptionScriptGroovyELTest.class) @EnableAutoConfiguration @@ -33,8 +34,8 @@ public class ThrowExceptionScriptGroovyELTest extends BaseTest { @Test public void test1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("T01", response.getCode()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("T01", response.getCode()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/LiteflowXmlScriptJsCommonELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/LiteflowXmlScriptJsCommonELTest.java index 005be1c2e..79dd6fc7e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/LiteflowXmlScriptJsCommonELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/LiteflowXmlScriptJsCommonELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/common/application.properties") @SpringBootTest(classes = LiteflowXmlScriptJsCommonELTest.class) @EnableAutoConfiguration @@ -36,8 +37,8 @@ public class LiteflowXmlScriptJsCommonELTest extends BaseTest { public void testCommon1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Double.valueOf(11), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Double.valueOf(11), context.getData("s1")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/contextbean/LiteFlowScriptContextbeanJavaScriptTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/contextbean/LiteFlowScriptContextbeanJavaScriptTest.java index 7872643ca..eb102f888 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/contextbean/LiteFlowScriptContextbeanJavaScriptTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/contextbean/LiteFlowScriptContextbeanJavaScriptTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.script.javascript.contextbean.bean.CheckContext; import com.yomahub.liteflow.test.script.javascript.contextbean.bean.Order2Context; import com.yomahub.liteflow.test.script.javascript.contextbean.bean.OrderContext; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -17,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/contextbean/application.properties") @SpringBootTest(classes = LiteFlowScriptContextbeanJavaScriptTest.class) @EnableAutoConfiguration @@ -32,13 +33,13 @@ public class LiteFlowScriptContextbeanJavaScriptTest extends BaseTest { public void testContextBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class, Order2Context.class); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); Order2Context order2Context = response.getContextBean(Order2Context.class); - Assert.assertEquals("order1", orderContext.getOrderNo()); - Assert.assertEquals("sign1", checkContext.getSign()); - Assert.assertEquals("order2", order2Context.getOrderNo()); + Assertions.assertEquals("order1", orderContext.getOrderNo()); + Assertions.assertEquals("sign1", checkContext.getSign()); + Assertions.assertEquals("order2", order2Context.getOrderNo()); } @Test @@ -51,7 +52,7 @@ public class LiteFlowScriptContextbeanJavaScriptTest extends BaseTest { orderContext2.setOrderNo("order2"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext, orderContext2); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/LiteFlowXmlScriptIfelseJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/LiteFlowXmlScriptIfelseJsELTest.java index d4e03f852..fd48db927 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/LiteFlowXmlScriptIfelseJsELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/LiteFlowXmlScriptIfelseJsELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.javascript.ifelse; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/ifelse/application.properties") @SpringBootTest(classes = LiteFlowXmlScriptIfelseJsELTest.class) @EnableAutoConfiguration @@ -28,56 +29,56 @@ public class LiteFlowXmlScriptIfelseJsELTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x0==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x0==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x0==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x0==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/LiteFlowXmlScriptLoopJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/LiteFlowXmlScriptLoopJsELTest.java index eaac52905..4a8ce24ab 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/LiteFlowXmlScriptLoopJsELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/LiteFlowXmlScriptLoopJsELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.javascript.loop; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/loop/application.properties") @SpringBootTest(classes = LiteFlowXmlScriptLoopJsELTest.class) @EnableAutoConfiguration @@ -28,31 +29,31 @@ public class LiteFlowXmlScriptLoopJsELTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -60,8 +61,8 @@ public class LiteFlowXmlScriptLoopJsELTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/LiteflowXmlScriptJsRefreshELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/LiteflowXmlScriptJsRefreshELTest.java index 30f76684d..1f7e0e862 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/LiteflowXmlScriptJsRefreshELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/LiteflowXmlScriptJsRefreshELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/refresh/application.properties") @SpringBootTest(classes = LiteflowXmlScriptJsRefreshELTest.class) @EnableAutoConfiguration @@ -39,8 +40,8 @@ public class LiteflowXmlScriptJsRefreshELTest extends BaseTest { public void testRefresh1() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s1[选择脚本]==>a", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s1[选择脚本]==>a", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /refresh/flow_update.xml"); // 进行刷新 @@ -48,8 +49,8 @@ public class LiteflowXmlScriptJsRefreshELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s1[选择脚本_改]==>b==>s2[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s1[选择脚本_改]==>b==>s2[普通脚本_新增]", responseNew.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/LiteFlowScriptScriptbeanJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/LiteFlowScriptScriptbeanJsELTest.java index f1ec1bfd5..a4a6e88ff 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/LiteFlowScriptScriptbeanJsELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/LiteFlowScriptScriptbeanJsELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptbean/application.properties") @SpringBootTest(classes = LiteFlowScriptScriptbeanJsELTest.class) @EnableAutoConfiguration @@ -29,17 +30,17 @@ public class LiteFlowScriptScriptbeanJsELTest extends BaseTest { @Test public void testScriptBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.getData("demo")); + Assertions.assertEquals("hello", context.getData("demo")); } @Test public void testScriptBean2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptmethod/LiteFlowScriptScriptMethodJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptmethod/LiteFlowScriptScriptMethodJsELTest.java index 30103cfb5..f5c1e029c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptmethod/LiteFlowScriptScriptMethodJsELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptmethod/LiteFlowScriptScriptMethodJsELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptmethod/application.properties") @SpringBootTest(classes = LiteFlowScriptScriptMethodJsELTest.class) @EnableAutoConfiguration @@ -29,17 +30,17 @@ public class LiteFlowScriptScriptMethodJsELTest extends BaseTest { @Test public void testScriptBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.getData("demo")); + Assertions.assertEquals("hello", context.getData("demo")); } @Test public void testScriptBean2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/LiteflowXmlScriptJsSwitchELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/LiteflowXmlScriptJsSwitchELTest.java index 2dc8e3efe..c9be861a5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/LiteflowXmlScriptJsSwitchELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/LiteflowXmlScriptJsSwitchELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.javascript.sw; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -20,7 +21,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/sw/application.properties") @SpringBootTest(classes = LiteflowXmlScriptJsSwitchELTest.class) @EnableAutoConfiguration @@ -34,8 +35,8 @@ public class LiteflowXmlScriptJsSwitchELTest extends BaseTest { @Test public void testSw1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s1[选择脚本]==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s1[选择脚本]==>a", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/throwException/ThrowExceptionScriptJsCommonELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/throwException/ThrowExceptionScriptJsCommonELTest.java index e90e96145..23cf82123 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/throwException/ThrowExceptionScriptJsCommonELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javascript-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/throwException/ThrowExceptionScriptJsCommonELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/throwException/application.properties") @SpringBootTest(classes = ThrowExceptionScriptJsCommonELTest.class) @EnableAutoConfiguration @@ -36,7 +37,7 @@ public class ThrowExceptionScriptJsCommonELTest extends BaseTest { public void testCommon1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/script/lua/common/ScriptLuaCommonELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/script/lua/common/ScriptLuaCommonELTest.java index defa35790..ae01e293d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/script/lua/common/ScriptLuaCommonELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/script/lua/common/ScriptLuaCommonELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.9.5 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/common/application.properties") @SpringBootTest(classes = ScriptLuaCommonELTest.class) @EnableAutoConfiguration @@ -36,8 +37,8 @@ public class ScriptLuaCommonELTest extends BaseTest { public void testCommon1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(30), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(30), context.getData("s1")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/script/lua/contextbean/LiteFlowScriptContextbeanLuaTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/script/lua/contextbean/LiteFlowScriptContextbeanLuaTest.java index 306109d49..323d403ab 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/script/lua/contextbean/LiteFlowScriptContextbeanLuaTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-lua-springboot/src/test/java/com/yomahub/liteflow/test/script/lua/contextbean/LiteFlowScriptContextbeanLuaTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.script.lua.contextbean.bean.CheckContext; import com.yomahub.liteflow.test.script.lua.contextbean.bean.Order2Context; import com.yomahub.liteflow.test.script.lua.contextbean.bean.OrderContext; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -17,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/contextbean/application.properties") @SpringBootTest(classes = LiteFlowScriptContextbeanLuaTest.class) @EnableAutoConfiguration @@ -32,13 +33,13 @@ public class LiteFlowScriptContextbeanLuaTest extends BaseTest { public void testContextBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class, Order2Context.class); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); Order2Context order2Context = response.getContextBean(Order2Context.class); - Assert.assertEquals(30, orderContext.getOrderType()); - Assert.assertEquals("d", checkContext.getSign()); - Assert.assertEquals("order2", order2Context.getOrderNo()); + Assertions.assertEquals(30, orderContext.getOrderType()); + Assertions.assertEquals("d", checkContext.getSign()); + Assertions.assertEquals("order2", order2Context.getOrderNo()); } @Test @@ -51,7 +52,7 @@ public class LiteFlowScriptContextbeanLuaTest extends BaseTest { orderContext2.setOrderNo("order2"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext, orderContext2); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/java/com/yomahub/liteflow/test/script/multi/language/MultiLanguageELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/java/com/yomahub/liteflow/test/script/multi/language/MultiLanguageELTest.java index 3c09fb1f1..2a2b2976d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/java/com/yomahub/liteflow/test/script/multi/language/MultiLanguageELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/java/com/yomahub/liteflow/test/script/multi/language/MultiLanguageELTest.java @@ -1,22 +1,18 @@ package com.yomahub.liteflow.test.script.multi.language; -import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.enums.FlowParserTypeEnum; -import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.util.JsonUtil; -import groovy.lang.MetaClass; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.util.Map; @@ -27,7 +23,7 @@ import java.util.Map; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/multiLanguage/application.properties") @SpringBootTest(classes = MultiLanguageELTest.class) @EnableAutoConfiguration @@ -44,9 +40,9 @@ public class MultiLanguageELTest extends BaseTest { DefaultContext context = response.getFirstContextBean(); Object student = context.getData("student"); Map studentMap = JsonUtil.parseObject(JsonUtil.toJsonString(student), Map.class); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(18), context.getData("s1")); - Assert.assertEquals(10032, studentMap.get("studentID")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(18), context.getData("s1")); + Assertions.assertEquals(10032, studentMap.get("studentID")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/script/python/common/ScriptPythonCommonELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/script/python/common/ScriptPythonCommonELTest.java index a1a0d87ae..7deeb878f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/script/python/common/ScriptPythonCommonELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/script/python/common/ScriptPythonCommonELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +22,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.9.5 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/common/application.properties") @SpringBootTest(classes = ScriptPythonCommonELTest.class) @EnableAutoConfiguration @@ -36,9 +37,9 @@ public class ScriptPythonCommonELTest extends BaseTest { public void testCommon1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(30), context.getData("s1")); - Assert.assertEquals("杰克", context.getData("name")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(30), context.getData("s1")); + Assertions.assertEquals("杰克", context.getData("name")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/script/python/contextbean/LiteFlowScriptContextbeanPythonTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/script/python/contextbean/LiteFlowScriptContextbeanPythonTest.java index e8acb793c..ed8d5b86c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/script/python/contextbean/LiteFlowScriptContextbeanPythonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-python-springboot/src/test/java/com/yomahub/liteflow/test/script/python/contextbean/LiteFlowScriptContextbeanPythonTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.script.python.contextbean.bean.CheckContext; import com.yomahub.liteflow.test.script.python.contextbean.bean.Order2Context; import com.yomahub.liteflow.test.script.python.contextbean.bean.OrderContext; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -17,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/contextbean/application.properties") @SpringBootTest(classes = LiteFlowScriptContextbeanPythonTest.class) @EnableAutoConfiguration @@ -32,13 +33,13 @@ public class LiteFlowScriptContextbeanPythonTest extends BaseTest { public void testContextBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class, Order2Context.class); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); Order2Context order2Context = response.getContextBean(Order2Context.class); - Assert.assertEquals(30, orderContext.getOrderType()); - Assert.assertEquals("d", checkContext.getSign()); - Assert.assertEquals("order2", order2Context.getOrderNo()); + Assertions.assertEquals(30, orderContext.getOrderType()); + Assertions.assertEquals("d", checkContext.getSign()); + Assertions.assertEquals("order2", order2Context.getOrderNo()); } @Test @@ -51,7 +52,7 @@ public class LiteFlowScriptContextbeanPythonTest extends BaseTest { orderContext2.setOrderNo("order2"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext, orderContext2); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptBuilderQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptBuilderQLExpressELTest.java index 4a47e958a..3ada3ff2a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptBuilderQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptBuilderQLExpressELTest.java @@ -7,16 +7,17 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.NodeTypeEnum; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = LiteFlowXmlScriptBuilderQLExpressELTest.class) @EnableAutoConfiguration public class LiteFlowXmlScriptBuilderQLExpressELTest extends BaseTest { @@ -56,8 +57,8 @@ public class LiteFlowXmlScriptBuilderQLExpressELTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg1"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试通过builder方式运行普通script节点,以file的方式运行 @@ -91,8 +92,8 @@ public class LiteFlowXmlScriptBuilderQLExpressELTest extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain2").setEL("THEN(d,SWITCH(s2).to(a,b))").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d[组件D]==>s2[条件脚本S2]==>b[组件B]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d[组件D]==>s2[条件脚本S2]==>b[组件B]", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptIfelseQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptIfelseQLExpressELTest.java index 2d507c64d..72cf753d4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptIfelseQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptIfelseQLExpressELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.qlexpress; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/ifelse/application.properties") @SpringBootTest(classes = LiteFlowXmlScriptIfelseQLExpressELTest.class) @EnableAutoConfiguration @@ -28,56 +29,56 @@ public class LiteFlowXmlScriptIfelseQLExpressELTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x0==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x0==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x0==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x0==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressELTest.java index 93feff778..619c98791 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/json-script-file/application.properties") @SpringBootTest(classes = LiteflowJsonScriptFileQLExpressELTest.class) @EnableAutoConfiguration @@ -39,24 +40,24 @@ public class LiteflowJsonScriptFileQLExpressELTest extends BaseTest { public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试条件脚本节点 @Test public void testScript2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); } @Test public void testScript3() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.el.json"); // 进行刷新 @@ -64,8 +65,8 @@ public class LiteflowJsonScriptFileQLExpressELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } // 测试脚本&规则平滑重载刷新 @@ -86,7 +87,7 @@ public class LiteflowJsonScriptFileQLExpressELTest extends BaseTest { for (int i = 0; i < 300; i++) { LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); + Assertions.assertTrue(responseNew.isSuccess()); Thread.sleep(10L); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptQLExpressELTest.java index 753ad877c..c81a57ff0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptQLExpressELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/json-script/application.properties") @SpringBootTest(classes = LiteflowJsonScriptQLExpressELTest.class) @EnableAutoConfiguration @@ -39,24 +40,24 @@ public class LiteflowJsonScriptQLExpressELTest extends BaseTest { public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试条件脚本节点 @Test public void testScript2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); } @Test public void testScript3() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /json-script/flow_update.el.json"); // 进行刷新 @@ -64,8 +65,8 @@ public class LiteflowJsonScriptQLExpressELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressELTest.java index 5d3640ad2..2f4cd5dc0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/xml-script-file/application.properties") @SpringBootTest(classes = LiteflowXmlScriptFileQLExpressELTest.class) @EnableAutoConfiguration @@ -39,24 +40,24 @@ public class LiteflowXmlScriptFileQLExpressELTest extends BaseTest { public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试条件脚本节点 @Test public void testScript2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); } @Test public void testScript3() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.el.xml"); // 进行刷新 @@ -64,8 +65,8 @@ public class LiteflowXmlScriptFileQLExpressELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } // 测试脚本&规则平滑重载刷新 @@ -86,7 +87,7 @@ public class LiteflowXmlScriptFileQLExpressELTest extends BaseTest { for (int i = 0; i < 300; i++) { LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); + Assertions.assertTrue(responseNew.isSuccess()); Thread.sleep(10L); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptQLExpressELTest.java index 7a7646ae0..33e86a0e0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptQLExpressELTest.java @@ -7,9 +7,10 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -24,7 +25,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/xml-script/application.properties") @SpringBootTest(classes = LiteflowXmlScriptQLExpressELTest.class) @EnableAutoConfiguration @@ -39,24 +40,24 @@ public class LiteflowXmlScriptQLExpressELTest extends BaseTest { public void testScript1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(Integer.valueOf(6), context.getData("s1")); } // 测试条件脚本节点 @Test public void testScript2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); } @Test public void testScript3() throws Exception { // 根据配置,加载的应该是flow.xml,执行原来的规则 LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseOld.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); + Assertions.assertTrue(responseOld.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); // 更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script/flow_update.el.xml"); // 进行刷新 @@ -64,8 +65,8 @@ public class LiteflowXmlScriptQLExpressELTest extends BaseTest { // 重新执行chain2这个链路,结果会变 LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(responseNew.isSuccess()); - Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); + Assertions.assertTrue(responseNew.isSuccess()); + Assertions.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/contextbean/LiteFlowScriptContextbeanQLExpressTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/contextbean/LiteFlowScriptContextbeanQLExpressTest.java index 2fb50fb71..b27b13198 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/contextbean/LiteFlowScriptContextbeanQLExpressTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/contextbean/LiteFlowScriptContextbeanQLExpressTest.java @@ -6,9 +6,10 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.script.qlexpress.contextbean.bean.CheckContext; import com.yomahub.liteflow.test.script.qlexpress.contextbean.bean.Order2Context; import com.yomahub.liteflow.test.script.qlexpress.contextbean.bean.OrderContext; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -17,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/contextbean/application.properties") @SpringBootTest(classes = LiteFlowScriptContextbeanQLExpressTest.class) @EnableAutoConfiguration @@ -32,13 +33,13 @@ public class LiteFlowScriptContextbeanQLExpressTest extends BaseTest { public void testContextBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class, Order2Context.class); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); Order2Context order2Context = response.getContextBean(Order2Context.class); - Assert.assertEquals(6, orderContext.getOrderType()); - Assert.assertEquals("d", checkContext.getSign()); - Assert.assertEquals("order2", order2Context.getOrderNo()); + Assertions.assertEquals(6, orderContext.getOrderType()); + Assertions.assertEquals("d", checkContext.getSign()); + Assertions.assertEquals("order2", order2Context.getOrderNo()); } @Test @@ -51,7 +52,7 @@ public class LiteFlowScriptContextbeanQLExpressTest extends BaseTest { orderContext2.setOrderNo("order2"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext, orderContext2); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/loop/LiteFlowXmlScriptLoopQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/loop/LiteFlowXmlScriptLoopQLExpressELTest.java index b1988dbad..c12ade736 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/loop/LiteFlowXmlScriptLoopQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/loop/LiteFlowXmlScriptLoopQLExpressELTest.java @@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.script.qlexpress.loop; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/loop/application.properties") @SpringBootTest(classes = LiteFlowXmlScriptLoopQLExpressELTest.class) @EnableAutoConfiguration @@ -28,31 +29,31 @@ public class LiteFlowXmlScriptLoopQLExpressELTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -60,8 +61,8 @@ public class LiteFlowXmlScriptLoopQLExpressELTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/scriptbean/LiteFlowScriptScriptbeanQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/scriptbean/LiteFlowScriptScriptbeanQLExpressELTest.java index 5c7f7b33e..8da7ceb06 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/scriptbean/LiteFlowScriptScriptbeanQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/scriptbean/LiteFlowScriptScriptbeanQLExpressELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptbean/application.properties") @SpringBootTest(classes = LiteFlowScriptScriptbeanQLExpressELTest.class) @EnableAutoConfiguration @@ -29,17 +30,17 @@ public class LiteFlowScriptScriptbeanQLExpressELTest extends BaseTest { @Test public void testScriptBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.getData("demo")); + Assertions.assertEquals("hello", context.getData("demo")); } @Test public void testScriptBean2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/scriptmethod/LiteFlowScriptScriptMethodQLExpressELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/scriptmethod/LiteFlowScriptScriptMethodQLExpressELTest.java index fd9948b91..6cc383680 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/scriptmethod/LiteFlowScriptScriptMethodQLExpressELTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-qlexpress-springboot/src/test/java/com/yomahub/liteflow/test/script/qlexpress/scriptmethod/LiteFlowScriptScriptMethodQLExpressELTest.java @@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/scriptmethod/application.properties") @SpringBootTest(classes = LiteFlowScriptScriptMethodQLExpressELTest.class) @EnableAutoConfiguration @@ -29,17 +30,17 @@ public class LiteFlowScriptScriptMethodQLExpressELTest extends BaseTest { @Test public void testScriptBean1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello", context.getData("demo")); + Assertions.assertEquals("hello", context.getData("demo")); } @Test public void testScriptBean2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,kobe", context.getData("demo")); + Assertions.assertEquals("hello,kobe", context.getData("demo")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-solon/pom.xml index e706226d5..2993329c6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/pom.xml @@ -21,7 +21,7 @@ org.noear - solon-test-junit4 + solon-test-junit5 ${solon.version} test diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 487da4867..814da97c7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -5,11 +5,11 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { FlowBus.cleanCache(); ExecutorHelper.loadInstance().clearExecutorServiceMap(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java index ed8cd7eb1..8e8897b85 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +18,7 @@ import org.slf4j.LoggerFactory; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/absoluteConfigPath/application.properties") public class AbsoluteConfigPathELSpringbootTest extends BaseTest { @@ -30,7 +30,7 @@ public class AbsoluteConfigPathELSpringbootTest extends BaseTest { @Test public void testAbsoluteConfig() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringbootTest.java index a2ad54558..6b223f825 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringbootTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -18,7 +18,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author ssss */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/asyncNode/application.properties") public class AsyncNodeELSpringbootTest extends BaseTest { @@ -31,7 +31,7 @@ public class AsyncNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -39,7 +39,7 @@ public class AsyncNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); - Assert.assertTrue( + Assertions.assertTrue( ListUtil .toList("b==>j==>g==>f==>h", "b==>j==>g==>h==>f", "b==>j==>h==>g==>f", "b==>j==>h==>f==>g", "b==>j==>f==>h==>g", "b==>j==>f==>g==>h") @@ -50,15 +50,15 @@ public class AsyncNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow3_1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(response.getSlot().getException().getClass(), TestException.class); } // 测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @@ -66,13 +66,13 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); // 因为不记录错误,所以最终结果是true - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 DefaultContext context = response.getFirstContextBean(); Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(new Integer(2), count); // 因为配置了不抛错,所以response里的cause应该为null - Assert.assertNull(response.getCause()); + Assertions.assertNull(response.getCause()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @@ -80,13 +80,13 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); // 整个并行组是报错的,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 DefaultContext context = response.getFirstContextBean(); Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(new Integer(2), count); // 因为第一个when配置了会报错,所以response里的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @@ -94,13 +94,13 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); // 第一个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 DefaultContext context = response.getFirstContextBean(); Integer count = context.getData("count"); - Assert.assertEquals(new Integer(1), count); + Assertions.assertEquals(new Integer(1), count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @@ -108,13 +108,13 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); // 第二个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 DefaultContext context = response.getFirstContextBean(); Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(new Integer(2), count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 测试任意异步一个执行完即继续的场景 @@ -125,8 +125,8 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow8() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("check").toString().startsWith("habc")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/base/BaseELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/base/BaseELSpringbootTest.java index d46afa4cd..4b6fbc38e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/base/BaseELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/base/BaseELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/base/application.properties") public class BaseELSpringbootTest extends BaseTest { @@ -26,35 +26,35 @@ public class BaseELSpringbootTest extends BaseTest { @Test public void testBase1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // switch节点最简单的测试用例 @Test public void testBase2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // then,when,switch混用的稍微复杂点的用例,switch跳到一个then上 @Test public void testBase3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 一个非常复杂的例子,可以看base目录下的img.png这个图示 @Test public void testBase4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 用变量来声明短流程 @Test public void testBase5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest1.java index 002ea599c..ab35a4150 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest1.java @@ -7,16 +7,16 @@ import com.yomahub.liteflow.enums.NodeTypeEnum; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.builder.cmp1.*; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; //基于builder模式的单元测试 //这里只是最基本的builder模式的测试,只是为了验证在springboot模式下的正常性 //更详细的builder模式测试用例会单独拉testcase去做 -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) public class BuilderELSpringbootTest1 extends BaseTest { @Inject @@ -76,8 +76,8 @@ public class BuilderELSpringbootTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } // 基于普通组件的builder模式测试 @@ -134,8 +134,8 @@ public class BuilderELSpringbootTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @Test @@ -168,8 +168,8 @@ public class BuilderELSpringbootTest1 extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(a1,c2,a2,c1)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest2.java index 2bfba62b1..a672390e5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest2.java @@ -4,15 +4,15 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; //基于builder模式的单元测试 //这里测试的是通过spring去扫描,但是通过代码去构建chain的用例 -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) public class BuilderELSpringbootTest2 extends BaseTest { @Inject @@ -24,8 +24,8 @@ public class BuilderELSpringbootTest2 extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(h, i, j)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("h==>i==>j", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("h==>i==>j", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpData/CmpDataELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpData/CmpDataELSpringbootTest.java index 606e0c529..46a28ce6e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpData/CmpDataELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpData/CmpDataELSpringbootTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.cmpData.vo.User; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -18,7 +18,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/cmpData/application.properties") public class CmpDataELSpringbootTest extends BaseTest { @@ -29,12 +29,12 @@ public class CmpDataELSpringbootTest extends BaseTest { @Test public void testCmpData() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); User user = context.getData("user"); - Assert.assertEquals(27, user.getAge()); - Assert.assertEquals("jack", user.getName()); - Assert.assertEquals(0, user.getBirth().compareTo(DateUtil.parseDate("1995-10-01").toJdkDate())); + Assertions.assertEquals(27, user.getAge()); + Assertions.assertEquals("jack", user.getName()); + Assertions.assertEquals(0, user.getBirth().compareTo(DateUtil.parseDate("1995-10-01").toJdkDate())); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringbootTest.java index 9e143dc0a..8e28792e9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringbootTest.java @@ -3,12 +3,12 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.snack.ONode; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -17,7 +17,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/cmpRetry/application.properties") public class LiteflowRetryELSpringbootTest extends BaseTest { @@ -28,32 +28,31 @@ public class LiteflowRetryELSpringbootTest extends BaseTest { @Test public void testRetry1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - System.out.println(ONode.stringify(response)); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } // 单个组件重试配置测试 @Test public void testRetry2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } // 单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); } // 单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java index 531a19dae..7624a3690 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.entity.CmpStep; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import java.util.*; @@ -19,7 +19,7 @@ import java.util.*; * @author Bryan.Zhang * @since 2.7.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/cmpStep/application.properties") public class CmpStepELSpringbootTest extends BaseTest { @@ -31,31 +31,31 @@ public class CmpStepELSpringbootTest extends BaseTest { @Test public void testStep1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test public void testStep2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } @Test public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Map> stepMap = response.getExecuteSteps(); - Assert.assertEquals(2, stepMap.size()); + Assertions.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); - Assert.assertEquals(5, queue.size()); + Assertions.assertEquals(5, queue.size()); Set tagSet = new HashSet<>(); response.getExecuteStepQueue() @@ -63,7 +63,7 @@ public class CmpStepELSpringbootTest extends BaseTest { .filter(cmpStep -> cmpStep.getNodeId().equals("a")) .forEach(cmpStep -> tagSet.add(cmpStep.getTag())); - Assert.assertEquals(3, tagSet.size()); + Assertions.assertEquals(3, tagSet.size()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java index e8f39b838..c188d3a92 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java @@ -4,14 +4,14 @@ import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/comments/application.properties") public class LiteflowNodeELSpringbootTest extends BaseTest { @@ -22,8 +22,8 @@ public class LiteflowNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); } } \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest1.java index eb7ac2444..adfa6d0da 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest1.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.complex; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/complex/application1.properties") public class ComplexELSpringbootTest1 extends BaseTest { @@ -28,7 +28,7 @@ public class ComplexELSpringbootTest1 extends BaseTest { @Test public void testComplex1_1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1_1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试复杂例子,优化后 @@ -37,7 +37,7 @@ public class ComplexELSpringbootTest1 extends BaseTest { @Test public void testComplex1_2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1_2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/complex2/ComplexELSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/complex2/ComplexELSpringbootTest2.java index be76a7180..9d79f629c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/complex2/ComplexELSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/complex2/ComplexELSpringbootTest2.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.complex2; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/complex/application2.properties") public class ComplexELSpringbootTest2 extends BaseTest { @@ -28,7 +28,7 @@ public class ComplexELSpringbootTest2 extends BaseTest { @Test public void testComplex2_1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2_1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试复杂例子,优化后 @@ -37,7 +37,7 @@ public class ComplexELSpringbootTest2 extends BaseTest { @Test public void testComplex2_2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2_2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELSpringbootTest.java index 5e8aaeb4c..58450c05e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory; * * @author donguo.tao */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/component/application.properties") public class FlowExecutorELSpringbootTest extends BaseTest { @@ -30,47 +30,47 @@ public class FlowExecutorELSpringbootTest extends BaseTest { @Test public void testIsAccess() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); - Assert.assertTrue(response.isSuccess()); - Assert.assertNotNull(response.getSlot().getResponseData()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNotNull(response.getSlot().getResponseData()); } // isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCause()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCause()); } // isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d", response.getExecuteStepStr()); } // setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("e", response.getExecuteStepStr()); } // 条件组件的功能点测试 @Test public void testNodeCondComponent() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringbootTest.java index 400fcd53b..be2c7cbe5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.customNodes; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +18,7 @@ import org.slf4j.LoggerFactory; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/customNodes/application.properties") public class CustomNodesELSpringbootTest extends BaseTest { @@ -30,9 +30,9 @@ public class CustomNodesELSpringbootTest extends BaseTest { @Test public void testCustomNodes() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringbootTest.java index fd6a2f050..0cdb4a6a9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/customWhenThreadPool/application.properties") public class CustomWhenThreadPoolELSpringbootTest extends BaseTest { @@ -35,8 +35,8 @@ public class CustomWhenThreadPoolELSpringbootTest extends BaseTest { public void testGlobalThreadPool() { LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -46,8 +46,8 @@ public class CustomWhenThreadPoolELSpringbootTest extends BaseTest { public void testGlobalAndCustomWhenThreadPool() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response1.getFirstContextBean(); - Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } /** @@ -60,8 +60,8 @@ public class CustomWhenThreadPoolELSpringbootTest extends BaseTest { // chain配置同一个thead1 LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response2.getFirstContextBean(); - Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response2.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/EventELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/EventELSpringbootTest.java index afefdbbbf..8b7696891 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/EventELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/EventELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -17,7 +17,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.7.1 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/event/application.properties") public class EventELSpringbootTest extends BaseTest { @@ -29,8 +29,8 @@ public class EventELSpringbootTest extends BaseTest { public void testEvent1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("abc", context.getData("test")); } // 测试组件失败事件 @@ -38,10 +38,10 @@ public class EventELSpringbootTest extends BaseTest { public void testEvent2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", context.getData("test")); - Assert.assertEquals("error:d", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("ab", context.getData("test")); + Assertions.assertEquals("error:d", context.getData("error")); } // 测试组件失败事件本身抛出异常 @@ -49,10 +49,10 @@ public class EventELSpringbootTest extends BaseTest { public void testEvent3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", context.getData("test")); - Assert.assertEquals("error:e", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("a", context.getData("test")); + Assertions.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringBootTest.java index 0dac705af..4312844c0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringBootTest.java @@ -9,18 +9,18 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; /** * 流程执行异常 单元测试 * * @author zendwang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) public class Exception1ELSpringBootTest extends BaseTest { @Inject @@ -29,31 +29,40 @@ public class Exception1ELSpringBootTest extends BaseTest { /** * 验证 chain 节点重复的异常 */ - @Test(expected = ChainDuplicateException.class) + @Test public void testChainDuplicateException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-exception.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(ChainDuplicateException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-exception.el.xml"); + flowExecutor.reloadRule(); + }); + } - @Test(expected = ConfigErrorException.class) + @Test public void testConfigErrorException() { - flowExecutor.setLiteflowConfig(null); - flowExecutor.reloadRule(); + Assertions.assertThrows(ConfigErrorException.class, () -> { + flowExecutor.setLiteflowConfig(null); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testFlowExecutorNotInitException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("error/flow.txt"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("error/flow.txt"); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testNoConditionInChainException() throws Exception { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-blank.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-blank.el.xml"); + flowExecutor.reloadRule(); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringBootTest.java index 6b02970be..115f35e55 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringBootTest.java @@ -7,12 +7,12 @@ import com.yomahub.liteflow.exception.LiteFlowException; import com.yomahub.liteflow.exception.NoSwitchTargetNodeException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; import org.noear.solon.core.AopContext; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -20,7 +20,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author zendwang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/exception/application.properties") public class Exception2ELSpringBootTest extends BaseTest { @@ -30,46 +30,52 @@ public class Exception2ELSpringBootTest extends BaseTest { @Inject private AopContext context; - @Test(expected = ChainNotFoundException.class) + @Test public void testChainNotFoundException() throws Exception { - flowExecutor.execute("chain0", "it's a request"); + Assertions.assertThrows(ChainNotFoundException.class, () -> { + flowExecutor.execute("chain0", "it's a request"); + }); } - @Test(expected = RuntimeException.class) + @Test public void testComponentCustomException() throws Exception { - flowExecutor.execute("chain1", "exception"); + Assertions.assertThrows(RuntimeException.class, () -> { + flowExecutor.execute("chain1", "exception"); + }); } @Test public void testGetSlotFromResponseWhenException() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); - Assert.assertFalse(response.isSuccess()); - Assert.assertNotNull(response.getCause()); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertNotNull(response.getSlot()); } - @Test(expected = NoSwitchTargetNodeException.class) + @Test public void testNoTargetFindException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); - Assert.assertFalse(response.isSuccess()); - throw response.getCause(); + Assertions.assertThrows(NoSwitchTargetNodeException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); + Assertions.assertFalse(response.isSuccess()); + throw response.getCause(); + }); } @Test public void testInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "custom-stateful-exception"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("300", response.getCode()); - Assert.assertNotNull(response.getCause()); - Assert.assertTrue(response.getCause() instanceof LiteFlowException); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("300", response.getCode()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertTrue(response.getCause() instanceof LiteFlowException); + Assertions.assertNotNull(response.getSlot()); } @Test public void testNotInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "test"); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCode()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCode()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringbootTest.java index 1825c012c..2cdcf6ac2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import java.util.concurrent.Future; @@ -18,7 +18,7 @@ import java.util.concurrent.Future; * @author Bryan.Zhang * @since 2.6.13 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/execute2Future/application.properties") public class Executor2FutureELSpringbootTest extends BaseTest { @@ -29,7 +29,7 @@ public class Executor2FutureELSpringbootTest extends BaseTest { public void testFuture() throws Exception { Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); LiteflowResponse response = future.get(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringbootTest.java index c409239ca..c1ec728ed 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/getChainName/application.properties") public class GetChainNameELSpringbootTest extends BaseTest { @@ -27,28 +27,28 @@ public class GetChainNameELSpringbootTest extends BaseTest { public void testGetChainName1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); } @Test public void testGetChainName2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("chain2", context.getData("g")); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); - Assert.assertEquals("sub5", context.getData("f")); - Assert.assertEquals("sub5_chain2", context.getData("e")); - Assert.assertEquals("sub6", context.getData("h")); - Assert.assertEquals("sub6", context.getData("j")); - Assert.assertNull(context.getData("k")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("chain2", context.getData("g")); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); + Assertions.assertEquals("sub5", context.getData("f")); + Assertions.assertEquals("sub5_chain2", context.getData("e")); + Assertions.assertEquals("sub6", context.getData("h")); + Assertions.assertEquals("sub6", context.getData("j")); + Assertions.assertNull(context.getData("k")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/ifelse/IfELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/ifelse/IfELSpringbootTest.java index 83f5588f4..3138f2f80 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/ifelse/IfELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/ifelse/IfELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.ifelse; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/ifelse/application.properties") public class IfELSpringbootTest extends BaseTest { @@ -26,56 +26,56 @@ public class IfELSpringbootTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringbootTest.java index e0f656fd0..1e40ced58 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.lfCmpAnno; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/lfCmpAnno/application.properties") public class LiteflowComponentELSpringbootTest extends BaseTest { @@ -26,8 +26,8 @@ public class LiteflowComponentELSpringbootTest extends BaseTest { @Test public void testConfig() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringbootTest.java index 5debffc3a..e70731910 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/loop/application.properties") public class LoopELSpringbootTest extends BaseTest { @@ -27,31 +27,31 @@ public class LoopELSpringbootTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -59,8 +59,8 @@ public class LoopELSpringbootTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } @@ -69,10 +69,10 @@ public class LoopELSpringbootTest extends BaseTest { public void testLoop6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } // 测试WHILE循环中的index @@ -80,10 +80,10 @@ public class LoopELSpringbootTest extends BaseTest { public void testLoop7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringbootTest.java index 7057c7314..69db27030 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringbootTest.java @@ -5,12 +5,12 @@ import com.yomahub.liteflow.flow.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.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -19,7 +19,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/monitor/application.properties") public class MonitorELSpringbootTest extends BaseTest { @@ -29,13 +29,14 @@ public class MonitorELSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Thread.sleep(10000); } - @AfterClass + @AfterAll public static void clean() { + BaseTest.cleanScanCache(); MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class); monitorBus.closeScheduler(); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileSpringbootTest.java index 8af807295..8cb415647 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileSpringbootTest.java @@ -6,16 +6,16 @@ import cn.hutool.core.util.CharsetUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import java.io.File; -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/monitorFile/application.properties") public class MonitorFileSpringbootTest extends BaseTest { @@ -30,7 +30,7 @@ public class MonitorFileSpringbootTest extends BaseTest { FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); Thread.sleep(3000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>c==>b", response.getExecuteStepStr()); + Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELSpringbootTest.java index 9d8c85837..8c9173c28 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELSpringbootTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.exception.NoSuchContextBeanException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -19,7 +19,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/multiContext/application.properties") public class MultiContextELSpringbootTest extends BaseTest { @@ -31,18 +31,20 @@ public class MultiContextELSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("987XYZ", checkContext.getSign()); - Assert.assertEquals(95, checkContext.getRandomId()); - Assert.assertEquals("SO12345", orderContext.getOrderNo()); - Assert.assertEquals(2, orderContext.getOrderType()); - Assert.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("987XYZ", checkContext.getSign()); + Assertions.assertEquals(95, checkContext.getRandomId()); + Assertions.assertEquals("SO12345", orderContext.getOrderNo()); + Assertions.assertEquals(2, orderContext.getOrderType()); + Assertions.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); } - @Test(expected = NoSuchContextBeanException.class) + @Test public void testMultiContext2() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); - DefaultContext context = response.getContextBean(DefaultContext.class); + Assertions.assertThrows(NoSuchContextBeanException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); + DefaultContext context = response.getContextBean(DefaultContext.class); + }); } @Test @@ -52,11 +54,11 @@ public class MultiContextELSpringbootTest extends BaseTest { CheckContext checkContext = new CheckContext(); checkContext.setSign("987654321d"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); OrderContext context1 = response.getContextBean(OrderContext.class); CheckContext context2 = response.getContextBean(CheckContext.class); - Assert.assertEquals("SO11223344", context1.getOrderNo()); - Assert.assertEquals("987654321d", context2.getSign()); + Assertions.assertEquals("SO11223344", context1.getOrderNo()); + Assertions.assertEquals("987654321d", context2.getSign()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringbootTest.java index c62204d9e..5052d86a5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/multipleType/application.properties") public class LiteflowMultipleTypeELSpringbootTest extends BaseTest { @@ -26,11 +26,11 @@ public class LiteflowMultipleTypeELSpringbootTest extends BaseTest { @Test public void testMultipleType() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringbootTest.java index 55da19605..524199bbd 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -17,7 +17,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/nodeExecutor/application.properties") public class LiteflowNodeExecutorELSpringbootTest extends BaseTest { @@ -29,9 +29,9 @@ public class LiteflowNodeExecutorELSpringbootTest extends BaseTest { public void testCustomerDefaultNodeExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("a", response.getExecuteStepStr()); } // 默认执行器测试+全局重试配置测试 @@ -39,17 +39,17 @@ public class LiteflowNodeExecutorELSpringbootTest extends BaseTest { public void testDefaultExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("b==>b==>b", response.getExecuteStepStr()); } // 自定义执行器测试 @Test public void testCustomerExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("c", response.getExecuteStepStr()); } // 自定义执行器测试+全局重试配置测试 @@ -57,9 +57,9 @@ public class LiteflowNodeExecutorELSpringbootTest extends BaseTest { public void testCustomExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); - Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); + Assertions.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamELSpringbootTest.java index 1cd70246e..f2ffff350 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.nullParam; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author LeoLee * @since 2.6.6 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/nullParam/application.properties") public class NullParamELSpringbootTest extends BaseTest { @@ -29,7 +29,7 @@ public class NullParamELSpringbootTest extends BaseTest { @Test public void testNullParam() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringbootTest.java index d582bbf41..60911af80 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author dongguo.tao * @since 2.5.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/parsecustom/application-custom-json.properties") public class CustomParserJsonELSpringbootTest extends BaseTest { @@ -27,7 +27,7 @@ public class CustomParserJsonELSpringbootTest extends BaseTest { @Test public void testJsonCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELSpringbootTest.java index 36949b2a2..9a6b92ab2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author bryan.zhang * @since 2.5.7 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/parsecustom/application-custom-xml.properties") public class CustomParserXmlELSpringbootTest extends BaseTest { @@ -27,7 +27,7 @@ public class CustomParserXmlELSpringbootTest extends BaseTest { @Test public void testXmlCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserYmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserYmlELSpringbootTest.java index 0906c594e..7a61da242 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserYmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserYmlELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author junjun */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/parsecustom/application-custom-yml.properties") public class CustomParserYmlELSpringbootTest extends BaseTest { @@ -26,7 +26,7 @@ public class CustomParserYmlELSpringbootTest extends BaseTest { @Test public void testYmlCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELSpringbootTest.java index 3229fbd11..13e66a5f9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/parser/application-json.properties") public class JsonParserELSpringbootTest extends BaseTest { @@ -27,7 +27,7 @@ public class JsonParserELSpringbootTest extends BaseTest { @Test public void testJsonParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELSpringbootTest.java index a9d1afcac..0e03bbc88 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELSpringbootTest.java @@ -3,14 +3,14 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/parser/application-springEL.properties") public class SpringELSupportELSpringbootTest extends BaseTest { @@ -21,7 +21,7 @@ public class SpringELSupportELSpringbootTest extends BaseTest { @Test public void testSpringELParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELSpringbootTest.java index d0d8473d8..5df5042b7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/parser/application-xml.properties") public class XmlParserELSpringbootTest extends BaseTest { @@ -27,7 +27,7 @@ public class XmlParserELSpringbootTest extends BaseTest { @Test public void testXmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELSpringbootTest.java index 3d31e8ed0..ba528c532 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/parser/application-yml.properties") public class YmlParserELSpringbootTest extends BaseTest { @@ -27,7 +27,7 @@ public class YmlParserELSpringbootTest extends BaseTest { @Test public void testYmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringbootTest.java index 66813293f..b652e25ef 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -17,7 +17,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/preAndFinally/application.properties") public class PreAndFinallyELSpringbootTest extends BaseTest { @@ -28,24 +28,24 @@ public class PreAndFinallyELSpringbootTest extends BaseTest { @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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } // 测试在finally节点里是否能获取exception @@ -53,31 +53,31 @@ public class PreAndFinallyELSpringbootTest extends BaseTest { public void testPreAndFinally4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(context.getData("hasEx")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue((Boolean) context.getData("hasEx")); } // 测试嵌套结构pre和finally是否在各自的chain里打出 @Test public void testPreAndFinally5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } // 测试变量结构pre和finally是否在各自的chain里打出 @Test public void testPreAndFinally6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } // 测试el整体结构的多重pre和finally @Test public void testPreAndFinally7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringbootTest.java index 7d0fe7326..ed0558750 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringbootTest.java @@ -5,11 +5,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -18,7 +18,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/privateDelivery/application.properties") public class PrivateDeliveryELSpringbootTest extends BaseTest { @@ -30,8 +30,8 @@ public class PrivateDeliveryELSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); ConcurrentHashSet set = context.getData("testSet"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(100, set.size()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(100, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringbootTest.java index f939af020..605880ee6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringbootTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -19,7 +19,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/refreshRule/application.properties") public class RefreshRuleELSpringbootTest extends BaseTest { @@ -32,7 +32,7 @@ public class RefreshRuleELSpringbootTest extends BaseTest { String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.el.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, content); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试优雅刷新的场景 @@ -52,7 +52,7 @@ public class RefreshRuleELSpringbootTest extends BaseTest { for (int i = 0; i < 500; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); try { Thread.sleep(10L); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringbootTest.java index a291043db..a42a3112b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -16,7 +16,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/reload/application.properties") public class ReloadELSpringbootTest extends BaseTest { @@ -29,7 +29,7 @@ public class ReloadELSpringbootTest extends BaseTest { public void testReload() throws Exception { flowExecutor.reloadRule(); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringbootTest.java index efef4b4f2..c9d81b0b8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -17,7 +17,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/removeChain/application.properties") public class RemoveChainELSpringbootTest extends BaseTest { @@ -27,10 +27,10 @@ public class RemoveChainELSpringbootTest extends BaseTest { @Test public void testRemoveChain() throws Exception { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response1.isSuccess()); + Assertions.assertTrue(response1.isSuccess()); FlowBus.removeChain("chain1"); LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response2.isSuccess()); + Assertions.assertFalse(response2.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringbootTest.java index 01d6ce7e4..269add359 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringbootTest.java @@ -3,17 +3,17 @@ package com.yomahub.liteflow.test.requestId; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** * @author tangkc */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/requestId/application.properties") public class LiteflowRequestIdELSpringbootTest extends BaseTest { @@ -23,8 +23,8 @@ public class LiteflowRequestIdELSpringbootTest extends BaseTest { @Test public void testRequestId() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1", response.getRequestId()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1", response.getRequestId()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringbootTest.java index fc9a37f3c..d463b70ac 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import java.util.HashSet; @@ -19,7 +19,7 @@ import java.util.Set; * * @author justin.xu */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/subflow/application-implicit.properties") public class ImplicitSubFlowELSpringbootTest extends BaseTest { @@ -33,15 +33,15 @@ public class ImplicitSubFlowELSpringbootTest extends BaseTest { public void testImplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); // 传递了slotIndex,则set的size==1 - Assert.assertEquals(1, RUN_TIME_SLOT.size()); + Assertions.assertEquals(1, RUN_TIME_SLOT.size()); // set中第一次设置的requestId和response中的requestId一致 - Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); + Assertions.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); // requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); + Assertions.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } // 在p里多线程调用q 10次,每个q取到的参数都是不同的。 @@ -49,18 +49,18 @@ public class ImplicitSubFlowELSpringbootTest extends BaseTest { public void testImplicitSubFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("c1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Set set = context.getData("test"); // requestData的取值正确 - Assert.assertEquals(10, set.size()); + Assertions.assertEquals(10, set.size()); } @Test public void testImplicitSubFlow3() { LiteflowResponse response = flowExecutor.execute2Resp("chain_r", "it's a request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringbootTest.java index c574e853a..46d611a9a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringbootTest.java @@ -5,12 +5,12 @@ import com.yomahub.liteflow.exception.MultipleParsersException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; import org.noear.solon.core.AopContext; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -18,7 +18,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/subflow/application-subInDifferentConfig1.properties") public class SubflowInDifferentConfigELSpringbootTest extends BaseTest { @@ -29,19 +29,21 @@ public class SubflowInDifferentConfigELSpringbootTest extends BaseTest { @Test public void testExplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } @Inject private AopContext context; // 主要测试有不同的配置类型后会不会报出既定的错误 - @Test(expected = MultipleParsersException.class) + @Test public void testExplicitSubFlow2() { - LiteflowConfig config = context.getBean(LiteflowConfig.class); - config.setRuleSource("subflow/flow-main.el.xml,subflow/flow-sub1.el.xml,subflow/flow-sub2.el.yml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(MultipleParsersException.class, () -> { + LiteflowConfig config = context.getBean(LiteflowConfig.class); + config.setRuleSource("subflow/flow-main.el.xml,subflow/flow-sub1.el.xml,subflow/flow-sub2.el.yml"); + flowExecutor.reloadRule(); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringBootTest.java index 7ae294105..30d2e5ee4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringBootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author justin.xu */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/subflow/application-xml.properties") public class SubflowXMLELSpringBootTest extends BaseTest { @@ -26,8 +26,8 @@ public class SubflowXMLELSpringBootTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringBootTest.java index 0ba515e1b..a85349784 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringBootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author justin.xu */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/subflow/application-yml.properties") public class SubflowYmlELSpringBootTest extends BaseTest { @@ -26,8 +26,8 @@ public class SubflowYmlELSpringBootTest extends BaseTest { @Test public void testExplicitSubFlowYml() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow2/SubflowJsonELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow2/SubflowJsonELSpringBootTest.java index 42d414e38..512d4870f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow2/SubflowJsonELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/subflow2/SubflowJsonELSpringBootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.subflow2; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author justin.xu */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/subflow/application-json.properties") public class SubflowJsonELSpringBootTest extends BaseTest { @@ -26,8 +26,8 @@ public class SubflowJsonELSpringBootTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/substituteNode/SubstituteSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/substituteNode/SubstituteSpringbootTest.java index a1759c629..623662234 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/substituteNode/SubstituteSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/substituteNode/SubstituteSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.substituteNode; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/substituteNode/application.properties") public class SubstituteSpringbootTest extends BaseTest { @@ -26,21 +26,21 @@ public class SubstituteSpringbootTest extends BaseTest { @Test public void testSub1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 有替补节点 @Test public void testSub2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试特殊命名的节点 @Test public void testSub3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java index ac9b9d65f..7d1b2c09f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.switchcase; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -15,7 +15,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * * @author Bryan.Zhang */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/switchcase/application.properties") public class SwitchELSpringbootTest extends BaseTest { @@ -28,54 +28,54 @@ public class SwitchELSpringbootTest extends BaseTest { @Test public void testSwitch1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); } @Test public void testSwitch2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d", response.getExecuteStepStr()); } @Test public void testSwitch3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>f==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>f==>b", response.getExecuteStepStr()); } // 根据tag来跳转,指定哪个组件的tag @Test public void testSwitch4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>g==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>g==>d", response.getExecuteStepStr()); } // tag的跳转 @Test public void testSwitch5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>h==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr()); } // 相同组件的tag的跳转 @Test public void testSwitch6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>h==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr()); } // switch增加default选项 @Test public void testSwitch7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>i==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>i==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootJsonTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootJsonTest.java index c2971eae5..d5301e3f3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootJsonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootJsonTest.java @@ -5,11 +5,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -18,7 +18,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/tag/application-json.properties") public class NodeTagELSpringbootJsonTest extends BaseTest { @@ -29,15 +29,15 @@ public class NodeTagELSpringbootJsonTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -47,9 +47,9 @@ public class NodeTagELSpringbootJsonTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -57,8 +57,8 @@ public class NodeTagELSpringbootJsonTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootXmlTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootXmlTest.java index 3383fe276..a25f63b63 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootXmlTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootXmlTest.java @@ -5,11 +5,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -18,7 +18,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/tag/application-xml.properties") public class NodeTagELSpringbootXmlTest extends BaseTest { @@ -29,15 +29,15 @@ public class NodeTagELSpringbootXmlTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -47,9 +47,9 @@ public class NodeTagELSpringbootXmlTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -57,8 +57,8 @@ public class NodeTagELSpringbootXmlTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } // 测试tag是否能在WHEN中起效果 @@ -66,8 +66,8 @@ public class NodeTagELSpringbootXmlTest extends BaseTest { public void testTag5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1", context.getData("test")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringbootTest.java index a08529b91..f12ece677 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringbootTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; /** @@ -17,7 +17,7 @@ import org.noear.solon.test.annotation.TestPropertySource; * @author Bryan.Zhang * @since 2.6.3 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/useTTLInWhen/application.properties") public class UseTTLInWhenELSpringbootTest extends BaseTest { @@ -28,11 +28,11 @@ public class UseTTLInWhenELSpringbootTest extends BaseTest { public void testUseTTLInWhen() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,b", context.getData("b")); - Assert.assertEquals("hello,c", context.getData("c")); - Assert.assertEquals("hello,d", context.getData("d")); - Assert.assertEquals("hello,e", context.getData("e")); - Assert.assertEquals("hello,f", context.getData("f")); + Assertions.assertEquals("hello,b", context.getData("b")); + Assertions.assertEquals("hello,c", context.getData("c")); + Assertions.assertEquals("hello,d", context.getData("d")); + Assertions.assertEquals("hello,e", context.getData("e")); + Assertions.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/validateRule/ValidateRuleELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/validateRule/ValidateRuleELSpringbootTest.java index 9579d45dc..c3184ede2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/validateRule/ValidateRuleELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/validateRule/ValidateRuleELSpringbootTest.java @@ -7,12 +7,12 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.validateRule.cmp.ACmp; import com.yomahub.liteflow.test.validateRule.cmp.BCmp; import com.yomahub.liteflow.test.validateRule.cmp.CCmp; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.noear.solon.test.SolonJUnit5Extension; -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) public class ValidateRuleELSpringbootTest extends BaseTest { @Test @@ -35,8 +35,8 @@ public class ValidateRuleELSpringbootTest extends BaseTest { .setType(NodeTypeEnum.COMMON) .setClazz(CCmp.class) .build(); - Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, h)")); - Assert.assertTrue(LiteFlowChainELBuilder.validate("THEN(a, b, c)")); + Assertions.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, h)")); + Assertions.assertTrue(LiteFlowChainELBuilder.validate("THEN(a, b, c)")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest1.java index 227ca8227..904fbcc9b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest1.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.exception.WhenTimeoutException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/whenTimeOut/application1.properties") public class WhenTimeOutELSpringbootTest1 extends BaseTest { @@ -32,8 +32,8 @@ public class WhenTimeOutELSpringbootTest1 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest2.java index a725c7026..3612d67d3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest2.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +18,7 @@ import org.slf4j.LoggerFactory; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/whenTimeOut/application2.properties") public class WhenTimeOutELSpringbootTest2 extends BaseTest { @@ -31,7 +31,7 @@ public class WhenTimeOutELSpringbootTest2 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java index 2604cdadd..ca844f9cc 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringbootTest.java @@ -3,16 +3,14 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -22,7 +20,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties") @SpringBootTest(classes = AbsoluteConfigPathELSpringbootTest.class) @EnableAutoConfiguration @@ -37,7 +34,7 @@ public class AbsoluteConfigPathELSpringbootTest extends BaseTest { @Test public void testAbsoluteConfig() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELSpringbootTest.java index 7be1ca2fe..5d4ebe689 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELSpringbootTest.java @@ -5,15 +5,13 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.aop.aspect.CustomAspect; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -22,7 +20,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/aop/application.properties") @SpringBootTest(classes = CustomAOPELSpringbootTest.class) @EnableAutoConfiguration @@ -38,10 +35,10 @@ public class CustomAOPELSpringbootTest extends BaseTest { public void testCustomAopS() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); } // 测试自定义AOP,并行场景 @@ -49,10 +46,10 @@ public class CustomAOPELSpringbootTest extends BaseTest { public void testCustomAopP() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELSpringbootTest.java index 9c71f164c..a34d051de 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELSpringbootTest.java @@ -6,16 +6,14 @@ import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.aop.aspect.CmpAspect; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -24,7 +22,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/aop/application.properties") @SpringBootTest(classes = GlobalAOPELSpringbootTest.class) @EnableAutoConfiguration @@ -40,12 +37,12 @@ public class GlobalAOPELSpringbootTest extends BaseTest { public void testGlobalAopS() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("d")); - Assert.assertEquals("before_after", context.getData("e")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("d")); + Assertions.assertEquals("before_after", context.getData("e")); } // 测试全局AOP,并行场景 @@ -53,26 +50,26 @@ public class GlobalAOPELSpringbootTest extends BaseTest { public void testGlobalAopP() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("d")); - Assert.assertEquals("before_after", context.getData("e")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("d")); + Assertions.assertEquals("before_after", context.getData("e")); } @Test public void testGlobalAopException() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("f")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("f")); } - @AfterClass + @AfterAll public static void cleanScanCache() { BaseTest.cleanScanCache(); ComponentScanner.cmpAroundAspect = null; diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringbootTest.java index 596bcad47..30703e603 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringbootTest.java @@ -6,14 +6,12 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -22,7 +20,6 @@ import javax.annotation.Resource; * * @author ssss */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/asyncNode/application.properties") @SpringBootTest(classes = AsyncNodeELSpringbootTest.class) @EnableAutoConfiguration @@ -38,7 +35,7 @@ public class AsyncNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -46,7 +43,7 @@ public class AsyncNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); - Assert.assertTrue( + Assertions.assertTrue( ListUtil .toList("b==>j==>g==>f==>h", "b==>j==>g==>h==>f", "b==>j==>h==>g==>f", "b==>j==>h==>f==>g", "b==>j==>f==>h==>g", "b==>j==>f==>g==>h") @@ -56,22 +53,22 @@ public class AsyncNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow3() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试errorResume,默认的errorResume为false,这里测试默认的 @Test public void testAsyncFlow3_1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(response.getSlot().getException().getClass(), TestException.class); } // 测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @@ -79,13 +76,13 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); // 因为不记录错误,所以最终结果是true - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 DefaultContext context = response.getFirstContextBean(); Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 因为配置了不抛错,所以response里的cause应该为null - Assert.assertNull(response.getCause()); + Assertions.assertNull(response.getCause()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @@ -93,13 +90,13 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); // 整个并行组是报错的,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 DefaultContext context = response.getFirstContextBean(); Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 因为第一个when配置了会报错,所以response里的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @@ -107,13 +104,13 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); // 第一个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 DefaultContext context = response.getFirstContextBean(); Integer count = context.getData("count"); - Assert.assertEquals(new Integer(1), count); + Assertions.assertEquals(1, count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @@ -121,13 +118,13 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); // 第二个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 DefaultContext context = response.getFirstContextBean(); Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 测试任意异步一个执行完即继续的场景 @@ -138,8 +135,8 @@ public class AsyncNodeELSpringbootTest extends BaseTest { public void testAsyncFlow8() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("check").toString().startsWith("habc")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELSpringbootTest.java index 7afa6e3b0..09490711a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/base/application.properties") @SpringBootTest(classes = BaseELSpringbootTest.class) @EnableAutoConfiguration @@ -33,35 +30,35 @@ public class BaseELSpringbootTest extends BaseTest { @Test public void testBase1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // switch节点最简单的测试用例 @Test public void testBase2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // then,when,switch混用的稍微复杂点的用例,switch跳到一个then上 @Test public void testBase3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 一个非常复杂的例子,可以看base目录下的img.png这个图示 @Test public void testBase4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 用变量来声明短流程 @Test public void testBase5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/booleanOpt/BooleanOptELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/booleanOpt/BooleanOptELSpringbootTest.java index 1ef6d921f..0e7eb64c1 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/booleanOpt/BooleanOptELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/booleanOpt/BooleanOptELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.booleanOpt; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/booleanOpt/application.properties") @SpringBootTest(classes = BooleanOptELSpringbootTest.class) @EnableAutoConfiguration @@ -33,38 +30,38 @@ public class BooleanOptELSpringbootTest extends BaseTest { @Test public void testBooleanOpt1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x2==>x3==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x2==>x3==>b", response.getExecuteStepStr()); } // IF情况下OR @Test public void testBooleanOpt2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x2==>x3==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x2==>x3==>a", response.getExecuteStepStr()); } // IF情况下AND+NOT @Test public void testBooleanOpt3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x2==>x3==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x2==>x3==>a", response.getExecuteStepStr()); } // IF情况下AND+OR+NOT混合复杂 @Test public void testBooleanOpt4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x3==>x3==>x4==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x3==>x3==>x4==>a", response.getExecuteStepStr()); } @Test public void testBooleanOpt5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("w1==>w2==>a==>bk==>w1==>w2==>a==>bk==>w1==>w2==>a==>bk==>w1==>w2==>a==>bk", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("w1==>w2==>a==>bk==>w1==>w2==>a==>bk==>w1==>w2==>a==>bk==>w1==>w2==>a==>bk", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest1.java index 49edee05f..84d74c9b8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest1.java @@ -7,19 +7,16 @@ import com.yomahub.liteflow.enums.NodeTypeEnum; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.builder.cmp1.*; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; //基于builder模式的单元测试 //这里只是最基本的builder模式的测试,只是为了验证在springboot模式下的正常性 //更详细的builder模式测试用例会单独拉testcase去做 -@RunWith(SpringRunner.class) @SpringBootTest(classes = BuilderELSpringbootTest1.class) @EnableAutoConfiguration public class BuilderELSpringbootTest1 extends BaseTest { @@ -81,8 +78,8 @@ public class BuilderELSpringbootTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } // 基于普通组件的builder模式测试 @@ -139,8 +136,8 @@ public class BuilderELSpringbootTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @Test @@ -173,8 +170,8 @@ public class BuilderELSpringbootTest1 extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(a1,c2,a2,c1)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest2.java index 186e37deb..2ff7868ee 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringbootTest2.java @@ -4,19 +4,16 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; //基于builder模式的单元测试 //这里测试的是通过spring去扫描,但是通过代码去构建chain的用例 -@RunWith(SpringRunner.class) @SpringBootTest(classes = BuilderELSpringbootTest2.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.builder.cmp2" }) @@ -31,8 +28,8 @@ public class BuilderELSpringbootTest2 extends BaseTest { LiteFlowChainELBuilder.createChain().setChainId("chain1").setEL("THEN(h, i, j)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("h==>i==>j", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("h==>i==>j", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/CatchELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/CatchELSpringbootTest.java index 32c8294e2..ff548cac2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/CatchELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/catchcase/CatchELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.catchcase; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/catchcase/application.properties") @SpringBootTest(classes = CatchELSpringbootTest.class) @EnableAutoConfiguration @@ -32,36 +29,36 @@ public class CatchELSpringbootTest extends BaseTest { @Test public void testCatch1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>c", response.getExecuteStepStrWithoutTime()); - Assert.assertNull(response.getCause()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertNull(response.getCause()); } @Test public void testCatch2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("a==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("a==>d", response.getExecuteStepStrWithoutTime()); } @Test public void testCatch3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a", response.getExecuteStepStrWithoutTime()); } @Test public void testCatch4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_3==>a==>b==>a==>b==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_3==>a==>b==>a==>b==>a==>b", response.getExecuteStepStrWithoutTime()); } @Test public void testCatch5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("a==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("a==>d", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpData/CmpDataELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpData/CmpDataELSpringbootTest.java index ab5c705c7..50bc3d6ed 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpData/CmpDataELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpData/CmpDataELSpringbootTest.java @@ -1,24 +1,18 @@ package com.yomahub.liteflow.test.cmpData; -import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.cmpData.vo.User; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; -import java.util.List; import java.util.stream.Collectors; /** @@ -26,7 +20,6 @@ import java.util.stream.Collectors; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/cmpData/application.properties") @SpringBootTest(classes = CmpDataELSpringbootTest.class) @EnableAutoConfiguration @@ -40,22 +33,22 @@ public class CmpDataELSpringbootTest extends BaseTest { @Test public void testCmpData1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); User user = context.getData("user"); - Assert.assertEquals(27, user.getAge()); - Assert.assertEquals("jack", user.getName()); - Assert.assertEquals(0, user.getBirth().compareTo(DateUtil.parseDate("1995-10-01").toJdkDate())); + Assertions.assertEquals(27, user.getAge()); + Assertions.assertEquals("jack", user.getName()); + Assertions.assertEquals(0, user.getBirth().compareTo(DateUtil.parseDate("1995-10-01").toJdkDate())); } @Test public void testCmpData2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg", TestContext.class); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); TestContext context = response.getFirstContextBean(); - Assert.assertEquals(8, context.getSet().size()); + Assertions.assertEquals(8, context.getSet().size()); String result = context.getSet().stream().sorted().collect(Collectors.joining()); - Assert.assertEquals("12345678", result); + Assertions.assertEquals("12345678", result); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringbootTest.java index 6504bf7aa..f12985760 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -20,7 +18,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/cmpRetry/application.properties") @SpringBootTest(classes = LiteflowRetryELSpringbootTest.class) @EnableAutoConfiguration @@ -34,31 +31,31 @@ public class LiteflowRetryELSpringbootTest extends BaseTest { @Test public void testRetry1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } // 单个组件重试配置测试 @Test public void testRetry2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } // 单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); } // 单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java index 0157e3b9c..340b4d063 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringbootTest.java @@ -4,19 +4,14 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.entity.CmpStep; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; import java.util.*; -import java.util.function.Consumer; -import java.util.function.Predicate; /** * springboot环境step的测试例子 @@ -24,7 +19,6 @@ import java.util.function.Predicate; * @author Bryan.Zhang * @since 2.7.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/cmpStep/application.properties") @SpringBootTest(classes = CmpStepELSpringbootTest.class) @EnableAutoConfiguration @@ -39,31 +33,31 @@ public class CmpStepELSpringbootTest extends BaseTest { @Test public void testStep1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test public void testStep2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } @Test public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Map> stepMap = response.getExecuteSteps(); - Assert.assertEquals(2, stepMap.size()); + Assertions.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); - Assert.assertEquals(5, queue.size()); + Assertions.assertEquals(5, queue.size()); Set tagSet = new HashSet<>(); response.getExecuteStepQueue() @@ -71,7 +65,7 @@ public class CmpStepELSpringbootTest extends BaseTest { .filter(cmpStep -> cmpStep.getNodeId().equals("a")) .forEach(cmpStep -> tagSet.add(cmpStep.getTag())); - Assert.assertEquals(3, tagSet.size()); + Assertions.assertEquals(3, tagSet.size()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java index e73d60e28..f8f6f74fa 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java @@ -5,18 +5,15 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/comments/application.properties") @SpringBootTest(classes = LiteflowNodeELSpringbootTest.class) @EnableAutoConfiguration @@ -32,9 +29,9 @@ public class LiteflowNodeELSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); DefaultContext context = response.getFirstContextBean(); String str = context.getData("str"); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); - Assert.assertEquals("https://liteflow.yomahub.com", str); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); + Assertions.assertEquals("https://liteflow.yomahub.com", str); } } \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest1.java index ec19d54f1..4299a575a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest1.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.complex; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/complex/application1.properties") @SpringBootTest(classes = ComplexELSpringbootTest1.class) @EnableAutoConfiguration @@ -35,7 +32,7 @@ public class ComplexELSpringbootTest1 extends BaseTest { @Test public void testComplex1_1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1_1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试复杂例子,优化后 @@ -44,7 +41,7 @@ public class ComplexELSpringbootTest1 extends BaseTest { @Test public void testComplex1_2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1_2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest2.java index 7c15b994b..8442e7abc 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/complex/ComplexELSpringbootTest2.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.complex; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/complex/application2.properties") @SpringBootTest(classes = ComplexELSpringbootTest2.class) @EnableAutoConfiguration @@ -35,7 +32,7 @@ public class ComplexELSpringbootTest2 extends BaseTest { @Test public void testComplex2_1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2_1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试复杂例子,优化后 @@ -44,7 +41,7 @@ public class ComplexELSpringbootTest2 extends BaseTest { @Test public void testComplex2_2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2_2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELSpringbootTest.java index 1e30b4376..572294c48 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorELSpringbootTest.java @@ -3,16 +3,14 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.ReflectionUtils; import javax.annotation.Resource; @@ -22,7 +20,6 @@ import javax.annotation.Resource; * * @author donguo.tao */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/component/application.properties") @SpringBootTest(classes = FlowExecutorELSpringbootTest.class) @EnableAutoConfiguration @@ -38,63 +35,65 @@ public class FlowExecutorELSpringbootTest extends BaseTest { @Test public void testIsAccess() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); - Assert.assertTrue(response.isSuccess()); - Assert.assertNotNull(response.getSlot().getResponseData()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNotNull(response.getSlot().getResponseData()); } //测试在isAccess里setIsEnd(true) @Test public void testIsAccess2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1-2", null); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 组件抛错的功能点测试 - @Test(expected = ArithmeticException.class) + @Test public void testComponentException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("/ by zero", response.getMessage()); - ReflectionUtils.rethrowException(response.getCause()); + Assertions.assertThrows(ArithmeticException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("/ by zero", response.getMessage()); + ReflectionUtils.rethrowException(response.getCause()); + }); } // isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCause()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCause()); } // isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d", response.getExecuteStepStr()); } // setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("e", response.getExecuteStepStr()); } // 条件组件的功能点测试 @Test public void testNodeCondComponent() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringbootTest.java index b8c84e376..5f195c83c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringbootTest.java @@ -3,16 +3,14 @@ package com.yomahub.liteflow.test.customNodes; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -22,7 +20,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/customNodes/application.properties") @SpringBootTest(classes = CustomNodesELSpringbootTest.class) @EnableAutoConfiguration @@ -37,9 +34,9 @@ public class CustomNodesELSpringbootTest extends BaseTest { @Test public void testCustomNodes() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringbootTest.java index 45516e80e..477d82a72 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringbootTest.java @@ -4,16 +4,14 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -23,7 +21,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/customWhenThreadPool/application.properties") @SpringBootTest(classes = CustomWhenThreadPoolELSpringbootTest.class) @EnableAutoConfiguration @@ -42,8 +39,8 @@ public class CustomWhenThreadPoolELSpringbootTest extends BaseTest { public void testGlobalThreadPool() { LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -53,8 +50,8 @@ public class CustomWhenThreadPoolELSpringbootTest extends BaseTest { public void testGlobalAndCustomWhenThreadPool() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response1.getFirstContextBean(); - Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } /** @@ -67,8 +64,8 @@ public class CustomWhenThreadPoolELSpringbootTest extends BaseTest { // chain配置同一个thead1 LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response2.getFirstContextBean(); - Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response2.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELSpringbootTest.java index 64ac4309e..e70ab573d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/EventELSpringbootTest.java @@ -4,14 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -21,7 +19,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.7.1 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/event/application.properties") @SpringBootTest(classes = EventELSpringbootTest.class) @EnableAutoConfiguration @@ -36,8 +33,8 @@ public class EventELSpringbootTest extends BaseTest { public void testEvent1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("abc", context.getData("test")); } // 测试组件失败事件 @@ -45,10 +42,10 @@ public class EventELSpringbootTest extends BaseTest { public void testEvent2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", context.getData("test")); - Assert.assertEquals("error:d", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("ab", context.getData("test")); + Assertions.assertEquals("error:d", context.getData("error")); } // 测试组件失败事件本身抛出异常 @@ -56,10 +53,10 @@ public class EventELSpringbootTest extends BaseTest { public void testEvent3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", context.getData("test")); - Assert.assertEquals("error:e", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("a", context.getData("test")); + Assertions.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringBootTest.java index 5d3c6d777..f17caed39 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringBootTest.java @@ -4,19 +4,13 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.exception.ChainDuplicateException; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.exception.FlowExecutorNotInitException; -import com.yomahub.liteflow.exception.FlowSystemException; -import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.ReflectionUtils; - import javax.annotation.Resource; /** @@ -24,7 +18,6 @@ import javax.annotation.Resource; * * @author zendwang */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = Exception1ELSpringBootTest.class) @EnableAutoConfiguration public class Exception1ELSpringBootTest extends BaseTest { @@ -35,31 +28,41 @@ public class Exception1ELSpringBootTest extends BaseTest { /** * 验证 chain 节点重复的异常 */ - @Test(expected = ChainDuplicateException.class) + @Test public void testChainDuplicateException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-exception.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(ChainDuplicateException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-exception.el.xml"); + flowExecutor.reloadRule(); + }); + } - @Test(expected = ConfigErrorException.class) + @Test public void testConfigErrorException() { - flowExecutor.setLiteflowConfig(null); - flowExecutor.reloadRule(); + Assertions.assertThrows(ConfigErrorException.class, () -> { + flowExecutor.setLiteflowConfig(null); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testFlowExecutorNotInitException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("error/flow.txt"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("error/flow.txt"); + flowExecutor.reloadRule(); + }); + } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testNoConditionInChainException() throws Exception { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-blank.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-blank.el.xml"); + flowExecutor.reloadRule(); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringBootTest.java index 4e753d4ce..dc4c5ac23 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringBootTest.java @@ -2,23 +2,19 @@ package com.yomahub.liteflow.test.exception; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.exception.ChainNotFoundException; -import com.yomahub.liteflow.exception.FlowSystemException; import com.yomahub.liteflow.exception.LiteFlowException; import com.yomahub.liteflow.exception.NoSwitchTargetNodeException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.ReflectionUtils; - import javax.annotation.Resource; /** @@ -26,7 +22,6 @@ import javax.annotation.Resource; * * @author zendwang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/exception/application.properties") @SpringBootTest(classes = Exception2ELSpringBootTest.class) @EnableAutoConfiguration @@ -39,46 +34,53 @@ public class Exception2ELSpringBootTest extends BaseTest { @Autowired private ApplicationContext context; - @Test(expected = ChainNotFoundException.class) + @Test public void testChainNotFoundException() throws Exception { - flowExecutor.execute("chain0", "it's a request"); + Assertions.assertThrows(ChainNotFoundException.class, () -> flowExecutor.execute("chain0", "it's a request")); } - @Test(expected = RuntimeException.class) + @Test public void testComponentCustomException() throws Exception { - flowExecutor.execute("chain1", "exception"); + Assertions.assertThrows(RuntimeException.class, new Executable() { + @Override + public void execute() throws Throwable { + flowExecutor.execute("chain1", "exception"); + } + }); } @Test public void testGetSlotFromResponseWhenException() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); - Assert.assertFalse(response.isSuccess()); - Assert.assertNotNull(response.getCause()); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertNotNull(response.getSlot()); } - @Test(expected = NoSwitchTargetNodeException.class) + @Test public void testNoTargetFindException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); - Assert.assertFalse(response.isSuccess()); - throw response.getCause(); + Assertions.assertThrows(NoSwitchTargetNodeException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); + Assertions.assertFalse(response.isSuccess()); + throw response.getCause(); + }); } @Test public void testInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "custom-stateful-exception"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("300", response.getCode()); - Assert.assertNotNull(response.getCause()); - Assert.assertTrue(response.getCause() instanceof LiteFlowException); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("300", response.getCode()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertTrue(response.getCause() instanceof LiteFlowException); + Assertions.assertNotNull(response.getSlot()); } @Test public void testNotInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "test"); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCode()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCode()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringbootTest.java index a65a4e341..fa723601b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringbootTest.java @@ -4,14 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.concurrent.Future; @@ -22,7 +20,6 @@ import java.util.concurrent.Future; * @author Bryan.Zhang * @since 2.6.13 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/execute2Future/application.properties") @SpringBootTest(classes = Executor2FutureELSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +33,7 @@ public class Executor2FutureELSpringbootTest extends BaseTest { public void testFuture() throws Exception { Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); LiteflowResponse response = future.get(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringbootTest.java index 644096d3e..ebaa9b2a9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringbootTest.java @@ -4,15 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; /** @@ -20,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/getChainName/application.properties") @SpringBootTest(classes = GetChainNameELSpringbootTest.class) @EnableAutoConfiguration @@ -34,28 +30,28 @@ public class GetChainNameELSpringbootTest extends BaseTest { public void testGetChainName1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); } @Test public void testGetChainName2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("chain2", context.getData("g")); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); - Assert.assertEquals("sub5", context.getData("f")); - Assert.assertEquals("sub5_chain2", context.getData("e")); - Assert.assertEquals("sub6", context.getData("h")); - Assert.assertEquals("sub6", context.getData("j")); - Assert.assertNull(context.getData("k")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("chain2", context.getData("g")); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); + Assertions.assertEquals("sub5", context.getData("f")); + Assertions.assertEquals("sub5_chain2", context.getData("e")); + Assertions.assertEquals("sub6", context.getData("h")); + Assertions.assertEquals("sub6", context.getData("j")); + Assertions.assertNull(context.getData("k")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfELSpringbootTest.java index 65be20f8b..cb0eedf59 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/ifelse/IfELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.ifelse; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/ifelse/application.properties") @SpringBootTest(classes = IfELSpringbootTest.class) @EnableAutoConfiguration @@ -33,64 +30,64 @@ public class IfELSpringbootTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } // IF节点中isAccess返回false,这个情况相当于IF整个表达式串没执行 @Test public void testIf8() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("c", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringbootTest.java index 1c34d349b..cdeb448d0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringbootTest.java @@ -5,15 +5,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; import java.util.List; @@ -22,7 +19,6 @@ import java.util.List; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/iterator/application.properties") @SpringBootTest(classes = IteratorELSpringbootTest.class) @EnableAutoConfiguration @@ -37,10 +33,10 @@ public class IteratorELSpringbootTest extends BaseTest { public void testIt1() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain1", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("123", str); + Assertions.assertEquals("123", str); } // 迭代器带break @@ -48,16 +44,16 @@ public class IteratorELSpringbootTest extends BaseTest { public void testIt2() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("12", str); + Assertions.assertEquals("12", str); } // 多层迭代 @Test public void testIt3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELSpringbootTest.java index cfc267250..7b241fe87 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazyELSpringbootTest.java @@ -3,9 +3,6 @@ package com.yomahub.liteflow.test.lazy; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringbootTest.java index 9d6747d9c..d67beea42 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringbootTest.java @@ -3,15 +3,13 @@ package com.yomahub.liteflow.test.lfCmpAnno; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; /** * 测试@LiteflowComponent标注 @@ -19,7 +17,6 @@ import org.springframework.test.context.junit4.SpringRunner; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/lfCmpAnno/application.properties") @SpringBootTest(classes = LiteflowComponentELSpringbootTest.class) @EnableAutoConfiguration @@ -32,8 +29,8 @@ public class LiteflowComponentELSpringbootTest extends BaseTest { @Test public void testConfig() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringbootTest.java index 21892a767..ac5916b09 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringbootTest.java @@ -1,31 +1,24 @@ package com.yomahub.liteflow.test.loop; -import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; -import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; /** * springboot环境EL循环的例子测试 * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/loop/application.properties") @SpringBootTest(classes = LoopELSpringbootTest.class) @EnableAutoConfiguration @@ -39,31 +32,31 @@ public class LoopELSpringbootTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -71,8 +64,8 @@ public class LoopELSpringbootTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } @@ -81,10 +74,10 @@ public class LoopELSpringbootTest extends BaseTest { public void testLoop6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } // 测试WHILE循环中的index @@ -92,10 +85,10 @@ public class LoopELSpringbootTest extends BaseTest { public void testLoop7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } // 测试嵌套循环 @@ -105,14 +98,14 @@ public class LoopELSpringbootTest extends BaseTest { DefaultContext context = response.getFirstContextBean(); List list = context.getData("test"); String str = StrUtil.join(StrUtil.EMPTY, list); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("001101201", str); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("001101201", str); } //FOR循环同一个组件,下标获取不到问题的测试 @Test public void testLoop9() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringbootTest.java index 1fdef50a0..6f73c6b56 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringbootTest.java @@ -5,15 +5,13 @@ import com.yomahub.liteflow.flow.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.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -23,7 +21,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/monitor/application.properties") @SpringBootTest(classes = MonitorELSpringbootTest.class) @EnableAutoConfiguration @@ -36,12 +33,12 @@ public class MonitorELSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Thread.sleep(10000); } - @AfterClass + @AfterAll public static void clean() { MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class); monitorBus.closeScheduler(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELSpringbootTest.java index 2ffdd06e2..1641688be 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELSpringbootTest.java @@ -6,9 +6,8 @@ import cn.hutool.core.util.CharsetUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -18,7 +17,6 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.io.File; -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/monitorFile/application.properties") @SpringBootTest(classes = MonitorFileELSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +34,7 @@ public class MonitorFileELSpringbootTest extends BaseTest { FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); Thread.sleep(3000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>c==>b", response.getExecuteStepStr()); + Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELSpringbootTest.java index 3835bbdbc..b94621d7a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextELSpringbootTest.java @@ -6,14 +6,12 @@ import com.yomahub.liteflow.exception.NoSuchContextBeanException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -23,7 +21,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/multiContext/application.properties") @SpringBootTest(classes = MultiContextELSpringbootTest.class) @EnableAutoConfiguration @@ -38,18 +35,20 @@ public class MultiContextELSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); OrderContext orderContext = response.getContextBean(OrderContext.class); CheckContext checkContext = response.getContextBean(CheckContext.class); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("987XYZ", checkContext.getSign()); - Assert.assertEquals(95, checkContext.getRandomId()); - Assert.assertEquals("SO12345", orderContext.getOrderNo()); - Assert.assertEquals(2, orderContext.getOrderType()); - Assert.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("987XYZ", checkContext.getSign()); + Assertions.assertEquals(95, checkContext.getRandomId()); + Assertions.assertEquals("SO12345", orderContext.getOrderNo()); + Assertions.assertEquals(2, orderContext.getOrderType()); + Assertions.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); } - @Test(expected = NoSuchContextBeanException.class) + @Test public void testMultiContext2() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); - DefaultContext context = response.getContextBean(DefaultContext.class); + Assertions.assertThrows(NoSuchContextBeanException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); + DefaultContext context = response.getContextBean(DefaultContext.class); + }); } @Test @@ -59,11 +58,11 @@ public class MultiContextELSpringbootTest extends BaseTest { CheckContext checkContext = new CheckContext(); checkContext.setSign("987654321d"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); OrderContext context1 = response.getContextBean(OrderContext.class); CheckContext context2 = response.getContextBean(CheckContext.class); - Assert.assertEquals("SO11223344", context1.getOrderNo()); - Assert.assertEquals("987654321d", context2.getSign()); + Assertions.assertEquals("SO11223344", context1.getOrderNo()); + Assertions.assertEquals("987654321d", context2.getSign()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringbootTest.java index 95689d51b..48ddd8f04 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringbootTest.java @@ -3,15 +3,13 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; /** * 测试springboot下混合格式规则的场景 @@ -19,7 +17,6 @@ import org.springframework.test.context.junit4.SpringRunner; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/multipleType/application.properties") @SpringBootTest(classes = LiteflowMultipleTypeELSpringbootTest.class) @EnableAutoConfiguration @@ -32,11 +29,11 @@ public class LiteflowMultipleTypeELSpringbootTest extends BaseTest { @Test public void testMultipleType() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringbootTest.java index 56c26dee4..367dc1215 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringbootTest.java @@ -4,14 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -21,7 +19,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/nodeExecutor/application.properties") @SpringBootTest(classes = LiteflowNodeExecutorELSpringbootTest.class) @EnableAutoConfiguration @@ -36,9 +33,9 @@ public class LiteflowNodeExecutorELSpringbootTest extends BaseTest { public void testCustomerDefaultNodeExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("a", response.getExecuteStepStr()); } // 默认执行器测试+全局重试配置测试 @@ -46,17 +43,17 @@ public class LiteflowNodeExecutorELSpringbootTest extends BaseTest { public void testDefaultExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("b==>b==>b", response.getExecuteStepStr()); } // 自定义执行器测试 @Test public void testCustomerExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("c", response.getExecuteStepStr()); } // 自定义执行器测试+全局重试配置测试 @@ -64,9 +61,9 @@ public class LiteflowNodeExecutorELSpringbootTest extends BaseTest { public void testCustomExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); - Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); + Assertions.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamELSpringbootTest.java index 97c864742..161662112 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamELSpringbootTest.java @@ -2,15 +2,13 @@ package com.yomahub.liteflow.test.nullParam; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; /** * 单元测试:传递null param导致NPE的优化代码 @@ -18,7 +16,6 @@ import org.springframework.test.context.junit4.SpringRunner; * @author LeoLee * @since 2.6.6 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/nullParam/application.properties") @SpringBootTest(classes = NullParamELSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +31,7 @@ public class NullParamELSpringbootTest { @Test public void testNullParam() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringbootTest.java index efc8ef0d8..c635bd162 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -20,7 +18,6 @@ import javax.annotation.Resource; * @author dongguo.tao * @since 2.5.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/parsecustom/application-custom-json.properties") @SpringBootTest(classes = CustomParserJsonELSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +31,7 @@ public class CustomParserJsonELSpringbootTest extends BaseTest { @Test public void testJsonCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELSpringbootTest.java index 63c51e29f..c620d9bfd 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlELSpringbootTest.java @@ -3,15 +3,12 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; /** @@ -20,7 +17,6 @@ import javax.annotation.Resource; * @author bryan.zhang * @since 2.5.7 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/parsecustom/application-custom-xml.properties") @SpringBootTest(classes = CustomParserXmlELSpringbootTest.class) @EnableAutoConfiguration @@ -34,7 +30,7 @@ public class CustomParserXmlELSpringbootTest extends BaseTest { @Test public void testXmlCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserYmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserYmlELSpringbootTest.java index 7742b478f..a0075f35d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserYmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserYmlELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author junjun */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/parsecustom/application-custom-yml.properties") @SpringBootTest(classes = CustomParserYmlELSpringbootTest.class) @EnableAutoConfiguration @@ -33,7 +30,7 @@ public class CustomParserYmlELSpringbootTest extends BaseTest { @Test public void testYmlCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELSpringbootTest.java index 765965948..8ba529a6a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserELSpringbootTest.java @@ -3,13 +3,11 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/parser/application-json.properties") @SpringBootTest(classes = JsonParserELSpringbootTest.class) @EnableAutoConfiguration @@ -32,7 +29,7 @@ public class JsonParserELSpringbootTest extends BaseTest { @Test public void testJsonParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELSpringbootTest.java index 6b33d15a0..0fde5834b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportELSpringbootTest.java @@ -3,17 +3,14 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/parser/application-springEL.properties") @SpringBootTest(classes = SpringELSupportELSpringbootTest.class) @EnableAutoConfiguration @@ -26,7 +23,7 @@ public class SpringELSupportELSpringbootTest extends BaseTest { @Test public void testSpringELParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELSpringbootTest.java index c29fa84c8..17b4d3ff3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserELSpringbootTest.java @@ -3,13 +3,11 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/parser/application-xml.properties") @SpringBootTest(classes = XmlParserELSpringbootTest.class) @EnableAutoConfiguration @@ -32,7 +29,7 @@ public class XmlParserELSpringbootTest extends BaseTest { @Test public void testXmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELSpringbootTest.java index 5d6c84b63..1fb333778 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserELSpringbootTest.java @@ -3,13 +3,11 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/parser/application-yml.properties") @SpringBootTest(classes = YmlParserELSpringbootTest.class) @EnableAutoConfiguration @@ -32,7 +29,7 @@ public class YmlParserELSpringbootTest extends BaseTest { @Test public void testYmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringbootTest.java index 0a6936d3e..64cf00bf7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringbootTest.java @@ -4,14 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -21,7 +19,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/preAndFinally/application.properties") @SpringBootTest(classes = PreAndFinallyELSpringbootTest.class) @EnableAutoConfiguration @@ -35,24 +32,24 @@ public class PreAndFinallyELSpringbootTest extends BaseTest { @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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } // 测试在finally节点里是否能获取exception @@ -60,31 +57,31 @@ public class PreAndFinallyELSpringbootTest extends BaseTest { public void testPreAndFinally4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(context.getData("hasEx")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue((Boolean) context.getData("hasEx")); } // 测试嵌套结构pre和finally是否在各自的chain里打出 @Test public void testPreAndFinally5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } // 测试变量结构pre和finally是否在各自的chain里打出 @Test public void testPreAndFinally6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } // 测试el整体结构的多重pre和finally @Test public void testPreAndFinally7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringbootTest.java index 70447b208..659060d60 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringbootTest.java @@ -5,9 +5,8 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +21,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/privateDelivery/application.properties") @SpringBootTest(classes = PrivateDeliveryELSpringbootTest.class) @EnableAutoConfiguration @@ -37,8 +35,8 @@ public class PrivateDeliveryELSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); ConcurrentHashSet set = context.getData("testSet"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(100, set.size()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(100, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringbootTest.java index 76971e72b..73aa495c5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringbootTest.java @@ -6,15 +6,12 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; /** @@ -23,7 +20,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/refreshRule/application.properties") @SpringBootTest(classes = RefreshRuleELSpringbootTest.class) @EnableAutoConfiguration @@ -39,7 +35,7 @@ public class RefreshRuleELSpringbootTest extends BaseTest { String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.el.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, content); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试优雅刷新的场景 @@ -59,7 +55,7 @@ public class RefreshRuleELSpringbootTest extends BaseTest { for (int i = 0; i < 500; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); try { Thread.sleep(10L); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringbootTest.java index c94295a7f..26ed24e5e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -20,7 +18,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/reload/application.properties") @SpringBootTest(classes = ReloadELSpringbootTest.class) @EnableAutoConfiguration @@ -36,7 +33,7 @@ public class ReloadELSpringbootTest extends BaseTest { public void testReload() throws Exception { flowExecutor.reloadRule(); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringbootTest.java index cfca512b4..a10502ffc 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringbootTest.java @@ -4,14 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -21,7 +19,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/removeChain/application.properties") @SpringBootTest(classes = RemoveChainELSpringbootTest.class) @EnableAutoConfiguration @@ -34,10 +31,10 @@ public class RemoveChainELSpringbootTest extends BaseTest { @Test public void testRemoveChain() throws Exception { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response1.isSuccess()); + Assertions.assertTrue(response1.isSuccess()); FlowBus.removeChain("chain1"); LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response2.isSuccess()); + Assertions.assertFalse(response2.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringbootTest.java index 4f06fe5bc..62ccebebe 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringbootTest.java @@ -4,21 +4,18 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; /** * @author tangkc */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/requestId/application.properties") @SpringBootTest(classes = LiteflowRequestIdELSpringbootTest.class) @EnableAutoConfiguration @@ -31,14 +28,14 @@ public class LiteflowRequestIdELSpringbootTest extends BaseTest { @Test public void testRequestId1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1", response.getRequestId()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1", response.getRequestId()); } @Test public void testRequestId2() throws Exception { LiteflowResponse response = flowExecutor.execute2RespWithRid("chain1", null, "T001234", DefaultContext.class); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("T001234", response.getRequestId()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("T001234", response.getRequestId()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/slotOffer/SlotOfferELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/slotOffer/SlotOfferELSpringbootTest.java index 01040f570..042ee84ae 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/slotOffer/SlotOfferELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/slotOffer/SlotOfferELSpringbootTest.java @@ -3,33 +3,22 @@ package com.yomahub.liteflow.test.slotOffer; import cn.hutool.core.collection.ConcurrentHashSet; import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.flow.FlowBus; -import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.flow.parallel.ParallelSupplier; import com.yomahub.liteflow.slot.DataBus; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; -import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; -import java.util.function.Supplier; /** * springboot环境EL常规的例子测试 * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = SlotOfferELSpringbootTest.class) @EnableAutoConfiguration public class SlotOfferELSpringbootTest extends BaseTest { @@ -70,9 +59,9 @@ public class SlotOfferELSpringbootTest extends BaseTest { resultFuture.get(); - Assert.assertEquals(0, set.size()); - Assert.assertEquals(0, error.size()); - Assert.assertEquals(0, DataBus.OCCUPY_COUNT.get()); + Assertions.assertEquals(0, set.size()); + Assertions.assertEquals(0, error.size()); + Assertions.assertEquals(0, DataBus.OCCUPY_COUNT.get()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringbootTest.java index 692515642..f91a7e834 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringbootTest.java @@ -4,15 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.annotation.Repeat; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.HashSet; @@ -23,7 +20,6 @@ import java.util.Set; * * @author justin.xu */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/subflow/application-implicit.properties") @SpringBootTest(classes = ImplicitSubFlowELSpringbootTest.class) @EnableAutoConfiguration @@ -40,15 +36,15 @@ public class ImplicitSubFlowELSpringbootTest extends BaseTest { public void testImplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); // 传递了slotIndex,则set的size==1 - Assert.assertEquals(1, RUN_TIME_SLOT.size()); + Assertions.assertEquals(1, RUN_TIME_SLOT.size()); // set中第一次设置的requestId和response中的requestId一致 - Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); + Assertions.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); // requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); + Assertions.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } // 在p里多线程调用q 10次,每个q取到的参数都是不同的。 @@ -56,18 +52,18 @@ public class ImplicitSubFlowELSpringbootTest extends BaseTest { public void testImplicitSubFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("c1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Set set = context.getData("test"); // requestData的取值正确 - Assert.assertEquals(10, set.size()); + Assertions.assertEquals(10, set.size()); } @Test public void testImplicitSubFlow3() { LiteflowResponse response = flowExecutor.execute2Resp("chain_r", "it's a request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringbootTest.java index 8d34c447a..563a9a34d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringbootTest.java @@ -5,16 +5,14 @@ import com.yomahub.liteflow.exception.MultipleParsersException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -23,7 +21,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/subflow/application-subInDifferentConfig1.properties") @SpringBootTest(classes = SubflowInDifferentConfigELSpringbootTest.class) @EnableAutoConfiguration @@ -37,19 +34,20 @@ public class SubflowInDifferentConfigELSpringbootTest extends BaseTest { @Test public void testExplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } @Autowired private ApplicationContext context; // 主要测试有不同的配置类型后会不会报出既定的错误 - @Test(expected = MultipleParsersException.class) + @Test public void testExplicitSubFlow2() { - LiteflowConfig config = context.getBean(LiteflowConfig.class); - config.setRuleSource("subflow/flow-main.el.xml,subflow/flow-sub1.el.xml,subflow/flow-sub2.el.yml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(MultipleParsersException.class, () -> { + LiteflowConfig config = context.getBean(LiteflowConfig.class); + config.setRuleSource("subflow/flow-main.el.xml,subflow/flow-sub1.el.xml,subflow/flow-sub2.el.yml"); + flowExecutor.reloadRule(); + }); } - } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELSpringBootTest.java index 2e8e88a80..ae6bdb8cb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELSpringBootTest.java @@ -3,15 +3,12 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; /** @@ -19,7 +16,6 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/subflow/application-json.properties") @SpringBootTest(classes = SubflowJsonELSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +29,8 @@ public class SubflowJsonELSpringBootTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringBootTest.java index c164cc2a4..ea93b075d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringBootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/subflow/application-xml.properties") @SpringBootTest(classes = SubflowXMLELSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +30,8 @@ public class SubflowXMLELSpringBootTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringBootTest.java index 5197c6d00..73e18dc5b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringBootTest.java @@ -3,15 +3,12 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - import javax.annotation.Resource; /** @@ -19,7 +16,6 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/subflow/application-yml.properties") @SpringBootTest(classes = SubflowYmlELSpringBootTest.class) @EnableAutoConfiguration @@ -33,8 +29,8 @@ public class SubflowYmlELSpringBootTest extends BaseTest { @Test public void testExplicitSubFlowYml() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/substituteNode/SubstituteSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/substituteNode/SubstituteSpringbootTest.java index 72a138731..9323de377 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/substituteNode/SubstituteSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/substituteNode/SubstituteSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.substituteNode; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/substituteNode/application.properties") @SpringBootTest(classes = SubstituteSpringbootTest.class) @EnableAutoConfiguration @@ -33,21 +30,21 @@ public class SubstituteSpringbootTest extends BaseTest { @Test public void testSub1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 有替补节点 @Test public void testSub2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试特殊命名的节点 @Test public void testSub3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java index ed2c147e0..734cadf91 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java @@ -3,14 +3,12 @@ package com.yomahub.liteflow.test.switchcase; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +17,6 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/switchcase/application.properties") @SpringBootTest(classes = SwitchELSpringbootTest.class) @EnableAutoConfiguration @@ -35,91 +32,91 @@ public class SwitchELSpringbootTest extends BaseTest { @Test public void testSwitch1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); } @Test public void testSwitch2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d", response.getExecuteStepStr()); } @Test public void testSwitch3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>f==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>f==>b", response.getExecuteStepStr()); } // 根据tag来跳转,指定哪个组件的tag @Test public void testSwitch4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>g==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>g==>d", response.getExecuteStepStr()); } // tag的跳转 @Test public void testSwitch5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>h==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr()); } // 相同组件的tag的跳转 @Test public void testSwitch6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>h==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr()); } // switch增加default选项 @Test public void testSwitch7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>i==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>i==>d", response.getExecuteStepStr()); } // switch返回如果是空,会走default选项 @Test public void testSwitch8() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>j==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>j==>d", response.getExecuteStepStr()); } // 测试跳转到某个链路上 @Test public void testSwitch9() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("k==>a==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("k==>a==>b", response.getExecuteStepStr()); } // 相同组件复用的用例 @Test public void testSwitch10() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 表达式上设置tag @Test public void testSwitch11() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain12", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 给chain设置tag,跳转到chain上 @Test public void testSwitch13() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain13", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootJsonTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootJsonTest.java index 2dd64e18b..3ff68a950 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootJsonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootJsonTest.java @@ -5,14 +5,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -22,7 +20,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/tag/application-json.properties") @SpringBootTest(classes = NodeTagELSpringbootJsonTest.class) @EnableAutoConfiguration @@ -36,15 +33,15 @@ public class NodeTagELSpringbootJsonTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -54,9 +51,9 @@ public class NodeTagELSpringbootJsonTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -64,8 +61,8 @@ public class NodeTagELSpringbootJsonTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootXmlTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootXmlTest.java index e0a3c4062..c02a58f03 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootXmlTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringbootXmlTest.java @@ -5,14 +5,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -22,7 +20,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/tag/application-xml.properties") @SpringBootTest(classes = NodeTagELSpringbootXmlTest.class) @EnableAutoConfiguration @@ -36,15 +33,15 @@ public class NodeTagELSpringbootXmlTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -54,9 +51,9 @@ public class NodeTagELSpringbootXmlTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -64,8 +61,8 @@ public class NodeTagELSpringbootXmlTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } // 测试tag是否能在WHEN中起效果 @@ -73,8 +70,8 @@ public class NodeTagELSpringbootXmlTest extends BaseTest { public void testTag5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1", context.getData("test")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/url/LiteflowNodeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/url/LiteflowNodeELSpringbootTest.java index 600c04717..b80fc8a7b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/url/LiteflowNodeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/url/LiteflowNodeELSpringbootTest.java @@ -5,18 +5,15 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/url/application.properties") @SpringBootTest(classes = LiteflowNodeELSpringbootTest.class) @EnableAutoConfiguration @@ -32,9 +29,9 @@ public class LiteflowNodeELSpringbootTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); DefaultContext context = response.getFirstContextBean(); String str = context.getData("oracleUrl"); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); - Assert.assertEquals("jdbc:oracle:thin:@//localhost:1521/USERS", str); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); + Assertions.assertEquals("jdbc:oracle:thin:@//localhost:1521/USERS", str); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringbootTest.java index 9c7615463..a9a7532b8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringbootTest.java @@ -4,14 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -21,7 +19,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.3 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/useTTLInWhen/application.properties") @SpringBootTest(classes = UseTTLInWhenELSpringbootTest.class) @EnableAutoConfiguration @@ -35,11 +32,11 @@ public class UseTTLInWhenELSpringbootTest extends BaseTest { public void testUseTTLInWhen() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,b", context.getData("b")); - Assert.assertEquals("hello,c", context.getData("c")); - Assert.assertEquals("hello,d", context.getData("d")); - Assert.assertEquals("hello,e", context.getData("e")); - Assert.assertEquals("hello,f", context.getData("f")); + Assertions.assertEquals("hello,b", context.getData("b")); + Assertions.assertEquals("hello,c", context.getData("c")); + Assertions.assertEquals("hello,d", context.getData("d")); + Assertions.assertEquals("hello,e", context.getData("e")); + Assertions.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/validateRule/ValidateRuleELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/validateRule/ValidateRuleELSpringbootTest.java index 66b87af11..3511de711 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/validateRule/ValidateRuleELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/validateRule/ValidateRuleELSpringbootTest.java @@ -2,28 +2,16 @@ package com.yomahub.liteflow.test.validateRule; import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; -import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.enums.NodeTypeEnum; -import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import com.yomahub.liteflow.test.base.BaseELSpringbootTest; import com.yomahub.liteflow.test.validateRule.cmp.ACmp; import com.yomahub.liteflow.test.validateRule.cmp.BCmp; import com.yomahub.liteflow.test.validateRule.cmp.CCmp; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; -import javax.annotation.Resource; - -@RunWith(SpringRunner.class) @SpringBootTest(classes = ValidateRuleELSpringbootTest.class) @EnableAutoConfiguration public class ValidateRuleELSpringbootTest extends BaseTest { @@ -48,8 +36,8 @@ public class ValidateRuleELSpringbootTest extends BaseTest { .setType(NodeTypeEnum.COMMON) .setClazz(CCmp.class) .build(); - Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, h)")); - Assert.assertTrue(LiteFlowChainELBuilder.validate("THEN(a, b, c)")); + Assertions.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, h)")); + Assertions.assertTrue(LiteFlowChainELBuilder.validate("THEN(a, b, c)")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest1.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest1.java index 108b4fe69..fa25396ea 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest1.java @@ -4,16 +4,14 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.exception.WhenTimeoutException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -23,7 +21,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/whenTimeOut/application1.properties") @SpringBootTest(classes = WhenTimeOutELSpringbootTest1.class) @EnableAutoConfiguration @@ -39,8 +36,8 @@ public class WhenTimeOutELSpringbootTest1 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest2.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest2.java index 2f06f6f3c..4a0c895e0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringbootTest2.java @@ -3,16 +3,14 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -22,7 +20,6 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/whenTimeOut/application2.properties") @SpringBootTest(classes = WhenTimeOutELSpringbootTest2.class) @EnableAutoConfiguration @@ -38,7 +35,7 @@ public class WhenTimeOutELSpringbootTest2 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-springnative/pom.xml index a2c4e4757..332c7fa64 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/pom.xml @@ -37,8 +37,12 @@ spring-context - junit - junit + jakarta.annotation + jakarta.annotation-api + + + org.junit.jupiter + junit-jupiter test diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringTest.java index da836cba9..5a662976c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathELSpringTest.java @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -17,7 +17,7 @@ import javax.annotation.Resource; * @author zendwang * @since 2.8.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/absoluteConfigPath/application.xml") public class AbsoluteConfigPathELSpringTest extends BaseTest { @@ -27,7 +27,7 @@ public class AbsoluteConfigPathELSpringTest extends BaseTest { @Test public void testAbsoluteConfig() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELSpringTest.java index 38f32a125..7ace8d384 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPELSpringTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -18,7 +18,7 @@ import javax.annotation.Resource; * @author zendwang * @since 2.8.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/aop/application-custom.xml") public class CustomAOPELSpringTest extends BaseTest { @@ -30,10 +30,10 @@ public class CustomAOPELSpringTest extends BaseTest { public void testCustomAopS() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); } // 测试自定义AOP,并行场景 @@ -41,10 +41,10 @@ public class CustomAOPELSpringTest extends BaseTest { public void testCustomAopP() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELSpringTest.java index 9fee62d42..32797b95e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPELSpringTest.java @@ -5,12 +5,12 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.test.BaseTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -21,7 +21,7 @@ import javax.annotation.Resource; * @since 2.8.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/aop/application-global.xml") public class GlobalAOPELSpringTest extends BaseTest { @@ -33,12 +33,12 @@ public class GlobalAOPELSpringTest extends BaseTest { public void testGlobalAopS() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("d")); - Assert.assertEquals("before_after", context.getData("e")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("d")); + Assertions.assertEquals("before_after", context.getData("e")); } // 测试全局AOP,并行场景 @@ -46,26 +46,26 @@ public class GlobalAOPELSpringTest extends BaseTest { public void testGlobalAopP() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("d")); - Assert.assertEquals("before_after", context.getData("e")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("d")); + Assertions.assertEquals("before_after", context.getData("e")); } @Test public void testGlobalAopException() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", context.getData("a")); - Assert.assertEquals("before_after", context.getData("b")); - Assert.assertEquals("before_after", context.getData("c")); - Assert.assertEquals("before_after", context.getData("f")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("before_after", context.getData("a")); + Assertions.assertEquals("before_after", context.getData("b")); + Assertions.assertEquals("before_after", context.getData("c")); + Assertions.assertEquals("before_after", context.getData("f")); } - @AfterClass + @AfterAll public static void cleanScanCache() { BaseTest.cleanScanCache(); ComponentScanner.cmpAroundAspect = null; diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringTest.java index faf11210b..3456ebf77 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeELSpringTest.java @@ -6,12 +6,11 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -19,7 +18,7 @@ import javax.annotation.Resource; * * @author ssss */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/asyncNode/application.xml") public class AsyncNodeELSpringTest extends BaseTest { @@ -32,7 +31,7 @@ public class AsyncNodeELSpringTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -40,7 +39,7 @@ public class AsyncNodeELSpringTest extends BaseTest { @Test public void testAsyncFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); - Assert.assertTrue( + Assertions.assertTrue( ListUtil .toList("b==>j==>g==>f==>h", "b==>j==>g==>h==>f", "b==>j==>h==>g==>f", "b==>j==>h==>f==>g", "b==>j==>f==>h==>g", "b==>j==>f==>g==>h") @@ -51,15 +50,15 @@ public class AsyncNodeELSpringTest extends BaseTest { @Test public void testAsyncFlow3_1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(response.getSlot().getException().getClass(), TestException.class); } // 测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @@ -68,12 +67,12 @@ public class AsyncNodeELSpringTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 因为不记录错误,所以最终结果是true - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 因为配置了不抛错,所以response里的cause应该为null - Assert.assertNull(response.getCause()); + Assertions.assertNull(response.getCause()); } // 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @@ -82,12 +81,12 @@ public class AsyncNodeELSpringTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 整个并行组是报错的,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 因为第一个when配置了会报错,所以response里的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @@ -96,12 +95,12 @@ public class AsyncNodeELSpringTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 第一个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(1), count); + Assertions.assertEquals(1, count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @@ -110,12 +109,12 @@ public class AsyncNodeELSpringTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); DefaultContext context = response.getFirstContextBean(); // 第二个when会抛错,所以最终结果是false - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 Integer count = context.getData("count"); - Assert.assertEquals(new Integer(2), count); + Assertions.assertEquals(2, count); // 第一个when会报错,所以最终response的cause里应该会有TestException - Assert.assertEquals(TestException.class, response.getCause().getClass()); + Assertions.assertEquals(TestException.class, response.getCause().getClass()); } // 测试任意异步一个执行完即继续的场景 @@ -126,8 +125,8 @@ public class AsyncNodeELSpringTest extends BaseTest { public void testAsyncFlow8() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("check").toString().startsWith("habc")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/base/BaseCommonELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/base/BaseCommonELSpringTest.java index 933d8f0ef..b3e3a7e2a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/base/BaseCommonELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/base/BaseCommonELSpringTest.java @@ -3,15 +3,15 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/base/application.xml") public class BaseCommonELSpringTest extends BaseTest { @@ -21,8 +21,8 @@ public class BaseCommonELSpringTest extends BaseTest { @Test public void testBaseCommon() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringTest1.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringTest1.java index 3beb0ef01..4796afc1b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringTest1.java @@ -13,17 +13,18 @@ import com.yomahub.liteflow.test.builder.cmp1.DCmp; import com.yomahub.liteflow.test.builder.cmp1.ECmp; import com.yomahub.liteflow.test.builder.cmp1.FCmp; import com.yomahub.liteflow.test.builder.cmp1.GCmp; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; //基于builder模式的单元测试 //这里只是最基本的builder模式的测试,只是为了验证在spring模式下的正常性 -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/builder/application1.xml") public class BuilderELSpringTest1 extends BaseTest { @@ -84,8 +85,8 @@ public class BuilderELSpringTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } // 基于普通组件的builder模式测试 @@ -142,8 +143,8 @@ public class BuilderELSpringTest1 extends BaseTest { .build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringTest2.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringTest2.java index b72c8cde3..419dbe9cc 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderELSpringTest2.java @@ -4,17 +4,17 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; //基于builder模式的单元测试 //这里测试的是通过spring去扫描,但是通过代码去构建chain的用例 -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/builder/application2.xml") public class BuilderELSpringTest2 extends BaseTest { @@ -27,8 +27,8 @@ public class BuilderELSpringTest2 extends BaseTest { LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(h, i, j)").build(); LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("h==>i==>j", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("h==>i==>j", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringTest.java index 0b060ef62..877839217 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryELSpringTest.java @@ -3,11 +3,12 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -18,7 +19,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/cmpRetry/application.xml") @ComponentScan({ "com.yomahub.liteflow.test.cmpRetry.cmp" }) public class LiteflowRetryELSpringTest extends BaseTest { @@ -30,31 +31,31 @@ public class LiteflowRetryELSpringTest extends BaseTest { @Test public void testRetry1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } // 单个组件重试配置测试 @Test public void testRetry2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } // 单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertFalse(response.isSuccess()); + Assertions.assertFalse(response.isSuccess()); } // 单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringTest.java index 789f8b2b3..6ea631107 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepELSpringTest.java @@ -4,16 +4,16 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.entity.CmpStep; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.util.*; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/cmpStep/application.xml") public class CmpStepELSpringTest extends BaseTest { @@ -23,31 +23,31 @@ public class CmpStepELSpringTest extends BaseTest { @Test public void testStep1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); - Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); - Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); - Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess()); + Assertions.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess()); + Assertions.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass()); + Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass()); } @Test public void testStep2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } @Test public void testStep3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Map> stepMap = response.getExecuteSteps(); - Assert.assertEquals(2, stepMap.size()); + Assertions.assertEquals(2, stepMap.size()); Queue queue = response.getExecuteStepQueue(); - Assert.assertEquals(5, queue.size()); + Assertions.assertEquals(5, queue.size()); Set tagSet = new HashSet<>(); response.getExecuteStepQueue() @@ -55,7 +55,7 @@ public class CmpStepELSpringTest extends BaseTest { .filter(cmpStep -> cmpStep.getNodeId().equals("a")) .forEach(cmpStep -> tagSet.add(cmpStep.getTag())); - Assert.assertEquals(3, tagSet.size()); + Assertions.assertEquals(3, tagSet.size()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java index 7399ff844..0a1bb1ebe 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/comments/LiteflowNodeELSpringbootTest.java @@ -4,15 +4,16 @@ import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/comments/application.xml") public class LiteflowNodeELSpringbootTest extends BaseTest { @@ -23,8 +24,8 @@ public class LiteflowNodeELSpringbootTest extends BaseTest { @Test public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr())); } } \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/component/ComponentELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/component/ComponentELSpringTest.java index 76e6e1cfa..0c4884dc6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/component/ComponentELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/component/ComponentELSpringTest.java @@ -3,13 +3,13 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.util.ReflectionUtils; import javax.annotation.Resource; @@ -19,7 +19,7 @@ import javax.annotation.Resource; * * @author donguo.tao */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/component/application.xml") public class ComponentELSpringTest extends BaseTest { @@ -32,56 +32,58 @@ public class ComponentELSpringTest extends BaseTest { @Test public void testIsAccess() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); - Assert.assertTrue(response.isSuccess()); - Assert.assertNotNull(response.getSlot().getResponseData()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNotNull(response.getSlot().getResponseData()); } // 组件抛错的功能点测试 - @Test(expected = ArithmeticException.class) + @Test public void testComponentException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("/ by zero", response.getMessage()); - ReflectionUtils.rethrowException(response.getCause()); + Assertions.assertThrows(ArithmeticException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("/ by zero", response.getMessage()); + ReflectionUtils.rethrowException(response.getCause()); + }); } // isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCause()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCause()); } // isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("d", response.getExecuteStepStr()); } // setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("e", response.getExecuteStepStr()); } // 条件组件的功能点测试 @Test public void testNodeCondComponent() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigELSpringTest.java index 3d5083c5d..8e2d0a813 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigELSpringTest.java @@ -4,14 +4,13 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.util.concurrent.TimeUnit; @@ -21,7 +20,7 @@ import java.util.concurrent.TimeUnit; * @author zendwang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/config/application-local.xml") public class LiteflowConfigELSpringTest extends BaseTest { @@ -35,17 +34,17 @@ public class LiteflowConfigELSpringTest extends BaseTest { public void testConfig() throws Exception { LiteflowConfig config = context.getBean(LiteflowConfig.class); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("config/flow.el.json", config.getRuleSource()); - Assert.assertEquals(15000, config.getWhenMaxWaitTime().intValue()); - Assert.assertEquals(TimeUnit.MILLISECONDS, config.getWhenMaxWaitTimeUnit()); - Assert.assertEquals(200, config.getQueueLimit().intValue()); - Assert.assertEquals(300000L, config.getDelay().longValue()); - Assert.assertEquals(300000L, config.getPeriod().longValue()); - Assert.assertFalse(config.getEnableLog()); - // Assert.assertEquals(Runtime.getRuntime().availableProcessors() * 2, + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("config/flow.el.json", config.getRuleSource()); + Assertions.assertEquals(15000, config.getWhenMaxWaitTime().intValue()); + Assertions.assertEquals(TimeUnit.MILLISECONDS, config.getWhenMaxWaitTimeUnit()); + Assertions.assertEquals(200, config.getQueueLimit().intValue()); + Assertions.assertEquals(300000L, config.getDelay().longValue()); + Assertions.assertEquals(300000L, config.getPeriod().longValue()); + Assertions.assertFalse(config.getEnableLog()); + // Assertions.assertEquals(Runtime.getRuntime().availableProcessors() * 2, // config.getWhenMaxWorkers().longValue()); - Assert.assertEquals(512, config.getWhenQueueLimit().longValue()); + Assertions.assertEquals(512, config.getWhenQueueLimit().longValue()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchELSpringTest.java index 6648fa192..ebc2654a9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchELSpringTest.java @@ -3,12 +3,11 @@ package com.yomahub.liteflow.test.config; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -17,7 +16,7 @@ import javax.annotation.Resource; * @author zendwang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/config/local-rule-source-pattern-match.xml") public class LocalRuleSourcePatternMatchELSpringTest extends BaseTest { @@ -30,9 +29,9 @@ public class LocalRuleSourcePatternMatchELSpringTest extends BaseTest { @Test public void testLocalJsonRuleSourcePatternMatch() { LiteflowResponse response0 = executor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>b==>c", response0.getExecuteStepStr()); + Assertions.assertEquals("a==>b==>c", response0.getExecuteStepStr()); LiteflowResponse response1 = executor.execute2Resp("chain3", "arg"); - Assert.assertEquals("a==>c==>f==>g", response1.getExecuteStepStr()); + Assertions.assertEquals("a==>c==>f==>g", response1.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringTest.java index a599c5287..ed87add91 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesELSpringTest.java @@ -3,14 +3,13 @@ package com.yomahub.liteflow.test.customNodes; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -19,7 +18,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/customNodes/application.xml") public class CustomNodesELSpringTest extends BaseTest { @@ -31,9 +30,9 @@ public class CustomNodesELSpringTest extends BaseTest { @Test public void testCustomNodes() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringTest.java index c32ecce85..6b76e4c84 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELSpringTest.java @@ -4,13 +4,13 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -20,7 +20,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/customWhenThreadPool/application.xml") public class CustomWhenThreadPoolELSpringTest extends BaseTest { @@ -36,8 +36,8 @@ public class CustomWhenThreadPoolELSpringTest extends BaseTest { public void testGlobalThreadPool() { LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -47,8 +47,8 @@ public class CustomWhenThreadPoolELSpringTest extends BaseTest { public void testGlobalAndCustomWhenThreadPool() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response1.getFirstContextBean(); - Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response1.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } /** @@ -61,8 +61,8 @@ public class CustomWhenThreadPoolELSpringTest extends BaseTest { // chain配置同一个thead1 LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response2.getFirstContextBean(); - Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); + Assertions.assertTrue(response2.isSuccess()); + Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableELSpringTest.java index 27f9b70ca..588f48ddf 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableELSpringTest.java @@ -4,13 +4,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -20,7 +19,7 @@ import javax.annotation.Resource; * @author qjwyss * @since 2.6.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/enable/application-local.xml") public class LiteflowEnableELSpringTest extends BaseTest { @@ -33,11 +32,11 @@ public class LiteflowEnableELSpringTest extends BaseTest { Boolean enable = config.getEnable(); if (enable) { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); return; } - Assert.assertFalse(enable); + Assertions.assertFalse(enable); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/EventELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/EventELSpringTest.java index 61c3c37e3..5721ab06f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/EventELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/EventELSpringTest.java @@ -4,15 +4,14 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/event/application.xml") public class EventELSpringTest extends BaseTest { @@ -24,8 +23,8 @@ public class EventELSpringTest extends BaseTest { public void testEvent1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("abc", context.getData("test")); } // 测试组件失败事件 @@ -33,10 +32,10 @@ public class EventELSpringTest extends BaseTest { public void testEvent2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", context.getData("test")); - Assert.assertEquals("error:d", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("ab", context.getData("test")); + Assertions.assertEquals("error:d", context.getData("error")); } // 测试组件失败事件本身抛出异常 @@ -44,10 +43,10 @@ public class EventELSpringTest extends BaseTest { public void testEvent3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", context.getData("test")); - Assert.assertEquals("error:e", context.getData("error")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(NullPointerException.class, response.getCause().getClass()); + Assertions.assertEquals("a", context.getData("test")); + Assertions.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringTest.java index 1233ef6cc..d64ceac55 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception1ELSpringTest.java @@ -7,9 +7,12 @@ import com.yomahub.liteflow.exception.FlowExecutorNotInitException; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.function.Executable; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; @@ -19,7 +22,7 @@ import javax.annotation.Resource; * * @author zendwang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/exception/application1.xml") public class Exception1ELSpringTest extends BaseTest { @@ -29,31 +32,41 @@ public class Exception1ELSpringTest extends BaseTest { /** * 验证 chain 节点重复的异常 */ - @Test(expected = ChainDuplicateException.class) + @Test public void testChainDuplicateException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-exception.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(ChainDuplicateException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-exception.el.xml"); + flowExecutor.reloadRule(); + }); } - @Test(expected = ConfigErrorException.class) + @Test public void testConfigErrorException() { - flowExecutor.setLiteflowConfig(null); - flowExecutor.reloadRule(); + Assertions.assertThrows(ConfigErrorException.class, () -> { + flowExecutor.setLiteflowConfig(null); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testFlowExecutorNotInitException() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("error/flow.txt"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("error/flow.txt"); + flowExecutor.reloadRule(); + }); } - @Test(expected = FlowExecutorNotInitException.class) + @Test public void testNoConditionInChainException() throws Exception { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("exception/flow-blank.el.xml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(FlowExecutorNotInitException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("exception/flow-blank.el.xml"); + flowExecutor.reloadRule(); + }); + + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringTest.java index 49e333f83..5efed2f4f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception2ELSpringTest.java @@ -6,12 +6,11 @@ import com.yomahub.liteflow.exception.LiteFlowException; import com.yomahub.liteflow.exception.NoSwitchTargetNodeException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -19,53 +18,55 @@ import javax.annotation.Resource; * * @author zendwang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/exception/application2.xml") public class Exception2ELSpringTest extends BaseTest { @Resource private FlowExecutor flowExecutor; - @Test(expected = ChainNotFoundException.class) + @Test public void testChainNotFoundException() throws Exception { - flowExecutor.execute("chain0", "it's a request"); + Assertions.assertThrows(ChainNotFoundException.class, () -> flowExecutor.execute("chain0", "it's a request")); } - @Test(expected = RuntimeException.class) + @Test public void testComponentCustomException() throws Exception { - flowExecutor.execute("chain1", "exception"); + Assertions.assertThrows(RuntimeException.class, () -> flowExecutor.execute("chain1", "exception")); } @Test public void testGetSlotFromResponseWhenException() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); - Assert.assertFalse(response.isSuccess()); - Assert.assertNotNull(response.getCause()); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertNotNull(response.getSlot()); } - @Test(expected = NoSwitchTargetNodeException.class) + @Test public void testNoTargetFindException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); - Assert.assertFalse(response.isSuccess()); - throw response.getCause(); + Assertions.assertThrows(NoSwitchTargetNodeException.class, () -> { + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test"); + Assertions.assertFalse(response.isSuccess()); + throw response.getCause(); + }); } @Test public void testInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "custom-stateful-exception"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("300", response.getCode()); - Assert.assertNotNull(response.getCause()); - Assert.assertTrue(response.getCause() instanceof LiteFlowException); - Assert.assertNotNull(response.getSlot()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("300", response.getCode()); + Assertions.assertNotNull(response.getCause()); + Assertions.assertTrue(response.getCause() instanceof LiteFlowException); + Assertions.assertNotNull(response.getSlot()); } @Test public void testNotInvokeCustomStatefulException() { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "test"); - Assert.assertTrue(response.isSuccess()); - Assert.assertNull(response.getCode()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertNull(response.getCode()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringTest.java index dea605f28..e5d35eeed 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureELSpringTest.java @@ -4,12 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.util.concurrent.Future; @@ -19,7 +18,7 @@ import java.util.concurrent.Future; * @author Bryan.Zhang * @since 2.6.13 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/execute2Future/application.xml") public class Executor2FutureELSpringTest extends BaseTest { @@ -30,7 +29,7 @@ public class Executor2FutureELSpringTest extends BaseTest { public void testFuture() throws Exception { Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); LiteflowResponse response = future.get(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaELSpringTest.java index 69791808d..06f2ae30c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaELSpringTest.java @@ -7,15 +7,16 @@ import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.flowmeta.cmp2.DCmp; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/flowmeta/application.xml") public class FlowMetaELSpringTest extends BaseTest { @@ -27,8 +28,8 @@ public class FlowMetaELSpringTest extends BaseTest { public void testFlowMeta() { FlowBus.addNode("d", "d组件", NodeTypeEnum.COMMON, DCmp.class); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>d[d组件]", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>d[d组件]", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringTest.java index f2d18d144..ac3ccd01a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/getChainName/GetChainNameELSpringTest.java @@ -4,12 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -17,7 +16,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/getChainName/application.xml") public class GetChainNameELSpringTest extends BaseTest { @@ -28,28 +27,28 @@ public class GetChainNameELSpringTest extends BaseTest { public void testGetChainName1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); } @Test public void testGetChainName2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("chain2", context.getData("g")); - Assert.assertEquals("sub1", context.getData("a")); - Assert.assertEquals("sub2", context.getData("b")); - Assert.assertEquals("sub3", context.getData("c")); - Assert.assertEquals("sub4", context.getData("d")); - Assert.assertEquals("sub5", context.getData("f")); - Assert.assertEquals("sub5_chain2", context.getData("e")); - Assert.assertEquals("sub6", context.getData("h")); - Assert.assertEquals("sub6", context.getData("j")); - Assert.assertNull(context.getData("k")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("chain2", context.getData("g")); + Assertions.assertEquals("sub1", context.getData("a")); + Assertions.assertEquals("sub2", context.getData("b")); + Assertions.assertEquals("sub3", context.getData("c")); + Assertions.assertEquals("sub4", context.getData("d")); + Assertions.assertEquals("sub5", context.getData("f")); + Assertions.assertEquals("sub5_chain2", context.getData("e")); + Assertions.assertEquals("sub6", context.getData("h")); + Assertions.assertEquals("sub6", context.getData("j")); + Assertions.assertNull(context.getData("k")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELSpringTest.java index 0e643e628..2a6c77dd4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/ifelse/IfElseELSpringTest.java @@ -3,15 +3,16 @@ package com.yomahub.liteflow.test.ifelse; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/ifelse/application.xml") public class IfElseELSpringTest extends BaseTest { @@ -22,56 +23,56 @@ public class IfElseELSpringTest extends BaseTest { @Test public void testIf1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime()); } // IF只有3个参数 @Test public void testIf2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有3个参数,进行嵌套 @Test public void testIf3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,加上ELSE @Test public void testIf4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime()); } // IF有2个参数,ELSE里再嵌套一个IF @Test public void testIf5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime()); } // 标准的IF ELIF ELSE @Test public void testIf6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime()); } // IF ELIF... ELSE 的形式 @Test public void testIf7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringTest.java index 2847e83bd..58eead611 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/iterator/IteratorELSpringTest.java @@ -5,16 +5,17 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.List; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/iterator/application.xml") public class IteratorELSpringTest extends BaseTest { @@ -26,10 +27,10 @@ public class IteratorELSpringTest extends BaseTest { public void testIt1() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain1", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("123", str); + Assertions.assertEquals("123", str); } // 迭代器带break @@ -37,10 +38,10 @@ public class IteratorELSpringTest extends BaseTest { public void testIt2() throws Exception { List list = ListUtil.toList("1", "2", "3"); LiteflowResponse response = flowExecutor.execute2Resp("chain2", list); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); DefaultContext context = response.getFirstContextBean(); String str = context.getData("test"); - Assert.assertEquals("12", str); + Assertions.assertEquals("12", str); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringTest.java index d2df5be6e..dc9a0db94 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentELSpringTest.java @@ -2,14 +2,13 @@ package com.yomahub.liteflow.test.lfCmpAnno; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; /** * 测试@LiteflowComponent标注 @@ -17,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/lfCmpAnno/application.xml") public class LiteflowComponentELSpringTest extends BaseTest { @@ -27,8 +26,8 @@ public class LiteflowComponentELSpringTest extends BaseTest { @Test public void testConfig() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringTest.java index 3c9b7d245..2b09e908b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/loop/LoopELSpringTest.java @@ -4,15 +4,16 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/loop/application.xml") public class LoopELSpringTest extends BaseTest { @@ -23,31 +24,31 @@ public class LoopELSpringTest extends BaseTest { @Test public void testLoop1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FPR循环由For组件定义 @Test public void testLoop2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr()); } // FOR循环中加入BREAK组件 @Test public void testLoop3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // WHILE循环 @Test public void testLoop4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z", response.getExecuteStepStr()); } @@ -55,8 +56,8 @@ public class LoopELSpringTest extends BaseTest { @Test public void testLoop5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y", response.getExecuteStepStr()); } @@ -65,10 +66,10 @@ public class LoopELSpringTest extends BaseTest { public void testLoop6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } // 测试WHILE循环中的index @@ -76,10 +77,10 @@ public class LoopELSpringTest extends BaseTest { public void testLoop7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("01234", context.getData("loop_e1")); - Assert.assertEquals("01234", context.getData("loop_e2")); - Assert.assertEquals("01234", context.getData("loop_e3")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("01234", context.getData("loop_e1")); + Assertions.assertEquals("01234", context.getData("loop_e2")); + Assertions.assertEquals("01234", context.getData("loop_e3")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringTest.java index 422b01f12..ce8f95728 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorELSpringTest.java @@ -3,15 +3,14 @@ package com.yomahub.liteflow.test.monitor; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.monitor.MonitorBus; -import com.yomahub.liteflow.slot.DefaultContext; 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.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -21,7 +20,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/monitor/application.xml") public class MonitorELSpringTest extends BaseTest { @@ -31,12 +30,12 @@ public class MonitorELSpringTest extends BaseTest { @Test public void testMonitor() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Thread.sleep(10000); } - @AfterClass + @AfterAll public static void clean() { MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class); monitorBus.closeScheduler(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringTest.java index 53ca0d5b0..e9e68980a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeELSpringTest.java @@ -2,14 +2,13 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; /** * 测试spring下混合格式规则的场景 @@ -17,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/multipleType/application.xml") public class LiteflowMultipleTypeELSpringTest extends BaseTest { @@ -27,11 +26,11 @@ public class LiteflowMultipleTypeELSpringTest extends BaseTest { @Test public void testMultipleType() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringTest.java index 5600f168e..dbff66d64 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorELSpringTest.java @@ -4,12 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -18,7 +17,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.10 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/nodeExecutor/application.xml") public class LiteflowNodeExecutorELSpringTest extends BaseTest { @@ -30,9 +29,9 @@ public class LiteflowNodeExecutorELSpringTest extends BaseTest { public void testCustomerDefaultNodeExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("a", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("a", response.getExecuteStepStr()); } // 默认执行器测试+全局重试配置测试 @@ -40,17 +39,17 @@ public class LiteflowNodeExecutorELSpringTest extends BaseTest { public void testDefaultExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); - Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); + Assertions.assertEquals("b==>b==>b", response.getExecuteStepStr()); } // 自定义执行器测试 @Test public void testCustomerExecutor() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("c", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("c", response.getExecuteStepStr()); } // 自定义执行器测试+全局重试配置测试 @@ -58,9 +57,9 @@ public class LiteflowNodeExecutorELSpringTest extends BaseTest { public void testCustomExecutorForRetry() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); - Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); + Assertions.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java index 45a862a91..91300e09a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java @@ -2,14 +2,12 @@ package com.yomahub.liteflow.test.nullParam; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -18,7 +16,7 @@ import javax.annotation.Resource; * @author LeoLee * @since 2.6.6 **/ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/nullParam/application-local.xml") public class NullParamTest extends BaseTest { @@ -31,7 +29,7 @@ public class NullParamTest extends BaseTest { @Test public void testNullParam() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringTest.java index 620216672..976ba2bf2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonELSpringTest.java @@ -2,13 +2,12 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -18,7 +17,7 @@ import javax.annotation.Resource; * @author dongguo.tao * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/parsecustom/application.xml") public class CustomParserJsonELSpringTest extends BaseTest { @@ -29,7 +28,7 @@ public class CustomParserJsonELSpringTest extends BaseTest { @Test public void testJsonCustomParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonELSpringTest.java index d5ad93d2f..7d5eb8e5c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonELSpringTest.java @@ -3,12 +3,11 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -17,7 +16,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/parser/application-json.xml") public class LFParserJsonELSpringTest extends BaseTest { @@ -28,7 +27,7 @@ public class LFParserJsonELSpringTest extends BaseTest { @Test public void testJsonParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonNoSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonNoSpringTest.java index ae6c61a33..e92e22940 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonNoSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonNoSpringTest.java @@ -4,8 +4,8 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * 无spring环境的json parser单元测试 @@ -22,7 +22,7 @@ public class LFParserJsonNoSpringTest extends BaseTest { liteflowConfig.setRuleSource("parser/flow.el.json"); FlowExecutor executor = new FlowExecutor(liteflowConfig); LiteflowResponse response = executor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlELSpringTest.java index d6c1caeb9..94f3181db 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlELSpringTest.java @@ -2,14 +2,12 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -18,7 +16,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/parser/application-xml.xml") public class LFParserXmlELSpringTest extends BaseTest { @@ -29,7 +27,7 @@ public class LFParserXmlELSpringTest extends BaseTest { @Test public void testXmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlNoSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlNoSpringTest.java index 9d09592a8..65678743a 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlNoSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlNoSpringTest.java @@ -4,8 +4,8 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * 无spring环境的xml parser单元测试 @@ -22,7 +22,7 @@ public class LFParserXmlNoSpringTest extends BaseTest { liteflowConfig.setRuleSource("parser/flow.el.xml"); FlowExecutor executor = new FlowExecutor(liteflowConfig); LiteflowResponse response = executor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlELSpringTest.java index 157434886..b3ca2e17b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlELSpringTest.java @@ -2,14 +2,12 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -18,7 +16,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/parser/application-yml.xml") public class LFParserYmlELSpringTest extends BaseTest { @@ -29,7 +27,7 @@ public class LFParserYmlELSpringTest extends BaseTest { @Test public void testYmlParser() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlNoSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlNoSpringTest.java index bcd53970e..592f70397 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlNoSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlNoSpringTest.java @@ -4,8 +4,8 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * 无spring环境的yml parser单元测试 @@ -22,7 +22,7 @@ public class LFParserYmlNoSpringTest extends BaseTest { liteflowConfig.setRuleSource("parser/flow.el.yml"); FlowExecutor executor = new FlowExecutor(liteflowConfig); LiteflowResponse response = executor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringTest.java index c56453ff4..db9b36d7c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyELSpringTest.java @@ -4,11 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -18,7 +18,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/preAndFinally/application.xml") public class PreAndFinallyELSpringTest extends BaseTest { @@ -29,24 +29,24 @@ public class PreAndFinallyELSpringTest extends BaseTest { @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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.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.getExecuteStepStr()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } // 测试在finally节点里是否能获取exception @@ -54,16 +54,16 @@ public class PreAndFinallyELSpringTest extends BaseTest { public void testPreAndFinally4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(context.getData("hasEx")); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertTrue((Boolean) context.getData("hasEx")); } // 测试嵌套结构pre和finally是否在各自的chain里打出 @Test public void testPreAndFinally5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringTest.java index 934f9656f..1d832bcb6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryELSpringTest.java @@ -5,14 +5,12 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; -import java.util.Set; /** * spring环境下隐私投递的测试 @@ -20,7 +18,7 @@ import java.util.Set; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/privateDelivery/application.xml") public class PrivateDeliveryELSpringTest extends BaseTest { @@ -32,8 +30,8 @@ public class PrivateDeliveryELSpringTest extends BaseTest { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); ConcurrentHashSet set = context.getData("testSet"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(100, set.size()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals(100, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringTest.java index 9c5df35f9..e81e8a36e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleELSpringTest.java @@ -6,12 +6,11 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -20,7 +19,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/refreshRule/application.xml") public class RefreshRuleELSpringTest extends BaseTest { @@ -33,7 +32,7 @@ public class RefreshRuleELSpringTest extends BaseTest { String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.el.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, content); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } // 测试优雅刷新的场景 @@ -53,7 +52,7 @@ public class RefreshRuleELSpringTest extends BaseTest { for (int i = 0; i < 500; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); try { Thread.sleep(10L); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringTest.java index 678b83ead..0784a46de 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/reload/ReloadELSpringTest.java @@ -2,13 +2,12 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -18,7 +17,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/reload/application.xml") public class ReloadELSpringTest extends BaseTest { @@ -31,7 +30,7 @@ public class ReloadELSpringTest extends BaseTest { public void testReload() throws Exception { flowExecutor.reloadRule(); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringTest.java index a655fa914..0e4070b85 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainELSpringTest.java @@ -3,17 +3,15 @@ package com.yomahub.liteflow.test.removeChain; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.FlowBus; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/removeChain/application.xml") public class RemoveChainELSpringTest extends BaseTest { @@ -23,10 +21,10 @@ public class RemoveChainELSpringTest extends BaseTest { @Test public void testRemoveChain() { LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response1.isSuccess()); + Assertions.assertTrue(response1.isSuccess()); FlowBus.removeChain("chain1"); LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response2.isSuccess()); + Assertions.assertFalse(response2.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringTest.java index 3971e34ec..287a8177e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/requestId/LiteflowRequestIdELSpringTest.java @@ -3,18 +3,18 @@ package com.yomahub.liteflow.test.requestId; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** * @author tangkc */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/requestId/application.xml") public class LiteflowRequestIdELSpringTest extends BaseTest { @@ -24,8 +24,8 @@ public class LiteflowRequestIdELSpringTest extends BaseTest { @Test public void testRequestId() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("1", response.getSlot().getRequestId()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("1", response.getSlot().getRequestId()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotELSpringTest.java index 42b5eee46..4b65e59e0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotELSpringTest.java @@ -5,12 +5,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DataBus; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.lang.reflect.Field; import java.util.ArrayList; @@ -26,7 +25,7 @@ import java.util.concurrent.Future; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/resizeSlot/application.xml") public class ResizeSlotELSpringTest extends BaseTest { @@ -44,7 +43,7 @@ public class ResizeSlotELSpringTest extends BaseTest { } for (Future future : futureList) { - Assert.assertTrue(future.get().isSuccess()); + Assertions.assertTrue(future.get().isSuccess()); } // 取到static的对象QUEUE @@ -54,7 +53,7 @@ public class ResizeSlotELSpringTest extends BaseTest { // 因为初始slotSize是4,按照0.75的扩容比,要满足100个线程,应该扩容5~6次,5次=65,6次=114 // 为什么不是直接114呢? // 因为在单测中根据机器的性能,在多线程情况下,有些机器跑的慢一点,也就是说65个就足够了。有些机器跑的快一点,是能真正扩容到114个的 - Assert.assertTrue(queue.size() > 4); + Assertions.assertTrue(queue.size() > 4); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringTest.java index dc1b2c608..0e99289bb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowELSpringTest.java @@ -4,12 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.util.HashSet; import java.util.Set; @@ -19,7 +18,7 @@ import java.util.Set; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/subflow/application-implicit.xml") public class ImplicitSubFlowELSpringTest extends BaseTest { @@ -33,15 +32,15 @@ public class ImplicitSubFlowELSpringTest extends BaseTest { public void testImplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); // 传递了slotIndex,则set的size==1 - Assert.assertEquals(1, RUN_TIME_SLOT.size()); + Assertions.assertEquals(1, RUN_TIME_SLOT.size()); // set中第一次设置的requestId和response中的requestId一致 - Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); + Assertions.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); // requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); + Assertions.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } // 在p里多线程调用q 10次,每个q取到的参数都是不同的。 @@ -49,12 +48,12 @@ public class ImplicitSubFlowELSpringTest extends BaseTest { public void testImplicitSubFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("c1", "it's a request"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); Set set = context.getData("test"); // requestData的取值正确 - Assert.assertEquals(10, set.size()); + Assertions.assertEquals(10, set.size()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringTest.java index 30e35bb39..18b02b705 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigELSpringTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -19,7 +19,7 @@ import javax.annotation.Resource; * * @author Bryan.Zhang */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/subflow/application-subInDifferentConfig1.xml") public class SubflowInDifferentConfigELSpringTest extends BaseTest { @@ -30,16 +30,18 @@ public class SubflowInDifferentConfigELSpringTest extends BaseTest { @Test public void testExplicitSubFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } // 主要测试有不同的配置类型后会不会报出既定的错误 - @Test(expected = MultipleParsersException.class) + @Test public void testExplicitSubFlow2() { - LiteflowConfig config = LiteflowConfigGetter.get(); - config.setRuleSource("subflow/flow-main.el.xml,subflow/flow-sub1.el.xml,subflow/flow-sub2.el.yml"); - flowExecutor.reloadRule(); + Assertions.assertThrows(MultipleParsersException.class, () -> { + LiteflowConfig config = LiteflowConfigGetter.get(); + config.setRuleSource("subflow/flow-main.el.xml,subflow/flow-sub1.el.xml,subflow/flow-sub2.el.yml"); + flowExecutor.reloadRule(); + }); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELSpringTest.java index 46374d302..fbe32c107 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonELSpringTest.java @@ -2,13 +2,12 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -17,7 +16,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/subflow/application-json.xml") public class SubflowJsonELSpringTest extends BaseTest { @@ -28,8 +27,8 @@ public class SubflowJsonELSpringTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringTest.java index bedf4edcf..bca2767ad 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLELSpringTest.java @@ -2,13 +2,12 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -17,7 +16,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/subflow/application-xml.xml") public class SubflowXMLELSpringTest extends BaseTest { @@ -28,8 +27,8 @@ public class SubflowXMLELSpringTest extends BaseTest { @Test public void testExplicitSubFlow() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringTest.java index a36095eab..705610b61 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlELSpringTest.java @@ -2,13 +2,12 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; -import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -17,7 +16,7 @@ import javax.annotation.Resource; * * @author justin.xu */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/subflow/application-yml.xml") public class SubflowYmlELSpringTest extends BaseTest { @@ -28,8 +27,8 @@ public class SubflowYmlELSpringTest extends BaseTest { @Test public void testExplicitSubFlowYml() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java index 9f91d2b73..ef485a1f1 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java @@ -3,15 +3,15 @@ package com.yomahub.liteflow.test.switchcase; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/switchcase/application.xml") public class SwitchELSpringTest extends BaseTest { @@ -21,36 +21,36 @@ public class SwitchELSpringTest extends BaseTest { @Test public void testSwitch1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d==>b", response.getExecuteStepStr()); } @Test public void testSwitch2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>e==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>e==>d", response.getExecuteStepStr()); } @Test public void testSwitch3() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>f==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>f==>b", response.getExecuteStepStr()); } @Test public void testSwitch4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>g==>d", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>g==>d", response.getExecuteStepStr()); } @Test public void testSwitch5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>h==>b", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringJsonTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringJsonTest.java index 6fbc39f5d..095839c27 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringJsonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringJsonTest.java @@ -5,11 +5,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -19,7 +19,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/tag/application-json.xml") public class NodeTagELSpringJsonTest extends BaseTest { @@ -30,15 +30,15 @@ public class NodeTagELSpringJsonTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -48,9 +48,9 @@ public class NodeTagELSpringJsonTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -58,8 +58,8 @@ public class NodeTagELSpringJsonTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringXmlTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringXmlTest.java index 93f2ee4a3..bfdaa6f56 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringXmlTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagELSpringXmlTest.java @@ -5,11 +5,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -19,7 +19,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/tag/application-xml.xml") public class NodeTagELSpringXmlTest extends BaseTest { @@ -30,15 +30,15 @@ public class NodeTagELSpringXmlTest extends BaseTest { public void testTag1() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("123", context.getData("test")); } @Test public void testTag2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } // 测试多线程when情况下的tag取值是否正确 @@ -48,9 +48,9 @@ public class NodeTagELSpringXmlTest extends BaseTest { for (int i = 0; i < 50; i++) { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); ConcurrentHashSet testSet = context.getData("test"); - Assert.assertEquals(3, testSet.size()); + Assertions.assertEquals(3, testSet.size()); } } @@ -58,8 +58,8 @@ public class NodeTagELSpringXmlTest extends BaseTest { @Test public void testTag4() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("g", response.getExecuteStepStr()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("g", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringTest.java index 7498c5251..b0bf72431 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenELSpringTest.java @@ -4,12 +4,11 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -18,7 +17,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.3 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/useTTLInWhen/application.xml") public class UseTTLInWhenELSpringTest extends BaseTest { @@ -29,11 +28,11 @@ public class UseTTLInWhenELSpringTest extends BaseTest { public void testUseTTLInWhen() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertEquals("hello,b", context.getData("b")); - Assert.assertEquals("hello,c", context.getData("c")); - Assert.assertEquals("hello,d", context.getData("d")); - Assert.assertEquals("hello,e", context.getData("e")); - Assert.assertEquals("hello,f", context.getData("f")); + Assertions.assertEquals("hello,b", context.getData("b")); + Assertions.assertEquals("hello,c", context.getData("c")); + Assertions.assertEquals("hello,d", context.getData("d")); + Assertions.assertEquals("hello,e", context.getData("e")); + Assertions.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringTest1.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringTest1.java index 2be2c8477..d1b692da3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringTest1.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringTest1.java @@ -4,13 +4,13 @@ import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.exception.WhenTimeoutException; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @@ -20,7 +20,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/whenTimeOut/application1.xml") public class WhenTimeOutELSpringTest1 extends BaseTest { @@ -33,8 +33,8 @@ public class WhenTimeOutELSpringTest1 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringTest2.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringTest2.java index 2658ddf36..6deb5f32c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringTest2.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutELSpringTest2.java @@ -3,14 +3,13 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; /** @@ -19,7 +18,7 @@ import javax.annotation.Resource; * @author Bryan.Zhang * @since 2.6.4 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/whenTimeOut/application2.xml") public class WhenTimeOutELSpringTest2 extends BaseTest { @@ -32,7 +31,7 @@ public class WhenTimeOutELSpringTest2 extends BaseTest { @Test public void testWhenTimeOut() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/pom.xml index b759a97f2..ef9d65a99 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/pom.xml @@ -14,7 +14,7 @@ 2.1.214 - 2.0.5.RELEASE + 2.6.8 diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 4b0e1e5ce..eb7287357 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,7 +6,7 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; /** * @author tangkc @@ -14,7 +14,7 @@ import org.junit.AfterClass; */ public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELMultiLanguageSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELMultiLanguageSpringbootTest.java index 46df04608..06c3eaf36 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELMultiLanguageSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELMultiLanguageSpringbootTest.java @@ -3,18 +3,18 @@ package com.yomahub.liteflow.test.sql; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.test.BaseTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/application-xml.properties") @SpringBootTest(classes = SQLWithXmlELMultiLanguageSpringbootTest.class) @EnableAutoConfiguration @@ -27,8 +27,8 @@ public class SQLWithXmlELMultiLanguageSpringbootTest extends BaseTest { @Test public void testMultiLanguage1() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x2[python脚本]==>x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x2[python脚本]==>x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELSpringbootTest.java index f000048c9..111418e30 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELSpringbootTest.java @@ -8,15 +8,14 @@ import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.util.JsonUtil; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.sql.Connection; import java.sql.DriverManager; @@ -27,7 +26,7 @@ import java.sql.Statement; * @author tangkc * @since 2.9.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/application-xml.properties") @SpringBootTest(classes = SQLWithXmlELSpringbootTest.class) @EnableAutoConfiguration @@ -40,27 +39,27 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { @Test public void testSQLWithXml() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); // 修改数据库 changeData(); // 重新加载规则 flowExecutor.reloadRule(); - Assert.assertEquals("a==>c==>b", flowExecutor.execute2Resp("chain1", "arg").getExecuteStepStr()); + Assertions.assertEquals("a==>c==>b", flowExecutor.execute2Resp("chain1", "arg").getExecuteStepStr()); } @Test public void testSQLWithScriptXml() { LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime()); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime()); // 修改数据库 changeScriptData(); // 重新加载规则 flowExecutor.reloadRule(); - Assert.assertEquals("x0[if 脚本]", flowExecutor.execute2Resp("chain3", "arg").getExecuteStepStr()); + Assertions.assertEquals("x0[if 脚本]", flowExecutor.execute2Resp("chain3", "arg").getExecuteStepStr()); } /** diff --git a/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java index 8411b0c52..df1e70c4c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.thread.ExecutorHelper; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; public class BaseTest { - @AfterClass + @AfterAll public static void cleanScanCache() { ComponentScanner.cleanCache(); FlowBus.cleanCache(); diff --git a/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkClusterWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkClusterWithXmlELSpringbootTest.java index 05415a7c8..4a33feab8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkClusterWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkClusterWithXmlELSpringbootTest.java @@ -9,23 +9,22 @@ import org.I0Itec.zkclient.exception.ZkMarshallingError; import org.I0Itec.zkclient.serialize.ZkSerializer; import org.apache.curator.test.InstanceSpec; import org.apache.curator.test.TestingCluster; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.nio.charset.StandardCharsets; /** * springboot环境下的zk cluster的测试 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/zookeeper/application-xml-cluster.properties") @SpringBootTest(classes = ZkClusterWithXmlELSpringbootTest.class) @EnableAutoConfiguration @@ -41,7 +40,7 @@ public class ZkClusterWithXmlELSpringbootTest extends BaseTest { @Resource private FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { System.setProperty("zookeeper.admin.enableServer", "false"); @@ -91,17 +90,17 @@ public class ZkClusterWithXmlELSpringbootTest extends BaseTest { public void testZkNodeWithXmlWithLanguage() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("hello", context.getData("test")); - Assert.assertEquals("hello", context.getData("test1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("hello", context.getData("test")); + Assertions.assertEquals("hello", context.getData("test1")); } @Test public void testZkNodeWithXml() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("hello", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("hello", context.getData("test")); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlELSpringbootTest.java index 2dc833d3c..c04891253 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlELSpringbootTest.java @@ -8,17 +8,16 @@ import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; import org.I0Itec.zkclient.serialize.ZkSerializer; import org.apache.curator.test.TestingServer; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; import java.nio.charset.StandardCharsets; @@ -28,7 +27,7 @@ import java.nio.charset.StandardCharsets; * @author zendwang * @since 2.5.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/zookeeper/application-xml.properties") @SpringBootTest(classes = ZkNodeWithXmlELSpringbootTest.class) @EnableAutoConfiguration @@ -44,7 +43,7 @@ public class ZkNodeWithXmlELSpringbootTest extends BaseTest { @Resource private FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { zkServer = new TestingServer(21810); ZkClient zkClient = new ZkClient("127.0.0.1:21810"); @@ -84,21 +83,22 @@ public class ZkNodeWithXmlELSpringbootTest extends BaseTest { public void testZkNodeWithXmlWithLanguage() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("hello", context.getData("test")); - Assert.assertEquals("hello", context.getData("test1")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("hello", context.getData("test")); + Assertions.assertEquals("hello", context.getData("test1")); } @Test public void testZkNodeWithXml() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); DefaultContext context = response.getFirstContextBean(); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("hello", context.getData("test")); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("hello", context.getData("test")); } - @AfterClass + @AfterAll public static void tearDown() throws Exception { + BaseTest.cleanScanCache(); zkServer.stop(); } diff --git a/pom.xml b/pom.xml index 3b025c401..612ad1c7a 100644 --- a/pom.xml +++ b/pom.xml @@ -44,14 +44,14 @@ UTF-8 8 8 - 2.0.5.RELEASE - 5.0.9.RELEASE + 2.6.8 + 5.3.20 1.7.32 2.14.0-rc2 1.32 2.1.3 5.3.0 - 4.12 + 5.8.2 5.8.11 2.12.3 5.1.0 @@ -64,16 +64,18 @@ 1.11.13 1.8.13 1.2.3 - 2.0.0 + 2.3.8 4.1.84.Final 31.1-jre 4.5.13 1.9.4 - 1.7.0 + 2.1.0 2.7.3 3.0.1 5.3.3 2.11.0 + 1.3.5 + 15.4 @@ -113,6 +115,13 @@ test true + + jakarta.annotation + jakarta.annotation-api + ${jakarta.version} + provided + true + org.slf4j slf4j-api @@ -134,8 +143,8 @@ ${dom4j.version} - junit - junit + org.junit.jupiter + junit-jupiter ${junit.version} test @@ -290,6 +299,11 @@ commons-io ${common-io.version} + + org.openjdk.nashorn + nashorn-core + ${nashorn.version} + From 3e0ea10a1779db4615b24d0fefe67c54a0420ac3 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Thu, 13 Jul 2023 01:23:13 +0800 Subject: [PATCH 7/9] =?UTF-8?q?enhancement=20#I7J59V=20java17=E4=B8=8B?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=AE=8C=E6=95=B4=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteflow-script-plugin/liteflow-script-javascript/pom.xml | 4 ---- pom.xml | 6 ------ 2 files changed, 10 deletions(-) diff --git a/liteflow-script-plugin/liteflow-script-javascript/pom.xml b/liteflow-script-plugin/liteflow-script-javascript/pom.xml index 1df6fc7fc..2796eeefc 100644 --- a/liteflow-script-plugin/liteflow-script-javascript/pom.xml +++ b/liteflow-script-plugin/liteflow-script-javascript/pom.xml @@ -19,9 +19,5 @@ ${revision} provided - - org.openjdk.nashorn - nashorn-core - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 612ad1c7a..32ffdc1cd 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,6 @@ 5.3.3 2.11.0 1.3.5 - 15.4 @@ -299,11 +298,6 @@ commons-io ${common-io.version} - - org.openjdk.nashorn - nashorn-core - ${nashorn.version} - From 98aa51f44ed26a796fc577bbae2d76108681656a Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Thu, 13 Jul 2023 11:38:31 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pom.xml | 2 +- .../liteflow-testcase-el-sql-springboot/pom.xml | 2 +- liteflow-testcase-el/liteflow-testcase-el-zk-springboot/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/pom.xml index 9a730b95b..cdb70d7fd 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/pom.xml @@ -25,7 +25,7 @@ com.yomahub - liteflow-script-javascript + liteflow-script-graaljs ${revision} test diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/pom.xml index ef9d65a99..a63134de4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/pom.xml @@ -59,7 +59,7 @@ com.yomahub - liteflow-script-javascript + liteflow-script-graaljs ${revision} test diff --git a/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/pom.xml index 65228a046..3562881e8 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-zk-springboot/pom.xml @@ -34,7 +34,7 @@ com.yomahub - liteflow-script-javascript + liteflow-script-graaljs ${revision} test From 8cce43db126a6349935374b6eb6b6ce44e4c9972 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Thu, 13 Jul 2023 13:18:18 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/resources/multiLanguage/flow.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/resources/multiLanguage/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/resources/multiLanguage/flow.xml index 90d4b2f81..b1c7e9c38 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/resources/multiLanguage/flow.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-script-multi-language-springboot/src/test/resources/multiLanguage/flow.xml @@ -4,8 +4,12 @@