Skip to content

Commit 69d87f1

Browse files
committed
Reorganize internals of DefaultCacheAwareContextLoaderDelegate
1 parent 38f9479 commit 69d87f1

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -73,40 +73,6 @@ public DefaultCacheAwareContextLoaderDelegate(ContextCache contextCache) {
7373
this.contextCache = contextCache;
7474
}
7575

76-
/**
77-
* Get the {@link ContextCache} used by this context loader delegate.
78-
*/
79-
protected ContextCache getContextCache() {
80-
return this.contextCache;
81-
}
82-
83-
/**
84-
* Load the {@code ApplicationContext} for the supplied merged context configuration.
85-
* <p>Supports both the {@link SmartContextLoader} and {@link ContextLoader} SPIs.
86-
* @throws Exception if an error occurs while loading the application context
87-
*/
88-
protected ApplicationContext loadContextInternal(MergedContextConfiguration mergedContextConfiguration)
89-
throws Exception {
90-
91-
ContextLoader contextLoader = mergedContextConfiguration.getContextLoader();
92-
Assert.notNull(contextLoader, "Cannot load an ApplicationContext with a NULL 'contextLoader'. " +
93-
"Consider annotating your test class with @ContextConfiguration or @ContextHierarchy.");
94-
95-
ApplicationContext applicationContext;
96-
97-
if (contextLoader instanceof SmartContextLoader) {
98-
SmartContextLoader smartContextLoader = (SmartContextLoader) contextLoader;
99-
applicationContext = smartContextLoader.loadContext(mergedContextConfiguration);
100-
}
101-
else {
102-
String[] locations = mergedContextConfiguration.getLocations();
103-
Assert.notNull(locations, "Cannot load an ApplicationContext with a NULL 'locations' array. " +
104-
"Consider annotating your test class with @ContextConfiguration or @ContextHierarchy.");
105-
applicationContext = contextLoader.loadContext(locations);
106-
}
107-
108-
return applicationContext;
109-
}
11076

11177
@Override
11278
public boolean isContextLoaded(MergedContextConfiguration mergedContextConfiguration) {
@@ -152,4 +118,34 @@ public void closeContext(MergedContextConfiguration mergedContextConfiguration,
152118
}
153119
}
154120

121+
/**
122+
* Get the {@link ContextCache} used by this context loader delegate.
123+
*/
124+
protected ContextCache getContextCache() {
125+
return this.contextCache;
126+
}
127+
128+
/**
129+
* Load the {@code ApplicationContext} for the supplied merged context configuration.
130+
* <p>Supports both the {@link SmartContextLoader} and {@link ContextLoader} SPIs.
131+
* @throws Exception if an error occurs while loading the application context
132+
*/
133+
protected ApplicationContext loadContextInternal(MergedContextConfiguration mergedContextConfiguration)
134+
throws Exception {
135+
136+
ContextLoader contextLoader = mergedContextConfiguration.getContextLoader();
137+
Assert.notNull(contextLoader, "Cannot load an ApplicationContext with a NULL 'contextLoader'. " +
138+
"Consider annotating your test class with @ContextConfiguration or @ContextHierarchy.");
139+
140+
if (contextLoader instanceof SmartContextLoader) {
141+
return ((SmartContextLoader) contextLoader).loadContext(mergedContextConfiguration);
142+
}
143+
else {
144+
String[] locations = mergedContextConfiguration.getLocations();
145+
Assert.notNull(locations, "Cannot load an ApplicationContext with a NULL 'locations' array. " +
146+
"Consider annotating your test class with @ContextConfiguration or @ContextHierarchy.");
147+
return contextLoader.loadContext(locations);
148+
}
149+
}
150+
155151
}

0 commit comments

Comments
 (0)