1641 Commits

Author SHA1 Message Date
Sam Brannen
077146d636 Merge branch '6.2.x' 2025-06-09 14:12:45 +02:00
Sam Brannen
18d6a55e3e Polishing and removal of "this." for method invocations 2025-06-09 14:10:30 +02:00
Sam Brannen
de7d50d39f Redeclare @⁠TestMethodOrder on @⁠Nested test class
Thanks to the new Discovery Issue Reporting mechanism introduced in JUnit 5.13, I became
aware of the fact that the @⁠Order annotations in NestedAfterTestClassSqlScriptsTests
were being silently ignored.

To address that, this commit redeclares @⁠TestMethodOrder on @⁠Nested test class.
2025-06-07 15:22:57 +02:00
Sam Brannen
3aa3b81e1c Update copyright headers 2025-06-06 13:49:23 +02:00
Johnny Lim
7f6a7b806e Replace AssertionsForClassTypes with Assertions
Closes gh-34821

Signed-off-by: Johnny Lim <izeye@naver.com>
2025-06-06 13:49:23 +02:00
Sam Brannen
0f9870b603 Stop referring to JUnit 5 in documentation
Closes gh-34970
2025-05-30 14:37:05 +02:00
Brian Clozel
81ea754ac2 Merge branch '6.2.x' 2025-05-19 12:11:32 +02:00
Brian Clozel
fdab8fabd2 Avoid duplicate Content-Type in MockHttpServletRequest
Fixes gh-34913
2025-05-19 12:04:46 +02:00
rstoyanchev
094e653746 Versioning support in WebTestClient controller setup
See gh-34919
2025-05-19 09:36:51 +01:00
rstoyanchev
3095219479 Support API versioning in MockMvc
See gh-34919
2025-05-19 09:36:51 +01:00
rstoyanchev
5b19f6249e Refactoring in ApiVersionInserter
Refine naming of static factory methods, and update them to be
shortcuts for instance creation.

See gh-34919
2025-05-19 09:36:51 +01:00
Sam Brannen
01fea5e7ed Polish Jackson 3 support
- Improve Javadoc.

- Suppress warnings for "removal".

- Update copyright headers.

- Migrate several tests from:
  - MappingJackson2MessageConverter to JacksonJsonMessageConverter
  - Jackson2JsonEncoder to JacksonJsonEncoder
  - Jackson2JsonDecoder to JacksonJsonDecoder
  - Jackson2SmileEncoder to JacksonSmileEncoder
  - Jackson2ObjectMapperBuilder to JsonMapper and XmlMapper
  - MappingJackson2JsonView to JacksonJsonView
  - MappingJackson2HttpMessageConverter to JacksonJsonHttpMessageConverter
  - MappingJackson2XmlHttpMessageConverter to JacksonXmlHttpMessageConverter
2025-05-14 16:55:27 +02:00
Sébastien Deleuze
7acd4aec38 Introduce Jackson 3 support to AnnotationDrivenBeanDefinitionParser
See gh-33798
2025-05-13 17:53:29 +02:00
Sébastien Deleuze
0ad4fcaeaf Update spring-test tests to use Jackson 3
See gh-33798
2025-05-13 17:53:28 +02:00
Sébastien Deleuze
71987a8713 Introduce Jackson 3 support for views
This commit introduces Jackson 3 based variants of the following
Jackson 2 classes (and related dependent classes).

MappingJackson2JsonView -> JacksonJsonView
MappingJackson2XmlView-> JacksonXmlView

See gh-33798
2025-05-13 17:53:28 +02:00
rstoyanchev
d8b506e09a Fix failing test 2025-05-06 21:43:12 +01:00
Sam Brannen
f8e7bf7825 Merge branch '6.2.x' 2025-05-02 11:39:09 +02:00
Sam Brannen
e8f873a349 Ensure Bean Overrides are discovered once in hierarchies
Prior to this commit, bean overrides (such as @⁠MockitoBean, etc.) were
discovered multiple times if they were declared:

- at the type-level on an interface that is implemented at more than
  one level in the type hierarchy, the enclosing class hierarchy, or a
  combination of the type and enclosing class hierarchies.

or

- on a field declared in a class which can be reached multiple times
  while traversing the type and enclosing class hierarchies in
  scenarios such as the following: the class (X) in which the field is
  declared is a supertype of an enclosing type of the test class, and X
  is also an enclosing type of a supertype of the test class.

