Skip to content

Commit 09b4ae6

Browse files
authored
Merge pull request #4175 from graphql-java/fix-build-after-gradle-9-upgrade
fix build after gradle 9 upgrade
2 parents a41872e + 07eb4be commit 09b4ae6

4 files changed

Lines changed: 58 additions & 45 deletions

File tree

‎build.gradle‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import aQute.bnd.gradle.BundleTaskExtension
12
import net.ltgt.gradle.errorprone.CheckSeverity
2-
import org.gradle.api.file.DuplicatesStrategy
33
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
44
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
55

@@ -127,7 +127,8 @@ dependencies {
127127
implementation 'org.antlr:antlr4-runtime:' + antlrVersion
128128
implementation 'com.google.guava:guava:' + guavaVersion
129129

130-
testImplementation 'junit:junit:4.13.2'
130+
testImplementation 'org.junit.jupiter:junit-jupiter:5.14.1'
131+
131132
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
132133
testImplementation 'net.bytebuddy:byte-buddy:1.17.8'
133134
testImplementation 'org.objenesis:objenesis:3.4'
@@ -148,7 +149,7 @@ dependencies {
148149
testImplementation 'org.openjdk.jmh:jmh-core:1.37' // required for ArchUnit to check JMH tests
149150

150151
// JUnit Platform launcher required for Gradle 9
151-
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
152+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.14.1'
152153

153154
antlr 'org.antlr:antlr4:' + antlrVersion
154155

@@ -166,8 +167,6 @@ dependencies {
166167
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
167168
}
168169

169-
import aQute.bnd.gradle.BundleTaskExtension
170-
171170
shadowJar {
172171
minimize()
173172
archiveClassifier.set('')
@@ -362,12 +361,30 @@ tasks.register('testWithJava17', Test) {
362361
javaLauncher = javaToolchains.launcherFor {
363362
languageVersion = JavaLanguageVersion.of(17)
364363
}
364+
testClassesDirs = sourceSets.test.output.classesDirs
365+
classpath = sourceSets.test.runtimeClasspath
366+
classpath += sourceSets.jmh.output
367+
dependsOn "jmhClasses"
368+
369+
370+
dependsOn tasks.named('testClasses')
371+
365372
}
373+
366374
tasks.register('testWithJava11', Test) {
367375
javaLauncher = javaToolchains.launcherFor {
368376
languageVersion = JavaLanguageVersion.of(11)
369377
}
378+
testClassesDirs = sourceSets.test.output.classesDirs
379+
classpath = sourceSets.test.runtimeClasspath
380+
381+
dependsOn tasks.named('testClasses')
382+
383+
classpath += sourceSets.jmh.output
384+
dependsOn "jmhClasses"
385+
370386
}
387+
371388
test.dependsOn testWithJava17
372389
test.dependsOn testWithJava11
373390

‎src/test/groovy/graphql/HelloWorld.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import graphql.schema.GraphQLObjectType;
55
import graphql.schema.GraphQLSchema;
6-
import org.junit.Test;
6+
import org.junit.jupiter.api.Test;
77

88
import java.util.Map;
99

1010
import static graphql.Scalars.GraphQLString;
1111
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
1212
import static graphql.schema.GraphQLObjectType.newObject;
13-
import static org.junit.Assert.assertEquals;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
1414

1515
public class HelloWorld {
1616

‎src/test/groovy/graphql/archunit/JMHForkArchRuleTest.groovy‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class JMHForkArchRuleTest extends Specification {
1818
def importedClasses = new ClassFileImporter()
1919
.importPackages("benchmark", "performance", "graphql.execution")
2020

21+
2122
def rule = classes()
2223
.that().areAnnotatedWith(Fork.class)
2324
.and().areTopLevelClasses()

‎src/test/groovy/graphql/util/querygenerator/QueryGeneratorTest.groovy‎

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@ import graphql.TestUtil
55
import graphql.parser.Parser
66
import graphql.schema.GraphQLSchema
77
import graphql.validation.Validator
8-
import org.junit.Assert
98
import spock.lang.Specification
109

11-
import static org.junit.Assert.assertEquals
12-
import static org.junit.Assert.assertFalse
13-
import static org.junit.Assert.assertNotNull
14-
import static org.junit.Assert.assertTrue
1510

1611
class QueryGeneratorTest extends Specification {
1712
def "generate query for simple type"() {
@@ -51,10 +46,10 @@ class QueryGeneratorTest extends Specification {
5146
def result = executeTest(schema, fieldPath, expectedNoOperation)
5247

5348
then:
54-
assertNotNull(result)
55-
assertEquals("Bar", result.usedType)
56-
assertEquals(4, result.totalFieldCount)
57-
assertFalse(result.reachedMaxFieldCount)
49+
result != null
50+
"Bar" == result.usedType
51+
4 == result.totalFieldCount
52+
!result.reachedMaxFieldCount
5853

5954
when: "operation and arguments are passed"
6055
def expectedWithOperation = """
@@ -81,7 +76,7 @@ query barTestOperation {
8176
)
8277

8378
then:
84-
assertNotNull(result)
79+
result != null
8580
}
8681

8782

@@ -113,7 +108,7 @@ query barTestOperation {
113108
def result = executeTest(schema, fieldPath, expectedNoOperation)
114109

115110
then:
116-
assertNotNull(result)
111+
result != null
117112
}
118113

119114
def "generate query field of non-nullable type"() {
@@ -144,7 +139,7 @@ query barTestOperation {
144139
def result = executeTest(schema, fieldPath, expectedNoOperation)
145140

146141
then:
147-
assertNotNull(result)
142+
result != null
148143
}
149144

150145
def "generate query for type with nested type"() {
@@ -189,7 +184,7 @@ query barTestOperation {
189184
def result = executeTest(schema, fieldPath, expected)
190185

191186
then:
192-
assertNotNull(result)
187+
result != null
193188
}
194189

195190
def "generate query for deeply nested field"() {
@@ -236,7 +231,7 @@ query barTestOperation {
236231
def result = executeTest(schema, fieldPath, expectedNoOperation)
237232

238233
then:
239-
assertNotNull(result)
234+
result != null
240235
}
241236

242237
def "straight forward cyclic dependency"() {
@@ -272,7 +267,7 @@ query barTestOperation {
272267
def result = executeTest(schema, fieldPath, expected)
273268

274269
then:
275-
assertNotNull(result)
270+
result != null
276271
}
277272

278273
def "cyclic dependency with 2 fields of the same type"() {
@@ -313,7 +308,7 @@ query barTestOperation {
313308
def result = executeTest(schema, fieldPath, expected)
314309

315310
then:
316-
assertNotNull(result)
311+
result != null
317312
}
318313

319314
def "transitive cyclic dependency"() {
@@ -370,7 +365,7 @@ query barTestOperation {
370365
def result = executeTest(schema, fieldPath, expected)
371366

372367
then:
373-
assertNotNull(result)
368+
result != null
374369
}
375370

376371
def "generate mutation and subscription for simple type"() {
@@ -411,7 +406,7 @@ mutation {
411406
def result = executeTest(schema, fieldPath, expected)
412407

413408
then:
414-
assertNotNull(result)
409+
result != null
415410

416411
when: "operation and arguments are passed"
417412

@@ -434,7 +429,7 @@ subscription {
434429
)
435430

436431
then:
437-
assertNotNull(result)
432+
result != null
438433
}
439434

440435
def "generate query containing fields with arguments"() {
@@ -471,7 +466,7 @@ subscription {
471466
def result = executeTest(schema, fieldPath, expected)
472467

473468
then:
474-
assertNotNull(result)
469+
result != null
475470
}
476471

477472
def "generate query for the 'node' field, which returns an interface"() {
@@ -530,7 +525,7 @@ subscription {
530525
result = executeTest(schema, fieldPath, null, "(id: \"1\")", classifierType, expected, QueryGeneratorOptions.newBuilder().build())
531526

532527
then:
533-
assertNotNull(result)
528+
result != null
534529

535530
when: "passing typeName on field that doesn't return an interface"
536531
fieldPath = "Query.foo"
@@ -605,7 +600,7 @@ subscription {
605600
result = executeTest(schema, fieldPath, null, null, classifierType, expected, QueryGeneratorOptions.newBuilder().build())
606601

607602
then:
608-
assertNotNull(result)
603+
result != null
609604

610605
when: "passing typeName that is not part of the union"
611606
fieldPath = "Query.something"
@@ -657,9 +652,9 @@ subscription {
657652
def result = executeTest(schema, fieldPath, null, null, null, expected, options)
658653

659654
then:
660-
assertNotNull(result)
661-
assertEquals(3, result.totalFieldCount)
662-
assertTrue(result.reachedMaxFieldCount)
655+
result != null
656+
3 == result.totalFieldCount
657+
result.reachedMaxFieldCount
663658
}
664659

665660
def "field limit enforcement may result in less fields than the MAX"() {
@@ -704,7 +699,7 @@ subscription {
704699
def result = executeTest(schema, fieldPath, null, null, null, expected, options)
705700

706701
then:
707-
assertNotNull(result)
702+
result != null
708703
}
709704

710705
def "max field limit is enforced"() {
@@ -743,9 +738,9 @@ $resultFields
743738
def result = executeTest(schema, fieldPath, expected)
744739

745740
then:
746-
assertNotNull(result)
747-
assertEquals(10_000, result.totalFieldCount)
748-
assertTrue(result.reachedMaxFieldCount)
741+
result != null
742+
10_000 == result.totalFieldCount
743+
result.reachedMaxFieldCount
749744
}
750745

751746
def "filter types and field"() {
@@ -800,7 +795,7 @@ $resultFields
800795
def result = executeTest(schema, fieldPath, null, null, null, expected, options)
801796

802797
then:
803-
assertNotNull(result)
798+
result != null
804799
}
805800

806801
def "union fields"() {
@@ -855,7 +850,7 @@ $resultFields
855850
def result = executeTest(schema, fieldPath, expected)
856851

857852
then:
858-
assertNotNull(result)
853+
result != null
859854
}
860855

861856
def "interface fields"() {
@@ -912,7 +907,7 @@ $resultFields
912907
def result = executeTest(schema, fieldPath, expected)
913908

914909
then:
915-
assertNotNull(result)
910+
result != null
916911
}
917912

918913
def "interface fields with a single implementing type"() {
@@ -960,7 +955,7 @@ $resultFields
960955
def result = executeTest(schema, fieldPath, expected)
961956

962957
then:
963-
assertNotNull(result)
958+
result != null
964959
}
965960

966961
def "cyclic dependency with union"() {
@@ -1018,7 +1013,7 @@ $resultFields
10181013
def result = executeTest(schema, fieldPath, expected)
10191014

10201015
then:
1021-
assertNotNull(result)
1016+
result != null
10221017
}
10231018

10241019
def "union fields with a single type in union"() {
@@ -1064,7 +1059,7 @@ $resultFields
10641059
def result = executeTest(schema, fieldPath, expected)
10651060

10661061
then:
1067-
assertNotNull(result)
1062+
result != null
10681063
}
10691064

10701065
def "generates query for large type"() {
@@ -1079,7 +1074,7 @@ $resultFields
10791074
def result = executeTest(schema, fieldPath, null, "(id: \"issue-id-1\")", "JiraIssue", expected, QueryGeneratorOptions.newBuilder().build())
10801075

10811076
then:
1082-
assertNotNull(result)
1077+
result != null
10831078
}
10841079

10851080
private static QueryGeneratorResult executeTest(
@@ -1115,7 +1110,7 @@ $resultFields
11151110

11161111
executeQuery(query, schema)
11171112

1118-
assertEquals(expected.trim(), query.trim())
1113+
expected.trim() == query.trim()
11191114

11201115
return result
11211116
}
@@ -1126,7 +1121,7 @@ $resultFields
11261121
def errors = new Validator().validateDocument(schema, document, Locale.ENGLISH)
11271122

11281123
if (!errors.isEmpty()) {
1129-
Assert.fail("Validation errors: " + errors.collect { it.getMessage() }.join(", "))
1124+
throw new Exception("Validation errors: " + errors.collect { it.getMessage() }.join(", "))
11301125
}
11311126

11321127
}

0 commit comments

Comments
 (0)