2018-05-30 12:00:13 +02:00
|
|
|
package util
|
|
|
|
|
|
|
|
import com.lesfurets.jenkins.unit.BasePipelineTest
|
2018-06-06 11:19:19 +02:00
|
|
|
import com.sap.piper.GitUtils
|
2018-10-18 08:51:48 +02:00
|
|
|
import com.sap.piper.JenkinsUtils
|
2018-05-30 12:00:13 +02:00
|
|
|
import com.sap.piper.Utils
|
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.runner.RunWith
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
|
|
import org.springframework.test.context.ContextConfiguration
|
|
|
|
import org.springframework.test.context.TestExecutionListeners
|
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
|
|
|
|
|
|
|
@RunWith(SpringJUnit4ClassRunner)
|
|
|
|
@ContextConfiguration(classes = [BasePiperTestContext.class])
|
|
|
|
@TestExecutionListeners(listeners = [LibraryLoadingTestExecutionListener.class], mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
|
|
|
|
abstract class BasePiperTest extends BasePipelineTest {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
Script nullScript
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
Utils utils
|
|
|
|
|
2018-10-18 08:51:48 +02:00
|
|
|
@Autowired
|
|
|
|
JenkinsUtils jenkinsUtils
|
|
|
|
|
2018-05-30 12:00:13 +02:00
|
|
|
@Override
|
|
|
|
@Before
|
|
|
|
void setUp() throws Exception {
|
|
|
|
helper = LibraryLoadingTestExecutionListener.singletonInstance
|
|
|
|
if(!isHelperInitialized()) {
|
|
|
|
super.setScriptRoots('.', 'vars')
|
|
|
|
super.setUp()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean isHelperInitialized() {
|
|
|
|
try {
|
|
|
|
helper.loadScript('dummy.groovy')
|
|
|
|
} catch (Exception e) {
|
|
|
|
if (e.getMessage().startsWith('GroovyScriptEngine is not initialized:'))
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
@Deprecated
|
|
|
|
void prepareObjectInterceptors(Object object) {
|
|
|
|
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(object)
|
|
|
|
}
|
|
|
|
}
|