Skip to content

Allow TestPropertyValues.of to take a Map source #23685

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
wimdeblauwe opened this issue Oct 14, 2020 · 1 comment
Closed

Allow TestPropertyValues.of to take a Map source #23685

wimdeblauwe opened this issue Oct 14, 2020 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@wimdeblauwe
Copy link
Contributor

wimdeblauwe commented Oct 14, 2020

I had a problem in my unit test because I used TestPropertyValues like this:

TestPropertyValues.of("tempo.base-url",
                              "http://localhost:" + wireMockServer.port() + "/core/3/")
                          .applyTo(applicationContext);

The correct usage is to provide the key and the value in a single String like this:

TestPropertyValues.of("tempo.base-url=http://localhost:" + wireMockServer.port() + "/core/3/")
                          .applyTo(applicationContext);

I was confused with the Map.of() factory methods from Java 9. I wonder if we could support something like that?

Maybe this:

TestPropertyValues.of(Map.of("key1", "value1",
                             "key2", "value2"))
                          .applyTo(applicationContext);

or (using the inner Pair class):

TestPropertyValues.of(Pair.of("key1", "value1"),
                      Pair.of("key2", "value2"))
                          .applyTo(applicationContext);
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 14, 2020
@philwebb
Copy link
Member

I think the Map variant would work best.

@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 14, 2020
@philwebb philwebb added this to the 2.4.x milestone Oct 14, 2020
@philwebb philwebb self-assigned this Oct 14, 2020
@philwebb philwebb changed the title Ability to provide key/value as separate arguments to TestPropertyValues Allow TestPropertyValues.of to take a Map source Oct 14, 2020
@philwebb philwebb modified the milestones: 2.4.x, 2.4.0-RC1 Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants