Convert maintained JAX-RS samples to JUnit 5#24173
Conversation
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> |
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>
cef2158 to
0ff0380
Compare
|
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. |
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.
|
@wing328 I have rebased the branch on master. |
|
It looks like the failing test is pre-existing condition. |
|
i'll fix that in another pr |
|
thanks for the PR which has been merged. for those who wants junit4 support for backward compatibility, please use customized templates. |
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 run tests on the JUnit Platform. The Spring Boot CXF server path stays 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.java-pkmst,cxf-ext) and align samples to JUnit 5.Written for commit 0730a8a. Summary will update on new commits.