Merge branch '5.3.x'
# Conflicts: # spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java
This commit is contained in:
commit
a9466437c8
|
|
@ -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
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
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) {
|
|
||||||
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,35 @@ 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
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
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 smartContextLoader) {
|
||||||
|
return 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.");
|
||||||
|
return contextLoader.loadContext(locations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -241,9 +241,10 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
|
||||||
* Factory method for creating the {@link GenericApplicationContext} used by
|
* Factory method for creating the {@link GenericApplicationContext} used by
|
||||||
* this {@code ContextLoader}.
|
* this {@code ContextLoader}.
|
||||||
* <p>The default implementation creates a {@code GenericApplicationContext}
|
* <p>The default implementation creates a {@code GenericApplicationContext}
|
||||||
* using the default constructor. This method may get overridden e.g. to use
|
* using the default constructor. This method may be overridden — for
|
||||||
* a custom context subclass or to create a {@code GenericApplicationContext}
|
* example, to use a custom context subclass or to create a
|
||||||
* with a custom {@link DefaultListableBeanFactory} implementation.
|
* {@code GenericApplicationContext} with a custom
|
||||||
|
* {@link DefaultListableBeanFactory} implementation.
|
||||||
* @return a newly instantiated {@code GenericApplicationContext}
|
* @return a newly instantiated {@code GenericApplicationContext}
|
||||||
* @since 5.2.9
|
* @since 5.2.9
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
|
||||||
|
|
||||||
validateMergedContextConfiguration(webMergedConfig);
|
validateMergedContextConfiguration(webMergedConfig);
|
||||||
|
|
||||||
GenericWebApplicationContext context = new GenericWebApplicationContext();
|
GenericWebApplicationContext context = createContext();
|
||||||
|
|
||||||
ApplicationContext parent = mergedConfig.getParentApplicationContext();
|
ApplicationContext parent = mergedConfig.getParentApplicationContext();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
|
|
@ -192,6 +192,21 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory method for creating the {@link GenericWebApplicationContext} used
|
||||||
|
* by this {@code ContextLoader}.
|
||||||
|
* <p>The default implementation creates a {@code GenericWebApplicationContext}
|
||||||
|
* using the default constructor. This method may be overridden — for
|
||||||
|
* example, to use a custom context subclass or to create a
|
||||||
|
* {@code GenericWebApplicationContext} with a custom
|
||||||
|
* {@link DefaultListableBeanFactory} implementation.
|
||||||
|
* @return a newly instantiated {@code GenericWebApplicationContext}
|
||||||
|
* @since 5.2.23
|
||||||
|
*/
|
||||||
|
protected GenericWebApplicationContext createContext() {
|
||||||
|
return new GenericWebApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures web resources for the supplied web application context (WAC).
|
* Configures web resources for the supplied web application context (WAC).
|
||||||
* <h4>Implementation Details</h4>
|
* <h4>Implementation Details</h4>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue