|
79 | 79 | */ |
80 | 80 | public abstract class AbstractTestContextBootstrapper implements TestContextBootstrapper { |
81 | 81 |
|
| 82 | + private static final String IGNORED_DEFAULT_CONFIG_MESSAGE = """ |
| 83 | + For test class [%1$s], the following 'default' context configuration %2$s were detected \ |
| 84 | + but are currently ignored: %3$s. In Spring Framework 7.1, these %2$s will no longer be ignored. \ |
| 85 | + Please update your test configuration accordingly. For details, see: \ |
| 86 | + https://docs.spring.io/spring-framework/reference/testing/testcontext-framework/ctx-management/default-config.html"""; |
| 87 | + |
| 88 | + |
82 | 89 | private final Log logger = LogFactory.getLog(getClass()); |
83 | 90 |
|
84 | 91 | private @Nullable BootstrapContext bootstrapContext; |
@@ -290,28 +297,25 @@ private void logWarningForIgnoredDefaultConfig(MergedContextConfiguration merged |
290 | 297 | MergedContextConfiguration completeMergedConfig = buildMergedContextConfiguration( |
291 | 298 | testClass, completeDefaultConfigAttributesList, contextLoader, null, |
292 | 299 | cacheAwareContextLoaderDelegate, false); |
293 | | - if (!mergedConfig.equals(completeMergedConfig)) { |
294 | | - String warningMessage = """ |
295 | | - For test class [%1$s], the following 'default' context configuration %2$s were \ |
296 | | - detected but are currently ignored: %3$s. In Spring Framework 7.1, these %2$s will no \ |
297 | | - longer be ignored. Please update your test configuration accordingly. For details, see: \ |
298 | | - https://docs.spring.io/spring-framework/reference/testing/testcontext-framework/ctx-management/default-config.html"""; |
299 | 300 |
|
| 301 | + if (!Arrays.equals(mergedConfig.getClasses(), completeMergedConfig.getClasses())) { |
300 | 302 | Set<Class<?>> currentClasses = new HashSet<>(Arrays.asList(mergedConfig.getClasses())); |
301 | 303 | String ignoredClasses = Arrays.stream(completeMergedConfig.getClasses()) |
302 | 304 | .filter(clazz -> !currentClasses.contains(clazz)) |
303 | 305 | .map(Class::getName) |
304 | 306 | .collect(Collectors.joining(", ")); |
305 | 307 | if (!ignoredClasses.isEmpty()) { |
306 | | - logger.warn(warningMessage.formatted(testClass.getName(), "classes", ignoredClasses)); |
| 308 | + logger.warn(IGNORED_DEFAULT_CONFIG_MESSAGE.formatted(testClass.getName(), "classes", ignoredClasses)); |
307 | 309 | } |
| 310 | + } |
308 | 311 |
|
| 312 | + if (!Arrays.equals(mergedConfig.getLocations(), completeMergedConfig.getLocations())) { |
309 | 313 | Set<String> currentLocations = new HashSet<>(Arrays.asList(mergedConfig.getLocations())); |
310 | 314 | String ignoredLocations = Arrays.stream(completeMergedConfig.getLocations()) |
311 | 315 | .filter(location -> !currentLocations.contains(location)) |
312 | 316 | .collect(Collectors.joining(", ")); |
313 | 317 | if (!ignoredLocations.isEmpty()) { |
314 | | - logger.warn(warningMessage.formatted(testClass.getName(), "locations", ignoredLocations)); |
| 318 | + logger.warn(IGNORED_DEFAULT_CONFIG_MESSAGE.formatted(testClass.getName(), "locations", ignoredLocations)); |
315 | 319 | } |
316 | 320 | } |
317 | 321 | } |
|
0 commit comments