Skip to content

Commit 5aa4a0e

Browse files
committed
minor refactor: junit5 changes (tests weren't running)
1 parent f029ec2 commit 5aa4a0e

17 files changed

Lines changed: 111 additions & 0 deletions

src/test/groovy/bugs/Groovy4116Bug.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ package bugs
2020

2121
import org.codehaus.groovy.control.MultipleCompilationErrorsException
2222

23+
import org.junit.jupiter.api.Test
24+
2325
import static groovy.test.GroovyAssert.shouldFail
2426

2527
final class Groovy4116Bug {
2628

29+
@Test
2730
void testAnInterfaceMethodNotImplementedPublic() {
2831
def err = shouldFail MultipleCompilationErrorsException, '''
2932
class C4116 implements I4116 {
@@ -36,6 +39,7 @@ final class Groovy4116Bug {
3639
assert err.message =~ /The method foo should be public as it implements the corresponding method from interface I4116/
3740
}
3841

42+
@Test
3943
void testAnInterfaceMethodNotImplementedPublicV2SuperClassInterface() {
4044
def err = shouldFail MultipleCompilationErrorsException, '''
4145
abstract class A4116 implements I4116 {

src/test/groovy/bugs/Groovy5396Bug.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
package bugs
2020

2121

22+
import org.junit.jupiter.api.Test
23+
2224
import static groovy.test.GroovyAssert.assertScript
2325

2426

2527
class Groovy5396Bug {
28+
@Test
2629
void testClassAccessToPackageLocalPropertyInSuper() {
2730
assertScript """
2831
class GroovyBase extends AbstractBase {

src/test/groovy/bugs/Groovy6722Bug.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
package bugs
2020

2121

22+
import org.junit.jupiter.api.Test
23+
2224
import static groovy.test.GroovyAssert.assertScript
2325

2426

2527
class Groovy6722Bug {
28+
@Test
2629
void testThatCompilerRecognizesCovariantArray() {
2730
assertScript '''
2831
abstract class Top<Elem,Result> {

src/test/groovy/bugs/Groovy7520Bug.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
package bugs
2020

2121

22+
import org.junit.jupiter.api.Test
23+
2224
import static groovy.test.GroovyAssert.shouldFail
2325

2426

2527
class Groovy7520Bug {
28+
@Test
2629
void testShouldSeeConflictUsingAbstractMethod() {
2730
def msg = shouldFail '''
2831
abstract class DefinesMethod {

src/test/groovy/gls/annotations/closures/AnnotationClosureExhaustiveTestSupport.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,31 @@
1818
*/
1919
package gls.annotations.closures
2020

21+
import org.junit.jupiter.api.Test
22+
2123
abstract class AnnotationClosureExhaustiveTestSupport {
2224
abstract Class getAnnotationClass()
2325

2426
abstract Class getAnnotatedClass()
2527

2628
abstract void verify(Class closureClass)
2729

30+
@Test
2831
void testWorksOnClassLevel() {
2932
worksOn(annotatedClass)
3033
}
3134

35+
@Test
3236
void testWorksOnMethodLevel() {
3337
worksOn(annotatedClass.getDeclaredMethod("aMethod", Object))
3438
}
3539

40+
@Test
3641
void testWorksOnFieldLevel() {
3742
worksOn(annotatedClass.getDeclaredField("aField"))
3843
}
3944

45+
@Test
4046
void testWorksOnPropertyLevel() {
4147
worksOn(annotatedClass.getDeclaredField("aProperty"))
4248
}

src/test/groovy/gls/syntax/Gep3OrderDslTest.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package gls.syntax
2121
import org.codehaus.groovy.control.CompilerConfiguration
2222
import org.junit.jupiter.api.AfterEach
2323
import org.junit.jupiter.api.BeforeEach
24+
import org.junit.jupiter.api.Test
2425

2526
class Gep3OrderDslTest {
2627
@BeforeEach
@@ -37,6 +38,7 @@ class Gep3OrderDslTest {
3738

3839
}
3940

41+
@Test
4042
void testDsl() {
4143
// use the script binding for silent sentence words like "to", "the"
4244
def binding = new CustomBinding()

src/test/groovy/groovy/lang/GroovyShellTest2.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
*/
1919
package groovy.lang
2020

21+
import org.junit.jupiter.api.Test
22+
2123
class GroovyShellTest2 {
24+
@Test
2225
void testBindingsInBaseScriptInitializers() {
2326
def shell = new GroovyShell();
2427
def scriptText = '''
@@ -40,6 +43,7 @@ class GroovyShellTest2 {
4043
assert result == arg0
4144
}
4245

46+
@Test
4347
void testBindingsInScriptFieldInitializers() {
4448
def shell = new GroovyShell();
4549
def scriptText = '''
@@ -54,6 +58,7 @@ class GroovyShellTest2 {
5458
assert result == arg0
5559
}
5660

61+
@Test
5762
void testEvalBindingsInBaseScriptInitializers() {
5863
def context = new Binding()
5964
def arg0 = 'Hello Groovy Eval'
@@ -76,6 +81,7 @@ class GroovyShellTest2 {
7681
assert result == arg0
7782
}
7883

84+
@Test
7985
void testEvalBindingsInScriptFieldInitializers() {
8086
def context = new Binding()
8187
def arg0 = 'Rehi Groovy Eval'

src/test/groovy/groovy/lang/MapOfClosureTest.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@
1919
package groovy.lang
2020

2121

22+
import org.junit.jupiter.api.Test
23+
2224
import static groovy.test.GroovyAssert.shouldFail
25+
import static org.junit.jupiter.api.Assertions.assertEquals
2326

2427
/**
2528
* Tests maps of closures coerced to classes by asType()
2629
*/
2730
class MapOfClosureTest {
2831

32+
@Test
2933
void testInterfaceProxy() {
3034
def outer = 1
3135
def x = [run: { outer++ }] as Runnable
@@ -35,6 +39,7 @@ class MapOfClosureTest {
3539
assert outer == 2
3640
}
3741

42+
@Test
3843
void testInterfaceProxyWithoutAllMethods() {
3944
def proxy = [methodOne: { 'some string' }] as MultiMethodInterface
4045

@@ -47,6 +52,7 @@ class MapOfClosureTest {
4752
}
4853
}
4954

55+
@Test
5056
void testObject() {
5157
def m = [bar: { "foo" }]
5258
def x = m as Object
@@ -55,6 +61,7 @@ class MapOfClosureTest {
5561
assert "foo" == x.bar()
5662
}
5763

64+
@Test
5865
void testAbstractClassSubclassing() {
5966
def outer = 1
6067
def x = [run: { outer++ }] as TimerTask
@@ -66,6 +73,7 @@ class MapOfClosureTest {
6673
/**
6774
* Checks public and protected methods from parents can also be overridden by the Map coercion to classes.
6875
*/
76+
@Test
6977
void testOverrideProtectedMethods() {
7078
def b = [pub: { "map pub" }, prot: { "map prot" }, child: { "map child" }] as B
7179

@@ -78,6 +86,7 @@ class MapOfClosureTest {
7886
/**
7987
* Checks that abstract methods can also be overridden.
8088
*/
89+
@Test
8190
void testAbstractMethodIsOverrided() {
8291
def a = [abstractMethod: { "map abstract" }] as A
8392

@@ -87,6 +96,7 @@ class MapOfClosureTest {
8796
/**
8897
* Verify that complex method signatures, even with primitive types and arrays, can be overridden.
8998
*/
99+
@Test
90100
void testComplexMethodSignature() {
91101
def c = [foo: { int a, List b, Double[] c -> ["map foo"] as String[] }] as C
92102

src/test/groovy/groovy/lang/ReferenceSerializationTest.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* under the License.
1818
*/
1919
package groovy.lang
20+
21+
import org.junit.jupiter.api.Test
22+
2023
/**
2124
* GROOVY-4305: Make groovy.lang.Reference implement Serializable
2225
*/
@@ -40,6 +43,7 @@ class ReferenceSerializationTest implements Serializable {
4043
return ois.readObject()
4144
}
4245

46+
@Test
4347
void testSimplePogoSerializationToObjectOutputStream() {
4448
int age = 33
4549
String name = "Guillaume"
@@ -54,6 +58,7 @@ class ReferenceSerializationTest implements Serializable {
5458
assert personDeserialized.pet.kind == "cat"
5559
}
5660

61+
@Test
5762
void testClosureSerializationWithAReferenceToALocalVariable() {
5863
int number = 2
5964
def doubler = { it * number }
@@ -64,6 +69,7 @@ class ReferenceSerializationTest implements Serializable {
6469
assert closure(3) == 6
6570
}
6671

72+
@Test
6773
void testAICReferencingLocalVariableTest() {
6874
long count = 0
6975
def button = new Button()

src/test/groovy/groovy/util/ProxyGeneratorAdapterTest.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
package groovy.util
2020

2121
import org.codehaus.groovy.runtime.ProxyGeneratorAdapter
22+
import org.junit.jupiter.api.Test
2223

2324
import static groovy.test.GroovyAssert.assertScript
2425

2526
class ProxyGeneratorAdapterTest {
27+
@Test
2628
void testShouldCreateProxy() {
2729
def map = ['toString': { 'HELLO' }]
2830
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Object, null, this.class.classLoader, false, null)
@@ -31,11 +33,13 @@ class ProxyGeneratorAdapterTest {
3133
assert obj.toString() == 'HELLO'
3234
}
3335

36+
@Test
3437
void testShouldCreateProxyWithArrayDelegate() {
3538
def adapter = new ProxyGeneratorAdapter([:], Map$Entry, [Map$Entry] as Class[], null, false, String[])
3639
assert adapter.proxyName() =~ /String_array\d+_groovyProxy/
3740
}
3841

42+
@Test
3943
void testImplementSingleAbstractMethod() {
4044
def map = ['m': { 'HELLO' }]
4145
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Foo, null, this.class.classLoader, false, null)
@@ -45,6 +49,7 @@ class ProxyGeneratorAdapterTest {
4549
assert obj.m() == 'HELLO'
4650
}
4751

52+
@Test
4853
void testImplementSingleAbstractMethodReturningVoid() {
4954
def map = ['bar': { println 'HELLO' }]
5055
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Bar, null, this.class.classLoader, false, null)
@@ -54,6 +59,7 @@ class ProxyGeneratorAdapterTest {
5459
obj.bar()
5560
}
5661

62+
@Test
5763
void testImplementSingleAbstractMethodReturningVoidAndSharedVariable() {
5864
def x = null
5965
def map = ['bar': { x = 'HELLO' }]
@@ -66,6 +72,7 @@ class ProxyGeneratorAdapterTest {
6672
assert x == 'HELLO'
6773
}
6874

75+
@Test
6976
void testImplementMethodFromInterface() {
7077
def map = ['foo': { 'HELLO' }]
7178
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Object, [FooInterface] as Class[], this.class.classLoader, false, null)
@@ -75,6 +82,7 @@ class ProxyGeneratorAdapterTest {
7582
assert obj.foo() == 'HELLO'
7683
}
7784

85+
@Test
7886
void testImplementMethodFromInterfaceUsingInterfaceAsSuperClass() {
7987
def map = ['foo': { 'HELLO' }]
8088
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, FooInterface, null, this.class.classLoader, false, null)
@@ -84,6 +92,7 @@ class ProxyGeneratorAdapterTest {
8492
assert obj.foo() == 'HELLO'
8593
}
8694

95+
@Test
8796
void testImplementMethodFromInterfaceAndSuperClass() {
8897
def x = null
8998
def map = ['foo': { 'HELLO' }, 'bar': { x='WORLD'} ]
@@ -98,6 +107,7 @@ class ProxyGeneratorAdapterTest {
98107
assert x == 'WORLD'
99108
}
100109

110+
@Test
101111
void testImplementMethodFromInterfaceWithPrimitiveTypes() {
102112
def map = ['calc': { x -> x*2 } ]
103113
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Bar, [OtherInterface] as Class[], this.class.classLoader, false, null)
@@ -107,6 +117,7 @@ class ProxyGeneratorAdapterTest {
107117
assert obj.calc(3) == 6
108118
}
109119

120+
@Test
110121
void testWildcardProxy() {
111122
def map = ['*': { '1' } ]
112123
ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, Foo, null, this.class.classLoader, false, null)
@@ -116,6 +127,7 @@ class ProxyGeneratorAdapterTest {
116127
assert obj.m() == '1'
117128
}
118129

130+
@Test
119131
void testDelegatingProxy() {
120132
assertScript '''
121133
public abstract class A { abstract protected String doIt() }
@@ -131,6 +143,7 @@ class ProxyGeneratorAdapterTest {
131143
}
132144

133145
// GROOVY-5925
146+
@Test
134147
void testProxyForLongConstructor() {
135148

136149
def map = [nextInt: { x -> return 0 }]
@@ -142,6 +155,7 @@ class ProxyGeneratorAdapterTest {
142155
assert proxy.nextInt() == 0
143156
}
144157

158+
@Test
145159
void testProxyForDoubleConstructor() {
146160
assertScript '''
147161
public class A {
@@ -162,6 +176,7 @@ class ProxyGeneratorAdapterTest {
162176
}
163177

164178
// GROOVY-7146
179+
@Test
165180
void testShouldNotThrowVerifyErrorBecauseOfStackSize() {
166181
assertScript '''
167182
interface DoStuff {
@@ -178,6 +193,7 @@ class ProxyGeneratorAdapterTest {
178193
static trait Trait1 { def method1() { 'Trait1 method' } }
179194

180195
// GROOVY-7443
196+
@Test
181197
void testTraitFromDifferentClassloader() {
182198
def aWith1 = new ClassA().withTraits(Trait1)
183199
assert aWith1.method1() == 'Trait1 method'
@@ -192,6 +208,7 @@ class ProxyGeneratorAdapterTest {
192208
assert aWith2.method2() == 'Trait2 method'
193209
}
194210

211+
@Test
195212
void testGetTypeArgsRegisterLength() {
196213
def types = { list -> list as org.objectweb.asm.Type[] }
197214
def proxyGeneratorAdapter = new ProxyGeneratorAdapter([:], Object, [] as Class[], null, false, Object)

0 commit comments

Comments
 (0)