This commit makes several methods of TestContext non-final in order to
allow TestContext to be mocked — for example with Mockito.
Note, however, that TestContext has been converted to an interface in
Spring Framework 4.0.
Issue: SPR-11144
This commit fixes a bug introduced in the last commit.
ServletTestExecutionListener (STEL) now tracks whether it has already
populated the RequestContextHolder.
Issue: SPR-11144
Backport-Commit: 800018a817
The previous commit for issue SPR-11144 revealed a bug in
ServletTestExecutionListener (STEL). Specifically, STEL acted on the
fact that the ApplicationContext for a given TestContext was an
instance of WebApplicationContext. This behavior could potentially
break test code from previous releases of the Spring Framework that
relied on a custom setup of the RequestAttributes in the
RequestContextHolder with a custom WebApplicationContext ContextLoader.
This commit addresses this issue by ensuring that STEL only comes into
play if the test class is annotated with @WebAppConfiguration (for
prepareTestInstance() and beforeTestMethod()) or if the TestContext
attribute named RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE is set to
Boolean.TRUE (for afterTestMethod()).
Issue: SPR-11144
Backport-Commit: 099b10d23b
Specifically, read and write methods are allowed to express property types with superclass/subclass relationships in both directions now.
Issue: SPR-11139
(cherry picked from commit cb624e2)
Our per-bean caching in AutowiredAnnotationBeanPostProcessor and co relies on unique bean names, so this change fixes potential cache mismatch problems occuring there.
Issue: SPR-11131
(cherry picked from commit 242ecdc)
Prior to this commit, the ServletTestExecutionListener did not
overwrite RequestAttributes in the RequestContextHolder if the
ApplicationContext associated with the given TestContext was not a
WebApplicationContext; however, the ServletTestExecutionListener would
clear the RequestAttributes after every test method execution,
regardless of whether the context was a WebApplicationContext or not.
This behavior breaks backwards compatibility with integration tests
that managed the RequestAttributes in RequestContextHolder themselves.
This commit addresses this issue by introducing a TestContext attribute
named RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE in
ServletTestExecutionListener. This attribute is used internally within
ServletTestExecutionListener to ensure that the RequestContextHolder is
only cleared (i.e., reset) if the ServletTestExecutionListener actually
populated the RequestContextHolder.
Issue: SPR-11144
Backport-Commit: a3b022aa48
Fix regression introduced in b25e91a5 where ReflectivePropertyAccessor
does not consider the return type for "is" getters.
Issue: SPR-11142
(cherry picked from commit 85b0bfff)
Fix CacheAspectSupport to consider a cache hit from any of the multiple
@Cachables that may have been specified using the @Caching annotation.
Prior to this commit the following scenario would never produce a hit:
@Caching(cacheable = {
@Cacheable(value = "c1", unless = "#result.size() < 4"),
@Cacheable(value = "c2", unless = "#result.size() > 3")
})
Issue: SPR-11124