From b904a859043d9e5d3537af3206c2809aaace9bcb Mon Sep 17 00:00:00 2001 From: Maciej Miklas Date: Mon, 17 Aug 2020 14:10:49 +0200 Subject: [PATCH] createContext() for AbstractGenericContextLoader --- .../support/AbstractGenericContextLoader.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 8cefc456fb03..5729a02c580e 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 final ConfigurableApplicationContext loadContext(MergedContextConfigurati validateMergedContextConfiguration(mergedConfig); - GenericApplicationContext context = new GenericApplicationContext(); + GenericApplicationContext context = createContext(); ApplicationContext parent = mergedConfig.getParentApplicationContext(); if (parent != null) { @@ -130,6 +130,15 @@ public final ConfigurableApplicationContext loadContext(MergedContextConfigurati 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 final ConfigurableApplicationContext loadContext(String... locations) thr 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);