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] =?UTF-8?q?enhancement=20#I7KZCZ=20=E5=9C=A8=E4=BD=BF?=
=?UTF-8?q?=E7=94=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE=E7=9A=84?=
=?UTF-8?q?=E6=97=B6=E5=80=99=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=AD=E5=B7=B2=E7=BB=8F=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=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 000000000..5ff6309b7
--- /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 000000000..b7bd4c935
--- /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 000000000..eb7287357
--- /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 000000000..427351b64
--- /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 000000000..d694f7bf8
--- /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 000000000..f263fa7d7
--- /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 000000000..c2ffd816c
--- /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 000000000..0d45928bb
--- /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 000000000..8645c0b2e
--- /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 000000000..dda527ee6
--- /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 000000000..fa60f098a
--- /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 000000000..35412b6a8
--- /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 000000000..fa60f098a
--- /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 c573fd243..ee72f5f9a 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 87edf48cd..9d9287230 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 2d53f3497..8f23e9e9f 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