2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.apps.controllerblueprints.scripts
20 import org.apache.commons.io.FileUtils
21 import org.junit.Ignore
23 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
25 import kotlin.script.experimental.jvm.util.classpathFromClass
26 import kotlin.script.experimental.jvm.util.classpathFromClassloader
27 import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
28 import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate
30 class BlueprintScriptingHostTest {
34 fun `test classpaths`() {
36 println(" *********** classpathFromClass *********** ")
37 classpathFromClass(BlueprintScriptingHostTest::class.java.classLoader,
38 BlueprintScriptingHostTest::class)!!
41 println(" *********** classpathFromClassloader *********** ")
42 classpathFromClassloader(BlueprintScriptingHostTest::class.java.classLoader)!!
45 println(" *********** classpathFromClasspathProperty *********** ")
46 classpathFromClasspathProperty()!!
51 fun `test same script two folders`() {
53 FileUtils.forceMkdir(File("target/scripts1/"))
54 FileUtils.forceMkdir(File("target/scripts2/"))
56 val scriptSource1 = BluePrintSourceCode()
57 scriptSource1.moduleName = "blueprint-test-script"
59 scriptSource1.targetJarFile = File("target/scripts1/blueprint-script-generated.jar")
60 val sources1: MutableList<String> = arrayListOf()
61 sources1.add("src/test/resources/scripts1")
62 scriptSource1.blueprintKotlinSources = sources1
64 val scriptClassName = "Simple_cba\$SampleComponentFunction"
66 val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<BluePrintKotlinScript>()
68 val scriptEvaluator = BluePrintScriptEvaluator<BlueprintFunctionNode<String, String>>(scriptClassName)
70 val scriptSource2 = BluePrintSourceCode()
71 scriptSource2.moduleName = "blueprint-test-script"
73 scriptSource2.targetJarFile = File("target/scripts2/blueprint-script-generated.jar")
74 val sources2: MutableList<String> = arrayListOf()
75 sources2.add("src/test/resources/scripts2")
76 scriptSource2.blueprintKotlinSources = sources2
79 val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource1, compilationConfiguration,
84 val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource2, compilationConfiguration,