forked from sdanzan/groovy-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGroovyWrapperTest.groovy
56 lines (43 loc) · 2.08 KB
/
GroovyWrapperTest.groovy
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
/**
* Created by gon on 23/05/15.
*/
class GroovyWrapperTest extends GroovyTestCase {
def targetScript = 'GroovyWrapper.groovy'
def instance
@Override
void setUp() {
GroovyClassLoader loader = new GroovyClassLoader()
instance = loader.parseClass(new File(targetScript)).newInstance()
}
void testExtractGrapesGradleNotation() {
def lines = ["// some code here",
"@Grab('org.codehaus.groovy:groovy-all:2.4.3')",
"// other code here"]
def results = instance.extractGrapes(lines)
assert results == [['org.codehaus.groovy', 'groovy-all', '2.4.3']]
}
void testExtractGrapesIvyNotation() {
def lines = ["// some code here",
"@Grab(group ='org.spockframework', module = 'spock-core', version = '1.0-groovy-2.4')",
"// other code here"]
def results = instance.extractGrapes(lines)
assert results == [['org.spockframework', 'spock-core', '1.0-groovy-2.4']]
}
void testExtractGrapesMixedNotation() {
def lines = ["// some code here",
"@Grab(group ='org.spockframework', module = 'spock-core', version = '1.0-groovy-2.4')",
"@Grab('org.codehaus.groovy:groovy-all:2.4.3')",
"// other code here"]
def results = instance.extractGrapes(lines)
assert results == [['org.spockframework', 'spock-core', '1.0-groovy-2.4'], ['org.codehaus.groovy', 'groovy-all', '2.4.3']]
}
void testOnlyGrabDirective() {
def lines = ["// some code here",
"@GrabResolve(name='codehaus', root='http://repository.codehaus.org/')",
"@Grab(group ='org.spockframework', module = 'spock-core', version = '1.0-groovy-2.4')",
"@Grab('org.codehaus.groovy:groovy-all:2.4.3')",
"// other code here"]
def results = instance.extractGrapes(lines)
assert results == [['org.spockframework', 'spock-core', '1.0-groovy-2.4'], ['org.codehaus.groovy', 'groovy-all', '2.4.3']]
}
}