Commit Graph

3166 Commits

Author SHA1 Message Date
Juergen Hoeller 83edf6a4aa Adapt test for MockServletContext version
See gh-35671
2025-10-21 01:07:03 +02:00
Juergen Hoeller 687fc935a8 Merge branch '6.2.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
#	spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java
#	spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockServletContext.java
2025-10-21 01:04:38 +02:00
Juergen Hoeller 7adcd99ea2 Polishing 2025-10-21 00:59:56 +02:00
Juergen Hoeller aa625f0ba9 Consistently declare Servlet mock classes with Servlet 6.1 baseline
Closes gh-35671
2025-10-21 00:43:28 +02:00
Juergen Hoeller 7ca2a5dec5 Early support for Jakarta Servlet 6.2 and Jakarta Activation 2.2
Closes gh-35670
2025-10-21 00:42:03 +02:00
Sam Brannen 687bc7652d Avoid unnecessary import for SpringExtension's Javadoc 2025-10-18 13:35:54 +02:00
Dónal Murtagh 22ecab5aab Fix code snippets in Javadoc for exchangeSuccessfully()
Closes gh-35642

Signed-off-by: Dónal Murtagh <donal.murtagh@clarusonesourcing.com>
2025-10-16 18:44:33 +02:00
Juergen Hoeller 2e4ca41382 Add getBeanProvider(ParameterizedTypeReference) overload
Closes gh-31444
2025-10-15 16:10:28 +02:00
rstoyanchev a78554eea6 Merge branch '6.2.x' 2025-10-14 16:50:53 +01:00
Edgar Asatryan 141df5291d Prevent NoClassDefFoundError when Jetty Reactive HttpClient not on classpath
Closes gh-35608

Signed-off-by: Edgar Asatryan <nstdio@gmail.com>
2025-10-14 16:49:10 +01:00
rstoyanchev 9a2bfeae2f AbstractMockHttpServletRequestBuilder exposes HttpHeaders
Closes gh-35576
2025-10-14 16:21:23 +01:00
rstoyanchev 9ed3c034f5 AbstractMockHttpServletRequestBuilder uses HttpHeaders internally
See gh-35576
2025-10-14 16:21:23 +01:00
rstoyanchev 00190a1111 Add exchangeSuccessfully to test clients
Closes gh-35582
2025-10-14 11:37:01 +01:00
rstoyanchev e0b8cb4fe2 Allow setting ApiVersionInserter to null
It should be possible to reset this, e.g. after call to mutate
a client or a test client.
2025-10-08 13:52:14 +01:00
rstoyanchev 03e379b070 Improve Javadoc for use of ApiVersionInserter
Closes gh-35565
2025-10-08 12:24:37 +01:00
rstoyanchev 00543becf8 Allow explicitly sending no API version
Closes gh-35566
2025-10-08 12:24:37 +01:00
rstoyanchev d057eb2e5d Improve converter config in RestTestClient.Builder
Compose consumers and apply them together from the build method
to allow multiple parties to supply consumers that collaborate
on the same HttpMessageConverters.Builder.

See gh-35578
2025-10-08 06:34:53 +01:00
rstoyanchev 451f2b5a90 Polishing in MockMvcClientHttpRequestFactory
Replace anonymous subclass with inner.
Simplify methods to adapt client-server request and response.
2025-10-08 06:34:53 +01:00
Sam Brannen 30db2e4fb5 Support Bean Overrides for non-singletons
Prior to this commit, the BeanOverrideBeanFactoryPostProcessor rejected
any attempt to override a non-singleton bean; however, due to interest
from the community, we have decided to provide support for overriding
non-singleton beans via the Bean Override mechanism — for example, when
using @⁠MockitoBean, @⁠MockitoSpyBean, and @⁠TestBean.

With this commit, we now support Bean Overrides for non-singletons: for
standard JVM runtimes as well as AOT processing and AOT runtimes. This
commit also documents that non-singletons will effectively be converted
to singletons when overridden and logs a warning similar to the
following.

WARN: BeanOverrideBeanFactoryPostProcessor - Converting 'prototype' scoped bean definition 'myBean' to a singleton.

See gh-33602
See gh-32933
See gh-33800
Closes gh-35574
2025-10-07 15:33:18 +02:00
Sam Brannen c6e5cfe03d Use consistent naming for Bean Override test classes 2025-10-06 15:26:51 +02:00
Stéphane Nicoll e91abd442a Simplify MockHttpServletRequestBuilders hierarchy
Closes gh-33231
2025-10-02 09:22:33 +02:00
rstoyanchev f071f95899 Merge branch '6.2.x' 2025-10-01 14:46:47 +01:00
rstoyanchev df860fd3cd Polishing contribution
Closes gh-35493
2025-10-01 14:45:18 +01:00
Réda Housni Alaoui 636523a2f5 AbstractMockHttpServletRequestBuilder#buildRequest is not idempotent
See gh-35493

Signed-off-by: Réda Housni Alaoui <reda-alaoui@hey.com>
2025-10-01 14:44:23 +01:00
Stéphane Nicoll a2c0e1cec8 Fix typos 2025-10-01 11:23:00 +02:00
Stéphane Nicoll 8cad5711f5 Add Kotlin extensions for RestTestClient
Closes gh-35558
2025-10-01 10:56:34 +02:00
Sam Brannen 7ba736dc06 Stop overriding default methods in TrackingTestNGTestListener
At some point, TestNG started implementing listener methods as interface
default methods, so we no longer need to override those methods with
empty implementations.
2025-09-26 14:56:03 +02:00
Sam Brannen 1b3aeba5ee Merge branch '6.2.x' 2025-09-25 17:55:22 +02:00
Sam Brannen 5cd2cb38e1 Make AbstractTestNGSpringContextTests thread-safe regarding tracked exceptions
Prior to this commit, AbstractTestNGSpringContextTests was not
thread-safe with regard to tracked exceptions.

To address that, AbstractTestNGSpringContextTests now tracks the test
exception via a ThreadLocal.

Closes gh-35528
2025-09-25 17:51:39 +02:00
Manu Sridharan e834a3a80c Nullability fixes for AtomicReference variables
Closes gh-35514
Signed-off-by: Manu Sridharan <msridhar@gmail.com>
2025-09-25 07:39:44 +02:00
Sam Brannen d84bf18408 Upgrade to JUnit 6.0 RC3
See gh-35124
2025-09-23 16:19:54 +02:00
Sébastien Deleuze 7635ac38f6 Use uppercase for classpath-related static final field names
Closes gh-35525
2025-09-22 18:32:14 +02:00
Sam Brannen 0c61ac956b Add missing @⁠Override annotations
... and suppress "serial" warnings
2025-09-22 13:20:37 +02:00
rstoyanchev 11dd0d6118 Provide access to raw content in RestTestClient
Closes gh-35399
2025-09-17 15:50:59 +01:00
Sébastien Deleuze da0a36bfd6 Upgrade to NullAway 0.12.10 and refine nullability
Closes gh-35492
2025-09-17 15:17:23 +02:00
rstoyanchev c7121d048c Replace X-API-Version with API-Version
Closes gh-35494
2025-09-17 11:48:49 +01:00
Sébastien Deleuze 7baf6d12b0 Merge branch '6.2.x' 2025-09-09 11:28:09 +02:00
Sébastien Deleuze 9e8c64011d Make JsonPathAssertions#isEqualTo parameter nullable
Closes gh-35445
2025-09-09 11:25:58 +02:00
Sam Brannen e5b58effa3 Deprecate put(MergedContextConfiguration, ApplicationContext) in ContextCache
Closes gh-35415
2025-09-04 15:04:41 +02:00
Sam Brannen ca62119cb3 Evict context from ContextCache before loading a new context
Since Spring Framework 4.2, DefaultContextCache supported an LRU (least
recently used) eviction policy via a custom LruCache which extended
LinkedHashMap. The LruCache reacted to LinkedHashMap's
removeEldestEntry() callback to remove the LRU context if the maxSize
of the cache was exceeded.

Due to the nature of the implementation in LinkedHashMap, the
removeEldestEntry() callback is invoked after a new entry has been
stored to the map.

Consequently, a Spring ApplicationContext (C1) was evicted from the
cache after a new context (C2) was loaded and added to the cache,
leading to failure scenarios such as the following.

- C1 and C2 share an external resource -- for example, a database.
- C2 initializes the external resource with test data when C2 is loaded.
- C1 cleans up the external resource when C1 is closed.
- C1 is loaded and added to the cache.
- C2 is loaded and added to the cache before C1 is evicted.
- C1 is evicted and closed.
- C2 tests fail, because C1 removed test data required for C2.

To address such scenarios, this commit replaces the custom LruCache
with custom LRU eviction logic in DefaultContextCache and revises
the put(MergedContextConfiguration, ApplicationContext) method to
delegate to a new evictLruContextIfNecessary() method.

This commit also introduces a new put(MergedContextConfiguration,
LoadFunction) method in the ContextCache API which is overridden by
DefaultContextCache to ensure that an evicted context is removed and
closed before a new context is loaded to take its place in the cache.

In addition, DefaultCacheAwareContextLoaderDelegate has been revised to
make use of the new put(MergedContextConfiguration, LoadFunction) API.

Closes gh-21007
2025-09-04 14:13:10 +02:00
Sam Brannen 8eca3a3eaf Polishing 2025-09-04 14:10:17 +02:00
Sam Brannen e53e413a21 Merge branch '6.2.x' 2025-09-03 14:53:20 +02:00
Sam Brannen 33fe8d29c1 Document potential need to use Mockito.doXxx() to stub a @⁠MockitoSpyBean
Closes gh-35410
2025-09-03 14:52:58 +02:00
Sam Brannen 6dc5bf7634 Clean up warnings related to deprecated HttpStatus values, etc. 2025-09-02 12:50:57 +02:00
Sam Brannen 521764e68b Fix links, @⁠since tags, formatting, etc. in RestTestClient 2025-09-02 12:31:17 +02:00
rstoyanchev 0c02443965 Consistently support no value params in query string
Closes gh-35329
2025-08-29 10:25:37 +03:00
rstoyanchev 268706abd2 Polishing in AbstractMockHttpServletRequestBuilder
See gh-35329
2025-08-29 10:22:43 +03:00
Johnny Lim 737f66d922 Restore mixed use of uri() and queryParam()
for query parameters in AbstractMockHttpServletRequestBuilder.

See gh-35329

Signed-off-by: Johnny Lim <izeye@naver.com>
2025-08-29 09:13:51 +03:00
rstoyanchev d8804c798b RestTestClient correctly exposes the response body
Closes gh-35385
2025-08-26 18:22:32 +03:00
Brian Clozel 7112efee1b Align HttpStatus with RFC9110
This commit updates the `HttpStatus` enum with the latest changes in
RFC9110:

* deprecate "413 Payload Too Large" in favor of "413 Content Too Large"
* deprecate "418 I'm a teapot" as it was meant as a joke and is now
  marked as unused
* Introduce new "421 Misdirected Request"
* deprecate "422 Unprocessable Entity" in favor of
  "422 Unprocessable Content"
* deprecate "509 Bandwidth Limit Exceeded" as it's now unassigned
* deprecate "510 Not Extended" as it's now marked as "historic"

The relevant exceptions, test matchers and more have been updated as a
result.

Closes gh-32870
2025-08-25 14:30:57 +02:00