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 SpringFactoriesLoader
SpringFactoriesLoader.ArgumentResolver, SpringFactoriesLoader.FailureHandler -
Field Summary
Fields inherited from class SpringFactoriesLoader
FACTORIES_RESOURCE_LOCATION -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate a newMockSpringFactoriesLoaderinstance with the default classloader.MockSpringFactoriesLoader(@Nullable ClassLoader classLoader) Create a newMockSpringFactoriesLoaderinstance with the given classloader.protectedMockSpringFactoriesLoader(@Nullable ClassLoader classLoader, Map<String, List<String>> factories) -
Method Summary
Modifier and TypeMethodDescriptionfinal <T> voidAdd factory implementations to this instance.voidAdd factory implementations to this instance.<T> voidaddInstance(Class<T> factoryType, T... factoryInstances) Add factory instances to this instance.<T> voidaddInstance(String factoryType, T... factoryInstance) Add factory instances to this instance.protected <T> @Nullable TinstantiateFactory(String implementationName, Class<T> type, @Nullable SpringFactoriesLoader.ArgumentResolver argumentResolver, SpringFactoriesLoader.FailureHandler failureHandler) Methods inherited from class SpringFactoriesLoader
forDefaultResourceLocation, forDefaultResourceLocation, forResourceLocation, forResourceLocation, load, load, load, load, loadFactories, loadFactoriesResource, loadFactoryNames
-
Constructor Details
-
MockSpringFactoriesLoader
public MockSpringFactoriesLoader()Create a newMockSpringFactoriesLoaderinstance with the default classloader. -
MockSpringFactoriesLoader
Create a newMockSpringFactoriesLoaderinstance with the given classloader.- Parameters:
classLoader- the classloader to use
-
MockSpringFactoriesLoader
-
-
Method Details
-
instantiateFactory
protected <T> @Nullable T instantiateFactory(String implementationName, Class<T> type, @Nullable SpringFactoriesLoader.ArgumentResolver argumentResolver, SpringFactoriesLoader.FailureHandler failureHandler) - Overrides:
instantiateFactoryin 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
-
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
-