Convert maintained JAX-RS samples to JUnit 5#24173
Open
wilx wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 50 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache:253">
P1: Hardcoded Java 8 (`java.version=1.8`) is applied unconditionally to all generated CXF client POMs, but the `useJackson3` branch depends on CXF 4.2.0 and Jackson 3.1.2, both of which require JDK 17. This will cause compilation or runtime failures for the `useJackson3` variant.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| </repository> | ||
| </repositories> | ||
| <properties> | ||
| <java.version>1.8</java.version> |
Contributor
There was a problem hiding this comment.
P1: Hardcoded Java 8 (java.version=1.8) is applied unconditionally to all generated CXF client POMs, but the useJackson3 branch depends on CXF 4.2.0 and Jackson 3.1.2, both of which require JDK 17. This will cause compilation or runtime failures for the useJackson3 variant.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache, line 253:
<comment>Hardcoded Java 8 (`java.version=1.8`) is applied unconditionally to all generated CXF client POMs, but the `useJackson3` branch depends on CXF 4.2.0 and Jackson 3.1.2, both of which require JDK 17. This will cause compilation or runtime failures for the `useJackson3` variant.</comment>
<file context>
@@ -246,14 +250,17 @@ for this project used jakarta.validation-api -->
</repository>
</repositories>
<properties>
+ <java.version>1.8</java.version>
+ <maven.compiler.source>${java.version}</maven.compiler.source>
+ <maven.compiler.target>${java.version}</maven.compiler.target>
</file context>
Use JUnit Jupiter Engine 5.14.4 for generated non-Spring tests and update generated Surefire/Failsafe plugin declarations to 3.5.6 so Maven runs the JUnit Platform tests instead of silently ignoring them. Keep the old Spring Boot CXF server path on JUnit 4 because Spring Boot 1.5 / Spring Framework 4.3 is not compatible with the JUnit Jupiter SpringExtension. Do not force Java 8 compiler settings into the CXF client POM template because the useJackson3 branch depends on CXF 4.2.0 and Jackson 3.1.2, which require a newer JDK. Users on very old JVM/compiler defaults will need to configure their build. Leave the unmaintained generator outputs and templates out of this conversion, including java-pkmst and cxf-ext.
Member
|
thanks for the PR please resolve the merge conflicts when you've time and then I'll try to get it merged before the upcoming stable release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use JUnit Jupiter Engine 5.14.4 for the generated tests and update generated Surefire/Failsafe plugin declarations to 3.5.6 so Maven runs the JUnit Platform tests instead of silently ignoring them.
Set the generated CXF client POMs to compile as Java 8. JUnit 5 requires Java 8, and generated Java code in the 2020s should not fall back to Maven's old source/target 5 defaults.
Leave the unmaintained generator outputs and templates out of this conversion, including java-pkmst and cxf-ext.
Testing
Ran generated sample verification without command-line compiler source/target overrides:
Results:
Also ran the changed Jersey2 Java 8 generated test directly:
./mvnw -q -f samples/openapi3/client/petstore/java/jersey2-java8/pom.xml \ -Dtest=org.openapitools.client.ApiClientTest testResult:
git diff --checkpasses.PR checklist
Read the contribution guidelines.
Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
@hiveship
Summary by cubic
Convert maintained JAX-RS generators and samples (CXF, Jersey 2/3, spec) to JUnit 5 and update test plugins so Maven runs tests on the JUnit Platform. Keep the Spring Boot CXF server path on JUnit 4 for compatibility.
Dependencies
junit:junitwithorg.junit.jupiter:junit-jupiter-engine5.14.4.maven-surefire-pluginandmaven-failsafe-pluginto 3.5.6.Migration
@BeforeEach,Assertions); whengenerateSpringBootApplicationis true, use JUnit 4.Written for commit 0ff0380. Summary will update on new commits.