From cebc731296413ba73b772174cad50c804e48d09f Mon Sep 17 00:00:00 2001 From: zhanghua <964552300@qq.com> Date: Sun, 4 Dec 2022 01:41:26 +0800 Subject: [PATCH] =?UTF-8?q?1.=20apollo=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yomahub/liteflow/test/BaseTest.java | 28 +++++++++ .../apollo/ApolloWithXmlELSpringbootTest.java | 57 +++++++++++++++++++ .../liteflow/test/apollo/cmp/ACmp.java | 20 +++++++ .../liteflow/test/apollo/cmp/BCmp.java | 21 +++++++ .../liteflow/test/apollo/cmp/CCmp.java | 21 +++++++ .../apollo/application-xml.properties | 2 + 6 files changed, 149 insertions(+) create mode 100644 liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/ApolloWithXmlELSpringbootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/ACmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/BCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/CCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/resources/apollo/application-xml.properties 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 new file mode 100644 index 000000000..dbad4a0e5 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -0,0 +1,28 @@ +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.AfterClass; + +/** + * @Description: + * @Author: zhanghua + * @Date: 2022/12/3 15:22 + */ +public class BaseTest { + + @AfterClass + 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-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 new file mode 100644 index 000000000..e158cf7c7 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/ApolloWithXmlELSpringbootTest.java @@ -0,0 +1,57 @@ +package com.yomahub.liteflow.test.apollo; + +import com.alibaba.nacos.client.config.NacosConfigService; +import com.ctrip.framework.apollo.Config; +import com.ctrip.framework.apollo.ConfigService; +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 org.junit.After; +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.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 javax.annotation.Resource; + +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + +/** + * @Description: + * @Author: zhanghua + * @Date: 2022/12/3 15:22 + */ +@RunWith(SpringRunner.class) +@TestPropertySource(value = "classpath:/apollo/application-xml.properties") +@SpringBootTest(classes = ApolloWithXmlELSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.apollo.cmp"}) +public class ApolloWithXmlELSpringbootTest { + + + @Resource + private FlowExecutor flowExecutor; + + @After + public void after() { + FlowBus.cleanCache(); + } + + + @Test + public void testApolloWithXml1() throws InterruptedException { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Thread.sleep(2000l); + Assert.assertEquals("a==>b==>c==>c==>b==>a", response.getExecuteStepStrWithoutTime()); + } + + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/ACmp.java new file mode 100644 index 000000000..8ad342958 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/ACmp.java @@ -0,0 +1,20 @@ +/** + *
Title: liteflow
+ *Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.apollo.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-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/BCmp.java new file mode 100644 index 000000000..24a392e13 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/BCmp.java @@ -0,0 +1,21 @@ +/** + *Title: liteflow
+ *Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.apollo.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-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/CCmp.java new file mode 100644 index 000000000..f40763850 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/java/com/yomahub/liteflow/test/apollo/cmp/CCmp.java @@ -0,0 +1,21 @@ +/** + *Title: liteflow
+ *Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.apollo.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-apollo-springboot/src/test/resources/apollo/application-xml.properties b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/resources/apollo/application-xml.properties new file mode 100644 index 000000000..fbc7690ee --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-apollo-springboot/src/test/resources/apollo/application-xml.properties @@ -0,0 +1,2 @@ +liteflow.rule-source-ext-data={"namespace":"liteflowConfig"} +liteflow.parse-on-start=false \ No newline at end of file