From 6457587e7f53268629f26144eb7049164614c090 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Sun, 2 Jul 2023 20:30:37 +0800 Subject: [PATCH 01/30] =?UTF-8?q?enhancement=20#I7HPAN=20onError=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=A2=9E=E5=8A=A0Exception=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yomahub/liteflow/core/NodeComponent.java | 4 ++-- .../liteflow/core/proxy/ComponentProxy.java | 20 ++++++++++--------- .../yomahub/liteflow/test/event/cmp/DCmp.java | 2 +- .../yomahub/liteflow/test/event/cmp/DCmp.java | 2 +- .../yomahub/liteflow/test/event/cmp/ECmp.java | 2 +- .../yomahub/liteflow/test/event/cmp/DCmp.java | 2 +- .../yomahub/liteflow/test/event/cmp/ECmp.java | 2 +- .../yomahub/liteflow/test/event/cmp/DCmp.java | 4 +++- .../yomahub/liteflow/test/event/cmp/ECmp.java | 2 +- .../yomahub/liteflow/test/event/cmp/DCmp.java | 2 +- .../yomahub/liteflow/test/event/cmp/ECmp.java | 2 +- 11 files changed, 24 insertions(+), 20 deletions(-) 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 e13099bf..aee9c013 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 @@ -112,7 +112,7 @@ public abstract class NodeComponent { // 执行失败后回调方法 // 这里要注意,失败方法本身抛出错误,只打出堆栈,往外抛出的还是主要的异常 try { - self.onError(); + self.onError(e); } catch (Exception ex) { String errMsg = StrUtil.format("component[{}] onError method happens exception", this.getDisplayName()); @@ -151,7 +151,7 @@ public abstract class NodeComponent { // 如果需要在成功后回调某一个方法,请覆盖这个方法 } - public void onError() throws Exception { + public void onError(Exception e) throws Exception { // 如果需要在抛错后回调某一段逻辑,请覆盖这个方法 } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java index 7116981c..a0d5ebea 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java @@ -2,10 +2,7 @@ package com.yomahub.liteflow.core.proxy; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.lang.Tuple; -import cn.hutool.core.util.ClassUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.*; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.annotation.LiteflowRetry; import com.yomahub.liteflow.core.NodeComponent; @@ -198,19 +195,24 @@ public class ComponentProxy { .orElse(null); // 如果被代理的对象里有此标注标的方法,则调用此被代理的对象里的方法,如果没有,则调用父类里的方法 - // 进行检查,检查被代理的bean里是否有且仅有NodeComponent这个类型的参数 - boolean checkFlag = liteFlowMethodBean.getMethod().getParameterTypes().length == 1 - && Arrays.asList(liteFlowMethodBean.getMethod().getParameterTypes()).contains(NodeComponent.class); + // 进行检查,检查被代理的bean里是否第一个参数为NodeComponent这个类型的 + boolean checkFlag = liteFlowMethodBean.getMethod().getParameterTypes().length > 0 + && liteFlowMethodBean.getMethod().getParameterTypes()[0].equals(NodeComponent.class); if (!checkFlag) { String errMsg = StrUtil.format( - "Method[{}.{}] must have NodeComponent parameter(and only one parameter)", + "Method[{}.{}] must have NodeComponent parameter(first parameter is NodeComponent)", bean.getClass().getName(), liteFlowMethodBean.getMethod().getName()); LOG.error(errMsg); throw new ComponentMethodDefineErrorException(errMsg); } try { - return liteFlowMethodBean.getMethod().invoke(bean, proxy); + if (args.length > 0){ + Object[] wrapArgs = ArrayUtil.insert(args, 0, proxy); + return liteFlowMethodBean.getMethod().invoke(bean, wrapArgs); + }else{ + return liteFlowMethodBean.getMethod().invoke(bean, proxy); + } } catch (Exception e) { InvocationTargetException targetEx = (InvocationTargetException) e; diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index b299e555..6468f77c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -23,7 +23,7 @@ public class DCmp { } @LiteflowMethod(LiteFlowMethodEnum.ON_ERROR) - public void onError(NodeComponent bindCmp) throws Exception { + public void onError(NodeComponent bindCmp, Exception e) throws Exception { DefaultContext context = bindCmp.getFirstContextBean(); context.setData("error", "error:" + bindCmp.getNodeId()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index 3114c491..106b5fe6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -19,7 +19,7 @@ public class DCmp extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { DefaultContext context = this.getFirstContextBean(); context.setData("error", "error:" + this.getNodeId()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index a1d03798..bf815e2f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -19,7 +19,7 @@ public class ECmp extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { DefaultContext context = this.getFirstContextBean(); context.setData("error", "error:" + this.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index 50feb43c..a4e57da6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -21,7 +21,7 @@ public class DCmp extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { DefaultContext context = this.getFirstContextBean(); context.setData("error", "error:" + this.getNodeId()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index 75dadc2a..d36ce73f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -21,7 +21,7 @@ public class ECmp extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { DefaultContext context = this.getFirstContextBean(); context.setData("error", "error:" + this.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index 5dbbc711..13ffac28 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.event.cmp; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @Component("d") @@ -21,7 +22,8 @@ public class DCmp extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { + Slot slot = this.getSlot(); DefaultContext context = this.getFirstContextBean(); context.setData("error", "error:" + this.getNodeId()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index fe6f51dd..6be4803d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -21,7 +21,7 @@ public class ECmp extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { DefaultContext context = this.getFirstContextBean(); context.setData("error", "error:" + this.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index 5dbbc711..7a520af6 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -21,7 +21,7 @@ public class DCmp extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { DefaultContext context = this.getFirstContextBean(); context.setData("error", "error:" + this.getNodeId()); } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index fe6f51dd..6be4803d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -21,7 +21,7 @@ public class ECmp extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { DefaultContext context = this.getFirstContextBean(); context.setData("error", "error:" + this.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); From b759aeaabb0b0de71089e1cfc77c6e684854e5a4 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Sun, 2 Jul 2023 20:44:55 +0800 Subject: [PATCH 02/30] =?UTF-8?q?enhancement=20#I7HPAN=20onError=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=A2=9E=E5=8A=A0Exception=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/yomahub/liteflow/core/NodeComponent.java | 2 +- .../com/yomahub/liteflow/solon/NodeComponentOfMethod.java | 2 +- .../java/com/yomahub/liteflow/test/event/cmp/CmpConfig.java | 4 ++-- .../test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) 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 aee9c013..3e627487 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 @@ -116,7 +116,7 @@ public abstract class NodeComponent { } catch (Exception ex) { String errMsg = StrUtil.format("component[{}] onError method happens exception", this.getDisplayName()); - LOG.error(errMsg); + LOG.error(errMsg, ex); } throw e; } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/NodeComponentOfMethod.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/NodeComponentOfMethod.java index 96f9fce7..6305f882 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/NodeComponentOfMethod.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/NodeComponentOfMethod.java @@ -89,7 +89,7 @@ public class NodeComponentOfMethod extends NodeComponent { } @Override - public void onError() throws Exception { + public void onError(Exception e) throws Exception { if (methodEnum != LiteFlowMethodEnum.ON_ERROR) { return; } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CmpConfig.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CmpConfig.java index 21fcb58c..c0055936 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CmpConfig.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CmpConfig.java @@ -60,7 +60,7 @@ public class CmpConfig { } @LiteflowMethod(value = LiteFlowMethodEnum.ON_ERROR, nodeId = "d") - public void onErrorD(NodeComponent bindCmp) throws Exception { + public void onErrorD(NodeComponent bindCmp, Exception e) throws Exception { DefaultContext context = bindCmp.getFirstContextBean(); context.setData("error", "error:" + bindCmp.getNodeId()); } @@ -73,7 +73,7 @@ public class CmpConfig { } @LiteflowMethod(value = LiteFlowMethodEnum.ON_ERROR, nodeId = "e") - public void onErrorE(NodeComponent bindCmp) throws Exception { + public void onErrorE(NodeComponent bindCmp,Exception e) throws Exception { DefaultContext context = bindCmp.getFirstContextBean(); context.setData("error", "error:" + bindCmp.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index 7ca3b3e6..9d98ccd3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -23,7 +23,7 @@ public class ECmp { } @LiteflowMethod(LiteFlowMethodEnum.ON_ERROR) - public void onError(NodeComponent bindCmp) throws Exception { + public void onError(NodeComponent bindCmp, Exception e) throws Exception { DefaultContext context = bindCmp.getFirstContextBean(); context.setData("error", "error:" + bindCmp.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); From f3bb3f8b6c3dfaf4f2c5ed413445f04aeaf4072d Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Sun, 2 Jul 2023 20:50:21 +0800 Subject: [PATCH 03/30] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../element/condition/SwitchCondition.java | 105 +++++++++--------- 1 file changed, 50 insertions(+), 55 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java index 509c928a..66883cd7 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java @@ -30,71 +30,66 @@ public class SwitchCondition extends Condition { @Override public void executeCondition(Integer slotIndex) throws Exception { - if (ListUtil.toList(NodeTypeEnum.SWITCH, NodeTypeEnum.SWITCH_SCRIPT).contains(this.getSwitchNode().getType())) { - // 获取switch node - Node switchNode = this.getSwitchNode(); - // 获取target List - List targetList = this.getTargetList(); + // 获取switch node + Node switchNode = this.getSwitchNode(); + // 获取target List + List targetList = this.getTargetList(); - // 先去判断isAccess方法,如果isAccess方法都返回false,整个SWITCH表达式不执行 - if (!switchNode.isAccess(slotIndex)) { - return; - } + // 先去判断isAccess方法,如果isAccess方法都返回false,整个SWITCH表达式不执行 + if (!switchNode.isAccess(slotIndex)) { + return; + } - // 先执行switch节点 - switchNode.setCurrChainId(this.getCurrChainId()); - switchNode.execute(slotIndex); + // 先执行switch节点 + switchNode.setCurrChainId(this.getCurrChainId()); + switchNode.execute(slotIndex); - // 拿到switch节点的结果 - String targetId = switchNode.getItemResultMetaValue(slotIndex); + // 拿到switch节点的结果 + String targetId = switchNode.getItemResultMetaValue(slotIndex); - Slot slot = DataBus.getSlot(slotIndex); + Slot slot = DataBus.getSlot(slotIndex); - Executable targetExecutor = null; - if (StrUtil.isNotBlank(targetId)) { - // 这里要判断是否使用tag模式跳转 - if (targetId.contains(TAG_FLAG)) { - String[] target = targetId.split(TAG_FLAG, 2); - String _targetId = target[0]; - String _targetTag = target[1]; - targetExecutor = targetList.stream().filter(executable -> { - return (StrUtil.startWith(_targetId, TAG_PREFIX) && _targetTag.equals(executable.getTag())) - || ((StrUtil.isEmpty(_targetId) || _targetId.equals(executable.getId())) - && (StrUtil.isEmpty(_targetTag) || _targetTag.equals(executable.getTag()))); - }).findFirst().orElse(null); - } - else { - targetExecutor = targetList.stream() - .filter(executable -> executable.getId().equals(targetId)) - .findFirst() - .orElse(null); - } - } - - if (ObjectUtil.isNull(targetExecutor)) { - // 没有匹配到执行节点,则走默认的执行节点 - targetExecutor = this.getDefaultExecutor(); - } - - if (ObjectUtil.isNotNull(targetExecutor)) { - // switch的目标不能是Pre节点或者Finally节点 - if (targetExecutor instanceof PreCondition || targetExecutor instanceof FinallyCondition) { - String errorInfo = StrUtil.format( - "[{}]:switch component[{}] error, switch target node cannot be pre or finally", - slot.getRequestId(), this.getSwitchNode().getInstance().getDisplayName()); - throw new SwitchTargetCannotBePreOrFinallyException(errorInfo); - } - targetExecutor.setCurrChainId(this.getCurrChainId()); - targetExecutor.execute(slotIndex); + Executable targetExecutor = null; + if (StrUtil.isNotBlank(targetId)) { + // 这里要判断是否使用tag模式跳转 + if (targetId.contains(TAG_FLAG)) { + String[] target = targetId.split(TAG_FLAG, 2); + String _targetId = target[0]; + String _targetTag = target[1]; + targetExecutor = targetList.stream().filter(executable -> { + return (StrUtil.startWith(_targetId, TAG_PREFIX) && _targetTag.equals(executable.getTag())) + || ((StrUtil.isEmpty(_targetId) || _targetId.equals(executable.getId())) + && (StrUtil.isEmpty(_targetTag) || _targetTag.equals(executable.getTag()))); + }).findFirst().orElse(null); } else { - String errorInfo = StrUtil.format("[{}]:no target node find for the component[{}],target str is [{}]", - slot.getRequestId(), this.getSwitchNode().getInstance().getDisplayName(), targetId); - throw new NoSwitchTargetNodeException(errorInfo); + targetExecutor = targetList.stream() + .filter(executable -> executable.getId().equals(targetId)) + .findFirst() + .orElse(null); } } + + if (ObjectUtil.isNull(targetExecutor)) { + // 没有匹配到执行节点,则走默认的执行节点 + targetExecutor = this.getDefaultExecutor(); + } + + if (ObjectUtil.isNotNull(targetExecutor)) { + // switch的目标不能是Pre节点或者Finally节点 + if (targetExecutor instanceof PreCondition || targetExecutor instanceof FinallyCondition) { + String errorInfo = StrUtil.format( + "[{}]:switch component[{}] error, switch target node cannot be pre or finally", + slot.getRequestId(), this.getSwitchNode().getInstance().getDisplayName()); + throw new SwitchTargetCannotBePreOrFinallyException(errorInfo); + } + targetExecutor.setCurrChainId(this.getCurrChainId()); + targetExecutor.execute(slotIndex); + } else { - throw new SwitchTypeErrorException("switch instance must be NodeSwitchComponent"); + String errorInfo = StrUtil.format("[{}]:no target node find for the component[{}],target str is [{}]", + slot.getRequestId(), this.getSwitchNode().getInstance().getDisplayName(), targetId); + throw new NoSwitchTargetNodeException(errorInfo); } } From e5b21d6245437bcf97e6d3e5bd31cabc01dac1d6 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Sun, 9 Jul 2023 16:05:54 +0800 Subject: [PATCH 04/30] =?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 24e9535d..3b025c40 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 05/30] =?UTF-8?q?enhancement=20#I7K3T1=20=E8=87=AA?= =?UTF-8?q?=E5=B8=A6AOP=E6=8B=A6=E6=88=AA=E9=9C=80=E8=A6=81=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA=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 d8bff0d2..091e39f8 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 3e627487..bf064af2 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 a89664d8..3fe93821 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 598c971d..c783985b 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 2e5a2a2c..9b3f88f5 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 9e7ff129..b2686ca3 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 e3884622..82a3464f 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 e3884622..82a3464f 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 e3884622..82a3464f 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 e3884622..82a3464f 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 06/30] =?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 730f08b2..fd0815ce 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 63b1ed1a..843d0f96 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 760ee924..83665f26 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 a7214995..00bc9e68 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 07/30] =?UTF-8?q?enhancement=20#I7JZ4D=20=E5=B8=8C?= =?UTF-8?q?=E6=9C=9B=E6=A1=86=E6=9E=B6=E6=9C=89=E4=B8=8E=E6=88=96=E9=9D=9E?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E7=9A=84=E7=9B=B8=E5=85=B3=E6=97=A5?= =?UTF-8?q?=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 61a65df5..3c70b6b8 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 a4b22614..5e53f843 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 08/30] =?UTF-8?q?bug=20#I7HTR4=20=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=B8=8D=E5=90=8Ctag=EF=BC=8C=E5=8F=96step?= =?UTF-8?q?=E6=97=B6=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 cbef4b7e..37a87e56 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 753261b2..6ffd2e57 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 753261b2..6ffd2e57 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 07e65f86..de3306ef 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 c1b0d6d8..531a19da 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 ed9084d4..0157e3b9 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 5a5536e0..789f8b2b 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 0f35cedf0fd4dc7aa8ecb9b997847b0e0f4f1453 Mon Sep 17 00:00:00 2001 From: Kugaaa Date: Wed, 12 Jul 2023 14:59:30 +0800 Subject: [PATCH 09/30] =?UTF-8?q?enhancement=20#I7GMTS=20=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=96=87=E4=BB=B6=E7=9B=91=E5=90=AC=20catch=20?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=EF=BC=8C=E4=BF=9D=E8=AF=81=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E4=B8=8D=E8=A2=AB=E5=81=9C=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yomahub/liteflow/monitor/MonitorFile.java | 12 +++++++-- .../MonitorFileELSpringbootTest.java | 27 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/monitor/MonitorFile.java b/liteflow-core/src/main/java/com/yomahub/liteflow/monitor/MonitorFile.java index 756d5427..fb3226b7 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/monitor/MonitorFile.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/monitor/MonitorFile.java @@ -63,13 +63,21 @@ public class MonitorFile { @Override public void onFileChange(File file) { LOG.info("file modify,filePath={}", file.getAbsolutePath()); - FlowExecutorHolder.loadInstance().reloadRule(); + this.reloadRule(); } @Override public void onFileDelete(File file) { LOG.info("file delete,filePath={}", file.getAbsolutePath()); - FlowExecutorHolder.loadInstance().reloadRule(); + this.reloadRule(); + } + + private void reloadRule() { + try { + FlowExecutorHolder.loadInstance().reloadRule(); + } catch (Exception e) { + LOG.error("reload rule error", e); + } } }); // 创建文件变化监听器 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 2ffdd06e..32c895be 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 @@ -7,8 +7,10 @@ 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.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -23,6 +25,7 @@ import java.io.File; @SpringBootTest(classes = MonitorFileELSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.monitorFile.cmp" }) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MonitorFileELSpringbootTest extends BaseTest { @Resource @@ -39,4 +42,28 @@ public class MonitorFileELSpringbootTest extends BaseTest { Assert.assertEquals("a==>c==>b", response.getExecuteStepStr()); } + /** + * 测试文件变更,但是 EL 规则错误情况 + * 输出 ERROR 日志异常信息,但是不会停止监听线程,当下一次变更正确后替换为新规则 + */ + @Test + public void testMonitorError() throws Exception { + String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + String content = FileUtil.readUtf8String(absolutePath); + + // 错误规则配置 + String newContent = content.replace("THEN(a, c, b);", "THEN(c, b, ;"); + FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + Thread.sleep(3000); + LiteflowResponse reloadFailedResponse = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertEquals("a==>c==>b", reloadFailedResponse.getExecuteStepStr()); + + // 再次变更正确 + newContent = content.replace("THEN(a, c, b);", "THEN(c, b, a);"); + FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + Thread.sleep(3000); + LiteflowResponse reloadSuccessResponse = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertEquals("c==>b==>a", reloadSuccessResponse.getExecuteStepStr()); + } + } From fb87a1b06a1d1555ec98655382105676559595f2 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Wed, 12 Jul 2023 23:51:36 +0800 Subject: [PATCH 10/30] =?UTF-8?q?enhancement=20#I7KR2F=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=E5=85=A8=E9=9D=A2=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=B8=BAjunit5=20enhancement=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 --- .../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 ce72a17f..34d048be 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 2796eeef..1df6fc7f 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 785bc391..c83a4730 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 8837f3ac..d4115364 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 8411b0c5..f7e94e50 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 241105e0..293b56d8 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 7e6c56d4..78108882 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 796302a2..f0b658ae 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 31978fd0..1b32cc91 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 9221bfed..992a57bd 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 88b3e73d..3816eee1 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 9b655b1b..c6e4c453 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 6ffd2e57..2cd4394f 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 acfa4bcc..bbaae887 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 1327e75b..19374852 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 12c0c765..edd35207 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 c99a0842..997d938c 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 f349416f..f9d5894b 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 9a66e2be..8a5af926 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 a4ea53ff..bf5435e2 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 634ea3b7..be58bd1e 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 6ffc613d..12dd77f2 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 a0b8bd03..d6cc11e0 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 06c9866d..a360b125 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 768d603f..54048c83 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 40701689..666e124d 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 41094404..ec9b9bda 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 a9eac119..db2615d0 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 fa1fd1cf..0072210f 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 ddfb1fac..29c189fa 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 98f6706b..6db534bb 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 ee4c8ad6..4758e345 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 1ca5b55e..0db20cda 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 24c8602c..8a88f4b1 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 2279d9ca..d9d5c9c6 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 26c17b9d..a2cf815c 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 7e3b298e..666e23f5 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 58a52274..0b7dc1b5 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 444b67ba..dcca7597 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 f94b292c..6507ec3b 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 262e3f15..1a5a2a56 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 dbdb47bb..726fc70d 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 01fd8d6c..155e9dce 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 76faa833..cfba172a 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 a47628d8..ea68295f 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 21222419..4a0c2333 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 cdb72ce0..e71b65bb 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 3154263f..57a7e1fb 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 32288826..884441ea 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 8459e6af..da047c27 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 35a8a96d..1e6cc049 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 b25b2115..7cb779f5 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 76cc3be9..ea9ed68e 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 08f9e0a6..314f9bf5 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 28cce58a..5cd386cf 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 9e4b2f40..ea0987bd 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 1a736d3c..018f6db1 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 f0116e0f..0b892b71 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 2f1b8bea..49b1d3b5 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 8411b0c5..df1e70c4 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 7270c2ca..55c90007 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 3f18688f..0d68fb5d 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 f3ee21e5..aa85b864 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 3d9c34b3..b9960c2f 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 13705781..af10a674 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 01fc730b..7f8b8714 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 22f938a1..49cbc7ca 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 e110847f..9dd1bfa2 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 6ffd2e57..2cd4394f 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 287f2626..456cb42e 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 9b94331b..ccc1a9a9 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 9ca148ef..6b1cdfc1 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 28206f8c..5b79fd4f 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 c607c371..3697244c 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 acff88e5..52797ee2 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 7cd9996e..9e13664f 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 47937059..097ca251 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 acdd913b..d8e2ae4e 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 c33486d8..c67912e0 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 e1193169..c3360a9d 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 2b0101d2..2a803ea3 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 252156aa..b1f97a9f 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 d30f7edd..d3e5f5e8 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 715aba47..ecde1aeb 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 a83730d7..36583df9 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 0a4385e9..1384989d 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 c2b3d196..80909b86 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 7ce1c34f..3a323bfb 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 acf28f87..b264ef59 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 2d5b7642..7da4b8ca 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 983a4ab4..832c9c97 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 10d68eb7..66b0d8bc 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 d91a89ef..ab803996 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 43ca2189..09125227 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 32af794e..9b7c996f 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 31c31aaa..d1e93831 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 3de6b0e0..1144405d 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 4966cfe5..57259878 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 7e3a0976..24aeead6 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 c8114b84..5591ab83 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 ccccbfb0..53ba46bf 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 16dc9824..3806eba9 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 cf56d27e..9d996665 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 a35ed55a..818c973d 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 8c6f729e..baa2c386 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 457bfedd..4a9b4404 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 5fbd5a8d..57c19686 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 fffe03a4..e86dc7c9 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 0b6faf33..bfd2840d 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 22cc5f54..e65864e2 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 cf07233b..5584dd22 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 ea4d57e2..5392e4d8 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 3664207e..36d9c8c0 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 c763a638..370c13ca 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 36f5c3b1..d632bb02 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 8411b0c5..df1e70c4 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 33d61b6f..64f6dfdc 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 8411b0c5..df1e70c4 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 1f5a97f2..1e33174e 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 01a8ffe6..4020d12a 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 1acabc13..a9494a2a 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 537fb9ce..120c3984 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 d538d1b7..a15432ec 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 e3f91c40..f19a20b0 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 e3acc5f7..4f4eaffc 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 f8ed19ce..e1ee7b9c 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 de3306ef..07e933e2 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 b48125f6..e2badc7f 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 de97af78..1914ceeb 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 6c7ba197..e8364f4e 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 6a6ae34c..32349e33 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 308e27e1..df70cd1f 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 3f5daab6..588eb0b7 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 69b9116c..93204fd8 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 14d1412f..ffaac24f 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 aa4d2e45..2f485178 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 038b996c..4f528750 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 c2a2d583..ef70159e 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 884281ec..4f452b2d 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 a35bb973..ec243a08 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 3ca2731f..07e4a7f1 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 dfcbc6bc..b0d0d522 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 0bdecdb9..9d09c8bd 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 2aac6e70..847fd48d 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 6bd18a78..4cf6f27e 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 aaaf83d7..df24bf39 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 3aa7e4ac..21410c9e 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 585b23e0..ab58e5b0 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 7d1a7600..43aa68ed 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 dc986bd1..319cf45a 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 0e919db7..d578e6ee 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 e219333c..1af2def9 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 92bb2ff8..2f32f1e9 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 2e3601e2..f0c24847 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 9aed5923..4d7fefd9 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 bc3fdbdc..5e972cce 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 d53279ed..b95edc1c 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 fca6e9a6..4e34267a 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 0d523b3c..596a84b4 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 63f394b0..b4a3411f 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 deaae153..ee526f59 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 8c053255..f4065f21 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 5ae9809b..5ff8ea01 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 1dd75078..bdb5ebc7 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 628b30e9..054a3351 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 f81d73e3..85dff4fc 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 ad18b675..67315416 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 8411b0c5..df1e70c4 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 76067318..8a4985bd 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 8411b0c5..df1e70c4 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 46013f8d..617a9859 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 13ecb6c1..f7fefa6d 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 1468cebd..57e62f50 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 c80b8ebe..8140a2d5 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 7cf0e7e3..e101f4de 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 ffd03d98..e78e3ebc 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 4c086fd9..e3929ea9 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 bb9ff548..52e4f770 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 b4d229b5..7e518151 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 8411b0c5..df1e70c4 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 5fdb7043..029b5b3b 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 dcca3e7d..083feb54 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 d2bab54f..07fad900 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 d62c0b30..430391a1 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 673b2135..1930f144 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 6c166715..57436b53 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 5c0700f2..1d8a7b43 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 4d8cf9f3..f41a0b02 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 c7bb258f..afae9794 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 7f3506e9..b2f3813c 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 b9c6520c..2cf256c3 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 6bfd95be..80b606d9 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 712c85d3..03d0a1ee 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 8411b0c5..df1e70c4 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 005be1c2..79dd6fc7 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 7872643c..eb102f88 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 d4e03f85..fd48db92 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 eaac5290..4a8ce24a 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 30f76684..1f7e0e86 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 f1ec1bfd..a4a6e88f 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 30103cfb..f5c1e029 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 2dc8e3ef..c9be861a 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 e90e9614..23cf8212 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 8411b0c5..df1e70c4 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 defa3579..ae01e293 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 306109d4..323d403a 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 8411b0c5..df1e70c4 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 3c09fb1f..2a2b2976 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 8411b0c5..df1e70c4 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 a1a0d87a..7deeb878 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 e8acb793..ed8d5b86 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 8411b0c5..df1e70c4 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 4a47e958..3ada3ff2 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 2d507c64..72cf753d 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 93feff77..619c9879 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 753ad877..c81a57ff 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 5d3640ad..2f4cd5dc 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 7a7646ae..33e86a0e 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 2fb50fb7..b27b1319 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 b1988dba..c12ade73 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 5c7f7b33..8da7ceb0 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 fd9948b9..6cc38368 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 e706226d..2993329c 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 487da486..814da97c 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 ed8cd7eb..8e8897b8 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 a2ad5455..6b223f82 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 d46afa4c..4b6fbc38 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 002ea599..ab35a415 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 2bfba62b..a672390e 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 606e0c52..46a28ce6 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 9e143dc0..8e28792e 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 531a19da..7624a369 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 e8f39b83..c188d3a9 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 eb7ac244..adfa6d0d 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 be76a718..9d79f629 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 5e8aaeb4..58450c05 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 400fcd53..be2c7cbe 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 fd6a2f05..0cdb4a6a 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 afefdbbb..8b769689 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 0dac705a..4312844c 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 6b02970b..115f35e5 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 1825c012..2cdcf6ac 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 c409239c..c1ec728e 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 83f5588f..3138f2f8 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 e0f656fd..1e40ced5 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 5debffc3..e7073191 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 7057c731..69db2703 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 8af80729..8cb41564 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 9d8c8583..8c9173c2 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 c62204d9..5052d86a 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 55da1960..524199bb 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 1cd70246..f2ffff35 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 d582bbf4..60911af8 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 36949b2a..9a6b92ab 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 0906c594..7a61da24 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 3229fbd1..13e66a5f 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 a9d1afca..0e03bbc8 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 d0d8473d..5df5042b 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 3d31e8ed..ba528c53 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 66813293..b652e25e 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 7d0fe732..ed055875 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 f939af02..605880ee 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 a291043d..a42a3112 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 efef4b4f..c9d81b0b 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 01d6ce7e..269add35 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 fc9a37f3..d463b70a 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 c574e853..46d611a9 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 7ae29410..30d2e5ee 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 0ba515e1..a8534978 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 42d414e3..512d4870 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 a1759c62..62366223 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 ac9b9d65..7d1b2c09 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 c2971eae..d5301e3f 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 3383fe27..a25f63b6 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 a08529b9..f12ece67 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 9579d45d..c3184ede 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 227ca822..904fbcc9 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 a725c702..3612d67d 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 8411b0c5..df1e70c4 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 2604cdad..ca844f9c 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 7be1ca2f..5d4ebe68 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 9c71f164..a34d051d 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 596bcad4..30703e60 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 7afa6e3b..09490711 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 1ef6d921..0e7eb64c 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 49edee05..84d74c9b 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 186e37de..2ff7868e 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 32c8294e..ff548cac 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 ab5c705c..50bc3d6e 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 6504bf7a..f1298576 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 0157e3b9..340b4d06 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 e73d60e2..f8f6f74f 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 ec19d54f..4299a575 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 7c15b994..8442e7ab 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 1e30b437..572294c4 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 b8c84e37..5f195c83 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 45516e80..477d82a7 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 64ac4309..e70ab573 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 5d3c6d77..f17caed3 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 4e753d4c..dc4c5ac2 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 a65a4e34..fa723601 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 644096d3..ebaa9b2a 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 65be20f8..cb0eedf5 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 1c34d349..cdeb448d 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 cfc26725..7b241fe8 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 9d6747d9..d67beea4 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 21892a76..ac5916b0 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 1fdef50a..6f73c6b5 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 2ffdd06e..1641688b 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 3835bbdb..b94621d7 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 95689d51..48ddd8f0 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 56c26dee..367dc121 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 97c86474..16166211 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 efc8ef0d..c635bd16 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 63c51e29..c620d9bf 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 7742b478..a0075f35 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 76596594..8ba529a6 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 6b33d15a..0fde5834 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 c29fa84c..17b4d3ff 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 5d6c84b6..1fb33377 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 0a6936d3..64cf00bf 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 70447b20..659060d6 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 76971e72..73aa495c 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 c94295a7..26ed24e5 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 cfca512b..a10502ff 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 4f06fe5b..62ccebeb 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 01040f57..042ee84a 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 69251564..f91a7e83 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 8d34c447..563a9a34 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 2e8e88a8..ae6bdb8c 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 c164cc2a..ea93b075 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 5197c6d0..73e18dc5 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 72a13873..9323de37 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 ed2c147e..734cadf9 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 2dd64e18..3ff68a95 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 e0a3c406..c02a58f0 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 600c0471..b80fc8a7 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 9c761546..a9a7532b 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 66b87af1..3511de71 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 108b4fe6..fa25396e 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 2f06f6f3..4a0c895e 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 a2c4e475..332c7fa6 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 8411b0c5..df1e70c4 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 da836cba..5a662976 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 38f32a12..7ace8d38 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 9fee62d4..32797b95 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 faf11210..3456ebf7 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 933d8f0e..b3e3a7e2 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 3beb0ef0..4796afc1 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 b72c8cde..419dbe9c 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 0b060ef6..87783921 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 789f8b2b..6ea63110 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 7399ff84..0a1bb1eb 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 76e6e1cf..0c4884dc 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 3d5083c5..8e2d0a81 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 6648fa19..ebc2654a 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 a599c528..ed87add9 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 c32ecce8..6b76e4c8 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 27f9b70c..588f48dd 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 61c3c37e..5721ab06 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 1233ef6c..d64ceac5 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 49e333f8..5efed2f4 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 dea605f2..e5d35eee 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 69791808..06f2ae30 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 f2d18d14..ac3ccd01 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 0e643e62..2a6c77dd 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 2847e83b..58eead61 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 d2df5be6..dc9a0db9 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 3c9b7d24..2b09e908 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 422b01f1..ce8f9572 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 53ca0d5b..e9e68980 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 5600f168..dbff66d6 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 45a862a9..91300e09 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 62021667..976ba2bf 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 d5ad93d2..7d5eb8e5 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 ae6c61a3..e92e2294 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 d6c1caeb..94f3181d 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 9d09592a..65678743 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 15743488..b3ca2e17 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 bcd53970..592f7039 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 c56453ff..db9b36d7 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 934f9656..1d832bcb 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 9c5df35f..e81e8a36 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 678b83ea..0784a46d 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 a655fa91..0e4070b8 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 3971e34e..287a8177 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 42b5eee4..4b65e59e 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 dc1b2c60..0e99289b 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 30e35bb3..18b02b70 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 46374d30..fbe32c10 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 bedf4edc..bca2767a 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 a36095ea..705610b6 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 9f91d2b7..ef485a1f 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 6fbc39f5..095839c2 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 93f2ee4a..bfdaa6f5 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 7498c525..b0bf7243 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 2be2c847..d1b692da 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 2658ddf3..6deb5f32 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 b759a97f..ef9d65a9 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 4b0e1e5c..eb728735 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 46df0460..06c3eaf3 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 f000048c..111418e3 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 8411b0c5..df1e70c4 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 05415a7c..4a33feab 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 2dc833d3..c0489125 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 3b025c40..612ad1c7 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 11/30] =?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 1df6fc7f..2796eeef 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 612ad1c7..32ffdc1c 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 12/30] =?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 9a730b95..cdb70d7f 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 ef9d65a9..a63134de 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 65228a04..3562881e 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 13/30] =?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 90d4b2f8..b1c7e9c3 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 @@ From 861342f478b26959252ec18d62114253c02e79b1 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Sun, 16 Jul 2023 15:41:57 +0800 Subject: [PATCH 14/30] =?UTF-8?q?enhancement=20#I7KZCZ=20=E5=9C=A8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E5=B7=B2=E7=BB=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yomahub/liteflow/spi/ContextAware.java | 25 +- .../liteflow/spi/local/LocalContextAware.java | 71 +-- .../liteflow/parser/sql/SQLXmlELParser.java | 3 + .../liteflow/parser/sql/util/JDBCHelper.java | 505 ++++++++---------- .../parser/sql/util/LiteFlowJdbcUtil.java | 134 +++++ .../liteflow/parser/sql/vo/SQLParserVO.java | 329 ++++++------ .../liteflow/spi/solon/SolonContextAware.java | 124 +++-- .../liteflow/spi/spring/SpringAware.java | 140 ++--- .../liteflow/spring/LiteFlowSpringUtil.java | 275 ++++++++++ ...LWithXmlELMultiLanguageSpringbootTest.java | 34 ++ .../test/def/SQLWithXmlELSpringbootTest.java | 101 ++++ .../application-data-source-xml.properties | 21 + 12 files changed, 1158 insertions(+), 604 deletions(-) create mode 100644 liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/util/LiteFlowJdbcUtil.java create mode 100644 liteflow-spring/src/main/java/com/yomahub/liteflow/spring/LiteFlowSpringUtil.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/resources/application-data-source-xml.properties diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/ContextAware.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/ContextAware.java index ea819742..824de84f 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/ContextAware.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/ContextAware.java @@ -1,5 +1,7 @@ package com.yomahub.liteflow.spi; +import java.util.Map; + /** * 环境容器SPI接口 * @@ -8,18 +10,27 @@ package com.yomahub.liteflow.spi; */ public interface ContextAware extends SpiPriority { - T getBean(String name); + T getBean(String name); - T getBean(Class clazz); + T getBean(Class clazz); - T registerBean(String beanName, Class clazz); + T registerBean(String beanName, Class clazz); - T registerBean(Class clazz); + T registerBean(Class clazz); - T registerBean(String beanName, Object bean); + T registerBean(String beanName, Object bean); - T registerOrGet(String beanName, Class clazz); + T registerOrGet(String beanName, Class clazz); - boolean hasBean(String beanName); + /** + * 获取指定类型对应的所有Bean,包括子类 + * + * @param Bean类型 + * @param type 类、接口,null表示获取所有bean + * @return 类型对应的bean,key是bean注册的name,value是Bean + */ + Map getBeansOfType(Class type); + + boolean hasBean(String beanName); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalContextAware.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalContextAware.java index 63d3cc80..8dd95832 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalContextAware.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalContextAware.java @@ -3,6 +3,8 @@ package com.yomahub.liteflow.spi.local; import cn.hutool.core.util.ReflectUtil; import com.yomahub.liteflow.spi.ContextAware; +import java.util.Map; + /** * 非Spring环境容器实现 其实非Spring没有环境容器,所以这是个空实现 * @@ -11,44 +13,49 @@ import com.yomahub.liteflow.spi.ContextAware; */ public class LocalContextAware implements ContextAware { - @Override - public T getBean(String name) { - return null; - } + @Override + public T getBean(String name) { + return null; + } - @Override - public T getBean(Class clazz) { - return null; - } + @Override + public T getBean(Class clazz) { + return null; + } - @Override - public T registerBean(String beanName, Class clazz) { - return ReflectUtil.newInstance(clazz); - } + @Override + public T registerBean(String beanName, Class clazz) { + return ReflectUtil.newInstance(clazz); + } - @Override - public T registerBean(Class clazz) { - return registerBean(null, clazz); - } + @Override + public T registerBean(Class clazz) { + return registerBean(null, clazz); + } - @Override - public T registerBean(String beanName, Object bean) { - return (T) bean; - } + @Override + public T registerBean(String beanName, Object bean) { + return (T) bean; + } - @Override - public T registerOrGet(String beanName, Class clazz) { - return registerBean(beanName, clazz); - } + @Override + public T registerOrGet(String beanName, Class clazz) { + return registerBean(beanName, clazz); + } - @Override - public boolean hasBean(String beanName) { - return false; - } + @Override + public Map getBeansOfType(Class type) { + return null; + } - @Override - public int priority() { - return 2; - } + @Override + public boolean hasBean(String beanName) { + return false; + } + + @Override + public int priority() { + return 2; + } } diff --git a/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/SQLXmlELParser.java b/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/SQLXmlELParser.java index 90781805..ce3bbe53 100644 --- a/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/SQLXmlELParser.java +++ b/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/SQLXmlELParser.java @@ -71,6 +71,9 @@ public class SQLXmlELParser extends ClassXmlFlowELParser { * @param sqlParserVO sqlParserVO */ private void checkParserVO(SQLParserVO sqlParserVO) { + if (sqlParserVO.isDefaultDataSource()) { + return; + } if (StrUtil.isEmpty(sqlParserVO.getUrl())) { throw new ELSQLException(StrFormatter.format(ERROR_MSG_PATTERN, "url")); } diff --git a/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/util/JDBCHelper.java b/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/util/JDBCHelper.java index e7a8bc93..03435a21 100644 --- a/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/util/JDBCHelper.java +++ b/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/util/JDBCHelper.java @@ -9,7 +9,6 @@ import com.yomahub.liteflow.parser.sql.exception.ELSQLException; import com.yomahub.liteflow.parser.sql.vo.SQLParserVO; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -25,331 +24,279 @@ import java.util.Objects; */ public class JDBCHelper { - private static final String SQL_PATTERN = "SELECT {},{} FROM {} WHERE {}=?"; + private static final String SQL_PATTERN = "SELECT {},{} FROM {} WHERE {}=?"; - private static final String SCRIPT_SQL_CHECK_PATTERN = "SELECT 1 FROM {} WHERE {}=?"; + private static final String SCRIPT_SQL_CHECK_PATTERN = "SELECT 1 FROM {} WHERE {}=?"; - private static final String SCRIPT_SQL_PATTERN = "SELECT {},{},{},{} FROM {} WHERE {}=?"; + private static final String SCRIPT_SQL_PATTERN = "SELECT {},{},{},{} FROM {} WHERE {}=?"; - private static final String SCRIPT_WITH_LANGUAG_SQL_PATTERN = "SELECT {},{},{},{},{} FROM {} WHERE {}=?"; + private static final String SCRIPT_WITH_LANGUAG_SQL_PATTERN = "SELECT {},{},{},{},{} FROM {} WHERE {}=?"; - private static final String CHAIN_XML_PATTERN = "{}"; + private static final String CHAIN_XML_PATTERN = "{}"; - private static final String NODE_XML_PATTERN = "{}"; + private static final String NODE_XML_PATTERN = "{}"; - private static final String NODE_ITEM_XML_PATTERN = ""; + private static final String NODE_ITEM_XML_PATTERN = ""; - private static final String NODE_ITEM_WITH_LANGUAGE_XML_PATTERN = ""; + private static final String NODE_ITEM_WITH_LANGUAGE_XML_PATTERN = ""; - private static final String XML_PATTERN = "{}{}"; + private static final String XML_PATTERN = "{}{}"; - private static final Integer FETCH_SIZE_MAX = 1000; + private static final Integer FETCH_SIZE_MAX = 1000; - private SQLParserVO sqlParserVO; + private SQLParserVO sqlParserVO; - private static JDBCHelper INSTANCE; + private static JDBCHelper INSTANCE; - /** - * 初始化 INSTANCE - */ - public static void init(SQLParserVO sqlParserVO) { - try { - INSTANCE = new JDBCHelper(); - Class.forName(sqlParserVO.getDriverClassName()); - INSTANCE.setSqlParserVO(sqlParserVO); - } - catch (ClassNotFoundException e) { - throw new ELSQLException(e.getMessage()); - } - } + /** + * 初始化 INSTANCE + */ + public static void init(SQLParserVO sqlParserVO) { + try { + INSTANCE = new JDBCHelper(); + if (StrUtil.isNotBlank(sqlParserVO.getDriverClassName())) { + Class.forName(sqlParserVO.getDriverClassName()); + } + INSTANCE.setSqlParserVO(sqlParserVO); + } catch (ClassNotFoundException e) { + throw new ELSQLException(e.getMessage()); + } + } - /** - * 获取 INSTANCE - */ - public static JDBCHelper getInstance() { - return INSTANCE; - } + /** + * 获取 INSTANCE + */ + public static JDBCHelper getInstance() { + return INSTANCE; + } - /** - * 获取链接 - */ - public Connection getConn() { - Connection connection; - try { - connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), - sqlParserVO.getPassword()); - } - catch (SQLException e) { - throw new ELSQLException(e.getMessage()); - } - return connection; - } + /** + * 获取 ElData 数据内容 + */ + public String getContent() { + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; - /** - * 获取 ElData 数据内容 - */ - public String getContent() { - Connection conn = null; - PreparedStatement stmt = null; - ResultSet rs = null; + String chainTableName = sqlParserVO.getChainTableName(); + String elDataField = sqlParserVO.getElDataField(); + String chainNameField = sqlParserVO.getChainNameField(); + String chainApplicationNameField = sqlParserVO.getChainApplicationNameField(); + String applicationName = sqlParserVO.getApplicationName(); - String chainTableName = sqlParserVO.getChainTableName(); - String elDataField = sqlParserVO.getElDataField(); - String chainNameField = sqlParserVO.getChainNameField(); - String chainApplicationNameField = sqlParserVO.getChainApplicationNameField(); - String applicationName = sqlParserVO.getApplicationName(); + if (StrUtil.isBlank(chainTableName)) { + throw new ELSQLException("You did not define the chainTableName property"); + } - if (StrUtil.isBlank(chainTableName)) { - throw new ELSQLException("You did not define the chainTableName property"); - } + if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(chainApplicationNameField)) { + throw new ELSQLException("You did not define the applicationName or chainApplicationNameField property"); + } - if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(chainApplicationNameField)) { - throw new ELSQLException("You did not define the applicationName or chainApplicationNameField property"); - } + String sqlCmd = StrUtil.format(SQL_PATTERN, chainNameField, elDataField, chainTableName, + chainApplicationNameField); - String sqlCmd = StrUtil.format(SQL_PATTERN, chainNameField, elDataField, chainTableName, - chainApplicationNameField); + List result = new ArrayList<>(); + try { + conn = LiteFlowJdbcUtil.getConn(sqlParserVO); + stmt = conn.prepareStatement(sqlCmd, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); + // 设置游标拉取数量 + stmt.setFetchSize(FETCH_SIZE_MAX); + stmt.setString(1, applicationName); + rs = stmt.executeQuery(); - List result = new ArrayList<>(); - try { - conn = getConn(); - stmt = conn.prepareStatement(sqlCmd, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - // 设置游标拉取数量 - stmt.setFetchSize(FETCH_SIZE_MAX); - stmt.setString(1, applicationName); - rs = stmt.executeQuery(); + while (rs.next()) { + String elData = getStringFromResultSet(rs, elDataField); + String chainName = getStringFromResultSet(rs, chainNameField); - while (rs.next()) { - String elData = getStringFromResultSet(rs, elDataField); - String chainName = getStringFromResultSet(rs, chainNameField); + result.add(StrUtil.format(CHAIN_XML_PATTERN, XmlUtil.escape(chainName), elData)); + } + } catch (Exception e) { + throw new ELSQLException(e.getMessage()); + } finally { + // 关闭连接 + LiteFlowJdbcUtil.close(conn, stmt, rs); + } - result.add(StrUtil.format(CHAIN_XML_PATTERN, XmlUtil.escape(chainName), elData)); - } - } - catch (Exception e) { - throw new ELSQLException(e.getMessage()); - } - finally { - // 关闭连接 - close(conn, stmt, rs); - } + String chainsContent = CollUtil.join(result, StrUtil.EMPTY); - String chainsContent = CollUtil.join(result, StrUtil.EMPTY); + String nodesContent; + if (hasScriptData()) { + nodesContent = getScriptNodes(); + } else { + nodesContent = StrUtil.EMPTY; + } - String nodesContent; - if (hasScriptData()) { - nodesContent = getScriptNodes(); - } - else { - nodesContent = StrUtil.EMPTY; - } + return StrUtil.format(XML_PATTERN, nodesContent, chainsContent); + } - return StrUtil.format(XML_PATTERN, nodesContent, chainsContent); - } + /** + * 获取脚本节点内容 + */ + public String getScriptNodes() { + String scriptLanguageField = sqlParserVO.getScriptLanguageField(); + if (StrUtil.isNotBlank(scriptLanguageField)) { + return getScriptNodesWithLanguage(); + } - public String getScriptNodes() { - String scriptLanguageField = sqlParserVO.getScriptLanguageField(); - if (StrUtil.isNotBlank(scriptLanguageField)) { - return getScriptNodesWithLanguage(); - } + List result = new ArrayList<>(); + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; - List result = new ArrayList<>(); - Connection conn = null; - PreparedStatement stmt = null; - ResultSet rs = null; + String scriptTableName = sqlParserVO.getScriptTableName(); + String scriptIdField = sqlParserVO.getScriptIdField(); + String scriptDataField = sqlParserVO.getScriptDataField(); + String scriptNameField = sqlParserVO.getScriptNameField(); + String scriptTypeField = sqlParserVO.getScriptTypeField(); + String scriptApplicationNameField = sqlParserVO.getScriptApplicationNameField(); + String applicationName = sqlParserVO.getApplicationName(); - String scriptTableName = sqlParserVO.getScriptTableName(); - String scriptIdField = sqlParserVO.getScriptIdField(); - String scriptDataField = sqlParserVO.getScriptDataField(); - String scriptNameField = sqlParserVO.getScriptNameField(); - String scriptTypeField = sqlParserVO.getScriptTypeField(); - String scriptApplicationNameField = sqlParserVO.getScriptApplicationNameField(); - String applicationName = sqlParserVO.getApplicationName(); + if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(scriptApplicationNameField)) { + throw new ELSQLException("You did not define the applicationName or scriptApplicationNameField property"); + } - if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(scriptApplicationNameField)) { - throw new ELSQLException("You did not define the applicationName or scriptApplicationNameField property"); - } + String sqlCmd = StrUtil.format(SCRIPT_SQL_PATTERN, scriptIdField, scriptDataField, scriptNameField, + scriptTypeField, scriptTableName, scriptApplicationNameField); + try { + conn = LiteFlowJdbcUtil.getConn(sqlParserVO); + stmt = conn.prepareStatement(sqlCmd, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); + // 设置游标拉取数量 + stmt.setFetchSize(FETCH_SIZE_MAX); + stmt.setString(1, applicationName); + rs = stmt.executeQuery(); - String sqlCmd = StrUtil.format(SCRIPT_SQL_PATTERN, scriptIdField, scriptDataField, scriptNameField, - scriptTypeField, scriptTableName, scriptApplicationNameField); - try { - conn = getConn(); - stmt = conn.prepareStatement(sqlCmd, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - // 设置游标拉取数量 - stmt.setFetchSize(FETCH_SIZE_MAX); - stmt.setString(1, applicationName); - rs = stmt.executeQuery(); + while (rs.next()) { + String id = getStringFromResultSet(rs, scriptIdField); + String data = getStringFromResultSet(rs, scriptDataField); + String name = getStringFromResultSet(rs, scriptNameField); + String type = getStringFromResultSet(rs, scriptTypeField); - while (rs.next()) { - String id = getStringFromResultSet(rs, scriptIdField); - String data = getStringFromResultSet(rs, scriptDataField); - String name = getStringFromResultSet(rs, scriptNameField); - String type = getStringFromResultSet(rs, scriptTypeField); + NodeTypeEnum nodeTypeEnum = NodeTypeEnum.getEnumByCode(type); + if (Objects.isNull(nodeTypeEnum)) { + throw new ELSQLException(StrUtil.format("Invalid type value[{}]", type)); + } - NodeTypeEnum nodeTypeEnum = NodeTypeEnum.getEnumByCode(type); - if (Objects.isNull(nodeTypeEnum)) { - throw new ELSQLException(StrUtil.format("Invalid type value[{}]", type)); - } + if (!nodeTypeEnum.isScript()) { + throw new ELSQLException(StrUtil.format("The type value[{}] is not a script type", type)); + } - if (!nodeTypeEnum.isScript()) { - throw new ELSQLException(StrUtil.format("The type value[{}] is not a script type", type)); - } + result.add(StrUtil.format(NODE_ITEM_XML_PATTERN, XmlUtil.escape(id), XmlUtil.escape(name), type, data)); + } + } catch (Exception e) { + throw new ELSQLException(e.getMessage()); + } finally { + // 关闭连接 + LiteFlowJdbcUtil.close(conn, stmt, rs); + } + return StrUtil.format(NODE_XML_PATTERN, CollUtil.join(result, StrUtil.EMPTY)); + } - result.add(StrUtil.format(NODE_ITEM_XML_PATTERN, XmlUtil.escape(id), XmlUtil.escape(name), type, data)); - } - } - catch (Exception e) { - throw new ELSQLException(e.getMessage()); - } - finally { - // 关闭连接 - close(conn, stmt, rs); - } - return StrUtil.format(NODE_XML_PATTERN, CollUtil.join(result, StrUtil.EMPTY)); - } + /** + * 获取脚本节点(带语言) + * + * @return + */ + public String getScriptNodesWithLanguage() { - public String getScriptNodesWithLanguage() { + List result = new ArrayList<>(); + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; - List result = new ArrayList<>(); - Connection conn = null; - PreparedStatement stmt = null; - ResultSet rs = null; + String scriptTableName = sqlParserVO.getScriptTableName(); + String scriptIdField = sqlParserVO.getScriptIdField(); + String scriptDataField = sqlParserVO.getScriptDataField(); + String scriptNameField = sqlParserVO.getScriptNameField(); + String scriptTypeField = sqlParserVO.getScriptTypeField(); + String scriptApplicationNameField = sqlParserVO.getScriptApplicationNameField(); + String applicationName = sqlParserVO.getApplicationName(); + String scriptLanguageField = sqlParserVO.getScriptLanguageField(); - String scriptTableName = sqlParserVO.getScriptTableName(); - String scriptIdField = sqlParserVO.getScriptIdField(); - String scriptDataField = sqlParserVO.getScriptDataField(); - String scriptNameField = sqlParserVO.getScriptNameField(); - String scriptTypeField = sqlParserVO.getScriptTypeField(); - String scriptApplicationNameField = sqlParserVO.getScriptApplicationNameField(); - String applicationName = sqlParserVO.getApplicationName(); - String scriptLanguageField = sqlParserVO.getScriptLanguageField(); + if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(scriptApplicationNameField)) { + throw new ELSQLException("You did not define the applicationName or scriptApplicationNameField property"); + } - if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(scriptApplicationNameField)) { - throw new ELSQLException("You did not define the applicationName or scriptApplicationNameField property"); - } + String sqlCmd = StrUtil.format(SCRIPT_WITH_LANGUAG_SQL_PATTERN, scriptIdField, scriptDataField, scriptNameField, + scriptTypeField, scriptLanguageField, scriptTableName, scriptApplicationNameField); + try { + conn = LiteFlowJdbcUtil.getConn(sqlParserVO); + stmt = conn.prepareStatement(sqlCmd, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); + // 设置游标拉取数量 + stmt.setFetchSize(FETCH_SIZE_MAX); + stmt.setString(1, applicationName); + rs = stmt.executeQuery(); - String sqlCmd = StrUtil.format(SCRIPT_WITH_LANGUAG_SQL_PATTERN, scriptIdField, scriptDataField, scriptNameField, - scriptTypeField, scriptLanguageField, scriptTableName, scriptApplicationNameField); - try { - conn = getConn(); - stmt = conn.prepareStatement(sqlCmd, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - // 设置游标拉取数量 - stmt.setFetchSize(FETCH_SIZE_MAX); - stmt.setString(1, applicationName); - rs = stmt.executeQuery(); + while (rs.next()) { + String id = getStringFromResultSet(rs, scriptIdField); + String data = getStringFromResultSet(rs, scriptDataField); + String name = getStringFromResultSet(rs, scriptNameField); + String type = getStringFromResultSet(rs, scriptTypeField); + String language = getStringFromResultSet(rs, scriptLanguageField); - while (rs.next()) { - String id = getStringFromResultSet(rs, scriptIdField); - String data = getStringFromResultSet(rs, scriptDataField); - String name = getStringFromResultSet(rs, scriptNameField); - String type = getStringFromResultSet(rs, scriptTypeField); - String language = getStringFromResultSet(rs, scriptLanguageField); + NodeTypeEnum nodeTypeEnum = NodeTypeEnum.getEnumByCode(type); + if (Objects.isNull(nodeTypeEnum)) { + throw new ELSQLException(StrUtil.format("Invalid type value[{}]", type)); + } - NodeTypeEnum nodeTypeEnum = NodeTypeEnum.getEnumByCode(type); - if (Objects.isNull(nodeTypeEnum)) { - throw new ELSQLException(StrUtil.format("Invalid type value[{}]", type)); - } + if (!nodeTypeEnum.isScript()) { + throw new ELSQLException(StrUtil.format("The type value[{}] is not a script type", type)); + } - if (!nodeTypeEnum.isScript()) { - throw new ELSQLException(StrUtil.format("The type value[{}] is not a script type", type)); - } + if (!ScriptTypeEnum.checkScriptType(language)) { + throw new ELSQLException(StrUtil.format("The language value[{}] is error", language)); + } - if (!ScriptTypeEnum.checkScriptType(language)) { - throw new ELSQLException(StrUtil.format("The language value[{}] is error", language)); - } + result.add(StrUtil.format(NODE_ITEM_WITH_LANGUAGE_XML_PATTERN, XmlUtil.escape(id), XmlUtil.escape(name), + type, language, data)); + } + } catch (Exception e) { + throw new ELSQLException(e.getMessage()); + } finally { + // 关闭连接 + LiteFlowJdbcUtil.close(conn, stmt, rs); + } + return StrUtil.format(NODE_XML_PATTERN, CollUtil.join(result, StrUtil.EMPTY)); + } - result.add(StrUtil.format(NODE_ITEM_WITH_LANGUAGE_XML_PATTERN, XmlUtil.escape(id), XmlUtil.escape(name), - type, language, data)); - } - } - catch (Exception e) { - throw new ELSQLException(e.getMessage()); - } - finally { - // 关闭连接 - close(conn, stmt, rs); - } - return StrUtil.format(NODE_XML_PATTERN, CollUtil.join(result, StrUtil.EMPTY)); - } + private boolean hasScriptData() { + if (StrUtil.isBlank(sqlParserVO.getScriptTableName())) { + return false; + } - /** - * 关闭连接 - * @param conn conn - * @param stmt stmt - * @param rs rs - */ - private void close(Connection conn, PreparedStatement stmt, ResultSet rs) { - // 关闭连接 - if (conn != null) { - try { - conn.close(); - } - catch (SQLException e) { - throw new ELSQLException(e.getMessage()); - } - } - // 关闭 statement - if (stmt != null) { - try { - stmt.close(); - } - catch (SQLException e) { - throw new ELSQLException(e.getMessage()); - } - } - // 关闭结果集 - if (rs != null) { - try { - rs.close(); - } - catch (SQLException e) { - throw new ELSQLException(e.getMessage()); - } - } - } + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + String sqlCmd = StrUtil.format(SCRIPT_SQL_CHECK_PATTERN, sqlParserVO.getScriptTableName(), + sqlParserVO.getScriptApplicationNameField()); + try { + conn = LiteFlowJdbcUtil.getConn(sqlParserVO); + stmt = conn.prepareStatement(sqlCmd, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); + stmt.setFetchSize(1); + stmt.setString(1, sqlParserVO.getApplicationName()); + rs = stmt.executeQuery(); + return rs.next(); + } catch (Exception e) { + return false; + } finally { + // 关闭连接 + LiteFlowJdbcUtil.close(conn, stmt, rs); + } + } - private boolean hasScriptData() { - if (StrUtil.isBlank(sqlParserVO.getScriptTableName())) { - return false; - } + private String getStringFromResultSet(ResultSet rs, String field) throws SQLException { + String data = rs.getString(field); + if (StrUtil.isBlank(data)) { + throw new ELSQLException(StrUtil.format("exist {} field value is empty", field)); + } + return data; + } - Connection conn = null; - PreparedStatement stmt = null; - ResultSet rs = null; - String sqlCmd = StrUtil.format(SCRIPT_SQL_CHECK_PATTERN, sqlParserVO.getScriptTableName(), - sqlParserVO.getScriptApplicationNameField()); - try { - conn = getConn(); - stmt = conn.prepareStatement(sqlCmd, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - stmt.setFetchSize(1); - stmt.setString(1, sqlParserVO.getApplicationName()); - rs = stmt.executeQuery(); - return rs.next(); - } - catch (Exception e) { - return false; - } - finally { - // 关闭连接 - close(conn, stmt, rs); - } - } + private SQLParserVO getSqlParserVO() { + return sqlParserVO; + } - // #region get set method - private String getStringFromResultSet(ResultSet rs, String field) throws SQLException { - String data = rs.getString(field); - if (StrUtil.isBlank(data)) { - throw new ELSQLException(StrUtil.format("exist {} field value is empty", field)); - } - return data; - } - - private SQLParserVO getSqlParserVO() { - return sqlParserVO; - } - - private void setSqlParserVO(SQLParserVO sqlParserVO) { - this.sqlParserVO = sqlParserVO; - } + private void setSqlParserVO(SQLParserVO sqlParserVO) { + this.sqlParserVO = sqlParserVO; + } } diff --git a/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/util/LiteFlowJdbcUtil.java b/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/util/LiteFlowJdbcUtil.java new file mode 100644 index 00000000..4b2b640e --- /dev/null +++ b/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/util/LiteFlowJdbcUtil.java @@ -0,0 +1,134 @@ +package com.yomahub.liteflow.parser.sql.util; + +import cn.hutool.core.util.StrUtil; +import com.yomahub.liteflow.parser.sql.exception.ELSQLException; +import com.yomahub.liteflow.parser.sql.vo.SQLParserVO; +import com.yomahub.liteflow.spi.holder.ContextAwareHolder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.sql.DataSource; +import java.sql.*; +import java.util.Map; + +public class LiteFlowJdbcUtil { + private static final Logger LOG = LoggerFactory.getLogger(LiteFlowJdbcUtil.class); + private static final String CHECK_SQL_PATTERN = "SELECT {},{} FROM {} WHERE {}='{}'"; + + /** + * 获取链接 + * 此方法会根据配置,判读使用指定数据源,还是IOC容器中已有的数据源 + * + * @param sqlParserVO + * @return + */ + public static Connection getConn(SQLParserVO sqlParserVO) { + Connection connection = null; + String url = sqlParserVO.getUrl(); + String username = sqlParserVO.getUsername(); + String password = sqlParserVO.getPassword(); + + try { + // 如果不配置 jdbc 连接相关配置,代表使用项目数据源 + if (sqlParserVO.isDefaultDataSource()) { + String executeSql = buildCheckSql(sqlParserVO); + Map dataSourceMap = ContextAwareHolder.loadContextAware().getBeansOfType(DataSource.class); + // 遍历数据源,多数据源场景下,判断哪个数据源有 liteflow 配置 + for (Map.Entry entry : dataSourceMap.entrySet()) { + String dataSourceName = entry.getKey(); + DataSource dataSource = entry.getValue(); + + if (checkConnectionCanExecuteSql(dataSource.getConnection(), executeSql)) { + connection = dataSource.getConnection(); + LOG.info("use dataSourceName[{}],has found liteflow config", dataSourceName); + } else { + LOG.info("check dataSourceName[{}],but not has liteflow config", dataSourceName); + } + } + if (connection == null) { + throw new ELSQLException("can not found liteflow config in dataSourceName " + dataSourceMap.keySet()); + } + } + // 如果配置 jdbc 连接相关配置,代表使用指定链接信息 + else { + connection = DriverManager.getConnection(url, username, password); + } + + } catch (Exception e) { + throw new ELSQLException(e.getMessage()); + } + + return connection; + } + + /** + * 判断连接是否可以执行指定 sql + * + * @param conn 连接 + * @param sql 执行 sql + */ + public static boolean checkConnectionCanExecuteSql(Connection conn, String sql) { + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = conn.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); + stmt.setFetchSize(1); + rs = stmt.executeQuery(); + return rs.next(); + } catch (Exception e) { + return false; + } finally { + // 关闭连接 + close(conn, stmt, rs); + } + } + + /** + * 关闭 + * + * @param conn conn + * @param conn conn + * @param rs rs + */ + public static void close(Connection conn, PreparedStatement stmt, ResultSet rs) { + // 关闭连接 + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + throw new ELSQLException(e.getMessage()); + } + } + // 关闭 statement + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + throw new ELSQLException(e.getMessage()); + } + } + // 关闭结果集 + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + throw new ELSQLException(e.getMessage()); + } + } + } + + /** + * 构建检查 sql + * + * @param sqlParserVO + * @return + */ + private static String buildCheckSql(SQLParserVO sqlParserVO) { + String chainTableName = sqlParserVO.getChainTableName(); + String elDataField = sqlParserVO.getElDataField(); + String chainNameField = sqlParserVO.getChainNameField(); + String chainApplicationNameField = sqlParserVO.getChainApplicationNameField(); + String applicationName = sqlParserVO.getApplicationName(); + return StrUtil.format(CHECK_SQL_PATTERN, chainNameField, elDataField, chainTableName, chainApplicationNameField, applicationName); + } +} diff --git a/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/vo/SQLParserVO.java b/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/vo/SQLParserVO.java index 4459d192..b549bafd 100644 --- a/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/vo/SQLParserVO.java +++ b/liteflow-rule-plugin/liteflow-rule-sql/src/main/java/com/yomahub/liteflow/parser/sql/vo/SQLParserVO.java @@ -1,5 +1,7 @@ package com.yomahub.liteflow.parser.sql.vo; +import cn.hutool.core.util.StrUtil; + /** * 用于解析 RuleSourceExtData 的 VO 类,用于 sql 模式中 * @@ -8,212 +10,219 @@ package com.yomahub.liteflow.parser.sql.vo; */ public class SQLParserVO { - /** - * 连接地址 - */ - private String url; + /** + * 连接地址 + */ + private String url; - /** - * 驱动 - */ - private String driverClassName; + /** + * 驱动 + */ + private String driverClassName; - /** - * 账号名 - */ - private String username; + /** + * 账号名 + */ + private String username; - /** - * 密码 - */ - private String password; + /** + * 密码 + */ + private String password; - /** - * 应用名 - */ - private String applicationName; + /** + * 应用名 + */ + private String applicationName; - /** - * chain表名 - */ - private String chainTableName; + /** + * chain表名 + */ + private String chainTableName; - /** - * chain表里的应用名字段 - */ - private String chainApplicationNameField = "application_name"; + /** + * chain表里的应用名字段 + */ + private String chainApplicationNameField = "application_name"; - /** - * chainName - */ - private String chainNameField = "chain_name"; + /** + * chainName + */ + private String chainNameField = "chain_name"; - /** - * el 表达式相关数据 - */ - private String elDataField = "el_data"; + /** + * el 表达式相关数据 + */ + private String elDataField = "el_data"; - /** - * 脚本 node 表名 - */ - private String scriptTableName; + /** + * 脚本 node 表名 + */ + private String scriptTableName; - /** - * script表里的应用名字段 - */ - private String scriptApplicationNameField = "application_name"; + /** + * script表里的应用名字段 + */ + private String scriptApplicationNameField = "application_name"; - /** - * 脚本 node id 字段 - */ - private String scriptIdField = "script_id"; + /** + * 脚本 node id 字段 + */ + private String scriptIdField = "script_id"; - /** - * 脚本 node name 字段 - */ - private String scriptNameField = "script_name"; + /** + * 脚本 node name 字段 + */ + private String scriptNameField = "script_name"; - /** - * 脚本 node data 字段 - */ - private String scriptDataField = "script_data"; + /** + * 脚本 node data 字段 + */ + private String scriptDataField = "script_data"; - /** - * 脚本 node type 字段 - */ - private String scriptTypeField = "script_type"; + /** + * 脚本 node type 字段 + */ + private String scriptTypeField = "script_type"; - /** - * 脚本 node language 字段 - */ - private String scriptLanguageField; + /** + * 脚本 node language 字段 + */ + private String scriptLanguageField; - public String getUrl() { - return url; - } + public String getUrl() { + return url; + } - public void setUrl(String url) { - this.url = url; - } + public void setUrl(String url) { + this.url = url; + } - public String getDriverClassName() { - return driverClassName; - } + public String getDriverClassName() { + return driverClassName; + } - public void setDriverClassName(String driverClassName) { - this.driverClassName = driverClassName; - } + public void setDriverClassName(String driverClassName) { + this.driverClassName = driverClassName; + } - public String getUsername() { - return username; - } + public String getUsername() { + return username; + } - public void setUsername(String username) { - this.username = username; - } + public void setUsername(String username) { + this.username = username; + } - public String getPassword() { - return password; - } + public String getPassword() { + return password; + } - public void setPassword(String password) { - this.password = password; - } + public void setPassword(String password) { + this.password = password; + } - public String getApplicationName() { - return applicationName; - } + public String getApplicationName() { + return applicationName; + } - public void setApplicationName(String applicationName) { - this.applicationName = applicationName; - } + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } - public String getChainTableName() { - return chainTableName; - } + public String getChainTableName() { + return chainTableName; + } - public void setChainTableName(String chainTableName) { - this.chainTableName = chainTableName; - } + public void setChainTableName(String chainTableName) { + this.chainTableName = chainTableName; + } - public String getChainApplicationNameField() { - return chainApplicationNameField; - } + public String getChainApplicationNameField() { + return chainApplicationNameField; + } - public void setChainApplicationNameField(String chainApplicationNameField) { - this.chainApplicationNameField = chainApplicationNameField; - } + public void setChainApplicationNameField(String chainApplicationNameField) { + this.chainApplicationNameField = chainApplicationNameField; + } - public String getChainNameField() { - return chainNameField; - } + public String getChainNameField() { + return chainNameField; + } - public void setChainNameField(String chainNameField) { - this.chainNameField = chainNameField; - } + public void setChainNameField(String chainNameField) { + this.chainNameField = chainNameField; + } - public String getElDataField() { - return elDataField; - } + public String getElDataField() { + return elDataField; + } - public void setElDataField(String elDataField) { - this.elDataField = elDataField; - } + public void setElDataField(String elDataField) { + this.elDataField = elDataField; + } - public String getScriptTableName() { - return scriptTableName; - } + public String getScriptTableName() { + return scriptTableName; + } - public void setScriptTableName(String scriptTableName) { - this.scriptTableName = scriptTableName; - } + public void setScriptTableName(String scriptTableName) { + this.scriptTableName = scriptTableName; + } - public String getScriptApplicationNameField() { - return scriptApplicationNameField; - } + public String getScriptApplicationNameField() { + return scriptApplicationNameField; + } - public void setScriptApplicationNameField(String scriptApplicationNameField) { - this.scriptApplicationNameField = scriptApplicationNameField; - } + public void setScriptApplicationNameField(String scriptApplicationNameField) { + this.scriptApplicationNameField = scriptApplicationNameField; + } - public String getScriptIdField() { - return scriptIdField; - } + public String getScriptIdField() { + return scriptIdField; + } - public void setScriptIdField(String scriptIdField) { - this.scriptIdField = scriptIdField; - } + public void setScriptIdField(String scriptIdField) { + this.scriptIdField = scriptIdField; + } - public String getScriptNameField() { - return scriptNameField; - } + public String getScriptNameField() { + return scriptNameField; + } - public void setScriptNameField(String scriptNameField) { - this.scriptNameField = scriptNameField; - } + public void setScriptNameField(String scriptNameField) { + this.scriptNameField = scriptNameField; + } - public String getScriptDataField() { - return scriptDataField; - } + public String getScriptDataField() { + return scriptDataField; + } - public void setScriptDataField(String scriptDataField) { - this.scriptDataField = scriptDataField; - } + public void setScriptDataField(String scriptDataField) { + this.scriptDataField = scriptDataField; + } - public String getScriptTypeField() { - return scriptTypeField; - } + public String getScriptTypeField() { + return scriptTypeField; + } - public void setScriptTypeField(String scriptTypeField) { - this.scriptTypeField = scriptTypeField; - } + public void setScriptTypeField(String scriptTypeField) { + this.scriptTypeField = scriptTypeField; + } - public String getScriptLanguageField() { - return scriptLanguageField; - } + public String getScriptLanguageField() { + return scriptLanguageField; + } - public void setScriptLanguageField(String scriptLanguageField) { - this.scriptLanguageField = scriptLanguageField; - } + public void setScriptLanguageField(String scriptLanguageField) { + this.scriptLanguageField = scriptLanguageField; + } + + /** + * 判断配资是否使用 IOC 已有数据源 + */ + public boolean isDefaultDataSource() { + return StrUtil.isBlank(url) && StrUtil.isBlank(username) && StrUtil.isBlank(password) && StrUtil.isBlank(driverClassName); + } } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonContextAware.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonContextAware.java index 8488019a..4cb16d9e 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonContextAware.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonContextAware.java @@ -1,10 +1,15 @@ package com.yomahub.liteflow.spi.solon; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.yomahub.liteflow.spi.ContextAware; import org.noear.solon.Solon; import org.noear.solon.core.BeanWrap; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * 基于代码形式的 Solon 上下文工具类 * @@ -12,73 +17,76 @@ import org.noear.solon.core.BeanWrap; */ public class SolonContextAware implements ContextAware { - @Override - public T getBean(String name) { - try { - return Solon.context().getBean(name); - } - catch (Exception e) { - return null; - } - } + @Override + public T getBean(String name) { + try { + return Solon.context().getBean(name); + } catch (Exception e) { + return null; + } + } - @Override - public T getBean(Class clazz) { - try { - return Solon.context().getBean(clazz); - } - catch (Exception e) { - return null; - } - } + @Override + public T getBean(Class clazz) { + try { + return Solon.context().getBean(clazz); + } catch (Exception e) { + return null; + } + } - private T getBean(String beanName, Class clazz) { - try { - return Solon.context().getBean(beanName); - } - catch (Exception e) { - return null; - } - } + private T getBean(String beanName, Class clazz) { + try { + return Solon.context().getBean(beanName); + } catch (Exception e) { + return null; + } + } - @Override - public T registerBean(String beanName, Class c) { - BeanWrap beanWrap = new BeanWrap(Solon.context(), c, null, beanName); - Solon.context().putWrap(beanName, beanWrap); + @Override + public T registerBean(String beanName, Class c) { + BeanWrap beanWrap = new BeanWrap(Solon.context(), c, null, beanName); + Solon.context().putWrap(beanName, beanWrap); - return beanWrap.get(); - } + return beanWrap.get(); + } - @Override - public T registerBean(Class c) { - return registerBean(c.getName(), c); - } + @Override + public T registerBean(Class c) { + return registerBean(c.getName(), c); + } - @Override - public T registerBean(String beanName, Object bean) { - BeanWrap beanWrap = new BeanWrap(Solon.context(), bean.getClass(), bean, beanName); - Solon.context().putWrap(beanName, beanWrap); + @Override + public T registerBean(String beanName, Object bean) { + BeanWrap beanWrap = new BeanWrap(Solon.context(), bean.getClass(), bean, beanName); + Solon.context().putWrap(beanName, beanWrap); - return beanWrap.get(); - } + return beanWrap.get(); + } - @Override - public T registerOrGet(String beanName, Class clazz) { - T t = getBean(beanName, clazz); - if (ObjectUtil.isNull(t)) { - t = registerBean(beanName, clazz); - } - return t; - } + @Override + public T registerOrGet(String beanName, Class clazz) { + T t = getBean(beanName, clazz); + if (ObjectUtil.isNull(t)) { + t = registerBean(beanName, clazz); + } + return t; + } - @Override - public boolean hasBean(String beanName) { - return Solon.context().hasWrap(beanName); - } + @Override + public Map getBeansOfType(Class type) { + List wrapsOfType = Solon.context().getWrapsOfType(type); + return CollUtil.toMap(wrapsOfType, new HashMap(), BeanWrap::name, BeanWrap::get); + } - @Override - public int priority() { - return 1; - } + @Override + public boolean hasBean(String beanName) { + return Solon.context().hasWrap(beanName); + } + + @Override + public int priority() { + return 1; + } } diff --git a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringAware.java b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringAware.java index 232adecb..41e604f0 100644 --- a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringAware.java +++ b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringAware.java @@ -1,10 +1,8 @@ package com.yomahub.liteflow.spi.spring; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.ReflectUtil; import com.yomahub.liteflow.spi.ContextAware; import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; @@ -12,6 +10,8 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; +import java.util.Map; + /** * 基于代码形式的spring上下文工具类 * @@ -19,83 +19,87 @@ import org.springframework.context.ConfigurableApplicationContext; */ public class SpringAware implements ApplicationContextAware, ContextAware { - private static ApplicationContext applicationContext = null; + private static ApplicationContext applicationContext = null; - public SpringAware() { - } + public SpringAware() { + } - @Override - public void setApplicationContext(ApplicationContext ac) throws BeansException { - applicationContext = ac; - } + @Override + public void setApplicationContext(ApplicationContext ac) throws BeansException { + applicationContext = ac; + } - public static ApplicationContext getApplicationContext() { - return applicationContext; - } + public static ApplicationContext getApplicationContext() { + return applicationContext; + } - @Override - public T getBean(String name) { - T t = (T) applicationContext.getBean(name); - return t; - } + @Override + public T getBean(String name) { + T t = (T) applicationContext.getBean(name); + return t; + } - @Override - public T getBean(Class clazz) { - T t = applicationContext.getBean(clazz); - return t; - } + @Override + public Map getBeansOfType(Class type) { + return applicationContext.getBeansOfType(type); + } - private T getBean(String beanName, Class clazz) { - T t = applicationContext.getBean(beanName, clazz); - return t; - } + @Override + public T getBean(Class clazz) { + T t = applicationContext.getBean(clazz); + return t; + } - @Override - public T registerBean(String beanName, Class c) { - DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationContext - .getAutowireCapableBeanFactory(); - BeanDefinition beanDefinition = new GenericBeanDefinition(); - beanDefinition.setBeanClassName(c.getName()); - beanFactory.setAllowBeanDefinitionOverriding(true); - beanFactory.registerBeanDefinition(beanName, beanDefinition); - return getBean(beanName); - } + private T getBean(String beanName, Class clazz) { + T t = applicationContext.getBean(beanName, clazz); + return t; + } - @Override - public T registerBean(Class c) { - return registerBean(c.getName(), c); - } + @Override + public T registerBean(String beanName, Class c) { + DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationContext + .getAutowireCapableBeanFactory(); + BeanDefinition beanDefinition = new GenericBeanDefinition(); + beanDefinition.setBeanClassName(c.getName()); + beanFactory.setAllowBeanDefinitionOverriding(true); + beanFactory.registerBeanDefinition(beanName, beanDefinition); + return getBean(beanName); + } - @Override - public T registerBean(String beanName, Object bean) { - ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) applicationContext; - DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) configurableApplicationContext - .getAutowireCapableBeanFactory(); - defaultListableBeanFactory.registerSingleton(beanName, bean); - return (T) configurableApplicationContext.getBean(beanName); - } + @Override + public T registerBean(Class c) { + return registerBean(c.getName(), c); + } - @Override - public T registerOrGet(String beanName, Class clazz) { - if (ObjectUtil.isNull(applicationContext)) { - return null; - } - try { - return getBean(beanName, clazz); - } - catch (Exception e) { - return registerBean(beanName, clazz); - } - } + @Override + public T registerBean(String beanName, Object bean) { + ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) applicationContext; + DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) configurableApplicationContext + .getAutowireCapableBeanFactory(); + defaultListableBeanFactory.registerSingleton(beanName, bean); + return (T) configurableApplicationContext.getBean(beanName); + } - @Override - public boolean hasBean(String beanName) { - return applicationContext.containsBean(beanName); - } + @Override + public T registerOrGet(String beanName, Class clazz) { + if (ObjectUtil.isNull(applicationContext)) { + return null; + } + try { + return getBean(beanName, clazz); + } catch (Exception e) { + return registerBean(beanName, clazz); + } + } - @Override - public int priority() { - return 1; - } + @Override + public boolean hasBean(String beanName) { + return applicationContext.containsBean(beanName); + } + + @Override + public int priority() { + return 1; + } } diff --git a/liteflow-spring/src/main/java/com/yomahub/liteflow/spring/LiteFlowSpringUtil.java b/liteflow-spring/src/main/java/com/yomahub/liteflow/spring/LiteFlowSpringUtil.java new file mode 100644 index 00000000..fe019718 --- /dev/null +++ b/liteflow-spring/src/main/java/com/yomahub/liteflow/spring/LiteFlowSpringUtil.java @@ -0,0 +1,275 @@ +package com.yomahub.liteflow.spring; + +import cn.hutool.core.exceptions.UtilException; +import cn.hutool.core.lang.TypeReference; +import cn.hutool.core.util.ArrayUtil; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.beans.factory.support.DefaultSingletonBeanRegistry; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.ResolvableType; + +import java.lang.reflect.ParameterizedType; +import java.util.Arrays; +import java.util.Map; + + +public class LiteFlowSpringUtil implements BeanFactoryPostProcessor, ApplicationContextAware { + + /** + * "@PostConstruct"注解标记的类中,由于ApplicationContext还未加载,导致空指针
+ * 因此实现BeanFactoryPostProcessor注入ConfigurableListableBeanFactory实现bean的操作 + */ + private static ConfigurableListableBeanFactory beanFactory; + /** + * Spring应用上下文环境 + */ + private static ApplicationContext applicationContext; + + @SuppressWarnings("NullableProblems") + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + LiteFlowSpringUtil.beanFactory = beanFactory; + } + + @SuppressWarnings("NullableProblems") + @Override + public void setApplicationContext(ApplicationContext applicationContext) { + LiteFlowSpringUtil.applicationContext = applicationContext; + } + + /** + * 获取{@link ApplicationContext} + * + * @return {@link ApplicationContext} + */ + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + /** + * 获取{@link ListableBeanFactory},可能为{@link ConfigurableListableBeanFactory} 或 {@link ApplicationContextAware} + * + * @return {@link ListableBeanFactory} + * @since 5.7.0 + */ + public static ListableBeanFactory getBeanFactory() { + final ListableBeanFactory factory = null == beanFactory ? applicationContext : beanFactory; + if (null == factory) { + throw new UtilException("No ConfigurableListableBeanFactory or ApplicationContext injected, maybe not in the Spring environment?"); + } + return factory; + } + + /** + * 获取{@link ConfigurableListableBeanFactory} + * + * @return {@link ConfigurableListableBeanFactory} + * @throws UtilException 当上下文非ConfigurableListableBeanFactory抛出异常 + * @since 5.7.7 + */ + public static ConfigurableListableBeanFactory getConfigurableBeanFactory() throws UtilException { + final ConfigurableListableBeanFactory factory; + if (null != beanFactory) { + factory = beanFactory; + } else if (applicationContext instanceof ConfigurableApplicationContext) { + factory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory(); + } else { + throw new UtilException("No ConfigurableListableBeanFactory from context!"); + } + return factory; + } + + //通过name获取 Bean. + + /** + * 通过name获取 Bean + * + * @param Bean类型 + * @param name Bean名称 + * @return Bean + */ + @SuppressWarnings("unchecked") + public static T getBean(String name) { + return (T) getBeanFactory().getBean(name); + } + + /** + * 通过class获取Bean + * + * @param Bean类型 + * @param clazz Bean类 + * @return Bean对象 + */ + public static T getBean(Class clazz) { + return getBeanFactory().getBean(clazz); + } + + /** + * 通过name,以及Clazz返回指定的Bean + * + * @param bean类型 + * @param name Bean名称 + * @param clazz bean类型 + * @return Bean对象 + */ + public static T getBean(String name, Class clazz) { + return getBeanFactory().getBean(name, clazz); + } + + /** + * 通过类型参考返回带泛型参数的Bean + * + * @param reference 类型参考,用于持有转换后的泛型类型 + * @param Bean类型 + * @return 带泛型参数的Bean + * @since 5.4.0 + */ + @SuppressWarnings("unchecked") + public static T getBean(TypeReference reference) { + final ParameterizedType parameterizedType = (ParameterizedType) reference.getType(); + final Class rawType = (Class) parameterizedType.getRawType(); + final Class[] genericTypes = Arrays.stream(parameterizedType.getActualTypeArguments()).map(type -> (Class) type).toArray(Class[]::new); + final String[] beanNames = getBeanFactory().getBeanNamesForType(ResolvableType.forClassWithGenerics(rawType, genericTypes)); + return getBean(beanNames[0], rawType); + } + + /** + * 获取指定类型对应的所有Bean,包括子类 + * + * @param Bean类型 + * @param type 类、接口,null表示获取所有bean + * @return 类型对应的bean,key是bean注册的name,value是Bean + * @since 5.3.3 + */ + public static Map getBeansOfType(Class type) { + return getBeanFactory().getBeansOfType(type); + } + + /** + * 获取指定类型对应的Bean名称,包括子类 + * + * @param type 类、接口,null表示获取所有bean名称 + * @return bean名称 + * @since 5.3.3 + */ + public static String[] getBeanNamesForType(Class type) { + return getBeanFactory().getBeanNamesForType(type); + } + + /** + * 获取配置文件配置项的值 + * + * @param key 配置项key + * @return 属性值 + * @since 5.3.3 + */ + public static String getProperty(String key) { + if (null == applicationContext) { + return null; + } + return applicationContext.getEnvironment().getProperty(key); + } + + /** + * 获取应用程序名称 + * + * @return 应用程序名称 + * @since 5.7.12 + */ + public static String getApplicationName() { + return getProperty("spring.application.name"); + } + + /** + * 获取当前的环境配置,无配置返回null + * + * @return 当前的环境配置 + * @since 5.3.3 + */ + public static String[] getActiveProfiles() { + if (null == applicationContext) { + return null; + } + return applicationContext.getEnvironment().getActiveProfiles(); + } + + /** + * 获取当前的环境配置,当有多个环境配置时,只获取第一个 + * + * @return 当前的环境配置 + * @since 5.3.3 + */ + public static String getActiveProfile() { + final String[] activeProfiles = getActiveProfiles(); + return ArrayUtil.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; + } + + /** + * 动态向Spring注册Bean + *

+ * 由{@link org.springframework.beans.factory.BeanFactory} 实现,通过工具开放API + *

+ * 更新: shadow 2021-07-29 17:20:44 增加自动注入,修复注册bean无法反向注入的问题 + * + * @param Bean类型 + * @param beanName 名称 + * @param bean bean + * @author shadow + * @since 5.4.2 + */ + public static void registerBean(String beanName, T bean) { + final ConfigurableListableBeanFactory factory = getConfigurableBeanFactory(); + factory.autowireBean(bean); + factory.registerSingleton(beanName, bean); + } + + /** + * 注销bean + *

+ * 将Spring中的bean注销,请谨慎使用 + * + * @param beanName bean名称 + * @author shadow + * @since 5.7.7 + */ + public static void unregisterBean(String beanName) { + final ConfigurableListableBeanFactory factory = getConfigurableBeanFactory(); + if (factory instanceof DefaultSingletonBeanRegistry) { + DefaultSingletonBeanRegistry registry = (DefaultSingletonBeanRegistry) factory; + registry.destroySingleton(beanName); + } else { + throw new UtilException("Can not unregister bean, the factory is not a DefaultSingletonBeanRegistry!"); + } + } + + /** + * 发布事件 + * + * @param event 待发布的事件,事件必须是{@link ApplicationEvent}的子类 + * @since 5.7.12 + */ + public static void publishEvent(ApplicationEvent event) { + if (null != applicationContext) { + applicationContext.publishEvent(event); + } + } + + /** + * 发布事件 + * Spring 4.2+ 版本事件可以不再是{@link ApplicationEvent}的子类 + * + * @param event 待发布的事件 + * @since 5.7.21 + */ + public static void publishEvent(Object event) { + if (null != applicationContext) { + applicationContext.publishEvent(event); + } + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java new file mode 100644 index 00000000..c573fd24 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java @@ -0,0 +1,34 @@ +package com.yomahub.liteflow.test.def; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.test.BaseTest; +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.junit.jupiter.SpringExtension; + +import javax.annotation.Resource; + +@ExtendWith(SpringExtension.class) +@TestPropertySource(value = "classpath:/application-xml.properties") +@SpringBootTest(classes = SQLWithXmlELMultiLanguageSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.sql.cmp"}) +public class SQLWithXmlELMultiLanguageSpringbootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testMultiLanguage1() { + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + 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/def/SQLWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java new file mode 100644 index 00000000..87edf48c --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java @@ -0,0 +1,101 @@ +package com.yomahub.liteflow.test.def; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.parser.sql.exception.ELSQLException; +import com.yomahub.liteflow.parser.sql.vo.SQLParserVO; +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.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.junit.jupiter.SpringExtension; + +import javax.annotation.Resource; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; + +/** + * @author tangkc + * @since 2.9.0 + */ +@ExtendWith(SpringExtension.class) +@TestPropertySource(value = "classpath:/application-xml.properties") +@SpringBootTest(classes = SQLWithXmlELSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.sql.cmp"}) +public class SQLWithXmlELSpringbootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testSQLWithXml() { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); + + // 修改数据库 + changeData(); + + // 重新加载规则 + flowExecutor.reloadRule(); + Assertions.assertEquals("a==>c==>b", flowExecutor.execute2Resp("chain1", "arg").getExecuteStepStr()); + } + + @Test + public void testSQLWithScriptXml() { + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime()); + + // 修改数据库 + changeScriptData(); + // 重新加载规则 + flowExecutor.reloadRule(); + Assertions.assertEquals("x0[if 脚本]", flowExecutor.execute2Resp("chain3", "arg").getExecuteStepStr()); + } + + /** + * 修改数据库数据 + */ + private void changeData() { + LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); + SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class); + Connection connection; + try { + connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), + sqlParserVO.getPassword()); + Statement statement = connection.createStatement(); + statement.executeUpdate("UPDATE EL_TABLE SET EL_DATA='THEN(a, c, b);' WHERE chain_name='chain1'"); + } catch (SQLException e) { + throw new ELSQLException(e.getMessage()); + } + } + + /** + * 修改数据库数据 + */ + private void changeScriptData() { + LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); + SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class); + Connection connection; + try { + connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), + sqlParserVO.getPassword()); + Statement statement = connection.createStatement(); + statement.executeUpdate( + "UPDATE SCRIPT_NODE_TABLE SET SCRIPT_NODE_DATA='return false;' WHERE SCRIPT_NODE_ID='x0'"); + } catch (SQLException e) { + throw new ELSQLException(e.getMessage()); + } + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/resources/application-data-source-xml.properties b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/resources/application-data-source-xml.properties new file mode 100644 index 00000000..4458be23 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/resources/application-data-source-xml.properties @@ -0,0 +1,21 @@ +liteflow.rule-source-ext-data={\ + "applicationName":"demo",\ + "chainTableName":"EL_TABLE",\ + "chainApplicationNameField":"application_name",\ + "chainNameField":"chain_name",\ + "elDataField":"EL_DATA",\ + "scriptTableName":"script_node_table",\ + "scriptApplicationNameField":"application_name",\ + "scriptIdField":"script_node_id",\ + "scriptNameField":"script_node_name",\ + "scriptDataField":"script_node_data",\ + "scriptLanguageField":"script_language",\ + "scriptTypeField":"script_node_type"\ + } +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.url=jdbc:h2:mem:test_db;MODE=MySQL +spring.datasource.username=root +spring.datasource.password=123456 +spring.datasource.schema=classpath:/sql/schema.sql +spring.datasource.data=classpath:/sql/data.sql +spring.datasource.platform=h2 \ No newline at end of file From f0d92de9c3f7dda7403e8fd8a91a899e2ead4b78 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Sun, 16 Jul 2023 22:12:30 +0800 Subject: [PATCH 15/30] =?UTF-8?q?enhancement=20#I7LGZR=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=9C=AA=E5=A1=AB=E5=86=99=20chainId=20=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/parser/helper/ParserHelper.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java index 983521d3..eb239f76 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java @@ -140,6 +140,8 @@ public class ParserHelper { // 校验加载的 chainName 是否有重复的 // TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了 String chainName = Optional.ofNullable(e.attributeValue(ID)).orElse(e.attributeValue(NAME)); + // 检查 chainName + checkChainId(chainName, e.getText()); if (!chainNameSet.add(chainName)) { throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName)); } @@ -202,9 +204,11 @@ public class ParserHelper { JsonNode innerJsonObject = iterator.next(); // 校验加载的 chainName 是否有重复的 // TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了 - String chainName = Optional.ofNullable(innerJsonObject.get(ID)) - .orElse(innerJsonObject.get(NAME)) - .textValue(); + JsonNode chainNameJsonNode = Optional.ofNullable(innerJsonObject.get(ID)) + .orElse(innerJsonObject.get(NAME)); + String chainName = Optional.ofNullable(chainNameJsonNode).map(JsonNode::textValue).orElse(null); + // 检查 chainName + checkChainId(chainName, innerJsonObject.toPrettyString()); if (!chainNameSet.add(chainName)) { throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName)); } @@ -250,6 +254,17 @@ public class ParserHelper { chainELBuilder.setEL(el).build(); } + /** + * 检查 chainId + * @param chainId chainId + * @param elData elData + */ + private static void checkChainId(String chainId, String elData) { + if (StrUtil.isBlank(chainId)) { + throw new ParseException("missing chain id in expression \r\n" + elData); + } + } + private static class RegexUtil { // java 注释的正则表达式 From 62419c44196b6a8af9531789b55c7cd8b0aacb14 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Sun, 16 Jul 2023 23:18:37 +0800 Subject: [PATCH 16/30] =?UTF-8?q?I7L5DX=20#I7L5DX=202.10.5=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=B8=ADScriptBean=E6=B3=A8=E8=A7=A3=E6=B3=A8?= =?UTF-8?q?=E5=85=A5bean=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/core/proxy/ComponentProxy.java | 3 +- .../liteflow/exception/ProxyException.java | 31 +++++++++++++++++++ .../script/proxy/ScriptBeanProxy.java | 22 +++++++++---- .../LiteFlowScriptScriptbeanGroovyELTest.java | 9 ++++++ .../groovy/scriptbean/bean/DemoBean5.java | 26 ++++++++++++++++ .../src/test/resources/scriptbean/flow.xml | 11 +++++++ 6 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 liteflow-core/src/main/java/com/yomahub/liteflow/exception/ProxyException.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptbean/bean/DemoBean5.java diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java index a0d5ebea..4ca355f8 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java @@ -10,6 +10,7 @@ import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import com.yomahub.liteflow.enums.NodeTypeEnum; import com.yomahub.liteflow.exception.ComponentMethodDefineErrorException; import com.yomahub.liteflow.exception.LiteFlowException; +import com.yomahub.liteflow.exception.ProxyException; import com.yomahub.liteflow.log.LFLog; import com.yomahub.liteflow.log.LFLoggerManager; import com.yomahub.liteflow.util.LiteFlowProxyUtil; @@ -153,7 +154,7 @@ public class ComponentProxy { return nodeComponent; } catch (Exception e) { - throw new LiteFlowException(e); + throw new ProxyException(e); } }).collect(Collectors.toList()); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ProxyException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ProxyException.java new file mode 100644 index 00000000..77e21c11 --- /dev/null +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ProxyException.java @@ -0,0 +1,31 @@ + +package com.yomahub.liteflow.exception; + +/** + * @author Bryan.Zhang + */ +public class ProxyException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** 异常信息 */ + private String message; + + public ProxyException(String message) { + this.message = message; + } + + public ProxyException(Throwable cause) { + super(cause); + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/script/proxy/ScriptBeanProxy.java b/liteflow-core/src/main/java/com/yomahub/liteflow/script/proxy/ScriptBeanProxy.java index c70c13a2..35c02922 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/script/proxy/ScriptBeanProxy.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/script/proxy/ScriptBeanProxy.java @@ -3,6 +3,7 @@ package com.yomahub.liteflow.script.proxy; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.*; import com.yomahub.liteflow.exception.LiteFlowException; +import com.yomahub.liteflow.exception.ProxyException; import com.yomahub.liteflow.exception.ScriptBeanMethodInvokeException; import com.yomahub.liteflow.log.LFLog; import com.yomahub.liteflow.log.LFLoggerManager; @@ -10,8 +11,18 @@ import com.yomahub.liteflow.script.annotation.ScriptBean; import com.yomahub.liteflow.util.LiteFlowProxyUtil; import com.yomahub.liteflow.util.SerialsUtil; import net.bytebuddy.ByteBuddy; +import net.bytebuddy.description.method.ParameterDescription; +import net.bytebuddy.description.modifier.Visibility; +import net.bytebuddy.dynamic.DynamicType; +import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy; +import net.bytebuddy.implementation.FixedValue; import net.bytebuddy.implementation.InvocationHandlerAdapter; +import net.bytebuddy.implementation.MethodCall; +import net.bytebuddy.implementation.MethodDelegation; +import net.bytebuddy.implementation.bytecode.constant.DefaultValue; import net.bytebuddy.matcher.ElementMatchers; + +import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.util.Arrays; @@ -56,19 +67,18 @@ public class ScriptBeanProxy { } try { - return new ByteBuddy().subclass(orignalClass) - .name(StrUtil.format("{}.ByteBuddy${}", ClassUtil.getPackage(orignalClass), - SerialsUtil.generateShortUUID())) + Class c = new ByteBuddy().subclass(orignalClass).name(StrUtil.format("{}.ByteBuddy${}", ClassUtil.getPackage(orignalClass),SerialsUtil.generateShortUUID())) .method(ElementMatchers.any()) .intercept(InvocationHandlerAdapter.of(new AopInvocationHandler(bean, methodNameList))) .annotateType(orignalClass.getAnnotations()) .make() .load(ScriptBeanProxy.class.getClassLoader()) - .getLoaded() - .newInstance(); + .getLoaded(); + + return ReflectUtil.newInstanceIfPossible(c); } catch (Exception e) { - throw new LiteFlowException(e); + throw new ProxyException(e); } } 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 2cf256c3..11c33ede 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 @@ -92,4 +92,13 @@ public class LiteFlowScriptScriptbeanGroovyELTest extends BaseTest { Assertions.assertEquals("hello", context.get("demo")); } + //测试用构造方法的方式注入bean的场景 + @Test + public void testScriptBean8() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg"); + Assertions.assertTrue(response.isSuccess()); + DefaultContext context = response.getFirstContextBean(); + Assertions.assertEquals("hello,jordan", context.getData("demo")); + } + } diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptbean/bean/DemoBean5.java b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptbean/bean/DemoBean5.java new file mode 100644 index 00000000..bc7aeaff --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/java/com/yomahub/liteflow/test/script/groovy/scriptbean/bean/DemoBean5.java @@ -0,0 +1,26 @@ +package com.yomahub.liteflow.test.script.groovy.scriptbean.bean; + +import com.yomahub.liteflow.script.annotation.ScriptBean; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +@ScriptBean("demo5") +public class DemoBean5 { + + private final DemoBean2 demoBean2; + + public DemoBean5(DemoBean2 demoBean2) { + this.demoBean2 = demoBean2; + } + + public String getDemoStr1() { + return "hello"; + } + + public String getDemoStr2(String name) { + return demoBean2.getDemoStr2(name); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/resources/scriptbean/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/resources/scriptbean/flow.xml index ac6c1474..f90327b4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/resources/scriptbean/flow.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-script-groovy-springboot/src/test/resources/scriptbean/flow.xml @@ -50,6 +50,13 @@ abcCx.put("demo", str) ]]> + + + + @@ -79,4 +86,8 @@ THEN(a,b,c,s5); + + + THEN(a,b,c,f); + \ No newline at end of file From fd0769dd9a9e79346257650514d1a96872c4153e Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Mon, 17 Jul 2023 08:43:56 +0800 Subject: [PATCH 17/30] =?UTF-8?q?enhancement=20#I7KZCZ=20=E5=9C=A8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E5=B7=B2=E7=BB=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/spring/LiteFlowSpringUtil.java | 275 ------------------ 1 file changed, 275 deletions(-) delete mode 100644 liteflow-spring/src/main/java/com/yomahub/liteflow/spring/LiteFlowSpringUtil.java diff --git a/liteflow-spring/src/main/java/com/yomahub/liteflow/spring/LiteFlowSpringUtil.java b/liteflow-spring/src/main/java/com/yomahub/liteflow/spring/LiteFlowSpringUtil.java deleted file mode 100644 index fe019718..00000000 --- a/liteflow-spring/src/main/java/com/yomahub/liteflow/spring/LiteFlowSpringUtil.java +++ /dev/null @@ -1,275 +0,0 @@ -package com.yomahub.liteflow.spring; - -import cn.hutool.core.exceptions.UtilException; -import cn.hutool.core.lang.TypeReference; -import cn.hutool.core.util.ArrayUtil; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.support.DefaultSingletonBeanRegistry; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.core.ResolvableType; - -import java.lang.reflect.ParameterizedType; -import java.util.Arrays; -import java.util.Map; - - -public class LiteFlowSpringUtil implements BeanFactoryPostProcessor, ApplicationContextAware { - - /** - * "@PostConstruct"注解标记的类中,由于ApplicationContext还未加载,导致空指针
- * 因此实现BeanFactoryPostProcessor注入ConfigurableListableBeanFactory实现bean的操作 - */ - private static ConfigurableListableBeanFactory beanFactory; - /** - * Spring应用上下文环境 - */ - private static ApplicationContext applicationContext; - - @SuppressWarnings("NullableProblems") - @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { - LiteFlowSpringUtil.beanFactory = beanFactory; - } - - @SuppressWarnings("NullableProblems") - @Override - public void setApplicationContext(ApplicationContext applicationContext) { - LiteFlowSpringUtil.applicationContext = applicationContext; - } - - /** - * 获取{@link ApplicationContext} - * - * @return {@link ApplicationContext} - */ - public static ApplicationContext getApplicationContext() { - return applicationContext; - } - - /** - * 获取{@link ListableBeanFactory},可能为{@link ConfigurableListableBeanFactory} 或 {@link ApplicationContextAware} - * - * @return {@link ListableBeanFactory} - * @since 5.7.0 - */ - public static ListableBeanFactory getBeanFactory() { - final ListableBeanFactory factory = null == beanFactory ? applicationContext : beanFactory; - if (null == factory) { - throw new UtilException("No ConfigurableListableBeanFactory or ApplicationContext injected, maybe not in the Spring environment?"); - } - return factory; - } - - /** - * 获取{@link ConfigurableListableBeanFactory} - * - * @return {@link ConfigurableListableBeanFactory} - * @throws UtilException 当上下文非ConfigurableListableBeanFactory抛出异常 - * @since 5.7.7 - */ - public static ConfigurableListableBeanFactory getConfigurableBeanFactory() throws UtilException { - final ConfigurableListableBeanFactory factory; - if (null != beanFactory) { - factory = beanFactory; - } else if (applicationContext instanceof ConfigurableApplicationContext) { - factory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory(); - } else { - throw new UtilException("No ConfigurableListableBeanFactory from context!"); - } - return factory; - } - - //通过name获取 Bean. - - /** - * 通过name获取 Bean - * - * @param Bean类型 - * @param name Bean名称 - * @return Bean - */ - @SuppressWarnings("unchecked") - public static T getBean(String name) { - return (T) getBeanFactory().getBean(name); - } - - /** - * 通过class获取Bean - * - * @param Bean类型 - * @param clazz Bean类 - * @return Bean对象 - */ - public static T getBean(Class clazz) { - return getBeanFactory().getBean(clazz); - } - - /** - * 通过name,以及Clazz返回指定的Bean - * - * @param bean类型 - * @param name Bean名称 - * @param clazz bean类型 - * @return Bean对象 - */ - public static T getBean(String name, Class clazz) { - return getBeanFactory().getBean(name, clazz); - } - - /** - * 通过类型参考返回带泛型参数的Bean - * - * @param reference 类型参考,用于持有转换后的泛型类型 - * @param Bean类型 - * @return 带泛型参数的Bean - * @since 5.4.0 - */ - @SuppressWarnings("unchecked") - public static T getBean(TypeReference reference) { - final ParameterizedType parameterizedType = (ParameterizedType) reference.getType(); - final Class rawType = (Class) parameterizedType.getRawType(); - final Class[] genericTypes = Arrays.stream(parameterizedType.getActualTypeArguments()).map(type -> (Class) type).toArray(Class[]::new); - final String[] beanNames = getBeanFactory().getBeanNamesForType(ResolvableType.forClassWithGenerics(rawType, genericTypes)); - return getBean(beanNames[0], rawType); - } - - /** - * 获取指定类型对应的所有Bean,包括子类 - * - * @param Bean类型 - * @param type 类、接口,null表示获取所有bean - * @return 类型对应的bean,key是bean注册的name,value是Bean - * @since 5.3.3 - */ - public static Map getBeansOfType(Class type) { - return getBeanFactory().getBeansOfType(type); - } - - /** - * 获取指定类型对应的Bean名称,包括子类 - * - * @param type 类、接口,null表示获取所有bean名称 - * @return bean名称 - * @since 5.3.3 - */ - public static String[] getBeanNamesForType(Class type) { - return getBeanFactory().getBeanNamesForType(type); - } - - /** - * 获取配置文件配置项的值 - * - * @param key 配置项key - * @return 属性值 - * @since 5.3.3 - */ - public static String getProperty(String key) { - if (null == applicationContext) { - return null; - } - return applicationContext.getEnvironment().getProperty(key); - } - - /** - * 获取应用程序名称 - * - * @return 应用程序名称 - * @since 5.7.12 - */ - public static String getApplicationName() { - return getProperty("spring.application.name"); - } - - /** - * 获取当前的环境配置,无配置返回null - * - * @return 当前的环境配置 - * @since 5.3.3 - */ - public static String[] getActiveProfiles() { - if (null == applicationContext) { - return null; - } - return applicationContext.getEnvironment().getActiveProfiles(); - } - - /** - * 获取当前的环境配置,当有多个环境配置时,只获取第一个 - * - * @return 当前的环境配置 - * @since 5.3.3 - */ - public static String getActiveProfile() { - final String[] activeProfiles = getActiveProfiles(); - return ArrayUtil.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; - } - - /** - * 动态向Spring注册Bean - *

