The ability to set a system property to change the default
CacheAwareContextLoaderDelegate was only needed by the Spring Native
project in the Spring Framework 5.3.x line and should not be used by
other projects.
This commit therefore reverts the changes made in conjunction with
gh-27540.
Closes gh-29061
For certain use cases it is beneficial to be able to compute something
during AOT build-time processing and then retrieve the result of that
computation during AOT run-time execution, without having to deal with
code generation on your own.
To support such use cases, this commit introduces an AotTestAttributes
mechanism in the Spring TestContext Framework with the following
feature set.
- conceptually similar to org.springframework.core.AttributeAccessor in
the sense that attributes are generic metadata
- allows an AOT-aware test component to contribute a key-value pair
during the AOT build-time processing phase, where the key is a String
and the value is a String
- provides convenience methods for storing and retrieving attributes as
boolean values
- generates the necessary source code during the AOT build-time
processing phase in the TestContext framework to create a persistent
map of the attributes
- provides a mechanism for accessing the stored attributes during AOT
run-time execution
Closes gh-29100
This commit renames registerResourceIfNecessary() to registerResource()
and throws an exception if the class path resource does not exist.
Closes gh-29083
As of Java 18, the serial lint warning in javac has been expanded to
check for class fields that are not marked as `Serializable`.
See https://www.oracle.com/java/technologies/javase/18all-relnotes.html#JDK-8202056
In the Spring Framework codebase, this can happen with `Map`, `Set` or
`List` attributes which are often assigned with an unmodifiable
implementation variant. Such implementations are `Serializable` but
cannot be used as field types.
This commit ensures that the following changes are applied:
* fields are marked as transient if they can't be serialized
* classes are marked as `Serializable` if this was missing
* `@SuppressWarnings("serial")` is applied where relevant
This commit introduces endToEndTestsForEntireSpringTestModule() in
AotIntegrationTests to allow us to periodically check on our AOT
support.
Status quo:
- several test classes cannot be processed for AOT due to exceptions
thrown during processing
- some generated classes fail to compile
- some tests fail
See gh-29122
This commit introduces a new registerResourceIfNecessary() method in
RuntimeHintsUtils that simplifies the registration of hints for
`classpath:` resources.
Closes gh-29083
Prior to this commit, the `HtmlUnitRequestBuilder` would "translate"
HtmlUnit web requests into Servlet requests using APIs that were not
clearly defined and meant for internal usage.
HtmlUnit 2.64.0 introduced a new `.getParameters()` API for collecting
`NameValuePair` parsed from the request URI or request body, depending
on the nature of the request. This arrangement is much more stable and
in line with HtmlUnit's expectations.
This commit uses this new API and makes HtmlUnit 2.64.0 a new minimum
requirement for using HtmlUnit integration with Spring Framework.
This also removes tests that were previously testing HtmlUnit's behavior
and using the API now marked as internal.
Closes gh-28240
This commit harmonizes the package space by moving the TestCompiler
infrastructure from the now outdated "generator" package to "generate".
Closes gh-29082
SqlScriptsTestExecutionListener now implements AotTestExecutionListener
in order to register run-time hints for SQL scripts used by test
classes and test methods annotated with @Sql if the configured or
detected SQL scripts are classpath resources.
Closes gh-29027
This commit introduces an AotTestExecutionListener API that extends
TestExecutionListener and allows a TestExecutionListener to opt in for
AOT processing support, analogous to what the AotContextLoader API does
for a SmartContextLoader.
Closes gh-29070
We no longer register reflection run-time hints for the SpringExtension
since that is covered by the JupiterConfigProvider in the GraalVM Native
Build Tools project.
This commit introduces automatic registration of runtime hints for
custom ActiveProfilesResolver implementations configured via the
`resolver` attribute in @ActiveProfiles.
Closes gh-29022
This commit introduces StandardTestRuntimeHints and migrates existing
hint registration from TestContextAotGenerator to this new class.
In addition, this commit removes a package cycle between context.aot and
context.web that was introduced in commit dc7c7ac22a.
See gh-29026, gh-29069
Although RuntimeHintsRegistrar can be implemented to register general
hints that should be applied for all testing infrastructure, certain
use cases require access to test classes and the
MergedContextConfiguration in order to register appropriate hints.
To address that, this commit introduces TestRuntimeHintsRegistrar as a
companion to the core RuntimeHintsRegistrar.
Closes gh-29069
This commit introduces automatic registration of a runtime hint for
classpath resources configured via the `value` attribute in
@WebAppConfiguration.
Closes gh-29026
This commit introduces automatic registration of runtime hints for
classpath resources configured via the `locations` attribute in
@TestPropertySource as well as for detected default properties files.
Closes gh-29025
This commit introduces automatic registration of runtime hints for
classpath resources configured via the `locations` attribute in
@ContextConfiguration.
Closes gh-29021
This commit automatically registers runtime hints for
TestContextBootstrapper classes, including default bootstrappers as
well as any bootstrapper configured via @BootstrapWith.
Closes gh-29023