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

Open up TestPropertySourceUtils for public consumption [SPR-12721] #17318

Closed
spring-issuemaster opened this issue Feb 16, 2015 · 3 comments

Comments

@spring-issuemaster
Copy link
Collaborator

commented Feb 16, 2015

Sam Brannen opened SPR-12721 and commented

Status Quo

Spring Framework 4.1 introduced TestPropertySourceUtils for working with @TestPropertySource; however, the utilities in this class are package private.

In light of requirements from Spring Boot (and potentially other third-party frameworks), it would be beneficial to make such utilities public so that the logic contained in them can be reused outside the spring-test module.

Deliverables

  1. Make TestPropertySourceUtils public.
  2. Make utility methods in TestPropertySourceUtils public as appropriate.

Affects: 4.1 GA

Issue Links:

  • #17307 Preserve ordering of inlined properties in @TestPropertySource
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 16, 2015

Sam Brannen commented

Resolved as described in GitHub commit 75e0bc9:

Open up TestPropertySourceUtils for public consumption

Spring Framework 4.1 introduced support for @TestPropertySource;
however, the utilities used to parse inlined properties and add test
property sources to the environment are currently private which
prevents reuse by third-party frameworks like Spring Boot.

This commit addresses this issue by making such utilities public.

  • TestPropertySourceUtils is now a public class.

  • Various utility methods in TestPropertySourceUtils have been made
    public.

  • addResourcePropertySourcesToEnvironment() has been renamed to
    addPropertiesFilesToEnvironment().

  • extractEnvironmentProperties() has been renamed to
    convertInlinedPropertiesToMap().

  • All public methods in TestPropertySourceUtils are now fully
    documented.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 16, 2015

Sam Brannen commented

Backported to 4.1.5 in GitHub commit 2b135f0.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 17, 2015

Sam Brannen commented

Further refinements in GitHub commits 42af330 (4.2) and d98f626 (4.1.5):

Make TestPropertySourceUtils more robust

  • Added assertions for pre-conditions on method arguments for all
    public utility methods.

  • Introduced additional tests in TestPropertySourceUtilsTests to verify
    the new pre-conditions.

  • Introduced INLINED_PROPERTIES_PROPERTY_SOURCE_NAME constant for the
    name of the MapPropertySource created from inlined properties; the
    name therefore no longer contains the inlined properties, but the
    original values of the inlined properties can now be logged at debug
    level.

  • Simplified tests in InlinedPropertiesTestPropertySourceTests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.