Skip to content

Provide meta-annotation support in the TCF #393

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
wants to merge 15 commits into from

Conversation

sbrannen
Copy link
Member

Spring 3.0 already allows component stereotypes to be used in a
meta-annotation fashion, for example by creating a custom
@TransactionalService stereotype annotation which combines
@transactional and @service in a single, reusable, application-specific
annotation. However, the Spring TestContext Framework (TCF) currently
does not provide any support for test-related annotations to be used as
meta-annotations.

This commit overhauls the TCF with regard to how annotations are
retrieved and adds explicit support for the following annotations to be
used as meta-annotations in conjunction with the TCF.

  • @ContextConfiguration
  • @ContextHierarchy
  • @activeprofiles
  • @DirtiesContext
  • @IfProfileValue
  • @ProfileValueSourceConfiguration
  • @BeforeTransaction
  • @AfterTransaction
  • @TransactionConfiguration
  • @Rollback
  • @TestExecutionListeners
  • @repeat
  • @timed
  • @WebAppConfiguration

Note that meta-annotation support for @transactional was already
available prior to this commit.

Issue: SPR-7827

- Now using AnnotationUtils.getAnnotation() instead of
  Class.getAnnotation() where appropriate in the TestContext Framework.
- Now using AnnotationUtils.findAnnotation() instead of
  Class.isAnnotationPresent() where appropriate in the TestContext
  Framework.
- Introduced findAnnotationPrefersInteracesOverLocalMetaAnnotations() in
  AnnotationUtilsTests in order to verify the status quo.
- Introduced MetaAnnotationUtils and AnnotationDescriptor in the
  spring-test module.
- Verifying support for context hierarchies when @ContextConfiguration
  @ContextHierarchy are used as meta annotations.

Issue: SPR-7827
  meta annotations and interfaces.
- Overhauled and documented MetaAnnotationUtils.AnnotationDescriptor.
- @ignore'd failing tests in ContextLoaderUtilsContextHierarchyTests.
- Introduced findAnnotationDescriptorForTypes() in MetaAnnotationUtils.
  @ContextConfiguration and @ContextHierarchy as meta-annotations.
  looking up @DirtiesContext as a potential meta-annotation.
- Introduced unit tests in DirtiesContextTestExecutionListenerTests.
  @IfProfileValue as a potential meta-annotation.
  @ProfileValueSourceConfiguration as a potential meta-annotation.
  looking up @TransactionConfiguration and @Rollback as potential
  meta-annotations.
  @TestExecutionListeners as a potential meta-annotation.
  as a target, allowing them to be used as meta-annotations.
- TransactionalTestExecutionListener now uses AnnotationUtils for
  looking up @BeforeTransaction and @AfterTransaction as potential
  meta-annotations.
- Introduced TransactionalTestExecutionListenerTests.
  them to be used as meta-annotations.
- SpringJUnit4ClassRunner now uses AnnotationUtils for looking up
  @repeat and @timed as potential meta-annotations.
  from the DefaultTestContext constructor to
  ContextLoaderUtils.buildMergedContextConfiguration().
@ghost ghost assigned sbrannen Oct 28, 2013
sbrannen added a commit that referenced this pull request Oct 28, 2013
* SPR-7827:
  Provide meta-annotation support in the TCF
@sbrannen
Copy link
Member Author

Merged into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant