Commit Graph

216 Commits

Author SHA1 Message Date
Sam Brannen
7b3f53de50 Polish SpelParserTests 2020-12-04 18:49:05 +01:00
limo520
ef05eb3729 Fix assertions in SpelParserTests.generalExpressions
Closes gh-26211

Co-authored-by: fengyuanwei <fengyuanwei@wondersgroup.com>
2020-12-04 13:59:16 +01:00
Juergen Hoeller
4e8d6bea4d Fix test code formatting 2020-11-04 16:52:11 +01:00
Juergen Hoeller
079ca80854 SpEL supports record-style accessor methods as well
Closes gh-26029
2020-11-04 16:51:54 +01:00
Sam Brannen
705cf09ad7 Merge branch '5.2.x' 2020-10-26 15:05:35 +01:00
Sam Brannen
449377908f Fix JUnit 4 to AssertJ migration bugs
The migration from JUnit 4 assertions to AssertJ assertions resulted in
several unnecessary casts from int to long that actually cause
assertions to pass when they should otherwise fail.

This commit fixes all such bugs for the pattern `.isNotEqualTo((long)`.
2020-10-26 14:53:09 +01: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
Juergen Hoeller
3fd89c3ac1 Fix merge result
See gh-25706
2020-09-05 13:12:19 +02:00
Juergen Hoeller
9d7849c539 Merge branch '5.2.x'
# Conflicts:
#	spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
2020-09-05 13:02:01 +02:00
Juergen Hoeller
c368ce8223 Fix SpEL generated code for default method invocation
Closes gh-25706
2020-09-05 12:59:12 +02:00
Andy Clement
a404bf5a94 Fix SpEL generated code for default method invocation
Closes gh-25706
2020-09-04 22:23:13 -07:00
Sam Brannen
b0570cd3a6 Polish contribution
See gh-25367
2020-07-16 15:56:17 +02:00
Martin Knopf
35c0ae7b0c Allow auto grow for entries w/o default constructor in SpEL
Prior to this commit, The "auto grow" feature in SpEL expressions only
worked for element types with a default constructor. For example, auto
grow did not work for a list of BigDecimal elements.

This commit inserts a null value in the list when no default
constructor can be found for the element type.

Closes gh-25367
2020-07-16 15:31:33 +02:00
Sam Brannen
12e05280ad Upgrade to AssertJ 3.16 2020-05-06 15:22:23 +02:00
陈其苗
13970ae528 Use autoboxing instead of explicit wrapping in tests
Closes gh-24801
2020-04-01 14:34:20 +02:00
Sam Brannen
c3bc28762e Delete unused import in ExpressionLanguageScenarioTests
See gh-24586
2020-02-26 14:09:01 +01:00
ZhangT
c5fb7b9fb7 Simplify some redundant code
Closes gh-24586

Co-authored-by: Sam Brannen <sbrannen@pivotal.io>
2020-02-26 12:29:09 +01:00
Sam Brannen
a9d9b76d09 Support SpEL compilation of interface methods again
Spring Framework 5.1.8 introduced a regression for the compilation of
SpEL expressions referencing a method declared in an interface. An
attempt to compile such an expression resulted in a
SpelEvaluationException caused by an IncompatibleClassChangeError.

This commit fixes this regression by adding explicit support in
ReflectivePropertyAccessor.OptimalPropertyAccessor.generateCode() for
methods declared in interfaces.

Closes gh-24357
2020-02-12 15:33:01 +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
5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sébastien Deleuze
7646895fd4 Support Kotlin synthetic classes in MethodParameter and SpEL
Closes gh-23812
2019-11-13 14:22:53 +01:00
Sam Brannen
734ceed301 Polish contribution
See gh-23658
2019-09-19 22:02:19 +02:00
i321222
fde7b1e545 Avoid ArrayIndexOutOfBoundsException in SpEL's Indexer
When index == arrayLength, the array index is also out of bounds.

For this scenario, a SpelEvaluationException should be thrown instead
of ArrayIndexOutOfBoundsException.

Closes gh-23658
2019-09-19 22:01:10 +02:00
Sam Brannen
2b460854ce Polishing 2019-09-12 13:16:48 +02:00
Sam Brannen
e124cbb310 Fix Checkstyle violation 2019-09-12 13:15:58 +02:00
OLPMO
40fcf876ce Optimize test code with lambdas where feasible
This commit optimizes test code with lambda expressions
and method references where feasible.

Closes gh-23626
2019-09-12 13:09:31 +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
ad6231ad29 Add missing @Override annotations 2019-08-23 13:50:58 +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
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
Juergen Hoeller
a5cb8799fa Merge branch '5.1.x' 2019-07-05 18:22:02 +02:00
Juergen Hoeller
a1eae42fd0 Expose implementation method for annotation introspection purposes
Closes gh-23210
2019-07-05 17:07:44 +02:00
Sam Brannen
bdf3960283 Suppress warnings in Gradle build 2019-05-27 12:15:50 +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
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
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
Sam Brannen
47c39304af 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:27:38 +02:00
Juergen Hoeller
ce9162065c Merge branch '5.1.x' 2019-05-02 17:52:12 +02:00
Juergen Hoeller
18f6739be4 Allow null operands in compiled SpEL numeric operator expressions
Closes gh-22358
2019-05-02 17:27:49 +02:00
Andy Clement
0f553661a6 Allow null operands in compiled SpEL numeric operator expressions
Prior to this when SpEL compiled an expression using the numeric
operators <, >, <= or >= then it would not create code that handled
nulls. Nulls can occur if a boxed numeric operand is used prior
to compilation, then it is nulled out. SpEL now creates null
handling bytecode.

Closes gh-22358
2019-05-01 15:36:19 -07:00
Spring Operator
540759ec41 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 6515 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
2019-03-23 15:19:34 +01:00
Spring Operator
dc6f63f610 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 6625 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
2019-03-21 23:49:28 -05:00
Juergen Hoeller
7a77e83e10 SpelNodeImpl manages start/end position in separate integer values
Fixes gh-22157
2019-01-28 22:50:56 +01:00
Rossen Stoyanchev
bdac937a43 Replace more references to issue tracker
Fixes #22254
2019-01-17 17:08:39 -05:00
Stephane Nicoll
9cbd585c30 Polish "Join identical catch branches"
Closes gh-2052
2018-12-25 09:46:35 +01:00
igor-suhorukov
a218bf40cd Join identical catch branches
See gh-2052
2018-12-25 09:46:11 +01:00
Rossen Stoyanchev
38ae282c3b Update log category precision for all tests
Replace the full category capped at 36 chars with the class name only
and 1 char per package, e.g. org.apache.commons.Foo -> o.a.c.Foo
2018-12-12 11:40:33 -05:00
Hanope
bfb49c7249 Fix typos
See gh-2019
2018-11-19 08:41:21 +01:00