From 7fb16c21b68f37a5f1f172f081bd1924c7c0492c Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Wed, 21 Sep 2022 00:41:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E4=BB=A3=E7=A0=81,jetcd-core=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=88=B00.7.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../etcd/EtcdWithXmlELSpringbootTest.java | 33 ++++++++++++++----- .../etcd/application-xml-cluster.properties | 2 +- pom.xml | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) 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 acceb0ec..cc222159 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.etcd; import cn.hutool.core.util.ReflectUtil; import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.parser.etcd.EtcdClient; import com.yomahub.liteflow.parser.etcd.EtcdXmlELParser; @@ -35,29 +36,45 @@ import static org.mockito.Mockito.*; @ComponentScan({"com.yomahub.liteflow.test.etcd.cmp"}) public class EtcdWithXmlELSpringbootTest extends BaseTest { - @MockBean(answer= Answers.RETURNS_MOCKS) + @MockBean private EtcdClient etcdClient; @Resource private FlowExecutor flowExecutor; @Before - public void setUp() { + public void setUp(){ + //其实只有@Mock才需要initMocks方法,@MockBean不需要initMocks的 MockitoAnnotations.initMocks(this); - String flowXml = "THEN(a, b, c);"; - String changedFlowXml = "THEN(a, c);"; - when(etcdClient.get(any())).thenReturn(flowXml).thenReturn(changedFlowXml); + } + + @After + public void after(){ + FlowBus.cleanCache(); } @Test - public void testEtcdNodeWithXml() throws Exception { + public void testEtcdNodeWithXml1() throws Exception { + String flowXml = "THEN(a, b, c);"; + when(etcdClient.get(any())).thenReturn(flowXml); + + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + } + + @Test + public void testEtcdNodeWithXml2() throws Exception { + String flowXml = "THEN(a, b, c);"; + String changedFlowXml = "THEN(a, c);"; + when(etcdClient.get(any())).thenReturn(flowXml).thenReturn(changedFlowXml); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); // 手动触发一次 模拟节点数据变更 - EtcdXmlELParser parser = ContextAwareHolder.loadContextAware().getBean(EtcdXmlELParser.class); - parser.parse(etcdClient.get("/lite-flow/flow")); + flowExecutor.reloadRule(); LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response2.isSuccess()); diff --git a/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/resources/etcd/application-xml-cluster.properties b/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/resources/etcd/application-xml-cluster.properties index 211b3b4e..bf67b167 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/resources/etcd/application-xml-cluster.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-etcd-springboot/src/test/resources/etcd/application-xml-cluster.properties @@ -1,2 +1,2 @@ liteflow.rule-source-ext-data={"connectStr":"http://localhost:2379,http://localhost:3379,http://localhost:4379"} -liteflow.parse-on-start=false +liteflow.parse-on-start=false \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8d44a729..a24790d5 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ 2.12.3 5.1.0 0.10 - 0.5.0 + 0.7.3 3.3.0 3.0.8 1.11.13