- * 由{@link org.springframework.beans.factory.BeanFactory} 实现,通过工具开放API - *

- * 更新: shadow 2021-07-29 17:20:44 增加自动注入,修复注册bean无法反向注入的问题 - * - * @param Bean类型 - * @param beanName 名称 - * @param bean bean - * @author shadow - * @since 5.4.2 - */ - public static void registerBean(String beanName, T bean) { - final ConfigurableListableBeanFactory factory = getConfigurableBeanFactory(); - factory.autowireBean(bean); - factory.registerSingleton(beanName, bean); - } - - /** - * 注销bean - *

- * 将Spring中的bean注销,请谨慎使用 - * - * @param beanName bean名称 - * @author shadow - * @since 5.7.7 - */ - public static void unregisterBean(String beanName) { - final ConfigurableListableBeanFactory factory = getConfigurableBeanFactory(); - if (factory instanceof DefaultSingletonBeanRegistry) { - DefaultSingletonBeanRegistry registry = (DefaultSingletonBeanRegistry) factory; - registry.destroySingleton(beanName); - } else { - throw new UtilException("Can not unregister bean, the factory is not a DefaultSingletonBeanRegistry!"); - } - } - - /** - * 发布事件 - * - * @param event 待发布的事件,事件必须是{@link ApplicationEvent}的子类 - * @since 5.7.12 - */ - public static void publishEvent(ApplicationEvent event) { - if (null != applicationContext) { - applicationContext.publishEvent(event); - } - } - - /** - * 发布事件 - * Spring 4.2+ 版本事件可以不再是{@link ApplicationEvent}的子类 - * - * @param event 待发布的事件 - * @since 5.7.21 - */ - public static void publishEvent(Object event) { - if (null != applicationContext) { - applicationContext.publishEvent(event); - } - } -} From 8c5b103752e65774efe653b6b33f52a7731a8c52 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Tue, 18 Jul 2023 22:40:29 +0800 Subject: [PATCH 18/30] =?UTF-8?q?enhancement=20#I7KZCZ=20=E5=9C=A8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E5=B7=B2=E7=BB=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../def/SQLWithXmlELMultiLanguageSpringbootTest.java | 2 +- .../test/def/SQLWithXmlELSpringbootTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java index c573fd24..ee72f5f9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java @@ -15,7 +15,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @ExtendWith(SpringExtension.class) -@TestPropertySource(value = "classpath:/application-xml.properties") +@TestPropertySource(value = "classpath:/application-data-source-xml.properties") @SpringBootTest(classes = SQLWithXmlELMultiLanguageSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({"com.yomahub.liteflow.test.sql.cmp"}) diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java index 87edf48c..8e86d512 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java @@ -18,8 +18,8 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; +import javax.sql.DataSource; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; @@ -28,7 +28,7 @@ import java.sql.Statement; * @since 2.9.0 */ @ExtendWith(SpringExtension.class) -@TestPropertySource(value = "classpath:/application-xml.properties") +@TestPropertySource(value = "classpath:/application-data-source-xml.properties") @SpringBootTest(classes = SQLWithXmlELSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({"com.yomahub.liteflow.test.sql.cmp"}) @@ -36,6 +36,8 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { @Resource private FlowExecutor flowExecutor; + @Resource + private DataSource dataSource; @Test public void testSQLWithXml() { @@ -71,8 +73,7 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class); Connection connection; try { - connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), - sqlParserVO.getPassword()); + connection = dataSource.getConnection(); Statement statement = connection.createStatement(); statement.executeUpdate("UPDATE EL_TABLE SET EL_DATA='THEN(a, c, b);' WHERE chain_name='chain1'"); } catch (SQLException e) { @@ -88,8 +89,7 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class); Connection connection; try { - connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), - sqlParserVO.getPassword()); + connection = dataSource.getConnection(); Statement statement = connection.createStatement(); statement.executeUpdate( "UPDATE SCRIPT_NODE_TABLE SET SCRIPT_NODE_DATA='return false;' WHERE SCRIPT_NODE_ID='x0'"); From ae21f6a5dc594afeab857a79c95f1998739a9b5f Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Tue, 18 Jul 2023 22:41:37 +0800 Subject: [PATCH 19/30] =?UTF-8?q?enhancement=20#I7KZCZ=20=E5=9C=A8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E5=B7=B2=E7=BB=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/test/def/SQLWithXmlELSpringbootTest.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java index 8e86d512..9d928723 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java @@ -3,11 +3,7 @@ package com.yomahub.liteflow.test.def; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.parser.sql.exception.ELSQLException; -import com.yomahub.liteflow.parser.sql.vo.SQLParserVO; -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.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -69,8 +65,6 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { * 修改数据库数据 */ private void changeData() { - LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); - SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class); Connection connection; try { connection = dataSource.getConnection(); @@ -85,8 +79,6 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { * 修改数据库数据 */ private void changeScriptData() { - LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); - SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class); Connection connection; try { connection = dataSource.getConnection(); From d9ebc78754dc0c94c37bbb3c1f6bd4049a9ea29d Mon Sep 17 00:00:00 2001 From: luoyi <972849752@qq.com> Date: Wed, 19 Jul 2023 11:19:08 +0800 Subject: [PATCH 20/30] =?UTF-8?q?bug=20#I7KY2N=20=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E8=BF=90=E7=AE=97=E5=A2=9E=E5=8A=A0=E7=9F=AD=E8=B7=AF=E6=95=88?= =?UTF-8?q?=E6=9E=9C=EF=BC=8C=E9=81=BF=E5=85=8D=E5=A4=9A=E4=BD=99=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../element/condition/AndOrCondition.java | 39 ++++++++++++------- .../BooleanOptELSpringbootTest.java | 11 +++++- .../src/test/resources/booleanOpt/flow.xml | 5 +++ 3 files changed, 40 insertions(+), 15 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 3c70b6b8..129a93da 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,7 +1,6 @@ package com.yomahub.liteflow.flow.element.condition; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.enums.ConditionTypeEnum; import com.yomahub.liteflow.exception.AndOrConditionException; @@ -11,7 +10,9 @@ 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; +import java.util.function.Predicate; public class AndOrCondition extends Condition { @@ -23,21 +24,10 @@ public class AndOrCondition extends Condition { public void executeCondition(Integer slotIndex) throws Exception { List itemList = this.getItem(); - if (CollUtil.isEmpty(itemList)){ throw new AndOrConditionException("boolean item list is null"); } - boolean[] booleanArray = new boolean[itemList.size()]; - - for (int i = 0; i < itemList.size(); i++) { - Executable item = itemList.get(i); - 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(); Slot slot = DataBus.getSlot(slotIndex); @@ -45,16 +35,37 @@ public class AndOrCondition extends Condition { String resultKey = StrUtil.format("{}_{}",this.getClass().getName(),this.hashCode()); switch (booleanConditionType) { case AND: - slot.setAndOrResult(resultKey, BooleanUtil.and(booleanArray)); + slot.setAndOrResult(resultKey, itemList.stream().allMatch(new AndOrConditionPredicate(slotIndex))); break; case OR: - slot.setAndOrResult(resultKey, BooleanUtil.or(booleanArray)); + slot.setAndOrResult(resultKey, itemList.stream().anyMatch(new AndOrConditionPredicate(slotIndex))); break; default: throw new AndOrConditionException("condition type must be 'AND' or 'OR'"); } } + private class AndOrConditionPredicate implements Predicate { + + private final Integer slotIndex; + + public AndOrConditionPredicate(Integer slotIndex) { + this.slotIndex = slotIndex; + } + + @Override + public boolean test(Executable condition) { + try { + condition.setCurrChainId(getCurrChainId()); + condition.execute(slotIndex); + return condition.getItemResultMetaValue(slotIndex); + } catch (Exception e) { + throw new AndOrConditionException(e.getMessage()); + } + } + + } + @Override @SuppressWarnings("unchecked") 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 0e7eb64c..8d354796 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 @@ -39,7 +39,7 @@ public class BooleanOptELSpringbootTest extends BaseTest { public void testBooleanOpt2() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assertions.assertTrue(response.isSuccess()); - Assertions.assertEquals("x1==>x2==>x3==>a", response.getExecuteStepStr()); + Assertions.assertEquals("x1==>a", response.getExecuteStepStr()); } // IF情况下AND+NOT @@ -64,4 +64,13 @@ public class BooleanOptELSpringbootTest extends BaseTest { Assertions.assertTrue(response.isSuccess()); Assertions.assertEquals("w1==>w2==>a==>bk==>w1==>w2==>a==>bk==>w1==>w2==>a==>bk==>w1==>w2==>a==>bk", response.getExecuteStepStr()); } + + // AND + NOT 实现短路效果 + @Test + public void testBooleanOpt6() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x1==>b", response.getExecuteStepStr()); + } + } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/booleanOpt/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/booleanOpt/flow.xml index 8898e245..b215310e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/booleanOpt/flow.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/booleanOpt/flow.xml @@ -25,4 +25,9 @@ WHILE(AND(w1, NOT(w2))).DO(a).BREAK(bk); + + + IF(AND(NOT(x1), x2, x3), a, b); + + \ No newline at end of file From c18f46ac48ebb2683cdb8ef4f810d8b085c65c39 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Wed, 19 Jul 2023 18:45:47 +0800 Subject: [PATCH 21/30] =?UTF-8?q?enhancement=20#I7J1VJ=20=E5=B8=8C?= =?UTF-8?q?=E6=9C=9B=E9=92=88=E5=AF=B9=E8=8A=82=E7=82=B9=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E8=80=97=E6=97=B6=E7=9A=84=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/yomahub/liteflow/core/NodeComponent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bf064af2..56d81ec4 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 @@ -126,7 +126,7 @@ public abstract class NodeComponent { stopWatch.stop(); final long timeSpent = stopWatch.getTotalTimeMillis(); - LOG.debug("component[{}] finished in {} milliseconds", this.getDisplayName(), timeSpent); + LOG.info("component[{}] finished in {} milliseconds", this.getDisplayName(), timeSpent); // 往CmpStep中放入时间消耗信息 cmpStep.setTimeSpent(timeSpent); From b6eda40533403f6d9ba9df394d90207210d11518 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Tue, 18 Jul 2023 22:40:29 +0800 Subject: [PATCH 22/30] =?UTF-8?q?enhancement=20#I7KZCZ=20=E5=9C=A8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E5=B7=B2=E7=BB=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.gitignore | 38 ++++++++ .../pom.xml | 86 +++++++++++++++++++ .../com/yomahub/liteflow/test/BaseTest.java | 27 ++++++ ...LWithXmlELMultiLanguageSpringbootTest.java | 34 ++++++++ .../test/sql/SQLWithXmlELSpringbootTest.java | 42 +++++++++ .../yomahub/liteflow/test/sql/cmp/ACmp.java | 22 +++++ .../yomahub/liteflow/test/sql/cmp/BCmp.java | 22 +++++ .../yomahub/liteflow/test/sql/cmp/CCmp.java | 22 +++++ ...ication-dynamic-data-source-xml.properties | 31 +++++++ .../src/test/resources/sql/data.sql | 14 +++ .../src/test/resources/sql/schema.sql | 20 +++++ .../src/test/resources/sql/second/data.sql | 27 ++++++ .../src/test/resources/sql/second/schema.sql | 20 +++++ ...LWithXmlELMultiLanguageSpringbootTest.java | 2 +- .../test/def/SQLWithXmlELSpringbootTest.java | 20 ++--- liteflow-testcase-el/pom.xml | 1 + 16 files changed, 413 insertions(+), 15 deletions(-) create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/.gitignore create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/pom.xml create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/BaseTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELMultiLanguageSpringbootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELSpringbootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/ACmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/BCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/CCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/application-dynamic-data-source-xml.properties create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/data.sql create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/schema.sql create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/second/data.sql create mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/second/schema.sql diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/.gitignore b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/.gitignore new file mode 100644 index 00000000..5ff6309b --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/pom.xml new file mode 100644 index 00000000..b7bd4c93 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/pom.xml @@ -0,0 +1,86 @@ + + + + liteflow-testcase-el + com.yomahub + ${revision} + ../pom.xml + + 4.0.0 + + liteflow-testcase-el-sql-springboot-dynamic + + + 2.1.214 + 2.6.8 + 4.1.2 + 2.7.13 + + + + + org.springframework.boot + spring-boot-starter + ${spring-boot.version} + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot.version} + + + com.yomahub + liteflow-spring-boot-starter + ${revision} + + + + com.yomahub + liteflow-rule-sql + ${revision} + test + + + + org.springframework.boot + spring-boot-starter-test + + + + org.springframework.boot + spring-boot-starter-data-jpa + ${jpa.version} + test + + + + com.h2database + h2 + ${h2.version} + test + + + + com.yomahub + liteflow-script-groovy + ${revision} + test + + + + com.yomahub + liteflow-script-graaljs + ${revision} + test + + + + + com.baomidou + dynamic-datasource-spring-boot-starter + ${dynamic-datasource.version} + + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/BaseTest.java new file mode 100644 index 00000000..eb728735 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -0,0 +1,27 @@ +package com.yomahub.liteflow.test; + +import com.yomahub.liteflow.core.FlowInitHook; +import com.yomahub.liteflow.flow.FlowBus; +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.jupiter.api.AfterAll; + +/** + * @author tangkc + * @since 2.8.6 + */ +public class BaseTest { + + @AfterAll + public static void cleanScanCache() { + ComponentScanner.cleanCache(); + FlowBus.cleanCache(); + ExecutorHelper.loadInstance().clearExecutorServiceMap(); + SpiFactoryCleaner.clean(); + LiteflowConfigGetter.clean(); + FlowInitHook.cleanHook(); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELMultiLanguageSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELMultiLanguageSpringbootTest.java new file mode 100644 index 00000000..427351b6 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELMultiLanguageSpringbootTest.java @@ -0,0 +1,34 @@ +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.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.junit.jupiter.SpringExtension; + +import javax.annotation.Resource; + +@ExtendWith(SpringExtension.class) +@TestPropertySource(value = "classpath:/application-dynamic-data-source-xml.properties") +@SpringBootTest(classes = SQLWithXmlELMultiLanguageSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.sql.cmp"}) +public class SQLWithXmlELMultiLanguageSpringbootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testMultiLanguage1() { + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + 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-dynamic/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELSpringbootTest.java new file mode 100644 index 00000000..d694f7bf --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/SQLWithXmlELSpringbootTest.java @@ -0,0 +1,42 @@ +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.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.junit.jupiter.SpringExtension; + +import javax.annotation.Resource; + +/** + * @author tangkc + * @since 2.9.0 + */ +@ExtendWith(SpringExtension.class) +@TestPropertySource(value = "classpath:/application-dynamic-data-source-xml.properties") +@SpringBootTest(classes = SQLWithXmlELSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.sql.cmp"}) +public class SQLWithXmlELSpringbootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + @Test + public void testSQLWithXml() { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr()); + } + + @Test + public void testSQLWithScriptXml() { + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime()); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/ACmp.java new file mode 100644 index 00000000..f263fa7d --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/ACmp.java @@ -0,0 +1,22 @@ +/** + *

