Commit Graph

24791 Commits

Author SHA1 Message Date
Stephane Nicoll
e5f9574800 Fix test
Contribution was not applied on the actual use case

See gh-28915
2022-08-04 09:32:45 +02:00
Brian Clozel
34266f22c7 Merge branch '5.3.x' 2022-08-03 23:16:13 +02:00
Brian Clozel
0caa2ac696 Customize connection in UrlResource getInputStream
Prior to this commit, the `AbstractFileResolvingResource` would
provide a default implementation for `customizeConnection` which only
sets the HTTP request method as "HEAD".
While this is consistent with its usage within that class (in
`exists()`, `contentLength()` or `lastModified()`), this is not opened
for general usage by sub-classes.

`UrlResource` is an example of that, where its `getInputStream()` method
does not call this customization method.

This not only prevents implementations from calling
`customizeConnection` in various cases, but it also misleads developers
as they might think that customizations will be applied automatically.

This commit ensures that `customizeConnection` is called in all relevant
places and that the configuration of the HTTP method is instead done in
each method as it is use case specific.

Fixes gh-28909
2022-08-03 23:13:52 +02:00
Sam Brannen
855a3e5221 Polish ContextLoader support 2022-08-03 18:37:54 +03:00
Sam Brannen
e3f4d810f6 Revise configurable refresh support in SmartContextLoader SPI
This commit revises 903e9f2a02 based on feedback from the Spring Boot
team.

- The original loadContext(MergedContextConfiguration) method is no
  longer deprecated.

- loadContext(MergedContextConfiguration, boolean) has been replaced by
  loadContextForAotProcessing(MergedContextConfiguration) which is
  implemented as a `default` method that throws an
  UnsupportedOperationException.

- Affected code has been refactored to adjust to these changes.

See gh-28906
2022-08-03 16:54:32 +03:00
Stephane Nicoll
3a890033b7 Fix custom bean definition to stop using reflection
See gh-28915
2022-08-03 14:51:52 +02:00
Sam Brannen
903e9f2a02 Introduce configurable refresh support in SmartContextLoader SPI
Prior to this commit, the contract of the loadContext() method in the
SmartContextLoader SPI required that the ApplicationContext be returned
in a fully refreshed state with a JVM shutdown hook registered for it.

However, in order to support AOT processing within the Spring
TestContext Framework (TCF), we need a way to signal to
SmartContextLoader implementations that they should load the test's
ApplicationContext without refreshing it or registering a JVM shutdown
hook.

To address this issue, this commit:

- Introduces a new loadContext(MergedContextConfiguration, boolean)
  method. The boolean `refresh` flag controls whether the returned
  ApplicationContext should be refreshed and have a JVM shutdown hook
  registered for it.

- Deprecates the existing loadContext(MergedContextConfiguration)
  method in favor of loadContext(MergedContextConfiguration, boolean).

- Removes all use of the deprecated method within the spring-test
  module, excluding the exception mentioned below.

Note that loadContext(MergedContextConfiguration, boolean) is
implemented as an interface `default` method which delegates to the
deprecated loadContext(MergedContextConfiguration) method for backward
compatibility. When migrating a SmartContextLoader to Spring Framework
6.0, implementations that directly implement the SmartContextLoader SPI
(instead of extending AbstractGenericContextLoader or
AbstractGenericWebContextLoader) will need to override the new
loadContext(MergedContextConfiguration, boolean) method in order to
honor the `refresh` flag for AOT processing support. See the
implementation in AbstractGenericContextLoader for an example of how
this can be achieved.

Closes gh-28906
2022-08-03 13:10:35 +03:00
Stephane Nicoll
dcad3beeb9 Polish 2022-08-03 11:03:28 +02:00
Stephane Nicoll
c9faff7491 Apply property hints to FactoryBean if necessary
This commit handles a BeanDefinition that configures the FactoryBean
as the "beanClass", while exposing the actual type in "resolvedType".
While unusual, this is required in certain cases when the factory
bean exposes generic information itself.

Previously, the hints for properties injection were applied on the
user type.

