Compare commits

...

121 Commits

Author SHA1 Message Date
Brian Clozel daf9551578 Next development version (v6.2.20-SNAPSHOT) 2026-06-08 19:16:50 +02:00
Sam Brannen 76a36dfd70 Track operations during SpEL expression evaluation
This commit introduces support for tracking operations during SpEL
expression evaluation. If the maximum number of operations is exceeded,
a SpelEvaluationException is thrown.

The limit can be configured either on a per-use-case basis via
SpelParserConfiguration supplied to the SpelExpressionParser or
globally as a JVM system property or Spring property named
`spring.expression.maxOperations`.

Closes gh-36801
2026-06-08 15:13:12 +02:00
Sam Brannen 3d47da9746 Ensure getters have non-void return types in SpEL
Closes gh-36800
2026-06-08 15:13:12 +02:00
Sam Brannen 519d7332eb Improve additional error messages in SpEL
This commit picks up where 987d6cca6d left off.

See gh-36756
2026-06-08 15:13:12 +02:00
Sam Brannen ec89834fa8 Further improve pattern caching in SpEL
See gh-36755
2026-06-08 15:13:12 +02:00
Sam Brannen b294371a46 Avoid too many character access attempts in AntPathMatcher
Closes gh-36799
2026-06-08 15:13:12 +02:00
Sébastien Deleuze 1829b42b9c Ensure consistent JSP tag attribute processing
Closes gh-36798
2026-06-08 15:13:12 +02:00
Sébastien Deleuze 86d99790db Refine JavaScriptUtils#javaScriptEscape
Closes gh-36796
2026-06-08 15:13:12 +02:00
Sébastien Deleuze 3aaec98765 Prevent special prefixes in default view name resolution
This commit updates the default view name generation logic in
both Spring WebMVC and Spring WebFlux to prevent "redirect:"
and "forward:" (for MVC) prefixes from the incoming request path.

Closes gh-36794
2026-06-08 15:13:12 +02:00
Sébastien Deleuze ee4e79002b Add trusted packages to MappingJackson2MessageConverter
This commit introduces trusted packages, specified via the related
setter for untrusted use cases. It allows explicit configuration
of which Java packages are allowed to be deserialized.

Closes gh-36792
2026-06-08 15:13:12 +02:00
rstoyanchev ce90e4b11f RfcParser rejects invalid IPv6 host
Closes gh-36787
2026-06-08 15:13:12 +02:00
Brian Clozel 224e647e1b Upgrade to Reactor 2024.0.18
Closes gh-36882
2026-06-08 12:19:46 +02:00
Brian Clozel c0d399ab88 Upgrade to Micrometer 1.15.12
Closes gh-36881
2026-06-08 10:25:24 +02:00
Sam Brannen 5c4497a96c Fix additional links to Selenium documentation
See gh-36875

(cherry picked from commit b4a378186f)
2026-06-05 14:58:22 +02:00
leestana01 0fadafa9bc Fix broken links to Selenium documentation
The links to docs.seleniumhq.org no longer resolve, since the host was
retired.

This commit changes those links to use the current Selenium
documentation at selenium.dev.

Closes gh-36875

Signed-off-by: leestana01 <leestana01@naver.com>
(cherry picked from commit 220fcaa1e3)
2026-06-05 14:58:14 +02:00
Brian Clozel f161a419bd Polishing contribution
This commit adds further fixes in the same area, since there were
similar bugs in the WriteCompletionHandler:
* databuffers were not always emitted when fully read in the onNext hook
* on completion, the iterator was closed too early, before it was fully
  read
* on completion, writing the next bytebuffers from the iterator would
  always reuse the first one and not update the attachment

Closes gh-36714
2026-06-04 12:20:04 +02:00
KimDaehyeon 244f6ec390 Fix data loss in DataBufferUtils synchronous write
Prior to this commit, WritableByteChannelSubscriber.hookOnNext() called
iterator.next() exactly once. If a DataBuffer consisted of multiple NIO
ByteBuffers (e.g., NettyDataBuffer wrapping a CompositeByteBuf), only
the first buffer was written to the channel, and the remaining buffers
were silently ignored and lost.

This commit adds the missing while (iterator.hasNext()) outer loop to
ensure all fragmented buffers exposed by the iterator are completely
and safely written to the synchronous channel.

See gh-36714

Signed-off-by: KimDaehyeon <daehyeon3351@gmail.com>
2026-06-04 12:19:52 +02:00
Brian Clozel cca70d4ad2 Polishing contribution
This fixes a potential regression introduced by the previous commit.
Because the current value was not updated after the temporal was rolled
forward, there were new cases where entire days would be skipped.

Closes gh-36865
2026-06-04 10:38:53 +02:00
arno 96b44949a8 Fix CronExpression day skip on midnight DST gap
After rollForward, BitsCronField always searched for the next
matching bit from zero. When daylight saving creates a gap at
the start of a period (e.g. Africa/Cairo), the temporal lands on
a non-zero field value and matching from zero could advance an
entire period too far, skipping the calendar day.

Search from the actual field value in the new period instead,
falling back to zero only when no bit matches in that period.

See gh-36865

Signed-off-by: arno <me@zmovo.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 10:38:17 +02:00
Juergen Hoeller 2555655ccf Fix concurrency issue against shared cookie field in setLocaleContext
Closes gh-36869

(cherry picked from commit 2e653246b5)
2026-06-03 23:10:36 +02:00
Brian Clozel ecfa498ea9 Support multi-line comments in Server Sent Events
Prior to this commit, comments sent with Server Sent Events could break
the wire format when sent over the network when comments contained line
breaks.
While comments are mainly used for sending keepalive messages, they can
also be used for sending debug data. This commit ensures that line
breaks are properly handled in comments.

Fixes gh-36866
2026-06-03 11:22:49 +02:00
Juergen Hoeller e2646fe324 Fix applicability note on setAutoGrowCollectionLimit
Closes gh-36863

(cherry picked from commit ecc847c493)
2026-06-02 17:38:09 +02:00
Sam Brannen a22818564b Update antora-extensions to 1.14.12
Closes gh-36851

(cherry picked from commit 6985d00fce)
2026-05-28 11:00:21 +02:00
Juergen Hoeller c37ba027e7 Upgrade to Netty 4.1.134 2026-05-27 16:53:44 +02:00
Juergen Hoeller 2dd550d80f Force initialization of configuration class in mainline thread
Closes gh-36844

(cherry picked from commit af2b96192d)
2026-05-27 16:52:15 +02:00
Juergen Hoeller 9ca396e424 Remove scanned class only when conflicting with imported class
Closes gh-36835

(cherry picked from commit 121c0ac285)
2026-05-27 16:52:11 +02:00
Juergen Hoeller 2eb0ba3843 Fix MethodParameter nestingLevel documentation
Closes gh-36826

(cherry picked from commit 3e585830d7)
2026-05-27 16:52:07 +02:00
Sam Brannen cc48200b65 Upgrade Antora dependencies
(cherry picked from commit b95caa8331)
2026-05-27 12:17:18 +02:00
Sam Brannen 44150f2523 Pin Node.js version to 24.15.0
Prior to this commit, the `antora` Gradle task silently failed to build
the reference documentation, since Antora uses the latest LTS release
for Node.js by default, and the latest LTS apparently does not work for
us.

(cherry picked from commit 7651d5841f)
2026-05-27 12:05:48 +02:00
Sam Brannen a0a3fe41f6 Polish contribution
See gh-36833

(cherry picked from commit 6e122d3aaa)
2026-05-26 16:45:16 +02:00
seonwoo_jung de18f74c53 Expose ClassLoader from DefaultDeserializer
Add a public accessor for the ClassLoader configured on a
DefaultDeserializer instance so that callers no longer need to read the
private field via reflection in order to forward it to a
ConfigurableObjectInputStream subclass.

See gh-36827
Closes gh-36833

Signed-off-by: seonwoo_jung <laborlawseon@kap.kr>
(cherry picked from commit f7be796c1c)
2026-05-26 16:45:16 +02:00
dependabot[bot] 89ecaea937 Upgrade fast-xml-parser to 5.7.0
Closes gh-36691

(cherry picked from commit ac24766510)
2026-05-20 16:54:45 +02:00
Juergen Hoeller 444877a475 Polishing
(cherry picked from commit 8fe1de4595)
2026-05-13 19:57:29 +02:00
Juergen Hoeller 57b62dd73a Restrict SpringVersion.getVersion() to "major.minor.patch" format
Closes gh-36785

(cherry picked from commit c048074436)
2026-05-12 16:25:05 +02:00
Yanming Zhou 5f661f1b64 Fix typos for validateExistingTransaction
Closes gh-36767

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>

(cherry picked from commit cfb8dc6cc8)
2026-05-09 16:41:51 +02:00
Juergen Hoeller b0137977d8 Upgrade to Netty 4.1.133 2026-05-08 16:11:11 +02:00
Juergen Hoeller 425ce8625a Consistently expose map key quotes
Closes gh-36765

(cherry picked from commit d3152c11c7)
2026-05-08 16:10:16 +02:00
Juergen Hoeller 85c578b929 Avoid ResolvableType#forType contention for implicit cache cleanup
Closes gh-36745

(cherry picked from commit 856e1d5dc8)
2026-05-08 16:10:02 +02:00
Sam Brannen cf727bd7c8 Fix error message for invalid regex in SpEL
Closes gh-36756

(cherry picked from commit 987d6cca6d)
2026-05-06 13:55:18 +02:00
shenjianeng e8f08b4158 Refactor regex pattern caching using computeIfAbsent
Closes gh-36755

Signed-off-by: shenjianeng <ishenjianeng@qq.com>

(cherry picked from commit ec21dc0f91)
2026-05-06 13:55:03 +02:00
Brian Clozel c6b485c31d Do not warn against Root Servlet context location
Closes gh-36693
2026-05-05 11:54:02 +02:00
rstoyanchev b8ddd2c690 Avoid race in InMemoryWebSession
Closes gh-36742
2026-05-01 15:23:59 +01:00
rstoyanchev a42a6e0c6a Switch to JdkIdGenerator in AbstractWebSocketSession
Closes gh-36740
2026-05-01 14:23:00 +01:00
Brian Clozel 8a93a88962 Fix parsing failure for MIME types with quoted pairs
Prior to this commit, MIME types with parameter values that contain a
quoted pair would sometimes fail and parse an incomplete parameter
value.

This commit ensures that the quoted section of the parameter value is
correctly handled.

Fixes gh-36730
2026-04-30 16:26:12 +02:00
Juergen Hoeller fdcf4d50f0 Consistent wrapping of BeanCreationExceptions from instance suppliers
Closes gh-36725

(cherry picked from commit 08c5280843)
2026-04-30 14:50:04 +02:00
Juergen Hoeller 3c023114fb Polishing
(cherry picked from commit cd5fee5347)
2026-04-29 22:03:04 +02:00
Juergen Hoeller 8b5cbb7496 Detect custom deserialized NullValue instances
Closes gh-36727

(cherry picked from commit 916cb64581)
2026-04-29 22:02:13 +02:00
Brian Clozel a58fdeaf3f Fix PartGenerator token request while creating tmp file
Prior to this commit, the `PartGenerator` would allow requesting
additional part tokens while in the `CreateFileState`. This is invalid
as any new token emitted would be rejected and would fail the entire
process.
This would only happen if the tmp file creation is slow enough for a new
token to be parsed and emitted.

This commit ensures that no new part token is requested while creating
the temporary file.
This change also fixes lifecycle issues and ensures that buffer
resources are cleaned in case of errors.

Fixes gh-36694
2026-04-28 23:30:01 +02:00
Sigurd Gerke e4bfdfa229 Fix a regression on value class parameter handling
This commit fixes a regression introduced by gh-36449 for
nullable value class with an non-null value.

Closes gh-36720
Signed-off-by: Sigurd Gerke <sigurd.gerke@onedata.de>
2026-04-28 11:08:06 +02:00
Brian Clozel 46867fad81 Avoid cache collisions in CachingResourceResolver
Prior to this commit, there could be cache collisions in the
`CachingResourceResolver` because the cache key generation was
incomplete. This commit expands the cache key generation to avoid such
cases.

Fixes gh-36713
2026-04-28 09:30:39 +02:00
Sam Brannen 371dcc5c13 Upgrade to JUnit 5.14.4
Closes gh-36707
2026-04-27 14:09:59 +03:00
Yanming Zhou dc032c1e33 Remove unnecessary invocations of toString()
Closes gh-36709

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>

(cherry picked from commit bfb88cfc1c)
2026-04-27 14:06:20 +03:00
Yanming Zhou 626907bbfd Update copyright headers in remaining source files
Closes gh-36703

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>

(cherry picked from commit c4dfb24116)
2026-04-27 14:05:50 +03:00
Brian Clozel 8d51f47357 Enfoce single version removal in content versioning
Prior to this commit, content based version strategies would remove all
instances of the version string in the request path when trying to
resolve the original resource with the chain.
This can cause issues in rare cases where there is a collision between
the content version and some other version string in the request path.

Because this strategy is based on the contents of the file itself, we
should only remove the last instance of the version string and then
attempt to resolve the original file.

Fixes gh-36698
2026-04-23 15:08:06 +02:00
Brian Clozel fb0c78ae27 Warn against unsafe static resource locations
Prior to this commit, `ResourceHandlerUtils` would perform resource
location checks to ensure that the configured location is valid. This
commit also ensures that we log a WARN message if the application
chooses a well-known unsafe location like "classpath:" or the root
Servlet context for serving static resources.

Closes gh-36693
2026-04-23 10:47:34 +02:00
Juergen Hoeller 9f431e2eac Polishing
(cherry picked from commit 8965d9bccf)
2026-04-21 20:41:11 +02:00
Juergen Hoeller cba8f225d9 Consistently ignore exceptions for Xerces-specific properties
Closes gh-36682

(cherry picked from commit af7a5716e8)
2026-04-21 20:41:06 +02:00
Stéphane Nicoll 515152b645 Next development version (v6.2.19-SNAPSHOT) 2026-04-17 08:32:54 +02:00
Juergen Hoeller f6671e77e2 Upgrade to Reactor 2024.0.17 and Micrometer 1.15.11
Closes gh-36660
Closes gh-36661
2026-04-16 23:47:49 +02:00
rstoyanchev b338fdd99d Add doOnDiscard in MultipartHttpMessageReader
Closes gh-36563
2026-04-16 21:19:13 +01:00
Sam Brannen 4e3f264f34 Add missing tests for WebRequestDataBinder
See gh-36625

(cherry picked from commit 63817ce202)
2026-04-16 16:36:27 +02:00
Sam Brannen 9e0b83ead3 Polish WebRequestDataBinderTests
(cherry picked from commit 61bd79017f)
2026-04-16 16:36:18 +02:00
Sam Brannen af4b1229a5 Extract ServletRequestParameterPropertyValuesTests
(cherry picked from commit c9b88b4ebd)
2026-04-16 15:08:23 +02:00
Sam Brannen 623ccd1a4f Revise "Skip binding entirely when field is not allowed"
This commit reverts the changes made to WebDataBinder's doBind()
implementation in e4d03f6625 and instead implements the skipping logic
directly in checkFieldDefaults(), checkFieldMarkers(), and
adaptEmptyArrayIndices() by preemptively checking if the corresponding
field is allowed.

This commit also improves the Javadoc and adds missing tests.

See gh-36625
Fixes gh-36627

(cherry picked from commit 68c575ab14)
2026-04-16 15:08:09 +02:00
Sam Brannen 69068ba33d Further clarify semantics of HttpMethod.valueOf()
See gh-36652

(cherry picked from commit cb320468db)
2026-04-14 16:19:43 +02:00
angry2.k f182f9a76b Clarify semantics of HttpMethod.valueOf()
HttpMethod.valueOf() performs a case-sensitive lookup of predefined
HttpMethod constants. For example, valueOf("GET") resolves to
HttpMethod.GET, whereas valueOf("get") results in a newly created
HttpMethod instance.
Update the Javadoc to explicitly document this behavior.

See gh-36642
Closes gh-36652

Signed-off-by: angry-2k <edkev@kakao.com>

(cherry picked from commit df828458fa)
2026-04-14 16:19:35 +02:00
Sam Brannen 9d144487e7 Improve SpEL tests for Elvis and Ternary operators
(cherry picked from commit 21f3b964fe)
2026-04-12 14:31:15 +02:00
Sébastien Deleuze b07bc2cb99 Apply nullable value class fix to InvocableHandlerMethod
See gh-36643
2026-04-10 16:24:36 +02:00
T45K 57d4765131 Fix nullable value class handling in CoroutinesUtils
Closes gh-36643
Signed-off-by: T45K <tasktas9@gmail.com>
2026-04-10 16:22:55 +02:00
Brian Clozel cbdec804a5 Allow null id/event in ServerSentEvent
The builder itself does not allow `null` values so this shouldn't be
necessary, but because the offending change was introduced late in the
6.2.x line, we'll be more flexible here.

Fixes gh-36634
2026-04-10 14:43:29 +02:00
Sam Brannen 438b1011fe Revise documentation for @⁠ActiveProfiles and ActiveProfilesResolver
See gh-36269
See gh-36600

(cherry picked from commit 99b78adce3)
2026-04-09 12:59:42 +02:00
Mohak-Nagaraju c5e560574c Document that spring.profiles.active is ignored by @⁠ActiveProfiles
The Spring TestContext Framework does not honor the
`spring.profiles.active` system property when determining
active profiles for a test class if @⁠ActiveProfiles is
used.

This commit documents that behavior in the @⁠ActiveProfiles
and DefaultActiveProfilesResolver Javadoc, as well as in
the reference manual. A SystemPropertyActiveProfilesResolver
example is also added showing how to allow
`spring.profiles.active` to override @⁠ActiveProfiles.

See gh-36269
Closes gh-36600

Signed-off-by: Mohak Nagaraju <98132980+Mohak-Nagaraju@users.noreply.github.com>
(cherry picked from commit 644731c9f6)
2026-04-09 12:59:34 +02:00
Brian Clozel 589e58e400 Skip binding entirely when field is not allowed
Prior to this commit, fields that are not allowed for binding were
always skipped and would not be bound. But the field and default marker
support (with the "_" and "!" prefixes) would be still considered and
could trigger collection instantiation/autogrow.

While this does not cause unwanted binding, this allocates memory for no
reason. This commit revisits the binding algorithm to only consider
default and field marker support if the regular field is allowed.

Fixes gh-36627
2026-04-09 11:06:46 +02:00
Sam Brannen 6101419d80 Support @⁠Sql with DataSource wrapped in a TransactionAwareDataSourceProxy
Prior to this commit, SqlScriptsTestExecutionListener unwrapped data
sources wrapped in an InfrastructureProxy or a scoped proxy, but it did
not unwrap a data source wrapped in a TransactionAwareDataSourceProxy.
Consequently, the sameDataSource() check failed in the latter case,
preventing execution of @⁠Sql scripts.

To address that, this commit revises sameDataSource() to unwrap a
TransactionAwareDataSourceProxy as well, analogous to the
implementations of setDataSource() in DataSourceTransactionManager,
JpaTransactionManager, and HibernateTransactionManager.

Closes gh-36611

(cherry picked from commit 6251b2c0c9)
2026-04-09 10:36:55 +02:00
Juergen Hoeller 63cd96fa5f Revise target bean exception with consistent message formatting 2026-04-08 15:48:17 +02:00
Juergen Hoeller 923ec6a8e1 Upgrade to Groovy 4.0.31 and Mockito 5.23 2026-04-08 15:09:57 +02:00
Juergen Hoeller 241a7dca02 Polishing
(cherry picked from commit 1687d90a8c)
2026-04-08 15:09:33 +02:00
Juergen Hoeller d675132ac0 Improve SpringValidatorAdapter and MethodValidationAdapter performance
Closes gh-36621

(cherry picked from commit b8f1005897)
2026-04-08 13:57:27 +02:00
Juergen Hoeller 2801c7e23e Avoid MessageFormat rendering for exception messages in binding errors
Closes gh-36609

(cherry picked from commit 0150c4ba06)
2026-04-08 13:57:22 +02:00
Sam Brannen d356e7a238 Improve Javadoc for MergedAnnotations
(cherry picked from commit b560c7b85d)
2026-04-08 12:36:44 +02:00
Brian Clozel df198987e0 Allow unlimited caching in ContentCachingRequestWrapper
Prior to this commit the `ContentCachingRequestWrapper(HttpServletRequest)`
constructor was deprecated; this variant caches by default an unlimited
amount of data. The replacement
`ContentCachingRequestWrapper(HttpServletRequest, int)` allows such
behavior in 7.0 but that change has not been bacported to 6.2.x.

This commit ensures that the replacement constructor can be safely used
in 6.2.x, preparing for the 7.0.x upgrade.

Fixes gh-36620
2026-04-08 11:29:27 +02:00
Sam Brannen b6a246989f Use ClassLoader for method or field in MergedAnnotation
Prior to this commit, the `return` keyword was missing in
TypeMappedAnnotation's getClassLoader() implementation, which prevented
the ClassLoader of the Member (Method or Field) from being used.

This commit fixes that by adding the missing `return` keyword and adds
a test using a custom ClassLoader to verify the correct behavior.

Closes gh-36606

(cherry picked from commit f3b6c222f9)
2026-04-07 18:24:04 +02:00
Brian Clozel 2a9afd6ede Document valid SpEL separators for tokenizer
(cherry picked from commit 14466eef4c)
(cherry picked from commit 8d390f4e5a)
2026-04-07 18:23:46 +02:00
Sam Brannen 9c82638820 Fix typo
(cherry picked from commit 9d365906b5)
2026-04-06 17:02:31 +02:00
Sam Brannen b2069e4c37 Fix flaky SpEL tests
This commit fixes SpEL related tests that failed if the test methods
were executed in a different order than in the Gradle build.

(cherry picked from commit 97e10a5948)
2026-04-06 17:02:14 +02:00
Sam Brannen 659271cf61 Fix BridgeMethodResolverTests.findBridgedMethodInHierarchy() in Eclipse
(cherry picked from commit bfbfe4a572)
2026-04-06 17:00:57 +02:00
Brian Clozel 39a6d4709f Deprecate types removed in 7.0
This commit `@Deprecate` for removal the following because support was
removed in 7.0:

* Netty 5 and Reactor Netty2 experimental support is abandonned
* Undertow does not support the Framework 7.0 baseline, developers
  should consider another Servlet container at this point

See gh-36591
2026-04-03 17:50:38 +02:00
Sam Brannen d78d80b02a Skip annotations that cannot be processed in AnnotationBeanNameGenerator
Prior to this commit, AnnotationBeanNameGenerator failed when searching
for a convention-based bean name, if an annotation referenced a
non-existent class.

To address that, this commit introduces a try-catch block around each
invocation of MergedAnnotation.asAnnotationAttributes() and skips
processing of the current MergedAnnotation if an exception occurs,
which is likely due to a type referenced from an annotation attribute
not being present in the classpath.

See gh-31203
Closes gh-36524

(cherry picked from commit 00fbd91cca)
2026-04-02 16:57:09 +02:00
Juergen Hoeller 684b1e8a4b Enforce strict implementation of Resource#isReadable() contract
Closes gh-36584

(cherry picked from commit e977bd7bf0)
2026-04-02 14:45:05 +02:00
Sam Brannen 6f204bf4a3 Polishing
(cherry picked from commit 24c7d31ba7)
2026-04-02 13:24:03 +02:00
Sam Brannen 5873e40782 Enforce use of AssertJ assumptions via Checkstyle
Closes gh-36582

(cherry picked from commit b6fc3a1b6f)
2026-04-02 13:24:03 +02:00
Sam Brannen 153e553675 Ignore .cursor directory
(cherry picked from commit d767806977)
2026-04-02 12:48:21 +02:00
Juergen Hoeller 9ceb9efb2c Polishing 2026-04-01 21:25:11 +02:00
Sam Brannen 9af3961b9b Deprecate methodIdentification() in CacheAspectSupport for removal
CacheAspectSupport currently contains a protected methodIdentification()
method which is not used internally within the framework, and it appears
that it was accidentally copied from TransactionAspectSupport when the
caching support was first introduced.

In light of that, this commit deprecates it for removal in 7.1.

See gh-36576
Closes gh-36576

(cherry picked from commit 22adccd190)
2026-03-31 17:51:17 +02:00
rstoyanchev fa04db3b03 Consistently log request details in ExchangeFunctions
Closes gh-36502
2026-03-31 16:26:37 +01:00
Sam Brannen 1a05ed236e Correct Javadoc for MergedAnnotation.asAnnotationAttributes()
Closes gh-36567

(cherry picked from commit b7a1157e66)
2026-03-30 17:03:14 +02:00
Sam Brannen 5a4a14c9c2 Polishing
(cherry picked from commit 27bc60e077)
2026-03-30 17:03:05 +02:00
Juergen Hoeller aff0ce1a00 Polishing 2026-03-28 20:53:26 +01:00
Juergen Hoeller cdfb77d5b0 Upgrade to Netty 4.1.132 and Protobuf 4.34.1 2026-03-28 11:47:13 +01:00
Juergen Hoeller 41f4072670 Fix ApplicationListenerMethodAdapter name in error message 2026-03-28 11:42:46 +01:00
Juergen Hoeller 49bb287800 Polishing
(cherry picked from commit b81a63fb5c)
2026-03-28 11:24:25 +01:00
Juergen Hoeller db6111fabe Add documentation notes on error handling with sync=true
See gh-36531

(cherry picked from commit 529a6fc932)
2026-03-28 11:23:59 +01:00
Sam Brannen 522a2e2e80 Introduce Kotlin examples for Bean Overrides (@⁠MockitoBean, etc.)
This commit introduces Kotlin examples in the reference manual for
@⁠MockitoBean, @⁠MockitoSpyBean, and @⁠TestBean.

Closes gh-36541

(cherry picked from commit 6d3d3d11c4)
2026-03-26 14:30:17 +01:00
Juergen Hoeller 0c2375a08c Consistent handling of early setCatalog/setSchema/setHoldability calls
Closes gh-36527
Closes gh-36528
2026-03-24 23:48:25 +01:00
Junseo Bae b7137c5baf Fix incorrect cross reference in AbstractEnvironment Javadoc
Closes gh-36516

Signed-off-by: Junseo Bae <ferrater1013@gmail.com>

(cherry picked from commit f92e810831)
2026-03-23 11:51:37 +01:00
Sam Brannen 315591f18e Sync changes to antora-playbook.yml from docs-build branch
(cherry picked from commit 9fba394b8a)
2026-03-23 11:37:25 +01:00
Juergen Hoeller 96a028a028 Consistent IOException spelling in class/method names 2026-03-21 12:19:07 +01:00
Juergen Hoeller 8b67472e35 Avoid endless re-interruption loop on shutdown
Closes gh-36506
2026-03-21 12:19:01 +01:00
Juergen Hoeller 3997551ba5 Recognize error code 149 as deadlock loser (MySQL Galera)
Closes gh-36499
2026-03-21 12:18:58 +01:00
Brian Clozel e607f1c30f Share codings resolution in resource resolvers
Prior to this commit, different resource resolvers would resolve
accepted codings from the HTTP request sent by the client. This would be
done with different implementations, which could lead to resolution
errors and desynchronizations.

This commit now introduced a new shared method in
`EncodedResourceResolver` (Servlet and Reactive) to perform a consisten
resolution.

Fixes gh-36507
2026-03-20 16:13:47 +01:00
Sam Brannen 506c6f1777 Clean up AssertJ usage after migration
- Avoid the use of assertThat(Arrays.equals(...))
- Convert assertThat(Boolean.FALSE).isEqualTo(x) to assertThat(x).isEqualTo(Boolean.FALSE)
- Convert assertThat(Boolean.TRUE).isEqualTo(x) to assertThat(x).isEqualTo(Boolean.TRUE)
- Convert assertThat(x.equals(y)).isTrue() to assertThat(x).isEqualTo(y)
- Convert assertThat(x.equals(y)).isFalse() to assertThat(x).isNotEqualTo(y)
- Remove unnecessary parentheses in assertThat() arguments
- Convert assertThat(x instanceof X).isFalse() to assertThat(x).isNotInstanceOf()
- Convert assertThat(x instanceof X).isTrue() to assertThat(x).isInstanceOf()
- Convert assertThat(!x).isTrue() to assertThat(x).isFalse()
- Inline conditions in assertThat() statements

Closes gh-36504

(cherry picked from commit e1e4d52b61)
2026-03-20 11:38:33 +01:00
Sam Brannen 6d6b788b25 Enable SpringJUnit5 Checkstyle rule
See gh-36496
Closes gh-36496

(cherry picked from commit 1256307c83)
2026-03-18 19:07:27 +01:00
Sam Brannen 01248c7753 Remove obsolete "test" prefix from test method names
Although this commit also changes the visibility of some test methods
to package-private, the remainder of that task will be addressed in
conjunction with gh-36496.

Closes gh-36495

(cherry picked from commit 4c14abf0cd)
2026-03-18 18:27:53 +01:00
github-actions[bot] 40562e2485 Update Antora Spring UI to v0.4.26 2026-03-17 09:21:37 +01:00
jun 52345c56a7 Fix typo in StompSession Javadoc
Closes gh-36469

Signed-off-by: jun <ryuu.public@gmail.com>
(cherry picked from commit c2c6130da5)
2026-03-16 13:40:12 +01:00
Sam Brannen e598df8c60 Fix common typos and grammatical mistakes
Closes gh-36471

(cherry picked from commit 5eb0e99d58)
2026-03-15 17:19:28 +01:00
Sam Brannen 0c4ed55fd2 Consistently use American English spelling
Since the Spring Framework uses American English spelling, this commit
updates Javadoc and the reference manual to ensure consistency in that
regard. However, there are two exceptions to this rule that arise due
to their use within a technical context.

- We use "cancelled/cancelling" instead of "canceled/canceling" in
  numerous places (including error messages).
- We use "implementor" instead of "implementer".

Closes gh-36470

(cherry picked from commit 17699103dc)
2026-03-15 17:16:39 +01:00
Sam Brannen 10faa7fdff Remove obsolete, custom Eclipse configuration for spring-oxm
See gh-36195

(cherry picked from commit 9b366b28b7)
2026-03-15 14:59:32 +01:00
Sam Brannen 2269c56d61 Polish contribution
See gh-36195

(cherry picked from commit 0f990e44a8)
2026-03-15 14:59:32 +01:00
Clayton Walker 15c82d558d Improve XJC configuration for spring-oxm in the Gradle build
Closes gh-36195

Signed-off-by: Clayton Walker <clayton.m.walker@gmail.com>

(cherry picked from commit e102bc4933)
2026-03-15 14:59:25 +01:00
Brian Clozel b4646ce9b4 Next development version (v6.2.18-SNAPSHOT) 2026-03-13 09:16:10 +01:00
1084 changed files with 7843 additions and 5728 deletions
+1
View File
@@ -9,6 +9,7 @@ ivy-cache
argfile*
activemq-data/
classes/
.cursor/
# Log files
jxl.log
+3 -3
View File
@@ -15,8 +15,8 @@ content:
# https://docs.antora.org/antora/latest/playbook/content-refname-matching/
# branches: We include snapshots for main, 6.2.x, and 7.0.x to 9.*.x.
branches: ['main', '6.2.x', '{7..9}.+({0..9}).x']
# tags: We effectively include all releases from 6.0.9 to 9.*.*.
tags: ['v{6..9}.+({0..9}).+({0..9})?(-{RC,M}*)', '!(v6.0.{0..8})', '!(v6.0.0-{RC,M}{0..9})']
# tags: include all releases from 6.2.0 to 9.*.*.
tags: ['v6.2.+({0..9})', 'v{7..9}.+({0..9}).+({0..9})?(-{RC,M}*)']
start_path: framework-docs
asciidoc:
extensions:
@@ -38,4 +38,4 @@ runtime:
failure_level: warn
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.25/ui-bundle.zip
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.26/ui-bundle.zip
+4
View File
@@ -17,6 +17,10 @@ antora {
]
}
node {
version = '24.15.0'
}
tasks.named("generateAntoraYml") {
asciidocAttributes = project.provider( {
return ["spring-version": project.version ]
@@ -74,6 +74,11 @@ expressions used in XML bean definitions, `@Value`, etc.
| The mode to use when compiling expressions for the
xref:core/expressions/evaluation.adoc#expressions-compiler-configuration[Spring Expression Language].
| `spring.expression.maxOperations`
| The default maximum number of operations permitted during
xref:core/expressions/evaluation.adoc#expressions-parser-configuration[Spring Expression Language]
expression evaluation.
| `spring.getenv.ignore`
| Instructs Spring to ignore operating system environment variables if a Spring
`Environment` property -- for example, a placeholder in a configuration String -- isn't
@@ -378,7 +378,7 @@ The container also supports creating a bean with {spring-framework-api}++/beans/
. The custom arguments require dynamic introspection of a matching constructor or factory method.
Those arguments cannot be detected by AOT, so the necessary reflection hints will have to be provided manually.
. By-passing the instance supplier means that all other optimizations after creation are skipped as well.
. Bypassing the instance supplier means that all other optimizations after creation are skipped as well.
For instance, autowiring on fields and methods will be skipped as they are handled in the instance supplier.
Rather than having prototype-scoped beans created with custom arguments, we recommend a manual factory pattern where a bean is responsible for the creation of the instance.
@@ -274,7 +274,7 @@ Kotlin::
Next, you can provide the information for the candidate bean definitions. You can add
`<qualifier/>` tags as sub-elements of the `<bean/>` tag and then specify the `type` and
`value` to match your custom qualifier annotations. The type is matched against the
fully-qualified class name of the annotation. Alternately, as a convenience if no risk of
fully-qualified class name of the annotation. Alternatively, as a convenience if no risk of
conflicting names exists, you can use the short class name. The following example
demonstrates both approaches:
@@ -575,7 +575,7 @@ Kotlin::
----
======
NOTE: Do not define such beans to be lazy as the `ApplicationContext` will honour that and will not register the method to listen to events.
NOTE: Do not define such beans to be lazy as the `ApplicationContext` will honor that and will not register the method to listen to events.
The method signature once again declares the event type to which it listens,
but, this time, with a flexible name and without implementing a specific listener interface.
@@ -395,6 +395,16 @@ set a JVM system property or Spring property named `spring.context.expression.ma
to the maximum expression length needed by your application (see
xref:appendix.adoc#appendix-spring-properties[Supported Spring Properties]).
Similarly, the number of operations performed during the evaluation of a SpEL expression
cannot exceed 10,000 by default; however, the `maxOperations` value is configurable. If
you create a `SpelExpressionParser` programmatically (the recommend approach), you can
specify a custom `maxOperations` value when creating the `SpelParserConfiguration` that
you provide to the `SpelExpressionParser`. If you are not able to configure an explicit
value for `maxOperations` via `SpelParserConfiguration`, you can set a JVM system
property or Spring property named `spring.expression.maxOperations` to the maximum number
of operations required by your application (see
xref:appendix.adoc#appendix-spring-properties[Supported Spring Properties]).
[[expressions-spel-compilation]]
== SpEL Compilation
@@ -2,4 +2,12 @@
= Language Reference
:page-section-summary-toc: 1
This section describes how the Spring Expression Language works.
Spring Expression Language (SpEL) expressions are composed of a sequence of tokens such
as literals, operators, method invocations, and so forth.
Whitespace can be used freely between tokens to format and improve the readability of
expressions. Specifically, the `\s` (space), `\t` (tab), `\r` (carriage return), and `\n`
(newline) characters are all valid separators between tokens. However, whitespace is
ignored by the expression parser unless it is part of a string literal.
The following sections describe the features and syntax of SpEL.
@@ -270,7 +270,7 @@ is applicable for typical implementations of indexed structures.
NOTE: `ReflectiveIndexAccessor` also implements `CompilableIndexAccessor` in order to
support xref:core/expressions/evaluation.adoc#expressions-spel-compilation[compilation]
to bytecode for read access. Note, however, that the configured read-method must be
invokable via a `public` class or `public` interface for compilation to succeed.
invocable via a `public` class or `public` interface for compilation to succeed.
The following code listings define a `Color` enum and `FruitMap` type that behaves like a
map but does not implement the `java.util.Map` interface. Thus, if you want to index into
@@ -351,10 +351,10 @@ recognized and used as the `PropertyEditor` for `Something`-typed properties.
[literal,subs="verbatim,quotes"]
----
com
chank
pop
Something
SomethingEditor // the PropertyEditor for the Something class
└── example
└── things
├── *Something*
└── *SomethingEditor* // the PropertyEditor for the Something class
----
Note that you can also use the standard `BeanInfo` JavaBeans mechanism here as well
@@ -366,10 +366,10 @@ following example uses the `BeanInfo` mechanism to explicitly register one or mo
[literal,subs="verbatim,quotes"]
----
com
chank
pop
Something
SomethingBeanInfo // the BeanInfo for the Something class
└── example
└── things
├── *Something*
└── *SomethingBeanInfo* // the BeanInfo for the Something class
----
The following Java source code for the referenced `SomethingBeanInfo` class
@@ -22,7 +22,7 @@ where all the underlying resources have to participate in the service-level tran
NOTE: By default, a participating transaction joins the characteristics of the outer scope,
silently ignoring the local isolation level, timeout value, or read-only flag (if any).
Consider switching the `validateExistingTransactions` flag to `true` on your transaction
Consider switching the `validateExistingTransaction` flag to `true` on your transaction
manager if you want isolation level declarations to be rejected when participating in
an existing transaction with a different isolation level. This non-lenient mode also
rejects read-only mismatches (that is, an inner read-write transaction that tries to participate
@@ -72,6 +72,13 @@ bean definition profiles programmatically by implementing a custom
xref:testing/testcontext-framework/ctx-management/env-profiles.adoc#testcontext-ctx-management-env-profiles-ActiveProfilesResolver[`ActiveProfilesResolver`]
and registering it by using the `resolver` attribute of `@ActiveProfiles`.
NOTE: When `@ActiveProfiles` is declared on a test class, the `spring.profiles.active`
property (whether configured as a JVM system property or environment variable) is not
taken into account by the TestContext Framework when determining active profiles. If
you need to allow `spring.profiles.active` to override the profiles configured via
`@ActiveProfiles`, you can implement a custom `ActiveProfilesResolver` as described in
xref:testing/testcontext-framework/ctx-management/env-profiles.adoc[Context Configuration with Environment Profiles].
See xref:testing/testcontext-framework/ctx-management/env-profiles.adoc[Context Configuration with Environment Profiles],
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration], and the
{spring-framework-api}/test/context/ActiveProfiles.html[`@ActiveProfiles`] javadoc for
@@ -130,6 +130,21 @@ Java::
}
----
<1> Replace the bean with type `CustomService` with a Mockito mock.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@SpringJUnitConfig(TestConfig::class)
class BeanOverrideTests {
@MockitoBean // <1>
lateinit var customService: CustomService
// tests...
}
----
<1> Replace the bean with type `CustomService` with a Mockito mock.
======
In the example above, we are creating a mock for `CustomService`. If more than one bean
@@ -158,6 +173,22 @@ Java::
}
----
<1> Replace the bean named `service` with a Mockito mock.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@SpringJUnitConfig(TestConfig::class)
class BeanOverrideTests {
@MockitoBean("service") // <1>
lateinit var customService: CustomService
// tests...
}
----
<1> Replace the bean named `service` with a Mockito mock.
======
The following `@SharedMocks` annotation registers two mocks by-type and one mock by-name.
@@ -177,6 +208,19 @@ Java::
----
<1> Register `OrderService` and `UserService` mocks by-type.
<2> Register `PrintingService` mock by-name.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@MockitoBean(types = [OrderService::class, UserService::class]) // <1>
@MockitoBean(name = "ps1", types = [PrintingService::class]) // <2>
annotation class SharedMocks
----
<1> Register `OrderService` and `UserService` mocks by-type.
<2> Register `PrintingService` mock by-name.
======
The following demonstrates how `@SharedMocks` can be used on a test class.
@@ -207,6 +251,34 @@ Java::
----
<1> Register common mocks via the custom `@SharedMocks` annotation.
<2> Optionally inject mocks to _stub_ or _verify_ them.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@SpringJUnitConfig(TestConfig::class)
@SharedMocks // <1>
class BeanOverrideTests {
@Autowired
lateinit var orderService: OrderService // <2>
@Autowired
lateinit var userService: UserService // <2>
@Autowired
lateinit var ps1: PrintingService // <2>
// Inject other components that rely on the mocks.
@Test
fun testThatDependsOnMocks() {
// ...
}
}
----
<1> Register common mocks via the custom `@SharedMocks` annotation.
<2> Optionally inject mocks to _stub_ or _verify_ them.
======
TIP: The mocks can also be injected into `@Configuration` classes or other test-related
@@ -236,6 +308,21 @@ Java::
}
----
<1> Wrap the bean with type `CustomService` with a Mockito spy.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@SpringJUnitConfig(TestConfig::class)
class BeanOverrideTests {
@MockitoSpyBean // <1>
lateinit var customService: CustomService
// tests...
}
----
<1> Wrap the bean with type `CustomService` with a Mockito spy.
======
In the example above, we are wrapping the bean with type `CustomService`. If more than
@@ -261,6 +348,21 @@ Java::
}
----
<1> Wrap the bean named `service` with a Mockito spy.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@SpringJUnitConfig(TestConfig::class)
class BeanOverrideTests {
@MockitoSpyBean("service") // <1>
lateinit var customService: CustomService
// tests...
}
----
<1> Wrap the bean named `service` with a Mockito spy.
======
The following `@SharedSpies` annotation registers two spies by-type and one spy by-name.
@@ -280,6 +382,19 @@ Java::
----
<1> Register `OrderService` and `UserService` spies by-type.
<2> Register `PrintingService` spy by-name.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@MockitoSpyBean(types = [OrderService::class, UserService::class]) // <1>
@MockitoSpyBean(name = "ps1", types = [PrintingService::class]) // <2>
annotation class SharedSpies
----
<1> Register `OrderService` and `UserService` spies by-type.
<2> Register `PrintingService` spy by-name.
======
The following demonstrates how `@SharedSpies` can be used on a test class.
@@ -310,6 +425,34 @@ Java::
----
<1> Register common spies via the custom `@SharedSpies` annotation.
<2> Optionally inject spies to _stub_ or _verify_ them.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@SpringJUnitConfig(TestConfig::class)
@SharedSpies // <1>
class BeanOverrideTests {
@Autowired
lateinit var orderService: OrderService // <2>
@Autowired
lateinit var userService: UserService // <2>
@Autowired
lateinit var ps1: PrintingService // <2>
// Inject other components that rely on the spies.
@Test
fun testThatDependsOnMocks() {
// ...
}
}
----
<1> Register common spies via the custom `@SharedSpies` annotation.
<2> Optionally inject spies to _stub_ or _verify_ them.
======
TIP: The spies can also be injected into `@Configuration` classes or other test-related
@@ -73,6 +73,27 @@ Java::
----
<1> Mark a field for overriding the bean with type `CustomService`.
<2> The result of this static method will be used as the instance and injected into the field.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
class OverrideBeanTests {
@TestBean // <1>
lateinit var customService: CustomService
// test case body...
companion object {
@JvmStatic
fun customService(): CustomService { // <2>
return MyFakeCustomService()
}
}
}
----
<1> Mark a field for overriding the bean with type `CustomService`.
<2> The result of this static method will be used as the instance and injected into the field.
======
In the example above, we are overriding the bean with type `CustomService`. If more than
@@ -102,6 +123,28 @@ Java::
<1> Mark a field for overriding the bean with name `service`, and specify that the
factory method is named `createCustomService`.
<2> The result of this static method will be used as the instance and injected into the field.
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
class OverrideBeanTests {
@TestBean(name = "service", methodName = "createCustomService") // <1>
lateinit var customService: CustomService
// test case body...
companion object {
@JvmStatic
fun createCustomService(): CustomService { // <2>
return MyFakeCustomService()
}
}
}
----
<1> Mark a field for overriding the bean with name `service`, and specify that the
factory method is named `createCustomService`.
<2> The result of this static method will be used as the instance and injected into the field.
======
[TIP]
@@ -3,7 +3,7 @@
In the previous sections, we have seen how to use MockMvc in conjunction with the raw
HtmlUnit APIs. In this section, we use additional abstractions within the Selenium
https://docs.seleniumhq.org/projects/webdriver/[WebDriver] to make things even easier.
https://www.selenium.dev/documentation/webdriver/[WebDriver] to make things even easier.
[[mockmvc-server-htmlunit-webdriver-why]]
== Why WebDriver and MockMvc?
@@ -12,8 +12,8 @@ We can already use HtmlUnit and MockMvc, so why would we want to use WebDriver?
Selenium WebDriver provides a very elegant API that lets us easily organize our code. To
better show how it works, we explore an example in this section.
NOTE: Despite being a part of https://docs.seleniumhq.org/[Selenium], WebDriver does not
require a Selenium Server to run your tests.
NOTE: Despite being a part of https://www.selenium.dev/documentation/[Selenium],
WebDriver does not require a Selenium Server to run your tests.
Suppose we need to ensure that a message is created properly. The tests involve finding
the HTML form input elements, filling them out, and making various assertions.
@@ -308,7 +308,7 @@ interested. These are of type `WebElement`. WebDriver's
https://github.com/SeleniumHQ/selenium/wiki/PageFactory[`PageFactory`] lets us remove a
lot of code from the HtmlUnit version of `CreateMessagePage` by automatically resolving
each `WebElement`. The
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/PageFactory.html#initElements-org.openqa.selenium.WebDriver-java.lang.Class-[`PageFactory#initElements(WebDriver,Class<T>)`]
https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/PageFactory.html#initElements-org.openqa.selenium.WebDriver-java.lang.Class-[`PageFactory#initElements(WebDriver,Class<T>)`]
method automatically resolves each `WebElement` by using the field name and looking it up
by the `id` or `name` of the element within the HTML page.
<3> We can use the
@@ -352,7 +352,7 @@ interested. These are of type `WebElement`. WebDriver's
https://github.com/SeleniumHQ/selenium/wiki/PageFactory[`PageFactory`] lets us remove a
lot of code from the HtmlUnit version of `CreateMessagePage` by automatically resolving
each `WebElement`. The
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/PageFactory.html#initElements-org.openqa.selenium.WebDriver-java.lang.Class-[`PageFactory#initElements(WebDriver,Class<T>)`]
https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/PageFactory.html#initElements-org.openqa.selenium.WebDriver-java.lang.Class-[`PageFactory#initElements(WebDriver,Class<T>)`]
method automatically resolves each `WebElement` by using the field name and looking it up
by the `id` or `name` of the element within the HTML page.
<3> We can use the
@@ -19,6 +19,6 @@ meta-annotation. If a bootstrapper is not explicitly configured by using
`WebTestContextBootstrapper` is used, depending on the presence of `@WebAppConfiguration`.
Since the `TestContextBootstrapper` SPI is likely to change in the future (to accommodate
new requirements), we strongly encourage implementers not to implement this interface
new requirements), we strongly encourage implementors not to implement this interface
directly but rather to extend `AbstractTestContextBootstrapper` or one of its concrete
subclasses instead.
@@ -543,3 +543,85 @@ Kotlin::
----
======
The following example demonstrates how to implement and register a custom
`SystemPropertyOverrideActiveProfilesResolver` that allows the `spring.profiles.active`
property (when configured as a JVM system property) to override profiles configured via
`@ActiveProfiles`:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
----
// profiles resolved programmatically via a custom resolver that
// allows "spring.profiles.active" to override @ActiveProfiles
@ActiveProfiles(
resolver = SystemPropertyOverrideActiveProfilesResolver.class,
inheritProfiles = false)
class TransferServiceTest extends AbstractIntegrationTest {
// test body
}
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
----
// profiles resolved programmatically via a custom resolver that
// allows "spring.profiles.active" to override @ActiveProfiles
@ActiveProfiles(
resolver = SystemPropertyOverrideActiveProfilesResolver::class,
inheritProfiles = false)
class TransferServiceTest : AbstractIntegrationTest() {
// test body
}
----
======
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",role="primary",fold="-imports"]
----
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.test.context.support.DefaultActiveProfilesResolver;
import org.springframework.util.StringUtils;
public class SystemPropertyOverrideActiveProfilesResolver extends DefaultActiveProfilesResolver {
@Override
public String[] resolve(Class<?> testClass) {
String profiles = System.getProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME);
if (StringUtils.hasText(profiles)) {
return StringUtils.commaDelimitedListToStringArray(
StringUtils.trimAllWhitespace(profiles));
}
return super.resolve(testClass);
}
}
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary",fold="-imports"]
----
import org.springframework.core.env.AbstractEnvironment
import org.springframework.test.context.support.DefaultActiveProfilesResolver
import org.springframework.util.StringUtils
class SystemPropertyOverrideActiveProfilesResolver : DefaultActiveProfilesResolver() {
override fun resolve(testClass: Class<*>): Array<String> {
val profiles = System.getProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME)
if (StringUtils.hasText(profiles)) {
return StringUtils.commaDelimitedListToStringArray(
StringUtils.trimAllWhitespace(profiles)
)
}
return super.resolve(testClass)
}
}
----
======
@@ -269,7 +269,7 @@ The parameters to any of the above macros have consistent meanings:
For strictly sorted maps, you can use a `SortedMap` (such as a `TreeMap`) with a
suitable `Comparator` and, for arbitrary Maps that should return values in insertion
order, use a `LinkedHashMap` or a `LinkedMap` from `commons-collections`.
* `separator`: Where multiple options are available as discreet elements (radio buttons
* `separator`: Where multiple options are available as discrete elements (radio buttons
or checkboxes), the sequence of characters used to separate each one in the list
(such as `<br>`).
* `attributes`: An additional string of arbitrary tags or text to be included within
@@ -188,7 +188,7 @@ the content negotiation during the error handling phase will decide which conten
| `View`
| A `View` instance to use for rendering together with the implicit model -- determined
through command objects and `@ModelAttribute` methods. The handler method may also
programmatically enrich the model by declaring a `Model` argument (descried earlier).
programmatically enrich the model by declaring a `Model` argument (described earlier).
| `java.util.Map`, `org.springframework.ui.Model`
| Attributes to be added to the implicit model with the view name implicitly determined
+5 -5
View File
@@ -1,11 +1,11 @@
{
"dependencies": {
"antora": "3.2.0-alpha.11",
"antora": "3.2.0-alpha.12",
"@antora/atlas-extension": "1.0.0-alpha.5",
"@antora/collector-extension": "1.0.2",
"@antora/collector-extension": "1.0.3",
"@asciidoctor/tabs": "1.0.0-beta.6",
"@springio/antora-extensions": "1.14.7",
"fast-xml-parser": "5.3.8",
"@springio/asciidoctor-extensions": "1.0.0-alpha.17"
"@springio/antora-extensions": "1.14.12",
"fast-xml-parser": "5.7.0",
"@springio/asciidoctor-extensions": "1.0.0-alpha.18"
}
}
@@ -29,7 +29,7 @@ public class ExceptionController {
// tag::narrow[]
@ExceptionHandler({FileSystemException.class, RemoteException.class})
public ResponseEntity<String> handleIoException(IOException ex) {
public ResponseEntity<String> handleIOException(IOException ex) {
return ResponseEntity.internalServerError().body(ex.getMessage());
}
// end::narrow[]
@@ -27,7 +27,7 @@ class ExceptionController {
// tag::narrow[]
@ExceptionHandler(FileSystemException::class, RemoteException::class)
fun handleIoException(ex: IOException): ResponseEntity<String> {
fun handleIOException(ex: IOException): ResponseEntity<String> {
return ResponseEntity.internalServerError().body(ex.message)
}
// end::narrow[]
+7 -7
View File
@@ -8,20 +8,20 @@ javaPlatform {
dependencies {
api(platform("com.fasterxml.jackson:jackson-bom:2.18.5"))
api(platform("io.micrometer:micrometer-bom:1.15.10"))
api(platform("io.netty:netty-bom:4.1.130.Final"))
api(platform("io.micrometer:micrometer-bom:1.15.12"))
api(platform("io.netty:netty-bom:4.1.134.Final"))
api(platform("io.netty:netty5-bom:5.0.0.Alpha5"))
api(platform("io.projectreactor:reactor-bom:2024.0.16"))
api(platform("io.projectreactor:reactor-bom:2024.0.18"))
api(platform("io.rsocket:rsocket-bom:1.1.5"))
api(platform("org.apache.groovy:groovy-bom:4.0.30"))
api(platform("org.apache.groovy:groovy-bom:4.0.31"))
api(platform("org.apache.logging.log4j:log4j-bom:2.21.1"))
api(platform("org.assertj:assertj-bom:3.27.7"))
api(platform("org.eclipse.jetty:jetty-bom:12.0.33"))
api(platform("org.eclipse.jetty.ee10:jetty-ee10-bom:12.0.33"))
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.1"))
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.3"))
api(platform("org.junit:junit-bom:5.14.3"))
api(platform("org.mockito:mockito-bom:5.22.0"))
api(platform("org.junit:junit-bom:5.14.4"))
api(platform("org.mockito:mockito-bom:5.23.0"))
constraints {
api("com.fasterxml:aalto-xml:1.3.4")
@@ -31,7 +31,7 @@ dependencies {
api("com.google.code.findbugs:findbugs:3.0.1")
api("com.google.code.findbugs:jsr305:3.0.2")
api("com.google.code.gson:gson:2.13.2")
api("com.google.protobuf:protobuf-java-util:4.34.0")
api("com.google.protobuf:protobuf-java-util:4.34.1")
api("com.h2database:h2:2.4.240")
api("com.jayway.jsonpath:json-path:2.10.0")
api("com.oracle.database.jdbc:ojdbc11:21.9.0.0")
+1 -1
View File
@@ -1,4 +1,4 @@
version=6.2.17-SNAPSHOT
version=6.2.20-SNAPSHOT
org.gradle.caching=true
org.gradle.jvmargs=-Xmx2048m
-13
View File
@@ -84,19 +84,6 @@ eclipse.classpath.file.whenMerged {
}
}
// Due to an apparent bug in Gradle, even though we exclude the "main" classpath
// entries for sources generated by XJC in spring-oxm.gradle, the Gradle eclipse
// plugin still includes them in the generated .classpath file. So, we have to
// manually remove those lingering "main" entries.
if (project.name == "spring-oxm") {
eclipse.classpath.file.whenMerged { classpath ->
classpath.entries.removeAll {
it.path =~ /build\/generated\/sources\/xjc\/.+/ &&
it.entryAttributes.get("gradle_scope") == "main"
}
}
}
// Include project specific settings
tasks.register('eclipseSettings', Copy) {
from rootProject.files(
@@ -61,10 +61,9 @@ class AopNamespaceHandlerScopeIntegrationTests {
@Test
void testSingletonScoping() throws Exception {
void singletonScoping() throws Exception {
assertThat(AopUtils.isAopProxy(singletonScoped)).as("Should be AOP proxy").isTrue();
boolean condition = singletonScoped instanceof TestBean;
assertThat(condition).as("Should be target class proxy").isTrue();
assertThat(singletonScoped).as("Should be target class proxy").isInstanceOf(TestBean.class);
String rob = "Rob Harrop";
String bram = "Bram Smeets";
assertThat(singletonScoped.getName()).isEqualTo(rob);
@@ -75,19 +74,17 @@ class AopNamespaceHandlerScopeIntegrationTests {
}
@Test
void testRequestScoping() {
void requestScoping() {
MockHttpServletRequest oldRequest = new MockHttpServletRequest();
MockHttpServletRequest newRequest = new MockHttpServletRequest();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(oldRequest));
assertThat(AopUtils.isAopProxy(requestScoped)).as("Should be AOP proxy").isTrue();
boolean condition = requestScoped instanceof TestBean;
assertThat(condition).as("Should be target class proxy").isTrue();
assertThat(requestScoped).as("Should be target class proxy").isInstanceOf(TestBean.class);
assertThat(AopUtils.isAopProxy(testBean)).as("Should be AOP proxy").isTrue();
boolean condition1 = testBean instanceof TestBean;
assertThat(condition1).as("Regular bean should be JDK proxy").isFalse();
assertThat(testBean).as("Regular bean should be JDK proxy").isNotInstanceOf(TestBean.class);
String rob = "Rob Harrop";
String bram = "Bram Smeets";
@@ -103,7 +100,7 @@ class AopNamespaceHandlerScopeIntegrationTests {
}
@Test
void testSessionScoping() {
void sessionScoping() {
MockHttpSession oldSession = new MockHttpSession();
MockHttpSession newSession = new MockHttpSession();
@@ -112,14 +109,12 @@ class AopNamespaceHandlerScopeIntegrationTests {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
assertThat(AopUtils.isAopProxy(sessionScoped)).as("Should be AOP proxy").isTrue();
boolean condition1 = sessionScoped instanceof TestBean;
assertThat(condition1).as("Should not be target class proxy").isFalse();
assertThat(sessionScoped).as("Should not be target class proxy").isNotInstanceOf(TestBean.class);
assertThat(sessionScopedAlias).isSameAs(sessionScoped);
assertThat(AopUtils.isAopProxy(testBean)).as("Should be AOP proxy").isTrue();
boolean condition = testBean instanceof TestBean;
assertThat(condition).as("Regular bean should be JDK proxy").isFalse();
assertThat(testBean).as("Regular bean should be JDK proxy").isNotInstanceOf(TestBean.class);
String rob = "Rob Harrop";
String bram = "Bram Smeets";
@@ -65,7 +65,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
}
@Test
void testDefaultExclusionPrefix() {
void defaultExclusionPrefix() {
DefaultAdvisorAutoProxyCreator aapc = (DefaultAdvisorAutoProxyCreator) getBeanFactory().getBean(ADVISOR_APC_BEAN_NAME);
assertThat(aapc.getAdvisorBeanNamePrefix()).isEqualTo((ADVISOR_APC_BEAN_NAME + DefaultAdvisorAutoProxyCreator.SEPARATOR));
assertThat(aapc.isUsePrefix()).isFalse();
@@ -75,21 +75,21 @@ class AdvisorAutoProxyCreatorIntegrationTests {
* If no pointcuts match (no attrs) there should be proxying.
*/
@Test
void testNoProxy() {
void noProxy() {
BeanFactory bf = getBeanFactory();
Object o = bf.getBean("noSetters");
assertThat(AopUtils.isAopProxy(o)).isFalse();
}
@Test
void testTxIsProxied() {
void txIsProxied() {
BeanFactory bf = getBeanFactory();
ITestBean test = (ITestBean) bf.getBean("test");
assertThat(AopUtils.isAopProxy(test)).isTrue();
}
@Test
void testRegexpApplied() {
void regexpApplied() {
BeanFactory bf = getBeanFactory();
ITestBean test = (ITestBean) bf.getBean("test");
MethodCounter counter = (MethodCounter) bf.getBean("countingAdvice");
@@ -99,7 +99,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
}
@Test
void testTransactionAttributeOnMethod() {
void transactionAttributeOnMethod() {
BeanFactory bf = getBeanFactory();
ITestBean test = (ITestBean) bf.getBean("test");
@@ -121,7 +121,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
* Should not roll back on servlet exception.
*/
@Test
void testRollbackRulesOnMethodCauseRollback() throws Exception {
void rollbackRulesOnMethodCauseRollback() throws Exception {
BeanFactory bf = getBeanFactory();
Rollback rb = (Rollback) bf.getBean("rollback");
@@ -147,7 +147,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
}
@Test
void testRollbackRulesOnMethodPreventRollback() throws Exception {
void rollbackRulesOnMethodPreventRollback() throws Exception {
BeanFactory bf = getBeanFactory();
Rollback rb = (Rollback) bf.getBean("rollback");
@@ -165,12 +165,11 @@ class AdvisorAutoProxyCreatorIntegrationTests {
}
@Test
void testProgrammaticRollback() {
void programmaticRollback() {
BeanFactory bf = getBeanFactory();
Object bean = bf.getBean(TXMANAGER_BEAN_NAME);
boolean condition = bean instanceof CallCountingTransactionManager;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(CallCountingTransactionManager.class);
CallCountingTransactionManager txMan = (CallCountingTransactionManager) bf.getBean(TXMANAGER_BEAN_NAME);
Rollback rb = (Rollback) bf.getBean("rollback");
@@ -50,13 +50,13 @@ class ComponentBeanDefinitionParserTests {
}
@Test
void testBionicBasic() {
void bionicBasic() {
Component cp = getBionicFamily();
assertThat(cp.getName()).isEqualTo("Bionic-1");
}
@Test
void testBionicFirstLevelChildren() {
void bionicFirstLevelChildren() {
Component cp = getBionicFamily();
List<Component> components = cp.getComponents();
assertThat(components).hasSize(2);
@@ -65,7 +65,7 @@ class ComponentBeanDefinitionParserTests {
}
@Test
void testBionicSecondLevelChildren() {
void bionicSecondLevelChildren() {
Component cp = getBionicFamily();
List<Component> components = cp.getComponents().get(0).getComponents();
assertThat(components).hasSize(2);
@@ -83,7 +83,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
@Test
void testPrototype() {
void prototype() {
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("prototype");
assertThat(bean).isNotNull();
@@ -92,7 +92,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testSingletonScopeWithNoProxy() {
void singletonScopeWithNoProxy() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
@@ -115,7 +115,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testSingletonScopeIgnoresProxyInterfaces() {
void singletonScopeIgnoresProxyInterfaces() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
@@ -136,7 +136,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testSingletonScopeIgnoresProxyTargetClass() {
void singletonScopeIgnoresProxyTargetClass() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
@@ -157,7 +157,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testRequestScopeWithNoProxy() {
void requestScopeWithNoProxy() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("request");
@@ -178,15 +178,14 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testRequestScopeWithProxiedInterfaces() {
void requestScopeWithProxiedInterfaces() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
IScopedTestBean bean = (IScopedTestBean) context.getBean("request");
// should be dynamic proxy, implementing both interfaces
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
boolean condition = bean instanceof AnotherScopeTestInterface;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -200,15 +199,14 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testRequestScopeWithProxiedTargetClass() {
void requestScopeWithProxiedTargetClass() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
IScopedTestBean bean = (IScopedTestBean) context.getBean("request");
// should be a class-based proxy
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
boolean condition = bean instanceof RequestScopedTestBean;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(RequestScopedTestBean.class);
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -222,7 +220,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testSessionScopeWithNoProxy() {
void sessionScopeWithNoProxy() {
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("session");
@@ -243,15 +241,14 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testSessionScopeWithProxiedInterfaces() {
void sessionScopeWithProxiedInterfaces() {
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
IScopedTestBean bean = (IScopedTestBean) context.getBean("session");
// should be dynamic proxy, implementing both interfaces
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
boolean condition = bean instanceof AnotherScopeTestInterface;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -271,17 +268,15 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void testSessionScopeWithProxiedTargetClass() {
void sessionScopeWithProxiedTargetClass() {
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
IScopedTestBean bean = (IScopedTestBean) context.getBean("session");
// should be a class-based proxy
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
boolean condition1 = bean instanceof ScopedTestBean;
assertThat(condition1).isTrue();
boolean condition = bean instanceof SessionScopedTestBean;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(ScopedTestBean.class);
assertThat(bean).isInstanceOf(SessionScopedTestBean.class);
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -166,8 +166,7 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
// should be dynamic proxy, implementing both interfaces
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
boolean condition = bean instanceof AnotherScopeTestInterface;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -188,8 +187,7 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
// should be a class-based proxy
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
boolean condition = bean instanceof RequestScopedTestBean;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(RequestScopedTestBean.class);
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -231,8 +229,7 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
// should be dynamic proxy, implementing both interfaces
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
boolean condition = bean instanceof AnotherScopeTestInterface;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -259,10 +256,8 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
// should be a class-based proxy
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
boolean condition1 = bean instanceof ScopedTestBean;
assertThat(condition1).isTrue();
boolean condition = bean instanceof SessionScopedTestBean;
assertThat(condition).isTrue();
assertThat(bean).isInstanceOf(ScopedTestBean.class);
assertThat(bean).isInstanceOf(SessionScopedTestBean.class);
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -0,0 +1,36 @@
/*
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.core.env;
/**
* Constants used both locally and in scan* sub-packages
*/
public class Constants {
public static final String XML_PATH = "org/springframework/core/env/EnvironmentSystemIntegrationTests-context.xml";
public static final String ENVIRONMENT_AWARE_BEAN_NAME = "envAwareBean";
public static final String PROD_BEAN_NAME = "prodBean";
public static final String DEV_BEAN_NAME = "devBean";
public static final String DERIVED_DEV_BEAN_NAME = "derivedDevBean";
public static final String TRANSITIVE_BEAN_NAME = "transitiveBean";
public static final String PROD_ENV_NAME = "prod";
public static final String DEV_ENV_NAME = "dev";
public static final String DERIVED_DEV_ENV_NAME = "derivedDev";
}
@@ -58,15 +58,15 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
import static org.springframework.context.ConfigurableApplicationContext.ENVIRONMENT_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DERIVED_DEV_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DERIVED_DEV_ENV_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.ENVIRONMENT_AWARE_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.TRANSITIVE_BEAN_NAME;
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.XML_PATH;
import static org.springframework.core.env.Constants.DERIVED_DEV_BEAN_NAME;
import static org.springframework.core.env.Constants.DERIVED_DEV_ENV_NAME;
import static org.springframework.core.env.Constants.DEV_BEAN_NAME;
import static org.springframework.core.env.Constants.DEV_ENV_NAME;
import static org.springframework.core.env.Constants.ENVIRONMENT_AWARE_BEAN_NAME;
import static org.springframework.core.env.Constants.PROD_BEAN_NAME;
import static org.springframework.core.env.Constants.PROD_ENV_NAME;
import static org.springframework.core.env.Constants.TRANSITIVE_BEAN_NAME;
import static org.springframework.core.env.Constants.XML_PATH;
/**
* System integration tests for container support of the {@link Environment} API.
@@ -87,7 +87,7 @@ import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Con
* @author Sam Brannen
* @see org.springframework.context.support.EnvironmentIntegrationTests
*/
public class EnvironmentSystemIntegrationTests {
class EnvironmentSystemIntegrationTests {
private final ConfigurableEnvironment prodEnv = new StandardEnvironment();
@@ -648,7 +648,7 @@ public class EnvironmentSystemIntegrationTests {
}
}
@Profile(DERIVED_DEV_ENV_NAME)
@Profile(Constants.DERIVED_DEV_ENV_NAME)
@Configuration
static class DerivedDevConfig extends DevConfig {
@Bean
@@ -666,24 +666,4 @@ public class EnvironmentSystemIntegrationTests {
}
}
/**
* Constants used both locally and in scan* sub-packages
*/
public static class Constants {
public static final String XML_PATH = "org/springframework/core/env/EnvironmentSystemIntegrationTests-context.xml";
public static final String ENVIRONMENT_AWARE_BEAN_NAME = "envAwareBean";
public static final String PROD_BEAN_NAME = "prodBean";
public static final String DEV_BEAN_NAME = "devBean";
public static final String DERIVED_DEV_BEAN_NAME = "derivedDevBean";
public static final String TRANSITIVE_BEAN_NAME = "transitiveBean";
public static final String PROD_ENV_NAME = "prod";
public static final String DEV_ENV_NAME = "dev";
public static final String DERIVED_DEV_ENV_NAME = "derivedDev";
}
}
@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
@Profile(org.springframework.core.env.Constants.DEV_ENV_NAME)
@Configuration
class DevConfig {
@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
@Profile(org.springframework.core.env.Constants.PROD_ENV_NAME)
@Configuration
class ProdConfig {
@@ -19,7 +19,7 @@ package org.springframework.core.env.scan2;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME)
@Profile(org.springframework.core.env.Constants.DEV_ENV_NAME)
@Component(org.springframework.core.env.Constants.DEV_BEAN_NAME)
class DevBean {
}
@@ -19,8 +19,8 @@ package org.springframework.core.env.scan2;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME)
@Profile(org.springframework.core.env.Constants.PROD_ENV_NAME)
@Component(org.springframework.core.env.Constants.PROD_BEAN_NAME)
class ProdBean {
}
@@ -171,7 +171,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
@Override
public String toString() {
return "execution(" + getSignature().toString() + ")";
return "execution(" + getSignature() + ")";
}
@@ -83,7 +83,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
/**
* Add the supplied aspect instance to the chain. The type of the aspect instance
* supplied must be a singleton aspect. True singleton lifecycle is not honoured when
* supplied must be a singleton aspect. True singleton lifecycle is not honored when
* using this method - the caller is responsible for managing the lifecycle of any
* aspects added in this way.
* @param aspectInstance the AspectJ aspect instance
@@ -120,7 +120,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
/**
* The pointcut for Spring AOP to use.
* Actual behaviour of the pointcut will change depending on the state of the advice.
* Actual behavior of the pointcut will change depending on the state of the advice.
*/
@Override
public Pointcut getPointcut() {
@@ -261,7 +261,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
/**
* Pointcut implementation that changes its behaviour when the advice is instantiated.
* Pointcut implementation that changes its behavior when the advice is instantiated.
* Note that this is a <i>dynamic</i> pointcut; otherwise it might be optimized out
* if it does not at first match statically.
*/
@@ -82,7 +82,7 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
/**
* Subclasses may need to override this if they want to perform custom
* behaviour in around advice. However, subclasses should invoke this
* behavior in around advice. However, subclasses should invoke this
* method, which handles introduced interfaces and forwarding to the target.
*/
@Override
@@ -98,7 +98,7 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
/**
* Subclasses may need to override this if they want to perform custom
* behaviour in around advice. However, subclasses should invoke this
* behavior in around advice. However, subclasses should invoke this
* method, which handles introduced interfaces and forwarding to the target.
*/
@Override
@@ -24,7 +24,7 @@ import org.springframework.aop.Pointcut;
* Convenient superclass when we want to force subclasses to
* implement MethodMatcher interface, but subclasses
* will want to be pointcuts. The getClassFilter() method can
* be overridden to customize ClassFilter behaviour as well.
* be overridden to customize ClassFilter behavior as well.
*
* @author Rod Johnson
*/
@@ -23,7 +23,6 @@ import java.util.Map;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import test.annotation.EmptySpringAnnotation;
import test.annotation.transaction.Tx;
@@ -37,6 +36,7 @@ import org.springframework.beans.testfixture.beans.IOther;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.beans.testfixture.beans.subpkg.DeepBean;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
@@ -50,30 +50,22 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
*/
class AspectJExpressionPointcutTests {
private Method getAge;
private Method setAge;
private Method setSomeNumber;
private final Method getAge = ClassUtils.getMethod(TestBean.class, "getAge");
private final Method setAge = ClassUtils.getMethod(TestBean.class, "setAge", int.class);
private final Method setSomeNumber = ClassUtils.getMethod(TestBean.class, "setSomeNumber", Number.class);
private final Map<String, Method> methodsOnHasGeneric = new HashMap<>();
@BeforeEach
void setup() throws NoSuchMethodException {
getAge = TestBean.class.getMethod("getAge");
setAge = TestBean.class.getMethod("setAge", int.class);
setSomeNumber = TestBean.class.getMethod("setSomeNumber", Number.class);
AspectJExpressionPointcutTests() throws NoSuchMethodException {
// Assumes no overloading
for (Method method : HasGeneric.class.getMethods()) {
methodsOnHasGeneric.put(method.getName(), method);
this.methodsOnHasGeneric.put(method.getName(), method);
}
}
@Test
void testMatchExplicit() {
void matchExplicit() {
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression);
@@ -91,7 +83,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testMatchWithTypePattern() {
void matchWithTypePattern() {
String expression = "execution(* *..TestBean.*Age(..))";
Pointcut pointcut = getPointcut(expression);
@@ -110,12 +102,12 @@ class AspectJExpressionPointcutTests {
@Test
void testThis() throws SecurityException, NoSuchMethodException{
void thisCase() throws SecurityException, NoSuchMethodException{
testThisOrTarget("this");
}
@Test
void testTarget() throws SecurityException, NoSuchMethodException {
void target() throws SecurityException, NoSuchMethodException {
testThisOrTarget("target");
}
@@ -139,12 +131,12 @@ class AspectJExpressionPointcutTests {
}
@Test
void testWithinRootPackage() throws SecurityException, NoSuchMethodException {
void withinRootPackage() throws SecurityException, NoSuchMethodException {
testWithinPackage(false);
}
@Test
void testWithinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
void withinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
testWithinPackage(true);
}
@@ -168,7 +160,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testFriendlyErrorOnNoLocationClassMatching() {
void friendlyErrorOnNoLocationClassMatching() {
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
assertThatIllegalStateException()
.isThrownBy(() -> pc.getClassFilter().matches(ITestBean.class))
@@ -176,7 +168,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testFriendlyErrorOnNoLocation2ArgMatching() {
void friendlyErrorOnNoLocation2ArgMatching() {
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
assertThatIllegalStateException()
.isThrownBy(() -> pc.getMethodMatcher().matches(getAge, ITestBean.class))
@@ -184,7 +176,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testFriendlyErrorOnNoLocation3ArgMatching() {
void friendlyErrorOnNoLocation3ArgMatching() {
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
assertThatIllegalStateException()
.isThrownBy(() -> pc.getMethodMatcher().matches(getAge, ITestBean.class, (Object[]) null))
@@ -193,7 +185,7 @@ class AspectJExpressionPointcutTests {
@Test
void testMatchWithArgs() {
void matchWithArgs() {
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
@@ -214,7 +206,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testSimpleAdvice() {
void simpleAdvice() {
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
TestBean testBean = getAdvisedProxy(expression, interceptor);
@@ -227,7 +219,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testDynamicMatchingProxy() {
void dynamicMatchingProxy() {
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
TestBean testBean = getAdvisedProxy(expression, interceptor);
@@ -241,7 +233,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testInvalidExpression() {
void invalidExpression() {
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number) && args(Double)";
assertThat(getPointcut(expression).getClassFilter().matches(Object.class)).isFalse();
}
@@ -271,20 +263,20 @@ class AspectJExpressionPointcutTests {
}
@Test
void testWithUnsupportedPointcutPrimitive() {
void withUnsupportedPointcutPrimitive() {
String expression = "call(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
assertThat(getPointcut(expression).getClassFilter().matches(Object.class)).isFalse();
}
@Test
void testAndSubstitution() {
void andSubstitution() {
AspectJExpressionPointcut pc = getPointcut("execution(* *(..)) and args(String)");
String expr = pc.getPointcutExpression().getPointcutExpression();
assertThat(expr).isEqualTo("execution(* *(..)) && args(String)");
}
@Test
void testMultipleAndSubstitutions() {
void multipleAndSubstitutions() {
AspectJExpressionPointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
String expr = pc.getPointcutExpression().getPointcutExpression();
assertThat(expr).isEqualTo("execution(* *(..)) && args(String) && this(Object)");
@@ -297,7 +289,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testMatchGenericArgument() {
void matchGenericArgument() {
String expression = "execution(* set*(java.util.List<org.springframework.beans.testfixture.beans.TestBean>) )";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -316,7 +308,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testMatchVarargs() throws Exception {
void matchVarargs() throws Exception {
@SuppressWarnings("unused")
class MyTemplate {
@@ -342,19 +334,19 @@ class AspectJExpressionPointcutTests {
}
@Test
void testMatchAnnotationOnClassWithAtWithin() throws Exception {
void matchAnnotationOnClassWithAtWithin() throws Exception {
String expression = "@within(test.annotation.transaction.Tx)";
testMatchAnnotationOnClass(expression);
}
@Test
void testMatchAnnotationOnClassWithoutBinding() throws Exception {
void matchAnnotationOnClassWithoutBinding() throws Exception {
String expression = "within(@test.annotation.transaction.Tx *)";
testMatchAnnotationOnClass(expression);
}
@Test
void testMatchAnnotationOnClassWithSubpackageWildcard() throws Exception {
void matchAnnotationOnClassWithSubpackageWildcard() throws Exception {
String expression = "within(@(test.annotation..*) *)";
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
assertThat(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), TestBean.class)).isFalse();
@@ -366,7 +358,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testMatchAnnotationOnClassWithExactPackageWildcard() throws Exception {
void matchAnnotationOnClassWithExactPackageWildcard() throws Exception {
String expression = "within(@(test.annotation.transaction.*) *)";
testMatchAnnotationOnClass(expression);
}
@@ -384,7 +376,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testAnnotationOnMethodWithFQN() throws Exception {
void annotationOnMethodWithFQN() throws Exception {
String expression = "@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -398,7 +390,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testAnnotationOnCglibProxyMethod() throws Exception {
void annotationOnCglibProxyMethod() throws Exception {
String expression = "@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -410,7 +402,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testNotAnnotationOnCglibProxyMethod() throws Exception {
void notAnnotationOnCglibProxyMethod() throws Exception {
String expression = "!@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -422,7 +414,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testAnnotationOnDynamicProxyMethod() throws Exception {
void annotationOnDynamicProxyMethod() throws Exception {
String expression = "@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -434,7 +426,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testNotAnnotationOnDynamicProxyMethod() throws Exception {
void notAnnotationOnDynamicProxyMethod() throws Exception {
String expression = "!@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -446,7 +438,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testAnnotationOnMethodWithWildcard() throws Exception {
void annotationOnMethodWithWildcard() throws Exception {
String expression = "execution(@(test.annotation..*) * *(..))";
AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut();
anySpringMethodAnnotation.setExpression(expression);
@@ -462,7 +454,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testAnnotationOnMethodArgumentsWithFQN() throws Exception {
void annotationOnMethodArgumentsWithFQN() throws Exception {
String expression = "@args(*, test.annotation.EmptySpringAnnotation))";
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
takesSpringAnnotatedArgument2.setExpression(expression);
@@ -491,7 +483,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void testAnnotationOnMethodArgumentsWithWildcards() throws Exception {
void annotationOnMethodArgumentsWithWildcards() throws Exception {
String expression = "execution(* *(*, @(test..*) *))";
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
takesSpringAnnotatedArgument2.setExpression(expression);
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class BeanNamePointcutMatchingTests {
@Test
void testMatchingPointcuts() {
void matchingPointcuts() {
assertMatch("someName", "bean(someName)");
// Spring bean names are less restrictive compared to AspectJ names (methods, types etc.)
@@ -66,7 +66,7 @@ class BeanNamePointcutMatchingTests {
}
@Test
void testNonMatchingPointcuts() {
void nonMatchingPointcuts() {
assertMisMatch("someName", "bean(someNamex)");
assertMisMatch("someName", "bean(someX*Name)");
@@ -17,7 +17,6 @@
package org.springframework.aop.aspectj;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
import org.aspectj.lang.JoinPoint;
@@ -49,17 +48,17 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
class MethodInvocationProceedingJoinPointTests {
@Test
void testingBindingWithJoinPoint() {
void bindingWithJoinPoint() {
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
}
@Test
void testingBindingWithProceedingJoinPoint() {
void bindingWithProceedingJoinPoint() {
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
}
@Test
void testCanGetMethodSignatureFromJoinPoint() {
void canGetMethodSignatureFromJoinPoint() {
final Object raw = new TestBean();
// Will be set by advice during a method call
final int newAge = 23;
@@ -106,9 +105,9 @@ class MethodInvocationProceedingJoinPointTests {
assertThat(AbstractAspectJAdvice.currentJoinPoint().getSignature()).as("Return same MethodSignature repeatedly").isSameAs(msig);
assertThat(AbstractAspectJAdvice.currentJoinPoint()).as("Return same JoinPoint repeatedly").isSameAs(AbstractAspectJAdvice.currentJoinPoint());
assertThat(msig.getDeclaringType()).isEqualTo(method.getDeclaringClass());
assertThat(Arrays.equals(method.getParameterTypes(), msig.getParameterTypes())).isTrue();
assertThat(method.getParameterTypes()).isEqualTo(msig.getParameterTypes());
assertThat(msig.getReturnType()).isEqualTo(method.getReturnType());
assertThat(Arrays.equals(method.getExceptionTypes(), msig.getExceptionTypes())).isTrue();
assertThat(method.getExceptionTypes()).isEqualTo(msig.getExceptionTypes());
msig.toLongString();
msig.toShortString();
});
@@ -118,7 +117,7 @@ class MethodInvocationProceedingJoinPointTests {
}
@Test
void testCanGetSourceLocationFromJoinPoint() {
void canGetSourceLocationFromJoinPoint() {
final Object raw = new TestBean();
ProxyFactory pf = new ProxyFactory(raw);
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
@@ -135,7 +134,7 @@ class MethodInvocationProceedingJoinPointTests {
}
@Test
void testCanGetStaticPartFromJoinPoint() {
void canGetStaticPartFromJoinPoint() {
final Object raw = new TestBean();
ProxyFactory pf = new ProxyFactory(raw);
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
@@ -43,14 +43,14 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
class TrickyAspectJPointcutExpressionTests {
@Test
void testManualProxyJavaWithUnconditionalPointcut() {
void manualProxyJavaWithUnconditionalPointcut() {
TestService target = new TestServiceImpl();
LogUserAdvice logAdvice = new LogUserAdvice();
testAdvice(new DefaultPointcutAdvisor(logAdvice), logAdvice, target, "TestServiceImpl");
}
@Test
void testManualProxyJavaWithStaticPointcut() {
void manualProxyJavaWithStaticPointcut() {
TestService target = new TestServiceImpl();
LogUserAdvice logAdvice = new LogUserAdvice();
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@@ -59,7 +59,7 @@ class TrickyAspectJPointcutExpressionTests {
}
@Test
void testManualProxyJavaWithDynamicPointcut() {
void manualProxyJavaWithDynamicPointcut() {
TestService target = new TestServiceImpl();
LogUserAdvice logAdvice = new LogUserAdvice();
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@@ -68,7 +68,7 @@ class TrickyAspectJPointcutExpressionTests {
}
@Test
void testManualProxyJavaWithDynamicPointcutAndProxyTargetClass() {
void manualProxyJavaWithDynamicPointcutAndProxyTargetClass() {
TestService target = new TestServiceImpl();
LogUserAdvice logAdvice = new LogUserAdvice();
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@@ -77,7 +77,7 @@ class TrickyAspectJPointcutExpressionTests {
}
@Test
void testManualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception {
void manualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception {
LogUserAdvice logAdvice = new LogUserAdvice();
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@@ -97,7 +97,7 @@ class TypePatternClassFilterTests {
}
@Test
void testEquals() {
void equals() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
@@ -107,7 +107,7 @@ class TypePatternClassFilterTests {
}
@Test
void testHashCode() {
void hashCodeBehavior() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
@@ -117,7 +117,7 @@ class TypePatternClassFilterTests {
}
@Test
void testToString() {
void toStringOutput() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
@@ -430,8 +430,8 @@ abstract class AbstractAspectJAdvisorFactoryTests {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(itb::getAge);
}
// TODO document this behaviour.
// Is it different AspectJ behaviour, at least for checked exceptions?
// TODO document this behavior.
// Is it different AspectJ behavior, at least for checked exceptions?
@Test
void aspectMethodThrowsExceptionIllegalOnSignature() {
TestBean target = new TestBean();
@@ -39,7 +39,7 @@ class AspectJPointcutAdvisorTests {
@Test
void testSingleton() throws SecurityException, NoSuchMethodException {
void singleton() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(CommonExpressions.MATCH_ALL_METHODS);
@@ -53,7 +53,7 @@ class AspectJPointcutAdvisorTests {
}
@Test
void testPerTarget() throws SecurityException, NoSuchMethodException {
void perTarget() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(CommonExpressions.MATCH_ALL_METHODS);
@@ -63,8 +63,7 @@ class AspectJPointcutAdvisorTests {
1, "someBean");
assertThat(ajpa.getAspectMetadata().getPerClausePointcut()).isNotSameAs(Pointcut.TRUE);
boolean condition = ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut;
assertThat(condition).isTrue();
assertThat(ajpa.getAspectMetadata().getPerClausePointcut()).isInstanceOf(AspectJExpressionPointcut.class);
assertThat(ajpa.isPerInstance()).isTrue();
assertThat(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class)).isTrue();
@@ -76,13 +75,13 @@ class AspectJPointcutAdvisorTests {
}
@Test
void testPerCflowTarget() {
void perCflowTarget() {
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class));
}
@Test
void testPerCflowBelowTarget() {
void perCflowBelowTarget() {
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class));
}
@@ -39,13 +39,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class AspectProxyFactoryTests {
@Test
void testWithNonAspect() {
void withNonAspect() {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
assertThatIllegalArgumentException().isThrownBy(() -> proxyFactory.addAspect(TestBean.class));
}
@Test
void testWithSimpleAspect() {
void withSimpleAspect() {
TestBean bean = new TestBean();
bean.setAge(2);
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(bean);
@@ -55,7 +55,7 @@ class AspectProxyFactoryTests {
}
@Test
void testWithPerThisAspect() {
void withPerThisAspect() {
TestBean bean1 = new TestBean();
TestBean bean2 = new TestBean();
@@ -75,14 +75,14 @@ class AspectProxyFactoryTests {
}
@Test
void testWithInstanceWithNonAspect() {
void withInstanceWithNonAspect() {
AspectJProxyFactory pf = new AspectJProxyFactory();
assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new TestBean()));
}
@Test
@SuppressWarnings("unchecked")
void testSerializable() throws Exception {
void serializable() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
ITestBean proxy = proxyFactory.getProxy();
@@ -92,7 +92,7 @@ class AspectProxyFactoryTests {
}
@Test
void testWithInstance() throws Exception {
void withInstance() throws Exception {
MultiplyReturnValue aspect = new MultiplyReturnValue();
int multiple = 3;
aspect.setMultiple(multiple);
@@ -111,14 +111,14 @@ class AspectProxyFactoryTests {
}
@Test
void testWithNonSingletonAspectInstance() {
void withNonSingletonAspectInstance() {
AspectJProxyFactory pf = new AspectJProxyFactory();
assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new PerThisAspect()));
}
@Test // SPR-13328
@SuppressWarnings("unchecked")
public void testProxiedVarargsWithEnumArray() {
void proxiedVarargsWithEnumArray() {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
ITestBean proxy = proxyFactory.getProxy();
@@ -127,7 +127,7 @@ class AspectProxyFactoryTests {
@Test // SPR-13328
@SuppressWarnings("unchecked")
public void testUnproxiedVarargsWithEnumArray() {
void unproxiedVarargsWithEnumArray() {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnSetter.class);
ITestBean proxy = proxyFactory.getProxy();
@@ -47,7 +47,7 @@ class AspectJNamespaceHandlerTests {
@BeforeEach
public void setUp() {
void setUp() {
SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
XmlReaderContext readerContext =
@@ -56,7 +56,7 @@ class AspectJNamespaceHandlerTests {
}
@Test
void testRegisterAutoProxyCreator() {
void registerAutoProxyCreator() {
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
assertThat(registry.getBeanDefinitionCount()).as("Incorrect number of definitions registered").isEqualTo(1);
@@ -65,7 +65,7 @@ class AspectJNamespaceHandlerTests {
}
@Test
void testRegisterAspectJAutoProxyCreator() {
void registerAspectJAutoProxyCreator() {
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
assertThat(registry.getBeanDefinitionCount()).as("Incorrect number of definitions registered").isEqualTo(1);
@@ -77,7 +77,7 @@ class AspectJNamespaceHandlerTests {
}
@Test
void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() {
void registerAspectJAutoProxyCreatorWithExistingAutoProxyCreator() {
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
assertThat(registry.getBeanDefinitionCount()).isEqualTo(1);
@@ -89,7 +89,7 @@ class AspectJNamespaceHandlerTests {
}
@Test
void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() {
void registerAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() {
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
assertThat(registry.getBeanDefinitionCount()).isEqualTo(1);
@@ -33,6 +33,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice;
import org.springframework.aop.aspectj.AspectJPointcutAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,24 +49,21 @@ class AspectJPrecedenceComparatorTests {
private static final int LATE_ADVICE_DECLARATION_ORDER = 10;
private AspectJPrecedenceComparator comparator;
private final AspectJPrecedenceComparator comparator = new AspectJPrecedenceComparator();
private Method anyOldMethod;
private final Method anyOldMethod = ClassUtils.getMethod(MessageService.class, "getMessage");
private AspectJExpressionPointcut anyOldPointcut;
private final AspectJExpressionPointcut anyOldPointcut = new AspectJExpressionPointcut();
@BeforeEach
public void setUp() {
this.comparator = new AspectJPrecedenceComparator();
this.anyOldMethod = getClass().getMethods()[0];
this.anyOldPointcut = new AspectJExpressionPointcut();
void setUp() {
this.anyOldPointcut.setExpression("execution(* *(..))");
}
@Test
void testSameAspectNoAfterAdvice() {
void sameAspectNoAfterAdvice() {
Advisor advisor1 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
@@ -76,7 +74,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void testSameAspectAfterAdvice() {
void sameAspectAfterAdvice() {
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor2 sorted before advisor1").isEqualTo(1);
@@ -87,14 +85,14 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void testSameAspectOneOfEach() {
void sameAspectOneOfEach() {
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 and advisor2 not comparable").isEqualTo(1);
}
@Test
void testSameAdvisorPrecedenceDifferentAspectNoAfterAdvice() {
void sameAdvisorPrecedenceDifferentAspectNoAfterAdvice() {
Advisor advisor1 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("nothing to say about order here").isEqualTo(0);
@@ -105,7 +103,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void testSameAdvisorPrecedenceDifferentAspectAfterAdvice() {
void sameAdvisorPrecedenceDifferentAspectAfterAdvice() {
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("nothing to say about order here").isEqualTo(0);
@@ -116,7 +114,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void testHigherAdvisorPrecedenceNoAfterAdvice() {
void higherAdvisorPrecedenceNoAfterAdvice() {
Advisor advisor1 = createSpringAOPBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER);
Advisor advisor2 = createAspectJBeforeAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someOtherAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
@@ -127,7 +125,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void testHigherAdvisorPrecedenceAfterAdvice() {
void higherAdvisorPrecedenceAfterAdvice() {
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJAroundAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
@@ -138,7 +136,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void testLowerAdvisorPrecedenceNoAfterAdvice() {
void lowerAdvisorPrecedenceNoAfterAdvice() {
Advisor advisor1 = createAspectJBeforeAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someOtherAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted after advisor2").isEqualTo(1);
@@ -149,7 +147,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void testLowerAdvisorPrecedenceAfterAdvice() {
void lowerAdvisorPrecedenceAfterAdvice() {
Advisor advisor1 = createAspectJAfterAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted after advisor2").isEqualTo(1);
@@ -209,4 +207,11 @@ class AspectJPrecedenceComparatorTests {
return advisor;
}
static class MessageService {
public String getMessage() {
return "test";
}
}
}
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MethodInvocationTests {
@Test
void testValidInvocation() throws Throwable {
void validInvocation() throws Throwable {
Method method = Object.class.getMethod("hashCode");
Object proxy = new Object();
Object returnValue = new Object();
@@ -49,7 +49,7 @@ class MethodInvocationTests {
* toString on target can cause failure.
*/
@Test
void testToStringDoesntHitTarget() throws Throwable {
void toStringDoesntHitTarget() throws Throwable {
Object target = new TestBean() {
@Override
public String toString() {
@@ -36,7 +36,7 @@ class NullPrimitiveTests {
}
@Test
void testNullPrimitiveWithJdkProxy() {
void nullPrimitiveWithJdkProxy() {
class SimpleFoo implements Foo {
@Override
@@ -62,7 +62,7 @@ class NullPrimitiveTests {
}
@Test
void testNullPrimitiveWithCglibProxy() {
void nullPrimitiveWithCglibProxy() {
Bar target = new Bar();
ProxyFactory factory = new ProxyFactory(target);
@@ -38,7 +38,7 @@ class PrototypeTargetTests {
@Test
void testPrototypeProxyWithPrototypeTarget() {
void prototypeProxyWithPrototypeTarget() {
TestBeanImpl.constructionCount = 0;
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
@@ -52,7 +52,7 @@ class PrototypeTargetTests {
}
@Test
void testSingletonProxyWithPrototypeTarget() {
void singletonProxyWithPrototypeTarget() {
TestBeanImpl.constructionCount = 0;
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
@@ -40,14 +40,14 @@ import static org.mockito.Mockito.mock;
class ThrowsAdviceInterceptorTests {
@Test
void testNoHandlerMethods() {
void noHandlerMethods() {
// should require one handler method at least
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
new ThrowsAdviceInterceptor(new Object()));
}
@Test
void testNotInvoked() throws Throwable {
void notInvoked() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
Object ret = new Object();
@@ -58,7 +58,7 @@ class ThrowsAdviceInterceptorTests {
}
@Test
void testNoHandlerMethodForThrowable() throws Throwable {
void noHandlerMethodForThrowable() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
assertThat(ti.getHandlerMethodCount()).isEqualTo(2);
@@ -70,7 +70,7 @@ class ThrowsAdviceInterceptorTests {
}
@Test
void testCorrectHandlerUsed() throws Throwable {
void correctHandlerUsed() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
FileNotFoundException ex = new FileNotFoundException();
@@ -84,7 +84,7 @@ class ThrowsAdviceInterceptorTests {
}
@Test
void testCorrectHandlerUsedForSubclass() throws Throwable {
void correctHandlerUsedForSubclass() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
// Extends RemoteException
@@ -97,7 +97,7 @@ class ThrowsAdviceInterceptorTests {
}
@Test
void testHandlerMethodThrowsException() throws Throwable {
void handlerMethodThrowsException() throws Throwable {
final Throwable t = new Throwable();
MyThrowsHandler th = new MyThrowsHandler() {
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
class DebugInterceptorTests {
@Test
void testSunnyDayPathLogsCorrectly() throws Throwable {
void sunnyDayPathLogsCorrectly() throws Throwable {
MethodInvocation methodInvocation = mock();
Log log = mock();
@@ -52,7 +52,7 @@ class DebugInterceptorTests {
}
@Test
void testExceptionPathStillLogsCorrectly() throws Throwable {
void exceptionPathStillLogsCorrectly() throws Throwable {
MethodInvocation methodInvocation = mock();
IllegalArgumentException exception = new IllegalArgumentException();
@@ -46,7 +46,7 @@ class ExposeBeanNameAdvisorsTests {
}
@Test
void testNoIntroduction() {
void noIntroduction() {
String beanName = "foo";
TestBean target = new RequiresBeanNameBoundTestBean(beanName);
ProxyFactory pf = new ProxyFactory(target);
@@ -54,14 +54,13 @@ class ExposeBeanNameAdvisorsTests {
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
ITestBean proxy = (ITestBean) pf.getProxy();
boolean condition = proxy instanceof NamedBean;
assertThat(condition).as("No introduction").isFalse();
assertThat(proxy).as("No introduction").isNotInstanceOf(NamedBean.class);
// Requires binding
proxy.getAge();
}
@Test
void testWithIntroduction() {
void withIntroduction() {
String beanName = "foo";
TestBean target = new RequiresBeanNameBoundTestBean(beanName);
ProxyFactory pf = new ProxyFactory(target);
@@ -69,8 +68,7 @@ class ExposeBeanNameAdvisorsTests {
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
ITestBean proxy = (ITestBean) pf.getProxy();
boolean condition = proxy instanceof NamedBean;
assertThat(condition).as("Introduction was made").isTrue();
assertThat(proxy).as("Introduction was made").isInstanceOf(NamedBean.class);
// Requires binding
proxy.getAge();
@@ -34,7 +34,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
class ExposeInvocationInterceptorTests {
@Test
void testXmlConfig() {
void xmlConfig() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml"));
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify;
class PerformanceMonitorInterceptorTests {
@Test
void testSuffixAndPrefixAssignment() {
void suffixAndPrefixAssignment() {
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor();
assertThat(interceptor.getPrefix()).isNotNull();
@@ -49,7 +49,7 @@ class PerformanceMonitorInterceptorTests {
}
@Test
void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
void sunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
MethodInvocation mi = mock();
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
@@ -62,7 +62,7 @@ class PerformanceMonitorInterceptorTests {
}
@Test
void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
void exceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
MethodInvocation mi = mock();
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.verify;
class SimpleTraceInterceptorTests {
@Test
void testSunnyDayPathLogsCorrectly() throws Throwable {
void sunnyDayPathLogsCorrectly() throws Throwable {
MethodInvocation mi = mock();
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
given(mi.getThis()).willReturn(this);
@@ -51,7 +51,7 @@ class SimpleTraceInterceptorTests {
}
@Test
void testExceptionPathStillLogsCorrectly() throws Throwable {
void exceptionPathStillLogsCorrectly() throws Throwable {
MethodInvocation mi = mock();
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
given(mi.getThis()).willReturn(this);
@@ -35,25 +35,25 @@ class DefaultScopedObjectTests {
@Test
void testCtorWithNullBeanFactory() {
void ctorWithNullBeanFactory() {
assertThatIllegalArgumentException().isThrownBy(() ->
new DefaultScopedObject(null, GOOD_BEAN_NAME));
}
@Test
void testCtorWithNullTargetBeanName() {
void ctorWithNullTargetBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
testBadTargetBeanName(null));
}
@Test
void testCtorWithEmptyTargetBeanName() {
void ctorWithEmptyTargetBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
testBadTargetBeanName(""));
}
@Test
void testCtorWithJustWhitespacedTargetBeanName() {
void ctorWithJustWhitespacedTargetBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
testBadTargetBeanName(" "));
}
@@ -34,7 +34,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
class ScopedProxyAutowireTests {
@Test
void testScopedProxyInheritsAutowireCandidateFalse() {
void scopedProxyInheritsAutowireCandidateFalse() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml"));
@@ -48,7 +48,7 @@ class ScopedProxyAutowireTests {
}
@Test
void testScopedProxyReplacesAutowireCandidateTrue() {
void scopedProxyReplacesAutowireCandidateTrue() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireTrue.xml"));
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class AopUtilsTests {
@Test
void testPointcutCanNeverApply() {
void pointcutCanNeverApply() {
class TestPointcut extends StaticMethodMatcherPointcut {
@Override
public boolean matches(Method method, @Nullable Class<?> clazzy) {
@@ -58,13 +58,13 @@ class AopUtilsTests {
}
@Test
void testPointcutAlwaysApplies() {
void pointcutAlwaysApplies() {
assertThat(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), Object.class)).isTrue();
assertThat(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), TestBean.class)).isTrue();
}
@Test
void testPointcutAppliesToOneMethodOnObject() {
void pointcutAppliesToOneMethodOnObject() {
class TestPointcut extends StaticMethodMatcherPointcut {
@Override
public boolean matches(Method method, @Nullable Class<?> clazz) {
@@ -84,7 +84,7 @@ class AopUtilsTests {
* that's subverted the singleton construction limitation.
*/
@Test
void testCanonicalFrameworkClassesStillCanonicalOnDeserialization() throws Exception {
void canonicalFrameworkClassesStillCanonicalOnDeserialization() throws Exception {
assertThat(SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE)).isSameAs(MethodMatcher.TRUE);
assertThat(SerializationTestUtils.serializeAndDeserialize(ClassFilter.TRUE)).isSameAs(ClassFilter.TRUE);
assertThat(SerializationTestUtils.serializeAndDeserialize(Pointcut.TRUE)).isSameAs(Pointcut.TRUE);
@@ -95,7 +95,7 @@ class AopUtilsTests {
}
@Test
void testInvokeJoinpointUsingReflection() throws Throwable {
void invokeJoinpointUsingReflection() throws Throwable {
String name = "foo";
TestBean testBean = new TestBean(name);
Method method = ReflectionUtils.findMethod(TestBean.class, "getName");
@@ -58,14 +58,14 @@ class ComposablePointcutTests {
@Test
void testMatchAll() throws NoSuchMethodException {
void matchAll() throws NoSuchMethodException {
Pointcut pc = new ComposablePointcut();
assertThat(pc.getClassFilter().matches(Object.class)).isTrue();
assertThat(pc.getMethodMatcher().matches(Object.class.getMethod("hashCode"), Exception.class)).isTrue();
}
@Test
void testFilterByClass() {
void filterByClass() {
ComposablePointcut pc = new ComposablePointcut();
assertThat(pc.getClassFilter().matches(Object.class)).isTrue();
@@ -85,7 +85,7 @@ class ComposablePointcutTests {
}
@Test
void testUnionMethodMatcher() {
void unionMethodMatcher() {
// Matches the getAge() method in any class
ComposablePointcut pc = new ComposablePointcut(ClassFilter.TRUE, GET_AGE_METHOD_MATCHER);
assertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class)).isFalse();
@@ -108,7 +108,7 @@ class ComposablePointcutTests {
}
@Test
void testIntersectionMethodMatcher() {
void intersectionMethodMatcher() {
ComposablePointcut pc = new ComposablePointcut();
assertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class)).isTrue();
assertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
@@ -125,7 +125,7 @@ class ComposablePointcutTests {
}
@Test
void testEqualsAndHashCode() {
void equalsAndHashCode() {
ComposablePointcut pc1 = new ComposablePointcut();
ComposablePointcut pc2 = new ComposablePointcut();
@@ -152,7 +152,7 @@ class ControlFlowPointcutTests {
}
@Test
void testToString() {
void toStringOutput() {
String pointcutType = ControlFlowPointcut.class.getName();
String componentType = MyComponent.class.getName();
@@ -47,14 +47,14 @@ import static org.mockito.Mockito.mock;
class DelegatingIntroductionInterceptorTests {
@Test
void testNullTarget() {
void nullTarget() {
// Shouldn't accept null target
assertThatIllegalArgumentException().isThrownBy(() ->
new DelegatingIntroductionInterceptor(null));
}
@Test
void testIntroductionInterceptorWithDelegation() {
void introductionInterceptorWithDelegation() {
TestBean raw = new TestBean();
assertThat(raw).isNotInstanceOf(TimeStamped.class);
ProxyFactory factory = new ProxyFactory(raw);
@@ -70,7 +70,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void testIntroductionInterceptorWithInterfaceHierarchy() {
void introductionInterceptorWithInterfaceHierarchy() {
TestBean raw = new TestBean();
assertThat(raw).isNotInstanceOf(SubTimeStamped.class);
ProxyFactory factory = new ProxyFactory(raw);
@@ -86,7 +86,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void testIntroductionInterceptorWithSuperInterface() {
void introductionInterceptorWithSuperInterface() {
TestBean raw = new TestBean();
assertThat(raw).isNotInstanceOf(TimeStamped.class);
ProxyFactory factory = new ProxyFactory(raw);
@@ -103,7 +103,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void testAutomaticInterfaceRecognitionInDelegate() throws Exception {
void automaticInterfaceRecognitionInDelegate() throws Exception {
final long t = 1001L;
class Tester implements TimeStamped, ITester {
@Override
@@ -133,7 +133,7 @@ class DelegatingIntroductionInterceptorTests {
@Test
void testAutomaticInterfaceRecognitionInSubclass() throws Exception {
void automaticInterfaceRecognitionInSubclass() throws Exception {
final long t = 1001L;
@SuppressWarnings("serial")
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped, ITester {
@@ -178,7 +178,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void testIntroductionInterceptorDoesNotReplaceToString() {
void introductionInterceptorDoesNotReplaceToString() {
TestBean raw = new TestBean();
assertThat(raw).isNotInstanceOf(TimeStamped.class);
ProxyFactory factory = new ProxyFactory(raw);
@@ -199,7 +199,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void testDelegateReturnsThisIsMassagedToReturnProxy() {
void delegateReturnsThisIsMassagedToReturnProxy() {
NestedTestBean target = new NestedTestBean();
String company = "Interface21";
target.setCompany(company);
@@ -220,7 +220,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception {
void serializableDelegatingIntroductionInterceptorSerializable() throws Exception {
SerializablePerson serializableTarget = new SerializablePerson();
String name = "Tony";
serializableTarget.setName("Tony");
@@ -245,7 +245,7 @@ class DelegatingIntroductionInterceptorTests {
// Test when target implements the interface: should get interceptor by preference.
@Test
void testIntroductionMasksTargetImplementation() {
void introductionMasksTargetImplementation() {
final long t = 1001L;
@SuppressWarnings("serial")
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped {
@@ -56,19 +56,19 @@ class MethodMatchersTests {
@Test
void testDefaultMatchesAll() {
void defaultMatchesAll() {
MethodMatcher defaultMm = MethodMatcher.TRUE;
assertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.class)).isTrue();
assertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)).isTrue();
}
@Test
void testMethodMatcherTrueSerializable() throws Exception {
void methodMatcherTrueSerializable() throws Exception {
assertThat(MethodMatcher.TRUE).isSameAs(SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE));
}
@Test
void testSingle() {
void single() {
MethodMatcher defaultMm = MethodMatcher.TRUE;
assertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.class)).isTrue();
assertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)).isTrue();
@@ -80,7 +80,7 @@ class MethodMatchersTests {
@Test
void testDynamicAndStaticMethodMatcherIntersection() {
void dynamicAndStaticMethodMatcherIntersection() {
MethodMatcher mm1 = MethodMatcher.TRUE;
MethodMatcher mm2 = new TestDynamicMethodMatcherWhichMatches();
MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
@@ -95,7 +95,7 @@ class MethodMatchersTests {
}
@Test
void testStaticMethodMatcherUnion() {
void staticMethodMatcherUnion() {
MethodMatcher getterMatcher = new StartsWithMatcher("get");
MethodMatcher setterMatcher = new StartsWithMatcher("set");
MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
@@ -107,7 +107,7 @@ class MethodMatchersTests {
}
@Test
void testUnionEquals() {
void unionEquals() {
MethodMatcher first = MethodMatchers.union(MethodMatcher.TRUE, MethodMatcher.TRUE);
MethodMatcher second = new ComposablePointcut(MethodMatcher.TRUE).union(new ComposablePointcut(MethodMatcher.TRUE)).getMethodMatcher();
assertThat(first).isEqualTo(second);
@@ -120,7 +120,7 @@ class PointcutsTests {
@Test
void testTrue() {
void trueCase() {
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_ABSQUATULATE, TestBean.class)).isTrue();
@@ -130,7 +130,7 @@ class PointcutsTests {
}
@Test
void testMatches() {
void matches() {
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_ABSQUATULATE, TestBean.class)).isFalse();
@@ -143,7 +143,7 @@ class PointcutsTests {
* Should match all setters and getters on any class
*/
@Test
void testUnionOfSettersAndGetters() {
void unionOfSettersAndGetters() {
Pointcut union = Pointcuts.union(allClassGetterPointcut, allClassSetterPointcut);
assertThat(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
assertThat(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
@@ -151,7 +151,7 @@ class PointcutsTests {
}
@Test
void testUnionOfSpecificGetters() {
void unionOfSpecificGetters() {
Pointcut union = Pointcuts.union(allClassGetAgePointcut, allClassGetNamePointcut);
assertThat(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
assertThat(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
@@ -175,7 +175,7 @@ class PointcutsTests {
* Second one matches all getters in the MyTestBean class. TestBean getters shouldn't pass.
*/
@Test
void testUnionOfAllSettersAndSubclassSetters() {
void unionOfAllSettersAndSubclassSetters() {
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, MyTestBean.class, 6)).isTrue();
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
@@ -193,7 +193,7 @@ class PointcutsTests {
* it's the union of allClassGetAge and subclass getters
*/
@Test
void testIntersectionOfSpecificGettersAndSubclassGetters() {
void intersectionOfSpecificGettersAndSubclassGetters() {
assertThat(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
assertThat(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, MyTestBean.class)).isTrue();
assertThat(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, TestBean.class)).isFalse();
@@ -239,7 +239,7 @@ class PointcutsTests {
* The intersection of these two pointcuts leaves nothing.
*/
@Test
void testSimpleIntersection() {
void simpleIntersection() {
Pointcut intersection = Pointcuts.intersection(allClassGetterPointcut, allClassSetterPointcut);
assertThat(Pointcuts.matches(intersection, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
assertThat(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
@@ -43,7 +43,7 @@ class RegexpMethodPointcutAdvisorIntegrationTests {
@Test
void testSinglePattern() throws Throwable {
void singlePattern() throws Throwable {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
ITestBean advised = (ITestBean) bf.getBean("settersAdvised");
@@ -62,7 +62,7 @@ class RegexpMethodPointcutAdvisorIntegrationTests {
}
@Test
void testMultiplePatterns() throws Throwable {
void multiplePatterns() throws Throwable {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
// This is a CGLIB proxy, so we can proxy it to the target class
@@ -86,7 +86,7 @@ class RegexpMethodPointcutAdvisorIntegrationTests {
}
@Test
void testSerialization() throws Throwable {
void serialization() throws Throwable {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
// This is a CGLIB proxy, so we can proxy it to the target class
@@ -44,19 +44,19 @@ class RootClassFilterTests {
}
@Test
void testEquals() {
void equals() {
assertThat(filter1).isEqualTo(filter2);
assertThat(filter1).isNotEqualTo(filter3);
}
@Test
void testHashCode() {
void hashCodeBehavior() {
assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode());
assertThat(filter1.hashCode()).isNotEqualTo(filter3.hashCode());
}
@Test
void testToString() {
void toStringOutput() {
assertThat(filter1.toString()).isEqualTo("org.springframework.aop.support.RootClassFilter: java.lang.Exception");
assertThat(filter1.toString()).isEqualTo(filter2.toString());
}
@@ -36,7 +36,7 @@ class CommonsPool2TargetSourceProxyTests {
qualifiedResource(CommonsPool2TargetSourceProxyTests.class, "context.xml");
@Test
void testProxy() {
void proxy() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(CONTEXT);
@@ -48,7 +48,7 @@ class HotSwappableTargetSourceTests {
@BeforeEach
public void setup() {
void setup() {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml"));
@@ -58,7 +58,7 @@ class HotSwappableTargetSourceTests {
* We must simulate container shutdown, which should clear threads.
*/
@AfterEach
public void close() {
void close() {
// Will call pool.close()
this.beanFactory.destroySingletons();
}
@@ -68,7 +68,7 @@ class HotSwappableTargetSourceTests {
* Check it works like a normal invoker
*/
@Test
void testBasicFunctionality() {
void basicFunctionality() {
SideEffectBean proxied = (SideEffectBean) beanFactory.getBean("swappable");
assertThat(proxied.getCount()).isEqualTo(INITIAL_COUNT);
proxied.doWork();
@@ -80,7 +80,7 @@ class HotSwappableTargetSourceTests {
}
@Test
void testValidSwaps() {
void validSwaps() {
SideEffectBean target1 = (SideEffectBean) beanFactory.getBean("target1");
SideEffectBean target2 = (SideEffectBean) beanFactory.getBean("target2");
@@ -107,17 +107,17 @@ class HotSwappableTargetSourceTests {
}
@Test
void testRejectsSwapToNull() {
void rejectsSwapToNull() {
HotSwappableTargetSource swapper = (HotSwappableTargetSource) beanFactory.getBean("swapper");
assertThatIllegalArgumentException().as("Shouldn't be able to swap to invalid value").isThrownBy(() ->
swapper.swap(null))
.withMessageContaining("null");
// It shouldn't be corrupted, it should still work
testBasicFunctionality();
basicFunctionality();
}
@Test
void testSerialization() throws Exception {
void serialization() throws Exception {
SerializablePerson sp1 = new SerializablePerson();
sp1.setName("Tony");
SerializablePerson sp2 = new SerializablePerson();
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class LazyCreationTargetSourceTests {
@Test
void testCreateLazy() {
void createLazy() {
TargetSource targetSource = new AbstractLazyCreationTargetSource() {
@Override
protected Object createObject() {
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class PrototypeBasedTargetSourceTests {
@Test
void testSerializability() throws Exception {
void serializability() throws Exception {
MutablePropertyValues tsPvs = new MutablePropertyValues();
tsPvs.add("targetBeanName", "person");
RootBeanDefinition tsBd = new RootBeanDefinition(TestTargetSource.class);
@@ -39,7 +39,7 @@ class PrototypeTargetSourceTests {
@BeforeEach
public void setup() {
void setup() {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
qualifiedResource(PrototypeTargetSourceTests.class, "context.xml"));
@@ -52,7 +52,7 @@ class PrototypeTargetSourceTests {
* With the singleton, there will be change.
*/
@Test
void testPrototypeAndSingletonBehaveDifferently() {
void prototypeAndSingletonBehaveDifferently() {
SideEffectBean singleton = (SideEffectBean) beanFactory.getBean("singleton");
assertThat(singleton.getCount()).isEqualTo(INITIAL_COUNT);
singleton.doWork();
@@ -40,7 +40,7 @@ class ThreadLocalTargetSourceTests {
@BeforeEach
public void setup() {
void setup() {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
qualifiedResource(ThreadLocalTargetSourceTests.class, "context.xml"));
@@ -60,7 +60,7 @@ class ThreadLocalTargetSourceTests {
* with one another.
*/
@Test
void testUseDifferentManagedInstancesInSameThread() {
void useDifferentManagedInstancesInSameThread() {
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
apartment.doWork();
@@ -72,7 +72,7 @@ class ThreadLocalTargetSourceTests {
}
@Test
void testReuseInSameThread() {
void reuseInSameThread() {
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
apartment.doWork();
@@ -86,7 +86,7 @@ class ThreadLocalTargetSourceTests {
* Relies on introduction.
*/
@Test
void testCanGetStatsViaMixin() {
void canGetStatsViaMixin() {
ThreadLocalTargetSourceStats stats = (ThreadLocalTargetSourceStats) beanFactory.getBean("apartment");
// +1 because creating target for stats call counts
assertThat(stats.getInvocationCount()).isEqualTo(1);
@@ -104,7 +104,7 @@ class ThreadLocalTargetSourceTests {
}
@Test
void testNewThreadHasOwnInstance() throws InterruptedException {
void newThreadHasOwnInstance() throws InterruptedException {
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
apartment.doWork();
@@ -144,7 +144,7 @@ class ThreadLocalTargetSourceTests {
* Test for SPR-1442. Destroyed target should re-associated with thread and not throw NPE.
*/
@Test
void testReuseDestroyedTarget() {
void reuseDestroyedTarget() {
ThreadLocalTargetSource source = (ThreadLocalTargetSource)this.beanFactory.getBean("threadLocalTs");
// try first time
@@ -33,7 +33,7 @@ class RefreshableTargetSourceTests {
* Test what happens when checking for refresh but not refreshing object.
*/
@Test
void testRefreshCheckWithNonRefresh() throws Exception {
void refreshCheckWithNonRefresh() throws Exception {
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource();
ts.setRefreshCheckDelay(0);
@@ -49,7 +49,7 @@ class RefreshableTargetSourceTests {
* Test what happens when checking for refresh and refresh occurs.
*/
@Test
void testRefreshCheckWithRefresh() throws Exception {
void refreshCheckWithRefresh() throws Exception {
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
ts.setRefreshCheckDelay(0);
@@ -65,7 +65,7 @@ class RefreshableTargetSourceTests {
* Test what happens when no refresh occurs.
*/
@Test
void testWithNoRefreshCheck() {
void withNoRefreshCheck() {
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
ts.setRefreshCheckDelay(-1);
@@ -78,7 +78,7 @@ class RefreshableTargetSourceTests {
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void testRefreshOverTime() throws Exception {
void refreshOverTime() throws Exception {
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
ts.setRefreshCheckDelay(100);
@@ -95,7 +95,7 @@ class RefreshableTargetSourceTests {
Object d = ts.getTarget();
assertThat(d).as("D should not be null").isNotNull();
assertThat(a.equals(d)).as("A and D should not be equal").isFalse();
assertThat(a).as("A and D should not be equal").isNotEqualTo(d);
Object e = ts.getTarget();
assertThat(e).as("D and E should be equal").isEqualTo(d);
@@ -103,7 +103,7 @@ class RefreshableTargetSourceTests {
Thread.sleep(110);
Object f = ts.getTarget();
assertThat(e.equals(f)).as("E and F should be different").isFalse();
assertThat(e).as("E and F should be different").isNotEqualTo(f);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
* @author Phillip Webb
* @author Stephane Nicoll
*/
public abstract class AbstractCacheAnnotationTests {
abstract class AbstractCacheAnnotationTests {
protected ConfigurableApplicationContext ctx;
@@ -67,7 +67,7 @@ public abstract class AbstractCacheAnnotationTests {
@BeforeEach
public void setup() {
void setup() {
this.ctx = getApplicationContext();
this.cs = ctx.getBean("service", CacheableService.class);
this.ccs = ctx.getBean("classService", CacheableService.class);
@@ -78,7 +78,7 @@ public abstract class AbstractCacheAnnotationTests {
}
@AfterEach
public void close() {
void close() {
if (this.ctx != null) {
this.ctx.close();
}
@@ -555,133 +555,134 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(secondary.get(key2)).isNull();
}
@Test
void testCacheable() {
void cacheable() {
testCacheable(this.cs);
}
@Test
void testCacheableNull() {
void cacheableNull() {
testCacheableNull(this.cs);
}
@Test
void testCacheableSync() {
void cacheableSync() {
testCacheableSync(this.cs);
}
@Test
void testCacheableSyncNull() {
void cacheableSyncNull() {
testCacheableSyncNull(this.cs);
}
@Test
void testEvict() {
void evict() {
testEvict(this.cs, true);
}
@Test
void testEvictEarly() {
void evictEarly() {
testEvictEarly(this.cs);
}
@Test
void testEvictWithException() {
void evictWithException() {
testEvictException(this.cs);
}
@Test
void testEvictAll() {
void evictAll() {
testEvictAll(this.cs, true);
}
@Test
void testEvictAllEarly() {
void evictAllEarly() {
testEvictAllEarly(this.cs);
}
@Test
void testEvictWithKey() {
void evictWithKey() {
testEvictWithKey(this.cs);
}
@Test
void testEvictWithKeyEarly() {
void evictWithKeyEarly() {
testEvictWithKeyEarly(this.cs);
}
@Test
void testConditionalExpression() {
void conditionalExpression() {
testConditionalExpression(this.cs);
}
@Test
void testConditionalExpressionSync() {
void conditionalExpressionSync() {
testConditionalExpressionSync(this.cs);
}
@Test
void testUnlessExpression() {
void unlessExpression() {
testUnlessExpression(this.cs);
}
@Test
void testClassCacheUnlessExpression() {
void classCacheUnlessExpression() {
testUnlessExpression(this.cs);
}
@Test
void testKeyExpression() {
void keyExpression() {
testKeyExpression(this.cs);
}
@Test
void testVarArgsKey() {
void varArgsKey() {
testVarArgsKey(this.cs);
}
@Test
void testClassCacheCacheable() {
void classCacheCacheable() {
testCacheable(this.ccs);
}
@Test
void testClassCacheEvict() {
void classCacheEvict() {
testEvict(this.ccs, true);
}
@Test
void testClassEvictEarly() {
void classEvictEarly() {
testEvictEarly(this.ccs);
}
@Test
void testClassEvictAll() {
void classEvictAll() {
testEvictAll(this.ccs, true);
}
@Test
void testClassEvictWithException() {
void classEvictWithException() {
testEvictException(this.ccs);
}
@Test
void testClassCacheEvictWithWKey() {
void classCacheEvictWithWKey() {
testEvictWithKey(this.ccs);
}
@Test
void testClassEvictWithKeyEarly() {
void classEvictWithKeyEarly() {
testEvictWithKeyEarly(this.ccs);
}
@Test
void testNullValue() {
void nullValue() {
testNullValue(this.cs);
}
@Test
void testClassNullValue() {
void classNullValue() {
Object key = new Object();
assertThat(this.ccs.nullValue(key)).isNull();
int nr = this.ccs.nullInvocations().intValue();
@@ -694,27 +695,27 @@ public abstract class AbstractCacheAnnotationTests {
}
@Test
void testMethodName() {
void methodName() {
testMethodName(this.cs, "name");
}
@Test
void testClassMethodName() {
void classMethodName() {
testMethodName(this.ccs, "nametestCache");
}
@Test
void testRootVars() {
void rootVars() {
testRootVars(this.cs);
}
@Test
void testClassRootVars() {
void classRootVars() {
testRootVars(this.ccs);
}
@Test
void testCustomKeyGenerator() {
void customKeyGenerator() {
Object param = new Object();
Object r1 = this.cs.customKeyGenerator(param);
assertThat(this.cs.customKeyGenerator(param)).isSameAs(r1);
@@ -725,14 +726,14 @@ public abstract class AbstractCacheAnnotationTests {
}
@Test
void testUnknownCustomKeyGenerator() {
void unknownCustomKeyGenerator() {
Object param = new Object();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
this.cs.unknownCustomKeyGenerator(param));
}
@Test
void testCustomCacheManager() {
void customCacheManager() {
CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class);
Object key = new Object();
Object r1 = this.cs.customCacheManager(key);
@@ -743,139 +744,139 @@ public abstract class AbstractCacheAnnotationTests {
}
@Test
void testUnknownCustomCacheManager() {
void unknownCustomCacheManager() {
Object param = new Object();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
this.cs.unknownCustomCacheManager(param));
}
@Test
void testNullArg() {
void nullArg() {
testNullArg(this.cs);
}
@Test
void testClassNullArg() {
void classNullArg() {
testNullArg(this.ccs);
}
@Test
void testCheckedException() {
void checkedException() {
testCheckedThrowable(this.cs);
}
@Test
void testClassCheckedException() {
void classCheckedException() {
testCheckedThrowable(this.ccs);
}
@Test
void testCheckedExceptionSync() {
void checkedExceptionSync() {
testCheckedThrowableSync(this.cs);
}
@Test
void testClassCheckedExceptionSync() {
void classCheckedExceptionSync() {
testCheckedThrowableSync(this.ccs);
}
@Test
void testUncheckedException() {
void uncheckedException() {
testUncheckedThrowable(this.cs);
}
@Test
void testClassUncheckedException() {
void classUncheckedException() {
testUncheckedThrowable(this.ccs);
}
@Test
void testUncheckedExceptionSync() {
void uncheckedExceptionSync() {
testUncheckedThrowableSync(this.cs);
}
@Test
void testClassUncheckedExceptionSync() {
void classUncheckedExceptionSync() {
testUncheckedThrowableSync(this.ccs);
}
@Test
void testUpdate() {
void update() {
testCacheUpdate(this.cs);
}
@Test
void testClassUpdate() {
void classUpdate() {
testCacheUpdate(this.ccs);
}
@Test
void testConditionalUpdate() {
void conditionalUpdate() {
testConditionalCacheUpdate(this.cs);
}
@Test
void testClassConditionalUpdate() {
void classConditionalUpdate() {
testConditionalCacheUpdate(this.ccs);
}
@Test
void testMultiCache() {
void multiCache() {
testMultiCache(this.cs);
}
@Test
void testClassMultiCache() {
void classMultiCache() {
testMultiCache(this.ccs);
}
@Test
void testMultiEvict() {
void multiEvict() {
testMultiEvict(this.cs);
}
@Test
void testClassMultiEvict() {
void classMultiEvict() {
testMultiEvict(this.ccs);
}
@Test
void testMultiPut() {
void multiPut() {
testMultiPut(this.cs);
}
@Test
void testClassMultiPut() {
void classMultiPut() {
testMultiPut(this.ccs);
}
@Test
void testPutRefersToResult() {
void putRefersToResult() {
testPutRefersToResult(this.cs);
}
@Test
void testClassPutRefersToResult() {
void classPutRefersToResult() {
testPutRefersToResult(this.ccs);
}
@Test
void testMultiCacheAndEvict() {
void multiCacheAndEvict() {
testMultiCacheAndEvict(this.cs);
}
@Test
void testClassMultiCacheAndEvict() {
void classMultiCacheAndEvict() {
testMultiCacheAndEvict(this.ccs);
}
@Test
void testMultiConditionalCacheAndEvict() {
void multiConditionalCacheAndEvict() {
testMultiConditionalCacheAndEvict(this.cs);
}
@Test
void testClassMultiConditionalCacheAndEvict() {
void classMultiConditionalCacheAndEvict() {
testMultiConditionalCacheAndEvict(this.ccs);
}
@@ -37,7 +37,7 @@ class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests {
}
@Test
void testKeyStrategy() {
void keyStrategy() {
AnnotationCacheAspect aspect = ctx.getBean(
"org.springframework.cache.config.internalCacheAspect", AnnotationCacheAspect.class);
assertThat(aspect.getKeyGenerator()).isSameAs(ctx.getBean("keyGenerator"));
@@ -16,7 +16,7 @@
package org.springframework.cache.aspectj;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AutoClose;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -51,6 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class AspectJEnableCachingIsolatedTests {
@AutoClose
private ConfigurableApplicationContext ctx;
@@ -58,23 +59,16 @@ class AspectJEnableCachingIsolatedTests {
this.ctx = new AnnotationConfigApplicationContext(config);
}
@AfterEach
public void closeContext() {
if (this.ctx != null) {
this.ctx.close();
}
}
@Test
void testKeyStrategy() {
void keyStrategy() {
load(EnableCachingConfig.class);
AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class);
assertThat(aspect.getKeyGenerator()).isSameAs(this.ctx.getBean("keyGenerator", KeyGenerator.class));
}
@Test
void testCacheErrorHandler() {
void cacheErrorHandler() {
load(EnableCachingConfig.class);
AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class);
assertThat(aspect.getErrorHandler()).isSameAs(this.ctx.getBean("errorHandler", CacheErrorHandler.class));
@@ -128,7 +122,7 @@ class AspectJEnableCachingIsolatedTests {
@Test
@Disabled("AspectJ has some sort of caching that makes this one fail")
public void emptyConfigSupport() {
void emptyConfigSupport() {
load(EmptyConfigSupportConfig.class);
AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class);
assertThat(aspect.getCacheResolver()).isNotNull();
@@ -283,4 +277,5 @@ class AspectJEnableCachingIsolatedTests {
return new NamedCacheResolver(cacheManager(), "foo");
}
}
}
@@ -47,7 +47,7 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
* @author Stephane Nicoll
*/
@EnabledForTestGroups(LONG_RUNNING)
public class AnnotationAsyncExecutionAspectTests {
class AnnotationAsyncExecutionAspectTests {
private static final long WAIT_TIME = 1000; //milliseconds
@@ -57,7 +57,7 @@ public class AnnotationAsyncExecutionAspectTests {
@BeforeEach
public void setUp() {
void setUp() {
executor = new CountingExecutor();
AnnotationAsyncExecutionAspect.aspectOf().setExecutor(executor);
}
@@ -37,13 +37,13 @@ class AnnotationDrivenBeanDefinitionParserTests {
private ConfigurableApplicationContext context;
@BeforeEach
public void setup() {
void setup() {
this.context = new ClassPathXmlApplicationContext(
"annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class);
}
@AfterEach
public void after() {
void after() {
if (this.context != null) {
this.context.close();
}
@@ -56,7 +56,7 @@ class AnnotationDrivenBeanDefinitionParserTests {
@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExecutorReference() {
void asyncPostProcessorExecutorReference() {
Object executor = context.getBean("testExecutor");
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
assertThat(((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("defaultExecutor")).get()).isSameAs(executor);
@@ -64,7 +64,7 @@ class AnnotationDrivenBeanDefinitionParserTests {
@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExceptionHandlerReference() {
void asyncPostProcessorExceptionHandlerReference() {
Object exceptionHandler = context.getBean("testExceptionHandler");
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
assertThat(((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("exceptionHandler")).get()).isSameAs(exceptionHandler);
@@ -36,13 +36,13 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
* @author Stephane Nicoll
*/
@SpringJUnitConfig(JtaTransactionAspectsTests.Config.class)
public class JtaTransactionAspectsTests {
class JtaTransactionAspectsTests {
@Autowired
private CallCountingTransactionManager txManager;
@BeforeEach
public void setUp() {
void setUp() {
this.txManager.clear();
}
@@ -50,13 +50,13 @@ class TransactionAspectTests {
@BeforeEach
public void initContext() {
void initContext() {
AnnotationTransactionAspect.aspectOf().setTransactionManager(txManager);
}
@Test
void testCommitOnAnnotatedClass() throws Throwable {
void commitOnAnnotatedClass() throws Throwable {
txManager.clear();
assertThat(txManager.begun).isEqualTo(0);
annotationOnlyOnClassWithNoInterface.echo(null);
@@ -967,8 +967,8 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
actualName = propertyName.substring(0, keyStart);
}
String key = propertyName.substring(keyStart + PROPERTY_KEY_PREFIX.length(), keyEnd);
if (key.length() > 1 && (key.startsWith("'") && key.endsWith("'")) ||
(key.startsWith("\"") && key.endsWith("\""))) {
if (key.length() > 1 && ((key.startsWith("'") && key.endsWith("'")) ||
(key.startsWith("\"") && key.endsWith("\"")))) {
key = key.substring(1, key.length() - 1);
}
keys.add(key);

Some files were not shown because too many files have changed in this diff Show More