use of cn.taketoday.test.context.ContextCustomizer in project today-infrastructure by TAKETODAY.
the class ApplicationContextLoader method getInitializers.
/**
* Return the {@link ApplicationContextInitializer initializers} that will be applied
* to the context. By default this method will adapt {@link ContextCustomizer context
* customizers}, add {@link Application#getInitializers() application
* initializers} and add
* {@link MergedContextConfiguration#getContextInitializerClasses() initializers
* specified on the test}.
*
* @param config the source context configuration
* @param application the application instance
* @return the initializers to apply
*/
protected List<ApplicationContextInitializer> getInitializers(MergedContextConfiguration config, Application application) {
List<ApplicationContextInitializer> initializers = new ArrayList<>();
for (ContextCustomizer contextCustomizer : config.getContextCustomizers()) {
initializers.add(new ContextCustomizerAdapter(contextCustomizer, config));
}
initializers.addAll(application.getInitializers());
for (Class<? extends ApplicationContextInitializer> initializerClass : config.getContextInitializerClasses()) {
initializers.add(BeanUtils.newInstance(initializerClass));
}
if (config.getParent() != null) {
initializers.add(new ParentContextApplicationContextInitializer(config.getParentApplicationContext()));
}
return initializers;
}
use of cn.taketoday.test.context.ContextCustomizer in project today-framework by TAKETODAY.
the class ApplicationContextLoader method getInitializers.
/**
* Return the {@link ApplicationContextInitializer initializers} that will be applied
* to the context. By default this method will adapt {@link ContextCustomizer context
* customizers}, add {@link Application#getInitializers() application
* initializers} and add
* {@link MergedContextConfiguration#getContextInitializerClasses() initializers
* specified on the test}.
*
* @param config the source context configuration
* @param application the application instance
* @return the initializers to apply
*/
protected List<ApplicationContextInitializer> getInitializers(MergedContextConfiguration config, Application application) {
List<ApplicationContextInitializer> initializers = new ArrayList<>();
for (ContextCustomizer contextCustomizer : config.getContextCustomizers()) {
initializers.add(new ContextCustomizerAdapter(contextCustomizer, config));
}
initializers.addAll(application.getInitializers());
for (Class<? extends ApplicationContextInitializer> initializerClass : config.getContextInitializerClasses()) {
initializers.add(BeanUtils.newInstance(initializerClass));
}
if (config.getParent() != null) {
initializers.add(new ParentContextApplicationContextInitializer(config.getParentApplicationContext()));
}
return initializers;
}
Aggregations