1. 28 10月, 2013 1 次提交
    • S
      Provide meta-annotation support in the TCF · 5e7021f3
      Sam Brannen 提交于
      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.
      
      The following is a summary of the major changes included in this commit.
      
      - 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.
      - AnnotationUtils.findAnnotationDeclaringClass() and
        AnnotationUtils.findAnnotationDeclaringClassForTypes() now support
        meta annotations.
      - Introduced MetaAnnotationUtils and AnnotationDescriptor in the
        spring-test module.
      - Introduced UntypedAnnotationDescriptor in MetaAnnotationUtils.
      - Introduced findAnnotationDescriptorForTypes() in MetaAnnotationUtils.
      - ContextLoaderUtils now uses MetaAnnotationUtils for looking up
        @ActiveProfiles as a potential meta-annotation.
      - TestContextManager now uses MetaAnnotationUtils for looking up
        @TestExecutionListeners as a potential meta-annotation.
      - DirtiesContextTestExecutionListener now uses AnnotationUtils for
        looking up @DirtiesContext as a potential meta-annotation.
      - Introduced DirtiesContextTestExecutionListenerTests.
      - ProfileValueUtils now uses AnnotationUtils for looking up
        @IfProfileValue and @ProfileValueSourceConfiguration as potential
        meta-annotations.
      - @BeforeTransaction and @AfterTransaction now support ANNOTATION_TYPE
        as a target, allowing them to be used as meta-annotations.
      - TransactionalTestExecutionListener now uses AnnotationUtils for
        looking up @BeforeTransaction, @AfterTransaction, @Rollback, and
        @TransactionConfiguration as potential meta-annotations.
      - Introduced TransactionalTestExecutionListenerTests.
      - @Repeat and @Timed now support ANNOTATION_TYPE as a target, allowing
        them to be used as meta-annotations.
      - SpringJUnit4ClassRunner now uses AnnotationUtils for looking up
        @Repeat and @Timed as potential meta-annotations.
      - Moved all remaining logic for building the MergedContextConfiguration
        from the DefaultTestContext constructor to
        ContextLoaderUtils.buildMergedContextConfiguration().
      - Verified meta-annotation support for @WebAppConfiguration and
        @ContextConfiguration.
      
      Issue: SPR-7827
      5e7021f3
  2. 27 10月, 2013 1 次提交
  3. 26 10月, 2013 2 次提交
    • P
      Add getSource() to ResolvableType & TypeDescriptor · e80b7d1e
      Phillip Webb 提交于
      Add getSource() method to ResolvableType and TypeDescriptor allowing
      access to the underlying source field or method parameter when possible.
      
      Primarily added to provide access to additional type information or
      meta-data that alternative JVM languages may provide.
      
      Issue: SPR-10887
      e80b7d1e
    • P
      Restore prior resolveTypeArguments behavior · 1a3ba790
      Phillip Webb 提交于
      Restore prior behavior of GenericTypeResolver.resolveTypeArguments to
      never include null elements in the returned array.
      
      Issue: SPR-11030
      1a3ba790
  4. 25 10月, 2013 1 次提交
    • J
      Accept non-generic type match as a fallback · 08517667
      Juergen Hoeller 提交于
      DefaultListableBeanFactory performs a fallback check for autowire candidates now, which GenericTypeAwareAutowireCandidateResolver implements to accept raw type matches if the target class has unresolvable type variables. Full generic matches are still preferred; the BeanFactory will only start looking for fallback matches if the first pass led to an empty result.
      
      Issue: SPR-10993
      Issue: SPR-11004
      08517667
  5. 23 10月, 2013 1 次提交
    • P
      Add @PropertySources and ignoreResourceNotFound · e95bd9e2
      Phillip Webb 提交于
      Support repeatable @PropertySource annotations in Java 8 and add
      @PropertySources container annotation for Java 6/7. Also add an
      ignoreResourceNotFound attribute to @PropertySource allowing missing
      property resources to be silently ignored.
      
      This commit also introduces some generally useful methods to
      AnnotationUtils for working with @Repeatable annotations.
      
      Issue: SPR-8371
      e95bd9e2
  6. 22 10月, 2013 2 次提交
    • R
      Integrate suggested support for creating MVC URLs · bafc73f1
      Rossen Stoyanchev 提交于
      The key contract is MvcUrls. An instance is automatically created with
      the Spring MVC namespace and the MVC Java config but can also be easily
      created in any configuration.
      
      Some example tests can be found in DefaultMvcUrlsTests.
      
      Issue: SPR-10665, SPR-8826
      bafc73f1
    • O
      Introduced MvcUriComponentsBuilder to create URIs pointing to controller methods. · 4fd27b12
      Oliver Gierke 提交于
      MvcUriComponentsBuilder allows creating URIs that point to Spring MVC
      controller methods annotated with @RequestMapping. It builds them by
      exposing a mock method invocation API similar to Mockito, records the
      method invocations and thus builds up the URI by inspecting the mapping
      annotations and the parameters handed into the method invocations.
      
      Introduced a new SPI UriComponentsContributor that should be implemented 
      by HandlerMethodArgumentResolvers that actually contribute path segments 
      or query parameters to a URI. While the newly introduced 
      MvcUriComponentsBuilder looks up those UriComponentsContributor instances 
      from the MVC configuration.
      
      The MvcUriComponentsBuilderFactory (name to be discussed - MvcUris maybe?) 
      prevents the multiple lookups by keeping the UriComponentsBuilder 
      instances in an instance variable. So an instance of the factory could 
      be exposed as Spring bean or through a HandlerMethodArgumentResolver to 
      be injected into Controller methods.
      
      Issue: SPR-10665, SPR-8826
      4fd27b12
  7. 19 10月, 2013 1 次提交
  8. 18 10月, 2013 2 次提交
  9. 17 10月, 2013 1 次提交
    • P
      Refine ResolvableType class · 3337fd32
      Phillip Webb 提交于
      - Support for serialization
      - Allow programmatic creation of an array from a given component type
      - Allow programmatic creation with given generics
      - Extract generics from Class types using Class.getTypeParameters()
      - Move TypeVariableResolver to an inner class (and make method private)
      - Refine 'resolve()' algorithm
      
      Issue: SPR-10973
      3337fd32
  10. 15 10月, 2013 2 次提交
    • J
      Autowiring of generic types · 3bd6dfe0
      Juergen Hoeller 提交于
      Includes revisions of MethodParameter and DependencyDescriptor (in particular towards a reference to the containing class). Also refines several ResolvableType method signatures.
      
      Issue: SPR-9965
      3bd6dfe0
    • J
      Fixed type prediction for generic factory methods · 8b1927f3
      Juergen Hoeller 提交于
      We're consistently resolving class names now, and the entire algorithm moved from GenericTypeResolver to the internal AutowireUtils helper in the bean factory package.
      
      Issue: SPR-10411
      8b1927f3
  11. 11 10月, 2013 1 次提交
  12. 10 10月, 2013 3 次提交
    • P
      Refactor from deprecated GenericTypeResolver calls · 501a1cbb
      Phillip Webb 提交于
      Refactor AbstractMessageConverterMethodArgumentResolver and
      BridgeMethodResolver to use ResolvableType in preference to deprecated
      GenericTypeResolver calls.
      
      Issue: SPR-10980
      501a1cbb
    • P
      Use ResolvableType in GenericTypeResolver · 595efe9a
      Phillip Webb 提交于
      Refactor GenericTypeResolver to make use of ResolvableType
      for generic resolution.
      
      Issue: SPR-10978
      595efe9a
    • P
      Introduce ResolvableType Class · 6a18b004
      Phillip Webb 提交于
      Add a new ResolvableType Class which encapsulates java.lang.reflect.Type,
      providing access to supertypes, interfaces and generic parameters along
      with the ability to ultimately resolve to a java.lang.Class.
      
      ResolvableTypes may be obtained from fields, method parameters, method
      returns, classes or directly from a java.lang.reflect.Type. Most methods
      will themselves return ResolvableTypes, allowing easy navigation.
      
      For example:
      
      	private HashMap<Integer, List<String>> myMap;
      
      	public void example() {
       		ResolvableType t = ResolvableType.forField(
       					getClass().getDeclaredField("myMap"));
       		t.getSuperType(); // AbstractMap<Integer, List<String>>;
       		t.asMap(); // Map<Integer, List<String>>
       		t.getGeneric(0).resolve(); // Integer
       		t.getGeneric(1).resolve(); // List
       		t.getGeneric(1); // List<String>
       		t.resolveGeneric(1, 0); // String
       	}
      
      Issue: SPR-10973
      6a18b004
  13. 28 9月, 2013 1 次提交
  14. 14 9月, 2013 1 次提交
  15. 30 8月, 2013 2 次提交
  16. 21 8月, 2013 1 次提交
  17. 31 7月, 2013 1 次提交
  18. 24 7月, 2013 3 次提交
  19. 02 7月, 2013 1 次提交
    • P
      Add ConversionService support for ByteBuffers · 9dba73df
      Phillip Webb 提交于
      Add ByteBufferConverter that is registered by default with the
      DefaultConversionService. Allows conversion from/to a ByteBuffer and
      byte[] or to any type that can be converted via a byte[].
      
      Issue: SPR-10712
      9dba73df
  20. 09 6月, 2013 1 次提交
  21. 04 6月, 2013 1 次提交
    • P
      Introduce java.nio.file.Path based Resource · 2313c9a0
      Philippe Marschall 提交于
      Develop new org.springframework.core.io.Resource implementation
      backed by java.nio.file.Path. Primarily developed to allow custom
      file system implementations to be used with Spring.
      
      Since the minimum requirement for Spring is still Java 6 the
      existing FileSystemResource can't be retrofitted (and no #getPath
      method can be added to the Resource interface).
      
      Unlike FileSystemResource, PathResource delegates to the underlying
      file system instead of StringUtils. It has therefore slightly
      different semantics. First, when building relative resources via
      createRelative the relative path will apply to this path (like URL or
      Unix). Second, equality is delegated to the underlying file system
      provider so it's case-insensitive on Windows.
      
      Issue: SPR-10608
      2313c9a0
  22. 28 5月, 2013 2 次提交
    • C
      Polish pull request #291 per committer guidelines · 46d47fef
      Chris Beams 提交于
       - Update Apache license headers
       - Remove trailing whitespace
       - Edit original commit comment to use 'Issue:' syntax
       - Revert use of diamond operator (<>) in main sources
      
      See committer guidelines at
      https://github.com/SpringSource/spring-framework/blob/master/CONTRIBUTING.md
      
      Issue: SPR-10579
      46d47fef
    • D
      Make CommandLinePropertySource enumerable · 7860af86
      Dave Syer 提交于
      JOpt 4.4 has enumerable options, so this change can be made
      if we upgrade. The only awkward thing is that JOpt allows
      aliases for options, so we have to pick one to avoid double
      counting. This implementation picks the last one in the list
      which is the alphebtically last of the long options, if there
      are any (e.g. "o1", "option1" returns "option1"). Most of the
      time there will only be one or two aliases for each option so
      it won't matter.
      
      Issue: SPR-10579
      7860af86
  23. 17 5月, 2013 1 次提交
  24. 14 5月, 2013 2 次提交
  25. 09 5月, 2013 1 次提交
    • P
      Extend AnnotationMetadata and MethodMetadata · 8e445f3a
      Phillip Webb 提交于
      Update AnnotationMetadata and MethodMetadata to extend from a new
      AnnotatedTypeMetadata base interface containing the methods that are
      common to both. Also introduce new getAllAnnotationAttributes methods
      providing MultiValueMap access to both annotation and meta-annotation
      attributes.
      
      Existing classreading and standard implementations have been
      refactored to support the new interface.
      8e445f3a
  26. 29 3月, 2013 1 次提交
  27. 20 3月, 2013 1 次提交
  28. 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
  29. 26 2月, 2013 1 次提交
    • P
      StringToEnumConverterFactory class from enum value · 9a6c6b9e
      Phillip Webb 提交于
      Update StringToEnumConverterFactory to search superclasses until
      Class.isEnum() returns true. This allows conversion when the
      enum class is obtained from the enum value:
      
          public static enum SubFoo {
              BAR { String s() { return "x"; } };
              abstract String s();
          }
      
          conversionService.convert("BAR", SubFoo.BAR.getClass())
      
      This fix is particularly important when converting collections of
      enums.
      
      Issue: SPR-10329
      9a6c6b9e