-
Notifications
You must be signed in to change notification settings - Fork 402
Expand file tree
/
Copy pathTestInterceptingGCLLazyLoadLibClasses.groovy
More file actions
61 lines (54 loc) · 2.63 KB
/
TestInterceptingGCLLazyLoadLibClasses.groovy
File metadata and controls
61 lines (54 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.lesfurets.jenkins
import com.lesfurets.jenkins.unit.LibClassLoader
import com.lesfurets.jenkins.unit.BasePipelineTest
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
import static com.lesfurets.jenkins.unit.global.lib.ProjectSource.projectSource
class TestInterceptingGCLLazyLoadLibClasses extends BasePipelineTest {
@Override
@Before
void setUp() throws Exception {
scriptRoots += 'src/test/jenkins'
super.setUp()
helper.libLoader.preloadLibraryClasses = false
}
/**
* 1. Load two libraries--one dependent on the other--with implicity
* 2. Create instance of library class and pass instance to library vars step
* 3. That vars step in turn creates instance of another library class
* and passes it to another library step
* 4. Make sure interception of pipeline methods works propertly
*/
@Test
@Ignore("Interception of pipeline methods in library classes not working yet")
void test_cross_class_as_var_arg_implicit_lazy_load() throws Exception {
//This does not factor much in the current test but does replicate the
//use case in which the lazy load feature originated.
helper.cloneArgsOnMethodCallRegistration = false
//test_cross_class_as_var_arg_1 uses vars and classes in
//test_cross_class_as_var_arg_2 so the latter has to be loaded first
[
"test_cross_class_as_var_arg_2",
"test_cross_class_as_var_arg_1",
].each { libName ->
final libDir = this.class.getResource("/libs/$libName").file
final library = library().name(libName)
.defaultVersion("master")
.allowOverride(false)
.implicit(true)
.targetPath(libDir)
.retriever(projectSource(libDir))
.build()
helper.registerSharedLibrary(library)
}
final pipeline = "test_var_with_lib_class_arg"
runScript("job/library/cross_class_lazy_load/${pipeline}.jenkins")
printCallStack()
assertCallStackContains("""${pipeline}.monster1(org.test.Monster1""")
assertCallStackContains("""monster1.monster2(org.test.extra.Monster2""")
assertCallStackContains("""monster2.echo(Frankenstein's Monster all by itself is frightening)""")
assertCallStackContains("""monster1.echo(Dracula and Frankenstein's Monster make quite a scary team)""")
}
}