Such scenarios resulted in an IllegalStateException stating that a
duplicate BeanOverrideHandler was discovered.

To address that, this commit revises the search algorithm in
BeanOverrideHandler so that all types (superclasses, enclosing classes,
and implemented interfaces) are only visited once while traversing the
type and enclosing class hierarchies in search of bean override
handlers.

See gh-33925
See gh-34324
Closes gh-34844
2025-05-02 11:26:33 +02:00
Sam Brannen
13f9fed4bc Merge branch '6.2.x' 2025-05-01 10:52:26 +02:00
Sam Brannen
b943817f3e Close ApplicationContext after test AOT processing
See commit 1c108054ee
Closes gh-34841
2025-05-01 10:50:38 +02:00
Sam Brannen
c74fc7ec90 Deprecate JUnit 4 support in the TestContext framework
Closes gh-34794
2025-04-26 10:06:18 +02:00
Sam Brannen
2db1a63a92 Merge branch '6.2.x' 2025-04-26 09:41:09 +02:00
Sam Brannen
ef11a00c0b Polishing 2025-04-26 09:37:34 +02:00
Sam Brannen
4bf8e2f366 Merge branch '6.2.x' 2025-04-26 07:55:00 +02:00
Sam Brannen
176b0b09bf Migrate remaining JUnit 4 tests to JUnit Jupiter where feasible
In 49e5c84928 I unfortunately overlooked
several JUnit 4 based tests in the `junit4` package that should be
migrated to JUnit Jupiter.

This commit address those remaining test classes.

See gh-23451
See gh-34794
Closes gh-34813
2025-04-26 07:51:24 +02:00
Sam Brannen
52265a5c65 Merge branch '6.2.x' 2025-04-24 16:30:45 +02:00
Sam Brannen
49e5c84928 Migrate remaining JUnit 4 tests to JUnit Jupiter where feasible
In Spring Framework 5.2, we migrated most of the test suite from JUnit
4 to JUnit Jupiter; however, prior to this commit, several tests in the
spring-test module were still based on JUnit 4 unnecessarily.

Since we are now planning to deprecate our JUnit 4 support in 7.0, this
commit migrates our remaining JUnit 4 based tests to JUnit Jupiter
whenever feasible. In the process, test classes that previously resided
under the "junit4" package have been moved to new packages directly
under the "org.springframework.text.context" package, and several
classes have been renamed for greater clarity of purpose.

Consequently, the only remaining tests based on JUnit 4 are those tests
that are required to run with JUnit 4 in order to test our JUnit 4
support.

This commit also greatly simplifies exclusions for Checkstyle rules
pertaining to JUnit usage.

See gh-23451
See gh-34794
Closes gh-34813
2025-04-24 16:20:39 +02:00
Sam Brannen
5fb37e3133 Polishing 2025-04-15 15:19:34 +02:00
rstoyanchev
fb94109c09 WebTestClient support for API versioning
Closes gh-34568
2025-04-14 17:45:49 +01:00
Sam Brannen
23aea5c402 Merge branch '6.2.x' 2025-04-14 11:32:48 +02:00
Sam Brannen
a22d204681 Remove duplicate words in Java source code
Discovered using regular expression: \b(\w+)\s+\1\b[^(}]
2025-04-14 11:24:55 +02:00
Sam Brannen
1795b234e4 Merge branch '6.2.x' 2025-04-10 14:52:22 +02:00
Sam Brannen
c168e1c297 Provide first-class support for Bean Overrides with @⁠ContextHierarchy
This commit provides first-class support for Bean Overrides
(@⁠MockitoBean, @⁠MockitoSpyBean, @⁠TestBean, etc.) with
@⁠ContextHierarchy.

Specifically, bean overrides can now specify which ApplicationContext
they target within the context hierarchy by configuring the
`contextName` attribute in the annotation. The `contextName` must match
a corresponding `name` configured via @⁠ContextConfiguration.

For example, the following test class configures the name of the second
hierarchy level to be "child" and simultaneously specifies that the
ExampleService should be wrapped in a Mockito spy in the context named
"child". Consequently, Spring will only attempt to create the spy in
the "child" context and will not attempt to create the spy in the
parent context.

@⁠ExtendWith(SpringExtension.class)
@⁠ContextHierarchy({
    @⁠ContextConfiguration(classes = Config1.class),
    @⁠ContextConfiguration(classes = Config2.class, name = "child")
})
class MockitoSpyBeanContextHierarchyTests {

    @⁠MockitoSpyBean(contextName = "child")
    ExampleService service;

    // ...
}

See gh-33293
See gh-34597
See gh-34726
Closes gh-34723

Signed-off-by: Sam Brannen <104798+sbrannen@users.noreply.github.com>
2025-04-10 14:46:50 +02:00
Sam Brannen
d6e35cf1f0 Introduce queryParamCount() in MockRestRequestMatchers
Closes gh-34703
2025-04-03 14:50:58 +02:00
Sam Brannen
2fa7b30831 Merge branch '6.2.x' 2025-03-27 15:32:42 +01:00
Sam Brannen
374c3b4545 Provide complete support for qualifier annotations with Bean Overrides
Prior to this commit, the Test Bean Override feature provided support
for overriding beans based on qualifier annotations in several
scenarios; however, qualifier annotations got lost if they were
declared on the return type of the @⁠Bean method for the bean being
overridden and the @⁠BeanOverride (such as @⁠MockitoBean) was based on
a supertype of that return type.

To address that, this commit sets the @⁠BeanOverride field as the
"qualified element" in the RootBeanDefinition to ensure that qualifier
annotations are available for subsequent autowiring candidate
resolution.

Closes gh-34646
2025-03-27 15:29:14 +01:00
Sam Brannen
d7e470d3e0 Polishing 2025-03-27 14:05:25 +01:00
Sam Brannen
8db1340263 Merge branch '6.2.x' 2025-03-19 16:24:18 +01:00
Sam Brannen
208d52d852 Introduce Checkstyle rule for separator symbol location 2025-03-19 15:35:44 +01:00
Sam Brannen
e05d4f2f18 Merge branch '6.2.x' 2025-03-18 16:42:37 +01:00
Sam Brannen
c6a9aa59a3 Remove BDDMockito Checkstyle rule
This commit removes the BDDMockito Checkstyle rule, since it did not
actually enforce the use of BDDMockito.

This commit also updates static imports to use Mockito instead of
BDDMockito where appropriate (automated via the Eclipse IDE Organize
Imports clean-up task).

Closes gh-34616
2025-03-18 16:35:57 +01:00
Sam Brannen
eb7b26db24 Merge branch '6.2.x' 2025-03-12 11:20:05 +01:00
Sam Brannen
020f556841 Support custom attribute with a value in MockCookie.parse()
Prior to this commit, MockCookie.parse() failed with an
IllegalArgumentException when attempting to parse a custom attribute
with a value, such as "Version=1". This is a regression that was
inadvertently introduced in 7fc4937199
when adding support for the "Partitioned" attribute which does not
support a value.

This commit addresses this regression by parsing both the name and the
value from an optional, custom attribute.

See gh-31454
Closes gh-34575
2025-03-12 11:19:38 +01:00
Sébastien Deleuze
5bd03494d4 Merge branch '6.2.x' 2025-03-07 09:30:28 +01:00
Dmitry Sulman
a6f3f18d89 Allow supertypes in ContentResultMatchersDsl matchers
Closes gh-34542
Signed-off-by: Dmitry Sulman <dmitry.sulman@gmail.com>
2025-03-07 09:29:48 +01:00
Sam Brannen
ca7ebd60ed Stop using deprecated ReflectionHintsPredicates.onMethod() on main 2025-03-04 11:21:37 +01:00
Sam Brannen
702c63a7e8 Merge branch '6.2.x' 2025-03-03 17:40:39 +01:00
Sam Brannen
e421104cf3 Supply RuntimeHints to an AotContextLoader
This commit introduces a new loadContextForAotProcessing(...) variant
in AotContextLoader which accepts a RuntimeHints argument. This new
method is an interface default method which delegates to the existing
loadContextForAotProcessing(MergedContextConfiguration) variant for
backward compatibility.

In addition, the original loadContextForAotProcessing(...) variant is
now deprecated and has been converted to an interface default method
which throws an UnsupportedOperationException.

Note, however, that the framework now only invokes the new
loadContextForAotProcessing(...) variant within TestContextAotGenerator.

Closes gh-34513
2025-03-03 17:39:56 +01:00
Sam Brannen
adfeba23e0 Polishing 2025-03-03 17:39:47 +01:00
Brian Clozel
a1410d98de Merge branch '6.2.x' 2025-02-25 17:19:01 +01:00