diff --git a/liteflow-script-plugin/liteflow-script-kotlin/pom.xml b/liteflow-script-plugin/liteflow-script-kotlin/pom.xml index c89e6d79..df3bed9d 100644 --- a/liteflow-script-plugin/liteflow-script-kotlin/pom.xml +++ b/liteflow-script-plugin/liteflow-script-kotlin/pom.xml @@ -23,7 +23,6 @@ org.jetbrains.kotlin kotlin-scripting-jsr223 - 1.9.23 \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/pom.xml index e76dca32..0563cb2d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/pom.xml @@ -21,7 +21,7 @@ com.yomahub liteflow-script-kotlin - 2.12.0 + ${revision} test diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/java/com/yomahub/liteflow/test/script/kotlin/validate/ValidateKotlinScriptComponentTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/java/com/yomahub/liteflow/test/script/kotlin/validate/ValidateKotlinScriptComponentTest.java index 727b2641..9c9e1885 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/java/com/yomahub/liteflow/test/script/kotlin/validate/ValidateKotlinScriptComponentTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/java/com/yomahub/liteflow/test/script/kotlin/validate/ValidateKotlinScriptComponentTest.java @@ -1,21 +1,41 @@ package com.yomahub.liteflow.test.script.kotlin.validate; import com.yomahub.liteflow.enums.ScriptTypeEnum; +import com.yomahub.liteflow.script.ScriptExecutor; +import com.yomahub.liteflow.script.ScriptExecutorFactory; import com.yomahub.liteflow.script.validator.ScriptValidator; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; +import javax.script.Compilable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; + @SpringBootTest(classes = ValidateKotlinScriptComponentTest.class) @EnableAutoConfiguration public class ValidateKotlinScriptComponentTest { @Test - public void testGroovyScriptComponentValidateFunction(){ + public void testScriptComponentValidateFunction() throws Exception { // 编译错误,字符串不能直接赋值给Int String wrongScript = "val number: Int = \"123\""; // 使用转换函数 String correctScript = "val number: Int = \"123\".toInt()"; +// ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); +// ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("kotlin"); +// Compilable compilable = (Compilable) scriptEngine; +// compilable.compile(correctScript); + +// try { +// ScriptExecutor scriptExecutor = ScriptExecutorFactory.loadInstance() +// .getScriptExecutor(ScriptTypeEnum.KOTLIN.getDisplayName()); +// scriptExecutor.compile(wrongScript); +// } catch (Exception e) { +// +// } + Assertions.assertTrue(ScriptValidator.validate(correctScript)); Assertions.assertFalse(ScriptValidator.validate(wrongScript)); diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/cmpdata/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/cmpdata/flow.xml index 4d333a05..889ae01e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/cmpdata/flow.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/cmpdata/flow.xml @@ -4,11 +4,9 @@ - println(_meta) var cmpData = _meta["cmpData"] as Map var context = bindings["defaultContext"] as DefaultContext context.setData("s1", cmpData["birth"]) diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/meta/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/meta/flow.xml index 01afbc11..ff49ec51 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/meta/flow.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/meta/flow.xml @@ -5,7 +5,7 @@ + var _meta = bindings["_meta"] as Map var nodeId = _meta["nodeId"] var currChainId = _meta["currChainId"] var requestData = _meta["requestData"] diff --git a/pom.xml b/pom.xml index fe2b4d1d..793082b5 100644 --- a/pom.xml +++ b/pom.xml @@ -76,6 +76,7 @@ 1.3.5 3.21.0 3.1.11 + 1.9.23 @@ -314,6 +315,11 @@ redisson ${redisson.version} + + org.jetbrains.kotlin + kotlin-scripting-jsr223 + ${kotlin.version} +