Title: liteflow

+ *

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

+ * + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.sql.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/BCmp.java new file mode 100644 index 00000000..c2ffd816 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/BCmp.java @@ -0,0 +1,22 @@ +/** + *

Title: liteflow

+ *

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

+ * + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.sql.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/CCmp.java new file mode 100644 index 00000000..0d45928b --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/java/com/yomahub/liteflow/test/sql/cmp/CCmp.java @@ -0,0 +1,22 @@ +/** + *

Title: liteflow

+ *

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

+ * + * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.sql.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/application-dynamic-data-source-xml.properties b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/application-dynamic-data-source-xml.properties new file mode 100644 index 00000000..8645c0b2 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/application-dynamic-data-source-xml.properties @@ -0,0 +1,31 @@ +liteflow.rule-source-ext-data={\ + "applicationName":"demo",\ + "chainTableName":"EL_TABLE",\ + "chainApplicationNameField":"application_name",\ + "chainNameField":"chain_name",\ + "elDataField":"EL_DATA",\ + "scriptTableName":"script_node_table",\ + "scriptApplicationNameField":"application_name",\ + "scriptIdField":"script_node_id",\ + "scriptNameField":"script_node_name",\ + "scriptDataField":"script_node_data",\ + "scriptLanguageField":"script_language",\ + "scriptTypeField":"script_node_type"\ + } +spring.profiles.active=test +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.dynamic.primary=h2-first +spring.datasource.dynamic.strict=false +spring.datasource.dynamic.datasource.h2-first.url=jdbc:h2:mem:test_db1 +spring.datasource.dynamic.datasource.h2-first.username=root1 +spring.datasource.dynamic.datasource.h2-first.password=123456 +spring.datasource.dynamic.datasource.h2-first.init.schema=classpath:/sql/schema.sql +spring.datasource.dynamic.datasource.h2-first.init.data=classpath:/sql/data.sql +spring.datasource.dynamic.datasource.h2-second.url=jdbc:h2:mem:test_db2 +spring.datasource.dynamic.datasource.h2-second.username=root2 +spring.datasource.dynamic.datasource.h2-second.password=123456 +spring.datasource.dynamic.datasource.h2-second.init.schema=classpath:/sql/second/schema.sql +spring.datasource.dynamic.datasource.h2-second.init.data=classpath:/sql/second/data.sql + + + diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/data.sql b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/data.sql new file mode 100644 index 00000000..dda527ee --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/data.sql @@ -0,0 +1,14 @@ +DELETE FROM EL_TABLE; + +INSERT INTO EL_TABLE (APPLICATION_NAME,CHAIN_NAME,EL_DATA) values ('demo','chain1','THEN(a, b, c);'); +INSERT INTO EL_TABLE (APPLICATION_NAME,CHAIN_NAME,EL_DATA) values ('demo','chain2','THEN(a, b, c);'); +INSERT INTO EL_TABLE (APPLICATION_NAME,CHAIN_NAME,EL_DATA) values ('demo','chain3','IF(x0, THEN(a, b));'); +INSERT INTO EL_TABLE (APPLICATION_NAME,CHAIN_NAME,EL_DATA) values ('demo','','IF(x0, THEN(a, b));'); +INSERT INTO EL_TABLE (APPLICATION_NAME,CHAIN_NAME,EL_DATA) values ('demo','chain4','IF(x2, IF(x0, THEN(a, b)));'); + +DELETE FROM SCRIPT_NODE_TABLE; + +INSERT INTO SCRIPT_NODE_TABLE (APPLICATION_NAME,SCRIPT_NODE_ID,SCRIPT_NODE_NAME,SCRIPT_NODE_TYPE,SCRIPT_NODE_DATA,SCRIPT_LANGUAGE) values ('demo','x0','if 脚本','if_script','return true','groovy'); +INSERT INTO SCRIPT_NODE_TABLE (APPLICATION_NAME,SCRIPT_NODE_ID,SCRIPT_NODE_NAME,SCRIPT_NODE_TYPE,SCRIPT_NODE_DATA,SCRIPT_LANGUAGE) values ('demo','x1','if 脚本','if_script','return false','groovy'); + +INSERT INTO SCRIPT_NODE_TABLE (APPLICATION_NAME,SCRIPT_NODE_ID,SCRIPT_NODE_NAME,SCRIPT_NODE_TYPE,SCRIPT_NODE_DATA,SCRIPT_LANGUAGE) values ('demo','x2','python脚本','if_script','return true','js'); diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/schema.sql b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/schema.sql new file mode 100644 index 00000000..fa60f098 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/schema.sql @@ -0,0 +1,20 @@ +create table IF NOT EXISTS `EL_TABLE` +( + `id` bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + `application_name` varchar(32) NOT NULL, + `chain_name` varchar(32) NOT NULL, + `el_data` varchar(1024) NOT NULL, + PRIMARY KEY (`id`) +); + +create table IF NOT EXISTS `script_node_table` +( + `id` bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + `application_name` varchar(32) NOT NULL, + `script_node_id` varchar(32) NOT NULL, + `script_node_name` varchar(32) NOT NULL, + `script_node_type` varchar(32) NOT NULL, + `script_node_data` varchar(1024) NOT NULL, + `script_language` varchar(1024) NOT NULL, + PRIMARY KEY (`id`) +); \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/second/data.sql b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/second/data.sql new file mode 100644 index 00000000..35412b6a --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/second/data.sql @@ -0,0 +1,27 @@ +DELETE +FROM EL_TABLE; + +INSERT INTO EL_TABLE (APPLICATION_NAME, CHAIN_NAME, EL_DATA) +values ('demo', 'chain11', 'THEN(a, b, c);'); +INSERT INTO EL_TABLE (APPLICATION_NAME, CHAIN_NAME, EL_DATA) +values ('demo', 'chain21', 'THEN(a, b, c);'); +INSERT INTO EL_TABLE (APPLICATION_NAME, CHAIN_NAME, EL_DATA) +values ('demo', 'chain31', 'IF(x0, THEN(a, b));'); +INSERT INTO EL_TABLE (APPLICATION_NAME, CHAIN_NAME, EL_DATA) +values ('demo', '', 'IF(x0, THEN(a, b));'); +INSERT INTO EL_TABLE (APPLICATION_NAME, CHAIN_NAME, EL_DATA) +values ('demo', 'chain41', 'IF(x2, IF(x0, THEN(a, b)));'); + +DELETE +FROM SCRIPT_NODE_TABLE; + +INSERT INTO SCRIPT_NODE_TABLE (APPLICATION_NAME, SCRIPT_NODE_ID, SCRIPT_NODE_NAME, SCRIPT_NODE_TYPE, SCRIPT_NODE_DATA, + SCRIPT_LANGUAGE) +values ('demo', 'x01', 'if 脚本', 'if_script', 'return true', 'groovy'); +INSERT INTO SCRIPT_NODE_TABLE (APPLICATION_NAME, SCRIPT_NODE_ID, SCRIPT_NODE_NAME, SCRIPT_NODE_TYPE, SCRIPT_NODE_DATA, + SCRIPT_LANGUAGE) +values ('demo', 'x11', 'if 脚本', 'if_script', 'return false', 'groovy'); + +INSERT INTO SCRIPT_NODE_TABLE (APPLICATION_NAME, SCRIPT_NODE_ID, SCRIPT_NODE_NAME, SCRIPT_NODE_TYPE, SCRIPT_NODE_DATA, + SCRIPT_LANGUAGE) +values ('demo', 'x21', 'python脚本', 'if_script', 'return true', 'js'); diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/second/schema.sql b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/second/schema.sql new file mode 100644 index 00000000..fa60f098 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/src/test/resources/sql/second/schema.sql @@ -0,0 +1,20 @@ +create table IF NOT EXISTS `EL_TABLE` +( + `id` bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + `application_name` varchar(32) NOT NULL, + `chain_name` varchar(32) NOT NULL, + `el_data` varchar(1024) NOT NULL, + PRIMARY KEY (`id`) +); + +create table IF NOT EXISTS `script_node_table` +( + `id` bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + `application_name` varchar(32) NOT NULL, + `script_node_id` varchar(32) NOT NULL, + `script_node_name` varchar(32) NOT NULL, + `script_node_type` varchar(32) NOT NULL, + `script_node_data` varchar(1024) NOT NULL, + `script_language` varchar(1024) NOT NULL, + PRIMARY KEY (`id`) +); \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java index c573fd24..ee72f5f9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELMultiLanguageSpringbootTest.java @@ -15,7 +15,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; @ExtendWith(SpringExtension.class) -@TestPropertySource(value = "classpath:/application-xml.properties") +@TestPropertySource(value = "classpath:/application-data-source-xml.properties") @SpringBootTest(classes = SQLWithXmlELMultiLanguageSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({"com.yomahub.liteflow.test.sql.cmp"}) diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java index 87edf48c..9d928723 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot/src/test/java/com/yomahub/liteflow/test/def/SQLWithXmlELSpringbootTest.java @@ -3,11 +3,7 @@ package com.yomahub.liteflow.test.def; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.parser.sql.exception.ELSQLException; -import com.yomahub.liteflow.parser.sql.vo.SQLParserVO; -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.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -18,8 +14,8 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; +import javax.sql.DataSource; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; @@ -28,7 +24,7 @@ import java.sql.Statement; * @since 2.9.0 */ @ExtendWith(SpringExtension.class) -@TestPropertySource(value = "classpath:/application-xml.properties") +@TestPropertySource(value = "classpath:/application-data-source-xml.properties") @SpringBootTest(classes = SQLWithXmlELSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({"com.yomahub.liteflow.test.sql.cmp"}) @@ -36,6 +32,8 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { @Resource private FlowExecutor flowExecutor; + @Resource + private DataSource dataSource; @Test public void testSQLWithXml() { @@ -67,12 +65,9 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { * 修改数据库数据 */ private void changeData() { - LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); - SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class); Connection connection; try { - connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), - sqlParserVO.getPassword()); + connection = dataSource.getConnection(); Statement statement = connection.createStatement(); statement.executeUpdate("UPDATE EL_TABLE SET EL_DATA='THEN(a, c, b);' WHERE chain_name='chain1'"); } catch (SQLException e) { @@ -84,12 +79,9 @@ public class SQLWithXmlELSpringbootTest extends BaseTest { * 修改数据库数据 */ private void changeScriptData() { - LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); - SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class); Connection connection; try { - connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), - sqlParserVO.getPassword()); + connection = dataSource.getConnection(); Statement statement = connection.createStatement(); statement.executeUpdate( "UPDATE SCRIPT_NODE_TABLE SET SCRIPT_NODE_DATA='return false;' WHERE SCRIPT_NODE_ID='x0'"); diff --git a/liteflow-testcase-el/pom.xml b/liteflow-testcase-el/pom.xml index 2d53f349..8f23e9e9 100644 --- a/liteflow-testcase-el/pom.xml +++ b/liteflow-testcase-el/pom.xml @@ -34,6 +34,7 @@ liteflow-testcase-el-script-lua-springboot liteflow-testcase-el-script-multi-language-springboot liteflow-testcase-el-script-aviator-springboot + liteflow-testcase-el-sql-springboot-dynamic From 288899d3add137ce2366a22369ead68abb032c7e Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Fri, 21 Jul 2023 00:29:12 +0800 Subject: [PATCH 23/30] =?UTF-8?q?enhancement=20#I7KOPV=20=E7=B1=BB?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E5=A3=B0=E6=98=8E=E7=BB=84=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=BB=BA=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/annotation/LiteflowMethod.java | 8 ++++++- .../liteflow/core/proxy/ComponentProxy.java | 21 ++++++++++++++++++- .../com/yomahub/liteflow/flow/FlowBus.java | 2 +- .../spi/LiteflowComponentSupport.java | 2 +- .../local/LocalLiteflowComponentSupport.java | 2 +- .../solon/SolonLiteflowComponentSupport.java | 2 +- .../SpringLiteflowComponentSupport.java | 2 +- .../liteflow/test/base/cmp/CmpConfig.java | 2 +- 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/annotation/LiteflowMethod.java b/liteflow-core/src/main/java/com/yomahub/liteflow/annotation/LiteflowMethod.java index 589cf4ee..7eba135e 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/annotation/LiteflowMethod.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/annotation/LiteflowMethod.java @@ -18,10 +18,16 @@ public @interface LiteflowMethod { /** * 节点ID,用于区分节点 默认为空 则按照Spring模式下BeanName为准。 - * @return + * @return nodeId */ String nodeId() default ""; + /** + * 节点Name + * @return nodeName + */ + String nodeName() default ""; + /** * CMP类型定义 * @return AnnotationNodeTypeEnum diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java index 4ca355f8..5d631594 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/proxy/ComponentProxy.java @@ -13,6 +13,7 @@ import com.yomahub.liteflow.exception.LiteFlowException; import com.yomahub.liteflow.exception.ProxyException; import com.yomahub.liteflow.log.LFLog; import com.yomahub.liteflow.log.LFLoggerManager; +import com.yomahub.liteflow.spi.holder.LiteflowComponentSupportHolder; import com.yomahub.liteflow.util.LiteFlowProxyUtil; import com.yomahub.liteflow.util.SerialsUtil; import net.bytebuddy.ByteBuddy; @@ -28,6 +29,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Predicate; import java.util.stream.Collectors; /** @@ -94,8 +96,23 @@ public class ComponentProxy { boolean legal = classes.size() == 1; if (!legal) { throw new LiteFlowException("The cmpClass of the same nodeId must be the same,you declared nodeId:" - + activeNodeId + ",cmpClass:" + classes); + + activeNodeId + ",cmpClass:" + clazz); } + + + String activeNodeName; + if (isMethodCreate){ + // 获取process上的LiteflowMethod + LiteflowMethod mainliteflowMethod = methodList.stream().filter(liteflowMethod -> liteflowMethod.value().isMainMethod()).findFirst().orElse(null); + if (mainliteflowMethod == null){ + String errMsg = StrUtil.format("you have not defined @LiteFlowMethod on the processXXX method in class {}", clazz.getName()); + throw new LiteFlowException(errMsg); + } + activeNodeName = mainliteflowMethod.nodeName(); + }else{ + activeNodeName = LiteflowComponentSupportHolder.loadLiteflowComponentSupport().getCmpName(bean); + } + // 当前节点实际LiteflowRetry注解 AtomicReference liteflowRetryAtomicReference = new AtomicReference<>(null); // 相同nodeId只能有一个LiteflowRetry定义方法,且必须再Process方法上 @@ -151,6 +168,8 @@ public class ComponentProxy { NodeComponent nodeComponent = (NodeComponent) instance; // 重设nodeId nodeComponent.setNodeId(activeNodeId); + // 重设nodeName + nodeComponent.setName(activeNodeName); return nodeComponent; } catch (Exception e) { diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java index 2a82c62a..1f8d1954 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java @@ -93,7 +93,7 @@ public class FlowBus { } nodeMap.put(nodeId, - new Node(ComponentInitializer.loadInstance().initComponent(nodeComponent, type, null, nodeId))); + new Node(ComponentInitializer.loadInstance().initComponent(nodeComponent, type, nodeComponent.getName(), nodeId))); } /** diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/LiteflowComponentSupport.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/LiteflowComponentSupport.java index da659f12..710eb392 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/LiteflowComponentSupport.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/LiteflowComponentSupport.java @@ -10,6 +10,6 @@ import com.yomahub.liteflow.core.NodeComponent; */ public interface LiteflowComponentSupport extends SpiPriority { - String getCmpName(NodeComponent nodeComponent); + String getCmpName(Object nodeComponent); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalLiteflowComponentSupport.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalLiteflowComponentSupport.java index 74426e82..4303b47b 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalLiteflowComponentSupport.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalLiteflowComponentSupport.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.spi.LiteflowComponentSupport; public class LocalLiteflowComponentSupport implements LiteflowComponentSupport { @Override - public String getCmpName(NodeComponent nodeComponent) { + public String getCmpName(Object nodeComponent) { return null; } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonLiteflowComponentSupport.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonLiteflowComponentSupport.java index 06b9de06..c25aa522 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonLiteflowComponentSupport.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonLiteflowComponentSupport.java @@ -14,7 +14,7 @@ import com.yomahub.liteflow.spi.LiteflowComponentSupport; public class SolonLiteflowComponentSupport implements LiteflowComponentSupport { @Override - public String getCmpName(NodeComponent nodeComponent) { + public String getCmpName(Object nodeComponent) { // 判断NodeComponent是否是标识了@LiteflowComponent的标注 // 如果标注了,那么要从中取到name字段 LiteflowComponent liteflowComponent = nodeComponent.getClass().getAnnotation(LiteflowComponent.class); diff --git a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringLiteflowComponentSupport.java b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringLiteflowComponentSupport.java index a88fdb9e..754ffcaa 100644 --- a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringLiteflowComponentSupport.java +++ b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringLiteflowComponentSupport.java @@ -15,7 +15,7 @@ import com.yomahub.liteflow.spi.LiteflowComponentSupport; public class SpringLiteflowComponentSupport implements LiteflowComponentSupport { @Override - public String getCmpName(NodeComponent nodeComponent) { + public String getCmpName(Object nodeComponent) { // 判断NodeComponent是否是标识了@LiteflowComponent的标注 // 如果标注了,那么要从中取到name字段 LiteflowComponent liteflowComponent = nodeComponent.getClass().getAnnotation(LiteflowComponent.class); diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/base/cmp/CmpConfig.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/base/cmp/CmpConfig.java index 5689c278..d5dab578 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/base/cmp/CmpConfig.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/base/cmp/CmpConfig.java @@ -10,7 +10,7 @@ import javax.annotation.Resource; @LiteflowComponent public class CmpConfig { - @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a") + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a", nodeName = "A组件") public void processA(NodeComponent bindCmp) { System.out.println("ACmp executed!"); } From ce810c4fee081dbb812d0073863cb80f4f53fa32 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Fri, 21 Jul 2023 13:56:00 +0800 Subject: [PATCH 24/30] =?UTF-8?q?=E4=BC=98=E5=8C=96monitorFile=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MonitorFileELDeclMultiSpringbootTest.java | 10 +++++++- .../MonitorFileELDeclSpringbootTest.java | 10 +++++++- .../monitorFile/LiteflowMonitorFileTest.java | 7 ++++++ .../MonitorFileSpringbootTest.java | 10 +++++++- .../MonitorFileELSpringbootTest.java | 23 +++++++++++-------- .../test/resources/monitorFile/flow.el.xml | 1 - 6 files changed, 48 insertions(+), 13 deletions(-) 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 8a88f4b1..9c4cf23f 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,6 +6,7 @@ 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.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -32,13 +33,20 @@ public class MonitorFileELDeclMultiSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception { String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); String content = FileUtil.readUtf8String(absolutePath); String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(3000); + Thread.sleep(1000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } + @AfterEach + public void afterEach(){ + String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + } + } 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 b264ef59..98fc5169 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,6 +6,7 @@ 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.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -32,12 +33,19 @@ public class MonitorFileELDeclSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception { String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); String content = FileUtil.readUtf8String(absolutePath); String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(3000); + Thread.sleep(1000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } + @AfterEach + public void afterEach(){ + String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + } + } 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 07e4a7f1..70c581ec 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,6 +8,7 @@ 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.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -37,4 +38,10 @@ public class LiteflowMonitorFileTest extends BaseTest { Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } + @AfterEach + public void afterEach(){ + String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + } + } 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 8cb41564..047786ac 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,6 +6,7 @@ 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.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -25,12 +26,19 @@ public class MonitorFileSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception { String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); String content = FileUtil.readUtf8String(absolutePath); String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(3000); + Thread.sleep(1000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } + @AfterEach + public void afterEach(){ + String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + } + } 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 9d7983d9..52369a82 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,10 +6,7 @@ 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.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -31,10 +28,11 @@ public class MonitorFileELSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception { String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); String content = FileUtil.readUtf8String(absolutePath); String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(3000); + Thread.sleep(1000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } @@ -46,21 +44,28 @@ public class MonitorFileELSpringbootTest extends BaseTest { @Test public void testMonitorError() throws Exception { String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); String content = FileUtil.readUtf8String(absolutePath); // 错误规则配置 - String newContent = content.replace("THEN(a, c, b);", "THEN(c, b, ;"); + String newContent = content.replace("THEN(a, b, c);", "THEN(c, b, ;"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); Thread.sleep(3000); LiteflowResponse reloadFailedResponse = flowExecutor.execute2Resp("chain1", "arg"); - Assertions.assertEquals("a==>c==>b", reloadFailedResponse.getExecuteStepStr()); + Assertions.assertEquals("a==>b==>c", reloadFailedResponse.getExecuteStepStr()); // 再次变更正确 - newContent = content.replace("THEN(a, c, b);", "THEN(c, b, a);"); + newContent = content.replace("THEN(a, b, c);", "THEN(c, b, a);"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(3000); + Thread.sleep(1000); LiteflowResponse reloadSuccessResponse = flowExecutor.execute2Resp("chain1", "arg"); Assertions.assertEquals("c==>b==>a", reloadSuccessResponse.getExecuteStepStr()); } + @AfterEach + public void afterEach(){ + String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); + FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); + } + } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/monitorFile/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/monitorFile/flow.el.xml index 98c3cbae..049210cf 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/monitorFile/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/monitorFile/flow.el.xml @@ -3,5 +3,4 @@ THEN(a, b, c); - \ No newline at end of file From 76563cf59680d9a665e7e1b4d7fa0b5d177bf358 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Fri, 21 Jul 2023 14:00:05 +0800 Subject: [PATCH 25/30] =?UTF-8?q?=E4=BC=98=E5=8C=96monitorFile=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/monitorFile/MonitorFileELDeclMultiSpringbootTest.java | 2 +- .../test/monitorFile/MonitorFileELDeclSpringbootTest.java | 2 +- .../liteflow/test/monitorFile/MonitorFileELSpringbootTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 9c4cf23f..bf3639f2 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 @@ -37,7 +37,7 @@ public class MonitorFileELDeclMultiSpringbootTest extends BaseTest { String content = FileUtil.readUtf8String(absolutePath); String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(1000); + Thread.sleep(3000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); 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/monitorFile/MonitorFileELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclSpringbootTest.java index 98fc5169..21b325a8 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 @@ -37,7 +37,7 @@ public class MonitorFileELDeclSpringbootTest extends BaseTest { String content = FileUtil.readUtf8String(absolutePath); String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(1000); + Thread.sleep(3000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } 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 52369a82..17308d7e 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 @@ -57,7 +57,7 @@ public class MonitorFileELSpringbootTest extends BaseTest { // 再次变更正确 newContent = content.replace("THEN(a, b, c);", "THEN(c, b, a);"); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(1000); + Thread.sleep(3000); LiteflowResponse reloadSuccessResponse = flowExecutor.execute2Resp("chain1", "arg"); Assertions.assertEquals("c==>b==>a", reloadSuccessResponse.getExecuteStepStr()); } From e5581f84f9f6cc2456059bc41e03a37af0f47a67 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Fri, 21 Jul 2023 14:43:42 +0800 Subject: [PATCH 26/30] =?UTF-8?q?=E4=BC=98=E5=8C=96monitorFile=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MonitorFileELDeclMultiSpringbootTest.java | 52 ------------------- .../test/monitorFile/cmp/CmpConfig.java | 28 ---------- .../monitorFile/application.properties | 2 - .../test/resources/monitorFile/flow.el.xml | 7 --- .../MonitorFileELDeclSpringbootTest.java | 51 ------------------ .../liteflow/test/monitorFile/cmp/ACmp.java | 25 --------- .../liteflow/test/monitorFile/cmp/BCmp.java | 25 --------- .../liteflow/test/monitorFile/cmp/CCmp.java | 25 --------- .../monitorFile/application.properties | 2 - .../test/resources/monitorFile/flow.el.xml | 7 --- .../monitorFile/LiteflowMonitorFileTest.java | 47 ----------------- .../liteflow/test/monitorFile/cmp/ACmp.java | 19 ------- .../liteflow/test/monitorFile/cmp/BCmp.java | 19 ------- .../liteflow/test/monitorFile/cmp/CCmp.java | 19 ------- .../MonitorFileSpringbootTest.java | 44 ---------------- .../liteflow/test/monitorFile/cmp/ACmp.java | 23 -------- .../liteflow/test/monitorFile/cmp/BCmp.java | 23 -------- .../liteflow/test/monitorFile/cmp/CCmp.java | 23 -------- .../monitorFile/application.properties | 2 - .../src/test/resources/monitorFile/flow.xml | 7 --- .../MonitorFileELSpringbootTest.java | 4 +- 21 files changed, 2 insertions(+), 452 deletions(-) delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclMultiSpringbootTest.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CmpConfig.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/monitorFile/application.properties delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/monitorFile/flow.el.xml delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclSpringbootTest.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/monitorFile/application.properties delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/monitorFile/flow.el.xml delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/LiteflowMonitorFileTest.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileSpringbootTest.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/monitorFile/application.properties delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/monitorFile/flow.xml 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 deleted file mode 100644 index bf3639f2..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclMultiSpringbootTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.yomahub.liteflow.test.monitorFile; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.resource.ClassPathResource; -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.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.test.context.junit.jupiter.SpringExtension; -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.io.File; - -@ExtendWith(SpringExtension.class) -@TestPropertySource(value = "classpath:/monitorFile/application.properties") -@SpringBootTest(classes = MonitorFileELDeclMultiSpringbootTest.class) -@EnableAutoConfiguration -@ComponentScan({ "com.yomahub.liteflow.test.monitorFile.cmp" }) -public class MonitorFileELDeclMultiSpringbootTest extends BaseTest { - - @Resource - private FlowExecutor flowExecutor; - - @Test - public void testMonitor() throws Exception { - String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); - FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - String content = FileUtil.readUtf8String(absolutePath); - String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); - FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(3000); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); - - } - - @AfterEach - public void afterEach(){ - String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); - FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CmpConfig.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CmpConfig.java deleted file mode 100644 index 19873353..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CmpConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.annotation.LiteflowComponent; -import com.yomahub.liteflow.annotation.LiteflowMethod; -import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.enums.LiteFlowMethodEnum; - -import java.util.Random; - -@LiteflowComponent -public class CmpConfig { - - @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a") - public void processA(NodeComponent bindCmp) { - System.out.println("ACmp executed!"); - } - - @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "b") - public void processB(NodeComponent bindCmp) { - System.out.println("BCmp executed!"); - } - - @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "c") - public void process(NodeComponent bindCmp) { - System.out.println("BCmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/monitorFile/application.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/monitorFile/application.properties deleted file mode 100644 index 361f7e90..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/monitorFile/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -liteflow.rule-source=monitorFile/flow.el.xml -liteflow.enable-monitor-file=true \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/monitorFile/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/monitorFile/flow.el.xml deleted file mode 100644 index 98c3cbae..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/monitorFile/flow.el.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - THEN(a, b, c); - - - \ No newline at end of file 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 deleted file mode 100644 index 21b325a8..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileELDeclSpringbootTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.yomahub.liteflow.test.monitorFile; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.resource.ClassPathResource; -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.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.test.context.junit.jupiter.SpringExtension; -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.io.File; - -@ExtendWith(SpringExtension.class) -@TestPropertySource(value = "classpath:/monitorFile/application.properties") -@SpringBootTest(classes = MonitorFileELDeclSpringbootTest.class) -@EnableAutoConfiguration -@ComponentScan({ "com.yomahub.liteflow.test.monitorFile.cmp" }) -public class MonitorFileELDeclSpringbootTest extends BaseTest { - - @Resource - private FlowExecutor flowExecutor; - - @Test - public void testMonitor() throws Exception { - String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); - FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - String content = FileUtil.readUtf8String(absolutePath); - String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); - FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(3000); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); - } - - @AfterEach - public void afterEach(){ - String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); - FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java deleted file mode 100644 index 753f3d95..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.annotation.LiteflowMethod; -import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.enums.LiteFlowMethodEnum; -import org.springframework.stereotype.Component; - -import java.util.Random; - -@Component("a") -public class ACmp { - - @LiteflowMethod(LiteFlowMethodEnum.PROCESS) - public void process(NodeComponent bindCmp) { - System.out.println("ACmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java deleted file mode 100644 index 2cf61833..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.annotation.LiteflowMethod; -import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.enums.LiteFlowMethodEnum; -import org.springframework.stereotype.Component; - -import java.util.Random; - -@Component("b") -public class BCmp { - - @LiteflowMethod(LiteFlowMethodEnum.PROCESS) - public void process(NodeComponent bindCmp) { - System.out.println("BCmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java deleted file mode 100644 index 697d5dab..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.annotation.LiteflowMethod; -import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.enums.LiteFlowMethodEnum; -import org.springframework.stereotype.Component; - -import java.util.Random; - -@Component("c") -public class CCmp { - - @LiteflowMethod(LiteFlowMethodEnum.PROCESS) - public void process(NodeComponent bindCmp) { - System.out.println("CCmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/monitorFile/application.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/monitorFile/application.properties deleted file mode 100644 index 361f7e90..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/monitorFile/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -liteflow.rule-source=monitorFile/flow.el.xml -liteflow.enable-monitor-file=true \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/monitorFile/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/monitorFile/flow.el.xml deleted file mode 100644 index 98c3cbae..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/monitorFile/flow.el.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - THEN(a, b, c); - - - \ No newline at end of file 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 deleted file mode 100644 index 70c581ec..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/LiteflowMonitorFileTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.yomahub.liteflow.test.monitorFile; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.resource.ClassPathResource; -import cn.hutool.core.util.CharsetUtil; -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 com.yomahub.liteflow.test.BaseTest; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.io.File; - -public class LiteflowMonitorFileTest extends BaseTest { - - private static FlowExecutor flowExecutor; - - @BeforeAll - public static void init() { - LiteflowConfig config = new LiteflowConfig(); - config.setRuleSource("monitorFile/flow.el.xml"); - config.setEnableMonitorFile(true); - flowExecutor = FlowExecutorHolder.loadInstance(config); - } - - @Test - public void testMonitor() throws InterruptedException { - String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); - String content = FileUtil.readUtf8String(absolutePath); - String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); - FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(3000); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); - } - - @AfterEach - public void afterEach(){ - String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); - FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java deleted file mode 100644 index d99aa2b9..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.core.NodeComponent; - -public class ACmp extends NodeComponent { - - @Override - public void process() { - System.out.println("ACmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java deleted file mode 100644 index 8b108f06..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.core.NodeComponent; - -public class BCmp extends NodeComponent { - - @Override - public void process() { - System.out.println("BCmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java deleted file mode 100644 index 6323f231..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.core.NodeComponent; - -public class CCmp extends NodeComponent { - - @Override - public void process() { - System.out.println("CCmp executed!"); - } - -} 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 deleted file mode 100644 index 047786ac..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/MonitorFileSpringbootTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.yomahub.liteflow.test.monitorFile; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.resource.ClassPathResource; -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.jupiter.api.AfterEach; -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.SolonJUnit5Extension; -import org.noear.solon.test.annotation.TestPropertySource; - -import java.io.File; - -@ExtendWith(SolonJUnit5Extension.class) -@TestPropertySource("classpath:/monitorFile/application.properties") -public class MonitorFileSpringbootTest extends BaseTest { - - @Inject - private FlowExecutor flowExecutor; - - @Test - public void testMonitor() throws Exception { - String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.xml").getAbsolutePath(); - FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - String content = FileUtil.readUtf8String(absolutePath); - String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); - FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(1000); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); - } - - @AfterEach - public void afterEach(){ - String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); - FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java deleted file mode 100644 index 2bcc4b1b..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/ACmp.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.core.NodeComponent; -import org.noear.solon.annotation.Component; - -import java.util.Random; - -@Component("a") -public class ACmp extends NodeComponent { - - @Override - public void process() { - System.out.println("ACmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java deleted file mode 100644 index 54437c01..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/BCmp.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.core.NodeComponent; -import org.noear.solon.annotation.Component; - -import java.util.Random; - -@Component("b") -public class BCmp extends NodeComponent { - - @Override - public void process() { - System.out.println("BCmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java deleted file mode 100644 index 346fdfde..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/monitorFile/cmp/CCmp.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.monitorFile.cmp; - -import com.yomahub.liteflow.core.NodeComponent; -import org.noear.solon.annotation.Component; - -import java.util.Random; - -@Component("c") -public class CCmp extends NodeComponent { - - @Override - public void process() { - System.out.println("CCmp executed!"); - } - -} diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/monitorFile/application.properties b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/monitorFile/application.properties deleted file mode 100644 index c1953bc1..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/monitorFile/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -liteflow.rule-source=monitorFile/flow.xml -liteflow.enable-monitor-file=true \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/monitorFile/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/monitorFile/flow.xml deleted file mode 100644 index 98c3cbae..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/monitorFile/flow.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - THEN(a, b, c); - - - \ No newline at end of file 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 17308d7e..ecc1f9e9 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 @@ -31,8 +31,9 @@ public class MonitorFileELSpringbootTest extends BaseTest { FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); String content = FileUtil.readUtf8String(absolutePath); String newContent = content.replace("THEN(a, b, c);", "THEN(a, c, b);"); + Thread.sleep(1000); FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8); - Thread.sleep(1000); + Thread.sleep(3000); LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr()); } @@ -44,7 +45,6 @@ public class MonitorFileELSpringbootTest extends BaseTest { @Test public void testMonitorError() throws Exception { String absolutePath = new ClassPathResource("classpath:/monitorFile/flow.el.xml").getAbsolutePath(); - FileUtil.writeString("THEN(a, b, c);", new File(absolutePath), CharsetUtil.CHARSET_UTF_8); String content = FileUtil.readUtf8String(absolutePath); // 错误规则配置 From 84143041455cb4fca17b1702edfa01b996d37889 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Fri, 21 Jul 2023 15:38:51 +0800 Subject: [PATCH 27/30] =?UTF-8?q?enhancement=20#I7KHE5=20=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E6=B3=A8=E8=A7=A3=E5=A3=B0=E6=98=8E=E5=BC=8F=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=9C=BA=E6=99=AFLiteFlowMethodEnum=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?getDisplayName=E7=AD=89=E9=9C=80=E6=B1=82=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/enums/LiteFlowMethodEnum.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/enums/LiteFlowMethodEnum.java b/liteflow-core/src/main/java/com/yomahub/liteflow/enums/LiteFlowMethodEnum.java index dd49f0a8..62005e12 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/enums/LiteFlowMethodEnum.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/enums/LiteFlowMethodEnum.java @@ -2,14 +2,19 @@ package com.yomahub.liteflow.enums; public enum LiteFlowMethodEnum { - PROCESS("process", true), PROCESS_SWITCH("processSwitch", true), PROCESS_IF("processIf", true), - PROCESS_FOR("processFor", true), PROCESS_WHILE("processWhile", true), PROCESS_BREAK("processBreak", true), + PROCESS("process", true), + PROCESS_SWITCH("processSwitch", true), + PROCESS_IF("processIf", true), + PROCESS_FOR("processFor", true), + PROCESS_WHILE("processWhile", true), + PROCESS_BREAK("processBreak", true), PROCESS_ITERATOR("processIterator", true), IS_ACCESS("isAccess", false), - IS_END("isEnd", false), IS_CONTINUE_ON_ERROR("isContinueOnError", false), + IS_END("isEnd", false), + IS_CONTINUE_ON_ERROR("isContinueOnError", false), GET_NODE_EXECUTOR_CLASS("getNodeExecutorClass", false), @@ -19,7 +24,10 @@ public enum LiteFlowMethodEnum { BEFORE_PROCESS("beforeProcess", false), - AFTER_PROCESS("afterProcess", false); + AFTER_PROCESS("afterProcess", false), + + GET_DISPLAY_NAME("getDisplayName", false) + ; private String methodName; From be77a06b9b250190b713e2ed600ec7994e37e7f2 Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Fri, 21 Jul 2023 16:29:23 +0800 Subject: [PATCH 28/30] =?UTF-8?q?=E6=9B=B4=E6=94=B9readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.zh-CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index dd95c39b..5216956f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -11,7 +11,7 @@ LiteFlow是一个轻量且强大的国产规则引擎框架,可用于复杂的 LiteFlow于2020年正式开源,2021年获得开源中国年度最受欢迎开源软件殊荣。于2022年获得Gitee最有价值开源项目(GVP)荣誉。是一个正处在高速发展中的开源项目。 -LiteFlow是一个由社区驱动的项目,我们非常重视社区建设,拥有一个2500多人的使用者社区,在使用中碰到任何问题或者建议都可以在社区中反应。 +LiteFlow是一个由社区驱动的项目,我们非常重视社区建设,拥有一个3000多人的使用者社区,在使用中碰到任何问题或者建议都可以在社区中反应。 你在官网中可以找到加入社区的方式! @@ -59,7 +59,7 @@ LiteFlow期待你的了解! **微信公众号** -由于社区群超过200人,需要邀请入群。关注公众号后点击`个人微信`加我,我可以拉你入群 +社区群需要邀请入群。关注公众号后点击`个人微信`加我,我可以拉你入群 ![offIical-wx](static/img/offical-wx.jpg) From 73392071f92ae2bad30ce63d51f29b8877f2559e Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Sat, 22 Jul 2023 16:25:53 +0800 Subject: [PATCH 29/30] =?UTF-8?q?=E8=BF=99=E9=87=8C=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81git=20ignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.gitignore | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/.gitignore diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/.gitignore b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/.gitignore deleted file mode 100644 index 5ff6309b..00000000 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file From 938afb6ad65640cdf669a4752dfd5355a7a2bc8e Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Sat, 22 Jul 2023 16:26:06 +0800 Subject: [PATCH 30/30] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=8C=96springboot?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow-testcase-el-sql-springboot-dynamic/pom.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/pom.xml index b7bd4c93..364966c4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-sql-springboot-dynamic/pom.xml @@ -16,19 +16,18 @@ 2.1.214 2.6.8 4.1.2 - 2.7.13 org.springframework.boot spring-boot-starter - ${spring-boot.version} + ${springboot.version} org.springframework.boot spring-boot-starter-web - ${spring-boot.version} + ${springboot.version} com.yomahub