1. 02 7月, 2015 1 次提交
    • S
      Introduce DirtiesContextBeforeModesTestExecutionListener · 0aac02d6
      Sam Brannen 提交于
      SPR-12429 introduced various `BEFORE_*` modes in `@DirtiesContext`. To
      support these new modes, `DirtiesContextTestExecutionListener` (DCTEL)
      was updated to support both `BEFORE_*` and `AFTER_*` modes. However,
      there is a problem with having DCTEL support `BEFORE_*` modes since it
      is typically configured to execute after the
      `DependencyInjectionTestExecutionListener` (DITEL), and this leads to
      several undesired side effects:
      
       - The test's `ApplicationContext` is closed by DCTEL *after*
         dependencies have been injected into the test instance.
      
       - Injected dependencies may therefore attempt to interact with an
         `ApplicationContext` that is no longer _active_.
      
       - If a test has its `ApplicationContext` injected as a dependency,
         interaction with the context will likely fail since the context has
         been closed.
      
       - Any `TestExecutionListeners` registered after DCTEL will get a _new_
         `ApplicationContext` if they invoke `getApplicationContext()` on the
         `TestContext`.
      
      This commit fixes these issues by introducing a new
      `DirtiesContextBeforeModesTestExecutionListener` (DCBMTEL) that is
      registered by default before DITEL. The previous support for `BEFORE_*`
      modes has been moved from DCTEL to DCBMTEL. In addition, an
      `AbstractDirtiesContextTestExecutionListener` has been extracted from
      DCTEL in order to avoid code duplication.
      
      Issue: SPR-13180
      0aac02d6
  2. 15 6月, 2015 1 次提交
    • S
      Retain order of active profiles in the TCF · 68a70437
      Sam Brannen 提交于
      Ever since @ActiveProfiles was introduced, the declared active profiles
      for integration tests have been sorted in order to support unique cache
      key generation; however, there are use cases for which the original
      ordering should be retained.
      
      For example, Spring Boot's ConfigFileApplicationListener loads
      configuration files for active profiles in the order returned by
      Environment.getActiveProfiles(), with the assumption that the ordering
      matches the order in which the developer declared the active profiles.
      
      This commit maintains the uniqueness of active profiles declared via
      @ActiveProfiles but no longer sorts them.
      
      Issue: SPR-12492
      68a70437
  3. 14 6月, 2015 1 次提交
    • S
      Revise method and parameter names in annotation support · 32c17bf5
      Sam Brannen 提交于
      In AnnotatedElementUtils, all methods pertaining to merging annotation
      attributes have been renamed to "getMerged*()" and "findMerged*()"
      accordingly. Existing methods such as getAnnotationAttributes(..) have
      been deprecated in favor of the more descriptive "merged" variants.
      This aligns the naming conventions in AnnotatedElementUtils with those
      already present in AnnotationReadingVisitorUtils.
      
      The use of "annotationType" as a variable name for the fully qualified
      class name of an annotation type has been replaced with
      "annotationName" in order to improve the readability and intent of the
      code base.
      
      In MetaAnnotationUtils.AnnotationDescriptor, getMergedAnnotation() has
      been renamed to synthesizeAnnotation(), and the method is now
      overridden in UntypedAnnotationDescriptor to always throw an
      UnsupportedOperationException in order to avoid potential run-time
      ClassCastExceptions.
      
      Issue: SPR-11511
      32c17bf5
  4. 29 5月, 2015 1 次提交
    • S
      Synthesize annotation from a map of attributes · e30c9b2e
      Sam Brannen 提交于
      Spring Framework 4.2 RC1 introduced support for synthesizing an
      annotation from an existing annotation in order to provide additional
      functionality above and beyond that provided by Java. Specifically,
      such synthesized annotations provide support for @AliasFor semantics.
      As luck would have it, the same principle can be used to synthesize an
      annotation from any map of attributes, and in particular, from an
      instance of AnnotationAttributes.
      
      The following highlight the major changes in this commit toward
      achieving this goal.
      
      - Introduced AnnotationAttributeExtractor abstraction and refactored
        SynthesizedAnnotationInvocationHandler to delegate to an
        AnnotationAttributeExtractor.
      
      - Extracted code from SynthesizedAnnotationInvocationHandler into new
        AbstractAliasAwareAnnotationAttributeExtractor and
        DefaultAnnotationAttributeExtractor implementation classes.
      
      - Introduced MapAnnotationAttributeExtractor for synthesizing an
        annotation that is backed by a map or AnnotationAttributes instance.
      
      - Introduced a variant of synthesizeAnnotation() in AnnotationUtils
        that accepts a map.
      
      - Introduced findAnnotation(*) methods in AnnotatedElementUtils that
        synthesize merged AnnotationAttributes back into an annotation of the
        target type.
      
      The following classes have been refactored to use the new support for
      synthesizing AnnotationAttributes back into an annotation.
      
      - ApplicationListenerMethodAdapter
      - TestAnnotationUtils
      - AbstractTestContextBootstrapper
      - ActiveProfilesUtils
      - ContextLoaderUtils
      - DefaultActiveProfilesResolver
      - DirtiesContextTestExecutionListener
      - TestPropertySourceAttributes
      - TestPropertySourceUtils
      - TransactionalTestExecutionListener
      - MetaAnnotationUtils
      - MvcUriComponentsBuilder
      - RequestMappingHandlerMapping
      
      In addition, this commit also includes changes to ensure that arrays
      returned by synthesized annotations are properly cloned first.
      
      Issue: SPR-13067
      e30c9b2e
  5. 22 5月, 2015 1 次提交
    • S
      Support annotation attribute aliases and overrides via @AliasFor · ca66e076
      Sam Brannen 提交于
      This commit introduces first-class support for aliases for annotation
      attributes. Specifically, this commit introduces a new @AliasFor
      annotation that can be used to declare a pair of aliased attributes
      within a single annotation or an alias from an attribute in a custom
      composed annotation to an attribute in a meta-annotation.
      
      To support @AliasFor within annotation instances, AnnotationUtils has
      been overhauled to "synthesize" any annotations returned by "get" and
      "find" searches. A SynthesizedAnnotation is an annotation that is
      wrapped in a JDK dynamic proxy which provides run-time support for
      @AliasFor semantics. SynthesizedAnnotationInvocationHandler is the
      actual handler behind the proxy.
      
      In addition, the contract for @AliasFor is fully validated, and an
      AnnotationConfigurationException is thrown in case invalid
      configuration is detected.
      
      For example, @ContextConfiguration from the spring-test module is now
      declared as follows:
      
          public @interface ContextConfiguration {
      
              @AliasFor(attribute = "locations")
              String[] value() default {};
      
              @AliasFor(attribute = "value")
              String[] locations() default {};
      
              // ...
          }
      
      The following annotations and their related support classes have been
      modified to use @AliasFor.
      
      - @ManagedResource
      - @ContextConfiguration
      - @ActiveProfiles
      - @TestExecutionListeners
      - @TestPropertySource
      - @Sql
      - @ControllerAdvice
      - @RequestMapping
      
      Similarly, support for AnnotationAttributes has been reworked to
      support @AliasFor as well. This allows for fine-grained control over
      exactly which attributes are overridden within an annotation hierarchy.
      In fact, it is now possible to declare an alias for the 'value'
      attribute of a meta-annotation.
      
      For example, given the revised declaration of @ContextConfiguration
      above, one can now develop a composed annotation with a custom
      attribute override as follows.
      
          @ContextConfiguration
          public @interface MyTestConfig {
      
              @AliasFor(
                 annotation = ContextConfiguration.class,
                 attribute = "locations"
              )
              String[] xmlFiles();
      
              // ...
          }
      
      Consequently, the following are functionally equivalent.
      
      - @MyTestConfig(xmlFiles = "test.xml")
      - @ContextConfiguration("test.xml")
      - @ContextConfiguration(locations = "test.xml").
      
      Issue: SPR-11512, SPR-11513
      ca66e076
  6. 20 5月, 2015 1 次提交
  7. 19 5月, 2015 1 次提交
  8. 14 5月, 2015 1 次提交
  9. 21 4月, 2015 1 次提交
  10. 20 4月, 2015 4 次提交
    • S
      Ensure that contexts loaded by the TCF are active · 93f403cb
      Sam Brannen 提交于
      This commit adds an assertion to DefaultTestContext's
      getApplicationContext() method to ensure that a context loaded by the
      Spring TestContext Framework (TCF) or retrieved from the ContextCache
      is still active. This extra check helps to avoid situations where
      developers manually close a cached context instead of relying on the
      @DirtiesContext support.
      
      Issue: SPR-12932
      93f403cb
    • S
      Use ConcurrentHashMaps in DefaultContextCache · d66d1605
      Sam Brannen 提交于
      The changes made in 0cb22fc8 would
      result in contexts not being properly closed if evicted from the
      ConcurrentReferenceHashMap by the Garbage Collector.
      
      This commit reverts those changes and returns to using standard
      ConcurrentHashMaps for the time being.
      
      Issue: SPR-7687
      d66d1605
    • S
      Improve extensibility of TestContext bootstrapping & context caching · 129488cb
      Sam Brannen 提交于
       - DefaultBootstrapContext and DefaultCacheAwareContextLoaderDelegate
         are now public classes in the 'support' subpackage.
      
       - Introduced getCacheAwareContextLoaderDelegate() in
         AbstractTestContextBootstrapper as an extension point for configuring
         custom ContextCache support.
      
       - Introduced reflection-based createBootstrapContext() utility method
         in BootstrapUtils; TestContextManager now delegates to BootstrapUtils
         in order to avoid package cycles.
      
       - Introduced logStatistics() method in the ContextCache API and defined
         statistics logging category as a constant.
      
       - DefaultCacheAwareContextLoaderDelegate now delegates to
         ContextCache.logStatistics().
      
      Issue: SPR-12683
      129488cb
    • S
      Convert ContextCache to interface with default implementation · e6c24f71
      Sam Brannen 提交于
       - ContextCache is now a public interface.
      
       - Introduced public DefaultContextCache implementation in the 'support'
         subpackage.
      
      Issue: SPR-12683
      e6c24f71
  11. 19 4月, 2015 1 次提交
    • S
      Introduce buildTestContext() in TestContextBootstrapper · 186abcb0
      Sam Brannen 提交于
      This commit moves the responsibility of building a TestContext from the
      TestContextManager to a TestContextBootstrapper.
      
      In addition, DefaultTestContext is now a public class residing in the
      "support" subpackage.
      
      Issue: SPR-12683
      186abcb0
  12. 15 4月, 2015 1 次提交
    • S
      Make AbsTstCtxBootstrapper.resolveContextLoader protected · c006b74e
      Sam Brannen 提交于
      This commit increases the extensibility of
      AbstractTestContextBootstrapper by making the resolveContextLoader()
      and resolveExplicitContextLoaderClass() methods protected instead of
      private.
      
      Furthermore, resolveContextLoader() now throws an IllegalStateException
      if getDefaultContextLoaderClass() returns null.
      
      Issue: SPR-12682
      c006b74e
  13. 23 3月, 2015 1 次提交
    • S
      Introduce BEFORE METHOD/CLASS modes in @DirtiesContext · e086a637
      Sam Brannen 提交于
      Prior to this commit, @DirtiesContext could only be used to close a
      test ApplicationContext after an entire test class or after a test
      method; however, there are some use cases for which it would be
      beneficial to close a test ApplicationContext before a given test class
      or test method -- for example, if some rogue (i.e., yet to be
      determined) test within a large test suite has corrupted the original
      configuration for the ApplicationContext.
      
      This commit provides a solution to such testing challenges by
      introducing the following modes for @DirtiesContext.
      
       - MethodMode.BEFORE_METHOD: configured via the new methodMode attribute
      
       - ClassMode.BEFORE_CLASS and ClassMode.BEFORE_EACH_TEST_METHOD: both
         configured via the existing classMode attribute
      
      Issue: SPR-12429
      e086a637
  14. 01 3月, 2015 1 次提交
    • S
      Simplify Groovy ContextLoaders in the TCF · e24a7ded
      Sam Brannen 提交于
      This commit simplifies the implementations of loadBeanDefinitions() in
      GenericGroovyXmlContextLoader and GenericGroovyXmlWebContextLoader.
      
      Due to the recent bug fix for GroovyBeanDefinitionReader regarding full
      support for XML config files, these Groovy context loaders can now
      simply use a GroovyBeanDefinitionReader instead of a
      GroovyBeanDefinitionReader plus an XmlBeanDefinitionReader.
      
      Issue: SPR-12769
      e24a7ded
  15. 18 2月, 2015 1 次提交
    • S
      Make TestPropertySourceUtils more robust · 42af3303
      Sam Brannen 提交于
       - 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.
      
      Issue: SPR-12721
      42af3303
  16. 17 2月, 2015 2 次提交
    • S
      Open up TestPropertySourceUtils for public consumption · 75e0bc92
      Sam Brannen 提交于
      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.
      
      Issue: SPR-12721
      75e0bc92
    • S
      Preserve ordering of inlined props in @TestPropertySource · d6a799ad
      Sam Brannen 提交于
      The initial implementation for adding inlined properties configured via
      @TestPropertySource to the context's environment did not preserve the
      order in which the properties were physically declared. This makes
      @TestPropertySource a poor testing facility for mimicking the
      production environment's configuration if the property source mechanism
      used in production preserves ordering of property names -- which is the
      case for YAML-based property sources used in Spring Boot, Spring Yarn,
      etc.
      
      This commit addresses this issue by ensuring that the ordering of
      inlined properties declared via @TestPropertySource is preserved.
      Specifically, the original functionality has been refactored. extracted
      from AbstractContextLoader, and moved to TestPropertySourceUtils where
      it may later be made public for general purpose use in other frameworks.
      
      Issue: SPR-12710
      d6a799ad
  17. 24 1月, 2015 2 次提交
    • S
      Support @Configuration as meta-annotation in the TCF · 2d918380
      Sam Brannen 提交于
      Spring Framework 4.0 introduced support for using test-related
      annotations as meta-annotations in the Spring TestContext Framework
      (TCF) in order to create custom composed annotations within a test
      suite; however, the detection of default @Configuration classes in test
      classes was not updated to search for @Configuration declared as a
      meta-annotation. Specifically, AnnotationConfigContextLoaderUtils
      invokes Class.isAnnotated() which only searches for annotations
      declared directly on the class in question.
      
      This commit addresses this issue by refactoring the
      isDefaultConfigurationClassCandidate() method in
      AnnotationConfigContextLoaderUtils so that it uses
      AnnotationUtils.findAnnotation() instead of Class.isAnnotated() for
      detecting the presence of the @Configuration annotation, either
      directly or as a meta-annotation.
      
      Issue: SPR-12659
      2d918380
    • S
      Refer to static nested classes, not static inner classes · c5c32ec2
      Sam Brannen 提交于
      Various parts of the reference manual as well as the Javadoc for
      AnnotationConfigContextLoaderUtils improperly refer to "static inner
      classes" even though this terminology does not exist in Java. The Java
      Language Specification explicitly refers to such classes as "static
      nested classes." An "inner class" must be non-static by definition.
      c5c32ec2
  18. 11 1月, 2015 1 次提交
    • S
      Enable reuse of DefaultActiveProfilesResolver · 276712dc
      Sam Brannen 提交于
      In order to allow DefaultActiveProfilesResolver to be reused (e.g., via
      extension or delegation), the check which asserts that the 'resolver'
      attribute of @ActiveProfiles is not set to a customer resolver class
      has been removed.
      
      Issue: SPR-12611
      276712dc
  19. 21 10月, 2014 1 次提交
  20. 15 8月, 2014 3 次提交
    • S
      Polishing · 8b86519b
      Sam Brannen 提交于
      8b86519b
    • S
      Support merging custom TELs with default TELs · 66250b1f
      Sam Brannen 提交于
      Prior to this commit, if a custom TestExecutionListener was registered
      via @TestExecutionListeners the defaults would not be registered. Thus,
      if a user wanted to declare a custom listener and use the default
      listeners, the user was forced to manually declare all default
      listeners in addition to any custom listeners. This unfortunately
      required that the user know exactly which listeners were registered by
      default. Moreover, the set of default listeners can change from release
      to release, and with the support for automatic discovery of default
      listeners introduced in SPR-11466 it is no longer even possible to know
      what the set of default TestExecutionListeners is before runtime.
      
      This commit addresses this issue by introducing a mechanism for merging
      custom declared listeners with the defaults for the current
      environment. Specifically, @TestExecutionListeners supports a new
      MergeMode that is used to control whether or not explicitly declared
      listeners are merged with the default listeners when
      @TestExecutionListeners is declared on a class that does not inherit
      listeners from a superclass.
      
      Issue: SPR-8854
      66250b1f
    • S
      Support automatic discovery of default TELs · e6d16148
      Sam Brannen 提交于
      Prior to this commit, there was no declarative mechanism for a custom
      TestExecutionListener to be registered as a default
      TestExecutionListener.
      
      This commit introduces support for discovering default
      TestExecutionListener implementations via the SpringFactoriesLoader
      mechanism. Specifically, the spring-test module declares all core
      default TestExecutionListeners under the
      org.springframework.test.context.TestExecutionListener key in its
      META-INF/spring.factories properties file, and third-party frameworks
      and developers can contribute to the list of default
      TestExecutionListeners in the same manner.
      
       - AbstractTestContextBootstrapper uses the SpringFactoriesLoader to
         look up the class names of all registered default
         TestExecutionListeners and sorts the instantiated listeners using
         AnnotationAwareOrderComparator.
      
       - DefaultTestContextBootstrapper and WebTestContextBootstrapper now
         rely on the SpringFactoriesLoader mechanism for finding default
         TestExecutionListeners instead of hard coding fully qualified class
         names.
      
       - To ensure that default TestExecutionListeners are registered in the
         correct order, each can implement Ordered or declare @order.
      
       - AbstractTestExecutionListener and all default TestExecutionListeners
         provided by Spring now implement Ordered with appropriate values.
      
       - Introduced "copy constructors" in MergedContextConfiguration and
         WebMergedContextConfiguration
      
       - SpringFactoriesLoader now uses AnnotationAwareOrderComparator
         instead of OrderComparator.
      
      Issue: SPR-11466
      e6d16148
  21. 14 8月, 2014 2 次提交
    • S
      Improve ex msg when locations & classes are declared in test hierarchy · 181299cc
      Sam Brannen 提交于
      Prior to this commit, if both locations and classes were declared via
      @ContextConfiguration at differing levels in a test class hierarchy,
      the exception message stated that neither of the default context
      loaders was able to load an ApplicationContext from the merged context
      configuration, but the message didn't explain why.
      
      This commit adds an explicit check for such scenarios and provides a
      more informative exception message similar to the following:
      
      "Neither X nor Y supports loading an ApplicationContext from
      [MergedContextConfiguration ...]: declare either 'locations' or
      'classes' but not both."
      
      Issue: SPR-12060
      181299cc
    • S
      Introduce @TestPropertySource support in the TCF · 2cf4147b
      Sam Brannen 提交于
      Spring Framework 3.1 introduced an Environment abstraction with support
      for hierarchical PropertySources that can be configured
      programmatically as well as declaratively via the @PropertySource
      annotation. However, prior to this commit, there was no way to
      declaratively configure PropertySources in integration tests in the
      Spring TestContext Framework (TCF).
      
      This commit introduces declarative support for PropertySources in the
      TCF via a new class-level @TestPropertySource annotation. This
      annotation provides two options for declaring test property sources:
      
       - The 'locations' attribute allows developers to declare external
         resource locations for test properties files.
      
       - The 'properties' attribute allows developers to declare inlined
         properties in the form of key-value pairs.
      
      Test properties files are added to the Environment before all other
      property sources and can therefore override system and application
      property sources. Similarly, inlined properties are added to the
      Environment before all other property sources and can therefore
      override system property sources, application property sources, and
      test properties files.
      
      Specifically, this commit introduces the following major changes:
      
       - Introduced @TestPropertySource annotation along with internal
         TestPropertySourceAttributes, MergedTestPropertySources, and
         TestPropertySourceUtils for working with test property sources
         within the TCF.
      
       - All TestContextBootstrappers have been modified to support the
         merged property resource locations and inlined properties from
         @TestPropertySource.
      
       - MergedContextConfiguration (and consequently the context caching
         key) is now additionally based on the merged property resource
         locations and inlined properties from @TestPropertySource. The same
         applies to WebMergedContextConfiguration.
      
       - AbstractContextLoader's prepareContext() method now adds
         PropertySources for all resource locations and inlined properties
         from the supplied MergedContextConfiguration to the Environment of
         the supplied ApplicationContext. All subclasses of
         AbstractGenericContextLoader and AbstractGenericWebContextLoader
         therefore automatically provide support for @TestPropertySource.
      
      Issue: SPR-12051
      2cf4147b
  22. 29 7月, 2014 1 次提交
  23. 28 7月, 2014 1 次提交
    • S
      Groovy loader should delegate to XML loader in the TCF · f862a009
      Sam Brannen 提交于
      If a resource location in the MergedContextConfiguration has a ".xml"
      extension, the GenericGroovyXmlContextLoader now delegates to a
      dedicated XmlBeanDefinitionReader for loading bean definitions from that
      resource, thus preserving XML validation for all XML resource locations.
      For all other extensions (presumably only ".groovy"), the
      GenericGroovyXmlContextLoader delegates to a GroovyBeanDefinitionReader.
      
      Issue: SPR-11233
      f862a009
  24. 25 7月, 2014 1 次提交
  25. 24 7月, 2014 1 次提交
    • S
      Support Groovy scripts in the TCF · 35c372f2
      Sam Brannen 提交于
      Spring Framework 4.0 introduced first-class support for a Groovy-based
      DSL for defining the beans for an ApplicationContext. However, prior to
      this commit, the Spring TestContext Framework (TCF) did not provide any
      out-of-the-box support for using Groovy scripts as path-based resource
      locations when loading an application context for tests.
      
      This commit addresses this issue by introducing first-class support for
      using Groovy scripts to load the ApplicationContext for integration
      tests managed by the TCF. Specifically, the following changes have been
      made in the TCF to support Groovy scripts.
      
       - Introduced getResourceSuffixes() in AbstractContextLoader in order
         to support multiple resource suffixes in the default detection
         process. This feature is used by the new Groovy/Xml context loaders.
      
       - Introduced GenericGroovyXmlContextLoader and
         GenericGroovyXmlWebContextLoader which support both Groovy scripts
         and XML config files for loading bean definitions. Furthermore,
         these loaders support "-context.xml" and "Context.groovy" as
         resource suffixes when detecting defaults. Note that a default XML
         config file will be detected before a default Groovy script.
      
       - DelegatingSmartContextLoader and WebDelegatingSmartContextLoader now
         use reflection to choose between using GenericGroovyXmlContextLoader
         and GenericGroovyXmlWebContextLoader vs. GenericXmlContextLoader and
         GenericXmlWebContextLoader as their XML loaders, depending on
         whether Groovy is present in the classpath.
      
       - Groovy scripts can be configured via the 'locations' or 'value'
         attributes of @ContextConfiguration and can be mixed seamlessly with
         XML config files.
      
      Issue: SPR-11233
      35c372f2
  26. 18 7月, 2014 1 次提交
  27. 20 6月, 2014 1 次提交
    • S
      Rename SQL script annotations in the TCF · abdb010f
      Sam Brannen 提交于
      Prior to this commit, SQL script annotations and related classes in the
      TestContext framework (TCF) were named DatabaseInitializer*. However,
      these annotations are not used only for initialization and are
      therefore misleading when used for cleaning up the database.
      
      This commit refines the names of annotations and related classes for
      configuring SQL scripts to be executed for integration tests in the TCF
      as follows:
      
      - @DatabaseInitializer -> @Sql
      - @DatabaseInitializers -> @SqlGroup
      - DatabaseInitializerTestExecutionListener -> SqlScriptsTestExecutionListener
      
      A special thanks goes out to the following attendees of the Zurich
      Hackergarten meeting last night for their collective brainstorming:
      @aalmiray, @atsticks, @ollin, @simkuenzi, @tangresh, @vyazelenko.
      
      Issue: SPR-7655
      abdb010f
  28. 06 6月, 2014 1 次提交
    • S
      Introduce annotation to execute SQL scripts in the TCF · 5fd6ebb5
      Sam Brannen 提交于
      Prior to this commit, it was possible to execute SQL scripts
      programmatically via ResourceDatabasePopulator, JdbcTestUtils, and
      ScriptUtils. Furthermore, it was also possible to execute SQL scripts
      declaratively via the <jdbc> XML namespace. However, it was not
      possible to execute SQL scripts declaratively on a per test class or
      per test method basis.
      
      This commit makes it possible to declaratively configure SQL scripts
      for execution in integration tests via annotations that can be declared
      at the class or method level. Details follow.
      
       - Introduced a repeatable @DatabaseInitializer annotation that can be
         used to configure SQL scripts at the class or method level with
         method-level overrides. @DatabaseInitializers serves as a container
         for @DatabaseInitializer.
      
       - Introduced a new DatabaseInitializerTestExecutionListener that is
         responsible for parsing @DatabaseInitializer and
         @DatabaseInitializers and executing SQL scripts.
      
       - DatabaseInitializerTestExecutionListener is registered by default in
         abstract base test classes as well as in TestContextBootstrapper
         implementations.
      
       - @DatabaseInitializer and @DatabaseInitializers may be used as
         meta-annotations; however, attribute overrides are not currently
         supported for repeatable annotations used as meta-annotations. This
         is a known limitation of Spring's AnnotationUtils.
      
       - The semantics for locating SQL script resources is consistent with
         @ContextConfiguration's semantics for locating XML configuration
         files. In addition, a default SQL script can be detected based
         either on the name of the annotated class or on the name of the
         annotated test method.
      
       - @DatabaseInitializer allows for specifying which DataSource and
         PlatformTransactionManager to use from the test's
         ApplicationContext, including default conventions consistent with
         TransactionalTestExecutionListener and @TransactionConfiguration.
      
       - @DatabaseInitializer supports all of the script configuration options
         currently supported by ResourceDatabasePopulator.
      
       - @DatabaseInitializer and DatabaseInitializerTestExecutionListener
         support execution phases for scripts that dictate when SQL scripts
         are executed (i.e., before or after a test method).
      
       - SQL scripts can be executed within the current test's transaction if
         present, outside of the current test's transaction if present, or
         always in a new transaction, depending on the value of the boolean
         requireNewTransaction flag in @DatabaseInitializer.
      
       - DatabaseInitializerTestExecutionListener delegates to
         ResourceDatabasePopulator#execute to actually execute the scripts.
      
      Issue: SPR-7655
      5fd6ebb5
  29. 20 5月, 2014 1 次提交
  30. 19 5月, 2014 1 次提交
  31. 28 4月, 2014 1 次提交
  32. 22 4月, 2014 1 次提交