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

Make use of JSONAssert in public API optional #32791

Closed
philwebb opened this issue May 10, 2024 · 5 comments
Closed

Make use of JSONAssert in public API optional #32791

philwebb opened this issue May 10, 2024 · 5 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@philwebb
Copy link
Member

See spring-projects/spring-boot#15967 (comment) for details.

The user is suggesting that we consider an alternative to org.skyscreamer:jsonassert since there's little maintenance activity and little appetite to fix the split package issue.

If we do consider something else, we might be able to have JsonTester adapt to either library.

@snicoll
Copy link
Member

snicoll commented May 10, 2024

Good timing considering that stuff is partially moving to Spring Framework and this gives us an opportunity to adapt things a bit.

@snicoll snicoll added the in: test Issues in the test module label May 10, 2024
@sbrannen sbrannen changed the title Consider alternative an json assertion library for module path compatibilty Consider alternative to JSON assertion library for module path compatibilty May 12, 2024
@jhoeller jhoeller changed the title Consider alternative to JSON assertion library for module path compatibilty Consider alternative to JSON assertion library for module path compatibility May 13, 2024
@snicoll
Copy link
Member

snicoll commented May 20, 2024

We could soften that particular use in the linked issue but Spring Framework 6.2 has more use of JSONAssert with the introduction of the AssertJ support. So if we want to move to something else, we could consider JsonUnit but it already depends on Spring.

I don't see us relying on JsonUnit at this stage (@lukas-krecan). @philwebb did you have any other candidates in mind?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label May 20, 2024
@philwebb
Copy link
Member Author

It doesn't look like there's any single candidate that would work as a drop-in replacement, but we could perhaps isolate ourselves a little by not using JSONAssert types in our own API.

I sketched something at https://github.com/philwebb/spring-framework/tree/gh-32791

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 20, 2024
@snicoll snicoll changed the title Consider alternative to JSON assertion library for module path compatibility Make use of JSONAssert in public API optional May 21, 2024
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels May 21, 2024
@snicoll snicoll self-assigned this May 21, 2024
@snicoll snicoll added this to the 6.2.x milestone May 21, 2024
@snicoll
Copy link
Member

snicoll commented May 21, 2024

We've decided to make the use of JSONAssert optional so that users can remove the library and still use other testing features (such as JSONpath or others). This would align with what we've recently done with JSONPath in our assertJ support. However, we don't intend to offer a way for users to use our json-diff related testing API with a different JSON assertion library. For those cases, they'll have to call that themselves.

@snicoll snicoll modified the milestones: 6.2.x, 6.2.0-M4 May 23, 2024
snicoll added a commit to snicoll/spring-framework that referenced this issue May 23, 2024
This commit introduces a JsonComparator abstraction, with an
implementation using JSONAssert. Previously, JSONAssert was the only
choice.

Test APIs have been adapted to allow the new abstraction while relying
on JSONAssert still for high-level methods.

Closes spring-projectsgh-32791

Co-authored-by: Stéphane Nicoll <[email protected]>
@snicoll
Copy link
Member

snicoll commented May 23, 2024

However, we don't intend to offer a way for users to use our json-diff related testing API with a different JSON assertion library. For those cases, they'll have to call that themselves.

Turns out we offered that by allowing a custom JSONComparator from JSONAssert. So we do have introduced high-level methods to pass any JsonComparator for those who want to use our API without JSONAssert. This impacts our new AssertJ support, the request and result matchers as well as WebTestClient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants