Skip to content

Convert maintained JAX-RS samples to JUnit 5#24173

Open
wilx wants to merge 2 commits into
OpenAPITools:masterfrom
wilx:junit4-to-5
Open

Convert maintained JAX-RS samples to JUnit 5#24173
wilx wants to merge 2 commits into
OpenAPITools:masterfrom
wilx:junit4-to-5

Conversation

@wilx

@wilx wilx commented Jun 30, 2026

Copy link
Copy Markdown

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:

for pom in \
  samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml \
  samples/client/petstore/jaxrs-cxf-client-swagger2/pom.xml \
  samples/client/petstore/jaxrs-cxf-client/pom.xml \
  samples/server/petstore/jaxrs-cxf-annotated-base-path/pom.xml \
  samples/server/petstore/jaxrs-cxf-non-spring-app/pom.xml \
  samples/server/petstore/jaxrs-cxf/pom.xml
do
  ./mvnw -q -f "$pom" verify || exit 1
done

Results:

jaxrs-cxf-client-jackson:       tests=20 failures=0 errors=0 skipped=0
jaxrs-cxf-client-swagger2:      tests=20 failures=0 errors=0 skipped=0
jaxrs-cxf-client:               tests=20 failures=0 errors=0 skipped=0
jaxrs-cxf-annotated-base-path:  tests=20 failures=0 errors=0 skipped=0
jaxrs-cxf-non-spring-app:       tests=20 failures=0 errors=0 skipped=0
jaxrs-cxf:                      tests=37 failures=0 errors=0 skipped=0

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 test

Result:

ApiClientTest: tests=3 failures=0 errors=0 skipped=0

git diff --check passes.

PR checklist

  • Read the contribution guidelines.

  • Run the following to build the project and update samples:

    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    

    (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

    • Replace junit:junit with org.junit.jupiter:junit-jupiter-engine 5.14.4.
    • Upgrade maven-surefire-plugin and maven-failsafe-plugin to 3.5.6.
  • Migration

    • Convert generated non-Spring tests to JUnit 5 (@BeforeEach, Assertions); when generateSpringBootApplication is true, use JUnit 4.
    • Do not force Java version in CXF client POMs; configure if needed.
    • Verified updated JAX-RS samples build and tests pass.

Written for commit 0ff0380. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Comment thread modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache Outdated
wilx added 2 commits July 1, 2026 19:22
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

wing328 commented Jul 6, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants