diff --git a/gradle.properties b/gradle.properties index 1869ff4..3db9cd6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ weaveVersion=2.6.0-SNAPSHOT -weaveTestSuiteVersion=2.5.0-SNAPSHOT +weaveTestSuiteVersion=2.6.0-SNAPSHOT nativeVersion=100.100.100 scalaVersion=2.12.11 ioVersion=1.0.0-SNAPSHOT diff --git a/native-cli-integration-tests/src/test/scala/org/mule/weave/native/NativeCliRuntimeIT.scala b/native-cli-integration-tests/src/test/scala/org/mule/weave/native/NativeCliRuntimeIT.scala index a049bed..b2c1bbf 100644 --- a/native-cli-integration-tests/src/test/scala/org/mule/weave/native/NativeCliRuntimeIT.scala +++ b/native-cli-integration-tests/src/test/scala/org/mule/weave/native/NativeCliRuntimeIT.scala @@ -59,14 +59,16 @@ class NativeCliRuntimeIT extends FunSpec private val INPUT_FILE_PATTERN = Pattern.compile("in[0-9]+\\.[a-zA-Z]+") private val OUTPUT_FILE_PATTERN = Pattern.compile("out\\.[a-zA-Z]+") + private val versionString: String = DataWeaveVersion(ComponentVersion.weaveSuiteVersion).toString() + val testSuites = Seq( - TestSuite("master", loadTestZipFile(s"weave-suites/runtime-${ComponentVersion.weaveSuiteVersion}-test.zip")), - TestSuite("yaml", loadTestZipFile(s"weave-suites/yaml-module-${ComponentVersion.weaveSuiteVersion}-test.zip")) - ) + TestSuite("master", loadTestZipFile(s"weave-suites/runtime-${ComponentVersion.weaveSuiteVersion}-test.zip")), + TestSuite("yaml", loadTestZipFile(s"weave-suites/yaml-module-${ComponentVersion.weaveSuiteVersion}-test.zip")) + ) private def loadTestZipFile(testSuiteExample: String): File = { val url = getResource(testSuiteExample) - val connection = url.openConnection.asInstanceOf[FileURLConnection] + val connection = url.openConnection val zipFile = new File(connection.getURL.toURI) zipFile } @@ -131,6 +133,7 @@ class NativeCliRuntimeIT extends FunSpec } } + def runTestCase(testFolders: Array[File]): Unit = { val unsortedScenarios = for { testFolder <- testFolders @@ -148,7 +151,7 @@ class NativeCliRuntimeIT extends FunSpec scenario.inputs.foreach(f => { val name = FilenameUtils.getBaseName(f.getName) args = args :+ "-i" - args = args :+ (name + s"=${f.getAbsolutePath}" ) + args = args :+ (name + s"=${f.getAbsolutePath}") }) @@ -209,7 +212,7 @@ class NativeCliRuntimeIT extends FunSpec args = args :+ s"--file=${cliTransform.getAbsolutePath}" - val languageLevel = DataWeaveVersion(ComponentVersion.weaveSuiteVersion).toString() + val languageLevel = versionString args = args :+ "--language-level=" + languageLevel val (exitCode, _, _) = NativeCliITTestRunner(args).execute(TIMEOUT._1, TIMEOUT._2) @@ -398,7 +401,7 @@ class NativeCliRuntimeIT extends FunSpec Array("sql_date_mapping") ++ Array("runtime_run") - if (DataWeaveVersion(ComponentVersion.weaveSuiteVersion).toString() == "2.4") { + val testToIgnore = if (versionString == "2.4") { baseArray ++ // A change to json streaming in 2.5.0 breaks this test Array("default_with_extended_null_type") ++ @@ -423,10 +426,16 @@ class NativeCliRuntimeIT extends FunSpec ) ++ Array("as-operator", "type-equality" - ) - } else { + ) ++ + Array("xml_doctype", "stringutils_unwrap") + } else if (versionString == "2.5") { + baseArray ++ + Array("xml_doctype", "stringutils_unwrap") + } + else { baseArray } + testToIgnore } } diff --git a/native-cli/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala b/native-cli/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala index 72f54b9..4742432 100644 --- a/native-cli/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala +++ b/native-cli/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala @@ -25,6 +25,7 @@ import org.mule.weave.v2.parser.phase.CompositeModuleParsingPhasesManager import org.mule.weave.v2.parser.phase.ModuleLoader import org.mule.weave.v2.parser.phase.ModuleLoaderManager import org.mule.weave.v2.parser.phase.ModuleParsingPhasesManager +import org.mule.weave.v2.runtime.CompilationConfig import org.mule.weave.v2.runtime.DataWeaveResult import org.mule.weave.v2.runtime.DataWeaveScript import org.mule.weave.v2.runtime.DataWeaveScriptingEngine @@ -55,16 +56,9 @@ class NativeRuntime(libDir: File, path: Array[File], console: Console, maybeLang private val pathBasedResourceResolver: PathBasedResourceResolver = PathBasedResourceResolver(path ++ Option(libDir.listFiles()).getOrElse(new Array[File](0))) - private val languageLevelService: LanguageLevelService = { - maybeLanguageLevel match { - case Some(version) => WeaveLanguageLevelService(version) - case None => DefaultLanguageLevelService - } - } - private val weaveScriptingEngine: DataWeaveScriptingEngine = { setupEnv() - new DataWeaveScriptingEngine(new NativeModuleComponentFactory(() => pathBasedResourceResolver, systemFirst = true), ParserConfiguration(), new Properties(), languageLevelService = languageLevelService) + new DataWeaveScriptingEngine(new NativeModuleComponentFactory(() => pathBasedResourceResolver, systemFirst = true), ParserConfiguration(), new Properties()) } if (console.isDebugEnabled()) { @@ -108,7 +102,16 @@ class NativeRuntime(libDir: File, path: Array[File], console: Console, maybeLang } private def compileScript(script: String, inputs: ScriptingBindings, nameIdentifier: NameIdentifier, defaultOutputMimeType: String) = { - weaveScriptingEngine.compile(script, nameIdentifier, inputs.entries().map(wi => new InputType(wi, None)).toArray, defaultOutputMimeType) + var config = weaveScriptingEngine.newConfig() + .withScript(script) + .withInputs(inputs.entries().map(wi => new InputType(wi, None)).toArray) + .withNameIdentifier(nameIdentifier) + .withDefaultOutputType(defaultOutputMimeType) + + if (maybeLanguageLevel.isDefined) { + config = config.withLanguageVersion(maybeLanguageLevel.get) + } + weaveScriptingEngine.compileWith(config) } private def createServiceManager(maybePrivileges: Option[Seq[String]] = None): ServiceManager = {