Browse Source

Merge branch '2.6.x' into 2.7.x

Closes gh-30383
pull/30406/head
Andy Wilkinson 4 years ago
parent
commit
bcb71dfd1b
  1. 12
      spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockBean.java
  2. 8
      spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyBean.java

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

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

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,9 +37,9 @@ import org.springframework.test.context.junit4.SpringRunner;
* {@link RunWith @RunWith} the {@link SpringRunner}. * {@link RunWith @RunWith} the {@link SpringRunner}.
* <p> * <p>
* Spies can be applied by type or by {@link #name() bean name}. All beans in the context * Spies can be applied by type or by {@link #name() bean name}. All beans in the context
* of the same type will be wrapped with the spy. If no existing bean is defined a new one * of a matching type (including subclasses) will be wrapped with the spy. If no existing
* will be added. Dependencies that are known to the application context but are not beans * bean is defined a new one will be added. Dependencies that are known to the application
* (such as those * context but are not beans (such as those
* {@link org.springframework.beans.factory.config.ConfigurableListableBeanFactory#registerResolvableDependency(Class, Object) * {@link org.springframework.beans.factory.config.ConfigurableListableBeanFactory#registerResolvableDependency(Class, Object)
* registered directly}) will not be found and a spied bean will be added to the context * registered directly}) will not be found and a spied bean will be added to the context
* alongside the existing dependency. * alongside the existing dependency.

Loading…
Cancel
Save