Commit Graph

30248 Commits

Author SHA1 Message Date
Sam Brannen 87c93d35d6 Revise bean override tests with a focus on AOT support
As a follow up to the previous commit (31f8e12adb), this commit
polishes bean override tests and revises them with a focus on AOT
testing support and simplified maintenance.

- Introduce EngineTestKitUtils to simplify working with JUnit's
  EngineTestKit.

- Use idiomatic EngineTestKit APIs to simplify assertions on
  EngineTestKit results.

- Introduce BeanOverrideTestSuite to simplify running all bean override
  tests within the IDE.

- Separate failure and success scenario tests, so that failure tests do
  not launch the JUnit Platform to run tests using the Spring
  TestContext Framework (TCF) within a test class that itself uses the
  TCF.

- Make AbstractTestBeanIntegrationTestCase actually abstract.

- Rename test case classes to give them meaningful names and simplify
  understanding of what's being tested.

- Ensure tests for @⁠MockitoSpyBean functionality use @⁠MockitoSpyBean
  instead of @⁠MockitoBean.

- Declare @⁠Configuration classes local to @⁠SpringJUnitConfig test
  classes whenever possible.

See gh-29122
See gh-32925
2024-05-31 12:19:31 +02:00
Sam Brannen 31f8e12adb Separate failure and success scenario tests for @⁠TestBean
This commit also ensures that @⁠Bean methods are declared within
@⁠Configuration classes instead of within test classes.

See gh-29122
2024-05-29 14:21:58 +02:00
Sam Brannen 1f537b97d5 Demonstrate how to disable Bean Override tests in AOT mode
See gh-29122
2024-05-29 14:20:35 +02:00
Sam Brannen cade3c7b0e Ensure MockMvcTesterIntegrationTests runs in AOT mode
See gh-29122
2024-05-29 13:32:22 +02:00
Sam Brannen a0c9a204b8 Polishing 2024-05-29 13:32:02 +02:00
Juergen Hoeller 8f21137883 Merge branch '6.1.x' 2024-05-28 18:47:38 +02:00
Juergen Hoeller 8c6a7799be Upgrade to Checkstyle 10.17 2024-05-28 18:46:22 +02:00
Juergen Hoeller 557dbba585 Remove superfluous addToClassHierarchy call for Enum types
Closes gh-32906
2024-05-28 18:45:05 +02:00
Juergen Hoeller 5a275443b5 Apply ThreadLocal#remove() to pre-instantiation threads
See gh-13410
See gh-32874
2024-05-28 16:35:58 +02:00
Sam Brannen 27985b1439 Disable class data sharing (CDS) for tests
Prior to this commit, the Gradle build output the following warning
multiple times.

OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

Since we don't need CDS enabled for our tests, I've added `-Xshare:off`
as a JVM argument for our tests to disable CDS.
2024-05-28 15:58:02 +02:00
Stéphane Nicoll bad4e18b4d Add support for building a request directly from MockMvcTester
Closes gh-32913'
2024-05-28 15:33:21 +02:00
Sam Brannen defb6b7a62 Polish documentation and implementation of SpEL's Indexer 2024-05-28 15:29:54 +02:00
Stéphane Nicoll 8d2bc3bdba Add support for fluent preparation of the request in MockMvcTester
See gh-32913
2024-05-28 15:29:14 +02:00
Stéphane Nicoll a3e7fd47c6 Allow MockHttpServletRequestBuilder to support AssertJ
This commit moves the features of MockHttpServletRequestBuilder in
an abstract class so that another class can offer the same feature
whilst providing AssertJ support. This wasn't possible previously as
the builder's return type would lose the concrete builder types.

This change benefits MockMultipartHttpServletRequestBuilder that can
use the same mechanism to offer additional settings.

This change also makes it so that a builder instance can be created
using only the HttpMethod. Previously, the URI had to be provided as
well and that makes it impossible to specify it using the builder.

See gh-32913
2024-05-28 15:29:14 +02:00
Arjen Poutsma 726ac9110c Do not read Map in FormHttpMessageConverter
This commit ensures that the FormHttpMessageConverter no longer supports
 reading Maps (just MultiValueMaps). Plain maps are often used to
 represent JSON.

See gh-32826
2024-05-28 15:25:08 +02:00
Stéphane Nicoll fc54cf4430 Harmonize use of uri in MockMvc
Closes gh-32915
2024-05-28 11:17:40 +02:00
Sam Brannen 54c07eddcc Merge branch '6.1.x' 2024-05-28 10:26:56 +02:00
Sam Brannen e9de426eb5 Support compilation of map indexing with primitive in SpEL
Prior to this commit, the Spring Expression Language (SpEL) failed to
compile an expression that indexed into a Map using a primitive literal
(boolean, int, long, float, or double).

This commit adds support for compilation of such expressions by
ensuring that primitive literals are boxed into their corresponding
wrapper types in the compiled bytecode.

Closes gh-32903
2024-05-28 10:19:15 +02:00
Stéphane Nicoll 2d1e58b928 Polish 2024-05-28 09:31:44 +02:00
Stéphane Nicoll f6504c5f91 Deprecate use of raw String for HttpMethod in MockMvc
Closes gh-32914
2024-05-28 09:24:08 +02:00
Sam Brannen 8871d67298 Merge branch '6.1.x' 2024-05-27 17:13:01 +02:00
Sam Brannen cda577d1aa Support compilation of array and list indexing with Integer in SpEL
Prior to this commit, the Spring Expression Language (SpEL) failed to
compile an expression that indexed into any array or list using an
Integer.

