Commit Graph

1168 Commits

Author SHA1 Message Date
Sam Brannen 2567b20949 Upgrade to spring-javaformat 0.0.28 and downgrade to Checkstyle 8.41
In order to be able to use text blocks and other new Java language
features, we are upgrading to a recent version of Checkstyle.

The latest version of spring-javaformat-checkstyle (0.0.28) is built
against Checkstyle 8.32 which does not include support for language
features such as text blocks. Support for text blocks was added in
Checkstyle 8.36.

In addition, there is a binary compatibility issue between
spring-javaformat-checkstyle 0.0.28 and Checkstyle 8.42. Thus we cannot
use Checkstyle 8.42 or higher.

In this commit, we therefore upgrade to spring-javaformat-checkstyle
0.0.28 and downgrade to Checkstyle 8.41.

This change is being applied to `5.3.x` as well as `main` in order to
benefit from the enhanced checking provided in more recent versions of
Checkstyle.

Closes gh-27481
2021-09-28 10:29:31 +02:00
Juergen Hoeller 8f96ca4a2d Merge branch '5.3.x'
# Conflicts:
#	spring-context/spring-context.gradle
#	spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java
2021-09-21 17:47:27 +02:00
Juergen Hoeller 1f8c233dfc Polishing 2021-09-21 17:43:03 +02:00
Juergen Hoeller 774583dfa7 Retain support for legacy PostConstruct/PreDestroy/Inject variants
Also removes JAX-WS support from CommonAnnotationBeanPostProcessor.

Closes gh-27444
See gh-27422
2021-09-21 17:07:42 +02:00
Juergen Hoeller d84ca2ba90 Jakarta EE 9 migration
Upgrades many dependency declarations; removes old EJB 2.x support and outdated Servlet-based integrations (Commons FileUpload, FreeMarker JSP support, Tiles).

Closes gh-22093
Closes gh-25354
Closes gh-26185
Closes gh-27423
See gh-27424
2021-09-17 09:14:07 +02:00
Juergen Hoeller 5822f1bf85 Drop RPC-style remoting
Closes gh-27422
2021-09-17 08:59:58 +02:00
Juergen Hoeller b7b078d26e Remove Joda-Time support
Closes gh-27426
2021-09-17 08:58:40 +02:00
Juergen Hoeller cf2429b0f0 Remove support for deprecated Java SecurityManager (-> JDK 17 build compatibility)
Includes hard JDK 9+ API dependency in CGLIB ReflectUtils (Lookup.defineClass) and removal of OutputStream spy proxy usage (avoiding invalid Mockito proxy on JDK 17)

Closes gh-26901
2021-09-15 15:30:25 +02:00
Sam Brannen ae56f2ac09 Polish contribution
See gh-27336
2021-08-30 16:54:16 +02:00
Philippe Marschall debf61b948
Remove unused private loggers
Closes gh-27336
2021-08-30 16:51:59 +02:00
Sam Brannen bd72e4498b Revise and document TimeUnit support in @Scheduled
This commit also fixes a bug introduced in commit e99b43b91e, where
java.time.Duration strings were converted to milliseconds and then
converted again using the configured TimeUnit.

See gh-27309
2021-08-25 20:55:55 +02:00
Axzial e99b43b91e Support TimeUnit in the @Scheduled annotation
This commit introduces a new `timeUnit` attribute in the @Scheduled
annotation to allow the user to specify a time unit other than
milliseconds.

Closes gh-27309
2021-08-25 20:50:37 +02:00
Syuziko eaf9deedfd Polish tests
See gh-27248
2021-08-07 18:53:47 +02:00
Juergen Hoeller d3b1c4f62b Code alignment between ThreadPoolTaskExecutor and ThreadPoolTaskScheduler
See gh-26700
2021-07-09 15:19:25 +02:00
Filip Hrisafov 531174258c Apply dynamic changes in ThreadPoolTaskExecutor before setting local value
If the ThreadPoolTaskExecutor is dynamically changed with an invalid value
the state of the ThreadPoolTaskExecutor does no longer correctly represent
the state of the underlying ThreadPoolExecutor
2021-07-09 15:10:55 +02:00
Juergen Hoeller 8680fdb8bc Polishing 2021-07-09 13:26:46 +02:00
Juergen Hoeller c45c46dad7 Make proxyTargetClass=true with introduction advice work for JDK proxy targets
Closes gh-27044
2021-07-09 13:23:04 +02:00
Arjen Poutsma 76b1c0f1fc Various bug fixes in CronExpression
This commit makes various bug fixes in CronExpression and related files.

Closes gh-27136
2021-07-07 10:56:07 +02:00
Sam Brannen 2bc7a3aa0a Implement equals, hashCode, & toString in BeanMethod and *Metadata types
Prior to this commit, ConfigurationClass implemented equals(),
hashCode(), and toString(), but BeanMethod did not.

This commit introduces equals(), hashCode(), and toString()
implementations in BeanMethod for consistency with ConfigurationClass
to make it possible to use BeanMethod instances to index additional
metadata as well.

In order to properly implement equals() in BeanMethod, the method
argument types are required, but these are not directly available in
BeanMethod. However, they are available via ASM when processing @Bean
methods. This commit therefore implements equals(), hashCode(), and
toString() in SimpleMethodMetadata which BeanMethod delegates to.

For completeness, this commit also implements equals(), hashCode(), and
toString() in StandardClassMetadata, StandardMethodMetadata, and
SimpleAnnotationMetadata.

Closes gh-27076
2021-06-24 16:41:28 +02:00
Sam Brannen 1bc236785c Polishing 2021-06-24 15:47:24 +02:00
duan847 3c8074b669
Fix assertion in XmlBeanFactoryTests
Closes gh-27058
2021-06-14 18:49:55 +02:00
Arjen Poutsma 6f2fe5ddcb (Re)introduce CronExpression::isValidExpression
This commit introduces CronExpression::isValidExpression, which was also
present on the deprecated CronSequenceGenerator.

