From 75a721d1019da2a2fa86e24ff439df4a224e5b19 Mon Sep 17 00:00:00 2001 From: Emmanuel Bourg Date: Wed, 3 Aug 2016 19:55:01 +0200 Subject: Imported Upstream version 4.3.2 --- .../support/AbstractDelegatingSmartContextLoader.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java') diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java b/spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java index ca60c8dd..c0ae608e 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AbstractDelegatingSmartContextLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import org.springframework.test.context.ContextLoader; import org.springframework.test.context.MergedContextConfiguration; import org.springframework.test.context.SmartContextLoader; import org.springframework.util.Assert; -import org.springframework.util.ObjectUtils; /** * {@code AbstractDelegatingSmartContextLoader} serves as an abstract base class @@ -202,15 +201,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte name(getAnnotationConfigLoader()), configAttributes)); } - // If neither loader detected defaults and no initializers were declared, - // throw an exception. - if (!configAttributes.hasResources() && ObjectUtils.isEmpty(configAttributes.getInitializers())) { - throw new IllegalStateException(String.format( - "Neither %s nor %s was able to detect defaults, and no ApplicationContextInitializers " - + "were declared for context configuration %s", name(getXmlLoader()), - name(getAnnotationConfigLoader()), configAttributes)); - } - if (configAttributes.hasLocations() && configAttributes.hasClasses()) { String message = String.format( "Configuration error: both default locations AND default configuration classes " @@ -263,8 +253,9 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte } // If neither of the candidates supports the mergedConfig based on resources but - // ACIs were declared, then delegate to the annotation config loader. - if (!mergedConfig.getContextInitializerClasses().isEmpty()) { + // ACIs or customizers were declared, then delegate to the annotation config + // loader. + if (!mergedConfig.getContextInitializerClasses().isEmpty() || !mergedConfig.getContextCustomizers().isEmpty()) { return delegateLoading(getAnnotationConfigLoader(), mergedConfig); } -- cgit v1.2.3