Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTEasy Reactive - Test selecting from multiple media types #960

Conversation

michalvavrik
Copy link
Member

@michalvavrik michalvavrik commented Dec 21, 2022

Summary

Tests matching requests to resource methods with multiple media types. I combined it with content negotiation and wildcards as they are handled by the same MediaTypeMapper. Main purpose of this PR is to verify quarkusio/quarkus#29732, intention is not to cover all scenarios (f.e. I didn't cover HTTP status 416) as these situations are very rare and users are unlikely to expose multiple endpoints that needs this mapper, it is also not efficient as the mapper is not optimized. There is no point to run added tests on OpenShift (no relation). I also didn't find any related JIRA ticket.

TCKS RESTEasy Reactive tests that are part of Quarkus covers JAX-RS specs media type selection very well, therefore this PR only concentrates on the parts that could have been affected by quarkusio/quarkus#29734.

succees: mvn clean verify -Dit.test=MediaTypeSelectionIT -Dquarkus.platform.group-id=io.quarkus.platform -Dquarkus.platform.version=2.13.6.Final
failure: mvn clean verify -Dit.test=MediaTypeSelectionIT -Dquarkus.platform.group-id=io.quarkus.platform -Dquarkus.platform.version=2.13.5.Final

Please select the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • Dependency update
  • Refactoring
  • Backport
  • New scenario (non-breaking change which adds functionality)
  • This change requires a documentation update
  • This change requires execution against OCP (use run tests phrase in comment)

Checklist:

  • Methods and classes used in PR scenarios are meaningful
  • Commits are well encapsulated and follow the best practices

@michalvavrik michalvavrik requested a review from jsmrcka December 21, 2022 01:18
@michalvavrik michalvavrik added the triage/backport-2.13? It needs to backport changes to branch 2.13 label Dec 21, 2022
@michalvavrik
Copy link
Member Author

Backport comment - only works with 2.13.6.

@michalvavrik
Copy link
Member Author

Hello @rsvoboda , @mjurc , @afalhambra I've added you all as reviewers for I don't know who is still available. First one to review win!

@michalvavrik michalvavrik removed the request for review from jsmrcka December 21, 2022 15:57
@michalvavrik
Copy link
Member Author

Hmm, I just thought of the way how to make the PR more interesting, give me 30 minutes.

@michalvavrik michalvavrik force-pushed the feature/multiple-media-types-selection branch from f3c646c to 6224ddf Compare December 21, 2022 16:50
@rsvoboda rsvoboda requested review from rsvoboda and removed request for afalhambra December 22, 2022 08:14
Copy link
Member

@rsvoboda rsvoboda left a comment

Choose a reason for hiding this comment

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

Slight changes needed, see the comments from review.

I would add some "bad user" cases. For example sending just atom content type instead of atom+xml, text/xml-foo.

Copy link
Contributor

@afalhambra afalhambra left a comment

Choose a reason for hiding this comment

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

minor comments, otherwise looks good to me!
Nice work @michalvavrik

README.md Show resolved Hide resolved
@michalvavrik michalvavrik force-pushed the feature/multiple-media-types-selection branch from 6224ddf to 15a87c3 Compare December 22, 2022 12:47
@michalvavrik
Copy link
Member Author

Added suggest "bad user" cases to testUnsupportedMediaType and testMediaSubTypeWildcard, thank you

@michalvavrik michalvavrik force-pushed the feature/multiple-media-types-selection branch from 15a87c3 to f0c4846 Compare December 22, 2022 12:50
Tests [matching requests to resource methods](https://jakarta.ee/specifications/restful-ws/3.1/jakarta-restful-ws-spec-3.1.html#mapping_requests_to_java_methods) with multiple [media types](https://www.iana.org/assignments/media-types/media-types.xhtml). I combined it with [content negotiation and wildcards](https://www.rfc-editor.org/rfc/rfc9110.html#section-12.4.2) as they are handled by the same [MediaTypeMapper](https://github.com/quarkusio/quarkus/blob/main/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java#L38), however I didn't dig every hole (e.g. left out quality values and so on). Main purpose of this PR is to verify quarkusio/quarkus#29732, intention is not to cover all scenarios (f.e. I didn't cover HTTP status 416) as these situations are very rare and users are unlikely to expose multiple endpoints that needs this mapper, it is also not efficient as the mapper is not optimized.

succees: `mvn clean verify -Dit.test=MediaTypeSelectionIT -Dquarkus.platform.group-id=io.quarkus.platform -Dquarkus.platform.version=2.13.6.Final`
failure: `mvn clean verify -Dit.test=MediaTypeSelectionIT -Dquarkus.platform.group-id=io.quarkus.platform -Dquarkus.platform.version=2.13.5.Final`
@michalvavrik michalvavrik force-pushed the feature/multiple-media-types-selection branch from f0c4846 to 3889f75 Compare December 22, 2022 12:52
@michalvavrik
Copy link
Member Author

Fixed 2 comment typos.

@michalvavrik
Copy link
Member Author

One test failure is in security-keycloak-oidc-client-extended module and it's failing over CORS. I'll look into it later today.

@michalvavrik michalvavrik merged commit 18c48ee into quarkus-qe:main Dec 22, 2022
@michalvavrik michalvavrik deleted the feature/multiple-media-types-selection branch December 22, 2022 17:36
@pjgg pjgg added this to the 2.7 milestone Jan 17, 2023
@pjgg pjgg removed the triage/backport-2.13? It needs to backport changes to branch 2.13 label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants