Commit Graph

518 Commits

Author SHA1 Message Date
Andy Wilkinson
0c8ae65bd4 Switch of the banner when SpringBootTest runs an app with a parent
Closes gh-33079
2022-11-18 15:43:41 +00:00
Phillip Webb
d7ac20cd6c Update copyright year of changed files 2022-10-25 15:47:30 -07:00
Phillip Webb
e917bd0ed0 Only build OutputCapture strings when necessary
Update `OutputCapture` so that expensive build operations are only
performed when necessary. This update is especially important for Kotlin
users calling `"Expected String" in output` since this results in a call
to Kotlin's `CharSequence.contains` which calls the `length()` and
`charAt()` methods many times.

Closes gh-32033
2022-10-03 16:55:44 -07:00
dreis2211
cee353fba6 Avoid using JUnit 4 assertions
See gh-32504
2022-09-27 08:11:47 +02:00
Phillip Webb
f8412847dc Update copyright year for "Fix typos in code and documentation"
See gh-31734
2022-07-26 12:08:30 +01:00
Marc Wrobel
dbfc6bded4 Fix typos in code and documentation
See gh-31734
2022-07-26 12:08:07 +01:00
Andy Wilkinson
3d203d0215 Polish 2022-05-26 17:30:39 +01:00
Andy Wilkinson
ee45fd2fc8 Remove redundant throws declarations from internal APIs
Closes gh-31176
2022-05-26 15:47:35 +01:00
Andy Wilkinson
cbf42dea14 Update deprecation messages to change removal version from 2.8 to 3.0
Closes gh-30903
2022-05-26 13:59:03 +01:00
Andy Wilkinson
d4348279a7 Merge branch '2.5.x' into 2.6.x
Closes gh-30666
2022-04-14 14:51:09 +01:00
Andy Wilkinson
8f1b8622ba Ensure that webEnvironment=NONE creates non-web context
Previously, if spring.main.web-application-type was configured in
application.properties to servlet or reactive, setting
webEnvironment=NONE on @SpringBootTest would not work correctly and
a servlet or reactive web application context would be created
based on the value of spring.main.web-application-type.

This commit updates the test context bootstapper to set
spring.main.web-application-type to none when webEnvironment has been
set to none. This is done in the merged context configuration's
property source properties which are applied to the environment in a
high-precedence test property source that will override configuration
in application.properties.

Closes gh-29695
2022-04-14 14:44:30 +01:00
Andy Wilkinson
887fa4a13f Merge branch '2.5.x' into 2.6.x
Closes gh-30664
2022-04-14 12:40:29 +01:00
Andy Wilkinson
c8de843d85 Honor final web application type when creating context in tests
Previously, SpringBootContextLoader would configure its
SpringApplication with an ApplicationContextFactory that ignores
the WebApplicationType with which its called and instead returns a
hard-coded type of context based on the type of the
MergedContextConfiguration. This hard-coding would result in the
wrong type of context being used if a subsequent change was made to
the application's WebApplicationType, for example due to binding of
the spring.main.web-application-type configuration property.

This commit updates SpringBootContextLoader to configure
SpringApplication with an ApplicationContextFactory that takes the
WebApplicationType with which it is called into consideration.

Fixes gh-29170
2022-04-14 12:26:07 +01:00
Andy Wilkinson
1244c429a6 Merge branch '2.5.x' into 2.6.x
Closes gh-30382
2022-03-23 11:17:36 +00:00
Andy Wilkinson
e927cd71dd Clarify type matching performed by MockBean and SpyBean
Closes gh-28656
2022-03-23 11:17:07 +00:00
Andy Wilkinson
95d67a985b Merge branch 'gh-29639' into 2.6.x
Closes gh-29909
2022-02-19 11:36:09 +00:00
Andy Wilkinson
5baa71f1b3 Allow beans with circular dependencies to be spied
Closes gh-29639
2022-02-19 11:35:58 +00:00
Andy Wilkinson
9a3f053034 Allow beans with circular dependencies to be spied
Closes gh-29639
2022-02-19 11:35:28 +00:00
Stephane Nicoll
136b5959c3 Merge branch '2.5.x' into 2.6.x
Closes gh-29612
2022-02-01 10:59:08 +01:00
Stephane Nicoll
7f17f819a6 Polish "Enforce use of BDDMockito"
See gh-29178
2022-02-01 10:03:18 +01:00
Yanming Zhou
b49418aaaf Enforce use of BDDMockito
1. Replace Mockito.verify*() with BDDMockito.then()
2. Replace Mockito.doReturn() with BDDMockito.willReturn()
3. Adjust checkstyle rule

See gh-29178
2022-02-01 09:37:15 +01:00
Phillip Webb
14fe9347b5 Merge branch '2.5.x' into 2.6.x 2022-01-14 13:56:47 -08:00
Phillip Webb
3f7bf7d34f Modify SpringApplication Environment rather than setting it
Update `SpringBootContextLoader` so that when possible the
`SpringApplication` remains in control of creating the `Environment`
instance.

Prior to this commit, we would always create the `Environment` in the
`SpringBootContextLoader` and then call `setEnvironment` on the
`SpringApplication`. This meant that the `ApplicationEnvironment`
classes were not used and that `isCustomEnvironment` was set to `true`
so no conversion was applied.

With the updated code, an `ApplicationListener` is used to mutate the
`Environment` instance and add the required test property sources.