Closes: gh-26996
2021-05-31 14:28:55 +02:00
Arjen Poutsma 4203e90655 Fix CronExpression roll-forward issue
This commit makes sure that BitsCronField rolls the date forward in
cases where we cannot find a next bit to elapse to.

Closes: gh-26964
2021-05-26 16:46:15 +02:00
Johnny Lim 98770b15e7
Polishing
Closes gh-26878
2021-04-29 16:53:53 +02:00
Stephane Nicoll 607d918340 Provide nested cause when a suitable CacheManager cannot be found
Closes gh-25250
2021-04-29 08:48:34 +02:00
Arjen Poutsma 27bfcbbc82 Fix daylight saving issue in CronExpression
Closes gh-26830
2021-04-21 12:04:21 +02:00
Sam Brannen 906a1f561a Polish CronTriggerTests and assess daylight savings time issue
This test polishes CronTriggerTests and modifies the
daylightSavingMissingHour() test to help analyze why the test fails
for CET if the minute value for the last completion time falls between
0 and 9 minutes.

Associated broken build:

https://ge.spring.io/s/epphj7vruwcn6/tests/:spring-context:test/org.springframework.scheduling.support.CronTriggerTests/testDaylightSavingMissingHour(LocalDateTime,%20TimeZone)%5B2%5D?expanded-stacktrace=WyIwIl0
2021-04-20 12:18:01 +02:00
Sam Brannen e489706f13 Ensure @DateTimeFormat tests pass on Java 9+
Prior to this commit, two tests for exception handling regarding
@DateTimeFormat processing only passed on Java 8. This is due to the
fact that the toString() implementation for annotations changed in Java
9. Specifically, the representation for arrays changed from [] to {},
and strings are enclosed in double quotes beginning with Java 9.

This commit ensures that the affected @DateTimeFormat tests pass on
Java 9+, by making the assertions more lenient regarding toString()
output for annotations.

See gh-26777
See gh-26804
2021-04-18 15:48:00 +02:00
Sam Brannen 0f31830ae2 Retain root cause for parsing patterns in @DateTimeFormat
The support for fallback parsing patterns in @DateTimeFormat introduced
in gh-20292 introduced a regression in that the original cause of the
parsing exception was no longer retained.

gh-26777 addressed that regression for `java.time` support; whereas,
this commit addresses that regression for legacy Date types.

This commit ensures that the original ParseException is set as the
cause for any newly created ParseException, thereby retaining the
original exception as the root cause.

Closes gh-26804
2021-04-16 19:14:41 +02:00
Sam Brannen 22d9012081 Retain root cause for parsing patterns in @DateTimeFormat
The support for fallback parsing patterns in @DateTimeFormat introduced
in gh-20292 introduced a regression in that the original cause of the
parsing exception was no longer retained.

This commit ensures that the original DateTimeParseException is set as
the cause for any newly created DateTimeParseException, thereby
retaining the original exception as the root cause.

Closes gh-26777
2021-04-12 19:55:43 +02:00
Arjen Poutsma f982fd99d7 Fix timezone offset in CronExpressionTests
Closes gh-26744
2021-03-30 16:37:26 +02:00
Arjen Poutsma ab18ab6025 Fix CronExpression issue with ZonedDateTime & DST
This commit fixes an issue with CronExpression when used in combination
with ZonedDateTime and daylight saving time.

Closes gh-26744
2021-03-30 15:20:59 +02:00
Sam Brannen b2bcb0f93a Support multiple parsing patterns in @DateTimeFormat
Prior to this commit, @DateTimeFormat only supported a single format
for parsing date time values via the style, iso, and pattern attributes.

This commit introduces a new fallbackPatterns attribute that can be
used to configure multiple fallback patterns for parsing date time
values. This allows applications to accept multiple input formats for
date time values.

For example, if you wish to use the ISO date format for parsing and
printing but allow for lenient parsing of user input for various
additional date formats, you could annotate a field or method parameter
with configuration similar to the following.

    @DateTimeFormat(
        iso = ISO.DATE,
        fallbackPatterns = { "M/d/yy", "dd.MM.yyyy" }
    )

Closes gh-20292
2021-03-11 11:30:30 +01:00
Juergen Hoeller 3c9bd3177e Move getListenerId method to Smart/GenericApplicationListener
See gh-26638
2021-03-09 12:30:52 +01:00
Juergen Hoeller 86902d27b2 Expose id/getListenerId in base EventListener/ApplicationListener (pulled up from tx)
Includes removeApplicationListeners(Predicate) method in ApplicationEventMulticaster.

Closes gh-26638
2021-03-08 19:31:56 +01:00
Arjen Poutsma eb68e6a62a Support SUN as minimum of range in CronExpression
This commit makes sure that SUN can be used at the beginning of a range,
 like SUN-FRI.

Closes gh-26598
2021-02-25 10:50:34 +01:00
Juergen Hoeller df977a2fd2 Nullability refinements and related polishing 2021-02-14 17:57:32 +01:00
Juergen Hoeller defc2466b0 Fail early FactoryBean instantiation for LinkageError
Closes gh-26425
2021-02-14 17:56:38 +01:00
Arjen Poutsma 67112b211a Rollback to midnight in quartz expressions
This commit makes sure that the CronExpression rolls back the time to
midnight when dealing with Quartz expression fields (such as "L", "LW",
etc.).

Closes gh-26390
2021-01-19 15:06:40 +01:00
Juergen Hoeller 4ac27e4dab Suppress ClassCastException for payload type mismatch as well
Closes gh-26349
2021-01-11 09:44:38 +01:00
Arjen Poutsma d387d9ae1e Allow quartz expression in cron expression lists
This commit introduces support for lists of quartz cron fields, such
as "1L, LW" or "TUE#1, TUE#3, TUE#5".

Closes gh-26289
2021-01-07 14:27:07 +01:00
Arjen Poutsma 4f6d26b25c Parse list with range delta in CronExpression
Closes gh-26313
2021-01-04 16:02:28 +01:00
Sam Brannen 91a6254187 Test status quo for repeatable @PropertySource on composed annotation
This commit introduces tests that verify support for using
@PropertySource as a repeatable annotation without the
@PropertySources container, both locally on an @Configuration class
and on a custom composed annotation.

See gh-26329
2021-01-02 16:21:53 +01:00
Sam Brannen c8ad762b40 Polishing 2021-01-02 16:21:53 +01:00
Sam Brannen 5c1176786c Test status quo for list support in CronExpression
See gh-26289
2020-12-30 14:38:58 +01:00
Juergen Hoeller 00b56c026a Consistent handling of NullBean instances in resolveNamedBean
Closes gh-26271
2020-12-16 22:27:41 +01:00
Juergen Hoeller c970c318f4 Polishing 2020-12-07 22:08:01 +01:00
Johnny Lim c7f2f50c15
Polish ConfigurationClassPostProcessorTests
Closes gh-26197
2020-12-02 15:07:15 +01:00
Juergen Hoeller 56dbe06d9b Register @Bean definitions as dependent on containing configuration class
Closes gh-26167
2020-11-27 17:00:16 +01:00
Juergen Hoeller 412aa06d86 Reliably refresh metadata for dynamically changing prototype bean class
Closes gh-26019
2020-11-04 16:48:54 +01:00
Juergen Hoeller 95110d8257 Introduce TransactionalApplicationListener interface (with callback support)
Includes forPayload methods and common adapter classes for programmatic usage.
Aligns default order values for event handling delegates to LOWEST_PRECEDENCE.

Closes gh-24163
2020-10-22 15:19:32 +02:00
Сергей Цыпанов 8a04910bdd Drop explicit zeroing at instantiation of Atomic* objects 2020-10-06 15:45:12 +02:00
Brian Clozel 61d893257e Rewrite "performance" test to JMH benchmarks
This commit rewrites the remaining "fastEnough" performance tests into
proper JMH benchmarks.

See gh-24830
2020-09-25 13:43:38 +02:00
Brian Clozel e02d3f32b4 Requalify tests as LONG_RUNNING
Prior to this commit, some tests would belong to the PERFORMANCE
`TestGroup`, while they were not testing for performance but rather
performing functional tests that involve long running operations or
timeouts.

This commit moves those tests to the LONG_RUNNING `TestGroup`.

See gh-24830
2020-09-25 13:43:38 +02:00
Juergen Hoeller 6c631e3d5c Merge branch '5.2.x'
# Conflicts:
#	spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java
2020-09-25 11:36:18 +02:00
Juergen Hoeller c83f6adc24 Revise event multicaster locking for non-synchronized retriever caching
Closes gh-25799
2020-09-25 11:24:26 +02:00
Sam Brannen d7fab85f51 Merge branch '5.2.x' 2020-09-25 11:17:24 +02:00
Sam Brannen f5d36aa47a Revert use of Map::computeIfAbsent in thread and tx scopes
Issues gh-25038 and gh-25618 collectively introduced a regression for
thread-scoped and transaction-scoped beans.

For example, given a thread-scoped bean X that depends on another
thread-scoped bean Y, if the names of the beans (when used as map keys)
end up in the same bucket within a ConcurrentHashMap AND an attempt is
made to retrieve bean X from the ApplicationContext prior to retrieving
bean Y, then the use of Map::computeIfAbsent in SimpleThreadScope
results in recursive access to the same internal bucket in the map.

On Java 8, that scenario simply hangs. On Java 9 and higher,
ConcurrentHashMap throws an IllegalStateException pointing out that a
"Recursive update" was attempted.

In light of these findings, we are reverting the changes made to
SimpleThreadScope and SimpleTransactionScope in commits 50a4fdac6e and
148dc95eb1.

Closes gh-25801
2020-09-25 11:00:06 +02:00
Arjen Poutsma 91b609817e Do not use BitSet in BitsCronField
This commit changes BitsCronField to use a long instead of a BitSet,
since the later can use significant memory.

Closes gh-25687
2020-09-08 10:11:32 +02:00
Brian Clozel c5694506ae Early configuration of ApplicationStartup on BeanFactory
Prior to this commit, the `GenericApplicationContext` configured the
`AppliationStartup` on the `BeanFactory` only right before refreshing it.
Delaying this has no purpose and we should instead configure it as soon
as possible by overriding the setter method.

Closes gh-25718
2020-09-07 10:48:59 +02:00
Yanming Zhou a2bb59f1b8 Replace StringBuffer with StringBuilder where possible 2020-09-03 22:40:51 +02:00
Сергей Цыпанов 1f3e52d932 gh-25650 Replace remaining usage of LinkedList with ArrayList in tests 2020-08-31 14:33:14 +02:00
Juergen Hoeller 2080878d82 Merge branch '5.2.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java
2020-08-27 14:40:54 +02:00
Juergen Hoeller 60fa704f78 Consistent behavior for overloaded @Bean methods with ASM processing
Closes gh-25263
2020-08-27 14:13:33 +02:00
Sam Brannen 0f7ad1b5bf Merge branch '5.2.x' 2020-08-22 23:50:28 +02:00
Sam Brannen 148dc95eb1 Fix regressions in SimpleThreadScope and SimpleTransactionScope
PR gh-25038 introduced regressions in SimpleThreadScope and
SimpleTransactionScope in Spring Framework 5.2.7. Specifically, if a
thread-scoped or transaction-scoped bean has a dependency on another
thread-scoped or transaction-scoped bean, respectively, a
ConcurrentModificationException will be thrown on Java 11 or higher.

