From 2f21f45f7f4ba7891e6bf68f4ac8b4f30cc0202e Mon Sep 17 00:00:00 2001 From: Andreas Marek Date: Thu, 20 Nov 2025 08:17:27 +1000 Subject: [PATCH 1/4] fix testWithJavaXX tasks --- build.gradle | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index d69b06efb6..30bb08c9d9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ +import aQute.bnd.gradle.BundleTaskExtension import net.ltgt.gradle.errorprone.CheckSeverity -import org.gradle.api.file.DuplicatesStrategy import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion @@ -166,8 +166,6 @@ dependencies { testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' } -import aQute.bnd.gradle.BundleTaskExtension - shadowJar { minimize() archiveClassifier.set('') @@ -362,12 +360,24 @@ tasks.register('testWithJava17', Test) { javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(17) } + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + + dependsOn tasks.named('testClasses') + } + tasks.register('testWithJava11', Test) { javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(11) } + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + + dependsOn tasks.named('testClasses') + } + test.dependsOn testWithJava17 test.dependsOn testWithJava11 From b1369f8f5e48a669db7736f52df0d24b450b391a Mon Sep 17 00:00:00 2001 From: Andreas Marek Date: Thu, 20 Nov 2025 10:44:37 +1000 Subject: [PATCH 2/4] upgrade gradle 9 work --- build.gradle | 12 +- src/test/groovy/graphql/HelloWorld.java | 106 +++++++++--------- .../archunit/JMHForkArchRuleTest.groovy | 1 + .../querygenerator/QueryGeneratorTest.groovy | 71 ++++++------ 4 files changed, 96 insertions(+), 94 deletions(-) diff --git a/build.gradle b/build.gradle index 30bb08c9d9..6a48b0f58a 100644 --- a/build.gradle +++ b/build.gradle @@ -127,7 +127,9 @@ dependencies { implementation 'org.antlr:antlr4-runtime:' + antlrVersion implementation 'com.google.guava:guava:' + guavaVersion - testImplementation 'junit:junit:4.13.2' + testImplementation 'org.junit.jupiter:junit-jupiter:5.14.1' + +// testImplementation 'junit:junit:4.13.2' testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' testImplementation 'net.bytebuddy:byte-buddy:1.17.8' testImplementation 'org.objenesis:objenesis:3.4' @@ -148,7 +150,7 @@ dependencies { testImplementation 'org.openjdk.jmh:jmh-core:1.37' // required for ArchUnit to check JMH tests // JUnit Platform launcher required for Gradle 9 - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.14.1' antlr 'org.antlr:antlr4:' + antlrVersion @@ -362,6 +364,9 @@ tasks.register('testWithJava17', Test) { } testClassesDirs = sourceSets.test.output.classesDirs classpath = sourceSets.test.runtimeClasspath + classpath += sourceSets.jmh.output + dependsOn "jmhClasses" + dependsOn tasks.named('testClasses') @@ -376,6 +381,9 @@ tasks.register('testWithJava11', Test) { dependsOn tasks.named('testClasses') + classpath += sourceSets.jmh.output + dependsOn "jmhClasses" + } test.dependsOn testWithJava17 diff --git a/src/test/groovy/graphql/HelloWorld.java b/src/test/groovy/graphql/HelloWorld.java index b381b4bbc0..ccc181eb4d 100644 --- a/src/test/groovy/graphql/HelloWorld.java +++ b/src/test/groovy/graphql/HelloWorld.java @@ -1,54 +1,52 @@ -package graphql; - - -import graphql.schema.GraphQLObjectType; -import graphql.schema.GraphQLSchema; -import org.junit.Test; - -import java.util.Map; - -import static graphql.Scalars.GraphQLString; -import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; -import static graphql.schema.GraphQLObjectType.newObject; -import static org.junit.Assert.assertEquals; - -public class HelloWorld { - - public static void main(String[] args) { - GraphQLObjectType queryType = newObject() - .name("helloWorldQuery") - .field(newFieldDefinition() - .type(GraphQLString) - .name("hello") - .staticValue("world")) - .build(); - - GraphQLSchema schema = GraphQLSchema.newSchema() - .query(queryType) - .build(); - - GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - - Map result = graphQL.execute("{hello}").getData(); - System.out.println(result); - // Prints: {hello=world} - } - - @Test - public void helloWorldTest() { - GraphQLObjectType queryType = newObject() - .name("helloWorldQuery") - .field(newFieldDefinition() - .type(GraphQLString) - .name("hello") - .staticValue("world")) - .build(); - - GraphQLSchema schema = GraphQLSchema.newSchema() - .query(queryType) - .build(); - GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - Map result = graphQL.execute("{hello}").getData(); - assertEquals("world", result.get("hello")); - } -} +//package graphql; +// +// +//import graphql.schema.GraphQLObjectType; +//import graphql.schema.GraphQLSchema; +// +//import java.util.Map; +// +//import static graphql.Scalars.GraphQLString; +//import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; +//import static graphql.schema.GraphQLObjectType.newObject; +// +//public class HelloWorld { +// +// public static void main(String[] args) { +// GraphQLObjectType queryType = newObject() +// .name("helloWorldQuery") +// .field(newFieldDefinition() +// .type(GraphQLString) +// .name("hello") +// .staticValue("world")) +// .build(); +// +// GraphQLSchema schema = GraphQLSchema.newSchema() +// .query(queryType) +// .build(); +// +// GraphQL graphQL = GraphQL.newGraphQL(schema).build(); +// +// Map result = graphQL.execute("{hello}").getData(); +// System.out.println(result); +// // Prints: {hello=world} +// } +// +// @Test +// public void helloWorldTest() { +// GraphQLObjectType queryType = newObject() +// .name("helloWorldQuery") +// .field(newFieldDefinition() +// .type(GraphQLString) +// .name("hello") +// .staticValue("world")) +// .build(); +// +// GraphQLSchema schema = GraphQLSchema.newSchema() +// .query(queryType) +// .build(); +// GraphQL graphQL = GraphQL.newGraphQL(schema).build(); +// Map result = graphQL.execute("{hello}").getData(); +// assertEquals("world", result.get("hello")); +// } +//} diff --git a/src/test/groovy/graphql/archunit/JMHForkArchRuleTest.groovy b/src/test/groovy/graphql/archunit/JMHForkArchRuleTest.groovy index c3128daab6..943da3f59d 100644 --- a/src/test/groovy/graphql/archunit/JMHForkArchRuleTest.groovy +++ b/src/test/groovy/graphql/archunit/JMHForkArchRuleTest.groovy @@ -18,6 +18,7 @@ class JMHForkArchRuleTest extends Specification { def importedClasses = new ClassFileImporter() .importPackages("benchmark", "performance", "graphql.execution") + def rule = classes() .that().areAnnotatedWith(Fork.class) .and().areTopLevelClasses() diff --git a/src/test/groovy/graphql/util/querygenerator/QueryGeneratorTest.groovy b/src/test/groovy/graphql/util/querygenerator/QueryGeneratorTest.groovy index 1fa7c6b037..877dc11d73 100644 --- a/src/test/groovy/graphql/util/querygenerator/QueryGeneratorTest.groovy +++ b/src/test/groovy/graphql/util/querygenerator/QueryGeneratorTest.groovy @@ -5,13 +5,8 @@ import graphql.TestUtil import graphql.parser.Parser import graphql.schema.GraphQLSchema import graphql.validation.Validator -import org.junit.Assert import spock.lang.Specification -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertFalse -import static org.junit.Assert.assertNotNull -import static org.junit.Assert.assertTrue class QueryGeneratorTest extends Specification { def "generate query for simple type"() { @@ -51,10 +46,10 @@ class QueryGeneratorTest extends Specification { def result = executeTest(schema, fieldPath, expectedNoOperation) then: - assertNotNull(result) - assertEquals("Bar", result.usedType) - assertEquals(4, result.totalFieldCount) - assertFalse(result.reachedMaxFieldCount) + result != null + "Bar" == result.usedType + 4 == result.totalFieldCount + !result.reachedMaxFieldCount when: "operation and arguments are passed" def expectedWithOperation = """ @@ -81,7 +76,7 @@ query barTestOperation { ) then: - assertNotNull(result) + result != null } @@ -113,7 +108,7 @@ query barTestOperation { def result = executeTest(schema, fieldPath, expectedNoOperation) then: - assertNotNull(result) + result != null } def "generate query field of non-nullable type"() { @@ -144,7 +139,7 @@ query barTestOperation { def result = executeTest(schema, fieldPath, expectedNoOperation) then: - assertNotNull(result) + result != null } def "generate query for type with nested type"() { @@ -189,7 +184,7 @@ query barTestOperation { def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "generate query for deeply nested field"() { @@ -236,7 +231,7 @@ query barTestOperation { def result = executeTest(schema, fieldPath, expectedNoOperation) then: - assertNotNull(result) + result != null } def "straight forward cyclic dependency"() { @@ -272,7 +267,7 @@ query barTestOperation { def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "cyclic dependency with 2 fields of the same type"() { @@ -313,7 +308,7 @@ query barTestOperation { def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "transitive cyclic dependency"() { @@ -370,7 +365,7 @@ query barTestOperation { def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "generate mutation and subscription for simple type"() { @@ -411,7 +406,7 @@ mutation { def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null when: "operation and arguments are passed" @@ -434,7 +429,7 @@ subscription { ) then: - assertNotNull(result) + result != null } def "generate query containing fields with arguments"() { @@ -471,7 +466,7 @@ subscription { def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "generate query for the 'node' field, which returns an interface"() { @@ -530,7 +525,7 @@ subscription { result = executeTest(schema, fieldPath, null, "(id: \"1\")", classifierType, expected, QueryGeneratorOptions.newBuilder().build()) then: - assertNotNull(result) + result != null when: "passing typeName on field that doesn't return an interface" fieldPath = "Query.foo" @@ -605,7 +600,7 @@ subscription { result = executeTest(schema, fieldPath, null, null, classifierType, expected, QueryGeneratorOptions.newBuilder().build()) then: - assertNotNull(result) + result != null when: "passing typeName that is not part of the union" fieldPath = "Query.something" @@ -657,9 +652,9 @@ subscription { def result = executeTest(schema, fieldPath, null, null, null, expected, options) then: - assertNotNull(result) - assertEquals(3, result.totalFieldCount) - assertTrue(result.reachedMaxFieldCount) + result != null + 3 == result.totalFieldCount + result.reachedMaxFieldCount } def "field limit enforcement may result in less fields than the MAX"() { @@ -704,7 +699,7 @@ subscription { def result = executeTest(schema, fieldPath, null, null, null, expected, options) then: - assertNotNull(result) + result != null } def "max field limit is enforced"() { @@ -743,9 +738,9 @@ $resultFields def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) - assertEquals(10_000, result.totalFieldCount) - assertTrue(result.reachedMaxFieldCount) + result != null + 10_000 == result.totalFieldCount + result.reachedMaxFieldCount } def "filter types and field"() { @@ -800,7 +795,7 @@ $resultFields def result = executeTest(schema, fieldPath, null, null, null, expected, options) then: - assertNotNull(result) + result != null } def "union fields"() { @@ -855,7 +850,7 @@ $resultFields def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "interface fields"() { @@ -912,7 +907,7 @@ $resultFields def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "interface fields with a single implementing type"() { @@ -960,7 +955,7 @@ $resultFields def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "cyclic dependency with union"() { @@ -1018,7 +1013,7 @@ $resultFields def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "union fields with a single type in union"() { @@ -1064,7 +1059,7 @@ $resultFields def result = executeTest(schema, fieldPath, expected) then: - assertNotNull(result) + result != null } def "generates query for large type"() { @@ -1079,7 +1074,7 @@ $resultFields def result = executeTest(schema, fieldPath, null, "(id: \"issue-id-1\")", "JiraIssue", expected, QueryGeneratorOptions.newBuilder().build()) then: - assertNotNull(result) + result != null } private static QueryGeneratorResult executeTest( @@ -1115,7 +1110,7 @@ $resultFields executeQuery(query, schema) - assertEquals(expected.trim(), query.trim()) + expected.trim() == query.trim() return result } @@ -1126,7 +1121,7 @@ $resultFields def errors = new Validator().validateDocument(schema, document, Locale.ENGLISH) if (!errors.isEmpty()) { - Assert.fail("Validation errors: " + errors.collect { it.getMessage() }.join(", ")) + throw new Exception("Validation errors: " + errors.collect { it.getMessage() }.join(", ")) } } From fe97f246f3d598ffee2b5cb78f9ec7b7655a7415 Mon Sep 17 00:00:00 2001 From: Andreas Marek Date: Thu, 20 Nov 2025 11:00:08 +1000 Subject: [PATCH 3/4] upgrade gradle 9 work --- src/test/groovy/graphql/HelloWorld.java | 106 ++++++++++++------------ 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/src/test/groovy/graphql/HelloWorld.java b/src/test/groovy/graphql/HelloWorld.java index ccc181eb4d..5c8e13790f 100644 --- a/src/test/groovy/graphql/HelloWorld.java +++ b/src/test/groovy/graphql/HelloWorld.java @@ -1,52 +1,54 @@ -//package graphql; -// -// -//import graphql.schema.GraphQLObjectType; -//import graphql.schema.GraphQLSchema; -// -//import java.util.Map; -// -//import static graphql.Scalars.GraphQLString; -//import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; -//import static graphql.schema.GraphQLObjectType.newObject; -// -//public class HelloWorld { -// -// public static void main(String[] args) { -// GraphQLObjectType queryType = newObject() -// .name("helloWorldQuery") -// .field(newFieldDefinition() -// .type(GraphQLString) -// .name("hello") -// .staticValue("world")) -// .build(); -// -// GraphQLSchema schema = GraphQLSchema.newSchema() -// .query(queryType) -// .build(); -// -// GraphQL graphQL = GraphQL.newGraphQL(schema).build(); -// -// Map result = graphQL.execute("{hello}").getData(); -// System.out.println(result); -// // Prints: {hello=world} -// } -// -// @Test -// public void helloWorldTest() { -// GraphQLObjectType queryType = newObject() -// .name("helloWorldQuery") -// .field(newFieldDefinition() -// .type(GraphQLString) -// .name("hello") -// .staticValue("world")) -// .build(); -// -// GraphQLSchema schema = GraphQLSchema.newSchema() -// .query(queryType) -// .build(); -// GraphQL graphQL = GraphQL.newGraphQL(schema).build(); -// Map result = graphQL.execute("{hello}").getData(); -// assertEquals("world", result.get("hello")); -// } -//} +package graphql; + + +import graphql.schema.GraphQLObjectType; +import graphql.schema.GraphQLSchema; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +import static graphql.Scalars.GraphQLString; +import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; +import static graphql.schema.GraphQLObjectType.newObject; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class HelloWorld { + + public static void main(String[] args) { + GraphQLObjectType queryType = newObject() + .name("helloWorldQuery") + .field(newFieldDefinition() + .type(GraphQLString) + .name("hello") + .staticValue("world")) + .build(); + + GraphQLSchema schema = GraphQLSchema.newSchema() + .query(queryType) + .build(); + + GraphQL graphQL = GraphQL.newGraphQL(schema).build(); + + Map result = graphQL.execute("{hello}").getData(); + System.out.println(result); + // Prints: {hello=world} + } + + @Test + public void helloWorldTest() { + GraphQLObjectType queryType = newObject() + .name("helloWorldQuery") + .field(newFieldDefinition() + .type(GraphQLString) + .name("hello") + .staticValue("world")) + .build(); + + GraphQLSchema schema = GraphQLSchema.newSchema() + .query(queryType) + .build(); + GraphQL graphQL = GraphQL.newGraphQL(schema).build(); + Map result = graphQL.execute("{hello}").getData(); + assertEquals("world", result.get("hello")); + } +} From 07eb4be477557cd15489b72bc4d0ca8104f91eff Mon Sep 17 00:00:00 2001 From: Andreas Marek Date: Thu, 20 Nov 2025 11:42:33 +1000 Subject: [PATCH 4/4] upgrade gradle 9 work --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6a48b0f58a..f46e334617 100644 --- a/build.gradle +++ b/build.gradle @@ -129,7 +129,6 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.14.1' -// testImplementation 'junit:junit:4.13.2' testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' testImplementation 'net.bytebuddy:byte-buddy:1.17.8' testImplementation 'org.objenesis:objenesis:3.4'