Closes gh-28913
2022-08-03 10:58:41 +02:00
Stephane Nicoll
e79a8f6733 Polish 2022-08-03 10:53:57 +02:00
Stephane Nicoll
1fdd91eb30 Restore order of setImportMetadata in AOT optimized contexts
This commit adapts the generated code for handling ImportAware to
register a bean definition rather than adding the BeanPostProcessor
directly on the beanFactory. The previous arrangement put the
post processor handling import aware callbacks first on the list,
leading to inconsistent callback orders.

Tests have been adapted to validate this exact scenario.

Closes gh-28915
2022-08-03 10:16:20 +02:00
Stephane Nicoll
058b5fef6b Merge branch '5.3.x' 2022-08-02 16:11:16 +02:00
Stephane Nicoll
4eb8a5c082 Merge pull request #28914 from izeye
* pr/28914:
  Fix Javadoc since for new modules() and modulesToInstall()

Closes gh-28914
2022-08-02 16:11:04 +02:00
Johnny Lim
d080b64907 Fix Javadoc since for new modules() and modulesToInstall()
See gh-28914
2022-08-02 16:10:47 +02:00
Sam Brannen
abd06768a3 Avoid dependence on deprecated ContextLoader API within AbstractContextLoader
See gh-28905
2022-08-02 15:29:04 +03:00
Sam Brannen
cf1d4638ae Avoid use of deprecated ContextLoader methods in tests
See gh-28905
2022-08-02 15:12:40 +03:00
Sam Brannen
72548f7611 Improve documentation of SmartContextLoader contracts 2022-08-02 13:48:53 +03:00
Sam Brannen
ee33aa6117 Remove remaining reference to GenericPropertiesContextLoader
See gh-28911
2022-08-02 13:12:28 +03:00
Sam Brannen
2207d65b82 Deprecate methods in ContextLoader API in the TestContext framework
For Spring Framework 6.0 we have decided to deprecate the obsolete
methods in the ContextLoader API in the Spring TestContext Framework in
favor of the methods in the SmartContextLoader API which has been
available since Spring Framework 3.1.

Closes gh-28905
2022-08-02 13:07:12 +03:00
Sam Brannen
9c91375d75 Remove deprecated GenericPropertiesContextLoader from the TCF
Since GenericPropertiesContextLoader was deprecated in Spring Framework
5.3, we have decided to remove it in Spring Framework 6.0.

Closes gh-28911
2022-08-02 13:07:12 +03:00
Sam Brannen
b0ab0edd9d Polishing 2022-08-02 13:07:12 +03:00
Brian Clozel
42b3339cb9 Fix RecordedInvocation instance resolution
This commit fixes `RecordedInvocation` and
`RuntimeHintsInvocationsAssert` so that they don't refer to the recorded
instance for static calls.

This also consistently resolves the `TypeReference` of recorded
instances.

Fixes gh-28907
2022-08-01 17:45:55 +02:00
Sam Brannen
e4a7e35ead Polish TestCompiler 2022-08-01 13:41:50 +03:00
Sam Brannen
42ea09b08a Remove Hamcrest support from CompileWithTargetClassAccessClassLoader
CompileWithTargetClassAccessClassLoader is currently only used within the
CompileWithTargetClassAccessExtension which is dedicated to JUnit Jupiter
support which in turn should not have any direct dependencies on Hamcrest.

In other words, the JupiterTestEngine should not load any Hamcrest types
that would cause issues with the CompileWithTargetClassAccessClassLoader.
2022-08-01 13:37:03 +03:00
Sam Brannen
d9bf3e54f7 Removed unused method parameter
See gh-28901
2022-08-01 13:29:48 +03:00
Phillip Webb
4a23d9234c Include shadow source jars in eclipse setup
See gh-28892
2022-08-01 11:28:01 +01:00
Sam Brannen
ce850a583c Support overloaded test methods in CompileWithTargetClassAccessExtension
Prior to this commit, CompileWithTargetClassAccessExtension failed to
properly select overloaded test methods because it ignored the method
parameter list when looking up the test method.

This commit addresses this issue by selecting the test method using its
fully qualified method name which takes in account the class name,
method name, and parameter names.

