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 theSpringFactoriesLoadermechanism.
-
Method Details
-
loadFactoryImplementations
Load factory implementations of the given type via theSpringFactoriesLoadermechanism.This method utilizes a custom
SpringFactoriesLoader.FailureHandlerand DEBUG/TRACE logging that are specific to the needs of the Spring TestContext Framework.Specifically, this method looks up and instantiates all
factoryTypeentries configured in allMETA-INF/spring.factoriesfiles on the classpath.If a particular factory implementation cannot be loaded due to a
LinkageErrororClassNotFoundException, aDEBUGmessage will be logged, but the associated exception will not be rethrown. ARuntimeExceptionor any otherErrorwill 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:
-