Commit Graph

332 Commits

Author SHA1 Message Date
Andy Wilkinson
6548ca4c11 Implement equals and hashCode in TestTypeExcludeFilter
Fixes gh-23978
2020-11-03 14:50:00 +00:00
Andy Wilkinson
667ccdae84 Simplify temp directory creation and improve diagnostics
Closes gh-23622
2020-10-13 11:18:06 +01:00
Andy Wilkinson
bf9d23e55a Consider SpringBootTest's web environment in context cache key
Previously, the web environment configured on `@SpringBootTest` was not
part of the context cache key. As a result, two test classes that has
identical configuration other than one using a MOCK web environment and
the other using a DEFINED_PORT web environment would share a context
when they should not do so. Classes that use MOCK and RANDOM_PORT were
not affected as the use of RANDOM_PORT results in a property for the
port being added to the environment.

This commit adds a new ContextCustomizer, SpringBootTestWebEnvironment,
that is used to capture the `webEnvironment` from `@SpringBootTest`
and use it in its hashCode and equals implementations. This fixes the
problem as all context customizers are evaluated when determing the
equality of two context cache keys.

Fixes gh-23085
2020-09-24 14:43:51 +01:00
Phillip Webb
fdd6a89a61 Polish 2020-08-06 10:14:01 -07:00
Andy Wilkinson
41954533b2 Fix Mock|SpyBean context caching
The fix for gh-20916 updated DefinitionsParser so that the
ResolvableType for each MockBean or SpyBean field included the
implementation class from which the field was found. Where the field
was declared with a variable generic signature that was made constant
by its implementation class, this allowed the correct concrete type to
be determined. It also had the unintended side-effect of preventing two
test classes with identical `@MockBean` and `@SpyBean` configuration
from sharing a context as the resolvable types for their mock and spy
bean fields would now be different.

This commit updates DefinitionsParser to only include the
implementation class in the ResolvableType if the field's generic type
is variable. For cases where it is not variable, this restores the
behaviour prior to the fix for gh-20916.

Fixes gh-22566
2020-07-27 13:04:02 +01:00
Phillip Webb
b5e70157dc Update copyright year of changed files 2020-07-22 17:01:36 -07:00
Madhura Bhave
615cf63a82 Make MockBean resolve right type for abstract test class
Fixes gh-20916
2020-06-17 17:25:03 -07:00
Phillip Webb
0a05b4c9fd Update copyright year of changed files 2020-06-05 15:36:09 -07:00
Stephane Nicoll
60ff8bafb5 Polish "Align TestRestTemplate Javadoc with documentation"
See gh-21318
2020-05-08 14:49:50 +02:00
Andrii Hrytsiuk
f11c030b71 Align TestRestTemplate Javadoc with documentation
See gh-21318
2020-05-08 14:48:21 +02:00
Phillip Webb
9bb53a4c37 Polish 2020-04-23 14:31:49 -07:00
Madhura Bhave
4dc9bbe127 @SpringBootTest classes with different args shouldn't share a context
Fixes gh-20866
2020-04-23 10:18:14 -07:00
Madhura Bhave
b9c2b7b257 Prevent early initialization in MockitoPostProcessor
Fixes gh-20665
2020-04-22 14:35:50 -07:00
Andy Wilkinson
f708aace65 Merge branch '2.1.x' into 2.2.x
Fixes gh-19821
2020-01-20 15:18:00 +00:00
Andy Wilkinson
c85f19b75b Revert "Add profiles directly to the application environment for tests"
This reverts commit 487b9cbf96.

Fixes gh-19788
2020-01-20 15:01:09 +00:00
Phillip Webb
3cfbfebbb1 Merge branch '2.1.x' into 2.2.x 2020-01-13 16:45:40 -08:00
Phillip Webb
9bd49562fe Update copyright year of changed files 2020-01-13 14:09:11 -08:00
Madhura Bhave
ac10ebba33 Fix checkstyle 2020-01-07 13:49:02 -08:00
Madhura Bhave
67fab60fbd Merge branch '2.1.x' into 2.2.x
Closes gh-19560
2020-01-07 13:33:32 -08:00
Scott Frederick
487b9cbf96 Add profiles directly to the application environment for tests
Prior to this commit, active profiles were being added to the Spring Boot
application environment by setting the `spring.profiles.active` property.
This could result in profiles getting parsed differently than other uses of `@ActiveProfiles`.
Setting the profiles directly in the `Environment` prevents this parsing.

See gh-19556
2020-01-07 13:23:09 -08:00
Andy Wilkinson
9b0569cf81 Merge branch '2.1.x' into 2.2.x
Closes gh-19309
2019-12-05 16:15:15 +00:00
Andy Wilkinson
bc53fe0344 Recommend mockito-inline for mocking and spying of CGLib proxies
This reverts commit 52050c173c.

