Skip to content

Introduce ActiveProfilesResolver in the TestContext framework [SPR-10338] #14972

Closed

Description

@spring-projects-issues

Michail Nikolaev opened SPR-10338 and commented

Overview

See the related discussion on GitHub for details.


Deliverables

  1. Introduce an ActiveProfilesResolver API. (see Proposal)
  2. Add a resolver attribute to @ActiveProfiles. (see Proposal)
  3. Update ContextLoaderUtils.resolveActiveProfiles(Class<?>\) to support an ActiveProfilesResolver.
    • Make it a configuration error (i.e., by throwing an IllegalStateException) if both active profiles and a resolver are declared.
  4. Document these new features in the reference manual.

Proposal

interface ActiveProfilesResolver {
    String[] resolve(Class<?> testClass);
}
public @interface ActiveProfiles {

    String[] value() default {};

    String[] profiles() default {};

    boolean inheritProfiles() default true;

    Class<? extends ActiveProfilesResolver> resolver() default ActiveProfilesResolver.class;
}

Affects: 3.1 GA

Reference URL: #240

Referenced from: commits 044f512, 4542f36

Activity

  1. spring-projects-issues commented on Feb 27, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Michail Nikolaev commented

    Looks like it is not time-critical issue :) Could I try to contribute the implementation?

  2. spring-projects-issues commented on Feb 27, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Michail Nikolaev, yes, feel free to submit a pull request for the implementation.

    However, I would recommend that you wait until after Spring Framework 3.2.2 has been released in order to reduce the complexity of possible merge conflicts.

  3. spring-projects-issues commented on Mar 5, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Michail Nikolaev commented

    Pull request:
    #246

    if it is hard to merge, i'll resubmit it later

  4. spring-projects-issues commented on Apr 23, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Michail Nikolaev commented

    Have you any thoughts - will this issue moved to 4.0 M1?
    Thanks.

  5. spring-projects-issues commented on Jun 15, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Completed as described in comments for GitHub commit 044f51283b:

    Introduce ActiveProfilesResolver in the TCF

    Prior to this commit, the active bean definition profiles to use when
    loading an ApplicationContext for tests could only be configured
    declaratively (i.e., via hard-coded values supplied to the 'value' or
    'profiles' attribute of @ActiveProfiles).

    This commit makes it possible to programmatically configure active bean
    definition profiles in tests via a new ActiveProfileResolver interface.
    Custom resolvers can be registered via a new 'resolver' attribute
    introduced in @ActiveProfiles.

    Overview of changes:

    • Introduced a new ActiveProfilesResolver API.
    • Added a 'resolver' attribute to @ActiveProfiles.
    • Updated ContextLoaderUtils.resolveActiveProfiles() to support
      ActiveProfilesResolvers.
    • Documented these new features in the reference manual.
    • Added new content to the reference manual regarding the
      'inheritProfiles' attribute of @ActiveProfiles
    • Removed the use of <lineannotation> Docbook markup in the testing
      chapter of the reference manual for Java code examples in order to
      allow comments to have proper syntax highlighting in the generated
      HTML and PDF.
  6. spring-projects-issues commented on Jun 15, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Michail Nikolaev, thanks for all of your hard work!

    You'll notice that I unfortunately wasn't able to merge your pull request directly due to significant changes in the 4.0 (i.e., master) branch; however, I was still able to use a lot of your code (albeit with some rather tedious copying-n-pasting ;)).

    Also, your thorough unit and integration tests were especially helpful.

    Cheers,

    Sam

  7. spring-projects-issues commented on Jun 15, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Michail Nikolaev commented

    Thanks for your work, your help and attention.

  8. added
    in: test
    type: enhancement
    on Jan 11, 2019
  9. added this to the 4.0 M2 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: testtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions