Commit Graph

139 Commits

Author SHA1 Message Date
Sam Brannen 53828cbfad Merge branch '6.0.x' 2023-06-14 14:39:06 +02:00
Marcin Grzejszczak a82659c837 Introduce TestExecutionListener for Micrometer ObservationRegistry
Prior to this commit, there was no way to specify the
ObservationRegistry that is registered in the given test's
ApplicationContext as the one that should be used by Micrometer's
ObservationThreadLocalAccessor for context propagation.

This commit introduces a TestExecutionListener for Micrometer's
ObservationRegistry in the Spring TestContext Framework. Specifically,
this listener obtains the ObservationRegistry registered in the test's
ApplicationContext, stores it in ObservationThreadLocalAccessor for the
duration of each test method execution, and restores the original
ObservationRegistry in ObservationThreadLocalAccessor after each test.

Co-authored-by: Sam Brannen <sam@sambrannen.com>
See gh-30658
2023-06-14 14:35:53 +02:00
Sam Brannen 54904de77d Merge branch '6.0.x' 2023-06-09 11:52:20 +02:00
Sam Brannen f36327b380 Exclude commons-logging dependency in spring-test 2023-06-09 11:37:08 +02:00
Simon Baslé b39e93d0d1 Add test support to record async events, with Junit5 caveat
This commit modifies the way the `@RecordApplicationEvents` annotation
works in tests, allowing for capture of events from threads other than
the main test thread (async events) and for the assertion of captured
event from a separate thread (e.g. when using `Awaitility`).

This is done by switching the `ApplicationEventsHolder` to use an
`InheritedThreadLocal`.

There is a mutual exclusion between support of asynchronous events vs
support of JUnit5 parallel tests with the `@TestInstance(PER_CLASS)`
mode. As a result, we favor the former and now `SpringExtension` will
invalidate a test class that is annotated (or meta-annotated, or
enclosed-annotated) with `@RecordApplicationEvents` AND
`@TestInstance(PER_CLASS)` AND `@Execution(CONCURRENT)`.

See gh-29827
Closes gh-30020
2023-05-05 17:10:41 +02:00
Juergen Hoeller 19cf503534 Align with Servlet 6.0 and introduce support for Jakarta WebSocket 2.1
Includes corresponding build upgrade to Tomcat 10.1.1 and Undertow 2.3.0
(while retaining runtime compatibility with Tomcat 10.0 and Undertow 2.2)

Closes gh-29435
Closes gh-29436
2022-11-06 16:08:30 +01:00
rstoyanchev b6c2e8de23 Support context propagation for Spring MVC controllers
Closes gh-29056
2022-10-06 12:43:54 +01:00
Andy Wilkinson a5fb55fd6d Replace dependency management plugin with built-in platform support 2022-08-30 17:03:24 +01:00
Sam Brannen 5115deb5e3 Introduce CLI for triggering AOT test context processing
This commit introduces ProcessTestsAheadOfTimeCommand, a command-line
application (CLI) that scans the provided classpath roots for Spring
integration test classes and then generates AOT artifacts for those
test classes in the provided output directories.

This CLI is only intended to be used by build tools.

Closes gh-28825
2022-08-23 16:39:59 +02:00
Sam Brannen c1a6bfc701 Introduce initial support for processing test contexts ahead-of-time
This commit introduces TestContextAotGenerator for processing Spring
integration test classes and generating AOT artifacts. Specifically,
this class performs the following.

- bootstraps the TCF for a given test class
- builds the MergedContextConfiguration for each test class and tracks
  all test classes that share the same MergedContextConfiguration
- loads each test ApplicationContext without refreshing it
- passes the test ApplicationContext to ApplicationContextAotGenerator
  to generate the AOT optimized ApplicationContextInitializer
  - The GenerationContext passed to ApplicationContextAotGenerator uses
    a feature name of the form "TestContext###_", where "###" is a
    3-digit sequence ID left padded with zeros.

This commit also includes tests using the TestCompiler to verify that
each generated ApplicationContextInitializer can be used to populate a
GenericApplicationContext as expected.

See gh-28204
2022-08-23 13:40:48 +02:00
Sam Brannen 9962aa00a0 Introduce TestClassScanner to locate Spring test classes for AOT processing
This commit introduces the TestClassScanner which scans provided
classpath roots for Spring integration test classes using the JUnit
Platform Launcher API which allows all registered TestEngines to
discover tests according to their own rules.

The scanner currently detects the following categories of Spring
integration test classes.

- JUnit Jupiter: classes that register the SpringExtension via
  @ExtendWith.
- JUnit 4: classes that register the SpringJUnit4ClassRunner or
  SpringRunner via @RunWith.
- Generic: classes that are annotated with @ContextConfiguration or
  @BootstrapWith.

The scanner has been tested with the following TestEngine
implementations for the JUnit Platform.

- JUnit Jupiter
- JUnit Vintage
- JUnit Platform Suite Engine
- TestNG Engine for the JUnit Platform

Closes gh-28824
2022-07-15 13:21:22 +02:00
Juergen Hoeller 9688e61e20 Upgrade to Groovy 4.0
Closes gh-27985
2022-02-04 21:01:02 +01:00
Sam Brannen 44950bb862 Merge branch '5.3.x' 2021-11-30 12:27:41 +01:00
Sam Brannen 40d2058b97 Upgrade to JUnit 5.8.2
Closes gh-27744
2021-11-30 12:22:31 +01:00
Sam Brannen a247b83cd9 Ensure projects can be imported into Eclipse IDE with JDK 17
Prior to this commit, the Spring Framework projects could not be
imported into Eclipse IDE when using JDK 17 to build the projects.

The primary obstacle is the fact that Eclipse enforces a strict
"no split packages between the unnamed module and a system module" rule
when building with a "modular JDK" (such as JDK 17).

Resources:

- https://bugs.eclipse.org/bugs/show_bug.cgi?id=536928
- https://bugs.openjdk.java.net/browse/JDK-8215739
- http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-December/014077.html
- https://stackoverflow.com/questions/51094274/eclipse-cant-find-xml-related-classes-after-switching-build-path-to-jdk-10/53824670#53824670

Since the bug (JDK-8215739) has not been fixed in OpenJDK, the strict
"no split packages" rule does not apply to the Java compiler used in
Spring Framework's Gradle build or the compiler in IntelliJ IDEA. Hence,
this issue only arrises when building the framework in Eclipse IDE.

This commit addresses this issue in the following affected projects.

- spring-oxm: removal of the dependency on XPP3 which publishes
    javax.xml.namespace.QName as part of the JAR. The QName type is
    also published by the java.xml JDK 17 system module. To make the
    tests pass, we have switched to using the DomDriver instead of the
    XppDriver in our XStream tests.

- spring-test: HtmlUnit has a transitive dependency on xml-apis which
    publishes several packages also published by java.xml JDK 17 system
    module. Thus, we have explicitly excluded the transitive dependency
    on xml-apis for our `optional` configuration.

See gh-27407
2021-09-22 16:22:27 +02:00
Sam Brannen cf46384887 Merge branch '5.3.x' 2021-09-20 14:44:36 +02:00
Marc Philipp e29867b96e Exclude TestCase classes in spring-test build
When not excluded, TestNG will pick up nested TestCase classes and run
them.

This commit therefore filters out `*TestCase` test classes from the
build since these are not intended to be executed with the build.

See gh-27406
2021-09-20 14:02:06 +02:00
Sam Brannen 0b552a3534 Migrate to TestNG Engine for the JUnit Platform in spring-test
Prior to this commit, we had configured separate test tasks for JUnit
and TestNG. In addition, we configured a standard `test` task that
depended on the `junit` and `testNG` tasks, and we had an additional
`aggregateTestReports` task that aggregated the reports from the JUnit
and TestNG test tasks.

Thanks to the introduction of the "TestNG Engine for the JUnit
Platform", this commit simplifies our Gradle build in the spring-test
module by running JUnit 4, JUnit Jupiter, and TestNG tests on the JUnit
Platform in a single Gradle `test` task.

See gh-27406
2021-09-20 14:02:06 +02:00
Juergen Hoeller d84ca2ba90 Jakarta EE 9 migration
Upgrades many dependency declarations; removes old EJB 2.x support and outdated Servlet-based integrations (Commons FileUpload, FreeMarker JSP support, Tiles).

Closes gh-22093
Closes gh-25354
Closes gh-26185
Closes gh-27423
See gh-27424
2021-09-17 09:14:07 +02:00
Sam Brannen d55cbf8b4d Avoid use of deprecated API in aggregateTestReports task
See gh-26870
2021-09-13 16:52:00 +02:00
Brian Clozel cecc0849a8 Upgrade to Gradle 7.2
This commit upgrades Gradle to 7.2.
Gradle configuration names are updated accordingly.
This also upgrades Gradle build plugins.

See gh-26870
2021-09-13 09:37:35 +02:00
Sam Brannen 19283c9245 Avoid accidental dependency on older version of Byte Buddy
This commit allows Mockito-based tests in spring-test to work again
in Eclipse IDE.

This problem was uncovered while fixing gh-27365
2021-09-07 11:33:32 +02:00
Brian Clozel 9aae5ed3fa Update Reactor Netty modules
Since reactor/reactor-netty#739, the `reactor-netty` module is now split
into two: `reactor-netty-core` and `reactor-netty-http`.

This commit updates the Spring Framework build accordingly.
2020-08-01 11:49:15 +02:00
Sébastien Deleuze 6b355df903 Revert "Upgrade to Kotlin 1.4 M2"
This reverts commit 2a74eff10f.

Some regressions require to wait at least Kotlin 1.4 M3.
2020-06-18 14:06:39 +02:00
Rossen Stoyanchev bc33ae3f8b Update multipart RequestMatcher
See gh-23772
2020-06-18 07:49:27 +01:00
vspac e01160db31 Multipart RequestMatcher's
See gh-23772
2020-06-18 07:49:27 +01:00
Sébastien Deleuze 2a74eff10f Upgrade to Kotlin 1.4 M2
- The compiler is configured to retain compatibility with Kotlin 1.3.
- Explicit API mode is not yet enabled but could be in the future.
- A workaround for Gradle build is required for now, see
  https://youtrack.jetbrains.com/issue/KT-39610 for more details.
- Some exceptions thrown by Kotlin have changed to NullPointerException,
  see https://youtrack.jetbrains.com/issue/KT-22275 for more details.

Closes gh-24171
2020-06-16 15:21:57 +02:00
Sam Brannen 7b6d83a106 Use Gradle test fixture support for spring-web
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 5581f3b77b Use Gradle test fixture support for spring-tx
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 61d4ee594d Use Gradle test fixture support for spring-beans and spring-context
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 670cbb9aed Simplify Gradle test task configuration
As an added bonus, AbstractViewTests is now executed in the build.
2019-09-03 12:40:59 +02:00
Sam Brannen 2c44eabe41 Remove unnecessary dependency declarations in spring-test 2019-09-03 12:13:56 +02:00
Brian Clozel d4089747b8 Use dependency management in Framework build
Prior to this commit, the Spring Framework build would partially use the
dependency management plugin to import and enforce BOMs.

This commit applies the dependency management plugin to all Java
projects and regroups all version management declaration in the root
`build.gradle` file (versions and exclusions).

Some versions are overridden in specific modules for
backwards-compatibility reasons or extended support.

This commit also adds the Gradle versions plugin that checks for
dependency upgrades in artifact repositories and produces a report; you
can use the following:

    ./gradlew dependencyUpdates
2019-09-02 18:01:09 +02:00
Brian Clozel e9523161f0 Revert "Revert "Refactor Gradle tasks in Spring Framework build""
This reverts commit fb0d618751.
2019-08-20 20:26:43 +02:00
Stephane Nicoll fb0d618751 Revert "Refactor Gradle tasks in Spring Framework build"
This reverts commit 1539ba8991.
2019-08-20 20:07:11 +02:00
Brian Clozel 1539ba8991 Refactor Gradle tasks in Spring Framework build
This commit reorganizes tasks and scripts in the build to only apply
them where they're needed. We're considering here 3 "types" of projects
in our build:
* the root project, handling documentation, publishing, etc
* framework modules (a project that's published as a spring artifact)
* internal modules, such as the BOM, our coroutines support and our
integration-tests

With this change, we're strealining the project configuration for all
spring modules and only applying plugins when needed (typically our
kotlin support).

See gh-23282
2019-08-20 18:17:02 +02:00
Sam Brannen 303fc3211c Upgrade to Hamcrest 2.1
Closes gh-23467
2019-08-17 18:44:54 +02:00
Sam Brannen 979508a7f3 Remove JUnit 4 dependency from all modules except spring-test
This commit removes the JUnit 4 dependency from all modules except
spring-test which provides explicit JUnit 4 support.

This commit also includes the following.

- migration from JUnit 4 assertions to JUnit Jupiter assertions in all
  Kotlin tests
- migration from JUnit 4 assumptions in Spring's TestGroup support to
  JUnit Jupiter assumptions, based on org.opentest4j.TestAbortedException
- introduction of a new TestGroups utility class than can be used from
  existing JUnit 4 tests in the spring-test module in order to perform
  assumptions using JUnit 4's Assume class

See gh-23451
2019-08-17 11:37:21 +02:00
Sam Brannen fbe697061c Remove duplicate junit-bom configuration from spring-test.gradle
The junit-bom is already configured in build.gradle via "allprojects".
2019-07-21 20:40:53 +02:00
Sam Brannen 8ccf4a9072 Set testGroups system property for spring-test Gradle test tasks 2019-07-21 20:21:58 +02:00
Sam Brannen 69214429df Ensure aggregateTestReports task is UP-TO-DATE
Prior to this commit, the standard Gradle `test` task was configured to
execute all JUnit tests and had a dependency on the `testNG` task. In
addition, the `aggregateTestReports` task depended on the results of
the `test` and `testNG` tasks as input. Consequently, a subsequent
execution of the `aggregateTestReports` task would not be considered
UP-TO-DATE since the JUnit and TestNG results were both written to the
same "test" reports folder.

This commit introduces a new `junit` test task that allows JUnit and
TestNG test output to be completely independent. The standard `test`
task now depends on `junit` and `testNG` but does not execute any tests
itself, and the `aggregateTestReports` task now depends on the
individual `junit` and `testNG` results instead of on the mixed `test`
results.

See also: eec183ef28
2019-07-21 17:21:24 +02:00
Sebastien Deleuze c006a83584 Upgrade to Coroutines 1.3.0-RC
This commit upgrades Coroutines support to kotlinx.coroutines
1.3.0-RC, leverages the new Coroutines BOM and refine Coroutines
detection to avoid false positives.

Only Coroutines to Mono context interoperability is supported
for now.

CLoses gh-23326
2019-07-21 11:27:43 +02:00
Juergen Hoeller cdeb1fef5f Merge branch '5.1.x' 2019-07-20 18:23:00 +02:00
Juergen Hoeller 92890232df Upgrade to OpenPDF 1.2.21, Rome 1.12.1, XStream 1.4.11.1
Includes updated javadoc links for 5.1.x branch.
2019-07-20 18:20:03 +02:00
Sebastien Deleuze 095fd5bcb3 Use Kotlin BOM
Close gh-23316
2019-07-19 10:43:54 +02:00
Sam Brannen 0aa5533dea Execute test suite in Gradle using JUnit Platform
Closes gh-23286
2019-07-13 19:13:33 +02:00
Sam Brannen 480b1e0a0d Run JUnit 4 tests in spring-test on the JUnit Platform
This commit simplifies the build for spring-test by running JUnit 4
tests and JUnit Jupiter tests together in the standard Gradle `test`
task.

As an added bonus, the ignored tests in SpringJUnit4ConcurrencyTests
and ClassLevelDisabledSpringRuleTests are now reported in the test
results.

See gh-23286
2019-07-13 18:24:37 +02:00
Sebastien Deleuze 2b4d6ce354 Add body methods with Object parameter to WebFlux
The commit deprecates syncBody(Object) in favor of body(Object)
which has the same behavior in ServerResponse, WebClient and
WebTestClient. It also adds body(Object, Class) and
body(Object, ParameterizedTypeReference) methods in order to support
any reactive type that can be adapted to a Publisher via
ReactiveAdapterRegistry. Related BodyInserters#fromProducer
methods are provided as well.

Shadowed Kotlin body<T>() extensions are deprecated in favor of
bodyWithType<T>() ones, including dedicated Publisher<T> and
Flow<T> variants. Coroutines extensions are adapted as well, and
body(Object) can now be used with suspending functions.

Closes gh-23212
2019-07-07 22:27:57 +02:00
Juergen Hoeller e2d01bb783 Merge branch '5.1.x' 2019-06-22 17:11:31 +02:00