This commit takes rfc8297 into account and introduces a newer code 103
HttpStatus value which uses `Early Hints` as the more correct reason
phrase, deprecating the outdated `CHECKPOINT` enum value for 103.
Additionally:
- `HttpStatus.valueOf(103)` will return the new enum value
- `HttpStatusCode#isSameCodeAs(HttpStatusCode)` is introduced to ease
comparison of deprecated enums vs their newer counterparts (or any
instance of a more generic `HttpStatusCode`) by comparing the integer
`value()`
- `HttpStatusTests` covers the new deprecation as well as the three
previously deprecated codes, including a check with the above new
method to ensure they have comparable integer values
Supersedes and Closes gh-27960
As the DSL internally calls `ResultActions.andExpect`, this is done with
a trick where a synthetic `ResultActions` is provided at top level which
stores each `ResultMatcher` in a mutable list.
Once the DSL usage is done, the top level DSL `andExpectAll` turns that
list into a `vararg` passed down to the actual `actions.andExpectAll`.
Closes gh-27317
This commit introduces additional constructors in MockClientHttpRequest
and MockClientHttpResponse that were previously only present in the
internal "test fixtures" in spring-web.
This commit also aligns the mocks in spring-test with the test fixtures
in spring-web to simplify continued maintenance of the mocks and test
fixtures.
Closes gh-29670
Prior to this commit, if AOT processing of a test's ApplicationContext
failed, the TestContext Framework (TCF) still attempted to load the
context via standard (JVM) mechanisms when running in AOT mode.
For example, if a test class uses Spring Boot's @MockBean, AOT
processing of that test's context will fail with a WARN log message,
and there will no mapping from that test class to an AOT-generated
ApplicationContextInitializer (ACI). Consequently, when the test suite
is run in AOT mode that particular test class will currently fail with
a confusing stack trace due to the fact that Spring Boot's
SpringApplication attempts to locate a "main" ACI instead of the
missing "test" ACI (missing because it was not generated during AOT
processing).
In general, the TCF should not attempt to load an ApplicationContext in
"JVM mode" while running in "AOT mode".
This commit therefore reworks the logic in
DefaultCacheAwareContextLoaderDelegate to fail fast (with a meaningful
error message) if an AOT-generated ACI cannot be found while running in
AOT mode. This avoids the aforementioned confusion when @MockBean tests
fail in AOT mode (on the JVM or within a native image), and it also
helps to diagnose build problems if AOT processing has not yet been
performed for the project's test suite.
Closes gh-29579
SocketUtils was officially deprecated in 5.3.16 (gh-28052) and removed
in 6.0 M3 (gh-28054); however, there is still need for a subset of this
functionality in integration tests for testing scenarios in which it is
not possible for the system under test to select its own random port
(or rely on the operating system to provide an ephemeral port).
This commit therefore introduces a scaled down version in the
spring-test module called TestSocketUtils which supports retrieval of a
single TCP port.
See gh-29132
Prior to this commit, it was possible to register hints for individual
test classes programmatically via the
org.springframework.test.context.aot.TestRuntimeHintsRegistrar SPI;
however, that requires that a custom TestRuntimeHintsRegistrar be
registered via "META-INF/spring/aot.factories". In addition,
implementing a TestRuntimeHintsRegistrar is more cumbersome than using
the core mechanisms such as @Reflective, @ImportRuntimeHints, and
@RegisterReflectionForBinding.
This commit address this by introducing support for @Reflective and
@ImportRuntimeHints on test classes. @RegisterReflectionForBinding
support is available automatically since it is an extension of the
@Reflective mechanism.
Closes gh-29455
- Remove final modifier from private method
- Use StandardCharsets
- Remove unnecessary toString calls
- Remove unnecessary static modifiers
- Refactor to use enhanced switch
- Replace concatenated strings with text blocks
- Rely on auto-boxing where appropriate
- Remove unnecessary code
- Fix imports in Kotlin test classes
Closes gh-29413
This commit reverts changes to AbstractCacheManager since iterating
over the caches in a for-loop and a stream is duplicated effort.
This commit reverts changes to DefaultRenderingResponseBuilder,
RouterFunctions, and OriginHandshakeInterceptor since order matters for
those use cases: they were originally based on the semantics of
LinkedHashSet or LinkedHashMap; whereas, Set.copyOf() and Map.copyOf()
do not provide any guarantees regarding ordering.
This commit also applies analogous changes to "sibling" implementations
across Servlet mocks as well as Web MVC and WebFlux.
See gh-29321
Includes corresponding build upgrade to Tomcat 10.1.1 and Undertow 2.3.0
(while retaining runtime compatibility with Tomcat 10.0 and Undertow 2.2)
Closes gh-29435
Closes gh-29436