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.cds.controllerblueprints.core.scripts
20 import kotlinx.coroutines.runBlocking
22 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
23 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
24 import kotlin.script.experimental.jvm.util.classpathFromClass
25 import kotlin.script.experimental.jvm.util.classpathFromClassloader
26 import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
27 import kotlin.test.assertNotNull
29 class BluePrintScriptsServiceImplTest {
31 private fun viewClassPathInfo() {
33 println(" *********** classpathFromClass *********** ")
34 classpathFromClass(BluePrintScriptsServiceImplTest::class.java.classLoader,
35 BluePrintScriptsServiceImplTest::class)!!
38 println(" *********** classpathFromClassloader *********** ")
39 classpathFromClassloader(BluePrintScriptsServiceImplTest::class.java.classLoader)!!
42 println(" *********** classpathFromClasspathProperty *********** ")
43 classpathFromClasspathProperty()!!
48 fun testCachedService() {
51 val bluePrintScriptsService = BluePrintScriptsServiceImpl()
53 val basePath = normalizedPathName("src/test/resources/compile")
55 val instance = bluePrintScriptsService
56 .scriptInstance<BlueprintFunctionNode<String, String>>(basePath,
57 "cba.scripts.SampleBlueprintFunctionNode", true)
58 assertNotNull(instance, "failed to get compiled instance")
60 val cachedInstance = bluePrintScriptsService
61 .scriptInstance<BlueprintFunctionNode<String, String>>(basePath,
62 "cba.scripts.SampleBlueprintFunctionNode", false)
63 assertNotNull(cachedInstance, "failed to get cached compile instance")