X Tutup
Skip to content

Implement tests for ContentType and FormUtils#740

Open
Periecle wants to merge 2 commits intodevelopfrom
implement-content-type-form-utils-tests-3112091859909603494
Open

Implement tests for ContentType and FormUtils#740
Periecle wants to merge 2 commits intodevelopfrom
implement-content-type-form-utils-tests-3112091859909603494

Conversation

@Periecle
Copy link

@Periecle Periecle commented Mar 2, 2026

I have implemented the requested unit tests for ContentType and FormUtils utility classes in the feign-reactor-core module.

During the implementation, I identified and fixed a bug in the charset parsing regex in ContentType.java which failed to correctly parse quoted charset values (e.g., charset="UTF-8") and was too restrictive about trailing characters.

The new tests cover:

  • ContentType: parsing with/without charset, quoted charsets, different charsets, and unsupported charsets.
  • FormUtils: simple forms, collections, URL encoding of special characters, null values, and custom charsets.

All temporary manual verification tools and accidental binary files have been removed from the final submission.


PR created automatically by Jules for task 3112091859909603494 started by @Periecle

- Added comprehensive tests for `ContentType.parse()` and `FormUtils.serializeForm()`.
- Improved charset parsing regex in `ContentType` to support quoted values and better handle trailing characters.
- Removed temporary manual verification files before submission.

Co-authored-by: Periecle <26135126+Periecle@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the robustness of the feign-reactor-core module by introducing dedicated unit tests for its ContentType and FormUtils utility classes. The new tests validate various parsing and serialization behaviors, ensuring the reliability of content type handling and form data processing. A critical bug in the ContentType charset parsing logic was also addressed, improving its accuracy and resilience.

Highlights

  • Unit Test Implementation: Implemented comprehensive unit tests for ContentType and FormUtils utility classes in the feign-reactor-core module.
  • Bug Fix: Identified and fixed a bug in the ContentType.java charset parsing regex to correctly handle quoted charset values and improve flexibility.
  • Test Coverage: Added tests covering ContentType parsing scenarios (with/without charset, quoted, different, unsupported) and FormUtils serialization (simple forms, collections, special characters, nulls, custom charsets).
Changelog
  • feign-reactor-core/src/main/java/reactivefeign/utils/ContentType.java
    • Updated the charsetPattern regex to correctly parse quoted charset values and allow for more flexible trailing characters.
  • feign-reactor-core/src/test/java/reactivefeign/utils/ContentTypeTest.java
    • Added tests for ContentType parsing without charset.
    • Added tests for ContentType parsing with unquoted charset.
    • Added tests for ContentType parsing with quoted charset.
    • Added tests for ContentType parsing with a different charset (ISO-8859-1).
    • Added tests for ContentType parsing with an unsupported charset, defaulting to UTF-8.
  • feign-reactor-core/src/test/java/reactivefeign/utils/FormUtilsTest.java
    • Added a test for serializing a simple form with multiple key-value pairs.
    • Added a test for serializing a form containing a collection of values.
    • Added a test for serializing a form with special characters, ensuring correct URL encoding.
    • Added a test for serializing a form with a null value.
    • Added a test for serializing a form with a different character set (ISO-8859-1).
Activity
  • PR created automatically by Jules for task [3112091859909603494] started by @Periecle.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces unit tests for ContentType and FormUtils, which is a great addition for ensuring code quality and stability. It also includes a fix for a bug in the charset parsing logic within ContentType. My review focuses on the new code and the bug fix. I've found the test implementations to be thorough. I have one suggestion to further improve the regular expression for charset parsing to make it more robust against certain edge cases.


private static final Pattern charsetPattern = Pattern
.compile("(?i)\\bcharset=\\s*\"?([^\\s;\"/]*)/?>");
.compile("(?i)\\bcharset=\\s*\"?([^\\s;\"/>]*)[\"?/>]?");

Choose a reason for hiding this comment

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

medium

The updated regular expression is a definite improvement for handling quoted charsets. However, it could be made more robust. According to RFC 2616, the ? character is a separator and should not be part of the charset value. The current regex might incorrectly include it in the captured charset name.

To handle this correctly, I suggest adding ? to the negated character class in the capturing group. This will ensure that ? acts as a delimiter for the charset value.

Suggested change
.compile("(?i)\\bcharset=\\s*\"?([^\\s;\"/>]*)[\"?/>]?");
.compile("(?i)\\bcharset=\\s*\"?([^\\s;\"/>?]*)[\"?/>]?");

- Added comprehensive tests for `ContentType.parse()` and `FormUtils.serializeForm()`.
- Improved charset parsing regex in `ContentType` to support quoted values and better handle trailing characters.
- Fixed an issue where the regex was overly aggressive, causing potential mismatches.

Co-authored-by: Periecle <26135126+Periecle@users.noreply.github.com>
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.

1 participant

X Tutup