This commit adds support for compilation of such expressions by
ensuring that an Integer is unboxed into an int in the compiled
bytecode.

See gh-32694
Closes gh-32908
2024-05-27 17:06:48 +02:00
Marcus Hert Da Coregio 57fae7a59e Add update-antora-ui-spring.yml workflow 2024-05-27 16:56:13 +02:00
Sam Brannen b3cc603401 Avoid usage of deprecated AssertJ feature 2024-05-27 16:51:39 +02:00
Sam Brannen 870d15c0b6 Merge branch '6.1.x' 2024-05-27 16:44:19 +02:00
Sam Brannen 8feb842df5 Upgrade to AssertJ 3.26.0
See https://github.com/assertj/assertj/issues/3322
2024-05-27 16:43:22 +02:00
Brian Clozel 3b53165574 Expose WebSocketMessageBrokerStats contracts
Prior to this commit, the `WebSocketMessageBrokerStats` would be in
charge of periodically logging WebSocket stats. This class would also
publicly expose each stats type with dedicated methods, as `String`.
This would not allow observation libraries to easily extract information
and turn them into metrics.

This commit introduces new methods exposing the `Stats` types directly
and deprecates the former `String` variants. This will allow
observability libraries like Micrometer to expose this as metrics:

```
MeterRegistry meterRegistry = ...;

Gauge.builder("spring.stomp.frames", stats.getStompSubProtocolStats(),
      StompSubProtocolHandler.Stats::getTotalConnect)
  .tag("type", "CONNECT")
  .description("number of CONNECT frames processed")
  .register(meterRegistry);
```

Closes gh-31604
2024-05-27 16:06:32 +02:00
Brian Clozel e856e7e590 Add checkstyle rule for "@since" javadoc convention 2024-05-27 09:28:23 +02:00
Stéphane Nicoll e2c5887cea Allow JSON content assertions to be nested
Previously, AbstractJsonContentAssert worked on a raw String, which
made standard AssertJ nested calls, such as satisfies, to return an
assert on the raw string, rather than one with JSON support.

This commit rework AbstractJsonContentAssert so that it no longer
extend from AbstractStringAssert. This makes the list of methods more
focused on JSON assertions, and allow standard operations to provide
the right assert object.

Closes gh-32894
2024-05-27 09:25:12 +02:00
Sam Brannen 489d18a169 Merge branch '6.1.x' 2024-05-24 15:42:39 +02:00
Sam Brannen ea2931f24a Use Develocity Gradle plugin API to avoid deprecation warning
Prior to this commit, the Gradle build issued the following warning.

- The deprecated "gradleEnterprise.buildScan.value" API has been
  replaced by "develocity.buildScan.value"
2024-05-24 15:41:58 +02:00
Sam Brannen 7e3a4a12f8 Use consistent version strings for 6.2 2024-05-24 15:19:30 +02:00
Sam Brannen b82b83c8f0 Disable warnings for deprecated for removal in Eclipse 2024-05-24 14:30:56 +02:00
Sam Brannen 5d39598025 Disable warnings for unclosed @⁠AutoCloseable in Eclipse 2024-05-24 14:15:25 +02:00
Sam Brannen 159c2cd7c6 Remove obsolete code 2024-05-24 14:14:43 +02:00
Sam Brannen dac18a3ff1 Clean up warnings in Gradle build 2024-05-24 13:39:56 +02:00
Sam Brannen 77f7da01e4 Polishing 2024-05-24 13:39:56 +02:00
Sam Brannen e999f4e47d Sync changes to MockHttpServletRequest 2024-05-24 13:39:55 +02:00
Sam Brannen e3c268ef18 Fix formatting 2024-05-24 13:39:55 +02:00
Juergen Hoeller 49caa02584 Merge branch '6.1.x' 2024-05-24 13:06:21 +02:00
Juergen Hoeller 26d1c38d84 Polishing 2024-05-24 13:05:49 +02:00
Juergen Hoeller dae4366325 Merge branch '6.1.x' 2024-05-24 11:55:53 +02:00
Juergen Hoeller 345daaabbc Detect original generic method for CGLIB bridge method
Closes gh-32888
2024-05-24 11:49:10 +02:00
Arjen Poutsma 903493e9a9 Various MultiValueMap improvements
This commit makes several improvements to MultiValueMap:
- asSingleValueMap offers a single-value view (as opposed to the
  existing toSingleValueMap, which offers a copy)
- fromSingleValue is a static method that adapts a Map<?,?> to the
  MultiValueMap interface
- fromMultiValue is a static method that adapts a Map<?,List<?>> to the
  MultiValueMap interface

Closes gh-32832
2024-05-24 11:44:55 +02:00
Stéphane Nicoll 97647ef5f6 Flag tests using deprecated json method deprecated
See gh-32791
2024-05-24 11:03:33 +02:00
Juergen Hoeller 0110c5ac82 Merge branch '6.1.x' 2024-05-23 17:08:22 +02:00
Juergen Hoeller 6c08d93992 Polishing 2024-05-23 17:07:55 +02:00
Juergen Hoeller 6d7cd9c7dc Defensive handling of incompatible advice methods
This covers AspectJ transaction and caching aspects when encountered by Spring AOP.

Closes gh-32882
See gh-32793
2024-05-23 17:07:51 +02:00
Juergen Hoeller 35278d09ac Polishing 2024-05-23 16:34:24 +02:00
Stéphane Nicoll 975e2f4218 Revert "Avoid deprecation warnings for WebJarsResourceResolver"
This reverts commit 61db499ae2.
2024-05-23 16:21:42 +02:00