Closes gh-28901
2022-08-01 13:07:58 +03:00
Sam Brannen
8fb27c3857 Polish CompileWithTargetClassAccessExtension 2022-08-01 13:07:58 +03:00
Sam Brannen
4896b115d2 Ensure CompileWithTargetClassAccessExtension only uses Jupiter TestEngine
Commit 9dd7f5412a (which has now been
reverted) addressed the issue of having the TestNG TestEngine for the
JUnit Platform on the test runtime classpath by allowing `org.testng`
types to pass through to the original ClassLoader; however, that fix
merely obfuscated the underlying issue.

The underlying issue is that the CompileWithTargetClassAccessExtension
is only applicable to JUnit Jupiter tests and therefore should launch
the JUnit Platform with only the JUnit Jupiter TestEngine active.

This commit addresses this issue by applying an EngineFilter to include
only the "junit-jupiter" test engine.

Closes gh-28900
2022-08-01 12:48:41 +03:00
Sam Brannen
b89b6bd7a8 Revert "Support TestNG with @CompileWithTargetClassAccess"
This reverts commit 9dd7f5412a.
2022-08-01 12:44:42 +03:00
Sam Brannen
fa74c353eb Revert "Polishing"
This reverts commit c8648b523b.
2022-08-01 12:44:34 +03:00
Stephane Nicoll
13c68aab52 Merge pull request #28890 from eltociear
* pr/28890:
  Fix typo in BasicJsonWriter.java

Closes gh-28890
2022-08-01 09:17:51 +02:00
Ikko Ashimine
4ac9b7bff2 Fix typo in BasicJsonWriter.java
See gh-28890
2022-08-01 09:17:28 +02:00
Sam Brannen
c8648b523b Polishing 2022-07-31 15:07:02 +03:00
Sam Brannen
9dd7f5412a Support TestNG with @CompileWithTargetClassAccess 2022-07-31 14:57:48 +03:00
Sam Brannen
e4395f2f8b Clean up warnings and polishing 2022-07-31 14:14:56 +03:00
Phillip Webb
9d1e9703ae Include shadowed jar source in published source artifacts
Add a new `ShadowSource` Gradle task and update `spring-core.gradle`
to include source for cglib, javapoet and objenesis.

Closes gh-28892

Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com>
2022-07-30 10:25:58 +01:00
Sam Brannen
2dc8335b7f Make BootstrapUtils public
See gh-28891
2022-07-30 11:21:14 +03:00
Sam Brannen
ebeadc74c5 Add missing [@]since tag
See gh-17282
2022-07-30 11:14:06 +03:00
Sam Brannen
64c3ad3634 Make BootstrapUtils.resolveTestContextBootstrapper() public
Closes gh-28891
2022-07-30 11:09:07 +03:00
Sam Brannen
ad99add429 Polish AOT support 2022-07-30 10:51:14 +03:00
Sam Brannen
3912ef1507 Polish TestCompiler support 2022-07-30 10:51:14 +03:00
Stephane Nicoll
11d790c6eb Merge branch '5.3.x' 2022-07-29 18:07:37 +02:00
Stephane Nicoll
5ab55dfb64 Merge pull request #28183 from luvarqpp
* pr/28183:
  Polish "Improve documentation of Cacheable"
  Improve documentation of Cacheable

Closes gh-28183
2022-07-29 18:06:57 +02:00
Stephane Nicoll
04209def46 Polish "Improve documentation of Cacheable"
Apply the same improvements to CacheEvict and CachePut.

See gh-28183
2022-07-29 18:04:23 +02:00
luvarqpp
3a61930bd0 Improve documentation of Cacheable
See gh-28183
2022-07-29 17:57:15 +02:00
Stephane Nicoll
7b4a37f573 Merge pull request #28472 from JiayiLi1999
* pr/28472:
  Polish "Improve test coverage of RdbmsOperation"
  Improve test coverage of RdbmsOperation

Closes gh-28472
2022-07-29 17:37:30 +02:00
Stephane Nicoll
f9ee8a93ad Polish "Improve test coverage of RdbmsOperation"
See gh-28472
2022-07-29 17:36:33 +02:00
Jiayi Li
608be54a58 Improve test coverage of RdbmsOperation
See gh-28472
2022-07-29 17:28:00 +02:00
Stephane Nicoll
1bdb67cda9 Merge branch '5.3.x' 2022-07-29 17:13:52 +02:00