`

ReflectionTestUtils

    博客分类:
  • Java
 
阅读更多
Open Declarationorg.springframework.test.util.ReflectionTestUtils

 

ReflectionTestUtils is a collection of reflection-based utility methods for use in unit and integration testing scenarios.

There are often times when it would be beneficial to be able to set a non-public field, invoke a non-public setter method, or invoke a non-public configuration or lifecycle callback method when testing code involving, for example:

  • ORM frameworks such as JPA and Hibernate which condone the usage of private or protected field access as opposed to public setter methods for properties in a domain entity.
  • Spring's support for annotations such as @Autowired and @Resource which provides dependency injection for private or protected fields, setter methods, and configuration methods.
  • Use of annotations such as @PostConstruct and @PreDestroy for lifecycle callback methods.
Since:
2.5
Author:
Sam Brannen
Juergen Hoeller
See Also:
ReflectionUtils
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics