|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -73,40 +73,6 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext |
|
|
|
this.contextCache = contextCache; |
|
|
|
this.contextCache = contextCache; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the {@link ContextCache} used by this context loader delegate. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected ContextCache getContextCache() { |
|
|
|
|
|
|
|
return this.contextCache; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Load the {@code ApplicationContext} for the supplied merged context configuration. |
|
|
|
|
|
|
|
* <p>Supports both the {@link SmartContextLoader} and {@link ContextLoader} SPIs. |
|
|
|
|
|
|
|
* @throws Exception if an error occurs while loading the application context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected ApplicationContext loadContextInternal(MergedContextConfiguration mergedContextConfiguration) |
|
|
|
|
|
|
|
throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ContextLoader contextLoader = mergedContextConfiguration.getContextLoader(); |
|
|
|
|
|
|
|
Assert.notNull(contextLoader, "Cannot load an ApplicationContext with a NULL 'contextLoader'. " + |
|
|
|
|
|
|
|
"Consider annotating your test class with @ContextConfiguration or @ContextHierarchy."); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationContext applicationContext; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (contextLoader instanceof SmartContextLoader) { |
|
|
|
|
|
|
|
SmartContextLoader smartContextLoader = (SmartContextLoader) contextLoader; |
|
|
|
|
|
|
|
applicationContext = smartContextLoader.loadContext(mergedContextConfiguration); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
String[] locations = mergedContextConfiguration.getLocations(); |
|
|
|
|
|
|
|
Assert.notNull(locations, "Cannot load an ApplicationContext with a NULL 'locations' array. " + |
|
|
|
|
|
|
|
"Consider annotating your test class with @ContextConfiguration or @ContextHierarchy."); |
|
|
|
|
|
|
|
applicationContext = contextLoader.loadContext(locations); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return applicationContext; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean isContextLoaded(MergedContextConfiguration mergedContextConfiguration) { |
|
|
|
public boolean isContextLoaded(MergedContextConfiguration mergedContextConfiguration) { |
|
|
|
@ -152,4 +118,34 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the {@link ContextCache} used by this context loader delegate. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected ContextCache getContextCache() { |
|
|
|
|
|
|
|
return this.contextCache; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Load the {@code ApplicationContext} for the supplied merged context configuration. |
|
|
|
|
|
|
|
* <p>Supports both the {@link SmartContextLoader} and {@link ContextLoader} SPIs. |
|
|
|
|
|
|
|
* @throws Exception if an error occurs while loading the application context |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected ApplicationContext loadContextInternal(MergedContextConfiguration mergedContextConfiguration) |
|
|
|
|
|
|
|
throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ContextLoader contextLoader = mergedContextConfiguration.getContextLoader(); |
|
|
|
|
|
|
|
Assert.notNull(contextLoader, "Cannot load an ApplicationContext with a NULL 'contextLoader'. " + |
|
|
|
|
|
|
|
"Consider annotating your test class with @ContextConfiguration or @ContextHierarchy."); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (contextLoader instanceof SmartContextLoader) { |
|
|
|
|
|
|
|
return ((SmartContextLoader) contextLoader).loadContext(mergedContextConfiguration); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
String[] locations = mergedContextConfiguration.getLocations(); |
|
|
|
|
|
|
|
Assert.notNull(locations, "Cannot load an ApplicationContext with a NULL 'locations' array. " + |
|
|
|
|
|
|
|
"Consider annotating your test class with @ContextConfiguration or @ContextHierarchy."); |
|
|
|
|
|
|
|
return contextLoader.loadContext(locations); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|