Skip to content

Commit bcb71df

Browse files
committed
Merge branch '2.6.x' into 2.7.x
Closes gh-30383
2 parents 1fec2f0 + 1244c42 commit bcb71df

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockBean.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,12 @@
3636
* used as a class level annotation or on fields in either {@code @Configuration} classes,
3737
* or test classes that are {@link RunWith @RunWith} the {@link SpringRunner}.
3838
* <p>
39-
* Mocks can be registered by type or by {@link #name() bean name}. Any existing single
40-
* bean of the same type defined in the context will be replaced by the mock. If no
41-
* existing bean is defined a new one will be added. Dependencies that are known to the
42-
* application context but are not beans (such as those
39+
* Mocks can be registered by type or by {@link #name() bean name}. When registered by
40+
* type, any existing single bean of a matching type (including subclasses) in the context
41+
* will be replaced by the mock. When registered by name, an existing bean can be
42+
* specifically targeted for replacement by a mock. In either case, if no existing bean is
43+
* defined a new one will be added. Dependencies that are known to the application context
44+
* but are not beans (such as those
4345
* {@link org.springframework.beans.factory.config.ConfigurableListableBeanFactory#registerResolvableDependency(Class, Object)
4446
* registered directly}) will not be found and a mocked bean will be added to the context
4547
* alongside the existing dependency.

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyBean.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,9 +37,9 @@
3737
* {@link RunWith @RunWith} the {@link SpringRunner}.
3838
* <p>
3939
* Spies can be applied by type or by {@link #name() bean name}. All beans in the context
40-
* of the same type will be wrapped with the spy. If no existing bean is defined a new one
41-
* will be added. Dependencies that are known to the application context but are not beans
42-
* (such as those
40+
* of a matching type (including subclasses) will be wrapped with the spy. If no existing
41+
* bean is defined a new one will be added. Dependencies that are known to the application
42+
* context but are not beans (such as those
4343
* {@link org.springframework.beans.factory.config.ConfigurableListableBeanFactory#registerResolvableDependency(Class, Object)
4444
* registered directly}) will not be found and a spied bean will be added to the context
4545
* alongside the existing dependency.

0 commit comments

Comments
 (0)