Rename `ApplicationContextTester` and related classes to
`ApplicationContextRunner` and refactor existing tests to use correctly
named variables.
See gh-9875
Previously, JsonContentAssert returns AbstractMapAssert from
extractingJsonPathMapValue. This could lead to type safety warnings
when calling one of the assert's methods with a generic varargs
parameter such as
contains(Entry<? extends Object, ? extends Object>...).
This commit replaces the use of both AbstractMapAssert and
AbstractListAssert with MapAssert and ListAssert respectively. These
classes use final methods and @SafeVargs args to prevent the
above-described problem from occurring.
See gh-9675
Rename `ContextLoader` to `ApplicationContextTester` and provide
distinct subclasses for standard, web and reactive application contexts.
Context callbacks now return AssertJ compatible contexts, allowing
tests to run directly on context. For example:
context.run((loaded) -> assertThat(loaded).hasBean("foo"));
The returned context can now also represent a context that has failed
to start (meaning that the `loadAndFail` methods are no longer needed):
context.run((loaded) -> assertThat(loaded).hasFailed());
Configuration classes are loaded via the recently introduced
`Configurations` class. This means that the tester no longer needs to
be directly aware of auto-configuration concepts.
See gh-9634
Update `TestPropertyValues` so that it can also be used to update
system properties. Properties are set before the call is made and
restored to their previous value afterwards.
Fixes gh-9792
This commit applies what's been done in gh-9166 for WebFlux client and
server, but for the `WebTestClient` auto-configuration.
`WebTestClient` can be configured for mock or integration tests and this
change applies `CodecCustomizer` beans to the client being built.
Closes gh-9577
This commit adds ContextLoader, a test helper that configures an
ApplicationContext that is meant to simulate a particular
auto-configuration scenario.
The auto-configuration, user configuration and environment can be
customized. The loader invokes a ContextConsumer to assert the context
and automatically close the context once it is done.
Concretely, tests can create a shared field instance of that helper with
the shared configuration to increase its visibility and tune the context
further in each test.
If the context is expected to fail, `loadAndFail` allows to optionally
assert the root exception and consume it for further assertions.
This commit also migrates some tests to illustrate the practical use of
the helper
Closes gh-9634
Remove test-jar artifacts from Maven projects and relocate classes. The
majority of utilities now live in the `spring-boot-testsupport` module.
This update will help us to deploy artifacts using the standard Maven
deploy plugin in the future (which doesn't support the filtering of
individual artifacts).
Fixes gh-9493