1. 08 3月, 2019 1 次提交
  2. 09 6月, 2017 1 次提交
    • J
      Consistent use of @Nullable in spring-test · fd53d2a5
      Juergen Hoeller 提交于
      This commit also removes nullability from two common spots: ResolvableType.getType() and TargetSource.getTarget(), both of which are never effectively null with any regular implementation. For such scenarios, a non-null empty type/target is the cleaner contract.
      
      Issue: SPR-15540
      fd53d2a5
  3. 27 5月, 2017 1 次提交
    • S
      Introduce null-safety of Spring Framework API · 87598f48
      Sebastien Deleuze 提交于
      This commit introduces 2 new @Nullable and @NonNullApi
      annotations that leverage JSR 305 (dormant but available via
      Findbugs jsr305 dependency and already used by libraries
      like OkHttp) meta-annotations to specify explicitly
      null-safety of Spring Framework parameters and return values.
      
      In order to avoid adding too much annotations, the
      default is set at package level with @NonNullApi and
      @Nullable annotations are added when needed at parameter or
      return value level. These annotations are intended to be used
      on Spring Framework itself but also by other Spring projects.
      
      @Nullable annotations have been introduced based on Javadoc
      and search of patterns like "return null;". It is expected that
      nullability of Spring Framework API will be polished with
      complementary commits.
      
      In practice, this will make the whole Spring Framework API
      null-safe for Kotlin projects (when KT-10942 will be fixed)
      since Kotlin will be able to leverage these annotations to
      know if a parameter or a return value is nullable or not. But
      this is also useful for Java developers as well since IntelliJ
      IDEA, for example, also understands these annotations to
      generate warnings when unsafe nullable usages are detected.
      
      Issue: SPR-15540
      87598f48
  4. 03 9月, 2016 1 次提交
    • S
      Support concurrent execution in TestContextManager & DefaultTestContext · a10a8e56
      Sam Brannen 提交于
      Prior to this commit, executing tests concurrently in the TestContext
      Framework (TCF) was unsupported and typically lead to unpredictable
      results.
      
      This commit addresses this core issue by supporting concurrent
      execution in the TestContextManager and the DefaultTestContext.
      
      Specifically, the TestContextManager now uses ThreadLocal storage for
      the current TestContext, thereby ensuring that any registered
      TestExecutionListeners and the TestContextManager itself operate on a
      TestContext specific to the current thread.
      
      In order to avoid repeatedly incurring the costs of the overhead of the
      TCF bootstrapping process, the original TestContext built by the
      TestContextBootstrapper is used as a template which is then passed to
      the copy constructor of the concrete implementation of the TestContext
      to create the context for the current thread. DefaultTestContext now
      implements such a copy constructor, and all concrete implementations of
      TestContext are encouraged to do the same.
      
      If the TestContext built by the TestContextBootstrapper does not
      provide a copy constructor, thread-safety and support for concurrency
      are left completely to the implementation of the concrete TestContext.
      
      Note, however, that this commit does not address any thread-safety or
      concurrency issues in the ContextLoader SPI or its implementations.
      
      Issue: SPR-5863
      a10a8e56
  5. 23 3月, 2015 1 次提交
  6. 27 10月, 2013 1 次提交
    • S
      Convert TestContext to interface & default impl · 88fe2e9b
      Sam Brannen 提交于
      Since the Spring TestContext Framework was introduced in Spring
      Framework 2.5, the TestContext class has always been a public class
      with package private constructors. The visibility of TestContext's
      constructor and methods was intentionally limited in order to hide the
      implementation details of the context cache, etc. However, this fact
      has made it difficult (if not impossible) to unit test custom
      TestExecutionListener implementations.
      
      This commit addresses this issue by converting TestContext into a
      public interface with a package private DefaultTestContext
      implementation. This enables unit testing of any components that depend
      on a TestContext (e.g., TestExecutionListeners) while at the same time
      preserving the encapsulation of the inner workings of the TestContext
      implementation with regard to context loading and caching.
      
      Issue: SPR-7692
      88fe2e9b
  7. 11 5月, 2013 1 次提交
  8. 08 5月, 2013 2 次提交
  9. 07 3月, 2013 1 次提交
    • S
      Provide support for context hierarchies in the TCF · 98074e77
      Sam Brannen 提交于
      Prior to this commit the Spring TestContext Framework supported creating
      only flat, non-hierarchical contexts. There was no easy way to create
      contexts with parent-child relationships.
      
      This commit addresses this issue by introducing a new @ContextHierarchy
      annotation that can be used in conjunction with @ContextConfiguration
      for declaring hierarchies of application contexts, either within a
      single test class or within a test class hierarchy. In addition,
      @DirtiesContext now supports a new 'hierarchyMode' attribute for
      controlling context cache clearing for context hierarchies.
      
      - Introduced a new @ContextHierarchy annotation.
      - Introduced 'name' attribute in @ContextConfiguration.
      - Introduced 'name' property in ContextConfigurationAttributes.
      - TestContext is now aware of @ContextHierarchy in addition to
        @ContextConfiguration.
      - Introduced findAnnotationDeclaringClassForTypes() in AnnotationUtils.
      - Introduced resolveContextHierarchyAttributes() in ContextLoaderUtils.
      - Introduced buildContextHierarchyMap() in ContextLoaderUtils.
      - @ContextConfiguration and @ContextHierarchy may not be used as
        top-level, class-level annotations simultaneously.
      - Introduced reference to the parent configuration in
        MergedContextConfiguration and WebMergedContextConfiguration.
      - Introduced overloaded buildMergedContextConfiguration() methods in
        ContextLoaderUtils in order to handle context hierarchies separately
        from conventional, non-hierarchical contexts.
      - Introduced hashCode() and equals() in ContextConfigurationAttributes.
      - ContextLoaderUtils ensures uniqueness of @ContextConfiguration
        elements within a single @ContextHierarchy declaration.
      - Introduced CacheAwareContextLoaderDelegate that can be used for
        loading contexts with transparent support for interacting with the
        context cache -- for example, for retrieving the parent application
        context in a context hierarchy.
      - TestContext now delegates to CacheAwareContextLoaderDelegate for
        loading contexts.
      - Introduced getParentApplicationContext() in MergedContextConfiguration
      - The loadContext(MergedContextConfiguration) methods in
        AbstractGenericContextLoader and AbstractGenericWebContextLoader now
        set the parent context as appropriate.
      - Introduced 'hierarchyMode' attribute in @DirtiesContext with a
        corresponding HierarchyMode enum that defines EXHAUSTIVE and
        CURRENT_LEVEL cache removal modes.
      - ContextCache now internally tracks the relationships between contexts
        that make up a context hierarchy. Furthermore, when a context is
        removed, if it is part of a context hierarchy all corresponding
        contexts will be removed from the cache according to the supplied
        HierarchyMode.
      - AbstractGenericWebContextLoader will set a loaded context as the
        ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE in the MockServletContext when
        context hierarchies are used if the context has no parent or if the
        context has a parent that is not a WAC.
      - Where appropriate, updated Javadoc to refer to the
        ServletTestExecutionListener, which was introduced in 3.2.0.
      - Updated Javadoc to avoid and/or suppress warnings in spring-test.
      - Suppressed remaining warnings in code in spring-test.
      
      Issue: SPR-5613, SPR-9863
      98074e77
  10. 29 12月, 2012 3 次提交
  11. 08 10月, 2012 1 次提交
    • S
      Support loading WebApplicationContexts in the TCF · a73280cc
      Sam Brannen 提交于
      Prior to this commit, the Spring TestContext Framework only supported
      loading an ApplicationContext in integration tests from either XML or
      Java Properties files (since Spring 2.5), and Spring 3.1 introduced
      support for loading an ApplicationContext in integration tests from
      annotated classes (e.g., @Configuration classes). All of the
      ContextLoader implementations used to provide this support load a
      GenericApplicationContext. However, a GenericApplicationContext is not
      suitable for testing a web application since a web application relies on
      an implementation of WebApplicationContext (WAC).
      
      This commit makes it possible to integration test Spring-powered web
      applications by adding the following functionality to the Spring
      TestContext Framework.
      
       - Introduced AbstractGenericWebContextLoader and two concrete
         subclasses:
         - XmlWebContextLoader
         - AnnotationConfigWebContextLoader
      
       - Pulled up prepareContext(context, mergedConfig) from
         AbstractGenericContextLoader into AbstractContextLoader to allow it
         to be shared across web and non-web context loaders.
      
       - Introduced AnnotationConfigContextLoaderUtils and refactored
         AnnotationConfigContextLoader accordingly. These utils are also used
         by AnnotationConfigWebContextLoader.
      
       - Introduced a new @WebAppConfiguration annotation to denote that the
         ApplicationContext loaded for a test should be a WAC and to configure
         the base resource path for the root directory of a web application.
      
       - Introduced WebMergedContextConfiguration which extends
         MergedContextConfiguration with support for a baseResourcePath for
         the root directory of a web application.
      
       - ContextLoaderUtils.buildMergedContextConfiguration() now builds a
         WebMergedContextConfiguration instead of a standard
         MergedContextConfiguration if @WebAppConfiguration is present on the
         test class.
      
       - Introduced a configureWebResources() method in
         AbstractGenericWebContextLoader that is responsible for creating a
         MockServletContext with a proper ResourceLoader for the
         resourceBasePath configured in the WebMergedContextConfiguration. The
         resulting mock ServletContext is set in the WAC, and the WAC is
         stored as the Root WAC in the ServletContext.
      
       - Introduced a WebTestExecutionListener that sets up default thread
         local state via RequestContextHolder before each test method by using
         the MockServletContext already present in the WAC and by creating a
         MockHttpServletRequest, MockHttpServletResponse, and
         ServletWebRequest that is set in the RequestContextHolder. WTEL also
         ensures that the MockHttpServletResponse and ServletWebRequest can be
         injected into the test instance (e.g., via @Autowired) and cleans up
         thread locals after each test method.
      
       - WebTestExecutionListener is configured as a default
         TestExecutionListener before DependencyInjectionTestExecutionListener
      
       - Extracted AbstractDelegatingSmartContextLoader from
         DelegatingSmartContextLoader and introduced a new
         WebDelegatingSmartContextLoader.
      
       - ContextLoaderUtils now selects the default delegating ContextLoader
         class name based on the presence of @WebAppConfiguration on the test
         class.
      
       - Tests in the spring-test-mvc module no longer use a custom
         ContextLoader to load a WebApplicationContext. Instead, they now
         rely on new core functionality provided in this commit.
      
      Issue: SPR-5243
      a73280cc
  12. 31 1月, 2012 1 次提交
    • C
      Rename modules {org.springframework.*=>spring-*} · 02a4473c
      Chris Beams 提交于
      This renaming more intuitively expresses the relationship between
      subprojects and the JAR artifacts they produce.
      
      Tracking history across these renames is possible, but it requires
      use of the --follow flag to `git log`, for example
      
          $ git log spring-aop/src/main/java/org/springframework/aop/Advisor.java
      
      will show history up until the renaming event, where
      
          $ git log --follow spring-aop/src/main/java/org/springframework/aop/Advisor.java
      
      will show history for all changes to the file, before and after the
      renaming.
      
      See http://chrisbeams.com/git-diff-across-renamed-directories
      02a4473c
  13. 21 8月, 2011 1 次提交
  14. 13 8月, 2011 1 次提交
    • S
      [SPR-8386][SPR-8387] Redesign of DelegatingSmartContextLoader and the SmartContextLoader SPI: · a298c2dd
      Sam Brannen 提交于
      - Removed generatesDefaults() and supports() from the SmartContextLoader SPI and modified the DelegatingSmartContextLoader algorithm accordingly.
      - DelegatingSmartContextLoader no longer operates on a list of candidate loaders but rather on explicit instances of GenericXmlContextLoader and AnnotationConfigContextLoader.
      - Updated Javadoc regarding DelegatingSmartContextLoader as the new default loader.
      - Updated and polished Javadoc regarding changes in 3.1.
      - Now enforcing @ContextConfiguration's restriction on declaring locations or classes but not both.
      a298c2dd
  15. 21 7月, 2011 1 次提交
  16. 18 6月, 2011 1 次提交
    • S
      [SPR-8386] SmartContextLoader enhancements: · 9a56deb2
      Sam Brannen 提交于
      - introduced processContextConfigurationAttributes() method in SmartContextLoader SPI
      - refactored AnnotationConfigContextLoader, AbstractContextLoader, AbstractGenericContextLoader, ContextLoaderUtils, and TestContext implementations to take advantage of the SmartContextLoader SPI, MergedContextConfiguration, and ContextConfigurationAttributes
      - deleted ResourceTypeAwareContextLoader
      - deleted ContextLoaderUtils.LocationsResolver and implementations
      - moved context key generation from TestContext to MergedContextConfiguration
      9a56deb2
  17. 04 6月, 2011 1 次提交
  18. 03 6月, 2011 1 次提交
    • S
      [SPR-7960][SPR-8386] Supporting declarative configuration of bean definition... · 2913964b
      Sam Brannen 提交于
      [SPR-7960][SPR-8386] Supporting declarative configuration of bean definition profiles in the TestContext framework:
      - TextContext now works with MergedContextConfiguration instead of locations and loader
      - TextContext now builds context caching key from MergedContextConfiguration
      - Test context caching is now based on locations, classes, active profiles, and context loader
      - TextContext now delegates to SmartContextLoader or ContextLoader as appropriate
      - AbstractContextLoader now implements SmartContextLoader
      - AbstractGenericContextLoader now sets active profiles in the GenericApplicationContext 
      - Introduced integration tests for profile support in the TCF for both XML and annotation config
      2913964b
  19. 04 4月, 2011 2 次提交
  20. 03 4月, 2011 3 次提交
  21. 30 3月, 2011 1 次提交
  22. 13 9月, 2009 1 次提交
  23. 20 7月, 2009 2 次提交
  24. 05 5月, 2009 1 次提交
  25. 03 5月, 2009 1 次提交
  26. 20 11月, 2008 1 次提交
  27. 27 10月, 2008 1 次提交