diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java b/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java
index fd584ee5bd..516c489b40 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java
@@ -168,13 +168,13 @@ public class ContextConfigurationAttributes {
/**
* Determine if this {@code ContextConfigurationAttributes} instance has
* either path-based resource locations or class-based resources.
- * @return true
if neither the {@link #getLocations() locations}
- * nor the {@link #getClasses() classes} array is empty
+ * @return true
if either the {@link #getLocations() locations}
+ * or the {@link #getClasses() classes} array is not empty
* @see #getLocations()
* @see #getClasses()
*/
public boolean hasResources() {
- return !ObjectUtils.isEmpty(getLocations()) && !ObjectUtils.isEmpty(getClasses());
+ return !ObjectUtils.isEmpty(getLocations()) || !ObjectUtils.isEmpty(getClasses());
}
/**
diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/support/DelegatingSmartContextLoader.java b/org.springframework.test/src/main/java/org/springframework/test/context/support/DelegatingSmartContextLoader.java
index 124b9985c9..2be4a49a06 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/support/DelegatingSmartContextLoader.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/support/DelegatingSmartContextLoader.java
@@ -91,7 +91,7 @@ public class DelegatingSmartContextLoader implements SmartContextLoader {
// If any loader claims to generate defaults but none actually did,
// throw an exception.
- if (originallyHadResources && generatesDefaults() && !configAttributes.hasResources()) {
+ if (generatesDefaults() && !originallyHadResources && !configAttributes.hasResources()) {
throw new IllegalStateException(String.format("None of the SmartContextLoader candidates %s "
+ "was able to generate defaults for context configuration [%s].", candidates, configAttributes));
}