Class TestContextSpringFactoriesUtils
java.lang.Object
org.springframework.test.context.util.TestContextSpringFactoriesUtils
Collection of utilities for working with
SpringFactoriesLoader
within
the Spring TestContext Framework.
Primarily intended for use within the TestContext framework.
- Since:
- 6.0
- Author:
- Sam Brannen
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
loadFactoryImplementations
(Class<T> factoryType) Load factory implementations of the given type via theSpringFactoriesLoader
mechanism.
-
Method Details
-
loadFactoryImplementations
Load factory implementations of the given type via theSpringFactoriesLoader
mechanism.This method utilizes a custom
SpringFactoriesLoader.FailureHandler
and DEBUG/TRACE logging that are specific to the needs of the Spring TestContext Framework.Specifically, this method looks up and instantiates all
factoryType
entries configured in allMETA-INF/spring.factories
files on the classpath.If a particular factory implementation cannot be loaded due to a
LinkageError
orClassNotFoundException
, aDEBUG
message will be logged, but the associated exception will not be rethrown. ARuntimeException
or any otherError
will be rethrown. Any other exception will be thrown wrapped in anIllegalStateException
.- Type Parameters:
T
- the factory type- Parameters:
factoryType
- the interface or abstract class representing the factory- Returns:
- an unmodifiable list of factory implementations
- See Also:
-