diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringbootTest.java index e5b8ee402..3194e0d71 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringbootTest.java @@ -1,10 +1,14 @@ package com.yomahub.liteflow.test.enable; +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.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; @@ -12,6 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; /** * 测试springboot下的enable参数 + * * @author Bryan.Zhang * @since 2.5.10 */ @@ -22,8 +27,18 @@ import org.springframework.test.context.junit4.SpringRunner; @ComponentScan({"com.yomahub.liteflow.test.enable.cmp"}) public class LiteflowEnableSpringbootTest extends BaseTest { + @Autowired + private ApplicationContext context; + + @Test - public void testConfig() { - System.out.println("成功启动,并且打印"); + public void testEnable() { + LiteflowConfig config = context.getBean(LiteflowConfig.class); + Boolean enable = config.getEnable(); + if (enable) { + System.out.println("成功启动,并且打印"); + return; + } + Assert.assertFalse(enable); } } diff --git a/liteflow-testcase-springboot/src/test/resources/enable/application.properties b/liteflow-testcase-springboot/src/test/resources/enable/application.properties index dfe9a5f9a..64bcf0011 100644 --- a/liteflow-testcase-springboot/src/test/resources/enable/application.properties +++ b/liteflow-testcase-springboot/src/test/resources/enable/application.properties @@ -1,2 +1,2 @@ liteflow.enable=false -liteflow.rule-source=enable/flow.xml \ No newline at end of file +liteflow.rule-source=enable/flow.xml diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringTest.java new file mode 100644 index 000000000..04a2d05e6 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringTest.java @@ -0,0 +1,45 @@ +package com.yomahub.liteflow.test.enable; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.entity.data.DefaultSlot; +import com.yomahub.liteflow.entity.data.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.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + +/** + * spring环境下enable参数 + * + * @author qjwyss + * @since 2.6.0 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration("classpath:/enable/application-local.xml") +public class LiteflowEnableSpringTest extends BaseTest { + @Resource + private FlowExecutor flowExecutor; + + @Autowired + private ApplicationContext context; + + @Test + public void testEnable() throws Exception { + LiteflowConfig config = context.getBean(LiteflowConfig.class); + Boolean enable = config.getEnable(); + if (enable) { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + return; + } + + Assert.assertFalse(enable); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/cmp/ACmp.java new file mode 100644 index 000000000..1028beae5 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/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.enable.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/cmp/BCmp.java new file mode 100644 index 000000000..e4ed668c4 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/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.enable.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/cmp/CCmp.java new file mode 100644 index 000000000..f4c86c323 --- /dev/null +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/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.enable.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-springnative/src/test/resources/enable/application-local.xml b/liteflow-testcase-springnative/src/test/resources/enable/application-local.xml new file mode 100644 index 000000000..8c70f978f --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/enable/application-local.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/liteflow-testcase-springnative/src/test/resources/enable/flow.json b/liteflow-testcase-springnative/src/test/resources/enable/flow.json new file mode 100644 index 000000000..027f2811f --- /dev/null +++ b/liteflow-testcase-springnative/src/test/resources/enable/flow.json @@ -0,0 +1,28 @@ +{ + "flow": { + "nodes": { + "node": [ + { + "id": "a", + "class": "com.yomahub.liteflow.test.enable.cmp.ACmp" + }, + { + "id": "b", + "class": "com.yomahub.liteflow.test.enable.cmp.BCmp" + }, + { + "id": "c", + "class": "com.yomahub.liteflow.test.enable.cmp.CCmp" + } + ] + }, + "chain": [ + { + "name": "chain1", + "condition": [ + {"type": "then", "value": "a,b,c"} + ] + } + ] + } +}