The reason is that Java 11 introduced a check for concurrent
modification in java.util.HashMap's computeIfAbsent() implementation,
and such a modification can occur when a thread-scoped bean is being
created in order to satisfy a dependency of another thread-scoped bean
that is currently being created.

This commit fixes these regressions by switching from HashMap to
ConcurrentHashMap for the instance maps in SimpleThreadScope and
SimpleTransactionScope.

Closes gh-25618
2020-08-22 23:19:58 +02:00
Sam Brannen c558391e2c Declare interfaces as @FunctionalInterface where feasible
This commit declares each of the following public interfaces as a
@FunctionalInterface.

- org.springframework.context.ApplicationContextInitializer
- org.springframework.test.web.servlet.DispatcherServletCustomizer
- org.springframework.validation.MessageCodeFormatter
- org.springframework.util.IdGenerator
- org.springframework.beans.factory.config.YamlProcessor.MatchCallback
- org.springframework.beans.factory.config.YamlProcessor.DocumentMatcher

Closes gh-25580
2020-08-11 17:01:03 +02:00
Juergen Hoeller e87a49c61c Merge branch '5.2.x' 2020-08-07 21:43:33 +02:00
Juergen Hoeller 292f581cdd Populate dependencies metadata for resolved target behind lazy dependency proxy
Closes gh-25562
2020-08-07 21:42:02 +02:00
Arjen Poutsma 4d670ee25d Drop support for standalone "L" in CronExpression
This commit removes support for a standalone "L" in the
day-of-week of a cron expression, which used a locale-dependent
API to determine what the last day of the week is (Saturday or
Sunday ?).
Alternatively, we could have implement this in the exact way as Quartz
has done (i.e. treat the "L" like "SAT"), but we opted not to do that,
as having an explicit SAT or SUN is much clearer.
2020-08-05 09:42:18 +02:00
Arjen Poutsma 762cf0ffe8 Check for asterisk range in CronExpression
This commit makes sure that in CronExpression, the asterisk is only used
in a range field, and is not surrounded by unexpected characters.

Closes gh-19500
2020-08-04 16:34:02 +02:00
Arjen Poutsma 93b53dae29 Add support for Quartz features in CronExpression
This commit introduces support for Quartz-specific features in
CronExpression. This includes support for "L", "W", and "#".

Closes gh-20106
Closes gh-22436
2020-08-04 08:41:18 +02:00
Arjen Poutsma 1a8906bdc3 Support macros in CronExpression
This commit introduces supports for macros like "@yearly", "@monthly",
etc. in CronExpression.

Closes gh-25471
2020-08-04 07:51:32 +02:00
Arjen Poutsma dbec16d566 Add test for Friday 13th crontab failure
Added test for Friday 13th trigger, i.e. an uncommon crontab expression.
With the new CronExpression in place, this failure does not occur
anymore.

Closes gh-21574
2020-08-03 16:55:55 +02:00
Arjen Poutsma 72895f0810 Add test for combination of fixed date fields
Added test for a fixed day-of-week and day-of-month combination.
With the new CronExpression in place, this failure does not occur
anymore.

Closes gh-13621
2020-08-03 16:49:21 +02:00
Arjen Poutsma 87c3bb5797 Introduce CronExpression
This commit introduces CronExpression, a new for representing cron
expressions, and a direct replacement for CronSequenceGenerator.
2020-08-03 16:37:31 +02:00
Juergen Hoeller 718d46adac Check for alias overriding bean definition of same name
Closes gh-25430
2020-07-22 18:42:53 +02:00
XenoAmess c547809e89 Use instanceof instead of Class#isInstance where feasible
Closes gh-25446
2020-07-22 14:06:29 +02:00
XenoAmess cd12583e13
Use Integer.parseInt instead of Integer.valueOf for primitive int
Closes gh-25456
2020-07-22 10:54:32 +02:00
XenoAmess c7f44ff671
Fix links in Javadoc
Closes gh-25448
2020-07-22 10:24:55 +02:00
Juergen Hoeller 198d64d539 Merge branch '5.2.x'
# Conflicts:
#	build.gradle
2020-07-17 17:52:08 +02:00
Juergen Hoeller e9898f7d52 Polishing 2020-07-17 17:48:33 +02:00
Sam Brannen abe16eeb6e Use test name as thread name prefix in scheduling TaskExecutor tests
This commit also deletes a duplicate copy of the assertThreadNamePrefix()
method.
2020-07-11 17:01:54 +02:00
Sam Brannen ab0e651547 Polish SerializationTestUtils, clean up warnings, etc. 2020-06-20 18:17:03 +02:00
Sam Brannen edf25ce98a Polish ResourceBundleMessageSourceTests
- suppress warnings
- make tests faster (by sleeping less)
2020-06-18 11:49:44 +02:00
Sam Brannen 8099fc8178 Use try-with-resources language construct where feasible
Closes gh-2063

Co-authored-by: igor-suhorukov <igor.suhorukov@gmail.com>
2020-06-16 22:57:45 +02:00
Juergen Hoeller 7207f7645c Deprecate InstantiationAwareBeanPostProcessorAdapter
Consistently relying on default methods in the corresponding interfaces.

Closes gh-25165
2020-05-29 23:07:10 +02:00
Sam Brannen 763f7b9be8 Make TaskExecutor and TaskScheduler tests more robust 2020-05-27 15:25:39 +02:00
Sam Brannen c4ef002392 Stop to writing to STD_OUT in tests 2020-05-27 15:21:17 +02:00
Juergen Hoeller 399453d9f1 Merge branch '5.2.x'
# Conflicts:
#	spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java
#	spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java
2020-05-22 17:16:09 +02:00
Juergen Hoeller d7161f5e5e Polishing 2020-05-22 16:23:46 +02:00
Rossen Stoyanchev 6403a9f10e Defer decision on BindingResult type until access
Closes gh-24347
2020-05-14 15:42:43 +01:00
liym d54b903d28
Fix typo in RmiSupportTests
Closes gh-25051
2020-05-12 14:19:16 +02:00
Sam Brannen b313b3395f Fix AutoProxyLazyInitTests
See gh-24915
2020-05-12 12:37:10 +02:00
Sam Brannen 3c3e8e6a8b Only proxy supported beans in BeanNameAutoProxyCreator
Prior to this commit, if a BeanNameAutoProxyCreator was configured with
a custom TargetSourceCreator, the TargetSourceCreator was applied to
all beans in the ApplicationContext. Thus, the list of supported
beanNames was effectively ignored when applying any
TargetSourceCreator. Consequently, if a TargetSourceCreator returned a
non-null TargetSource for a given bean, the BeanNameAutoProxyCreator
proxied the bean even if the bean name had not been configured in the
beanNames list.

This commit addresses this issue by ensuring that a custom
TargetSourceCreator is only applied to beans whose names match the
configured beanNames list in a BeanNameAutoProxyCreator.

Closes gh-24915
2020-05-12 11:59:51 +02:00
Sam Brannen a07dc80d72 Polishing 2020-05-12 11:15:14 +02:00
Sam Brannen 12e05280ad Upgrade to AssertJ 3.16 2020-05-06 15:22:23 +02:00
Sam Brannen c3f439417e Disable remaining JavaScript-based tests on Java 15+
This commit disables all remaining JavaScript-based tests on Java 15 or
higher since the Nashorn JavaScript engine is no longer part of the JDK.
2020-04-28 17:22:22 +02:00
Sam Brannen 71ed8143a1 Disable StandardScriptFactoryTests on Java 15+
This commit disables StandardScriptFactoryTests on Java 15 or higher
since the Nashorn JavaScript engine is no longer part of the JDK.
2020-04-28 16:56:15 +02:00
Juergen Hoeller 73fadd8b7c Polishing 2020-04-27 11:45:41 +02:00
Juergen Hoeller 127e879726 Store source in index-derived ScannedGenericBeanDefinition as well
Includes consistent constructor-level storage of derived resource in ScannedGenericBeanDefinition and ConfigurationClassBeanDefinition.

Closes gh-24978
2020-04-27 11:45:08 +02:00
陈其苗 13970ae528 Use autoboxing instead of explicit wrapping in tests
Closes gh-24801
2020-04-01 14:34:20 +02:00
Sam Brannen 01cf0a3d4e Polish MBeanClientInterceptorTests and recover two lost tests
Two test methods were missing the @Test annotation after the migration
from JUnit 3 to JUnit 4.
2020-03-31 19:02:15 +02:00
Sam Brannen 9bd74c270f Remove flaky check in MBeanClientInterceptorTests
Prior to this commit, the testTestLazyConnectionToRemote() method in
MBeanClientInterceptorTests expected an exception to be thrown while
attempting to access the state of a proxied MBean after the MBeanServer
had been shutdown; however, the test occasionally failed if the server
had not been properly shutdown.

Since an attempt to wait on the server to shutdown proved not to be
consistently helpful in this scenario, we are entirely removing this
check from the test.
2020-03-31 18:55:54 +02:00
Qimiao Chen 7c831d2ef4
Replace anonymous inner classes with lambdas in tests
Closes gh-24808
2020-03-30 12:02:23 +02:00
Sam Brannen 06fa8692cd Attempt to make MBeanClientInterceptorTests more robust 2020-03-27 11:18:45 +01:00
Qimiao Chen 09b36380cd
Fix typos in source files
Closes gh-24746
2020-03-20 20:06:52 +01:00
Juergen Hoeller bcee6b9da4 Consistent assertions for supplier-based bean definition tests 2020-03-11 14:55:39 +01:00
Juergen Hoeller bee63e38c1 Create ScannedGenericBeanDefinitions for index-derived components as well
Closes gh-24638
2020-03-11 14:54:16 +01:00
ZhangT 6add7b4dec
Polishing
Closes gh-24543
2020-02-17 17:33:39 +01:00
Juergen Hoeller a4179b4795 Polishing 2020-02-12 18:32:32 +01:00
Sam Brannen 9dbd411f81 Suppress warnings in Gradle build 2020-02-12 11:04:07 +01:00
Sam Brannen 974cacac31 Support nested annotations in ASM-based processing again
Spring Framework 5.0 introduced a regression in ASM-based annotation
processing. Specifically, nested annotations were no longer supported,
and component scanning resulted in an exception if a candidate
component was annotated with an annotation that contained nested
annotations.

This commit fixes this regression by introducing special handling in
AnnotationTypeMapping that supports extracting values from objects of
type TypeMappedAnnotation when necessary.

Closes gh-24375
2020-02-12 10:36:54 +01:00
Juergen Hoeller 82adb09490 ImportSelector.getExclusionFilter() naming and javadoc clarification
See gh-24175
2020-02-05 18:20:27 +01:00
Juergen Hoeller d93303c008 ImportSelector.getCandidateFilter() for transitive filtering of classes
Closes gh-24175
2020-02-05 12:35:16 +01:00
Sam Brannen 984f9de191 Fix Checkstyle violation
See gh-24375
2020-01-16 18:14:14 +01:00
Sam Brannen 2a2efbe611 Introduce @Disabled regression test for gh-24375 2020-01-16 17:16:57 +01:00
Sébastien Deleuze 3f1882c4eb Support noarg callable references in Kotlin beans DSL
Closes gh-23395
2020-01-13 10:53:23 +01:00
Stephane Nicoll bdb9f9570e Polish 2020-01-09 17:08:48 +01:00
Juergen Hoeller b0e4b7e29c Re-calculate SimpleKey's hashCode field on deserialization
Closes gh-24320
2020-01-09 15:39:04 +01:00
Sam Brannen 8a371c7669 Use Gradle test fixture support for spring-aop
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 57b771ba92 Move common FactoryMethods to spring-beans test fixtures
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 726b1bb1d0 Rename test fixture package in spring-context
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 7cd4ddf5fc Rename test fixture package in spring-beans
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 4260c34b47 Rename test fixture package in spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 61d4ee594d Use Gradle test fixture support for spring-beans and spring-context
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Juergen Hoeller 7474ee7041 Polishing 2019-12-16 16:50:30 +01:00
Sam Brannen 47b18e5ea9 Polishing 2019-12-13 16:12:39 +01:00
lixiaolong11000 bee2b7cd73 Add missing test cases in XmlBeanFactoryTests
Closes gh-24189
2019-12-13 15:56:06 +01:00
Johnny Lim 1e83e889aa Use hasSize() where possible
See gh-24172
2019-12-10 07:58:53 +01:00
Sam Brannen 093323beeb Introduce Checkstyle rule to prohibit class names ending with "Test" 2019-11-29 17:30:29 +01:00
Sam Brannen 59e250c93c Consistent use of SCOPE_PROTOTYPE and SCOPE_SINGLETON constants
Closes gh-19905
2019-11-24 13:49:43 +01:00
Sam Brannen 8df3afd0b6 Polish contribution
See gh-23895
2019-11-14 13:26:38 +01:00
Sam Brannen 8186b77b58 Polish contribution
See gh-23895
2019-11-14 09:59:42 +01:00
monosoul a0e4ac39bf Inverse condition to fix ISO-formatted Instant parsing
Prior to this commit, InstantFormatter was able to properly serialize
an Instant that is far in the future (or in the past), but it could not
properly deserialize it, because in such scenarios an ISO-formatted
Instant starts with a +/- sign.

This commit fixes this issue, while maintaining the previous contract,
and also introduces tests for InstantFormatter.

Closes gh-23895
2019-11-14 09:59:42 +01:00
Juergen Hoeller 3dc5e7b1d5 Avoid String concatenation for lookup in StaticMessageSource
Closes gh-22451
2019-11-13 23:41:26 +01:00
Juergen Hoeller 22211a01ce Polishing 2019-11-13 17:23:23 +01:00
Juergen Hoeller c4ec6aea68 Fix Checkstyle violations
See gh-23784
2019-11-11 17:18:52 +01:00
Steven Schlansker fc55e66d50 ApplicationListenerMethodAdapter: gracefully handle beans which are actually NullBean
Currently, if you have an optional event listener (via a @Bean method returning `null`)
this causes the event multicaster to explode violently.  Now, we just safely skip it.
2019-11-11 15:43:29 +01:00
Sam Brannen d6002092c4 Clean up build warnings for ApplicationContextExpressionTests 2019-11-04 15:44:53 +01:00
Sam Brannen 74b7b550f6 Make MBeanServer tests more robust
This commit refactors several tests to use SocketUtils to find an
available port, compose a custom JMX service URL using that port, and
start an MBeanServer for the particular test using that port.

This commit also makes other changes to MBeanServer related tests in an
effort to make them more robust when executed concurrently.

Closes gh-23699
2019-10-31 14:34:57 +01:00
Sam Brannen 9f00eb68e9 Clean up warnings 2019-10-30 19:14:58 +01:00
Christoph Dreis 3c17178b16 Fix Mockito deprecations 2019-10-30 18:30:05 +01:00
Brian Clozel 4beb25b318 Reorder date formatting converter in registrar
Prior to this commit, the `DateFormatterRegistrar` would register the
annotation-based formatter before the pattern-based formatter. This
would create an issue when an application tries to convert a `String` to
an annotated `@DateTimeFormat Date`: since the converters are considered
in reversed order of registration in
`GenericConversionServicei#ConvertersForPair`, the pattern-based variant
would always be considered before the annotation-based variant,
overriding the developer's opinion.

This commit aligns the `DateFormatterRegistrar` with the
`DateTimeFormatterRegistrar` and registers the annotation-based variant
last.

Closes gh-23893
2019-10-30 17:15:59 +01:00
Sam Brannen 6a207d0012 Polish AnnotationConfigApplicationContextTests 2019-09-26 16:45:49 +02:00
Johnny Lim 2a4dbcc623 Fix an assertion in AnnotationConfigApplicationContextTests
Closes gh-23719
2019-09-26 16:34:27 +02:00
Sam Brannen b9013ada9f Abort MBeanServer tests if BindException encountered
This commit builds on the previous commit but covers exceptions thrown
by @BeforeEach and @AfterEach methods as well as @Test methods.
2019-09-24 19:20:39 +02:00
Sam Brannen 435cc67026 Abort MBeanServer tests if BindException encountered 2019-09-24 18:57:30 +02:00
Juergen Hoeller e68132686d Restore lenient target type handling for FactoryBean definitions
Closes gh-23561
2019-09-20 21:54:32 +02:00
Phillip Webb 077754b8e0 Support constructor injection for @Import classes
Allow `ImportBeanDefinitionRegistrar`, `ImportSelector`,
`DeferredImportSelector.Group` and `TypeFilter` to use constructor
parameters as an alternative to `*Aware` callbacks.

In order to remain backwards compatible, injection only occurs
when there is a single constructor with one or more parameters.

The following parameter types are supported:

* `Environment`
* `BeanFactory`
* `ClassLoader`
* `ResourceLoader`

In order to keep the algorithm simple, subclass parameter types are
not supported. For example, you cannot use `ConfigurableEnvironment`
instead of `Environment`.

Closes gh-23637
2019-09-13 15:20:57 -07:00
Sam Brannen d689ef8891 Support disabling cron jobs registered via SchedulingConfigurer
Prior to this commit, support was provided for disabling cron jobs
configured with an explicit "-" cron expression. However, the "-"
expression was only supported when supplied via the @Scheduled
annotation.

This commit adds support for disabling cron jobs configured with the
"-" cron expression when a cron job is registered via the
addCronTask(Runnable, String) method in the ScheduledTaskRegistrar
supplied to a SchedulingConfigurer.

Closes gh-23568
2019-09-12 16:08:26 +02:00
Andy Wilkinson 508b6798ff Move jmx.log beneath build/ to avoid UP-TO-DATE pollution
Previously, some tests in spring-context wrote a file named jmx.log
into spring-context/. This led to the file being included in the
sources of the Checkstyle NoHTTP Gradle task, breaking that task's
UP-TO-DATE checks and causing it to execute unnecessarily.

This commit updates the tests to write the jmx.log file beneath
spring-context/build/ so that it is not included in the sources of the
Checkstyle NoHTTP task.

Closes gh-23623
2019-09-12 11:39:43 +02:00
Sam Brannen 30cff46e7f Prevent improper use of testing framework APIs
Prior to this commit, a lot of work had been done to prevent improper
use of testing Framework APIs throughout the codebase; however, there
were still some loopholes.

This commit addresses these loopholes by introducing additional
Checkstyle rules (and modifying existing rules) to prevent improper use
of testing framework APIs in production code as well as in test code.

- Checkstyle rules for banned imports have been refactored into
  multiple rules specific to JUnit 3, JUnit 4, JUnit Jupiter, and
  TestNG.
- Accidental usage of org.junit.Assume has been switched to
  org.junit.jupiter.api.Assumptions.
- All test classes now reside under org.springframework packages.
- All test classes (including abstract test classes) now conform to the
  `*Tests` naming convention.
  - As an added bonus, tests in the renamed
    ScenariosForSpringSecurityExpressionTests are now included in the
    build.
- Dead JUnit 4 parameterized code has been removed from
  DefaultServerWebExchangeCheckNotModifiedTests.

Closes gh-22962
2019-09-12 11:20:56 +02:00
Sam Brannen 591995ecc8 Polish and revive disabled tests
This commit revives some previously disabled tests and converts
some usage of @Disabled to @EnabledForTestGroups(...).
2019-09-06 15:57:27 +02:00
Phillip Webb deba2ed1b3 Add blank line between java and javax imports
See gh-23539
2019-09-04 22:05:46 -07:00
Sebastien Deleuze ca02cc1194 Migrate to AssertJ in Kotlin tests
Closes gh-23475
2019-09-02 15:59:26 +02:00
Sam Brannen c004ef888c Configure index in @ParameterizedTest display names
This commit prepends "[{index}] " to all custom display names
configured via @ParameterizedTest.

This provides better diagnostics between the "technical names" reported
on the CI server vs. the "display names" reported within a developer's
IDE.

See gh-23451
2019-08-28 17:06:23 +02:00
Sam Brannen ad6231ad29 Add missing @Override annotations 2019-08-23 13:50:58 +02:00
Sam Brannen a07ce8eb82 Polishing 2019-08-23 13:50:57 +02:00
Sam Brannen 3e2b977d5d Re-enable shadowed, overridden @Test and lifecycle methods
Due to a bug (or "unintentional feature") in JUnit 4, overridden test
and lifecycle methods not annotated with @Test, @Before, @After, etc.
are still executed as test methods and lifecycle methods; however,
JUnit Jupiter does not support that. Thus, prior to this commit, some
overridden test and lifecycle methods were no longer executed after the
migration from JUnit 4 to JUnit Jupiter.

This commit addresses this issue for such known use cases, but there
are likely other such use cases within Spring's test suite.

See gh-23451
2019-08-23 13:50:57 +02:00
Sam Brannen 742cb90d34 Delete obsolete abstract test classes 2019-08-23 13:49:35 +02:00
Sam Brannen 288461a541 Introduce @EnabledForTestGroups in Spring's test suite
Closes gh-23476
2019-08-17 14:47:24 +02:00
Sam Brannen 979508a7f3 Remove JUnit 4 dependency from all modules except spring-test
This commit removes the JUnit 4 dependency from all modules except
spring-test which provides explicit JUnit 4 support.

This commit also includes the following.

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

See gh-23451
2019-08-17 11:37:21 +02:00
Sam Brannen 3f3e41923f Migrate rest of test suite from JUnit 4 to JUnit Jupiter
This commit migrates the rest of Spring's test suite to JUnit Jupiter,
except spring-test which will be migrated in a separate commit.

See gh-23451
2019-08-17 11:36:58 +02:00
Sebastien Deleuze 23cd261b6b Deprecate AnnotationConfigApplicationContext { } Kotlin extension
Closes gh-23420
2019-08-06 11:28:32 +02:00
Phillip Webb 89d150d398 Resolve factoryBeanClass if necessary
Update `AbstractAutowireCapableBeanFactory.getTypeForFactoryBean` to
use fallback to `determineTargetType` if the factory bean definition
does not have a resolved class.

This is required for the case where a `@Configuration` class is picked
up via component scanning and has a bean type that has not yet been
resolved.

Closes gh-23338
2019-08-01 07:48:12 +01:00
Phillip Webb 71a5308c78 Support FactoryBean bean definition attributes
Update `getTypeForFactoryBean` detection so that a bean definition
attribute can be used to supply the result. This commit allows projects
such as Spring Data to provide the result that would be supplied by
`getObjectType` early so that we don't need to initialize the
`FactoryBean` unnecessarily.

Closes gh-23338
2019-07-31 12:22:03 +02:00
Phillip Webb a0e462581f Consider generics for predicting FactoryBean types
Update the `FactoryBean` type prediction logic (primarily in the
`DefaultListableBeanFactory`) so that generic type information is
considered when calling `getBeanNamesForType` on a non-frozen
configuration.

Calling `getBeanNamesForType` with `allowEagerInit` disabled will now
detect `FactoryBean` variants as long as generic type information is
available in either the class or the factory method return type.

Closes gh-23338
2019-07-31 12:22:03 +02:00
Juergen Hoeller daf29118a6 Resolve ApplicationListener against BeanDefinition.getResolvableType()
This covers ApplicationListener generics in factory method return types in particular but also allows for programmatic setTargetType hints.

Closes gh-23178
2019-07-20 15:05:38 +02:00
Juergen Hoeller 8aa0b07768 Consistent early eviction tests in regular and transactional scenarios
See gh-23192
2019-07-20 15:05:07 +02:00
Sam Brannen af18d71bc2 Clean up warnings in Gradle build 2019-07-10 16:59:08 +02:00
Juergen Hoeller a5cb8799fa Merge branch '5.1.x' 2019-07-05 18:22:02 +02:00
Juergen Hoeller 7a7d4109ac Polishing 2019-07-05 17:47:36 +02:00
Juergen Hoeller aeef95938e SpringValidatorAdapter's ObjectError subclasses are serializable
Closes gh-23181
2019-07-05 17:07:01 +02:00
Juergen Hoeller 7bfe01a028 Support for reactive result values from event listener methods
Closes gh-21831
2019-07-05 16:19:23 +02:00
Thomas Girard 87c15ba9ad Use the accepted profiles in BeanDefinitionDsl
Closes gh-22393
2019-06-29 17:25:45 +02:00
Johnny Lim ef704aa531 Polish FormattingConversionServiceTests
See gh-23162
2019-06-20 08:40:47 +02:00
Phillip Webb 5e505ce3a9 Add FormatterRegistry addPrinter/addParser methods
Update `FormatterRegistry` with `addPrinter` and `addParser` methods
that can be used to register Printer or Parser implementations in a
similar way to the existing `addFormatter` method.

Closes gh-23110
2019-06-11 14:47:42 -07:00
Sam Brannen 3794a57651 Improve AnnotationProcessorPerformanceTests with Awaitility 2019-05-30 12:07:30 +02:00
Sam Brannen 30944ed2e2 Attempt to make AbstractSchedulingTaskExecutorTests more robust 2019-05-27 13:02:30 +02:00
Sam Brannen 32277b74db Attempt to make AbstractSchedulingTaskExecutorTests more robust 2019-05-27 12:01:34 +02:00
Juergen Hoeller 8f972a5a60 Merge branch '5.1.x' 2019-05-24 23:46:25 +02:00
Juergen Hoeller 80c6f2bcf9 Polishing 2019-05-24 23:31:32 +02:00
Juergen Hoeller 3c3d828e6c Actually test LiteConfiguration arrangement
Closes gh-23013
2019-05-24 23:18:10 +02:00
Phillip Webb 9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb 95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00
Rossen Stoyanchev 5f7541344a Fix test failing after #99302f 2019-05-23 10:41:08 -04:00
Rossen Stoyanchev 3a5fb1fdf3 Fix test failing after #99302f 2019-05-23 10:38:08 -04:00
Phillip Webb 02850f357f Migrate exception checking tests to use AssertJ
Migrate tests that use `@Test(expectedException=...)` or
`try...fail...catch` to use AssertJ's `assertThatException`
instead.
2019-05-20 10:47:53 -07:00
Sam Brannen 73dbd06361 Enforces static imports for JUnit 4 assertions and assumptions
This commit configures Checkstyle to enforces static imports for JUnit 4
assertions and assumptions.

See gh-22932
2019-05-12 15:13:07 +02:00
Sam Brannen deecab6311 Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-12 14:46:55 +02:00
Sam Brannen 724c805211 Discontinue use of JUnit 3 APIs
This commit also ensures that the JSR-330 TCK is executed with the
normal build by adhering to naming conventions for test classes.

See gh-22894
2019-05-12 14:46:55 +02:00
Phillip Webb 798b51f4a3 Migrate to BDD Mockito
Migrate all tests to consistently use BDD Mockito. Also add
checksyle rule to enforce going forwards.
2019-05-08 13:46:13 -07:00
Phillip Webb 816bbee8de Remove '.*' imports from tests
Organize test imports to expand all '.*' static imports into
fully qualified imports.

This update will allow us to use additional checkstyle rules in
the future, and will also help if we migrate fully to AssertJ.
2019-05-08 09:55:09 -07:00
Phil Webb d7320de871 Migrate away from ExpectedException (#22922)
* Add limited checkstyles to test code

Add a limited set of checkstyle rules to the test codebase to improve
code consistency.

* Fix checksyle violations in test code

* Organize imports to fix checkstyle for test code

* Migrate to assertThatExceptionOfType

Migrate aware from ExpectedException rules to AssertJ exception
assertions. Also include a checkstyle rules to ensure that the
the ExpectedException is not accidentally used in the future.

See gh-22894
2019-05-08 16:25:52 +02:00
Phillip Webb 8a293f51a4 Don't expose RetentionPolicy.CLASS annotations
Update ASM based metadata readers so that only RetentionPolicy.RUNTIME
annotations are exposed. This aligned behavior with the reflection based
implementation.

Closes gh-22886
2019-05-07 23:12:42 +02:00
Juergen Hoeller fff3813d75 Properly detect importing class metadata for lite configuration class
Closes gh-22920
2019-05-07 21:23:47 +02:00
Sam Brannen c79fdfb668 Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-05 18:09:11 +02:00
Sebastien Deleuze fc8d5c068c Support final @Configuration(proxyBeanMethods = false) classes
Closes gh-22869
2019-05-03 13:45:14 +02:00