|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -73,40 +73,6 @@ public DefaultCacheAwareContextLoaderDelegate(ContextCache contextCache) {
|
73 | 73 | this.contextCache = contextCache;
|
74 | 74 | }
|
75 | 75 |
|
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 |
| - } |
110 | 76 |
|
111 | 77 | @Override
|
112 | 78 | public boolean isContextLoaded(MergedContextConfiguration mergedContextConfiguration) {
|
@@ -152,4 +118,34 @@ public void closeContext(MergedContextConfiguration mergedContextConfiguration,
|
152 | 118 | }
|
153 | 119 | }
|
154 | 120 |
|
| 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 | + |
155 | 151 | }
|
0 commit comments