Fixes gh-29169
2022-01-14 13:47:22 -08:00
Stephane Nicoll
8384019a41 Merge branch '2.5.x' into 2.6.x
Closes gh-29377
2022-01-13 08:45:48 +01:00
Stephane Nicoll
5f03ace40f Update copyright year of changed file
See gh-29112
2022-01-13 08:43:03 +01:00
izeye
74c522c745 Polish SpringBootContextLoaderTests
See gh-29112
2022-01-13 08:42:36 +01:00
Phillip Webb
91d2b1b988 Merge branch '2.5.x' into 2.6.x
Closes gh-29374
2022-01-12 15:32:00 -08:00
Phillip Webb
eb6b48fff0 Use side-effect free environment with tests rather than converting
Refine the logic introduced in 64270eca to use a side-effect free
Environment implementation rather than converting the Environment early.

Early conversion can cause condition evaluation issues if
`src/test/resources/application.properties` files are bound to the
`SpringApplication`. Specifically the `spring.main.web-application-type`
property can change the `Environment` type which must happen before
conditions are evaluated.

Fixes gh-29169
2022-01-12 14:21:52 -08:00
izeye
7fbb5749d1 Polish
See gh-29157
2021-12-27 12:01:50 +01:00
Phillip Webb
f3bcbca841 Update copyright year of changed files 2021-12-16 13:05:17 -08:00
Madhura Bhave
27eb992252 Fix property source ordering in SpringBootTest
Update `SpringBootContextLoader` so that the active profiles
property source has a unique name. Prior to this commit, the
default name 'test' was used which could cause ordering issues
if other `@PropertySource` values were added to it later.

Closes gh-28804
2021-11-24 10:29:35 -08:00
Phillip Webb
beb68671bb Update copyright year of changed files 2021-11-24 10:23:32 -08:00
Madhura Bhave
49e408828c Fix property source ordering in SpringBootTest
Update `SpringBootContextLoader` so that the active profiles
property source has a unique name. Prior to this commit, the
default name 'test' was used which could cause ordering issues
if other `@PropertySource` values were added to it later.

Fixes gh-28776
2021-11-24 10:17:02 -08:00
Madhura Bhave
6b79d2860f Merge branch '2.5.x' into main
Closes gh-28724
2021-11-17 16:41:23 -08:00
Madhura Bhave
64270eca51 Convert environment used by SpringBootTestContextLoader
This commit aligns `SpringBootTest`s to also use `ApplicationEnvironment`
instead of `StandardEnvironment`. This prevents the side-effect of active
profiles from `@ActiveProfiles` from being added to the environment when
doGetActiveProfiles is called. In this case, calling `addActiveProfiles()`
in the environment post processor would result in `@ActiveProfiles` being
added to the environment first, resulting in the wrong order.

The additional call to `setActiveProfiles()` is also not necessary when using
ApplicationEnvironment because that call was put in place to prevent the side-effect
which `ApplicationEnvironment` does not have.

Fixes gh-28530
2021-11-17 16:40:53 -08:00
Andy Wilkinson
2a342ef416 Merge branch '2.5.x'
Closes gh-28662
2021-11-12 23:40:35 +00:00
Andy Wilkinson
5e4a502b2d Merge branch '2.4.x' into 2.5.x
Closes gh-28661
2021-11-12 20:31:25 +00:00
Andy Wilkinson
2cec3971d7 Prohibit unwanted dependencies in all modules not just starters
Closes gh-28658
2021-11-12 20:04:35 +00:00
Phillip Webb
d8629fc63d Merge branch '2.5.x' 2021-11-08 13:14:52 -08:00
Phillip Webb
ddd38a7ac3 Merge branch '2.4.x' into 2.5.x 2021-11-08 13:14:35 -08:00
Phillip Webb
75bf430eb1 Polish ImportsContextCustomizerTests
Update the test classes to include an `@Import` annotation. Without this
the tests would not fail even if the filter is missing.
2021-11-08 13:13:04 -08:00
Phillip Webb
0a6991e744 Merge branch '2.5.x'
Closes gh-28566
2021-11-08 13:11:03 -08:00
Phillip Webb
6406ee5609 Merge branch '2.4.x' into 2.5.x
Closes gh-28565
2021-11-08 13:08:52 -08:00
Phillip Webb
8a14e1e2e9 Polish 'Ignore JUnit annotations when caching test contexts'
See gh-28563
2021-11-08 13:07:26 -08:00
Loïc Ledoyen
23876d8a32 Ignore JUnit annotations when caching test contexts
Update `ImportsContextCustomizer` to ignore JUnit annotations.

See gh-28563
2021-11-08 13:06:23 -08:00
Stephane Nicoll
c05223d9c8 Merge branch '2.5.x'
Closes gh-28545
2021-11-06 12:06:14 +01:00
Stephane Nicoll
4304eea319 Polish contribution
See gh-28531
2021-11-06 12:03:22 +01:00
dreis2211
7d594aa301 Avoid duplicate AOP proxy class definition with FilteredClassLoader
See gh-28531
2021-11-06 11:58:28 +01:00
Stephane Nicoll
bf88405121 Flag BeanDefinitionRegistryPostProcessor beans with role infrastructure
Closes gh-28540
2021-11-05 14:20:37 +01:00
Stephane Nicoll
fbe614a61b Fix bean type visibility
See gh-28437
2021-11-02 14:41:32 +01:00