Class MockSpringFactoriesLoader
java.lang.Object
org.springframework.core.io.support.SpringFactoriesLoader
org.springframework.core.test.io.support.MockSpringFactoriesLoader
Simple mock
SpringFactoriesLoader
implementation that can be used for testing
purposes.- Since:
- 6.0
- Author:
- Phillip Webb
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.core.io.support.SpringFactoriesLoader
SpringFactoriesLoader.ArgumentResolver, SpringFactoriesLoader.FailureHandler
-
Field Summary
Fields inherited from class org.springframework.core.io.support.SpringFactoriesLoader
FACTORIES_RESOURCE_LOCATION
-
Constructor Summary
ModifierConstructorDescriptionCreate a newMockSpringFactoriesLoader
instance with the default classloader.MockSpringFactoriesLoader
(ClassLoader classLoader) Create a newMockSpringFactoriesLoader
instance with the given classloader.protected
MockSpringFactoriesLoader
(ClassLoader classLoader, Map<String, List<String>> factories) -
Method Summary
Modifier and TypeMethodDescriptionfinal <T> void
Add factory implementations to this instance.void
Add factory implementations to this instance.<T> void
addInstance
(Class<T> factoryType, T... factoryInstances) Add factory instances to this instance.<T> void
addInstance
(String factoryType, T... factoryInstance) Add factory instances to this instance.protected <T> T
instantiateFactory
(String implementationName, Class<T> type, SpringFactoriesLoader.ArgumentResolver argumentResolver, SpringFactoriesLoader.FailureHandler failureHandler) Methods inherited from class org.springframework.core.io.support.SpringFactoriesLoader
forDefaultResourceLocation, forDefaultResourceLocation, forResourceLocation, forResourceLocation, load, load, load, load, loadFactories, loadFactoriesResource, loadFactoryNames
-
Constructor Details
-
MockSpringFactoriesLoader
public MockSpringFactoriesLoader()Create a newMockSpringFactoriesLoader
instance with the default classloader. -
MockSpringFactoriesLoader
Create a newMockSpringFactoriesLoader
instance with the given classloader.- Parameters:
classLoader
- the classloader to use
-
MockSpringFactoriesLoader
-
-
Method Details
-
instantiateFactory
protected <T> T instantiateFactory(String implementationName, Class<T> type, @Nullable SpringFactoriesLoader.ArgumentResolver argumentResolver, SpringFactoriesLoader.FailureHandler failureHandler) - Overrides:
instantiateFactory
in classSpringFactoriesLoader
-
add
@SafeVarargs public final <T> void add(Class<T> factoryType, Class<? extends T>... factoryImplementations) Add factory implementations to this instance.- Parameters:
factoryType
- the factory type classfactoryImplementations
- the implementation classes
-
add
Add factory implementations to this instance.- Parameters:
factoryType
- the factory type class namefactoryImplementations
- the implementation class names
-
addInstance
Add factory instances to this instance.- Parameters:
factoryType
- the factory type classfactoryInstances
- the implementation instances to add
-
addInstance
Add factory instances to this instance.- Parameters:
factoryType
- the factory type class namefactoryInstance
- the implementation instances to add
-