See gh-17817
Closes gh-19020
2019-12-05 16:13:02 +00:00
Stephane Nicoll
fd94608f73 Polish "Restore proxying of @Bean methods in @TestConfiguration"
See gh-18675
2019-10-22 09:13:00 +02:00
Dmytro Nosan
7faa606920 Restore proxying of @Bean methods in @TestConfiguration
See gh-18675
2019-10-22 09:10:05 +02:00
Stephane Nicoll
0bc5803e34 Merge branch '2.1.x'
Closes gh-18603
2019-10-15 14:38:59 +02:00
Stephane Nicoll
e4ba6049ff Clarify scope of "@SpringBootTest#classes"
See gh-18229
2019-10-15 14:36:28 +02:00
Johnny Lim
887c3b71f3 Fix matchesNestedConfigurationClassWithoutTestMethodsIfItHasTestable()
See gh-18559
2019-10-12 16:51:53 +01:00
Andy Wilkinson
96f85a40de Support customization of WebTestClient.Builder when using @SpringBootTest
Closes gh-15132
2019-10-02 17:51:00 +01:00
Andy Wilkinson
46c30d6bb0 Merge branch '2.1.x'
Closes gh-18476
2019-10-02 10:48:57 +01:00
Andy Wilkinson
3d4157ad6d Correct SCM URLs in published poms
Previously, Maven's default behaviour was relied up which resulted
in the artifact ID being appended to each URL as it was inherited.
This behaviour can only be disabled in Maven 3.6 and later, a version
that we cannot use due to an incompatibility with the Flatten Plugin.

This commit works around Maven's default behaviour by defining
properties for the SCM URL, connection, and developer connection and
then explicitly defining the settings in each pom using these
properties. The explicit definition of the properties in each pom
prevents them being inherited from the parent, thereby disabling the
unwanted appending of the artifact ID to the URL.

Fixes gh-18328
2019-10-02 10:48:30 +01:00
Phillip Webb
b65ba60980 Polish 'Simplify some code'
See gh-18438
2019-10-01 22:08:20 -07:00
kenneth
e6b45de41e Simplify some code
See gh-18438
2019-10-01 22:08:02 -07:00
Stephane Nicoll
c605419f19 Merge branch '2.1.x'
Closes gh-18379
2019-09-27 16:34:59 +02:00
Roland Weisleder
92ae7b21a1 Fix typo in ApplicationContextAssert
See gh-18372
2019-09-27 16:32:32 +02:00
Phillip Webb
ad32603635 Restore compatibility with MockRestServiceServer
Closes gh-17885
2019-09-16 10:17:41 +02:00
Stephane Nicoll
3d5530d15d Merge branch '2.1.x'
Closes gh-18234
2019-09-16 10:03:19 +02:00
Stephane Nicoll
9065c4997d Fix rebase from master 2019-09-16 09:52:55 +02:00
Stephane Nicoll
e05f42f0f3 Polish Add Testable to CLASS_ANNOTATIONS in TestTypeExcludeFilter"
See gh-18214
2019-09-16 09:44:01 +02:00
Leonard Brünings
b9c8d7dd60 Add Testable to CLASS_ANNOTATIONS in TestTypeExcludeFilter
See gh-18214
2019-09-16 09:42:55 +02:00
dreis2211
b4350a9d96 Remove unnecessary blank lines
See gh-18089
2019-09-03 08:48:10 +02:00
dreis2211
3e35a6616c Fix duplicated words
See gh-18004
2019-09-01 09:09:38 +02:00
Andy Wilkinson
ba6fe60134 Merge branch '2.1.x'
Closes gh-17948
2019-08-23 19:15:02 +01:00
Andy Wilkinson
52050c173c Fix spying on scoped beans with @SpyBean
Previously, when spying on a scoped bean the creation of the spy
would be performed using the scoped proxy. This would result in
the spy being unable to spy on any of the target bean's methods as
the scoped proxy's implementations of those methods would be final.

This commit updates MockitoPostProcessor so that the creation of the
spy and injection of the @SpyBean-annotated field is performed using
the scoped target. The scoped target has not be proxied so this
allows Mockito to spy on all of its methods.

Closes gh-17817
2019-08-23 19:03:08 +01:00
Andy Wilkinson
ab87b2a39b Polish 2019-08-19 16:05:43 +01:00
dreis2211
d4affd7f85 Use hasSize() assertion in favor of length checks
See gh-17874
2019-08-17 06:39:41 +02:00
Phillip Webb
34c31ce099 Remove BeanTypeRegistry
Remove `BeanTypeRegistry` and rely entirely on standard calls Spring
Framework APIs.

Closes gh-17594
2019-08-01 10:15:15 +01:00
Phillip Webb
da4f436140 Change SearchStrategy EXHAUSTIVE to TYPE_HIERARCHY
Fixup references following upstream Spring Framework change.
2019-07-31 15:11:43 +01:00
dreis2211
8d2f2b75bd Upgrade to AssertJ 3.13.1
See gh-17690
2019-07-30 09:48:33 +02:00
Phillip Webb
8bc780762a Merge branch '2.1.x' 2019-07-24 11:42:48 +01:00
Phillip Webb
fb1dd8fe93 Merge branch '2.0.x' into 2.1.x 2019-07-24 11:41:32 +01:00