Skip to content

Add ClasspathFileUtil for easy getting files from resource directory #30015

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

Closed

Conversation

divinenickname
Copy link

We have some tests which needed a json example for reproduction. I think it would be better if we can ability to easy load them or other files from resource directory instead of defining them into class. It'll makes code more clarity and readable.

For example val body = """ { "bytes": [ 1, 2 ], "array": [ "Foo", "Bar" ], "number": 42, "string": "Foo", "bool": true, "fraction": 42 } """.trimIndent()

can be changed to val body = ResourceClasspathFileUtil("org/springframework/request.json").readText()

@pivotal-cla
Copy link

@divinenickname Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@divinenickname Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 22, 2023
@bclozel
Copy link
Member

bclozel commented Feb 22, 2023

I think this is already covered by new ClassPathResource ("some/resource.json"); this has been made even easier with #24651. I'm declining this PR as a result.

Thanks for your contribution!

@bclozel bclozel closed this Feb 22, 2023
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants