diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/pom.xml new file mode 100644 index 00000000..522969ec --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/pom.xml @@ -0,0 +1,44 @@ + + + + liteflow-testcase-el + com.yomahub + ${revision} + ../pom.xml + + 4.0.0 + + liteflow-testcase-el-script-graalvm-springboot + + + + com.yomahub + liteflow-spring-boot-starter + ${revision} + + + com.yomahub + liteflow-script-javascript + ${revision} + test + + + org.springframework.boot + spring-boot-starter-test + + + + org.graalvm.js + js-scriptengine + 20.2.0 + + + org.graalvm.js + js + 20.2.0 + + + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java new file mode 100644 index 00000000..64886670 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/BaseTest.java @@ -0,0 +1,20 @@ +package com.yomahub.liteflow.test; + +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; + +public class BaseTest { + + @AfterClass + public static void cleanScanCache(){ + ComponentScanner.cleanCache(); + FlowBus.cleanCache(); + ExecutorHelper.loadInstance().clearExecutorServiceMap(); + SpiFactoryCleaner.clean(); + LiteflowConfigGetter.clean(); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/LiteflowXmlScriptJsCommonELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/LiteflowXmlScriptJsCommonELTest.java new file mode 100644 index 00000000..a0bba42e --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/LiteflowXmlScriptJsCommonELTest.java @@ -0,0 +1,75 @@ +package com.yomahub.liteflow.test.script.graalvm.common; + +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.graalvm.polyglot.Context; +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; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; + + +/** + * 测试springboot下的groovy脚本组件,基于xml配置 + * @author Bryan.Zhang + * @since 2.6.0 + */ +@RunWith(SpringRunner.class) +@TestPropertySource(value = "classpath:/common/application.properties") +@SpringBootTest(classes = LiteflowXmlScriptJsCommonELTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.script.graalvm.common.cmp"}) +public class LiteflowXmlScriptJsCommonELTest extends BaseTest { + +// @Resource +// private FlowExecutor flowExecutor; +// +// //测试普通脚本节点 +// @Test +// 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")); +// } + + /** + * polyglot 模式 + */ + @Test + public void method1() { + System.out.println("Hello Java!"); + try (Context context = Context.newBuilder().allowAllAccess(true).build()) { + context.eval("js", "print('Hello JavaScript!');"); + context.eval("js", "let user = {name:\"dalong\",age:333}; print(JSON.stringify(user))"); + java.math.BigDecimal v = context.eval("js", + "var BigDecimal = Java.type('java.math.BigDecimal');" + + "BigDecimal.valueOf(10).pow(20)") + .asHostObject(); + System.out.println(v.toString()); + } + } + + /** + * 一种是基于ScriptEngineManager模式 + * @throws ScriptException + * @throws NoSuchMethodException + */ + @Test + public void method2() throws ScriptException, NoSuchMethodException { + // 注意此处可以直接使用js,因为js-scriptengine 的spi 注册的时候会自动处理了内置的nashorn + ScriptEngine eng = new ScriptEngineManager().getEngineByName("js"); + eng.eval("let user = {name:\"dalong\",age:333}; print(JSON.stringify(user))"); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/ACmp.java new file mode 100644 index 00000000..a4995568 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/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.script.graalvm.common.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/BCmp.java new file mode 100644 index 00000000..6a557066 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/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.script.graalvm.common.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/CCmp.java new file mode 100644 index 00000000..bd6eb3fa --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/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.script.graalvm.common.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/DCmp.java new file mode 100644 index 00000000..ca2f93ea --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/graalvm/common/cmp/DCmp.java @@ -0,0 +1,24 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.script.graalvm.common.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; + +@LiteflowComponent("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + DefaultContext context = this.getFirstContextBean(); + context.setData("count",198); + System.out.println("DCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/LiteflowXmlScriptJsCommonELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/LiteflowXmlScriptJsCommonELTest.java new file mode 100644 index 00000000..b10bf871 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/LiteflowXmlScriptJsCommonELTest.java @@ -0,0 +1,42 @@ +package com.yomahub.liteflow.test.script.javascript.common; + +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.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; + + +/** + * 测试springboot下的groovy脚本组件,基于xml配置 + * @author Bryan.Zhang + * @since 2.6.0 + */ +@RunWith(SpringRunner.class) +@TestPropertySource(value = "classpath:/common/application.properties") +@SpringBootTest(classes = LiteflowXmlScriptJsCommonELTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.script.javascript.common.cmp"}) +public class LiteflowXmlScriptJsCommonELTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + //测试普通脚本节点 + @Test + 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")); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/ACmp.java new file mode 100644 index 00000000..c746d2bc --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/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.script.javascript.common.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/BCmp.java new file mode 100644 index 00000000..67196ecc --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/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.script.javascript.common.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/CCmp.java new file mode 100644 index 00000000..ca9a0da8 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/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.script.javascript.common.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/DCmp.java new file mode 100644 index 00000000..05541c69 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/common/cmp/DCmp.java @@ -0,0 +1,24 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.script.javascript.common.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; + +@LiteflowComponent("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + DefaultContext context = this.getFirstContextBean(); + context.setData("count",198); + System.out.println("DCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/LiteFlowXmlScriptIfelseJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/LiteFlowXmlScriptIfelseJsELTest.java new file mode 100644 index 00000000..abdd26b5 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/LiteFlowXmlScriptIfelseJsELTest.java @@ -0,0 +1,82 @@ +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.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:/ifelse/application.properties") +@SpringBootTest(classes = LiteFlowXmlScriptIfelseJsELTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.script.javascript.ifelse.cmp"}) +public class LiteFlowXmlScriptIfelseJsELTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + //IF只有2个参数 + @Test + public void testIf1() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.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()); + } + + //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()); + } + + //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()); + } + + //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()); + } + + //标准的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()); + } + + //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()); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/ACmp.java new file mode 100644 index 00000000..9cd41a1c --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/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.script.javascript.ifelse.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/BCmp.java new file mode 100644 index 00000000..fbc73919 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/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.script.javascript.ifelse.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/CCmp.java new file mode 100644 index 00000000..d15d1537 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/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.script.javascript.ifelse.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/DCmp.java new file mode 100644 index 00000000..b97e293a --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/ifelse/cmp/DCmp.java @@ -0,0 +1,24 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.script.javascript.ifelse.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; + +@LiteflowComponent("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + DefaultContext context = this.getFirstContextBean(); + context.setData("count",198); + System.out.println("DCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/LiteFlowXmlScriptLoopJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/LiteFlowXmlScriptLoopJsELTest.java new file mode 100644 index 00000000..172414d3 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/LiteFlowXmlScriptLoopJsELTest.java @@ -0,0 +1,65 @@ +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.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:/loop/application.properties") +@SpringBootTest(classes = LiteFlowXmlScriptLoopJsELTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.script.javascript.loop.cmp"}) +public class LiteFlowXmlScriptLoopJsELTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + //FOR循环数字直接在el中定义 + @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()); + } + + //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()); + } + + //FOR循环中加入BREAK组件 + @Test + public void testLoop3() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + Assert.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", response.getExecuteStepStr()); + } + + //WHILE循环加入BREAK + @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", response.getExecuteStepStr()); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/ACmp.java new file mode 100644 index 00000000..e0f62fca --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/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.script.javascript.loop.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-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/BCmp.java new file mode 100644 index 00000000..b373dd6f --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/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.script.javascript.loop.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-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/CCmp.java new file mode 100644 index 00000000..bed25390 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/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.script.javascript.loop.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-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/DCmp.java new file mode 100644 index 00000000..08b4d059 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/loop/cmp/DCmp.java @@ -0,0 +1,29 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.script.javascript.loop.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; +import org.springframework.stereotype.Component; + +@Component("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + DefaultContext context = this.getFirstContextBean(); + String key = "test"; + if (context.hasData(key)){ + int count = context.getData(key); + context.setData(key, ++count); + }else{ + context.setData(key, 1); + } + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/LiteflowXmlScriptJsRefreshELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/LiteflowXmlScriptJsRefreshELTest.java new file mode 100644 index 00000000..4846a57f --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/LiteflowXmlScriptJsRefreshELTest.java @@ -0,0 +1,54 @@ +package com.yomahub.liteflow.test.script.javascript.refresh; + +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 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; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + + +/** + * 测试springboot下的groovy脚本组件,基于xml配置 + * @author Bryan.Zhang + * @since 2.6.0 + */ +@RunWith(SpringRunner.class) +@TestPropertySource(value = "classpath:/refresh/application.properties") +@SpringBootTest(classes = LiteflowXmlScriptJsRefreshELTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.script.javascript.refresh.cmp"}) +public class LiteflowXmlScriptJsRefreshELTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + //测试脚本的热重载 + @Test + public void testRefresh1() throws Exception{ + //根据配置,加载的应该是flow.xml,执行原来的规则 + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(responseOld.isSuccess()); + Assert.assertEquals("d==>s1[选择脚本]==>a", responseOld.getExecuteStepStr()); + //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 + String newContent = ResourceUtil.readUtf8Str("classpath: /refresh/flow_update.xml"); + //进行刷新 + FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, newContent); + + //重新执行chain2这个链路,结果会变 + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(responseNew.isSuccess()); + Assert.assertEquals("d==>s1[选择脚本_改]==>b==>s2[普通脚本_新增]", responseNew.getExecuteStepStr()); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/ACmp.java new file mode 100644 index 00000000..97bf04cb --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/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.script.javascript.refresh.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/BCmp.java new file mode 100644 index 00000000..2058dca8 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/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.script.javascript.refresh.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/CCmp.java new file mode 100644 index 00000000..79f62c73 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/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.script.javascript.refresh.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/DCmp.java new file mode 100644 index 00000000..9b25b218 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/refresh/cmp/DCmp.java @@ -0,0 +1,24 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.script.javascript.refresh.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; + +@LiteflowComponent("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + DefaultContext context = this.getFirstContextBean(); + context.setData("count",198); + System.out.println("DCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/LiteFlowScriptScriptbeanJsELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/LiteFlowScriptScriptbeanJsELTest.java new file mode 100644 index 00000000..3177177e --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/LiteFlowScriptScriptbeanJsELTest.java @@ -0,0 +1,44 @@ +package com.yomahub.liteflow.test.script.javascript.scriptbean; + +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.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:/scriptbean/application.properties") +@SpringBootTest(classes = LiteFlowScriptScriptbeanJsELTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.script.javascript.scriptbean.cmp","com.yomahub.liteflow.test.script.javascript.scriptbean.bean"}) +public class LiteFlowScriptScriptbeanJsELTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testScriptBean1() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + DefaultContext context = response.getFirstContextBean(); + Assert.assertEquals("hello", context.getData("demo")); + } + + @Test + public void testScriptBean2() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + Assert.assertTrue(response.isSuccess()); + DefaultContext context = response.getFirstContextBean(); + Assert.assertEquals("hello,kobe", context.getData("demo")); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/bean/DemoBean1.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/bean/DemoBean1.java new file mode 100644 index 00000000..7cd387e7 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/bean/DemoBean1.java @@ -0,0 +1,22 @@ +package com.yomahub.liteflow.test.script.javascript.scriptbean.bean; + +import com.yomahub.liteflow.script.ScriptBean; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +@ScriptBean("demo") +public class DemoBean1 { + + @Resource + private 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-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/bean/DemoBean2.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/bean/DemoBean2.java new file mode 100644 index 00000000..253b5221 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/bean/DemoBean2.java @@ -0,0 +1,11 @@ +package com.yomahub.liteflow.test.script.javascript.scriptbean.bean; + +import org.springframework.stereotype.Component; + +@Component +public class DemoBean2 { + + public String getDemoStr2(String name){ + return "hello,"+name; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/cmp/ACmp.java new file mode 100644 index 00000000..d709d953 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/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.script.javascript.scriptbean.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-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/cmp/BCmp.java new file mode 100644 index 00000000..bff941ba --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/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.script.javascript.scriptbean.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-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/cmp/CCmp.java new file mode 100644 index 00000000..a6cc80f5 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/scriptbean/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.script.javascript.scriptbean.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-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/LiteflowXmlScriptJsSwitchELTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/LiteflowXmlScriptJsSwitchELTest.java new file mode 100644 index 00000000..94046342 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/LiteflowXmlScriptJsSwitchELTest.java @@ -0,0 +1,40 @@ +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.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; + + +/** + * 测试springboot下的groovy脚本组件,基于xml配置 + * @author Bryan.Zhang + * @since 2.6.0 + */ +@RunWith(SpringRunner.class) +@TestPropertySource(value = "classpath:/sw/application.properties") +@SpringBootTest(classes = LiteflowXmlScriptJsSwitchELTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.script.javascript.sw.cmp"}) +public class LiteflowXmlScriptJsSwitchELTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + //测试选择脚本节点 + @Test + public void testSw1() { + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("d==>s1[选择脚本]==>a", response.getExecuteStepStr()); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/ACmp.java new file mode 100644 index 00000000..a5a7bfa3 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/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.script.javascript.sw.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/BCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/BCmp.java new file mode 100644 index 00000000..82958109 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/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.script.javascript.sw.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/CCmp.java new file mode 100644 index 00000000..ad15fcc6 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/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.script.javascript.sw.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/DCmp.java new file mode 100644 index 00000000..5bcb6047 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/java/com/yomahub/liteflow/test/script/javascript/sw/cmp/DCmp.java @@ -0,0 +1,24 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.script.javascript.sw.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; + +@LiteflowComponent("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + DefaultContext context = this.getFirstContextBean(); + context.setData("count",198); + System.out.println("DCmp executed!"); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/common/application.properties b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/common/application.properties new file mode 100644 index 00000000..4c9c216b --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/common/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=common/flow.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/common/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/common/flow.xml new file mode 100644 index 00000000..4eafbb46 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/common/flow.xml @@ -0,0 +1,29 @@ + + + + + + + + + + THEN(a, b, c, s1); + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/ifelse/application.properties b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/ifelse/application.properties new file mode 100644 index 00000000..8aa340b2 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/ifelse/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=ifelse/flow.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/ifelse/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/ifelse/flow.xml new file mode 100644 index 00000000..db5d0d59 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/ifelse/flow.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + IF(x0, THEN(a, b)); + + + + IF(x1, THEN(a, b), THEN(c, d)); + + + + item = IF(x1, a, THEN(c, c, b)); + IF( + x1, + a, + item + ); + + + + IF(x1, THEN(a, b)).ELSE(THEN(c, d)); + + + + item = IF(x1, a, THEN(c, c, b)); + + IF(x1, THEN(a, b)).ELSE(item); + + + + IF(x1, THEN(a, b)).ELIF(x0, THEN(c, c)).ELSE(d); + + + + IF(x1, a).ELIF(x1, b) + .ELIF(x1, c) + .ELIF(x1, d) + .ELSE(THEN(d, b, a)); + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/loop/application.properties b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/loop/application.properties new file mode 100644 index 00000000..7189d456 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/loop/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=loop/flow.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/loop/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/loop/flow.xml new file mode 100644 index 00000000..603cf721 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/loop/flow.xml @@ -0,0 +1,50 @@ + + + + + + + + + + 3; + ]]> + + + + + + + + + FOR(2).DO(THEN(a,b,c)); + + + + FOR(x).DO(THEN(a,b,c)); + + + + FOR(10).DO(THEN(a,b,d)).BREAK(y); + + + + WHILE(z).DO(THEN(a,d)); + + + + WHILE(z).DO(THEN(a,d)).BREAK(y); + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/application.properties b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/application.properties new file mode 100644 index 00000000..52bc92b9 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=refresh/flow.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/flow.xml new file mode 100644 index 00000000..52032643 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/flow.xml @@ -0,0 +1,21 @@ + + + + + 100){ + return "a"; + }else{ + return "b"; + } + ]]> + + + + + + THEN(d, SWITCH(s1).to(a,b)); + + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/flow_update.xml b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/flow_update.xml new file mode 100644 index 00000000..19a5c5bd --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/refresh/flow_update.xml @@ -0,0 +1,28 @@ + + + + + 150){ + return "b"; + }else{ + return "a"; + } + ]]> + + + + + + + + + THEN(d, SWITCH(s1).to(a,b), s2); + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/scriptbean/application.properties b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/scriptbean/application.properties new file mode 100644 index 00000000..8c26b5e8 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/scriptbean/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=scriptbean/flow.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/scriptbean/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/scriptbean/flow.xml new file mode 100644 index 00000000..c9cf7aa0 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/scriptbean/flow.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + THEN(a,b,c,d); + + + + THEN(a,b,c,e); + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/sw/application.properties b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/sw/application.properties new file mode 100644 index 00000000..871e47ef --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/sw/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=sw/flow.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/sw/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/sw/flow.xml new file mode 100644 index 00000000..5203f8b2 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-script-graalvm-springboot/src/test/resources/sw/flow.xml @@ -0,0 +1,20 @@ + + + + + 100){ + return 'a'; + }else{ + return 'b'; + } + ]]> + + + + + THEN(d, SWITCH(s1).to(a,b)); + + + \ No newline at end of file diff --git a/liteflow-testcase-el/pom.xml b/liteflow-testcase-el/pom.xml index 690b7fbb..10ca869e 100644 --- a/liteflow-testcase-el/pom.xml +++ b/liteflow-testcase-el/pom.xml @@ -23,6 +23,7 @@ liteflow-testcase-el-script-groovy-springboot liteflow-testcase-el-script-qlexpress-springboot liteflow-testcase-el-script-javascript-springboot + liteflow-testcase-el-script-graalvm-springboot liteflow-testcase-el-zk-springboot liteflow-testcase-el-sql-springboot liteflow-testcase-el-nacos-springboot