diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AbstractGenericContextLoader.java b/spring-test/src/main/java/org/springframework/test/context/support/AbstractGenericContextLoader.java index 8cefc456fb..5729a02c58 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AbstractGenericContextLoader.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AbstractGenericContextLoader.java @@ -112,7 +112,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader validateMergedContextConfiguration(mergedConfig); - GenericApplicationContext context = new GenericApplicationContext(); + GenericApplicationContext context = createContext(); ApplicationContext parent = mergedConfig.getParentApplicationContext(); if (parent != null) { @@ -130,6 +130,15 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader return context; } + /** + * Creates instance of application context used by this {@code ContextLoader} + * + * @return new Instance of application context + */ + protected GenericApplicationContext createContext() { + return new GenericApplicationContext(); + } + /** * Validate the supplied {@link MergedContextConfiguration} with respect to * what this context loader supports. @@ -184,7 +193,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader logger.debug(String.format("Loading ApplicationContext for locations [%s].", StringUtils.arrayToCommaDelimitedString(locations))); } - GenericApplicationContext context = new GenericApplicationContext(); + GenericApplicationContext context = createContext(); prepareContext(context); customizeBeanFactory(context.getDefaultListableBeanFactory()); createBeanDefinitionReader(context).loadBeanDefinitions(locations);