As of Spring Framework 5.1, we're depending on the Reactor Californium
release train.
Reactor Netty is now at version 0.8 and changed its artifact
coordinates, package names and broke several APIs. Spring Framework is
now up-to-date with those changes and this commit does the same for
Spring Boot.
Note that in that process, the `NettyServerCustomizer` has been changed
since the former `HttpServerOptions.Builder` API is now gone from
Reactor Netty, and we're now relying on immutable server instances
instead of a stateful builder pattern.
See gh-13321
This commit changes invocations to immediately return the expression
instead of assigning it to a temporary variable. The method name should
be sufficient for callers to know exactly what will be returned.
Closes gh-12211
This commit fixes two issues in `TestRestTemplate`:
* it improves the detection of the underlying request factory, using
reflection to look inside the intercepting request factory if
interceptors were configured
* it avoids reusing the same request factory when creating a new
`TestRestTemplate` with `withBasicAuth`. Sharing the same instance would
result in sharing authentication state (HTTP cookies). Since the
original request factory can't be detected consistently, a new one is
selected automatically
See gh-8697
Previously `TestRestTemplate` would override the configured
`ClientHttpRequestFactory` if the Apache HTTP client library was on
classpath.
This commit fixes two issues:
1. The existing `ClientHttpRequestFactory` is overridden *only* if it is
using the Apache HTTP client variant, in order to wrap it with the
`TestRestTemplate` custom support
2. Calling `withBasicAuth` will no longer directly use the request
factory returned by the internal `RestTemplate`; if client interceptors
are configured, the request factory is wrapped with an
`InterceptingClientHttpRequestFactory`. If we don't unwrap it,
interceptors are copied/applied twice in the newly created
`TestRestTemplate` instance. For that, we need to use reflection as the
underlying request factory is not accessible directly.
Closes gh-8697
Update `ApplicationContextAssert` with support for scopes. Allows
tests to consider the all ancestors, or limit assertions to just the
current context.
Fixes gh-12015
As discussed in gh-11872, `TestRestTemplate` constructor variants taking
a `RestTemplate` argument are confusing since the main goal of that
class is to mutate `RestTemplate`.
This commit removes all those constructor variants and replaces them
with `RestTemplateBuilder` arguments when possible.
Closes gh-11872
By default, AbstractTestExecutionListeners have an order of lowest
precedence. This means that it is impossible to write a listener with
lower precedence that any listener that's using the default order.
This commit updates Boot's 6 AbstractTestExecutionListeners to order
them explicitly. MockitoTestExecutionListener performs injection of
Mockito mocks and spies into the test instance. It now has an order of
2050 giving it slightly lower precedence than the dependency injection
test execution listener (2000).
The remaining 5 listeners have all been ordered with lowest precedence
- 100. This leaves them near their current lowest precedence position
while creating some room for any listeners that require lower
precedence.
Closes gh-11796
Update `@SpringBootTest` `WebTestClient` support so that the bean
definition is only registered when the user has not defined or
auto-configured their own.
See gh-10556
Update `@SpringBootTest` `TestRestTemplate` support so that the bean
definition is only registered when the user has not defined or
auto-configured their own.
See gh-10556
Since type erasure can be fixed only when using
ParameterizedTypeReference based Java methods, TestRestTemplate
API documentation should be updated to specify which extensions
are subject to type erasure, and which are not.
Closes gh-11604
Prior to this change, the dash was duplicated. For example
"test--systemEnvironment". This commit removes the redundant dash
and corrects the assertion in the test that should have caught the
problem.
See gh-11156
This commit introduces Kotlin extensions similar to the RestOperations
ones in order to be able to take advantage of Kotlin reified type
parameters for example.
See gh-11039
Update `SpringConfigurationPropertySource` so that the
`SystemEnvironmentPropertyMapper` is only used for the "actual" system
environment property source. This allows SystemEnvironmentProperySource
class to be used for other purposes (for example, Spring Cloud uses it
to as an override source providing decryption).
Only property sources named `systemEnvironment` or ending with
`-systemEnvironment` now have the `SystemEnvironmentPropertyMapper`
applied. The `TestPropertyValues` has been retrofitted to name the
source it adds appropriately.
Fixes gh-10840
Refactor `ReactiveWebApplicationContext` implementations to align closer
with the `WebApplicationContext` implementations defined in
Spring Framework.
The following classes are now provided:
- `AnnotationConfigReactiveWebApplicationContext` -- A refreshable
reactive web context with support for `@Configuration` classes.
- `GenericReactiveWebApplicationContext` -- A non-refreshable reactive
GenericApplicationContext.
- `ReactiveWebServerApplicationContext` -- A non-refreshable reactive
GenericApplicationContext with support for server discovery.
- `AnnotationConfigReactiveWebServerApplicationContext` -- A
non-refreshable reactive `GenericApplicationContext` with support
for `@Configuration` classes and server discovery.
These classes roughly align to the following Servlet equivalents:
- `AnnotationConfigWebApplicationContext` (Spring Framework)
- `GenericWebApplicationContext` (Spring Framework)
- `ServletWebServerApplicationContext` (Spring Boot)
- `AnnotationConfigServletWebServerApplicationContext` (Spring Boot)
An additional `ConfigurableReactiveWebEnvironment` interface as also
been introduced, primarily for `@ConditionalOnWebApplication` to use.
Fixes gh-10852
Provide a `getEnvironment` method in `SpringBootContextLoader` to allow
specialized `ConfigurableEnvironment` implementations to be used.
Closes gh-10740
Previously, we relied on Mockito's internals to bypass any Spring AOP
proxy during verification of a spy. Thanks to a new API in Mockito,
we can replace the use of Mockito's internals with a
VerificationStartedListener. This listener changes Mockito's view of
the mock to be the ultimate target of the AOP proxy, i.e. to be the
actual Mockito-created spy, allowing Mockito's verification of the
spy to proceed successfully.
This above-described change will mean that we require a very
up-to-date version of Mockito so the tests that verify our
compatibility with 2.5 have been removed as we will no longer support
it when using @MockBean or @SpyBean.
Lastly, two tests have been updated to replace their usage of the
internal MockUtil class with the equivalent public API calls.
Closes gh-10352