001/* 002 * Copyright 2002-2016 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.test.context; 018 019import java.util.List; 020 021import org.springframework.lang.Nullable; 022 023/** 024 * Factory for creating {@link ContextCustomizer ContextCustomizers}. 025 * 026 * <p>Factories are invoked after {@link ContextLoader ContextLoaders} have 027 * processed context configuration attributes but before the 028 * {@link MergedContextConfiguration} is created. 029 * 030 * <p>By default, the Spring TestContext Framework will use the 031 * {@link org.springframework.core.io.support.SpringFactoriesLoader SpringFactoriesLoader} 032 * mechanism for loading factories configured in all {@code META-INF/spring.factories} 033 * files on the classpath. 034 * 035 * @author Phillip Webb 036 * @author Sam Brannen 037 * @since 4.3 038 */ 039@FunctionalInterface 040public interface ContextCustomizerFactory { 041 042 /** 043 * Create a {@link ContextCustomizer} that should be used to customize a 044 * {@link org.springframework.context.ConfigurableApplicationContext ConfigurableApplicationContext} 045 * before it is refreshed. 046 * @param testClass the test class 047 * @param configAttributes the list of context configuration attributes for 048 * the test class, ordered <em>bottom-up</em> (i.e., as if we were traversing 049 * up the class hierarchy); never {@code null} or empty 050 * @return a {@link ContextCustomizer} or {@code null} if no customizer should 051 * be used 052 */ 053 @Nullable 054 ContextCustomizer createContextCustomizer(Class<?> testClass, List<ContextConfigurationAttributes> configAttributes); 055 056}