Java Code Examples for org.springframework.test.context.ContextCustomizerFactory

The following examples show how to use org.springframework.test.context.ContextCustomizerFactory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private Set<ContextCustomizer> getContextCustomizers(Class<?> testClass,
		List<ContextConfigurationAttributes> configAttributes) {

	List<ContextCustomizerFactory> factories = getContextCustomizerFactories();
	Set<ContextCustomizer> customizers = new LinkedHashSet<>(factories.size());
	for (ContextCustomizerFactory factory : factories) {
		ContextCustomizer customizer = factory.createContextCustomizer(testClass, configAttributes);
		if (customizer != null) {
			customizers.add(customizer);
		}
	}
	return customizers;
}
 
Example 2
@Override
protected List<ContextCustomizerFactory> getContextCustomizerFactories() {
	return singletonList(
		(ContextCustomizerFactory) (testClass, configAttributes) ->
			(ContextCustomizer) (context, mergedConfig) -> context.getBeanFactory().registerSingleton("foo", "foo")
	);
}
 
Example 3
private Set<ContextCustomizer> getContextCustomizers(Class<?> testClass,
		List<ContextConfigurationAttributes> configAttributes) {

	List<ContextCustomizerFactory> factories = getContextCustomizerFactories();
	Set<ContextCustomizer> customizers = new LinkedHashSet<>(factories.size());
	for (ContextCustomizerFactory factory : factories) {
		ContextCustomizer customizer = factory.createContextCustomizer(testClass, configAttributes);
		if (customizer != null) {
			customizers.add(customizer);
		}
	}
	return customizers;
}
 
Example 4
@Override
protected List<ContextCustomizerFactory> getContextCustomizerFactories() {
	return singletonList(
		(ContextCustomizerFactory) (testClass, configAttributes) ->
			(ContextCustomizer) (context, mergedConfig) -> context.getBeanFactory().registerSingleton("foo", "foo")
	);
}
 
Example 5
Source Project: spring-analysis-note   Source File: BootstrapWithTestInterface.java    License: MIT License 4 votes vote down vote up
@Override
protected List<ContextCustomizerFactory> getContextCustomizerFactories() {
	return singletonList(
		(ContextCustomizerFactory) (testClass, configAttributes) -> (ContextCustomizer) (context,
				mergedConfig) -> context.getBeanFactory().registerSingleton("foo", "foo"));
}
 
Example 6
Source Project: java-technology-stack   Source File: BootstrapWithTestInterface.java    License: MIT License 4 votes vote down vote up
@Override
protected List<ContextCustomizerFactory> getContextCustomizerFactories() {
	return singletonList(
		(ContextCustomizerFactory) (testClass, configAttributes) -> (ContextCustomizer) (context,
				mergedConfig) -> context.getBeanFactory().registerSingleton("foo", "foo"));
}
 
Example 7
/**
 * Get the {@link ContextCustomizerFactory} instances for this bootstrapper.
 * <p>The default implementation uses the {@link SpringFactoriesLoader} mechanism
 * for loading factories configured in all {@code META-INF/spring.factories}
 * files on the classpath.
 * @since 4.3
 * @see SpringFactoriesLoader#loadFactories
 */
protected List<ContextCustomizerFactory> getContextCustomizerFactories() {
	return SpringFactoriesLoader.loadFactories(ContextCustomizerFactory.class, getClass().getClassLoader());
}
 
Example 8
/**
 * Get the {@link ContextCustomizerFactory} instances for this bootstrapper.
 * <p>The default implementation uses the {@link SpringFactoriesLoader} mechanism
 * for loading factories configured in all {@code META-INF/spring.factories}
 * files on the classpath.
 * @since 4.3
 * @see SpringFactoriesLoader#loadFactories
 */
protected List<ContextCustomizerFactory> getContextCustomizerFactories() {
	return SpringFactoriesLoader.loadFactories(ContextCustomizerFactory.class, getClass().getClassLoader());
}