Prior to this commit, several of the methods in XpathRequestMatchers
declared unused type parameters (e.g., <T>). This was obviously the
result of copying an existing method that actually needs the type
parameter for proper casting.
For example, the following ...
public <T> RequestMatcher exists() {
// ...
}
... should actually be declared without <T>, since T is not used in the
implementation or in the return type:
public RequestMatcher exists() {
// ...
}
This commit removes all unused type parameter declarations in
XpathRequestMatchers.
Side Effects:
Now that we have removed the unused type parameter declarations, users
will see the following side effects if they had previously declared a
type argument when invoking such methods.
- Java: an "Unused type arguments for the non generic method ..."
warning will be generated by the compiler, but the code will continue
to work unmodified.
- Kotlin: a "Type inference failed: Not enough information to infer
parameter T in fun ..." compiler error will be raised, causing the
code to no longer compile (see
https://youtrack.jetbrains.com/issue/KT-5464). Removal of the type
argument declaration will allow the code to work correctly again.
Closes gh-23860
Prior to this commit, several of the ResultMatcher methods used in
MockMvc declared unused type parameters (e.g., <T>). This was obviously
the result of copying an existing method that actually needs the type
parameter for proper casting.
For example, the following in RequestResultMatchers ...
public <T> ResultMatcher attribute(String name, Object expectedValue) {
// ...
}
... should actually be declared without <T>, since T is not used in the
implementation or in the return type:
public ResultMatcher attribute(String name, Object expectedValue) {
// ...
}
This commit removes all unused type parameter declarations in MockMvc
result matchers.
Side Effects:
Now that we have removed the unused type parameter declarations, users
will see the following side effects if they had previously declared a
type argument when invoking such methods.
- Java: an "Unused type arguments for the non generic method ..."
warning will be generated by the compiler, but the code will continue
to work unmodified.
- Kotlin: a "Type inference failed: Not enough information to infer
parameter T in fun ..." compiler error will be raised, causing the
code to no longer compile (see
https://youtrack.jetbrains.com/issue/KT-5464). Removal of the type
argument declaration will allow the code to work correctly again.
Closes gh-23858
The new sessionAttributeDoesNotExist() method introduced in commit
e73344fc71 declares an unused type
parameter <T>.
This commit removes that unused type parameter from the method
signature.
See gh-23756
Analogous to the attributeDoesNotExist() method in ModelResultMatchers,
this commit introduces a new sessionAttributeDoesNotExist() method in
RequestResultMatchers which asserts that the given attributes are null
in the HttpSession.
Closes gh-23756
Spring Framework 5.2 introduced an EventPublishingTestExecutionListener
in the Spring TestContext Framework. This listener is automatically
registered via the spring.factories mechanism; however, this listener is
not registered in the abstract JUnit 4 and TestNG base classes.
This commit addresses this oversight by explicitly registering the
EventPublishingTestExecutionListener in the following classes.
- AbstractJUnit4SpringContextTests
- AbstractTransactionalJUnit4SpringContextTests
- AbstractTestNGSpringContextTests
- AbstractTransactionalTestNGSpringContextTests
Closes gh-23748
This commit renames the Runnable variant to executeWithoutResult
and uses a Consumer<TransactionStatus> parameter for better
consistency with TransactionCallbackWithoutResult.
Closes gh-23724
Prior to this commit, one could not test for the absence of a specific
HTTP header in a request.
This commit adds a headerDoesNotExist() method in MockRestRequestMatchers.
Closes gh-23721
Bypass server cookie and write Set-Cookie header directly for Reactor
Netty, and Servlet API which do not provide options.
For Undertow use the sameSite attribute.
Closes gh-23693
Spring Framework 5.2 M1 introduced a memory leak for applications using
@Async methods. Specifically, in a large test suite with multiple
ApplicationContexts that were closed (e.g., via @DirtiesContext,
@MockBean, or context cache eviction), the JVM process could run out of
memory.
Underlying cause: Due to a missing equals() implementation in Spring's
new AnnotationCandidateClassFilter, CGLIB's static cache of generated
classes indirectly retained references to BeanFactory instances for the
closed ApplicationContexts for the duration of the test suite.
This commit fixes this regression by introducing a proper equals()
implementation in AnnotationCandidateClassFilter. This commit also
introduces corresponding hashCode() and toString() implementations.
Closes gh-23571
This commit renames Spr3896SuiteTests to comply with our naming
convention for test classes that should be executed via the Gradle
build.
The effect of this commit is that test classes included in that "suite"
are no longer executed twice in the build. Consequently, Gradle and
Bamboo will now report the same number of executed tests for the
spring-test project.
Prior to this commit, the Spring Framework build would partially use the
dependency management plugin to import and enforce BOMs.
This commit applies the dependency management plugin to all Java
projects and regroups all version management declaration in the root
`build.gradle` file (versions and exclusions).
Some versions are overridden in specific modules for
backwards-compatibility reasons or extended support.
This commit also adds the Gradle versions plugin that checks for
dependency upgrades in artifact repositories and produces a report; you
can use the following:
./gradlew dependencyUpdates
Prior to this commit, it was impossible to include a placeholder (i.e.,
${placeholder.name}) in a Properties file location configured via
@TestPropertySource if the placeholder was immediately followed by a
relative path (i.e., "../"). This was due to the fact that the location
was always cleaned using StringUtils.cleanPath(), which removed the
placeholder and the relative path syntax.
This commit fixes this by preserving all placeholders in
@TestPropertySource locations by simply not cleaning the locations if
they contain placeholders.
Closes gh-23544
This commit ensures that locations to resources configured via
@ContextConfiguration & @TestPropertySource are consistently cleaned
using StringUtils.clean().
See gh-23544
This commit introduces a collection of @Nested integration tests that
verify proper support for @TestPropertySource with explicit properties
files declared with absolute paths, relative paths, and placeholders in
the classpath and in the file system.
See gh-23544